diff options
Diffstat (limited to 'pjlib/src/pj')
-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 |
7 files changed, 49 insertions, 31 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()); |