aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-05-30 14:49:49 -0400
committerNick Mathewson <nickm@torproject.org>2011-05-30 14:49:49 -0400
commitda7c60dcf310fb9914bfd1b84a34b440ab04900a (patch)
tree1a30bd8ef9e3473a45a5c72c538afceae9233412 /src/common/compat.h
parent6802499413f8efd98ad4d578e5ef937cb55c1edc (diff)
parentcfeafe5e77c9dd5587b1ec553eb1065f0bf841fd (diff)
downloadtor-da7c60dcf310fb9914bfd1b84a34b440ab04900a.tar.gz
tor-da7c60dcf310fb9914bfd1b84a34b440ab04900a.zip
Merge remote-tracking branch 'public/bug3270' into maint-0.2.2
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 e4c5f9ed23..eb79b04449 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -390,9 +390,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)
@@ -464,8 +473,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
@@ -492,7 +501,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)