Skip to content

Commit c80ecad

Browse files
committed
[libc][darwin] cmake options, minor nits
1 parent 5047182 commit c80ecad

File tree

4 files changed

+29
-157
lines changed

4 files changed

+29
-157
lines changed

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ function(_get_compile_options_from_config output_var)
119119
list(APPEND config_options "-DLIBC_TRAP_ON_RAISE_FP_EXCEPT")
120120
endif()
121121

122+
if(LIBC_CONF_RAW_MUTEX_DEFAULT_SPIN_COUNT)
123+
list(APPEND config_options "-DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=${LIBC_CONF_RAW_MUTEX_DEFAULT_SPIN_COUNT}")
124+
endif()
125+
122126
set(${output_var} ${config_options} PARENT_SCOPE)
123127
endfunction(_get_compile_options_from_config)
124128

libc/src/__support/threads/CMakeLists.txt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,52 +25,52 @@ endif()
2525

2626
if(TARGET libc.src.__support.threads.${LIBC_TARGET_OS}.futex_utils)
2727
add_header_library(
28-
mutex
28+
raw_mutex
2929
HDRS
30-
mutex.h
30+
raw_mutex.h
31+
COMPILE_OPTIONS
32+
${monotonicity_flags}
3133
DEPENDS
32-
.unix_mutex
34+
.${LIBC_TARGET_OS}.futex_utils
35+
libc.src.__support.threads.sleep
36+
libc.src.__support.time.abs_timeout
37+
libc.src.__support.time.monotonicity
38+
libc.src.__support.CPP.optional
39+
libc.hdr.types.pid_t
3340
)
41+
3442
add_header_library(
3543
unix_mutex
3644
HDRS
37-
unix_mutex.h
45+
unix_mutex.h
3846
DEPENDS
39-
.raw_mutex
47+
.raw_mutex
4048
)
4149

4250
add_header_library(
43-
raw_mutex
51+
mutex
4452
HDRS
45-
raw_mutex.h
53+
mutex.h
4654
DEPENDS
47-
.${LIBC_TARGET_OS}.futex_utils
48-
libc.src.__support.threads.sleep
49-
libc.src.__support.time.abs_timeout
50-
libc.src.__support.time.monotonicity
51-
libc.src.__support.CPP.optional
52-
libc.hdr.types.pid_t
53-
COMPILE_OPTIONS
54-
-DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=${LIBC_CONF_RAW_MUTEX_DEFAULT_SPIN_COUNT}
55-
${monotonicity_flags}
55+
.unix_mutex
5656
)
5757

5858
add_object_library(
5959
fork_callbacks
6060
SRCS
61-
fork_callbacks.cpp
61+
fork_callbacks.cpp
6262
HDRS
63-
fork_callbacks.h
63+
fork_callbacks.h
6464
DEPENDS
65-
.mutex
66-
libc.src.__support.CPP.mutex
65+
.mutex
66+
libc.src.__support.CPP.mutex
6767
)
6868
elseif(NOT (LIBC_CONF_THREAD_MODE STREQUAL LIBC_THREAD_MODE_PLATFORM))
6969
add_header_library(
7070
mutex
71-
HDRS
71+
HDRS
7272
mutex.h
73-
DEPENDS
73+
DEPENDS
7474
.mutex_common
7575
)
7676
endif()

libc/src/__support/threads/darwin/futex_utils.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//===--- Futex utils for Darwin ------------------------*- C++-*-===//
1+
//===--- Futex utils for Darwin ----------------------------------*- C++-*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
7-
//===------------------------------------------------------------===//
7+
//===----------------------------------------------------------------------===//
88

99
#ifndef LLVM_LIBC_SRC___SUPPORT_THREADS_DARWIN_FUTEX_UTILS_H
1010
#define LLVM_LIBC_SRC___SUPPORT_THREADS_DARWIN_FUTEX_UTILS_H
@@ -47,9 +47,8 @@ struct Futex : public cpp::Atomic<FutexWordType> {
4747
reinterpret_cast<void *>(this), static_cast<uint64_t>(val),
4848
sizeof(FutexWordType), OS_SYNC_WAIT_ON_ADDRESS_NONE);
4949
}
50-
if ((ret < 0) && (errno == ETIMEDOUT)) {
50+
if ((ret < 0) && (errno == ETIMEDOUT))
5151
return -ETIMEDOUT;
52-
}
5352
// case when os_sync returns early with an error. retry.
5453
if ((ret < 0) && ((errno == EINTR) || (errno == EFAULT))) {
5554
continue;

libc/src/__support/threads/darwin/mutex.h

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)