diff --git a/src/osal/lv_os.c b/src/osal/lv_os.c index 7b775f034c..64ef4b5d10 100644 --- a/src/osal/lv_os.c +++ b/src/osal/lv_os.c @@ -42,30 +42,26 @@ void lv_os_init(void) #endif /*LV_USE_OS != LV_OS_NONE*/ } +#if LV_USE_OS != LV_OS_NONE + void lv_lock(void) { -#if LV_USE_OS != LV_OS_NONE lv_mutex_lock(&lv_general_mutex); -#endif /*LV_USE_OS != LV_OS_NONE*/ } lv_result_t lv_lock_isr(void) { -#if LV_USE_OS != LV_OS_NONE return lv_mutex_lock_isr(&lv_general_mutex); -#else /*LV_USE_OS != LV_OS_NONE*/ - return LV_RESULT_OK; -#endif /*LV_USE_OS != LV_OS_NONE*/ } void lv_unlock(void) { -#if LV_USE_OS != LV_OS_NONE lv_mutex_unlock(&lv_general_mutex); -#endif /*LV_USE_OS != LV_OS_NONE*/ } /********************** * STATIC FUNCTIONS **********************/ + +#endif /*LV_USE_OS != LV_OS_NONE*/ diff --git a/src/osal/lv_os.h b/src/osal/lv_os.h index d0a4e02f5c..3de023e462 100644 --- a/src/osal/lv_os.h +++ b/src/osal/lv_os.h @@ -58,6 +58,8 @@ typedef enum { * GLOBAL PROTOTYPES **********************/ +#if LV_USE_OS != LV_OS_NONE + /*---------------------------------------- * These functions needs to be implemented * for specific operating systems @@ -175,6 +177,109 @@ lv_result_t lv_lock_isr(void); */ void lv_unlock(void); +#else + +/* Since compilation does not necessarily optimize cross-file empty functions well + * (-O3 optimization alone is not enough unless LTO optimization is enabled), + * In the absence of an operating system, use inline functions to help compile + * optimizations and avoid the call overhead of the OS API to ensure no performance penalty. + */ + +static inline lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), + size_t stack_size, + void * user_data) +{ + LV_UNUSED(thread); + LV_UNUSED(callback); + LV_UNUSED(prio); + LV_UNUSED(stack_size); + LV_UNUSED(user_data); + return LV_RESULT_INVALID; +} + +static inline lv_result_t lv_thread_delete(lv_thread_t * thread) +{ + LV_UNUSED(thread); + return LV_RESULT_INVALID; +} + +static inline lv_result_t lv_mutex_init(lv_mutex_t * mutex) +{ + LV_UNUSED(mutex); + return LV_RESULT_OK; +} + +static inline lv_result_t lv_mutex_lock(lv_mutex_t * mutex) +{ + LV_UNUSED(mutex); + return LV_RESULT_OK; +} + +static inline lv_result_t lv_mutex_lock_isr(lv_mutex_t * mutex) +{ + LV_UNUSED(mutex); + return LV_RESULT_OK; +} + +static inline lv_result_t lv_mutex_unlock(lv_mutex_t * mutex) +{ + LV_UNUSED(mutex); + return LV_RESULT_OK; +} + +static inline lv_result_t lv_mutex_delete(lv_mutex_t * mutex) +{ + LV_UNUSED(mutex); + return LV_RESULT_OK; +} + +static inline lv_result_t lv_thread_sync_init(lv_thread_sync_t * sync) +{ + LV_UNUSED(sync); + return LV_RESULT_INVALID; +} + +static inline lv_result_t lv_thread_sync_wait(lv_thread_sync_t * sync) +{ + LV_UNUSED(sync); + return LV_RESULT_INVALID; +} + +static inline lv_result_t lv_thread_sync_signal(lv_thread_sync_t * sync) +{ + LV_UNUSED(sync); + return LV_RESULT_INVALID; +} + +static inline lv_result_t lv_thread_sync_signal_isr(lv_thread_sync_t * sync) +{ + LV_UNUSED(sync); + return LV_RESULT_INVALID; +} + +static inline lv_result_t lv_thread_sync_delete(lv_thread_sync_t * sync) +{ + LV_UNUSED(sync); + return LV_RESULT_INVALID; +} + +static inline void lv_lock(void) +{ + /*Do nothing*/ +} + +static inline lv_result_t lv_lock_isr(void) +{ + return LV_RESULT_OK; +} + +static inline void lv_unlock(void) +{ + /*Do nothing*/ +} + +#endif /*LV_USE_OS != LV_OS_NONE*/ + /********************** * MACROS **********************/ diff --git a/src/osal/lv_os_none.c b/src/osal/lv_os_none.c deleted file mode 100644 index 547810db73..0000000000 --- a/src/osal/lv_os_none.c +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file lv_os_none.c - * - */ - -/********************* - * INCLUDES - *********************/ -#include "lv_os.h" - -#if LV_USE_OS == LV_OS_NONE -#include "../misc/lv_types.h" -#include "../misc/lv_assert.h" - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - -lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size, - void * user_data) -{ - LV_UNUSED(thread); - LV_UNUSED(callback); - LV_UNUSED(prio); - LV_UNUSED(stack_size); - LV_UNUSED(user_data); - LV_ASSERT(0); - return LV_RESULT_INVALID; -} - -lv_result_t lv_thread_delete(lv_thread_t * thread) -{ - LV_UNUSED(thread); - LV_ASSERT(0); - return LV_RESULT_INVALID; -} - -lv_result_t lv_mutex_init(lv_mutex_t * mutex) -{ - LV_UNUSED(mutex); - return LV_RESULT_OK; -} - -lv_result_t lv_mutex_lock(lv_mutex_t * mutex) -{ - LV_UNUSED(mutex); - return LV_RESULT_OK; -} - -lv_result_t lv_mutex_lock_isr(lv_mutex_t * mutex) -{ - LV_UNUSED(mutex); - return LV_RESULT_OK; -} - -lv_result_t lv_mutex_unlock(lv_mutex_t * mutex) -{ - LV_UNUSED(mutex); - return LV_RESULT_OK; -} - -lv_result_t lv_mutex_delete(lv_mutex_t * mutex) -{ - LV_UNUSED(mutex); - return LV_RESULT_OK; -} - -lv_result_t lv_thread_sync_init(lv_thread_sync_t * sync) -{ - LV_UNUSED(sync); - LV_ASSERT(0); - return LV_RESULT_INVALID; -} - -lv_result_t lv_thread_sync_wait(lv_thread_sync_t * sync) -{ - LV_UNUSED(sync); - LV_ASSERT(0); - return LV_RESULT_INVALID; -} - -lv_result_t lv_thread_sync_signal(lv_thread_sync_t * sync) -{ - LV_UNUSED(sync); - LV_ASSERT(0); - return LV_RESULT_INVALID; -} - -lv_result_t lv_thread_sync_signal_isr(lv_thread_sync_t * sync) -{ - LV_UNUSED(sync); - LV_ASSERT(0); - return LV_RESULT_INVALID; -} - -lv_result_t lv_thread_sync_delete(lv_thread_sync_t * sync) -{ - LV_UNUSED(sync); - LV_ASSERT(0); - return LV_RESULT_INVALID; -} - -/********************** - * STATIC FUNCTIONS - **********************/ - -#endif /*LV_USE_OS == LV_OS_NONE*/