~ubuntu-branches/ubuntu/trusty/linphone/trusty

« back to all changes in this revision

Viewing changes to oRTP/include/ortp/port.h

  • Committer: Package Import Robot
  • Author(s): Luk Claes
  • Date: 2013-09-11 19:08:43 UTC
  • mfrom: (1.1.19) (16.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20130911190843-fkydjxsdvy1fmx24
Tags: 3.6.1-2.1
* Non-maintainer upload.
* Apply Sebastian Ramacher's patch to fix FTBFS (Closes: #720668).

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
#pragma warning(disable : 1469)         // "cc" clobber ignored
76
76
#endif
77
77
 
 
78
#define ORTP_PUBLIC
 
79
 
78
80
#ifdef __cplusplus
79
81
extern "C"
80
82
{
119
121
#include <stdarg.h>
120
122
#include <winsock2.h>
121
123
#include <ws2tcpip.h>
122
 
#include <io.h>
123
124
 
124
125
#ifdef _MSC_VER
 
126
#ifdef ORTP_EXPORTS
 
127
#define ORTP_PUBLIC     __declspec(dllexport)
 
128
#else 
 
129
#define ORTP_PUBLIC     __declspec(dllimport)
 
130
#endif
125
131
#pragma push_macro("_WINSOCKAPI_")
126
132
#ifndef _WINSOCKAPI_
127
133
#define _WINSOCKAPI_
128
134
#endif
129
135
 
 
136
#define strtok_r strtok_s
 
137
 
130
138
typedef  unsigned __int64 uint64_t;
131
139
typedef  __int64 int64_t;
132
140
typedef  unsigned short uint16_t;
136
144
typedef __int16 int16_t;
137
145
#else
138
146
#include <stdint.h> /*provided by mingw32*/
 
147
#include <io.h>
 
148
#define ORTP_PUBLIC
 
149
ORTP_PUBLIC char* strtok_r(char *str, const char *delim, char **nextp);
139
150
#endif
140
151
 
141
152
#define vsnprintf       _vsnprintf
142
153
#define srandom         srand
143
154
#define random          rand
144
155
 
145
 
 
146
156
typedef SOCKET ortp_socket_t;
 
157
#ifdef WINAPI_FAMILY_PHONE_APP
 
158
typedef CONDITION_VARIABLE ortp_cond_t;
 
159
typedef SRWLOCK ortp_mutex_t;
 
160
#else
147
161
typedef HANDLE ortp_cond_t;
148
162
typedef HANDLE ortp_mutex_t;
 
163
#endif
149
164
typedef HANDLE ortp_thread_t;
150
165
 
151
166
#define ortp_thread_create      WIN_thread_create
167
182
{
168
183
#endif
169
184
 
170
 
int WIN_mutex_init(ortp_mutex_t *m, void *attr_unused);
171
 
int WIN_mutex_lock(ortp_mutex_t *mutex);
172
 
int WIN_mutex_unlock(ortp_mutex_t *mutex);
173
 
int WIN_mutex_destroy(ortp_mutex_t *mutex);
174
 
int WIN_thread_create(ortp_thread_t *t, void *attr_unused, void *(*func)(void*), void *arg);
175
 
int WIN_thread_join(ortp_thread_t thread, void **unused);
176
 
int WIN_cond_init(ortp_cond_t *cond, void *attr_unused);
177
 
int WIN_cond_wait(ortp_cond_t * cond, ortp_mutex_t * mutex);
178
 
int WIN_cond_signal(ortp_cond_t * cond);
179
 
int WIN_cond_broadcast(ortp_cond_t * cond);
180
 
int WIN_cond_destroy(ortp_cond_t * cond);
 
185
ORTP_PUBLIC int WIN_mutex_init(ortp_mutex_t *m, void *attr_unused);
 
186
ORTP_PUBLIC int WIN_mutex_lock(ortp_mutex_t *mutex);
 
187
ORTP_PUBLIC int WIN_mutex_unlock(ortp_mutex_t *mutex);
 
188
ORTP_PUBLIC int WIN_mutex_destroy(ortp_mutex_t *mutex);
 
189
ORTP_PUBLIC int WIN_thread_create(ortp_thread_t *t, void *attr_unused, void *(*func)(void*), void *arg);
 
190
ORTP_PUBLIC int WIN_thread_join(ortp_thread_t thread, void **unused);
 
191
ORTP_PUBLIC int WIN_cond_init(ortp_cond_t *cond, void *attr_unused);
 
192
ORTP_PUBLIC int WIN_cond_wait(ortp_cond_t * cond, ortp_mutex_t * mutex);
 
193
ORTP_PUBLIC int WIN_cond_signal(ortp_cond_t * cond);
 
194
ORTP_PUBLIC int WIN_cond_broadcast(ortp_cond_t * cond);
 
195
ORTP_PUBLIC int WIN_cond_destroy(ortp_cond_t * cond);
181
196
 
182
197
#ifdef __cplusplus
183
198
}
212
227
 
213
228
#endif
214
229
 
215
 
const char *getWinSocketError(int error);
 
230
ORTP_PUBLIC const char *getWinSocketError(int error);
216
231
#define getSocketErrorCode() WSAGetLastError()
217
232
#define getSocketError() getWinSocketError(WSAGetLastError())
218
233
 
219
234
#define snprintf _snprintf
220
235
#define strcasecmp _stricmp
221
 
 
222
 
#if 0
223
 
struct timeval {
224
 
        long    tv_sec;         /* seconds */
225
 
        long    tv_usec;        /* and microseconds */
226
 
};
227
 
#endif
 
236
#define strncasecmp _strnicmp
228
237
 
229
238
 
230
239
#ifdef __cplusplus
231
240
extern "C"{
232
241
#endif
233
 
int gettimeofday (struct timeval *tv, void* tz);
 
242
ORTP_PUBLIC int gettimeofday (struct timeval *tv, void* tz);
234
243
#ifdef _WORKAROUND_MINGW32_BUGS
235
244
char * WSAAPI gai_strerror(int errnum);
236
245
#endif
246
255
#define TRUE 1
247
256
#define FALSE 0
248
257
 
 
258
typedef struct ortpTimeSpec{
 
259
        int64_t tv_sec;
 
260
        int64_t tv_nsec;
 
261
}ortpTimeSpec;
 
262
 
249
263
#ifdef __cplusplus
250
264
extern "C"{
251
265
#endif
252
266
 
253
 
void* ortp_malloc(size_t sz);
254
 
void ortp_free(void *ptr);
255
 
void* ortp_realloc(void *ptr, size_t sz);
256
 
void* ortp_malloc0(size_t sz);
257
 
char * ortp_strdup(const char *tmp);
 
267
ORTP_PUBLIC void* ortp_malloc(size_t sz);
 
268
ORTP_PUBLIC void ortp_free(void *ptr);
 
269
ORTP_PUBLIC void* ortp_realloc(void *ptr, size_t sz);
 
270
ORTP_PUBLIC void* ortp_malloc0(size_t sz);
 
271
ORTP_PUBLIC char * ortp_strdup(const char *tmp);
258
272
 
259
273
/*override the allocator with this method, to be called BEFORE ortp_init()*/
260
274
typedef struct _OrtpMemoryFunctions{
268
282
#define ortp_new(type,count)    (type*)ortp_malloc(sizeof(type)*(count))
269
283
#define ortp_new0(type,count)   (type*)ortp_malloc0(sizeof(type)*(count))
270
284
 
271
 
int close_socket(ortp_socket_t sock);
272
 
int set_non_blocking_socket(ortp_socket_t sock);
273
 
 
274
 
char *ortp_strndup(const char *str,int n);
275
 
char *ortp_strdup_printf(const char *fmt,...);
276
 
char *ortp_strdup_vprintf(const char *fmt, va_list ap);
277
 
 
278
 
int ortp_file_exist(const char *pathname);
 
285
ORTP_PUBLIC int close_socket(ortp_socket_t sock);
 
286
ORTP_PUBLIC int set_non_blocking_socket(ortp_socket_t sock);
 
287
 
 
288
ORTP_PUBLIC char *ortp_strndup(const char *str,int n);
 
289
ORTP_PUBLIC char *ortp_strdup_printf(const char *fmt,...);
 
290
ORTP_PUBLIC char *ortp_strdup_vprintf(const char *fmt, va_list ap);
 
291
 
 
292
ORTP_PUBLIC int ortp_file_exist(const char *pathname);
 
293
 
 
294
ORTP_PUBLIC void ortp_get_cur_time(ortpTimeSpec *ret);
279
295
 
280
296
/* portable named pipes  and shared memory*/
281
297
#if !defined(_WIN32_WCE)
287
303
#define ORTP_PIPE_INVALID (-1)
288
304
#endif
289
305
 
290
 
ortp_pipe_t ortp_server_pipe_create(const char *name);
 
306
ORTP_PUBLIC ortp_pipe_t ortp_server_pipe_create(const char *name);
291
307
/*
292
308
 * warning: on win32 ortp_server_pipe_accept_client() might return INVALID_HANDLE_VALUE without
293
309
 * any specific error, this happens when ortp_server_pipe_close() is called on another pipe.
294
310
 * This pipe api is not thread-safe.
295
311
*/
296
 
ortp_pipe_t ortp_server_pipe_accept_client(ortp_pipe_t server);
297
 
int ortp_server_pipe_close(ortp_pipe_t spipe);
298
 
int ortp_server_pipe_close_client(ortp_pipe_t client);
299
 
 
300
 
ortp_pipe_t ortp_client_pipe_connect(const char *name);
301
 
int ortp_client_pipe_close(ortp_pipe_t sock);
302
 
 
303
 
int ortp_pipe_read(ortp_pipe_t p, uint8_t *buf, int len);
304
 
int ortp_pipe_write(ortp_pipe_t p, const uint8_t *buf, int len);
305
 
 
306
 
void *ortp_shm_open(unsigned int keyid, int size, int create);
307
 
void ortp_shm_close(void *memory);
 
312
ORTP_PUBLIC ortp_pipe_t ortp_server_pipe_accept_client(ortp_pipe_t server);
 
313
ORTP_PUBLIC int ortp_server_pipe_close(ortp_pipe_t spipe);
 
314
ORTP_PUBLIC int ortp_server_pipe_close_client(ortp_pipe_t client);
 
315
 
 
316
ORTP_PUBLIC ortp_pipe_t ortp_client_pipe_connect(const char *name);
 
317
ORTP_PUBLIC int ortp_client_pipe_close(ortp_pipe_t sock);
 
318
 
 
319
ORTP_PUBLIC int ortp_pipe_read(ortp_pipe_t p, uint8_t *buf, int len);
 
320
ORTP_PUBLIC int ortp_pipe_write(ortp_pipe_t p, const uint8_t *buf, int len);
 
321
 
 
322
ORTP_PUBLIC void *ortp_shm_open(unsigned int keyid, int size, int create);
 
323
ORTP_PUBLIC void ortp_shm_close(void *memory);
308
324
 
309
325
#endif
310
326
 
316
332
 
317
333
#if (defined(WIN32) || defined(_WIN32_WCE)) && !defined(ORTP_STATIC)
318
334
#ifdef ORTP_EXPORTS
319
 
   #define VAR_DECLSPEC    __declspec(dllexport)
 
335
   #define ORTP_VAR_PUBLIC    extern __declspec(dllexport)
320
336
#else
321
 
   #define VAR_DECLSPEC    __declspec(dllimport)
 
337
   #define ORTP_VAR_PUBLIC    __declspec(dllimport)
322
338
#endif
323
339
#else
324
 
   #define VAR_DECLSPEC    extern
 
340
   #define ORTP_VAR_PUBLIC    extern
325
341
#endif
326
342
 
327
343