Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 562f044b authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

A workaround for kernels missing CLOCK_BOOTTIME_ALARM

If the kernel doesn't have support for CLOCK_BOOTTIME_ALARM,
then timer_create(CLOCK_BOOTTIME_ALARM) will fail.

Added #ifdef KERNEL_MISSING_CLOCK_BOOTTIME_ALARM guard to get around
the issue. Platforms that don't have CLOCK_BOOTTIME_ALARM should have
the following lines in the device's "bdroid_buildcfg.h" file:

 /* Defined if the kernel does not have support for CLOCK_BOOTTIME_ALARM */
 #define KERNEL_MISSING_CLOCK_BOOTTIME_ALARM TRUE

Bug: 26611369
Change-Id: I455dbbc20f43b21a83998cd60cac8dea0a73080d
parent e3449e7a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -73,9 +73,11 @@ btosiCommonTestSrc := \

btosiCommonIncludes := \
    $(LOCAL_PATH)/.. \
    $(LOCAL_PATH)/../utils/include
    $(LOCAL_PATH)/../utils/include \
    $(LOCAL_PATH)/../stack/include $(bdroid_C_INCLUDES)

btosiCommonCFlags := -std=c99 -Wall -Werror -UNDEBUG -fvisibility=hidden
btosiCommonCFlags := -std=c99 -Wall -Werror -UNDEBUG -fvisibility=hidden \
    $(bdroid_CFLAGS)

# libosi static library for target
# ========================================================
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
 *
 ******************************************************************************/

#include "include/bt_target.h"

#define LOG_TAG "bt_osi_alarm"

#include "osi/include/alarm.h"
@@ -93,7 +95,12 @@ struct alarm_t {
// unit tests to run faster. It should not be modified by production code.
int64_t TIMER_INTERVAL_FOR_WAKELOCK_IN_MS = 3000;
static const clockid_t CLOCK_ID = CLOCK_BOOTTIME;

#if defined(KERNEL_MISSING_CLOCK_BOOTTIME_ALARM) && (KERNEL_MISSING_CLOCK_BOOTTIME_ALARM == TRUE)
static const clockid_t CLOCK_ID_ALARM = CLOCK_BOOTTIME;
#else
static const clockid_t CLOCK_ID_ALARM = CLOCK_BOOTTIME_ALARM;
#endif

// This mutex ensures that the |alarm_set|, |alarm_cancel|, and alarm callback
// functions execute serially and not concurrently. As a result, this mutex