42 #ifdef HAVE_SYS_TIME_H
47 #elif defined(HAVE_INTTYPES_H)
50 #ifdef HAVE_SYS_TYPES_H
51 #include <sys/types.h>
56 #define ev_uint64_t uint64_t
57 #define ev_int64_t int64_t
59 #define ev_uint64_t unsigned __int64
60 #define ev_int64_t signed __int64
61 #elif SIZEOF_LONG_LONG == 8
62 #define ev_uint64_t unsigned long long
63 #define ev_int64_t long long
64 #elif SIZEOF_LONG == 8
65 #define ev_uint64_t unsigned long
66 #define ev_int64_t long
68 #error "No way to define ev_uint64_t"
72 #define ev_uint32_t uint32_t
74 #define ev_uint32_t unsigned int
75 #elif SIZEOF_LONG == 4
76 #define ev_uint32_t unsigned long
78 #define ev_uint32_t unsigned int
80 #error "No way to define ev_uint32_t"
84 #define ev_uint16_t uint16_t
86 #define ev_uint16_t unsigned short
88 #define ev_uint16_t unsigned int
89 #elif SIZEOF_SHORT == 2
90 #define ev_uint16_t unsigned short
92 #error "No way to define ev_uint16_t"
96 #define ev_uint8_t uint8_t
98 #define ev_uint8_t unsigned char
101 int evutil_socketpair(
int d,
int type,
int protocol,
int sv[2]);
102 int evutil_make_socket_nonblocking(
int sock);
104 #define EVUTIL_CLOSESOCKET(s) closesocket(s)
106 #define EVUTIL_CLOSESOCKET(s) close(s)
110 #define EVUTIL_SOCKET_ERROR() WSAGetLastError()
111 #define EVUTIL_SET_SOCKET_ERROR(errcode) \
112 do { WSASetLastError(errcode); } while (0)
114 #define EVUTIL_SOCKET_ERROR() (errno)
115 #define EVUTIL_SET_SOCKET_ERROR(errcode) \
116 do { errno = (errcode); } while (0)
123 #define evutil_timeradd(tvp, uvp, vvp) timeradd((tvp), (uvp), (vvp))
124 #define evutil_timersub(tvp, uvp, vvp) timersub((tvp), (uvp), (vvp))
126 #define evutil_timeradd(tvp, uvp, vvp) \
128 (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
129 (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
130 if ((vvp)->tv_usec >= 1000000) { \
132 (vvp)->tv_usec -= 1000000; \
135 #define evutil_timersub(tvp, uvp, vvp) \
137 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
138 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
139 if ((vvp)->tv_usec < 0) { \
141 (vvp)->tv_usec += 1000000; \
146 #ifdef HAVE_TIMERCLEAR
147 #define evutil_timerclear(tvp) timerclear(tvp)
149 #define evutil_timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
152 #define evutil_timercmp(tvp, uvp, cmp) \
153 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
154 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
155 ((tvp)->tv_sec cmp (uvp)->tv_sec))
157 #ifdef HAVE_TIMERISSET
158 #define evutil_timerisset(tvp) timerisset(tvp)
160 #define evutil_timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
165 ev_int64_t evutil_strtoll(
const char *s,
char **endptr,
int base);
168 #ifdef HAVE_GETTIMEOFDAY
169 #define evutil_gettimeofday(tv, tz) gettimeofday((tv), (tz))
174 int evutil_snprintf(
char *
buf,
size_t buflen,
const char *format, ...)
176 __attribute__((format(printf, 3, 4)))
179 int evutil_vsnprintf(
char *buf,
size_t buflen,
const char *format, va_list ap);