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
#ifndef SP_RUNTIME_H#define SP_RUNTIME_H#ifdef __APPLE__/* getcontext/makecontext/swapcontext are gated behind _XOPEN_SOURCE on Darwin and marked deprecated since 10.6. _DARWIN_C_SOURCE re-enables Darwin extensions (MAP_ANON, etc.) that _XOPEN_SOURCE alone would hide. Suppress the deprecation warning so -Werror builds pass — we knowingly use these APIs because Spinel's Fiber implementation depends on them. */#define _XOPEN_SOURCE 600#define _DARWIN_C_SOURCE#pragma clang diagnostic push#pragma clang diagnostic ignored "-Wdeprecated-declarations"#endif/* Platform feature-test macros (_XOPEN_SOURCE for Darwin's ucontext, etc.) live at the top of sp_types.h so every translation unit that includes it -- the generated TU here, and the standalone libspinel_rt.a units like sp_fiber.c that reach <ucontext.h> via sp_fiber.h -> sp_gc.h -> sp_types.h -- define them before the first system header. Must precede <stdio.h>. */#include "sp_types.h"#include <stdio.h>#include <stdlib.h>lib/sp_types.hmodifiedView file
Loading diff…