integer_operations.h
)
+# Thread support is used by other support libraries. So, we add the "threads"
+# before other directories.
+add_subdirectory(threads)
+
add_subdirectory(File)
add_subdirectory(FPUtil)
add_subdirectory(OSUtil)
-add_subdirectory(threads)
+if(NOT (TARGET libc.src.__support.threads.mutex))
+ # Not all platforms have a mutex implementation. If mutex is unvailable,
+ # we just skip everything about files.
+ return()
+endif()
+
add_object_library(
file
SRCS
HDRS
file.h
DEPENDS
- libc.src.__support.threads.thread
+ libc.src.__support.threads.mutex
libc.include.errno
libc.src.errno.errno
)
+add_header_library(
+ mutex_common
+ HDRS
+ mutex_common.h
+)
+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${LIBC_TARGET_OS})
endif()
-add_header_library(
- thread
- HDRS
- mutex.h
- DEPENDS
- .${LIBC_TARGET_OS}.thread
-)
+if(TARGET libc.src.__support.threads.${LIBC_TARGET_OS}.mutex)
+ add_header_library(
+ mutex
+ HDRS
+ mutex.h
+ DEPENDS
+ .${LIBC_TARGET_OS}.mutex
+ )
+endif()
add_header_library(
- thread
+ mutex
HDRS
mutex.h
DEPENDS
libc.include.sys_syscall
libc.src.__support.CPP.atomic
libc.src.__support.OSUtil.osutil
+ libc.src.__support.threads.mutex_common
)
#include "src/__support/CPP/atomic.h"
#include "src/__support/OSUtil/syscall.h" // For syscall functions.
-#include "src/__support/threads/mutex.h"
+#include "src/__support/threads/mutex_common.h"
#include <linux/futex.h>
#include <stdint.h>
#ifndef LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_H
#define LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_H
-namespace __llvm_libc {
-
-enum class MutexError : int {
- NONE,
- BUSY,
- TIMEOUT,
- UNLOCK_WITHOUT_LOCK,
- BAD_LOCK_STATE,
-};
-
-} // namespace __llvm_libc
-
// Platform independent code will include this header file which pulls
// the platfrom specific specializations using platform macros.
//
--- /dev/null
+//===--- Common definitions useful for mutex implementations ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_COMMON_H
+#define LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_COMMON_H
+
+namespace __llvm_libc {
+
+enum class MutexError : int {
+ NONE,
+ BUSY,
+ TIMEOUT,
+ UNLOCK_WITHOUT_LOCK,
+ BAD_LOCK_STATE,
+};
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_COMMON_H
20 # For constinit of the atexit callback list.
DEPENDS
libc.src.__support.CPP.blockstore
- libc.src.__support.threads.thread
+ libc.src.__support.threads.mutex
)
add_entrypoint_object(
mtx_init.h
DEPENDS
libc.include.threads
- libc.src.__support.threads.thread
+ libc.src.__support.threads.mutex
)
add_entrypoint_object(
mtx_destroy.h
DEPENDS
libc.include.threads
- libc.src.__support.threads.thread
+ libc.src.__support.threads.mutex
)
add_entrypoint_object(
mtx_lock.h
DEPENDS
libc.include.threads
- libc.src.__support.threads.thread
+ libc.src.__support.threads.mutex
)
add_entrypoint_object(
mtx_unlock.h
DEPENDS
libc.include.threads
- libc.src.__support.threads.thread
+ libc.src.__support.threads.mutex
)
add_entrypoint_object(
libc.include.threads
libc.src.__support.CPP.atomic
libc.src.__support.OSUtil.osutil
- libc.src.__support.threads.thread
+ libc.src.__support.threads.mutex
)
add_entrypoint_object(
DEPENDS
.threads_utils
libc.include.threads
- libc.src.__support.threads.thread
+ libc.src.__support.threads.mutex
)
add_entrypoint_object(