39#define MY_ATTRIBUTE(A) __attribute__(A)
41#define MY_ATTRIBUTE(A)
55#include <sys/locking.h>
60#define bzero(p, n) memset(p, 0, n)
67#define xcom_close(fd) _close(fd)
68#define xcom_fclose(f) fclose(f)
69#define xcom_chdir(s) _chdir(s)
70#define xcom_dup(s) _dup(s)
71#define xcom_dup2(s, t) _dup2(s, t)
72#define xcom_lseek(fd, of, h) _lseek(fd, of, h)
73#define xcom_open(n, f, m) _open(n, f, m)
74#define xcom_fopen(n, m) fopen(n, m)
75#define xcom_fstat(f, b) _fstat(f, b)
77#define XCOM_F_TLOCK _LK_NBLCK
78#define xcom_lockf(fd, f, sz) _locking(fd, f, sz)
80#define xcom_lrand48() rand()
81#define xcom_srand48(x) srand(x)
82#define xcom_drand48() ((double)rand() / RAND_MAX)
84#define xcom_write(fd, buf, l) _write(fd, buf, (unsigned int)l)
85#define xcom_read(fd, buf, c) _read(fd, buf, (unsigned int)c)
87#define xcom_mktemp(s) _mktemp(s)
91#define xcom_strdup(x) _strdup(x)
93#define xcom_strtok(b, d, c) strtok_s(b, d, c)
95#define xcom_strcasecmp(a, b) _stricmp(a, b)
97#define xcom_execv _execv
109typedef SSIZE_T ssize_t;
113#define UINT64_MAX _UI64_MAX
116#define INT64_MAX _I64_MAX
119#define INT64_MIN _I64_MIN
122#define UINT32_MAX _UI32_MAX
125#define INT32_MAX _I32_MAX
128#define INT32_MIN _I32_MIN
131#define UINT16_MAX _UI16_MAX
134#define INT16_MAX _I16_MAX
137#define INT16_MIN _I16_MIN
153#define XCOM_O_CREAT _O_CREAT
154#define XCOM_O_WRONLY _O_WRONLY
155#define XCOM_O_APPEND _O_APPEND
156#define XCOM_O_LARGEFILE 0
157#define XCOM_O_EXCL _O_EXCL
158#define XCOM_O_RDWR _O_RDWR
159#define XCOM_O_RDONLY _O_RDONLY
160#define XCOM_O_RSYNC 0
161#define XCOM_O_BINARY _O_BINARY
164#define XCOM_S_IRUSR _S_IREAD
165#define XCOM_S_IWUSR _S_IWRITE
166#define XCOM_S_IXUSR 0
167#define XCOM_S_IWRXU XCOM_S_IRUSR | XCOM_S_IWUSR | XCOM_S_IXUSR
168#define XCOM_S_IRGRP 0
169#define XCOM_S_IWGRP 0
170#define XCOM_S_IROTH 0
171#define XCOM_S_IWOTH 0
173#define XCOM_FILE_WRITE_MODE "w"
183#define WEXITSTATUS(s) (s)
184#define WIFEXITED(s) ((s) == -1 ? 1 : ((s)&0x40000000) == 0)
185#define WIFSIGNALED(s) ((s) == -1 ? 0 : ((s)&0x40000000) != 0)
186#define WTERMSIG(s) ((s) == -1 ? 0 : ((s)&0x3FFFFFFF))
187#define WCOREDUMP(s) (((s) == CORE_EXIT_VALUE_WIN32) ? TRUE : FALSE)
190typedef SSIZE_T ssize_t;
192#define XCOM_CLRSYSERR (errno = 0, WSASetLastError(0))
193#define XCOM_ISSYSERR (errno != 0 || WSAGetLastError() != 0)
194#define XCOM_SYSERRNUM (WSAGetLastError() ? WSAGetLastError() : (errno))
195#define XCOM_SYSERRSTR \
196 (WSAGetLastError() ? g_strerror(WSAGetLastError()) : g_strerror(errno))
197#define xcom_gmtime_r(time, res) gmtime_s(res, time)
198#define xcom_localtime_r(time, res) localtime_s(res, time)
216#define xcom_close(fd) close(fd)
217#define xcom_fclose(f) fclose(f)
218#define xcom_chdir(s) chdir(s)
219#define xcom_dup(s) dup(s)
220#define xcom_dup2(s, t) dup2(s, t)
221#define xcom_lseek(fd, of, h) lseek(fd, of, h)
222#define xcom_open(n, f, m) open(n, f, m)
223#define xcom_fopen(n, m) fopen(n, m)
224#define xcom_fstat(f, b) fstat(f, b)
226#define XCOM_F_TLOCK F_TLOCK
227#define xcom_lockf(fd, f, sz) lockf(fd, f, sz)
229#define xcom_lrand48() lrand48()
230#define xcom_srand48(x) srand48(x)
231#define xcom_drand48() drand48()
233#define xcom_write(fd, buf, l) write(fd, buf, l)
234#define xcom_read(fd, buf, c) read(fd, buf, c)
235#define xcom_execv execv
237#define xcom_mktemp(s) mktemp(s)
241#define xcom_strdup(x) strdup(x)
243#define xcom_strtok(b, d, c) strtok_s(b, d, c)
245#define xcom_strtok(b, d, c) strtok_r(b, d, c)
248#define xcom_strcasecmp(a, b) strcasecmp(a, b)
258#define XCOM_O_CREAT O_CREAT
259#define XCOM_O_WRONLY O_WRONLY
260#define XCOM_O_APPEND O_APPEND
261#define XCOM_O_LARGEFILE O_LARGEFILE
262#define XCOM_O_EXCL O_EXCL
263#define XCOM_O_RDWR O_RDWR
264#define XCOM_O_RDONLY O_RDONLY
267#define XCOM_O_RSYNC O_DSYNC
269#define XCOM_O_RSYNC O_RSYNC
271#define XCOM_O_BINARY 0
273#define XCOM_S_IRUSR S_IRUSR
274#define XCOM_S_IWUSR S_IWUSR
275#define XCOM_S_IXUSR S_IXUSR
276#define XCOM_S_IWRXU XCOM_S_IRUSR | XCOM_S_IWUSR | XCOM_S_IXUSR
277#define XCOM_S_IRGRP S_IRGRP
278#define XCOM_S_IWGRP S_IWGRP
279#define XCOM_S_IROTH S_IROTH
280#define XCOM_S_IWOTH S_IWOTH
282#define XCOM_FILE_WRITE_MODE "wF"
284#define SOCKET_ERROR -1
286#define XCOM_CLRSYSERR errno = 0
287#define XCOM_ISSYSERR (errno != 0)
288#define XCOM_SYSERRNUM ((errno) + 0)
289#define XCOM_SYSERRSTR g_strerror(errno)
291#define xcom_gmtime_r(time, res) gmtime_r(time, res)
292#define xcom_localtime_r(time, res) localtime_r(time, res)
294#define thread_yield sched_yield
299#define NEWLINE "\r\n"