From 917c0541e4cc60fc4ea6fe434dabe0699ca7c2fd Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 26 May 2024 11:38:46 -0600 Subject: [PATCH] cross-tools: Document a rather bizarre looking construct On Linux, stddef.h will define __size_t to something when size_t is defined. On FreeBSD, __size_t is an actual typedef which we need for other parts of the system. If __size_t isn't defined, that tells us we need to define the fallback __size_t typedef (if it is defined, then we can't easily redefine it without issues because glob.h will define it to something different than stddef.h defines it). Add a comment to this effect. Sponsored by: Netflix Reviewed by: val_packett.cool Differential Revision: https://reviews.freebsd.org/D45350 --- tools/build/cross-build/include/linux/sys/types.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/build/cross-build/include/linux/sys/types.h b/tools/build/cross-build/include/linux/sys/types.h index 770b3057f8a8..222560167a71 100644 --- a/tools/build/cross-build/include/linux/sys/types.h +++ b/tools/build/cross-build/include/linux/sys/types.h @@ -37,6 +37,13 @@ #include_next +/* + * stddef.h for both gcc and clang will define __size_t when size_t has + * been defined (except on *BSD where it doesn't touch __size_t). So if + * we're building on Linux, we know that if that's not defined, we have + * to typedef __size_t for FreeBSD's use of __size_t in places to work + * during bootstrapping. + */ #ifndef __size_t typedef __SIZE_TYPE__ __size_t; #endif