From eec3d7893d6e6c69616aebb2a0fdbf7bfb2bd818 Mon Sep 17 00:00:00 2001 From: Matthew Stanley <1379tech@gmail.com> Date: Fri, 12 Jun 2026 19:30:50 -0700 Subject: [PATCH] debug_server: use _DARWIN_C_SOURCE on macOS for full BSD+POSIX namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS, defining _POSIX_C_SOURCE restricts the visible namespace and HIDES BSD symbols the TCP debug server needs — notably INADDR_LOOPBACK (and struct timeval). clang then fails with 'use of undeclared identifier INADDR_LOOPBACK'. Use _DARWIN_C_SOURCE on Apple (which exposes the full BSD+POSIX namespace incl. clock_gettime), keeping _POSIX_C_SOURCE for glibc. Mirrors the same __APPLE__/_DARWIN_C_SOURCE guard already used in psx_fiber.c. --- runtime/src/debug_server.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/src/debug_server.c b/runtime/src/debug_server.c index 0c690b97..dfcf34c9 100644 --- a/runtime/src/debug_server.c +++ b/runtime/src/debug_server.c @@ -9,7 +9,9 @@ */ /* Expose POSIX clock_gettime()/CLOCK_MONOTONIC (used by monotonic_ms) on * glibc — must precede any system header. Harmless on Windows/macOS. */ -#ifndef _POSIX_C_SOURCE +#ifdef __APPLE__ +# define _DARWIN_C_SOURCE 1 /* full BSD+POSIX namespace: clock_gettime AND INADDR_LOOPBACK/timeval */ +#elif !defined(_POSIX_C_SOURCE) # define _POSIX_C_SOURCE 200809L #endif #include