diff options
Diffstat (limited to 'pjlib')
-rw-r--r-- | pjlib/src/pj/except.c | 9 | ||||
-rw-r--r-- | pjlib/src/pj/ioqueue_common_abs.c | 30 | ||||
-rw-r--r-- | pjlib/src/pj/ioqueue_select.c | 4 | ||||
-rw-r--r-- | pjlib/src/pj/log.c | 2 | ||||
-rw-r--r-- | pjlib/src/pj/os_core_unix.c | 27 | ||||
-rw-r--r-- | pjlib/src/pj/os_error_unix.c | 6 | ||||
-rw-r--r-- | pjlib/src/pj/sock_bsd.c | 2 | ||||
-rw-r--r-- | pjlib/src/pjlib-test/file.c | 2 | ||||
-rw-r--r-- | pjlib/src/pjlib-test/ioq_perf.c | 2 | ||||
-rw-r--r-- | pjlib/src/pjlib-test/sock.c | 2 | ||||
-rw-r--r-- | pjlib/src/pjlib-test/string.c | 34 |
11 files changed, 70 insertions, 50 deletions
diff --git a/pjlib/src/pj/except.c b/pjlib/src/pj/except.c index 3b7e9817..006671e2 100644 --- a/pjlib/src/pj/except.c +++ b/pjlib/src/pj/except.c @@ -41,7 +41,8 @@ PJ_DEF(void) pj_throw_exception_(int exception_id) { struct pj_exception_state_t *handler; - handler = pj_thread_local_get(thread_local_id); + handler = (struct pj_exception_state_t*) + pj_thread_local_get(thread_local_id); if (handler == NULL) { PJ_LOG(1,("except.c", "!!!FATAL: unhandled exception %s!\n", pj_exception_id_name(exception_id))); @@ -78,7 +79,8 @@ PJ_DEF(void) pj_push_exception_handler_(struct pj_exception_state_t *rec) pj_assert(thread_local_id != -1); pj_atexit(&exception_cleanup); } - parent_handler = pj_thread_local_get(thread_local_id); + parent_handler = (struct pj_exception_state_t *) + pj_thread_local_get(thread_local_id); rec->prev = parent_handler; pj_thread_local_set(thread_local_id, rec); } @@ -87,7 +89,8 @@ PJ_DEF(void) pj_pop_exception_handler_(void) { struct pj_exception_state_t *handler; - handler = pj_thread_local_get(thread_local_id); + handler = (struct pj_exception_state_t *) + pj_thread_local_get(thread_local_id); pj_assert(handler != NULL); pj_thread_local_set(thread_local_id, handler->prev); } diff --git a/pjlib/src/pj/ioqueue_common_abs.c b/pjlib/src/pj/ioqueue_common_abs.c index 82f962c2..8fd1be72 100644 --- a/pjlib/src/pj/ioqueue_common_abs.c +++ b/pjlib/src/pj/ioqueue_common_abs.c @@ -301,7 +301,7 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h) //write_op->op = 0; } else { pj_assert(!"Invalid operation type!"); - write_op->op = 0; + write_op->op = PJ_IOQUEUE_OP_NONE; send_rc = PJ_EBUG; } @@ -318,7 +318,7 @@ void ioqueue_dispatch_write_event(pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h) h->fd_type == PJ_SOCK_DGRAM) { - write_op->op = 0; + write_op->op = PJ_IOQUEUE_OP_NONE; if (h->fd_type != PJ_SOCK_DGRAM) { /* Write completion of the whole stream. */ @@ -375,7 +375,7 @@ void ioqueue_dispatch_read_event( pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h ) /* Get one accept operation from the list. */ accept_op = h->accept_list.next; pj_list_erase(accept_op); - accept_op->op = 0; + accept_op->op = PJ_IOQUEUE_OP_NONE; /* Clear bit in fdset if there is no more pending accept */ if (pj_list_empty(&h->accept_list)) @@ -417,18 +417,18 @@ void ioqueue_dispatch_read_event( pj_ioqueue_t *ioqueue, pj_ioqueue_key_t *h ) bytes_read = read_op->size; if ((read_op->op == PJ_IOQUEUE_OP_RECV_FROM)) { - read_op->op = 0; + read_op->op = PJ_IOQUEUE_OP_NONE; rc = pj_sock_recvfrom(h->fd, read_op->buf, &bytes_read, read_op->flags, read_op->rmt_addr, read_op->rmt_addrlen); } else if ((read_op->op == PJ_IOQUEUE_OP_RECV)) { - read_op->op = 0; + read_op->op = PJ_IOQUEUE_OP_NONE; rc = pj_sock_recv(h->fd, read_op->buf, &bytes_read, read_op->flags); } else { pj_assert(read_op->op == PJ_IOQUEUE_OP_READ); - read_op->op = 0; + read_op->op = PJ_IOQUEUE_OP_NONE; /* * User has specified pj_ioqueue_read(). * On Win32, we should do ReadFile(). But because we got @@ -561,7 +561,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_recv( pj_ioqueue_key_t *key, PJ_CHECK_STACK(); read_op = (struct read_operation*)op_key; - read_op->op = 0; + read_op->op = PJ_IOQUEUE_OP_NONE; /* Check if key is closing. */ if (IS_CLOSING(key)) @@ -630,7 +630,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_recvfrom( pj_ioqueue_key_t *key, return PJ_ECANCELLED; read_op = (struct read_operation*)op_key; - read_op->op = 0; + read_op->op = PJ_IOQUEUE_OP_NONE; /* Try to see if there's data immediately available. */ @@ -768,7 +768,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_send( pj_ioqueue_key_t *key, } write_op->op = PJ_IOQUEUE_OP_SEND; - write_op->buf = (void*)data; + write_op->buf = (char*)data; write_op->size = *length; write_op->written = 0; write_op->flags = flags; @@ -848,7 +848,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_sendto( pj_ioqueue_key_t *key, /* * Check that address storage can hold the address parameter. */ - PJ_ASSERT_RETURN(addrlen <= sizeof(pj_sockaddr_in), PJ_EBUG); + PJ_ASSERT_RETURN(addrlen <= (int)sizeof(pj_sockaddr_in), PJ_EBUG); /* * Schedule asynchronous send. @@ -883,7 +883,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_sendto( pj_ioqueue_key_t *key, } write_op->op = PJ_IOQUEUE_OP_SEND_TO; - write_op->buf = (void*)data; + write_op->buf = (char*)data; write_op->size = *length; write_op->written = 0; write_op->flags = flags; @@ -920,7 +920,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_accept( pj_ioqueue_key_t *key, return PJ_ECANCELLED; accept_op = (struct accept_operation*)op_key; - accept_op->op = 0; + accept_op->op = PJ_IOQUEUE_OP_NONE; /* Fast track: * See if there's new connection available immediately. @@ -1052,7 +1052,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_post_completion( pj_ioqueue_key_t *key, while (op_rec != (void*)&key->read_list) { if (op_rec == (void*)op_key) { pj_list_erase(op_rec); - op_rec->op = 0; + op_rec->op = PJ_IOQUEUE_OP_NONE; pj_mutex_unlock(key->mutex); (*key->cb.on_read_complete)(key, op_key, bytes_status); @@ -1066,7 +1066,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_post_completion( pj_ioqueue_key_t *key, while (op_rec != (void*)&key->write_list) { if (op_rec == (void*)op_key) { pj_list_erase(op_rec); - op_rec->op = 0; + op_rec->op = PJ_IOQUEUE_OP_NONE; pj_mutex_unlock(key->mutex); (*key->cb.on_write_complete)(key, op_key, bytes_status); @@ -1080,7 +1080,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_post_completion( pj_ioqueue_key_t *key, while (op_rec != (void*)&key->accept_list) { if (op_rec == (void*)op_key) { pj_list_erase(op_rec); - op_rec->op = 0; + op_rec->op = PJ_IOQUEUE_OP_NONE; pj_mutex_unlock(key->mutex); (*key->cb.on_accept_complete)(key, op_key, diff --git a/pjlib/src/pj/ioqueue_select.c b/pjlib/src/pj/ioqueue_select.c index f5e36904..e200d642 100644 --- a/pjlib/src/pj/ioqueue_select.c +++ b/pjlib/src/pj/ioqueue_select.c @@ -193,7 +193,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_create( pj_pool_t *pool, sizeof(union operation_key), PJ_EBUG); /* Create and init common ioqueue stuffs */ - ioqueue = pj_pool_alloc(pool, sizeof(pj_ioqueue_t)); + ioqueue = PJ_POOL_ALLOC_T(pool, pj_ioqueue_t); ioqueue_init(ioqueue); ioqueue->max = max_fd; @@ -230,7 +230,7 @@ PJ_DEF(pj_status_t) pj_ioqueue_create( pj_pool_t *pool, for (i=0; i<max_fd; ++i) { pj_ioqueue_key_t *key; - key = pj_pool_alloc(pool, sizeof(pj_ioqueue_key_t)); + key = PJ_POOL_ALLOC_T(pool, pj_ioqueue_key_t); key->ref_count = 0; rc = pj_mutex_create_recursive(pool, NULL, &key->mutex); if (rc != PJ_SUCCESS) { diff --git a/pjlib/src/pj/log.c b/pjlib/src/pj/log.c index bc395546..518854c4 100644 --- a/pjlib/src/pj/log.c +++ b/pjlib/src/pj/log.c @@ -146,7 +146,7 @@ PJ_DEF(void) pj_log( const char *sender, int level, "<logging error: msg too long>"); } len = len + print_len; - if (len > 0 && len < sizeof(log_buffer)-2) { + if (len > 0 && len < (int)sizeof(log_buffer)-2) { if (log_decor & PJ_LOG_HAS_CR) { log_buffer[len++] = '\r'; } diff --git a/pjlib/src/pj/os_core_unix.c b/pjlib/src/pj/os_core_unix.c index 2528694a..33a8a856 100644 --- a/pjlib/src/pj/os_core_unix.c +++ b/pjlib/src/pj/os_core_unix.c @@ -21,7 +21,9 @@ * - Thanks for Zetron, Inc. (Phil Torre, ptorre@zetron.com) for donating * the RTEMS port. */ -#define _GNU_SOURCE +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif #include <pj/os.h> #include <pj/assert.h> #include <pj/pool.h> @@ -339,7 +341,7 @@ pj_status_t pj_thread_init(void) */ static void *thread_main(void *param) { - pj_thread_t *rec = param; + pj_thread_t *rec = (pj_thread_t*)param; void *result; pj_status_t rc; @@ -506,7 +508,7 @@ PJ_DEF(pj_status_t) pj_thread_resume(pj_thread_t *p) PJ_DEF(pj_thread_t*) pj_thread_this(void) { #if PJ_HAS_THREADS - pj_thread_t *rec = pj_thread_local_get(thread_tls_id); + pj_thread_t *rec = (pj_thread_t*)pj_thread_local_get(thread_tls_id); if (rec == NULL) { pj_assert(!"Calling pjlib from unknown/external thread. You must " @@ -663,7 +665,10 @@ PJ_DEF(pj_status_t) pj_atomic_create( pj_pool_t *pool, pj_atomic_t **ptr_atomic) { pj_status_t rc; - pj_atomic_t *atomic_var = pj_pool_calloc(pool, 1, sizeof(pj_atomic_t)); + pj_atomic_t *atomic_var; + + atomic_var = PJ_POOL_ZALLOC_T(pool, pj_atomic_t); + PJ_ASSERT_RETURN(atomic_var, PJ_ENOMEM); #if PJ_HAS_THREADS @@ -907,6 +912,12 @@ PJ_DEF(void) pj_leave_critical_section(void) /////////////////////////////////////////////////////////////////////////////// +#if defined(PJ_LINUX) && PJ_LINUX!=0 +PJ_BEGIN_DECL +PJ_DECL(int) pthread_mutexattr_settype(pthread_mutexattr_t*,int); +PJ_END_DECL +#endif + static pj_status_t init_mutex(pj_mutex_t *mutex, const char *name, int type) { #if PJ_HAS_THREADS @@ -921,7 +932,6 @@ static pj_status_t init_mutex(pj_mutex_t *mutex, const char *name, int type) if (type == PJ_MUTEX_SIMPLE) { #if defined(PJ_LINUX) && PJ_LINUX!=0 - extern int pthread_mutexattr_settype(pthread_mutexattr_t*,int); rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_FAST_NP); #elif defined(PJ_RTEMS) && PJ_RTEMS!=0 /* Nothing to do, default is simple */ @@ -930,7 +940,6 @@ static pj_status_t init_mutex(pj_mutex_t *mutex, const char *name, int type) #endif } else { #if defined(PJ_LINUX) && PJ_LINUX!=0 - extern int pthread_mutexattr_settype(pthread_mutexattr_t*,int); rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); #elif defined(PJ_RTEMS) && PJ_RTEMS!=0 // Phil Torre <ptorre@zetron.com>: @@ -991,7 +1000,7 @@ PJ_DEF(pj_status_t) pj_mutex_create(pj_pool_t *pool, PJ_ASSERT_RETURN(pool && ptr_mutex, PJ_EINVAL); - mutex = pj_pool_alloc(pool, sizeof(*mutex)); + mutex = PJ_POOL_ALLOC_T(pool, pj_mutex_t); PJ_ASSERT_RETURN(mutex, PJ_ENOMEM); if ((rc=init_mutex(mutex, name, type)) != PJ_SUCCESS) @@ -1228,7 +1237,7 @@ PJ_DEF(pj_status_t) pj_rwmutex_create(pj_pool_t *pool, const char *name, PJ_UNUSED_ARG(name); - rwm = pj_pool_alloc(pool, sizeof(pj_rwmutex_t)); + rwm = PJ_POOL_ALLOC_T(pool, pj_rwmutex_t); PJ_ASSERT_RETURN(rwm, PJ_ENOMEM); status = pthread_rwlock_init(&rwm->rwlock, NULL); @@ -1329,7 +1338,7 @@ PJ_DEF(pj_status_t) pj_sem_create( pj_pool_t *pool, PJ_CHECK_STACK(); PJ_ASSERT_RETURN(pool != NULL && ptr_sem != NULL, PJ_EINVAL); - sem = pj_pool_alloc(pool, sizeof(*sem)); + sem = PJ_POOL_ALLOC_T(pool, pj_sem_t); PJ_ASSERT_RETURN(sem, PJ_ENOMEM); if (sem_init( &sem->sem, 0, initial) != 0) diff --git a/pjlib/src/pj/os_error_unix.c b/pjlib/src/pj/os_error_unix.c index d3cfe14c..3d4b5263 100644 --- a/pjlib/src/pj/os_error_unix.c +++ b/pjlib/src/pj/os_error_unix.c @@ -40,6 +40,12 @@ PJ_DEF(void) pj_set_netos_error(pj_status_t code) errno = PJ_STATUS_TO_OS(code); } +PJ_BEGIN_DECL + + PJ_DECL(int) platform_strerror(pj_os_err_type code, + char *buf, pj_size_t bufsize ); +PJ_END_DECL + /* * platform_strerror() * diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c index 8fc4f70e..3e393359 100644 --- a/pjlib/src/pj/sock_bsd.c +++ b/pjlib/src/pj/sock_bsd.c @@ -385,7 +385,7 @@ PJ_DEF(pj_status_t) pj_sock_bind( pj_sock_t sock, { PJ_CHECK_STACK(); - PJ_ASSERT_RETURN(addr && len >= sizeof(struct sockaddr_in), PJ_EINVAL); + PJ_ASSERT_RETURN(addr && len >= (int)sizeof(struct sockaddr_in), PJ_EINVAL); if (bind(sock, (struct sockaddr*)addr, len) != 0) return PJ_RETURN_OS_ERROR(pj_get_native_netos_error()); diff --git a/pjlib/src/pjlib-test/file.c b/pjlib/src/pjlib-test/file.c index 5cfaf318..e32a2710 100644 --- a/pjlib/src/pjlib-test/file.c +++ b/pjlib/src/pjlib-test/file.c @@ -125,7 +125,7 @@ static int file_test_internal(void) } size = 0; - while (size < sizeof(readbuf)) { + while (size < (pj_ssize_t)sizeof(readbuf)) { pj_ssize_t read; read = 1; status = pj_file_read(fd, &readbuf[size], &read); diff --git a/pjlib/src/pjlib-test/ioq_perf.c b/pjlib/src/pjlib-test/ioq_perf.c index ea47603f..e15fe1be 100644 --- a/pjlib/src/pjlib-test/ioq_perf.c +++ b/pjlib/src/pjlib-test/ioq_perf.c @@ -505,7 +505,7 @@ int ioqueue_perf_test(void) PJ_LOG(3,(THIS_FILE, " =======================================")); best_bandwidth = 0; - for (i=0; i<sizeof(test_param)/sizeof(test_param[0]); ++i) { + for (i=0; i<(int)(sizeof(test_param)/sizeof(test_param[0])); ++i) { pj_size_t bandwidth; rc = perform_test(test_param[i].type, diff --git a/pjlib/src/pjlib-test/sock.c b/pjlib/src/pjlib-test/sock.c index 4ccad789..9011a706 100644 --- a/pjlib/src/pjlib-test/sock.c +++ b/pjlib/src/pjlib-test/sock.c @@ -141,7 +141,7 @@ static int simple_sock_test(void) PJ_LOG(3,("test", "...simple_sock_test()")); - for (i=0; i<sizeof(types)/sizeof(types[0]); ++i) { + for (i=0; i<(int)(sizeof(types)/sizeof(types[0])); ++i) { rc = pj_sock_socket(PJ_AF_INET, types[i], 0, &sock); if (rc != PJ_SUCCESS) { diff --git a/pjlib/src/pjlib-test/string.c b/pjlib/src/pjlib-test/string.c index d8bc54fd..dc845d07 100644 --- a/pjlib/src/pjlib-test/string.c +++ b/pjlib/src/pjlib-test/string.c @@ -96,8 +96,8 @@ static int stricmp_test(void) */ #define STRTEST(res,S1,S2,code) \ do { \ - s1.ptr=S1; s1.slen=S1?len:0; \ - s2.ptr=S2; s2.slen=S2?len:0; \ + s1.ptr=S1; s1.slen=(S1)?len:0; \ + s2.ptr=S2; s2.slen=(S2)?len:0; \ pj_get_timestamp(&t1); \ if (C(pj_stricmp(&s1,&s2),res)) return code; \ pj_get_timestamp(&t2); \ @@ -123,12 +123,14 @@ static int stricmp_test(void) pj_thread_sleep(0); +#define SNULL 0 + /* Compare empty strings. */ len=0; STRTEST( 0, "","",-500); - STRTEST( 0, NULL,"",-502); - STRTEST( 0, "",NULL,-504); - STRTEST( 0, NULL,NULL,-506); + STRTEST( 0, SNULL,"",-502); + STRTEST( 0, "",SNULL,-504); + STRTEST( 0, SNULL,SNULL,-506); STRTEST( 0, "hello","world",-508); /* equal, length=1 @@ -139,8 +141,8 @@ static int stricmp_test(void) STRTEST( 0, "a",buf+0,-510); STRTEST( 0, "a",buf+1,-512); STRTEST( -1, "O", "P", -514); - STRTEST(-1, NULL, "a", -516); - STRTEST(1, "a", NULL, -518); + STRTEST(-1, SNULL, "a", -516); + STRTEST(1, "a", SNULL, -518); /* equal, length=2 * use buffer to simulate non-aligned string. @@ -266,19 +268,19 @@ static int strcmp_test(void) /* Test with length == 0 */ len=0; STR_TEST(0, "", "", -400); - STR_TEST(0, NULL, "", -405); - STR_TEST(0, "", NULL, -410); - STR_TEST(0, NULL, NULL, -415); + STR_TEST(0, SNULL, "", -405); + STR_TEST(0, "", SNULL, -410); + STR_TEST(0, SNULL, SNULL, -415); STR_TEST(0, "hello", "", -420); - STR_TEST(0, "hello", NULL, -425); + STR_TEST(0, "hello", SNULL, -425); /* Test with length != 0 */ len = 2; STR_TEST(0, "12", "12", -430); STR_TEST(1, "12", "1", -435); STR_TEST(-1, "1", "12", -440); - STR_TEST(-1, NULL, "12", -445); - STR_TEST(1, "12", NULL, -450); + STR_TEST(-1, SNULL, "12", -445); + STR_TEST(1, "12", SNULL, -450); return 0; @@ -295,7 +297,7 @@ int string_test(void) pj_pool_t *pool; int i; - pool = pj_pool_create(mem, NULL, 4096, 0, NULL); + pool = pj_pool_create(mem, SNULL, 4096, 0, SNULL); if (!pool) return -5; /* @@ -367,7 +369,7 @@ int string_test(void) */ s5 = pj_str("123456"); - pj_strtoul2(&s5, NULL, 10); /* Crash test */ + pj_strtoul2(&s5, SNULL, 10); /* Crash test */ if (pj_strtoul2(&s5, &s4, 10) != 123456UL) return -290; @@ -381,7 +383,7 @@ int string_test(void) return -293; if (s4.slen != 4) return -294; - if (s4.ptr == NULL || *s4.ptr != 'A') + if (s4.ptr == SNULL || *s4.ptr != 'A') return -295; if (pj_strtoul2(&s5, &s4, 16) != 0x123ABCDUL) return -296; |