From 1764004b80b12fa34889f2204519ab09b0e4fe5f Mon Sep 17 00:00:00 2001 From: auronandace Date: Tue, 31 Mar 2026 08:53:10 +0100 Subject: [PATCH] move stdio bits to cbindgen --- include/bits/stdio.h | 17 ----------------- src/header/stdio/cbindgen.toml | 15 ++++++++++++++- src/header/stdio/constants.rs | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) delete mode 100644 include/bits/stdio.h diff --git a/include/bits/stdio.h b/include/bits/stdio.h deleted file mode 100644 index 63957176c8..0000000000 --- a/include/bits/stdio.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef _BITS_STDIO_H -#define _BITS_STDIO_H - -// XXX: this is only here because cbindgen can't handle string constants -#define P_tmpdir "/tmp" - -typedef struct FILE FILE; - -// A typedef doesn't suffice, because libgmp uses this definition to check if -// STDIO was loaded. -#define FILE FILE -// Likewise, stdin, stdout, and stderr are expected to be macros. -#define stdin stdin -#define stdout stdout -#define stderr stderr - -#endif /* _BITS_STDIO_H */ diff --git a/src/header/stdio/cbindgen.toml b/src/header/stdio/cbindgen.toml index 2be650affa..540f3775b6 100644 --- a/src/header/stdio/cbindgen.toml +++ b/src/header/stdio/cbindgen.toml @@ -1,6 +1,19 @@ sys_includes = ["stdarg.h", "stddef.h", "stdint.h", "sys/types.h", "features.h"] include_guard = "_RELIBC_STDIO_H" -trailer = "#include " +trailer = """ +// XXX: this is only here because cbindgen can't handle string constants +#define P_tmpdir "/tmp" + +typedef struct FILE FILE; + +// A typedef doesn't suffice, because libgmp uses this definition to check if +// STDIO was loaded. +#define FILE FILE +// Likewise, stdin, stdout, and stderr are expected to be macros. +#define stdin stdin +#define stdout stdout +#define stderr stderr +""" language = "C" style = "Type" no_includes = true diff --git a/src/header/stdio/constants.rs b/src/header/stdio/constants.rs index 57a7cfd1ee..d8caa0ca34 100644 --- a/src/header/stdio/constants.rs +++ b/src/header/stdio/constants.rs @@ -41,7 +41,7 @@ pub const L_tmpnam: c_int = 7; // 36^6 (26 letters + 10 digits) is larger than i32::MAX, so just set to that // for now pub const TMP_MAX: int32_t = 2_147_483_647; -// XXX: defined manually in bits/stdio.h as well because cbindgen can't handle +// XXX: defined manually in cbindgen as well because it can't handle // string constants in any form AFAICT pub const P_tmpdir: &[u8; 5] = b"/tmp\0";