Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Here are things still using __unix__, and I'm pretty sure those are correct.
$ grep -rsin '__unix__' -C10 in libc/
gives the following output:
include/llvm-libc-types/once_flag.h-4-// See https://llvm.org/LICENSE.txt for license information.
include/llvm-libc-types/once_flag.h-5-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
include/llvm-libc-types/once_flag.h-6-//
include/llvm-libc-types/once_flag.h-7-//===----------------------------------------------------------------------===//
include/llvm-libc-types/once_flag.h-8-
include/llvm-libc-types/once_flag.h-9-#ifndef __LLVM_LIBC_TYPES_ONCE_FLAG_H__
include/llvm-libc-types/once_flag.h-10-#define __LLVM_LIBC_TYPES_ONCE_FLAG_H__
include/llvm-libc-types/once_flag.h-11-
include/llvm-libc-types/once_flag.h-12-#include <llvm-libc-types/__futex_word.h>
include/llvm-libc-types/once_flag.h-13-
include/llvm-libc-types/once_flag.h:14:#ifdef __unix__
include/llvm-libc-types/once_flag.h-15-typedef __futex_word once_flag;
include/llvm-libc-types/once_flag.h-16-#else
include/llvm-libc-types/once_flag.h-17-#error "Once flag type not defined for the target platform."
include/llvm-libc-types/once_flag.h-18-#endif
include/llvm-libc-types/once_flag.h-19-
include/llvm-libc-types/once_flag.h-20-#endif // __LLVM_LIBC_TYPES_ONCE_FLAG_H__
--
include/llvm-libc-types/pthread_once_t.h-4-// See https://llvm.org/LICENSE.txt for license information.
include/llvm-libc-types/pthread_once_t.h-5-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
include/llvm-libc-types/pthread_once_t.h-6-//
include/llvm-libc-types/pthread_once_t.h-7-//===----------------------------------------------------------------------===//
include/llvm-libc-types/pthread_once_t.h-8-
include/llvm-libc-types/pthread_once_t.h-9-#ifndef __LLVM_LIBC_TYPES_PTHREAD_ONCE_T_H__
include/llvm-libc-types/pthread_once_t.h-10-#define __LLVM_LIBC_TYPES_PTHREAD_ONCE_T_H__
include/llvm-libc-types/pthread_once_t.h-11-
include/llvm-libc-types/pthread_once_t.h-12-#include <llvm-libc-types/__futex_word.h>
include/llvm-libc-types/pthread_once_t.h-13-
include/llvm-libc-types/pthread_once_t.h:14:#ifdef __unix__
include/llvm-libc-types/pthread_once_t.h-15-typedef __futex_word pthread_once_t;
include/llvm-libc-types/pthread_once_t.h-16-#else
include/llvm-libc-types/pthread_once_t.h-17-#error "Once flag type not defined for the target platform."
include/llvm-libc-types/pthread_once_t.h-18-#endif
include/llvm-libc-types/pthread_once_t.h-19-
include/llvm-libc-types/pthread_once_t.h-20-#endif // __LLVM_LIBC_TYPES_PTHREAD_ONCE_T_H__
--
include/llvm-libc-types/__mutex_type.h-12-#include <llvm-libc-types/__futex_word.h>
include/llvm-libc-types/__mutex_type.h-13-
include/llvm-libc-types/__mutex_type.h-14-typedef struct {
include/llvm-libc-types/__mutex_type.h-15- unsigned char __timed;
include/llvm-libc-types/__mutex_type.h-16- unsigned char __recursive;
include/llvm-libc-types/__mutex_type.h-17- unsigned char __robust;
include/llvm-libc-types/__mutex_type.h-18-
include/llvm-libc-types/__mutex_type.h-19- void *__owner;
include/llvm-libc-types/__mutex_type.h-20- unsigned long long __lock_count;
include/llvm-libc-types/__mutex_type.h-21-
include/llvm-libc-types/__mutex_type.h:22:#ifdef __unix__
include/llvm-libc-types/__mutex_type.h-23- __futex_word __ftxw;
include/llvm-libc-types/__mutex_type.h-24-#else
include/llvm-libc-types/__mutex_type.h-25-#error "Mutex type not defined for the target platform."
include/llvm-libc-types/__mutex_type.h-26-#endif
include/llvm-libc-types/__mutex_type.h-27-} __mutex_type;
include/llvm-libc-types/__mutex_type.h-28-
include/llvm-libc-types/__mutex_type.h-29-#endif // __LLVM_LIBC_TYPES___MUTEX_T_HLGTM, but...
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.
| libc/include/llvm-libc-types/struct_dirent.h | ||
|---|---|---|
| 21 | only d_ino (XSI) and d_name are specified by POSIX. | |
| libc/include/llvm-libc-types/struct_utsname.h | ||
| 15 | Apple (__APPLE__) uses 256: https://opensource.apple.com/source/xnu/xnu-201/bsd/sys/utsname.h.auto.html | |
| 26 | GNU extension | |
| libc/src/__support/File/dir.cpp | ||
| 43 | checked using _DIRENT_HAVE_D_RECLEN, respected by both musl and glibc ditto _OFF, _TYPE | |
done! I think there should be something addressing pthread_once_t and once_flag for other Unix platforms though. Both of these would've previously, before this commit, been valid on macOS, as __unix__ is defined and __futex_word is just an aligned 32 bit int. No internal Linux headers were used here before that would've caused an error.
typedef struct {
_Alignas(sizeof(__UINT32_TYPE__) > _Alignof(__UINT32_TYPE__)
? sizeof(__UINT32_TYPE__)
: _Alignof(__UINT32_TYPE__)) __UINT32_TYPE__ __word;
} __futex_word;from __futex_word.h
LGTM, and if there are spots where both linux and macos should be accepted then we should probably make those #if defined(__linux__) || defined(__APPLE__)
only d_ino (XSI) and d_name are specified by POSIX.