mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 01:46:29 +00:00
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).
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user