Consistently use the _WIN32 #define.

The _WIN32 variant is available pretty much on all compilers, others
might not be. G_OS_WIN32 would probably be an equally well-suited
alternative, but for now we standardize on _WIN32.

  http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system#WindowswithCygwinPOSIX
This commit is contained in:
Uwe Hermann 2018-09-01 21:11:45 +02:00
parent 9be587a148
commit 00f0016cc3
5 changed files with 9 additions and 13 deletions

View File

@ -23,19 +23,15 @@
#define _WIN32_WINNT 0x0501 #define _WIN32_WINNT 0x0501
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#endif #else
#include <string.h>
#include <unistd.h>
#ifndef _WIN32
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif #endif
#include <string.h>
#include <unistd.h>
#include <errno.h> #include <errno.h>
#include "protocol.h" #include "protocol.h"
@ -69,7 +65,7 @@
static gboolean data_available(struct ipdbg_la_tcp *tcp) static gboolean data_available(struct ipdbg_la_tcp *tcp)
{ {
#ifdef __WIN32__ #ifdef _WIN32
u_long bytes_available; u_long bytes_available;
ioctlsocket(tcp->socket, FIONREAD, &bytes_available); ioctlsocket(tcp->socket, FIONREAD, &bytes_available);
return (bytes_available > 0); return (bytes_available > 0);

View File

@ -745,7 +745,7 @@ struct drv_context {
/*--- log.c -----------------------------------------------------------------*/ /*--- log.c -----------------------------------------------------------------*/
#if defined(G_OS_WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) #if defined(_WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
/* /*
* On MinGW, we need to specify the gnu_printf format flavor or GCC * On MinGW, we need to specify the gnu_printf format flavor or GCC
* will assume non-standard Microsoft printf syntax. * will assume non-standard Microsoft printf syntax.

View File

@ -28,7 +28,7 @@
#include <libserialport.h> #include <libserialport.h>
#include <libsigrok/libsigrok.h> #include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h" #include "libsigrok-internal.h"
#ifdef G_OS_WIN32 #ifdef _WIN32
#include <windows.h> /* for HANDLE */ #include <windows.h> /* for HANDLE */
#endif #endif
@ -788,7 +788,7 @@ SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_devic
} }
/** @cond PRIVATE */ /** @cond PRIVATE */
#ifdef G_OS_WIN32 #ifdef _WIN32
typedef HANDLE event_handle; typedef HANDLE event_handle;
#else #else
typedef int event_handle; typedef int event_handle;

View File

@ -1294,7 +1294,7 @@ SR_PRIV int sr_session_source_add_channel(struct sr_session *session,
/* We should be using g_io_create_watch(), but can't without /* We should be using g_io_create_watch(), but can't without
* changing the driver API, as the callback signature is different. * changing the driver API, as the callback signature is different.
*/ */
#ifdef G_OS_WIN32 #ifdef _WIN32
g_io_channel_win32_make_pollfd(channel, events, &pollfd); g_io_channel_win32_make_pollfd(channel, events, &pollfd);
#else #else
pollfd.fd = g_io_channel_unix_get_fd(channel); pollfd.fd = g_io_channel_unix_get_fd(channel);

View File

@ -184,7 +184,7 @@ static LIBUSB_CALL void usb_pollfd_added(libusb_os_handle fd,
return; return;
pollfd = g_slice_new(GPollFD); pollfd = g_slice_new(GPollFD);
#ifdef G_OS_WIN32 #ifdef _WIN32
events = G_IO_IN; events = G_IO_IN;
#endif #endif
pollfd->fd = (gintptr)fd; pollfd->fd = (gintptr)fd;