[libc-commits] [PATCH] D153729: [libc] Correct usage of __unix__ and __linux__

Alfred Persson Forsberg via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Jun 26 04:11:29 PDT 2023


alfredfo added a comment.

In D153729#4447715 <https://reviews.llvm.org/D153729#4447715>, @sivachandra wrote:

> LGTM, but...
>
> In D153729#4447435 <https://reviews.llvm.org/D153729#4447435>, @alfredfo wrote:
>
>> Here are things still using `__unix__`, and I'm pretty sure those are correct.
>
> All of them seem to be related to the Linux futex word. Wouldn't `__linux__` be the most appropriate for them as well?

Oh right, definitely not available on all Unix systems.



================
Comment at: libc/include/llvm-libc-types/struct_dirent.h:21
 #endif
   unsigned char d_type;
   // The user code should use strlen to determine actual the size of d_name.
----------------
only d_ino (XSI) and d_name are specified by POSIX.


================
Comment at: libc/include/llvm-libc-types/struct_utsname.h:15
 #else
 // Arbitray default. Should be specialized for each platform.
 #define __UTS_NAME_LENGTH 1024
----------------
Apple `(__APPLE__)` uses 256: https://opensource.apple.com/source/xnu/xnu-201/bsd/sys/utsname.h.auto.html


================
Comment at: libc/include/llvm-libc-types/struct_utsname.h:26
+#ifdef __linux__
   char domainname[__UTS_NAME_LENGTH];
 #endif
----------------
GNU extension


================
Comment at: libc/src/__support/File/dir.cpp:43
+#ifdef __linux__
   // The d_reclen field is available on Linux but not required by POSIX.
   readptr += d->d_reclen;
----------------
checked using _DIRENT_HAVE_D_RECLEN, respected by both musl and glibc

ditto _OFF, _TYPE


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153729/new/

https://reviews.llvm.org/D153729



More information about the libc-commits mailing list