[PATCH 15/18] Fixed static and static inline in a header to be C99 inline.

Alejandro Colomar alx.manpages at gmail.com
Thu Jun 2 18:05:09 UTC 2022


Also create a new .c file with their extern declarations.
---
 auto/sources   |  1 +
 src/nxt_nncq.c | 21 +++++++++++++++++++++
 src/nxt_nncq.h | 24 ++++++++++++------------
 3 files changed, 34 insertions(+), 12 deletions(-)
 create mode 100644 src/nxt_nncq.c

diff --git a/auto/sources b/auto/sources
index dd0c90d..4042a63 100644
--- a/auto/sources
+++ b/auto/sources
@@ -7,6 +7,7 @@ NXT_LIB_SRCS=" \
     src/nxt_lib.c \
     src/nxt_gmtime.c \
     src/nxt_errno.c \
+    src/nxt_nncq.c \
     src/nxt_time.c \
     src/nxt_malloc.c \
     src/nxt_file.c \
diff --git a/src/nxt_nncq.c b/src/nxt_nncq.c
new file mode 100644
index 00000000..92ff81e
--- /dev/null
+++ b/src/nxt_nncq.c
@@ -0,0 +1,21 @@
+
+#include <nxt_main.h>
+
+
+extern nxt_nncq_atomic_t nxt_nncq_head(nxt_nncq_t const volatile *q);
+extern nxt_nncq_atomic_t nxt_nncq_tail(nxt_nncq_t const volatile *q);
+extern void nxt_nncq_tail_cmp_inc(nxt_nncq_t volatile *q, nxt_nncq_atomic_t t);
+extern nxt_nncq_atomic_t nxt_nncq_index(nxt_nncq_t const volatile *q,
+    nxt_nncq_atomic_t i);
+extern nxt_nncq_atomic_t nxt_nncq_map(nxt_nncq_t const volatile *q,
+    nxt_nncq_atomic_t i);
+extern nxt_nncq_cycle_t nxt_nncq_cycle(nxt_nncq_t const volatile *q,
+    nxt_nncq_atomic_t i);
+extern nxt_nncq_cycle_t nxt_nncq_next_cycle(nxt_nncq_t const volatile *q,
+    nxt_nncq_cycle_t i);
+extern nxt_nncq_atomic_t nxt_nncq_new_entry(nxt_nncq_t const volatile *q,
+    nxt_nncq_cycle_t cycle, nxt_nncq_atomic_t i);
+extern nxt_nncq_atomic_t nxt_nncq_empty(nxt_nncq_t const volatile *q);
+extern void nxt_nncq_init(nxt_nncq_t volatile *q);
+extern void nxt_nncq_enqueue(nxt_nncq_t volatile *q, nxt_nncq_atomic_t val);
+extern nxt_nncq_atomic_t nxt_nncq_dequeue(nxt_nncq_t volatile *q);
diff --git a/src/nxt_nncq.h b/src/nxt_nncq.h
index 20e7ecf..2d3f7c3 100644
--- a/src/nxt_nncq.h
+++ b/src/nxt_nncq.h
@@ -21,56 +21,56 @@ typedef struct {
 } nxt_nncq_t;
 
 
-static inline nxt_nncq_atomic_t
+inline nxt_nncq_atomic_t
 nxt_nncq_head(nxt_nncq_t const volatile *q)
 {
     return q->head;
 }
 
 
-static inline nxt_nncq_atomic_t
+inline nxt_nncq_atomic_t
 nxt_nncq_tail(nxt_nncq_t const volatile *q)
 {
     return q->tail;
 }
 
 
-static inline void
+inline void
 nxt_nncq_tail_cmp_inc(nxt_nncq_t volatile *q, nxt_nncq_atomic_t t)
 {
     nxt_atomic_cmp_set(&q->tail, t, t + 1);
 }
 
 
-static inline nxt_nncq_atomic_t
+inline nxt_nncq_atomic_t
 nxt_nncq_index(nxt_nncq_t const volatile *q, nxt_nncq_atomic_t i)
 {
     return i % NXT_NNCQ_SIZE;
 }
 
 
-static inline nxt_nncq_atomic_t
+inline nxt_nncq_atomic_t
 nxt_nncq_map(nxt_nncq_t const volatile *q, nxt_nncq_atomic_t i)
 {
     return i % NXT_NNCQ_SIZE;
 }
 
 
-static inline nxt_nncq_cycle_t
+inline nxt_nncq_cycle_t
 nxt_nncq_cycle(nxt_nncq_t const volatile *q, nxt_nncq_atomic_t i)
 {
     return i / NXT_NNCQ_SIZE;
 }
 
 
-static inline nxt_nncq_cycle_t
+inline nxt_nncq_cycle_t
 nxt_nncq_next_cycle(nxt_nncq_t const volatile *q, nxt_nncq_cycle_t i)
 {
     return i + 1;
 }
 
 
-static inline nxt_nncq_atomic_t
+inline nxt_nncq_atomic_t
 nxt_nncq_new_entry(nxt_nncq_t const volatile *q, nxt_nncq_cycle_t cycle,
     nxt_nncq_atomic_t i)
 {
@@ -78,14 +78,14 @@ nxt_nncq_new_entry(nxt_nncq_t const volatile *q, nxt_nncq_cycle_t cycle,
 }
 
 
-static inline nxt_nncq_atomic_t
+inline nxt_nncq_atomic_t
 nxt_nncq_empty(nxt_nncq_t const volatile *q)
 {
     return NXT_NNCQ_SIZE;
 }
 
 
-static void
+inline void
 nxt_nncq_init(nxt_nncq_t volatile *q)
 {
     q->head = NXT_NNCQ_SIZE;
@@ -94,7 +94,7 @@ nxt_nncq_init(nxt_nncq_t volatile *q)
 }
 
 
-static void
+inline void
 nxt_nncq_enqueue(nxt_nncq_t volatile *q, nxt_nncq_atomic_t val)
 {
     nxt_nncq_cycle_t   e_cycle, t_cycle;
@@ -128,7 +128,7 @@ nxt_nncq_enqueue(nxt_nncq_t volatile *q, nxt_nncq_atomic_t val)
 }
 
 
-static nxt_nncq_atomic_t
+inline nxt_nncq_atomic_t
 nxt_nncq_dequeue(nxt_nncq_t volatile *q)
 {
     nxt_nncq_cycle_t   e_cycle, h_cycle;
-- 
2.36.1



More information about the unit mailing list