mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-06-19 14:02:56 +02:00
Why: AIX can provide sys/queue.h without the BSD STAILQ macros. The new dynstats file-write queue then fails during normal parser builds before rsyslogd can be linked. Impact: Platforms with STAILQ in sys/queue.h keep using their native macros; AIX-like headers now get the small subset rsyslog needs. Before/After: Before, dynstats.h used STAILQ_HEAD directly from sys/queue.h. After, a configure check selects the native STAILQ macros when available and a local fallback otherwise. Technical Overview: Add a configure probe for sys/queue.h and for the STAILQ macro subset. Add runtime/compat_queue.h as the common include for rsyslog sources that need BSD queue declarations. The wrapper includes the platform header when available and defines only the missing STAILQ helpers used by dynstats and imptcp when configure did not find native STAILQ support. It also includes stddef.h so the fallback macros own their NULL dependency. Switch direct sys/queue.h users to the wrapper and distribute the new runtime header through runtime/Makefile.am. Closes https://github.com/rsyslog/rsyslog/issues/6885 With the help of AI-Agents: Codex
68 lines
2.2 KiB
C
68 lines
2.2 KiB
C
/*
|
|
* Compatibility helpers for BSD sys/queue.h users.
|
|
*
|
|
* Use the platform STAILQ macros when configure found them. Some platforms
|
|
* provide sys/queue.h without that subset, so keep the local fallback limited
|
|
* to the macros used by rsyslog.
|
|
*/
|
|
#ifndef INCLUDED_COMPAT_QUEUE_H
|
|
#define INCLUDED_COMPAT_QUEUE_H
|
|
|
|
#include <stddef.h>
|
|
#ifdef HAVE_SYS_QUEUE_H
|
|
#include <sys/queue.h>
|
|
#endif
|
|
|
|
#ifndef HAVE_SYS_QUEUE_STAILQ
|
|
#ifndef STAILQ_HEAD
|
|
#define STAILQ_HEAD(name, type) \
|
|
struct name { \
|
|
struct type *stqh_first; \
|
|
struct type **stqh_last; \
|
|
}
|
|
#endif
|
|
|
|
#ifndef STAILQ_ENTRY
|
|
#define STAILQ_ENTRY(type) \
|
|
struct { \
|
|
struct type *stqe_next; \
|
|
}
|
|
#endif
|
|
|
|
#ifndef STAILQ_INIT
|
|
#define STAILQ_INIT(head) \
|
|
do { \
|
|
(head)->stqh_first = NULL; \
|
|
(head)->stqh_last = &(head)->stqh_first; \
|
|
} while (0)
|
|
#endif
|
|
|
|
#ifndef STAILQ_EMPTY
|
|
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
|
|
#endif
|
|
|
|
#ifndef STAILQ_FIRST
|
|
#define STAILQ_FIRST(head) ((head)->stqh_first)
|
|
#endif
|
|
|
|
#ifndef STAILQ_INSERT_TAIL
|
|
#define STAILQ_INSERT_TAIL(head, elm, field) \
|
|
do { \
|
|
(elm)->field.stqe_next = NULL; \
|
|
*(head)->stqh_last = (elm); \
|
|
(head)->stqh_last = &(elm)->field.stqe_next; \
|
|
} while (0)
|
|
#endif
|
|
|
|
#ifndef STAILQ_REMOVE_HEAD
|
|
#define STAILQ_REMOVE_HEAD(head, field) \
|
|
do { \
|
|
if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) { \
|
|
(head)->stqh_last = &(head)->stqh_first; \
|
|
} \
|
|
} while (0)
|
|
#endif
|
|
#endif
|
|
|
|
#endif /* #ifndef INCLUDED_COMPAT_QUEUE_H */
|