aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-30 14:58:26 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-30 14:58:26 -0400
commit21de9d46e264ceb14f3fe59d17210d82f2499637 (patch)
tree225afa4993f268fc867d922e646f0449cedebf1c /src/common/compat.h
parent5dc3c462dcf42488055685e7f4fdb4a1a48003f1 (diff)
parentda7c60dcf310fb9914bfd1b84a34b440ab04900a (diff)
downloadtor-21de9d46e264ceb14f3fe59d17210d82f2499637.tar
tor-21de9d46e264ceb14f3fe59d17210d82f2499637.tar.gz
Merge remote-tracking branch 'origin/maint-0.2.2'
Conflicts: src/common/compat.c src/or/main.c
Diffstat (limited to 'src/common/compat.h')
-rw-r--r--src/common/compat.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/common/compat.h b/src/common/compat.h
index a317ea45c..094036dff 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -395,9 +395,18 @@ int tor_fd_seekend(int fd);
typedef int socklen_t;
#endif
-int tor_close_socket(int s);
-int tor_open_socket(int domain, int type, int protocol);
-int tor_accept_socket(int sockfd, struct sockaddr *addr, socklen_t *len);
+#ifdef MS_WINDOWS
+#define tor_socket_t intptr_t
+#define SOCKET_OK(s) ((s) != INVALID_SOCKET)
+#else
+#define tor_socket_t int
+#define SOCKET_OK(s) ((s) >= 0)
+#endif
+
+int tor_close_socket(tor_socket_t s);
+tor_socket_t tor_open_socket(int domain, int type, int protocol);
+tor_socket_t tor_accept_socket(int sockfd, struct sockaddr *addr,
+ socklen_t *len);
int get_n_open_sockets(void);
#define tor_socket_send(s, buf, len, flags) send(s, buf, len, flags)
@@ -469,8 +478,8 @@ int tor_inet_aton(const char *cp, struct in_addr *addr) ATTR_NONNULL((1,2));
const char *tor_inet_ntop(int af, const void *src, char *dst, size_t len);
int tor_inet_pton(int af, const char *src, void *dst);
int tor_lookup_hostname(const char *name, uint32_t *addr) ATTR_NONNULL((1,2));
-void set_socket_nonblocking(int socket);
-int tor_socketpair(int family, int type, int protocol, int fd[2]);
+void set_socket_nonblocking(tor_socket_t socket);
+int tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2]);
int network_init(void);
/* For stupid historical reasons, windows sockets have an independent
@@ -497,7 +506,7 @@ int network_init(void);
((e) == WSAEMFILE || (e) == WSAENOBUFS)
/** Return true if e is EADDRINUSE or the local equivalent. */
#define ERRNO_IS_EADDRINUSE(e) ((e) == WSAEADDRINUSE)
-int tor_socket_errno(int sock);
+int tor_socket_errno(tor_socket_t sock);
const char *tor_socket_strerror(int e);
#else
#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN)