]> sigrok.org Git - libsigrok.git/commitdiff
serial: On Windows, include <windows.h> for HANDLE
authorDaniel Elstner <redacted>
Thu, 10 Sep 2015 18:41:55 +0000 (20:41 +0200)
committerUwe Hermann <redacted>
Thu, 10 Sep 2015 20:42:27 +0000 (22:42 +0200)
src/serial.c

index 25e2b97b3ce63ef30e04317e50c9e3b7303462f2..b0ae07f083503ee5a615627528fdb467c223cbb6 100644 (file)
@@ -27,6 +27,9 @@
 #include <libserialport.h>
 #include <libsigrok/libsigrok.h>
 #include "libsigrok-internal.h"
+#ifdef G_OS_WIN32
+#include <windows.h> /* for HANDLE */
+#endif
 
 /** @cond PRIVATE */
 #define LOG_PREFIX "serial"
@@ -784,7 +787,7 @@ SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_devic
 }
 
 /** @cond PRIVATE */
-#ifdef _WIN32
+#ifdef G_OS_WIN32
 typedef HANDLE event_handle;
 #else
 typedef int event_handle;
@@ -814,12 +817,12 @@ SR_PRIV int serial_source_add(struct sr_session *session,
                return SR_ERR;
        }
 
-       serial->pollfds = (GPollFD *) g_malloc0(sizeof(GPollFD) * serial->event_set->count);
+       serial->pollfds = g_new0(GPollFD, serial->event_set->count);
 
        for (i = 0; i < serial->event_set->count; i++) {
 
-               serial->pollfds[i].fd = ((event_handle *) serial->event_set->handles)[i];
-
+               serial->pollfds[i].fd = (gintptr)
+                       ((event_handle *)serial->event_set->handles)[i];
                mask = serial->event_set->masks[i];
 
                if (mask & SP_EVENT_RX_READY)