From 9928023421ddad36d320331725f95694b9d6fc9e Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Fri, 29 Sep 2017 14:17:47 -0700 Subject: [PATCH] kernel: make 'static inline' implicit to __syscall The fact that these are all static inline functions internally is an implementation detail. Signed-off-by: Andrew Boie --- include/kernel.h | 13 ++++++------- include/toolchain/common.h | 6 ++++++ include/toolchain/gcc.h | 4 ---- scripts/gen_syscalls.py | 15 +++++++++++---- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/kernel.h b/include/kernel.h index 563fd01e323..c400ab1bc0d 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -2505,9 +2505,8 @@ struct k_sem { * * @return N/A */ -__syscall static inline void k_sem_init(struct k_sem *sem, - unsigned int initial_count, - unsigned int limit); +__syscall void k_sem_init(struct k_sem *sem, unsigned int initial_count, + unsigned int limit); /** * @brief Take a semaphore. @@ -2530,7 +2529,7 @@ __syscall static inline void k_sem_init(struct k_sem *sem, * @retval -EBUSY Returned without waiting. * @retval -EAGAIN Waiting period timed out. */ -__syscall static inline int k_sem_take(struct k_sem *sem, s32_t timeout); +__syscall int k_sem_take(struct k_sem *sem, s32_t timeout); /** * @brief Give a semaphore. @@ -2544,7 +2543,7 @@ __syscall static inline int k_sem_take(struct k_sem *sem, s32_t timeout); * * @return N/A */ -__syscall static inline void k_sem_give(struct k_sem *sem); +__syscall void k_sem_give(struct k_sem *sem); /** * @brief Reset a semaphore's count to zero. @@ -2555,7 +2554,7 @@ __syscall static inline void k_sem_give(struct k_sem *sem); * * @return N/A */ -__syscall_inline static inline void k_sem_reset(struct k_sem *sem); +__syscall_inline void k_sem_reset(struct k_sem *sem); static inline void _impl_k_sem_reset(struct k_sem *sem) { @@ -2571,7 +2570,7 @@ static inline void _impl_k_sem_reset(struct k_sem *sem) * * @return Current semaphore count. */ -__syscall_inline static inline unsigned int k_sem_count_get(struct k_sem *sem); +__syscall_inline unsigned int k_sem_count_get(struct k_sem *sem); static inline unsigned int _impl_k_sem_count_get(struct k_sem *sem) { diff --git a/include/toolchain/common.h b/include/toolchain/common.h index a05bf957de5..2369ae63ba9 100644 --- a/include/toolchain/common.h +++ b/include/toolchain/common.h @@ -106,6 +106,12 @@ #define _DO_CONCAT(x, y) x ## y #define _CONCAT(x, y) _DO_CONCAT(x, y) +/* Additionally used as a sentinel by gen_syscalls.py to identify what + * functions are system calls + */ +#define __syscall static inline +#define __syscall_inline static inline + #ifndef BUILD_ASSERT /* compile-time assertion that makes the build fail */ #define BUILD_ASSERT(EXPR) typedef char __build_assert_failure[(EXPR) ? 1 : -1] diff --git a/include/toolchain/gcc.h b/include/toolchain/gcc.h index a937c19741c..349051329da 100644 --- a/include/toolchain/gcc.h +++ b/include/toolchain/gcc.h @@ -95,10 +95,6 @@ do { \ #define __deprecated __attribute__((deprecated)) #define ARG_UNUSED(x) (void)(x) -/* Only used by gen_syscalls.py */ -#define __syscall -#define __syscall_inline - #define likely(x) __builtin_expect((long)!!(x), 1L) #define unlikely(x) __builtin_expect((long)!!(x), 0L) diff --git a/scripts/gen_syscalls.py b/scripts/gen_syscalls.py index 8a35dbf44f7..eeb4ba8633f 100755 --- a/scripts/gen_syscalls.py +++ b/scripts/gen_syscalls.py @@ -12,7 +12,6 @@ import os api_regex = re.compile(r''' __(syscall|syscall_inline)\s+ # __syscall or __syscall_inline -static\s+inline\s+ # All prototypes are static inline functions ([^(]+) # type and name of system call (split later) [(] # Function opening parenthesis ([^)]*) # Arg list (split later) @@ -33,7 +32,11 @@ def typename_split(item): if "(" in item: raise SyscallParseException("Please use typedefs for function pointers") - m = typename_regex.match(item).groups() + mo = typename_regex.match(item) + if not mo: + raise SyscallParseException("Malformed system call invocation") + + m = mo.groups() return (m[0].strip(), m[1]) @@ -84,10 +87,14 @@ def analyze_headers(base_path): for root, dirs, files in os.walk(base_path): for fn in files: - if not fn.endswith(".h"): + + # toolchain/common.h has the definition of __syscall which we + # don't want to trip over + path = os.path.join(root, fn) + if not fn.endswith(".h") or path.endswith("toolchain/common.h"): continue - with open(os.path.join(root, fn)) as fp: + with open(path, "r") as fp: try: result = [analyze_fn(mo.groups(), fn) for mo in api_regex.finditer(fp.read())]