Skip to content

Commit 4d5422e

Browse files
Okaaay, fix another function broken on Mac
1 parent 88bdc01 commit 4d5422e

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

RTXOff/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ else()
9595
if(PTHREAD_SETNAME_NP_WORKS)
9696
target_compile_definitions(rtxoff PRIVATE HAVE_PTHREAD_SETNAME_NP)
9797
endif()
98+
99+
# tell code to use more limited timing functions available on OS X
100+
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
101+
target_compile_definitions(rtxoff PRIVATE USE_MAC_TIME)
102+
endif()
103+
98104
endif()
99105

100106
# manually apply mbed configs

RTXOff/ThreadDispatcher.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@ ThreadDispatcher::ThreadDispatcher()
5454

5555
pthread_mutexattr_destroy(&recursiveAttr);
5656

57+
#ifdef USE_MAC_TIME
58+
pthread_cond_init(&kernelModeCondVar, nullptr);
59+
#else
5760
// initialize kernel mode cond var
5861
// make sure that the condition variable is using the monotonic clock
5962
pthread_condattr_t monotonicClockAttr;
6063
pthread_condattr_init(&monotonicClockAttr);
6164
pthread_condattr_setclock(&monotonicClockAttr, CLOCK_MONOTONIC); // sadly CLOCK_PROCESS_CPUTIME_ID is not supported here
6265

6366
pthread_cond_init(&kernelModeCondVar, &monotonicClockAttr);
67+
#endif
6468

6569
pthread_condattr_destroy(&monotonicClockAttr);
6670
}

tests/events/queue/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,16 @@ void time_left_test()
302302
EventQueue queue(TEST_EQUEUE_SIZE);
303303

304304
// Enque check events
305-
TEST_ASSERT(queue.call_in(500ms, check_time_left, &queue, 0, 100 - 500));
306-
TEST_ASSERT(queue.call_in(2000ms, check_time_left, &queue, 1, 200 - 2000));
305+
TEST_ASSERT(queue.call_in(500ms, check_time_left, &queue, 0, 1000 - 500));
306+
TEST_ASSERT(queue.call_in(2000ms, check_time_left, &queue, 1, 2000 - 2000));
307307

308308
// Enque events to be checked
309309
timeleft_events[0] = queue.call_in(1000ms, time_left, &queue, 0);
310310
timeleft_events[1] = queue.call_in(2000ms, time_left, &queue, 1);
311311
TEST_ASSERT(timeleft_events[0]);
312312
TEST_ASSERT(timeleft_events[1]);
313313

314-
queue.dispatch(300);
314+
queue.dispatch(3000);
315315

316316
// Ensure check was called
317317
TEST_ASSERT(touched);

0 commit comments

Comments
 (0)