summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-04-17 14:01:08 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-04-17 14:23:29 +0100
commit67b759c759855c31ad358b5566aa5e3b2a83aaa3 (patch)
treea4dc43fb527a41331bff70826900dbfce19e9230
parente03ac13e369131de9e0f2d0aa56dfbdd60c1bf9d (diff)
DBusSocket: put the #ifdef case before the !defined casedbussocket
This avoids the confusing #ifndef...#else anti-pattern.
-rw-r--r--dbus/dbus-sysdeps.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index 615950b7..f6a2948e 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -125,43 +125,43 @@ typedef unsigned long dbus_gid_t;
/**
* Socket interface
*/
-#ifndef DBUS_WIN
+#ifdef DBUS_WIN
-typedef struct { int fd; } DBusSocket;
-# define DBUS_SOCKET_FORMAT "d"
-# define DBUS_SOCKET_INIT { -1 }
+typedef struct { SOCKET sock; } DBusSocket;
+# define DBUS_SOCKET_FORMAT "Iu"
+# define DBUS_SOCKET_INIT { INVALID_SOCKET }
-static inline int
-_dbus_socket_printable (DBusSocket s) { return s.fd; }
+static inline SOCKET
+_dbus_socket_printable (DBusSocket s) { return s.sock; }
static inline dbus_bool_t
-_dbus_socket_is_valid (DBusSocket s) { return s.fd >= 0; }
+_dbus_socket_is_valid (DBusSocket s) { return s.sock != INVALID_SOCKET; }
static inline void
-_dbus_socket_invalidate (DBusSocket *s) { s->fd = -1; }
+_dbus_socket_invalidate (DBusSocket *s) { s->sock = INVALID_SOCKET; }
static inline int
-_dbus_socket_get_int (DBusSocket s) { return s.fd; }
+_dbus_socket_get_int (DBusSocket s) { return (int)s.sock; }
-#else /* DBUS_WIN */
+#else /* not DBUS_WIN */
-typedef struct { SOCKET sock; } DBusSocket;
-# define DBUS_SOCKET_FORMAT "Iu"
-# define DBUS_SOCKET_INIT { INVALID_SOCKET }
+typedef struct { int fd; } DBusSocket;
+# define DBUS_SOCKET_FORMAT "d"
+# define DBUS_SOCKET_INIT { -1 }
-static inline SOCKET
-_dbus_socket_printable (DBusSocket s) { return s.sock; }
+static inline int
+_dbus_socket_printable (DBusSocket s) { return s.fd; }
static inline dbus_bool_t
-_dbus_socket_is_valid (DBusSocket s) { return s.sock != INVALID_SOCKET; }
+_dbus_socket_is_valid (DBusSocket s) { return s.fd >= 0; }
static inline void
-_dbus_socket_invalidate (DBusSocket *s) { s->sock = INVALID_SOCKET; }
+_dbus_socket_invalidate (DBusSocket *s) { s->fd = -1; }
static inline int
-_dbus_socket_get_int (DBusSocket s) { return (int)s.sock; }
+_dbus_socket_get_int (DBusSocket s) { return s.fd; }
-#endif /* DBUS_WIN */
+#endif /* not DBUS_WIN */
static inline DBusSocket
_dbus_socket_get_invalid (void)