[PATCH 16/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:10 UTC 2022


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

diff --git a/auto/sources b/auto/sources
index 4042a63..dfbc580 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_app_nncq.c \
     src/nxt_nncq.c \
     src/nxt_time.c \
     src/nxt_malloc.c \
diff --git a/src/nxt_app_nncq.c b/src/nxt_app_nncq.c
new file mode 100644
index 00000000..0531cb1
--- /dev/null
+++ b/src/nxt_app_nncq.c
@@ -0,0 +1,29 @@
+
+#include <nxt_main.h>
+
+#include <nxt_app_nncq.h>
+
+
+extern nxt_app_nncq_atomic_t nxt_app_nncq_head(
+    nxt_app_nncq_t const volatile *q);
+extern nxt_app_nncq_atomic_t nxt_app_nncq_tail(
+    nxt_app_nncq_t const volatile *q);
+extern void nxt_app_nncq_tail_cmp_inc(nxt_app_nncq_t volatile *q,
+    nxt_app_nncq_atomic_t t);
+extern nxt_app_nncq_atomic_t nxt_app_nncq_index(
+    nxt_app_nncq_t const volatile *q, nxt_app_nncq_atomic_t i);
+extern nxt_app_nncq_atomic_t nxt_app_nncq_map(nxt_app_nncq_t const volatile *q,
+    nxt_app_nncq_atomic_t i);
+extern nxt_app_nncq_cycle_t nxt_app_nncq_cycle(nxt_app_nncq_t const volatile *q,
+    nxt_app_nncq_atomic_t i);
+extern nxt_app_nncq_cycle_t nxt_app_nncq_next_cycle(
+    nxt_app_nncq_t const volatile *q, nxt_app_nncq_cycle_t i);
+extern nxt_app_nncq_atomic_t nxt_app_nncq_new_entry(
+    nxt_app_nncq_t const volatile *q, nxt_app_nncq_cycle_t cycle,
+    nxt_app_nncq_atomic_t i);
+extern nxt_app_nncq_atomic_t nxt_app_nncq_empty(
+    nxt_app_nncq_t const volatile *q);
+extern void nxt_app_nncq_init(nxt_app_nncq_t volatile *q);
+extern void nxt_app_nncq_enqueue(nxt_app_nncq_t volatile *q,
+    nxt_app_nncq_atomic_t val);
+extern nxt_app_nncq_atomic_t nxt_app_nncq_dequeue(nxt_app_nncq_t volatile *q);
diff --git a/src/nxt_app_nncq.h b/src/nxt_app_nncq.h
index f9b8ce0..5768f73 100644
--- a/src/nxt_app_nncq.h
+++ b/src/nxt_app_nncq.h
@@ -21,49 +21,49 @@ typedef struct {
 } nxt_app_nncq_t;
 
 
-static inline nxt_app_nncq_atomic_t
+inline nxt_app_nncq_atomic_t
 nxt_app_nncq_head(nxt_app_nncq_t const volatile *q)
 {
     return q->head;
 }
 
 
-static inline nxt_app_nncq_atomic_t
+inline nxt_app_nncq_atomic_t
 nxt_app_nncq_tail(nxt_app_nncq_t const volatile *q)
 {
     return q->tail;
 }
 
 
-static inline void
+inline void
 nxt_app_nncq_tail_cmp_inc(nxt_app_nncq_t volatile *q, nxt_app_nncq_atomic_t t)
 {
     nxt_atomic_cmp_set(&q->tail, t, t + 1);
 }
 
 
-static inline nxt_app_nncq_atomic_t
+inline nxt_app_nncq_atomic_t
 nxt_app_nncq_index(nxt_app_nncq_t const volatile *q, nxt_app_nncq_atomic_t i)
 {
     return i % NXT_APP_NNCQ_SIZE;
 }
 
 
-static inline nxt_app_nncq_atomic_t
+inline nxt_app_nncq_atomic_t
 nxt_app_nncq_map(nxt_app_nncq_t const volatile *q, nxt_app_nncq_atomic_t i)
 {
     return i % NXT_APP_NNCQ_SIZE;
 }
 
 
-static inline nxt_app_nncq_cycle_t
+inline nxt_app_nncq_cycle_t
 nxt_app_nncq_cycle(nxt_app_nncq_t const volatile *q, nxt_app_nncq_atomic_t i)
 {
     return i / NXT_APP_NNCQ_SIZE;
 }
 
 
-static inline nxt_app_nncq_cycle_t
+inline nxt_app_nncq_cycle_t
 nxt_app_nncq_next_cycle(nxt_app_nncq_t const volatile *q,
     nxt_app_nncq_cycle_t i)
 {
@@ -71,7 +71,7 @@ nxt_app_nncq_next_cycle(nxt_app_nncq_t const volatile *q,
 }
 
 
-static inline nxt_app_nncq_atomic_t
+inline nxt_app_nncq_atomic_t
 nxt_app_nncq_new_entry(nxt_app_nncq_t const volatile *q,
     nxt_app_nncq_cycle_t cycle,
     nxt_app_nncq_atomic_t i)
@@ -80,14 +80,14 @@ nxt_app_nncq_new_entry(nxt_app_nncq_t const volatile *q,
 }
 
 
-static inline nxt_app_nncq_atomic_t
+inline nxt_app_nncq_atomic_t
 nxt_app_nncq_empty(nxt_app_nncq_t const volatile *q)
 {
     return NXT_APP_NNCQ_SIZE;
 }
 
 
-static void
+inline void
 nxt_app_nncq_init(nxt_app_nncq_t volatile *q)
 {
     q->head = NXT_APP_NNCQ_SIZE;
@@ -97,7 +97,7 @@ nxt_app_nncq_init(nxt_app_nncq_t volatile *q)
 }
 
 
-static void
+inline void
 nxt_app_nncq_enqueue(nxt_app_nncq_t volatile *q, nxt_app_nncq_atomic_t val)
 {
     nxt_app_nncq_cycle_t   e_cycle, t_cycle;
@@ -131,7 +131,7 @@ nxt_app_nncq_enqueue(nxt_app_nncq_t volatile *q, nxt_app_nncq_atomic_t val)
 }
 
 
-static nxt_app_nncq_atomic_t
+inline nxt_app_nncq_atomic_t
 nxt_app_nncq_dequeue(nxt_app_nncq_t volatile *q)
 {
     nxt_app_nncq_cycle_t   e_cycle, h_cycle;
diff --git a/src/nxt_nncq.c b/src/nxt_nncq.c
index 92ff81e..e6b126a 100644
--- a/src/nxt_nncq.c
+++ b/src/nxt_nncq.c
@@ -1,6 +1,8 @@
 
 #include <nxt_main.h>
 
+#include <nxt_nncq.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);
-- 
2.36.1



More information about the unit mailing list