Use unsigned types instead of long for threadqueue

This commit is contained in:
Nils O. Selåsdal
2013-11-17 21:02:02 +01:00
parent 0679a4a2ad
commit 938ffe330d
2 changed files with 9 additions and 9 deletions
+6 -6
View File
@@ -100,10 +100,10 @@ struct uc_threadqueue {
* Number of elements in the queue. * Number of elements in the queue.
* Use #threadqueue_length to read it. * Use #threadqueue_length to read it.
*/ */
long num_elements; unsigned int num_elements;
/** Max number of elements this queue will hold */ /** Max number of elements this queue will hold */
long max_elements; unsigned int max_elements;
/** /**
* Mutex for the queue. * Mutex for the queue.
*/ */
@@ -119,11 +119,11 @@ struct uc_threadqueue {
/** /**
* Number of threads blocking on writing to the queue * 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 * 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. * 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 * @return 0 on success EINVAL if queue is NULL or max_elements <= 0, or
* another errno value if pthread_ functions fails * 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 * 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 * @param queue Pointer to the queue for which to get the length
* @return the length(number of pending messages) in the queue * @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. * Destroy the queue.
+3 -3
View File
@@ -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; int rc = 0;
if (queue == NULL || max_elements <= 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 ) { if (queue == NULL ) {
return -EINVAL; return -EINVAL;