[libc-commits] [libc] 1acbc21 - [libc] Define __UTS_NAME_LENGTH for __APPLE__

Sam James via libc-commits libc-commits at lists.llvm.org
Sun Aug 13 17:57:09 PDT 2023


Author: Alfred Persson Forsberg
Date: 2023-08-14T01:56:32+01:00
New Revision: 1acbc21d46ba3f052471754bfa5860fba652e932

URL: https://github.com/llvm/llvm-project/commit/1acbc21d46ba3f052471754bfa5860fba652e932
DIFF: https://github.com/llvm/llvm-project/commit/1acbc21d46ba3f052471754bfa5860fba652e932.diff

LOG: [libc] Define __UTS_NAME_LENGTH for __APPLE__

Before https://github.com/llvm/llvm-project/commit/cae84d8acf5ec7a8f7b9fd2ce33397bcc22c590c all __linux__ checks were incorrectly __unix__ checks. __unix__ being true on macOS systems therefore meant that macOS would use 65 as __UTS_NAME_LENGTH.

This commit correctly specifices __UTS_NAME_LENGTH to match XNU as 256.
https://opensource.apple.com/source/xnu/xnu-201/bsd/sys/utsname.h.auto.html

Reviewed By: thesamesam

Differential Revision: https://reviews.llvm.org/D157824

Added: 
    

Modified: 
    libc/include/llvm-libc-types/struct_utsname.h

Removed: 
    


################################################################################
diff  --git a/libc/include/llvm-libc-types/struct_utsname.h b/libc/include/llvm-libc-types/struct_utsname.h
index 8ec426ac9b43c6..bfd1ad9ceddb7a 100644
--- a/libc/include/llvm-libc-types/struct_utsname.h
+++ b/libc/include/llvm-libc-types/struct_utsname.h
@@ -9,8 +9,10 @@
 #ifndef __LLVM_LIBC_TYPES_STRUCT_UTSNAME_H__
 #define __LLVM_LIBC_TYPES_STRUCT_UTSNAME_H__
 
-#ifdef __linux__
+#if defined(__linux__)
 #define __UTS_NAME_LENGTH 65
+#elif defined(__APPLE__)
+#define __UTS_NAME_LENGTH 256
 #else
 // Arbitray default. Should be specialized for each platform.
 #define __UTS_NAME_LENGTH 1024


        


More information about the libc-commits mailing list