[libc-commits] [libc] cae84d8 - [libc] Correct usage of __unix__ and __linux__

Sam James via libc-commits libc-commits at lists.llvm.org
Sun Jul 2 17:08:25 PDT 2023


Author: Alfred Persson Forsberg
Date: 2023-07-03T01:08:15+01:00
New Revision: cae84d8acf5ec7a8f7b9fd2ce33397bcc22c590c

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

LOG: [libc] Correct usage of __unix__ and __linux__

Reviewed By: michaelrj, thesamesam

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

Added: 
    

Modified: 
    libc/include/llvm-libc-macros/fcntl-macros.h
    libc/include/llvm-libc-macros/sched-macros.h
    libc/include/llvm-libc-macros/sys-ioctl-macros.h
    libc/include/llvm-libc-macros/sys-mman-macros.h
    libc/include/llvm-libc-macros/sys-random-macros.h
    libc/include/llvm-libc-macros/sys-resource-macros.h
    libc/include/llvm-libc-macros/sys-socket-macros.h
    libc/include/llvm-libc-macros/sys-stat-macros.h
    libc/include/llvm-libc-macros/sys-time-macros.h
    libc/include/llvm-libc-macros/time-macros.h
    libc/include/llvm-libc-macros/unistd-macros.h
    libc/include/llvm-libc-types/__mutex_type.h
    libc/include/llvm-libc-types/once_flag.h
    libc/include/llvm-libc-types/pthread_once_t.h
    libc/include/llvm-libc-types/struct_dirent.h
    libc/include/llvm-libc-types/struct_utsname.h
    libc/src/__support/File/dir.cpp
    libc/src/__support/OSUtil/io.h
    libc/src/__support/OSUtil/quick_exit.h
    libc/src/__support/OSUtil/syscall.h
    libc/src/__support/threads/mutex.h

Removed: 
    


################################################################################
diff  --git a/libc/include/llvm-libc-macros/fcntl-macros.h b/libc/include/llvm-libc-macros/fcntl-macros.h
index 4d957e17cafee0..448dcc0a813536 100644
--- a/libc/include/llvm-libc-macros/fcntl-macros.h
+++ b/libc/include/llvm-libc-macros/fcntl-macros.h
@@ -1,7 +1,7 @@
 #ifndef __LLVM_LIBC_MACROS_FCNTL_MACROS_H
 #define __LLVM_LIBC_MACROS_FCNTL_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/fcntl-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/sched-macros.h b/libc/include/llvm-libc-macros/sched-macros.h
index 2211d12caf97cd..760edd9feb723d 100644
--- a/libc/include/llvm-libc-macros/sched-macros.h
+++ b/libc/include/llvm-libc-macros/sched-macros.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_MACROS_SCHED_MACROS_H
 #define __LLVM_LIBC_MACROS_SCHED_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/sched-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/sys-ioctl-macros.h b/libc/include/llvm-libc-macros/sys-ioctl-macros.h
index b3fbfe346f829a..c273fab36e3fe5 100644
--- a/libc/include/llvm-libc-macros/sys-ioctl-macros.h
+++ b/libc/include/llvm-libc-macros/sys-ioctl-macros.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_MACROS_SYS_IOCTL_MACROS_H
 #define __LLVM_LIBC_MACROS_SYS_IOCTL_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/sys-ioctl-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/sys-mman-macros.h b/libc/include/llvm-libc-macros/sys-mman-macros.h
index 4e2231871466a6..97aeaa6967836b 100644
--- a/libc/include/llvm-libc-macros/sys-mman-macros.h
+++ b/libc/include/llvm-libc-macros/sys-mman-macros.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_MACROS_SYS_MMAN_MACROS_H
 #define __LLVM_LIBC_MACROS_SYS_MMAN_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/sys-mman-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/sys-random-macros.h b/libc/include/llvm-libc-macros/sys-random-macros.h
index 4e59efcaa1597f..e87128d0d0fcb3 100644
--- a/libc/include/llvm-libc-macros/sys-random-macros.h
+++ b/libc/include/llvm-libc-macros/sys-random-macros.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_MACROS_SYS_RANDOM_MACROS_H
 #define __LLVM_LIBC_MACROS_SYS_RANDOM_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/sys-random-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/sys-resource-macros.h b/libc/include/llvm-libc-macros/sys-resource-macros.h
index d85bdde07cf801..272723a955a76a 100644
--- a/libc/include/llvm-libc-macros/sys-resource-macros.h
+++ b/libc/include/llvm-libc-macros/sys-resource-macros.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_MACROS_SYS_RESOURCE_MACROS_H
 #define __LLVM_LIBC_MACROS_SYS_RESOURCE_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/sys-resource-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/sys-socket-macros.h b/libc/include/llvm-libc-macros/sys-socket-macros.h
index 935f43341c998b..2032360990631c 100644
--- a/libc/include/llvm-libc-macros/sys-socket-macros.h
+++ b/libc/include/llvm-libc-macros/sys-socket-macros.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_MACROS_SYS_SOCKET_MACROS_H
 #define __LLVM_LIBC_MACROS_SYS_SOCKET_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/sys-socket-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/sys-stat-macros.h b/libc/include/llvm-libc-macros/sys-stat-macros.h
index c09b489b585671..64f63c33b3e5b8 100644
--- a/libc/include/llvm-libc-macros/sys-stat-macros.h
+++ b/libc/include/llvm-libc-macros/sys-stat-macros.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_MACROS_SYS_STAT_MACROS_H
 #define __LLVM_LIBC_MACROS_SYS_STAT_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/sys-stat-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/sys-time-macros.h b/libc/include/llvm-libc-macros/sys-time-macros.h
index 5254cab0ad227a..8e463170330847 100644
--- a/libc/include/llvm-libc-macros/sys-time-macros.h
+++ b/libc/include/llvm-libc-macros/sys-time-macros.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_MACROS_SYS_TIME_MACROS_H
 #define __LLVM_LIBC_MACROS_SYS_TIME_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/sys-time-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/time-macros.h b/libc/include/llvm-libc-macros/time-macros.h
index 9d5fad5ea86e11..ffd46317b92e65 100644
--- a/libc/include/llvm-libc-macros/time-macros.h
+++ b/libc/include/llvm-libc-macros/time-macros.h
@@ -1,7 +1,7 @@
 #ifndef __LLVM_LIBC_MACROS_TIME_MACROS_H
 #define __LLVM_LIBC_MACROS_TIME_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/time-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-macros/unistd-macros.h b/libc/include/llvm-libc-macros/unistd-macros.h
index d00942fd582818..dbcac0f5e72dcb 100644
--- a/libc/include/llvm-libc-macros/unistd-macros.h
+++ b/libc/include/llvm-libc-macros/unistd-macros.h
@@ -1,7 +1,7 @@
 #ifndef __LLVM_LIBC_MACROS_UNISTD_MACROS_H
 #define __LLVM_LIBC_MACROS_UNISTD_MACROS_H
 
-#ifdef __unix__
+#ifdef __linux__
 #include "linux/unistd-macros.h"
 #endif
 

diff  --git a/libc/include/llvm-libc-types/__mutex_type.h b/libc/include/llvm-libc-types/__mutex_type.h
index ffd67e7c7bc336..a7ed8f843c3aa5 100644
--- a/libc/include/llvm-libc-types/__mutex_type.h
+++ b/libc/include/llvm-libc-types/__mutex_type.h
@@ -19,7 +19,7 @@ typedef struct {
   void *__owner;
   unsigned long long __lock_count;
 
-#ifdef __unix__
+#ifdef __linux__
   __futex_word __ftxw;
 #else
 #error "Mutex type not defined for the target platform."

diff  --git a/libc/include/llvm-libc-types/once_flag.h b/libc/include/llvm-libc-types/once_flag.h
index e6aec5e6522d6d..77bab28338a02c 100644
--- a/libc/include/llvm-libc-types/once_flag.h
+++ b/libc/include/llvm-libc-types/once_flag.h
@@ -11,7 +11,7 @@
 
 #include <llvm-libc-types/__futex_word.h>
 
-#ifdef __unix__
+#ifdef __linux__
 typedef __futex_word once_flag;
 #else
 #error "Once flag type not defined for the target platform."

diff  --git a/libc/include/llvm-libc-types/pthread_once_t.h b/libc/include/llvm-libc-types/pthread_once_t.h
index be5c139d0c0e69..6d65f8f7405219 100644
--- a/libc/include/llvm-libc-types/pthread_once_t.h
+++ b/libc/include/llvm-libc-types/pthread_once_t.h
@@ -11,7 +11,7 @@
 
 #include <llvm-libc-types/__futex_word.h>
 
-#ifdef __unix__
+#ifdef __linux__
 typedef __futex_word pthread_once_t;
 #else
 #error "Once flag type not defined for the target platform."

diff  --git a/libc/include/llvm-libc-types/struct_dirent.h b/libc/include/llvm-libc-types/struct_dirent.h
index fde3f8ce479804..de54a2262446f5 100644
--- a/libc/include/llvm-libc-types/struct_dirent.h
+++ b/libc/include/llvm-libc-types/struct_dirent.h
@@ -14,7 +14,7 @@
 
 struct dirent {
   ino_t d_ino;
-#ifdef __unix__
+#ifdef __linux__
   off_t d_off;
   unsigned short d_reclen;
 #endif

diff  --git a/libc/include/llvm-libc-types/struct_utsname.h b/libc/include/llvm-libc-types/struct_utsname.h
index 8d41938ab6932e..8ec426ac9b43c6 100644
--- a/libc/include/llvm-libc-types/struct_utsname.h
+++ b/libc/include/llvm-libc-types/struct_utsname.h
@@ -9,7 +9,7 @@
 #ifndef __LLVM_LIBC_TYPES_STRUCT_UTSNAME_H__
 #define __LLVM_LIBC_TYPES_STRUCT_UTSNAME_H__
 
-#ifdef __unix__
+#ifdef __linux__
 #define __UTS_NAME_LENGTH 65
 #else
 // Arbitray default. Should be specialized for each platform.
@@ -22,7 +22,7 @@ struct utsname {
   char release[__UTS_NAME_LENGTH];
   char version[__UTS_NAME_LENGTH];
   char machine[__UTS_NAME_LENGTH];
-#ifdef __unix__
+#ifdef __linux__
   char domainname[__UTS_NAME_LENGTH];
 #endif
 };

diff  --git a/libc/src/__support/File/dir.cpp b/libc/src/__support/File/dir.cpp
index e7cc4ca0b19b64..93b609dc7b755f 100644
--- a/libc/src/__support/File/dir.cpp
+++ b/libc/src/__support/File/dir.cpp
@@ -39,7 +39,7 @@ ErrorOr<struct ::dirent *> Dir::read() {
     return nullptr;
 
   struct ::dirent *d = reinterpret_cast<struct ::dirent *>(buffer + readptr);
-#ifdef __unix__
+#ifdef __linux__
   // The d_reclen field is available on Linux but not required by POSIX.
   readptr += d->d_reclen;
 #else

diff  --git a/libc/src/__support/OSUtil/io.h b/libc/src/__support/OSUtil/io.h
index 9330ee57646de3..54b7d051da7c09 100644
--- a/libc/src/__support/OSUtil/io.h
+++ b/libc/src/__support/OSUtil/io.h
@@ -15,7 +15,7 @@
 #include "gpu/io.h"
 #elif defined(__APPLE__)
 #include "darwin/io.h"
-#elif defined(__unix__)
+#elif defined(__linux__)
 #include "linux/io.h"
 #elif defined(__Fuchsia__)
 #include "fuchsia/io.h"

diff  --git a/libc/src/__support/OSUtil/quick_exit.h b/libc/src/__support/OSUtil/quick_exit.h
index ae0192d02c1bb9..4001e0bcda687f 100644
--- a/libc/src/__support/OSUtil/quick_exit.h
+++ b/libc/src/__support/OSUtil/quick_exit.h
@@ -15,7 +15,7 @@
 #include "gpu/quick_exit.h"
 #elif defined(__APPLE__)
 #include "darwin/quick_exit.h"
-#elif defined(__unix__)
+#elif defined(__linux__)
 #include "linux/quick_exit.h"
 #endif
 

diff  --git a/libc/src/__support/OSUtil/syscall.h b/libc/src/__support/OSUtil/syscall.h
index 3601e7653123a6..6ec9f070a48e32 100644
--- a/libc/src/__support/OSUtil/syscall.h
+++ b/libc/src/__support/OSUtil/syscall.h
@@ -11,7 +11,7 @@
 
 #ifdef __APPLE__
 #include "darwin/syscall.h"
-#elif defined(__unix__)
+#elif defined(__linux__)
 #include "linux/syscall.h"
 #endif
 

diff  --git a/libc/src/__support/threads/mutex.h b/libc/src/__support/threads/mutex.h
index 3c2291d8f41fd1..9f73d7c7409bf2 100644
--- a/libc/src/__support/threads/mutex.h
+++ b/libc/src/__support/threads/mutex.h
@@ -37,11 +37,11 @@
 // few global locks. So, to avoid static initialization order fiasco, we
 // want the constructors of the Mutex classes to be constexprs.
 
-#if defined(__unix__)
+#if defined(__linux__)
 #include "linux/mutex.h"
 #elif defined(LIBC_TARGET_ARCH_IS_GPU)
 #include "gpu/mutex.h"
-#endif // __unix__
+#endif // __linux__
 
 namespace __llvm_libc {
 


        


More information about the libc-commits mailing list