Skip to content

Commit 7df0e3b

Browse files
committed
[libc] use time_units
1 parent 345e298 commit 7df0e3b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "src/__support/CPP/optional.h"
1414
#include "src/__support/time/abs_timeout.h"
1515
#include "src/__support/time/clock_conversion.h"
16+
#include "src/__support/time/units.h"
1617

1718
#include <os/os_sync_wait_on_address.h>
1819

@@ -36,7 +37,8 @@ struct Futex : public cpp::Atomic<FutexWordType> {
3637
long ret = 0;
3738
if (timeout) {
3839
// Assuming, OS_CLOCK_MACH_ABSOLUTE_TIME is equivalent to CLOCK_REALTIME
39-
uint64_t tnsec = timeout->get_timespec().tv_sec * 1000000000 +
40+
using namespace time_units;
41+
uint64_t tnsec = timeout->get_timespec().tv_sec * 1_s_ns +
4042
timeout->get_timespec().tv_nsec;
4143
ret = os_sync_wait_on_address_with_timeout(
4244
reinterpret_cast<void *>(this), static_cast<uint64_t>(val),

libc/test/src/__support/threads/darwin/mutex_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ TEST(LlvmLibcSupportThreadsRawMutexTest, Timeout) {
4242
ASSERT_TRUE(mutex.unlock());
4343
}
4444

45-
// TODO(bojle): add other tests a la linux
45+
// TODO(bojle): merge threads test for darwin and linux into one after
46+
// adding support for shared locks in darwin

0 commit comments

Comments
 (0)