tor  0.4.2.0-alpha-dev
nettypes.h
Go to the documentation of this file.
1 /* Copyright (c) 2003-2004, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
11 #ifndef TOR_NET_TYPES_H
12 #define TOR_NET_TYPES_H
13 
14 #include "orconfig.h"
15 #ifdef HAVE_SYS_TYPES_H
16 #include <sys/types.h>
17 #endif
18 #ifdef HAVE_SYS_SOCKET_H
19 #include <sys/socket.h>
20 #endif
21 
22 #if (SIZEOF_SOCKLEN_T == 0)
23 typedef int socklen_t;
24 #endif
25 
26 #ifdef _WIN32
27 /* XXX Actually, this should arguably be SOCKET; we use intptr_t here so that
28  * any inadvertent checks for the socket being <= 0 or > 0 will probably
29  * still work. */
30 #define tor_socket_t intptr_t
31 #define TOR_SOCKET_T_FORMAT "%"PRIuPTR
32 #define SOCKET_OK(s) ((SOCKET)(s) != INVALID_SOCKET)
33 #define TOR_INVALID_SOCKET INVALID_SOCKET
34 #else /* !(defined(_WIN32)) */
35 
36 #define tor_socket_t int
37 #define TOR_SOCKET_T_FORMAT "%d"
38 
39 #define SOCKET_OK(s) ((s) >= 0)
40 
41 #define TOR_INVALID_SOCKET (-1)
42 #endif /* defined(_WIN32) */
43 
44 #endif /* !defined(TOR_NET_TYPES_H) */