From dc28f2faef12dc5cb260b5707120c024f1b988d5 Mon Sep 17 00:00:00 2001 From: auronandace Date: Fri, 8 May 2026 14:59:27 +0100 Subject: [PATCH] split out sizt_t from stddef header --- include/stddef.h | 3 +- src/header/bits_size-t/cbindgen.toml | 44 +++++++++++++++++++++ src/header/bits_size-t/mod.rs | 5 +++ src/header/mod.rs | 6 ++- src/header/sys_types_internal/cbindgen.toml | 1 + 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 src/header/bits_size-t/cbindgen.toml create mode 100644 src/header/bits_size-t/mod.rs diff --git a/include/stddef.h b/include/stddef.h index 334267f457..b9c936d26e 100644 --- a/include/stddef.h +++ b/include/stddef.h @@ -1,6 +1,7 @@ #ifndef _STDDEF_H #define _STDDEF_H #include +#include #define NULL 0 @@ -9,8 +10,6 @@ #endif typedef __PTRDIFF_TYPE__ ptrdiff_t; -typedef long unsigned int size_t; - typedef struct { long long __ll; long double __ld; } max_align_t; #define offsetof(type, member) __builtin_offsetof(type, member) diff --git a/src/header/bits_size-t/cbindgen.toml b/src/header/bits_size-t/cbindgen.toml new file mode 100644 index 0000000000..4fdd282e5d --- /dev/null +++ b/src/header/bits_size-t/cbindgen.toml @@ -0,0 +1,44 @@ +# POSIX header spec: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stddef.h.html +# +# This type is split out to prevent importing all of stddef.h into other headers. +# +# POSIX headers that require size_t: +# - aio.h +# - devctl.h (TODO not present in relibc) +# - dirent.h +# - glob.h +# - grp.h +# - iconv.h (external libiconv (gettext dependency)) +# - monetary.h +# - mqueue.h (TODO not present in relibc) +# - nbdm.h (TODO not present in relibc) +# - pwd.h +# - regex.h +# - search.h (TODO not present in relibc) +# - signal.h +# - stdio.h +# - stdlib.h +# - string.h +# - strings.h +# - sys/mman.h +# - sys/msg.h (TODO not present in relibc) +# - sys/sem.h (TODO not present in relibc) +# - sys/shm.h (TODO not present in relibc) +# - sys/socket.h +# - sys/types.h (should be re-exported) +# - sys/uio.h +# - time.h +# - uchar.h (TODO not present in relibc) +# - unistd.h +# - wchar.h +# - wordexp.h (TODO not present in relibc) +sys_includes = [] +include_guard = "_RELIBC_BITS_SIZE_T_H" +language = "C" +style = "type" +no_includes = true +cpp_compat = true +[export] +include = ["size_t"] +[enum] +prefix_with_name = true diff --git a/src/header/bits_size-t/mod.rs b/src/header/bits_size-t/mod.rs new file mode 100644 index 0000000000..6fefaa468d --- /dev/null +++ b/src/header/bits_size-t/mod.rs @@ -0,0 +1,5 @@ +use crate::platform::types::c_ulong; + +/// Unsigned integer type of the result of the sizeof operator. +#[allow(non_camel_case_types)] +pub type size_t = c_ulong; diff --git a/src/header/mod.rs b/src/header/mod.rs index 9ef9953492..55b7be9ca8 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -13,6 +13,8 @@ pub mod bits_pthread; pub mod bits_safamily_t; #[path = "bits_sigset-t/mod.rs"] pub mod bits_sigset_t; +#[path = "bits_size-t/mod.rs"] +pub mod bits_size_t; #[path = "bits_socklen-t/mod.rs"] pub mod bits_socklen_t; #[path = "bits_ssize-t/mod.rs"] @@ -23,7 +25,7 @@ pub mod bits_suseconds_t; pub mod bits_time_t; pub mod bits_timespec; pub mod bits_timeval; -// complex.h implemented in C +// complex.h implemented in C (currently through openlibm) pub mod cpio; pub mod crypt; pub mod ctype; @@ -134,7 +136,7 @@ pub mod sys_wait; pub mod tar; // TODO: term.h (deprecated) pub mod termios; -// TODO: tgmath.h (likely C implementation) +// TODO: tgmath.h (likely C implementation currenly through openlibm) // TODO: threads.h pub mod time; // TODO: uchar.h diff --git a/src/header/sys_types_internal/cbindgen.toml b/src/header/sys_types_internal/cbindgen.toml index 4e253f3ba4..a8862f8ac2 100644 --- a/src/header/sys_types_internal/cbindgen.toml +++ b/src/header/sys_types_internal/cbindgen.toml @@ -1,3 +1,4 @@ +# stddef.h brings in size_t sys_includes = ["stddef.h"] # TODO: figure out how to export void* type after_includes = """