Skip to content

Commit 021ef69

Browse files
committed
shims: TAILQ_FOREACH_SAFE is unavailable in glibc
TAILQ_FOREACH_SAFE is a BSD specific macro. Provide a definition for it in the Linux shims. Modern glibc doesnt use the QUEUE_DEBUGGING macro, remove it.
1 parent 6899a86 commit 021ef69

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/internal.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,14 +356,10 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
356356
do { (elm)->field.tqe_prev = NULL; } while (0)
357357

358358
#if DISPATCH_DEBUG
359-
// sys/queue.h debugging
360-
#if defined(__linux__)
361-
#define QUEUE_MACRO_DEBUG 1
362-
#else
363359
#undef TRASHIT
364360
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
365-
#endif
366361
#endif // DISPATCH_DEBUG
362+
367363
#define _TAILQ_TRASH_ENTRY(elm, field) do { \
368364
TRASHIT((elm)->field.tqe_next); \
369365
TRASHIT((elm)->field.tqe_prev); \

src/shims/linux_stubs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
#ifndef __DISPATCH__STUBS__INTERNAL
1717
#define __DISPATCH__STUBS__INTERNAL
1818

19+
#if !defined(TAILQ_FOREACH_SAFE)
20+
#define TAILQ_FOREACH_SAFE(var, head, field, temp) \
21+
for ((var) = TAILQ_FIRST((head)); \
22+
(var) && ((temp) = TAILQ_NEXT((var), field), 1); (var) = (temp))
23+
#endif
24+
25+
#if !defined(TRASHIT)
26+
#define TRASHIT(x) do { (x) = (void *)-1; } while (0)
27+
#endif
28+
1929
/*
2030
* Stub out defines for some mach types and related macros
2131
*/

0 commit comments

Comments
 (0)