From 64eab1f7b3d1e57761af6abfb790c5acd6c1fac5 Mon Sep 17 00:00:00 2001 From: Thad House Date: Mon, 2 Jan 2017 00:43:12 -0800 Subject: [PATCH] Fixes missing Extern "C" from HAL Threads (#437) Also fixes incorrect return value during set --- hal/include/HAL/Threads.h | 2 ++ hal/lib/athena/Threads.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hal/include/HAL/Threads.h b/hal/include/HAL/Threads.h index 4036d41fb5..8fe5578d4b 100644 --- a/hal/include/HAL/Threads.h +++ b/hal/include/HAL/Threads.h @@ -17,6 +17,7 @@ #define NativeThreadHandle const pthread_t* #endif +extern "C" { int32_t HAL_GetThreadPriority(NativeThreadHandle handle, HAL_Bool* isRealTime, int32_t* status); int32_t HAL_GetCurrentThreadPriority(HAL_Bool* isRealTime, int32_t* status); @@ -24,3 +25,4 @@ HAL_Bool HAL_SetThreadPriority(NativeThreadHandle handle, HAL_Bool realTime, int32_t priority, int32_t* status); HAL_Bool HAL_SetCurrentThreadPriority(HAL_Bool realTime, int32_t priority, int32_t* status); +} diff --git a/hal/lib/athena/Threads.cpp b/hal/lib/athena/Threads.cpp index f341b521af..8e8bc896ca 100644 --- a/hal/lib/athena/Threads.cpp +++ b/hal/lib/athena/Threads.cpp @@ -12,6 +12,7 @@ #include "HAL/Errors.h" +extern "C" { /** * Get the thread priority for the specified thread. * @@ -94,10 +95,10 @@ HAL_Bool HAL_SetThreadPriority(NativeThreadHandle handle, HAL_Bool realTime, sch.sched_priority = 0; if (pthread_setschedparam(*handle, scheduler, &sch)) { *status = HAL_THREAD_PRIORITY_ERROR; - return true; + return false; } else { *status = 0; - return false; + return true; } } @@ -118,3 +119,4 @@ HAL_Bool HAL_SetCurrentThreadPriority(HAL_Bool realTime, int32_t priority, auto thread = pthread_self(); return HAL_SetThreadPriority(&thread, realTime, priority, status); } +}