[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
Sun Jun 25 16:03:09 PDT 2023


alfredfo added a comment.

Here are things still using __unix__, and I'm pretty sure those are correct.

`grep -rsin '__unix__' -C10`

  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_H
  --
  src/__support/threads/mutex.h-30-// static MutexError destroy(mtx_t *);
  src/__support/threads/mutex.h-31-//
  src/__support/threads/mutex.h-32-// All of the static and non-static methods should ideally be implemented
  src/__support/threads/mutex.h-33-// as inline functions so that implementations of public functions can
  src/__support/threads/mutex.h-34-// call them without a function call overhead.
  src/__support/threads/mutex.h-35-//
  src/__support/threads/mutex.h-36-// Another point to keep in mind that is that the libc internally needs a
  src/__support/threads/mutex.h-37-// few global locks. So, to avoid static initialization order fiasco, we
  src/__support/threads/mutex.h-38-// want the constructors of the Mutex classes to be constexprs.
  src/__support/threads/mutex.h-39-
  src/__support/threads/mutex.h:40:#if defined(__unix__)
  src/__support/threads/mutex.h-41-#include "linux/mutex.h"
  src/__support/threads/mutex.h-42-#elif defined(LIBC_TARGET_ARCH_IS_GPU)
  src/__support/threads/mutex.h-43-#include "gpu/mutex.h"
  src/__support/threads/mutex.h:44:#endif // __unix__
  src/__support/threads/mutex.h-45-
  src/__support/threads/mutex.h-46-namespace __llvm_libc {
  src/__support/threads/mutex.h-47-
  src/__support/threads/mutex.h-48-// An RAII class for easy locking and unlocking of mutexes.
  src/__support/threads/mutex.h-49-class MutexLock {
  src/__support/threads/mutex.h-50-  Mutex *mutex;
  src/__support/threads/mutex.h-51-
  src/__support/threads/mutex.h-52-public:
  src/__support/threads/mutex.h-53-  explicit MutexLock(Mutex *m) : mutex(m) { mutex->lock(); }
  src/__support/threads/mutex.h-54-


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