]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.0.0/liblfds700/src/lfds700_queue_bounded_singleconsumer_singleproducer/lfds700_queue_bounded_singleconsumer_singleproducer_enqueue.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.0.0 / liblfds700 / src / lfds700_queue_bounded_singleconsumer_singleproducer / lfds700_queue_bounded_singleconsumer_singleproducer_enqueue.c
1 /***** includes *****/
2 #include "lfds700_queue_bounded_singleconsumer_singleproducer_internal.h"
3
4
5
6
7
8 /****************************************************************************/
9 int lfds700_queue_bss_enqueue( struct lfds700_queue_bss_state *qbsss, void *key, void *value )
10 {
11   int
12     rv = 0;
13
14   struct lfds700_queue_bss_element
15     *qbsse;
16
17   LFDS700_PAL_ASSERT( qbsss != NULL );
18   // TRD : key can be NULL
19   // TRD : value can be NULL
20
21   LFDS700_MISC_BARRIER_LOAD;
22
23   if( ( (qbsss->write_index+1) & qbsss->mask ) != qbsss->read_index )
24   {
25     qbsse = qbsss->element_array + qbsss->write_index;
26
27     qbsse->key = key;
28     qbsse->value = value;
29
30     LFDS700_MISC_BARRIER_STORE;
31
32     qbsss->write_index = (qbsss->write_index + 1) & qbsss->mask;
33
34     rv = 1;
35   }
36
37   return( rv );
38 }
39