libc: Refine the inline handling

1.Remove CONFIG_HAVE_INLINE macro
2.Change the ANSI C function to normal function
3.Other simple non ANSI function to macro

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2020-06-26 14:40:13 +08:00
committed by YAMAMOTO Takashi
parent 993591dca1
commit 60fe0a0f96
24 changed files with 476 additions and 231 deletions
-21
View File
@@ -47,13 +47,6 @@
* Public Functions
****************************************************************************/
#ifndef CONFIG_HAVE_INLINE
void bt_atomic_set(FAR bt_atomic_t *ptr, bt_atomic_t value)
{
*ptr = value;
}
#endif
bt_atomic_t bt_atomic_incr(FAR bt_atomic_t *ptr)
{
irqstate_t flags;
@@ -106,20 +99,6 @@ bt_atomic_t bt_atomic_clrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno)
return value;
}
#ifndef CONFIG_HAVE_INLINE
bt_atomic_t bt_atomic_get(FAR bt_atomic_t *ptr)
{
return *ptr;
}
#endif
#ifndef CONFIG_HAVE_INLINE
bool bt_atomic_testbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno)
{
return (*ptr & (1 << bitno)) != 0;
}
#endif
bool bt_atomic_testsetbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno)
{
irqstate_t flags;
+8 -33
View File
@@ -47,54 +47,29 @@
#include <stdint.h>
#include <stdbool.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define bt_atomic_set(ptr, value) (*(ptr) = (value))
#define bt_atomic_get(ptr) (*(ptr))
#define bt_atomic_testbit(ptr, bitno) ((*(ptr) & (1 << (bitno))) != 0)
/****************************************************************************
* Public Types
****************************************************************************/
typedef uint8_t bt_atomic_t;
/****************************************************************************
* Inline Functions
****************************************************************************/
#ifdef CONFIG_HAVE_INLINE
/* These operations are inherently atomic */
static inline void bt_atomic_set(FAR bt_atomic_t *ptr, bt_atomic_t value)
{
*ptr = value;
}
static inline bt_atomic_t bt_atomic_get(FAR bt_atomic_t *ptr)
{
return *ptr;
}
static inline bool bt_atomic_testbit(FAR bt_atomic_t *ptr,
bt_atomic_t bitno)
{
return (*ptr & (1 << bitno)) != 0;
}
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifndef CONFIG_HAVE_INLINE
void bt_atomic_set(FAR bt_atomic_t *ptr, bt_atomic_t value);
bt_atomic_t bt_atomic_get(FAR bt_atomic_t *ptr);
#endif
bt_atomic_t bt_atomic_incr(FAR bt_atomic_t *ptr);
bt_atomic_t bt_atomic_decr(FAR bt_atomic_t *ptr);
bt_atomic_t bt_atomic_setbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);
bt_atomic_t bt_atomic_clrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);
#ifndef CONFIG_HAVE_INLINE
bool bt_atomic_testbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);
#endif
bool bt_atomic_testsetbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);
bool bt_atomic_testclrbit(FAR bt_atomic_t *ptr, bt_atomic_t bitno);