summaryrefslogtreecommitdiff
path: root/src/common/compat.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-17 16:35:07 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-17 16:35:07 -0500
commit6e8c2a3e46e3578b0268d422b1753995d18fb734 (patch)
tree0f2952090d871b437021d2f6c6059e78234fa0f5 /src/common/compat.h
parent1e923dd2fbdc0834b8fb3ba97b658f15a6d5f6b4 (diff)
downloadtor-6e8c2a3e46e3578b0268d422b1753995d18fb734.tar.gz
tor-6e8c2a3e46e3578b0268d422b1753995d18fb734.zip
Use SOCKET_OK macros in even more places
Add a TOR_INVALID_SOCKET macro to wrap -1/INVALID_SOCKET. Partial work for bug4533.
Diffstat (limited to 'src/common/compat.h')
-rw-r--r--src/common/compat.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/compat.h b/src/common/compat.h
index 2db8107a8e..1b79565c0b 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -399,11 +399,19 @@ typedef int socklen_t;
#endif
#ifdef MS_WINDOWS
+/* XXX Actually, this should arguably be SOCKET; we use intptr_t here so that
+ * any inadvertant checks for the socket being <= 0 or > 0 will probably
+ * still work. */
#define tor_socket_t intptr_t
#define SOCKET_OK(s) ((unsigned)(s) != INVALID_SOCKET)
+#define TOR_INVALID_SOCKET INVALID_SOCKET
#else
+/** Type used for a network socket. */
#define tor_socket_t int
+/** Macro: true iff 's' is a possible value for a valid initialized socket. */
#define SOCKET_OK(s) ((s) >= 0)
+/** Error/uninitialized value for a tor_socket_t. */
+#define TOR_INVALID_SOCKET (-1)
#endif
int tor_close_socket(tor_socket_t s);