File tree 10 files changed +60
-30
lines changed 10 files changed +60
-30
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,10 @@ add_header_library(
54
54
integer_operations.h
55
55
)
56
56
57
+ # Thread support is used by other support libraries. So, we add the "threads"
58
+ # before other directories.
59
+ add_subdirectory (threads)
60
+
57
61
add_subdirectory (File)
58
62
add_subdirectory (FPUtil)
59
63
add_subdirectory (OSUtil)
60
- add_subdirectory (threads)
Original file line number Diff line number Diff line change
1
+ if (NOT (TARGET libc.src.__support.threads.mutex))
2
+ # Not all platforms have a mutex implementation. If mutex is unvailable,
3
+ # we just skip everything about files.
4
+ return ()
5
+ endif ()
6
+
1
7
add_object_library(
2
8
file
3
9
SRCS
4
10
file .cpp
5
11
HDRS
6
12
file .h
7
13
DEPENDS
8
- libc.src.__support.threads.thread
14
+ libc.src.__support.threads.mutex
9
15
libc.include .errno
10
16
libc.src.errno.errno
11
17
)
Original file line number Diff line number Diff line change
1
+ add_header_library(
2
+ mutex_common
3
+ HDRS
4
+ mutex_common.h
5
+ )
6
+
1
7
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /${LIBC_TARGET_OS} )
2
8
add_subdirectory (${LIBC_TARGET_OS} )
3
9
endif ()
4
10
5
- add_header_library(
6
- thread
7
- HDRS
8
- mutex.h
9
- DEPENDS
10
- .${LIBC_TARGET_OS} .thread
11
- )
11
+ if (TARGET libc.src.__support.threads.${LIBC_TARGET_OS} .mutex)
12
+ add_header_library(
13
+ mutex
14
+ HDRS
15
+ mutex.h
16
+ DEPENDS
17
+ .${LIBC_TARGET_OS} .mutex
18
+ )
19
+ endif ()
Original file line number Diff line number Diff line change 1
1
add_header_library(
2
- thread
2
+ mutex
3
3
HDRS
4
4
mutex.h
5
5
DEPENDS
6
6
libc.include .sys_syscall
7
7
libc.src.__support.CPP.atomic
8
8
libc.src.__support.OSUtil.osutil
9
+ libc.src.__support.threads.mutex_common
9
10
)
Original file line number Diff line number Diff line change 11
11
12
12
#include " src/__support/CPP/atomic.h"
13
13
#include " src/__support/OSUtil/syscall.h" // For syscall functions.
14
- #include " src/__support/threads/mutex .h"
14
+ #include " src/__support/threads/mutex_common .h"
15
15
16
16
#include < linux/futex.h>
17
17
#include < stdint.h>
Original file line number Diff line number Diff line change 9
9
#ifndef LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_H
10
10
#define LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_H
11
11
12
- namespace __llvm_libc {
13
-
14
- enum class MutexError : int {
15
- NONE,
16
- BUSY,
17
- TIMEOUT,
18
- UNLOCK_WITHOUT_LOCK,
19
- BAD_LOCK_STATE,
20
- };
21
-
22
- } // namespace __llvm_libc
23
-
24
12
// Platform independent code will include this header file which pulls
25
13
// the platfrom specific specializations using platform macros.
26
14
//
Original file line number Diff line number Diff line change
1
+ // ===--- Common definitions useful for mutex implementations ----*- C++ -*-===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_COMMON_H
10
+ #define LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_COMMON_H
11
+
12
+ namespace __llvm_libc {
13
+
14
+ enum class MutexError : int {
15
+ NONE,
16
+ BUSY,
17
+ TIMEOUT,
18
+ UNLOCK_WITHOUT_LOCK,
19
+ BAD_LOCK_STATE,
20
+ };
21
+
22
+ } // namespace __llvm_libc
23
+
24
+ #endif // LLVM_LIBC_SRC_SUPPORT_THREAD_MUTEX_COMMON_H
Original file line number Diff line number Diff line change @@ -280,7 +280,7 @@ add_entrypoint_object(
280
280
20 # For constinit of the atexit callback list.
281
281
DEPENDS
282
282
libc.src.__support.CPP.blockstore
283
- libc.src.__support.threads.thread
283
+ libc.src.__support.threads.mutex
284
284
)
285
285
286
286
add_entrypoint_object(
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ add_entrypoint_object(
31
31
mtx_init.h
32
32
DEPENDS
33
33
libc.include .threads
34
- libc.src.__support.threads.thread
34
+ libc.src.__support.threads.mutex
35
35
)
36
36
37
37
add_entrypoint_object(
@@ -42,7 +42,7 @@ add_entrypoint_object(
42
42
mtx_destroy.h
43
43
DEPENDS
44
44
libc.include .threads
45
- libc.src.__support.threads.thread
45
+ libc.src.__support.threads.mutex
46
46
)
47
47
48
48
add_entrypoint_object(
@@ -53,7 +53,7 @@ add_entrypoint_object(
53
53
mtx_lock.h
54
54
DEPENDS
55
55
libc.include .threads
56
- libc.src.__support.threads.thread
56
+ libc.src.__support.threads.mutex
57
57
)
58
58
59
59
add_entrypoint_object(
@@ -64,7 +64,7 @@ add_entrypoint_object(
64
64
mtx_unlock.h
65
65
DEPENDS
66
66
libc.include .threads
67
- libc.src.__support.threads.thread
67
+ libc.src.__support.threads.mutex
68
68
)
69
69
70
70
add_entrypoint_object(
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ add_header_library(
34
34
libc.include .threads
35
35
libc.src.__support.CPP.atomic
36
36
libc.src.__support.OSUtil.osutil
37
- libc.src.__support.threads.thread
37
+ libc.src.__support.threads.mutex
38
38
)
39
39
40
40
add_entrypoint_object(
@@ -105,7 +105,7 @@ add_entrypoint_object(
105
105
DEPENDS
106
106
.threads_utils
107
107
libc.include .threads
108
- libc.src.__support.threads.thread
108
+ libc.src.__support.threads.mutex
109
109
)
110
110
111
111
add_entrypoint_object(
You can’t perform that action at this time.
0 commit comments