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 0
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
66 #define vsnprintf _vsnprintf
68 #define getpid() _gethostid()
71 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64)
74 #define READSOCKET(a,b,c) recv((a), (char *) (b), (c), TDS_NOSIGNAL)
75 #define WRITESOCKET(a,b,c) send((a), (const char *) (b), (c), TDS_NOSIGNAL)
76 #define CLOSESOCKET(a) closesocket((a))
77 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (c))
79 int tds_socket_init(
void);
80 #define INITSOCKET() tds_socket_init()
81 void tds_socket_done(
void);
82 #define DONESOCKET() tds_socket_done()
83 #define NETDB_REENTRANT 1
85 #define TDSSOCK_EINTR WSAEINTR
86 #define TDSSOCK_EINPROGRESS WSAEWOULDBLOCK
87 #define TDSSOCK_WOULDBLOCK(e) ((e)==WSAEWOULDBLOCK)
88 #define sock_errno WSAGetLastError()
89 #define sock_strerror(n) tds_prwsaerror(n)
93 #define strcasecmp stricmp
94 #define strncasecmp strnicmp
96 #define vsnprintf _vsnprintf
97 #define snprintf _snprintf
103 #if defined(_WIN64) && !defined(WIN64)
107 #define TDS_SDIR_SEPARATOR "\\"
110 #if defined(__MSVCRT__) || defined(_MSC_VER)
111 #define getpid() _getpid()
112 #define strdup(s) _strdup(s)
114 #define fileno(f) _fileno(f)
115 #define stricmp(s1,s2) _stricmp(s1,s2)
116 #define strnicmp(s1,s2,n) _strnicmp(s1,s2,n)
122 #define sock_errno errno
125 #ifndef sock_strerror
126 #define sock_strerror(n) strerror(n)
129 #ifndef TDSSOCK_EINTR
130 #define TDSSOCK_EINTR EINTR
133 #ifndef TDSSOCK_EINPROGRESS
134 #define TDSSOCK_EINPROGRESS EINPROGRESS
137 #ifndef TDSSOCK_WOULDBLOCK
138 # if defined(EWOULDBLOCK) && EAGAIN != EWOULDBLOCK
139 # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN||(e)==EWOULDBLOCK)
141 # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN)
146 #define INITSOCKET() 0
150 #define DONESOCKET() do { } while(0)
155 # define READSOCKET(s,b,l) recv((s), (b), (l), MSG_NOSIGNAL)
157 # define READSOCKET(s,b,l) read((s), (b), (l))
163 # define WRITESOCKET(s,b,l) send((s), (b), (l), MSG_NOSIGNAL)
165 # define WRITESOCKET(s,b,l) write((s), (b), (l))
170 #define CLOSESOCKET(s) close((s))
174 #define IOCTLSOCKET(s,b,l) ioctl((s), (b), (l))
178 # define SOCKLEN_T socklen_t
181 #if !defined(__WIN32__) && !defined(_WIN32) && !defined(WIN32)
182 typedef int TDS_SYS_SOCKET;
183 #define INVALID_SOCKET -1
184 #define TDS_IS_SOCKET_INVALID(s) ((s) < 0)
186 typedef SOCKET TDS_SYS_SOCKET;
187 #define TDS_IS_SOCKET_INVALID(s) ((s) == INVALID_SOCKET)
190 #define tds_accept accept
191 #define tds_getpeername getpeername
192 #define tds_getsockopt getsockopt
193 #define tds_getsockname getsockname
194 #define tds_recvfrom recvfrom
196 #if defined(__hpux__) && SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
197 # if HAVE__XPG_ACCEPT
199 # define tds_accept _xpg_accept
202 # define tds_accept __accept
204 # if HAVE__XPG_GETPEERNAME
205 # undef tds_getpeername
206 # define tds_getpeername _xpg_getpeername
207 # elif HAVE___GETPEERNAME
208 # undef tds_getpeername
209 # define tds_getpeername __getpeername
211 # if HAVE__XPG_GETSOCKOPT
212 # undef tds_getsockopt
213 # define tds_getsockopt _xpg_getsockopt
214 # elif HAVE___GETSOCKOPT
215 # undef tds_getsockopt
216 # define tds_getsockopt __getsockopt
218 # if HAVE__XPG_GETSOCKNAME
219 # undef tds_getsockname
220 # define tds_getsockname _xpg_getsockname
221 # elif HAVE___GETSOCKNAME
222 # undef tds_getsockname
223 # define tds_getsockname __getsockname
225 # if HAVE__XPG_RECVFROM
227 # define tds_recvfrom _xpg_recvfrom
228 # elif HAVE___RECVFROM
230 # define tds_recvfrom __recvfrom
234 #ifndef TDS_SDIR_SEPARATOR
235 #define TDS_SDIR_SEPARATOR "/"
238 #ifdef HAVE_INTTYPES_H
239 #include <inttypes.h>
243 #define PRId64 TDS_I64_FORMAT