From 938ffe330d60cd71f0184c83aa192ca9f67264b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sun, 17 Nov 2013 21:02:02 +0100 Subject: [PATCH] Use unsigned types instead of long for threadqueue --- include/ucore/threadqueue.h | 12 ++++++------ src/threadqueue.c | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/ucore/threadqueue.h b/include/ucore/threadqueue.h index c6f546e..143db28 100644 --- a/include/ucore/threadqueue.h +++ b/include/ucore/threadqueue.h @@ -100,10 +100,10 @@ struct uc_threadqueue { * Number of elements in the queue. * Use #threadqueue_length to read it. */ - long num_elements; + unsigned int num_elements; /** Max number of elements this queue will hold */ - long max_elements; + unsigned int max_elements; /** * Mutex for the queue. */ @@ -119,11 +119,11 @@ struct uc_threadqueue { /** * Number of threads blocking on writing to the queue */ - long num_read_waiters; + unsigned short num_read_waiters; /** * Number of threads blocking on reading from the queue */ - long num_write_waiters; + unsigned short num_write_waiters; /** * Internal pointers for the messages in the queue. @@ -146,7 +146,7 @@ struct uc_threadqueue { * @return 0 on success EINVAL if queue is NULL or max_elements <= 0, or * another errno value if pthread_ functions fails */ -int uc_thread_queue_init(struct uc_threadqueue *queue, long max_elements); +int uc_thread_queue_init(struct uc_threadqueue *queue, unsigned int max_elements); /** * Adds a message to a queue @@ -225,7 +225,7 @@ static inline int uc_thread_queue_get(struct uc_threadqueue *queue, struct uc_th * @param queue Pointer to the queue for which to get the length * @return the length(number of pending messages) in the queue */ -long uc_thread_queue_length( struct uc_threadqueue *queue ); +unsigned int uc_thread_queue_length( struct uc_threadqueue *queue ); /** * Destroy the queue. diff --git a/src/threadqueue.c b/src/threadqueue.c index c5da95f..040b6a0 100644 --- a/src/threadqueue.c +++ b/src/threadqueue.c @@ -24,7 +24,7 @@ static inline void uc_get_absolute_time(struct timespec *result, } } -int uc_thread_queue_init(struct uc_threadqueue *queue, long max_elements) +int uc_thread_queue_init(struct uc_threadqueue *queue, unsigned int max_elements) { int rc = 0; if (queue == NULL || max_elements <= 0) { @@ -265,9 +265,9 @@ int uc_thread_queue_destroy(struct uc_threadqueue *queue, } -long uc_thread_queue_length(struct uc_threadqueue *queue) +unsigned int uc_thread_queue_length(struct uc_threadqueue *queue) { - long length; + unsigned int length; if (queue == NULL ) { return -EINVAL;