Commit b6cb8ddc

b6cb8ddcea88Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified

Description

Define _XOPEN_SOURCE in sp_types.h so the standalone sp_fiber.c builds on macOS

After the Fiber runtime was extracted into its own translation unit (lib/sp_fiber.c), <ucontext.h> -- reached via sp_fiber.h -> sp_gc.h -> sp_types.h -- was compiled without _XOPEN_SOURCE, which the previously-inline Fiber path had been getting from sp_runtime.h's top. macOS (Xcode 16.4) then fails build/sp_fiber.o with "The deprecated ucontext routines require _XOPEN_SOURCE to be defined" (CI red since the fiber-unit split).

Move the Darwin feature-test block (_XOPEN_SOURCE / _DARWIN_C_SOURCE plus the -Wdeprecated-declarations pragma) from sp_runtime.h to the top of sp_types.h -- the shared base header that both the generated TU and every libspinel_rt.a unit (sp_fiber.c included) pull in before any system header. sp_runtime.h now obtains it by including sp_types.h before <stdio.h>, so the macros are defined in exactly one place rather than copied.

Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]

Details

Commit
b6cb8ddcea88
Parent
8512198bc794

lib/sp_runtime.hmodifiedView file

@@ -2,17 +2,12 @@
22 #ifndef SP_RUNTIME_H
33 #define SP_RUNTIME_H
44
5-#ifdef __APPLE__
6-/* getcontext/makecontext/swapcontext are gated behind _XOPEN_SOURCE on
7- Darwin and marked deprecated since 10.6. _DARWIN_C_SOURCE re-enables
8- Darwin extensions (MAP_ANON, etc.) that _XOPEN_SOURCE alone would hide.
9- Suppress the deprecation warning so -Werror builds pass — we knowingly
10- use these APIs because Spinel's Fiber implementation depends on them. */
11-#define _XOPEN_SOURCE 600
12-#define _DARWIN_C_SOURCE
13-#pragma clang diagnostic push
14-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
15-#endif
5+/* Platform feature-test macros (_XOPEN_SOURCE for Darwin's ucontext, etc.)
6+ live at the top of sp_types.h so every translation unit that includes it --
7+ the generated TU here, and the standalone libspinel_rt.a units like
8+ sp_fiber.c that reach <ucontext.h> via sp_fiber.h -> sp_gc.h -> sp_types.h --
9+ define them before the first system header. Must precede <stdio.h>. */
10+#include "sp_types.h"
1611
1712 #include <stdio.h>
1813 #include <stdlib.h>