21 #ifndef _tds_sysdep_private_h_
22 #define _tds_sysdep_private_h_
27 #if defined(__GNUC__) && __GNUC__ >= 3
28 #define TDS_RCSID(name, id) \
29 static const char rcsid_##name[] __attribute__ ((unused)) = id
31 #define TDS_RCSID(name, id) \
32 static const char rcsid_##name[] = id; \
33 static const void *const no_unused_##name##_warn[] = { rcsid_##name, no_unused_##name##_warn }
36 #define TDS_ADDITIONAL_SPACE 16
39 # define TDS_NOSIGNAL MSG_NOSIGNAL
41 # define TDS_NOSIGNAL 0L
57 #define READSOCKET(a,b,c) recv((a), (b), (c), TDS_NOSIGNAL)
58 #define WRITESOCKET(a,b,c) send((a), (b), (c), TDS_NOSIGNAL)
59 #define CLOSESOCKET(a) closesocket((a))
60 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (char*)(c))
62 #define select select_s
64 #define strcasecmp stricmp
65 #define strncasecmp strnicmp
67 #define getpid() _gethostid()
70 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64)
75 #define READSOCKET(a,b,c) recv((a), (char *) (b), (c), TDS_NOSIGNAL)
76 #define WRITESOCKET(a,b,c) send((a), (const char *) (b), (c), TDS_NOSIGNAL)
77 #define CLOSESOCKET(a) closesocket((a))
78 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (c))
80 int tds_socket_init(
void);
81 #define INITSOCKET() tds_socket_init()
82 void tds_socket_done(
void);
83 #define DONESOCKET() tds_socket_done()
84 #define NETDB_REENTRANT 1
86 #define TDSSOCK_EINTR WSAEINTR
87 #define TDSSOCK_EINPROGRESS WSAEWOULDBLOCK
88 #define TDSSOCK_ETIMEDOUT WSAETIMEDOUT
89 #define TDSSOCK_WOULDBLOCK(e) ((e)==WSAEWOULDBLOCK)
90 #define sock_errno WSAGetLastError()
91 #define sock_strerror(n) tds_prwsaerror(n)
96 #define strcasecmp stricmp
98 #define strncasecmp strnicmp
99 #if defined(HAVE__SNPRINTF) && !defined(HAVE_SNPRINTF)
100 #define snprintf _snprintf
107 #if defined(_WIN64) && !defined(WIN64)
111 #define TDS_SDIR_SEPARATOR "\\"
114 #if defined(__MSVCRT__) || defined(_MSC_VER)
117 #define getpid() GetCurrentProcessId()
118 #define strdup(s) _strdup(s)
119 #define unlink(f) _unlink(f)
120 #define putenv(s) _putenv(s)
122 #define fileno(f) _fileno(f)
123 #define stricmp(s1,s2) _stricmp(s1,s2)
124 #define strnicmp(s1,s2,n) _strnicmp(s1,s2,n)
130 #define sock_errno errno
133 #ifndef sock_strerror
134 #define sock_strerror(n) strerror(n)
137 #ifndef TDSSOCK_EINTR
138 #define TDSSOCK_EINTR EINTR
141 #ifndef TDSSOCK_EINPROGRESS
142 #define TDSSOCK_EINPROGRESS EINPROGRESS
145 #ifndef TDSSOCK_ETIMEDOUT
146 #define TDSSOCK_ETIMEDOUT ETIMEDOUT
149 #ifndef TDSSOCK_WOULDBLOCK
150 # if defined(EWOULDBLOCK) && EAGAIN != EWOULDBLOCK
151 # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN||(e)==EWOULDBLOCK)
153 # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN)
158 #define INITSOCKET() 0
162 #define DONESOCKET() do { } while(0)
167 # define READSOCKET(s,b,l) recv((s), (b), (l), MSG_NOSIGNAL)
169 # define READSOCKET(s,b,l) read((s), (b), (l))
175 # define WRITESOCKET(s,b,l) send((s), (b), (l), MSG_NOSIGNAL)
177 # define WRITESOCKET(s,b,l) write((s), (b), (l))
182 #define CLOSESOCKET(s) close((s))
186 #define IOCTLSOCKET(s,b,l) ioctl((s), (b), (l))
190 # define SOCKLEN_T socklen_t
193 #if !defined(__WIN32__) && !defined(_WIN32) && !defined(WIN32)
194 typedef int TDS_SYS_SOCKET;
195 #define INVALID_SOCKET -1
196 #define TDS_IS_SOCKET_INVALID(s) ((s) < 0)
198 typedef SOCKET TDS_SYS_SOCKET;
199 #define TDS_IS_SOCKET_INVALID(s) ((s) == INVALID_SOCKET)
202 #define tds_accept accept
203 #define tds_getpeername getpeername
204 #define tds_getsockopt getsockopt
205 #define tds_getsockname getsockname
206 #define tds_recvfrom recvfrom
208 #if defined(__hpux__) && SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
209 # if HAVE__XPG_ACCEPT
211 # define tds_accept _xpg_accept
214 # define tds_accept __accept
216 # if HAVE__XPG_GETPEERNAME
217 # undef tds_getpeername
218 # define tds_getpeername _xpg_getpeername
219 # elif HAVE___GETPEERNAME
220 # undef tds_getpeername
221 # define tds_getpeername __getpeername
223 # if HAVE__XPG_GETSOCKOPT
224 # undef tds_getsockopt
225 # define tds_getsockopt _xpg_getsockopt
226 # elif HAVE___GETSOCKOPT
227 # undef tds_getsockopt
228 # define tds_getsockopt __getsockopt
230 # if HAVE__XPG_GETSOCKNAME
231 # undef tds_getsockname
232 # define tds_getsockname _xpg_getsockname
233 # elif HAVE___GETSOCKNAME
234 # undef tds_getsockname
235 # define tds_getsockname __getsockname
237 # if HAVE__XPG_RECVFROM
239 # define tds_recvfrom _xpg_recvfrom
240 # elif HAVE___RECVFROM
242 # define tds_recvfrom __recvfrom
246 #ifndef TDS_SDIR_SEPARATOR
247 #define TDS_SDIR_SEPARATOR "/"
250 #ifdef HAVE_INTTYPES_H
251 #include <inttypes.h>
255 #define PRId64 TDS_I64_PREFIX "d"
258 #define PRIu64 TDS_I64_PREFIX "u"
261 #define PRIx64 TDS_I64_PREFIX "x"