aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lib
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-06-13 12:00:58 +0200
committerbfredl <bjorn.linse@gmail.com>2024-07-13 12:30:49 +0200
commit7dffc36e61c46e6adc92cff5944e876446f3c40e (patch)
tree99278b5578dbcf5cbe5e53ca158bfc0de5df58d1 /src/nvim/lib
parentb0f39f3ef5502c037b5bdb0da3d45d312b7fdc2a (diff)
downloadrneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.tar.gz
rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.tar.bz2
rneovim-7dffc36e61c46e6adc92cff5944e876446f3c40e.zip
refactor(declarations): also generate prototypes for functions in headers
Before this change, "static inline" functions in headers needed to have their function attributes specified in a completely different way. The prototype had to be duplicated, and REAL_FATTR_ had to be used instead of the public FUNC_ATTR_ names. TODO: need a check that a "header.h.inline.generated.h" file is not forgotten when the first "static inline" function with attributes is added to a header (they would just be silently missing).
Diffstat (limited to 'src/nvim/lib')
-rw-r--r--src/nvim/lib/queue_defs.h30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/nvim/lib/queue_defs.h b/src/nvim/lib/queue_defs.h
index 1f113a057a..4f32f5fcb6 100644
--- a/src/nvim/lib/queue_defs.h
+++ b/src/nvim/lib/queue_defs.h
@@ -21,13 +21,15 @@
#include <stddef.h>
-#include "nvim/func_attr.h"
-
typedef struct queue {
struct queue *next;
struct queue *prev;
} QUEUE;
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "lib/queue_defs.h.inline.generated.h"
+#endif
+
// Public macros.
#define QUEUE_DATA(ptr, type, field) \
((type *)((char *)(ptr) - offsetof(type, field)))
@@ -44,29 +46,23 @@ typedef struct queue {
}
// ffi.cdef is unable to swallow `bool` in place of `int` here.
-static inline int QUEUE_EMPTY(const QUEUE *q)
- REAL_FATTR_ALWAYS_INLINE REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT;
-
static inline int QUEUE_EMPTY(const QUEUE *const q)
+ FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
{
return q == q->next;
}
#define QUEUE_HEAD(q) (q)->next
-static inline void QUEUE_INIT(QUEUE *q)
- REAL_FATTR_ALWAYS_INLINE;
-
static inline void QUEUE_INIT(QUEUE *const q)
+ FUNC_ATTR_ALWAYS_INLINE
{
q->next = q;
q->prev = q;
}
-static inline void QUEUE_ADD(QUEUE *h, QUEUE *n)
- REAL_FATTR_ALWAYS_INLINE;
-
static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n)
+ FUNC_ATTR_ALWAYS_INLINE
{
h->prev->next = n->next;
n->next->prev = h->prev;
@@ -74,10 +70,8 @@ static inline void QUEUE_ADD(QUEUE *const h, QUEUE *const n)
h->prev->next = h;
}
-static inline void QUEUE_INSERT_HEAD(QUEUE *h, QUEUE *q)
- REAL_FATTR_ALWAYS_INLINE;
-
static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q)
+ FUNC_ATTR_ALWAYS_INLINE
{
q->next = h->next;
q->prev = h;
@@ -85,10 +79,8 @@ static inline void QUEUE_INSERT_HEAD(QUEUE *const h, QUEUE *const q)
h->next = q;
}
-static inline void QUEUE_INSERT_TAIL(QUEUE *h, QUEUE *q)
- REAL_FATTR_ALWAYS_INLINE;
-
static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q)
+ FUNC_ATTR_ALWAYS_INLINE
{
q->next = h;
q->prev = h->prev;
@@ -96,10 +88,8 @@ static inline void QUEUE_INSERT_TAIL(QUEUE *const h, QUEUE *const q)
h->prev = q;
}
-static inline void QUEUE_REMOVE(QUEUE *q)
- REAL_FATTR_ALWAYS_INLINE;
-
static inline void QUEUE_REMOVE(QUEUE *const q)
+ FUNC_ATTR_ALWAYS_INLINE
{
q->prev->next = q->next;
q->next->prev = q->prev;