commit e10111ba5d4dd010e5035144d054f587cad507b7
parent dca1d7920a5a3ee3c5fd68e4d277264c3603495c
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Wed, 29 Apr 2026 11:30:13 -0700
libc-flatten: silence host preprocessor warnings
Three -W warnings emitted while flattening libc.flat.c:
- '/*' within block comment: lispcc-syscall.c had `posix/*.c` in a
block comment; the substring opens a nested block comment.
- -Wexpansion-to-defined ×2: mes/ntoab.c wraps `defined()` inside a
#define body, which is ISO-C UB. The mes author's FIXME comment
already had the inlined `#if` form; new ntoab-inline-defined patch
promotes it.
Diffstat:
5 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/docs/LIBC.md b/docs/LIBC.md
@@ -140,6 +140,7 @@ shape `stage1-flatten.sh` uses for tcc):
| libmini-write-proto | include/mes/lib-mini.h | `void __init_io ();` → typed prototype. cc.scm rejects empty-arg-list redecls when followed by a typed definition. |
| libmini-write-proto2 | include/mes/lib-mini.h | same fix for `ssize_t _write ();`. |
| lib-mes-debug-proto | include/mes/lib.h | same fix for `__mes_debug ()` and `__ungetc_init ()`. |
+| ntoab-inline-defined | mes/ntoab.c | drop a helper macro that wraps `defined()` (UB per ISO C; clang `-Wexpansion-to-defined`). The mes author's FIXME comment already had the inlined form. |
`mes/globals.c` is intentionally **not** patched — it must stay plain
int globals (no TLS).
diff --git a/scripts/libc-flatten.sh b/scripts/libc-flatten.sh
@@ -116,6 +116,10 @@ apply_simple_patch \
"$STAGE/include/mes/lib.h" \
"$PATCHES/lib-mes-debug-proto.before" \
"$PATCHES/lib-mes-debug-proto.after"
+apply_simple_patch \
+ "$STAGE/mes/ntoab.c" \
+ "$PATCHES/ntoab-inline-defined.before" \
+ "$PATCHES/ntoab-inline-defined.after"
# --- (3) flatten via host preprocessor --------------------------------
HOST_CC=${HOST_CC:-cc}
diff --git a/vendor/mes-libc/lispcc-syscall.c b/vendor/mes-libc/lispcc-syscall.c
@@ -7,7 +7,7 @@
* external-linkage rule (commit 6488cca).
*
* Layering:
- * public libc (read, write, open, …) — comes from posix/*.c
+ * public libc (read, write, open, …) — comes from the posix layer
* └─ low-level _read, _write, _open3 — provided here
* └─ named sys_* labels — provided by P1pp.P1pp
*
diff --git a/vendor/mes-libc/patches/ntoab-inline-defined.after b/vendor/mes-libc/patches/ntoab-inline-defined.after
@@ -0,0 +1,4 @@
+/* lispcc: drop the helper macro — wrapping `defined()` in a #define body
+ * is UB per ISO C and triggers -Wexpansion-to-defined. The mes author's
+ * FIXME comment already had the inlined form; we just promote it. */
+#if __M2__ || (!defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP))
diff --git a/vendor/mes-libc/patches/ntoab-inline-defined.before b/vendor/mes-libc/patches/ntoab-inline-defined.before
@@ -0,0 +1,5 @@
+#define __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP !defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP)
+
+// FIXME: M2-Planet 1.10.0 crashes on this...
+// #if __M2__ || (!defined (__MESC__and__arm__) && !defined (__TINYC__and__arm__and__BOOTSTRAP))
+#if __M2__ || __not__MESC__arm__and__not__TINYC__arm__BOOTSTRAP