perf(os): optimize OS API calls without OS mode (#7420)

Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com>
Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
VIFEX
2024-12-09 06:12:23 +08:00
committed by GitHub
parent 4f2fd4b549
commit 39c3e23e06
3 changed files with 109 additions and 135 deletions
+4 -8
View File
@@ -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*/
+105
View File
@@ -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
**********************/
-127
View File
@@ -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*/