25#if !defined(WIN32) && !defined(_WIN32_WCE)
46#include <sys/socket.h>
47#include <netinet/in.h>
48#if defined(_XOPEN_SOURCE_EXTENDED) || !defined(__hpux)
60typedef int ortp_socket_t;
61typedef pthread_t ortp_thread_t;
62typedef pthread_mutex_t ortp_mutex_t;
63typedef pthread_cond_t ortp_cond_t;
65#ifdef __INTEL_COMPILER
66#pragma warning(disable : 111)
67#pragma warning(disable : 181)
68#pragma warning(disable : 188)
69#pragma warning(disable : 593)
70#pragma warning(disable : 810)
71#pragma warning(disable : 869)
72#pragma warning(disable : 981)
73#pragma warning(disable : 1418)
74#pragma warning(disable : 1419)
75#pragma warning(disable : 1469)
85int __ortp_thread_join(ortp_thread_t thread,
void **ptr);
86int __ortp_thread_create(pthread_t *thread, pthread_attr_t *attr,
void * (*routine)(
void*),
void *arg);
92#define ortp_thread_create __ortp_thread_create
93#define ortp_thread_join __ortp_thread_join
94#define ortp_thread_exit pthread_exit
95#define ortp_mutex_init pthread_mutex_init
96#define ortp_mutex_lock pthread_mutex_lock
97#define ortp_mutex_unlock pthread_mutex_unlock
98#define ortp_mutex_destroy pthread_mutex_destroy
99#define ortp_cond_init pthread_cond_init
100#define ortp_cond_signal pthread_cond_signal
101#define ortp_cond_broadcast pthread_cond_broadcast
102#define ortp_cond_wait pthread_cond_wait
103#define ortp_cond_destroy pthread_cond_destroy
105#define SOCKET_OPTION_VALUE void *
106#define SOCKET_BUFFER void *
108#define getSocketError() strerror(errno)
109#define getSocketErrorCode() (errno)
110#define ortp_gettimeofday(tv,tz) gettimeofday(tv,tz)
111#define ortp_log10f(x) log10f(x)
127#define ORTP_PUBLIC __declspec(dllexport)
129#define ORTP_PUBLIC __declspec(dllimport)
131#pragma push_macro("_WINSOCKAPI_")
136#define strtok_r strtok_s
138typedef unsigned __int64 uint64_t;
139typedef __int64 int64_t;
140typedef unsigned short uint16_t;
141typedef unsigned int uint32_t;
143typedef unsigned char uint8_t;
144typedef __int16 int16_t;
149ORTP_PUBLIC
char* strtok_r(
char *str,
const char *delim,
char **nextp);
152#define vsnprintf _vsnprintf
156typedef SOCKET ortp_socket_t;
157#ifdef WINAPI_FAMILY_PHONE_APP
158typedef CONDITION_VARIABLE ortp_cond_t;
159typedef SRWLOCK ortp_mutex_t;
161typedef HANDLE ortp_cond_t;
162typedef HANDLE ortp_mutex_t;
164typedef HANDLE ortp_thread_t;
166#define ortp_thread_create WIN_thread_create
167#define ortp_thread_join WIN_thread_join
168#define ortp_thread_exit(arg)
169#define ortp_mutex_init WIN_mutex_init
170#define ortp_mutex_lock WIN_mutex_lock
171#define ortp_mutex_unlock WIN_mutex_unlock
172#define ortp_mutex_destroy WIN_mutex_destroy
173#define ortp_cond_init WIN_cond_init
174#define ortp_cond_signal WIN_cond_signal
175#define ortp_cond_broadcast WIN_cond_broadcast
176#define ortp_cond_wait WIN_cond_wait
177#define ortp_cond_destroy WIN_cond_destroy
185ORTP_PUBLIC
int WIN_mutex_init(ortp_mutex_t *m,
void *attr_unused);
186ORTP_PUBLIC
int WIN_mutex_lock(ortp_mutex_t *mutex);
187ORTP_PUBLIC
int WIN_mutex_unlock(ortp_mutex_t *mutex);
188ORTP_PUBLIC
int WIN_mutex_destroy(ortp_mutex_t *mutex);
189ORTP_PUBLIC
int WIN_thread_create(ortp_thread_t *t,
void *attr_unused,
void *(*func)(
void*),
void *arg);
190ORTP_PUBLIC
int WIN_thread_join(ortp_thread_t thread,
void **unused);
191ORTP_PUBLIC
int WIN_cond_init(ortp_cond_t *cond,
void *attr_unused);
192ORTP_PUBLIC
int WIN_cond_wait(ortp_cond_t * cond, ortp_mutex_t * mutex);
193ORTP_PUBLIC
int WIN_cond_signal(ortp_cond_t * cond);
194ORTP_PUBLIC
int WIN_cond_broadcast(ortp_cond_t * cond);
195ORTP_PUBLIC
int WIN_cond_destroy(ortp_cond_t * cond);
201#define SOCKET_OPTION_VALUE char *
202#define inline __inline
204#if defined(_WIN32_WCE)
206#define ortp_log10f(x) (float)log10 ((double)x)
211#define assert(exp) ((void)0)
216#define errno GetLastError()
220const char * ortp_strerror(DWORD value);
221#define strerror ortp_strerror
226#define ortp_log10f(x) log10f(x)
230ORTP_PUBLIC
const char *getWinSocketError(
int error);
231#define getSocketErrorCode() WSAGetLastError()
232#define getSocketError() getWinSocketError(WSAGetLastError())
234#define snprintf _snprintf
235#define strcasecmp _stricmp
236#define strncasecmp _strnicmp
242ORTP_PUBLIC
int ortp_gettimeofday (
struct timeval *tv,
void* tz);
243#ifdef _WORKAROUND_MINGW32_BUGS
244char * WSAAPI gai_strerror(
int errnum);
252typedef unsigned char bool_t;
267ORTP_PUBLIC
void* ortp_malloc(
size_t sz);
268ORTP_PUBLIC
void ortp_free(
void *ptr);
269ORTP_PUBLIC
void* ortp_realloc(
void *ptr,
size_t sz);
270ORTP_PUBLIC
void* ortp_malloc0(
size_t sz);
271ORTP_PUBLIC
char * ortp_strdup(
const char *tmp);
275 void *(*malloc_fun)(
size_t sz);
276 void *(*realloc_fun)(
void *ptr,
size_t sz);
277 void (*free_fun)(
void *ptr);
282#define ortp_new(type,count) (type*)ortp_malloc(sizeof(type)*(count))
283#define ortp_new0(type,count) (type*)ortp_malloc0(sizeof(type)*(count))
285ORTP_PUBLIC
int close_socket(ortp_socket_t sock);
286ORTP_PUBLIC
int set_non_blocking_socket(ortp_socket_t sock);
288ORTP_PUBLIC
char *ortp_strndup(
const char *str,
int n);
289ORTP_PUBLIC
char *ortp_strdup_printf(
const char *fmt,...);
290ORTP_PUBLIC
char *ortp_strdup_vprintf(
const char *fmt, va_list ap);
292ORTP_PUBLIC
int ortp_file_exist(
const char *pathname);
297#if !defined(_WIN32_WCE)
299typedef HANDLE ortp_pipe_t;
300#define ORTP_PIPE_INVALID INVALID_HANDLE_VALUE
302typedef int ortp_pipe_t;
303#define ORTP_PIPE_INVALID (-1)
306ORTP_PUBLIC ortp_pipe_t ortp_server_pipe_create(
const char *name);
312ORTP_PUBLIC ortp_pipe_t ortp_server_pipe_accept_client(ortp_pipe_t server);
313ORTP_PUBLIC
int ortp_server_pipe_close(ortp_pipe_t spipe);
314ORTP_PUBLIC
int ortp_server_pipe_close_client(ortp_pipe_t client);
316ORTP_PUBLIC ortp_pipe_t ortp_client_pipe_connect(
const char *name);
317ORTP_PUBLIC
int ortp_client_pipe_close(ortp_pipe_t sock);
319ORTP_PUBLIC
int ortp_pipe_read(ortp_pipe_t p, uint8_t *buf,
int len);
320ORTP_PUBLIC
int ortp_pipe_write(ortp_pipe_t p,
const uint8_t *buf,
int len);
322ORTP_PUBLIC
void *ortp_shm_open(
unsigned int keyid,
int size,
int create);
323ORTP_PUBLIC
void ortp_shm_close(
void *memory);
333#if (defined(WIN32) || defined(_WIN32_WCE)) && !defined(ORTP_STATIC)
335 #define ORTP_VAR_PUBLIC extern __declspec(dllexport)
337 #define ORTP_VAR_PUBLIC __declspec(dllimport)
340 #define ORTP_VAR_PUBLIC extern
347#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE==1