From 2237fcf1fab5b0ae67d7808f07b9a0ca13e27437 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 14 May 2024 17:53:58 +0000 Subject: [PATCH] Revert "Use inline keyword without underscores consistently" This reverts commit 58f06e11122723d68c5cb393aeb4ed1c7a2e7bfe. Bare `inline` is not ANSI C compatible, and NDK users may be using that. Test: treehugger Change-Id: I82c5424522142001cd59da63ef3fd440014451ad --- libc/bionic/sys_statvfs.cpp | 2 +- libc/dns/resolv/res_cache.c | 22 ++++++++----------- libc/include/android/api-level.h | 2 +- libc/include/android/legacy_stdlib_inlines.h | 6 ++--- libc/include/android/legacy_termios_inlines.h | 4 ++-- libc/include/android/legacy_threads_inlines.h | 2 +- libc/include/android/legacy_unistd_inlines.h | 2 +- libc/include/bits/stdatomic.h | 12 +++++----- libc/include/bits/swab.h | 2 +- libc/include/bits/termios_inlines.h | 4 ++-- libc/include/bits/termios_winsize_inlines.h | 2 +- libc/include/bits/threads_inlines.h | 2 +- libc/include/ctype.h | 2 +- libc/include/strings.h | 6 ++--- libc/include/sys/cdefs.h | 4 ++-- libc/kernel/tools/cpp.py | 4 ++-- 16 files changed, 37 insertions(+), 41 deletions(-) diff --git a/libc/bionic/sys_statvfs.cpp b/libc/bionic/sys_statvfs.cpp index 3a05c3fa6..b3a0aca0c 100644 --- a/libc/bionic/sys_statvfs.cpp +++ b/libc/bionic/sys_statvfs.cpp @@ -17,7 +17,7 @@ #include #include -static inline void __bionic_statfs_to_statvfs(const struct statfs* src, struct statvfs* dst) { +static __inline void __bionic_statfs_to_statvfs(const struct statfs* src, struct statvfs* dst) { dst->f_bsize = src->f_bsize; dst->f_frsize = src->f_frsize; dst->f_blocks = src->f_blocks; diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c index d6416e5c5..38de84b5f 100644 --- a/libc/dns/resolv/res_cache.c +++ b/libc/dns/resolv/res_cache.c @@ -1166,23 +1166,19 @@ entry_free( Entry* e ) } } -static inline void -entry_mru_remove( Entry* e ) -{ - e->mru_prev->mru_next = e->mru_next; - e->mru_next->mru_prev = e->mru_prev; +static __inline__ void entry_mru_remove(Entry* e) { + e->mru_prev->mru_next = e->mru_next; + e->mru_next->mru_prev = e->mru_prev; } -static inline void -entry_mru_add( Entry* e, Entry* list ) -{ - Entry* first = list->mru_next; +static __inline__ void entry_mru_add(Entry* e, Entry* list) { + Entry* first = list->mru_next; - e->mru_next = first; - e->mru_prev = list; + e->mru_next = first; + e->mru_prev = list; - list->mru_next = e; - first->mru_prev = e; + list->mru_next = e; + first->mru_prev = e; } /* compute the hash of a given entry, this is a hash of most diff --git a/libc/include/android/api-level.h b/libc/include/android/api-level.h index 113897c97..77ec6530b 100644 --- a/libc/include/android/api-level.h +++ b/libc/include/android/api-level.h @@ -191,7 +191,7 @@ int android_get_application_target_sdk_version() __INTRODUCED_IN(24); #if __ANDROID_API__ < 29 /* android_get_device_api_level is a static inline before API level 29. */ -#define __BIONIC_GET_DEVICE_API_LEVEL_INLINE static inline +#define __BIONIC_GET_DEVICE_API_LEVEL_INLINE static __inline #include #undef __BIONIC_GET_DEVICE_API_LEVEL_INLINE diff --git a/libc/include/android/legacy_stdlib_inlines.h b/libc/include/android/legacy_stdlib_inlines.h index 0ca1022e8..f0985fe61 100644 --- a/libc/include/android/legacy_stdlib_inlines.h +++ b/libc/include/android/legacy_stdlib_inlines.h @@ -38,15 +38,15 @@ __BEGIN_DECLS -static inline double strtod_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) { +static __inline double strtod_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) { return strtod(__s, __end_ptr); } -static inline float strtof_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) { +static __inline float strtof_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) { return strtof(__s, __end_ptr); } -static inline long strtol_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) { +static __inline long strtol_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) { return strtol(__s, __end_ptr, __base); } diff --git a/libc/include/android/legacy_termios_inlines.h b/libc/include/android/legacy_termios_inlines.h index e557525ab..a816b4048 100644 --- a/libc/include/android/legacy_termios_inlines.h +++ b/libc/include/android/legacy_termios_inlines.h @@ -39,14 +39,14 @@ #include #include -#define __BIONIC_TERMIOS_INLINE static inline +#define __BIONIC_TERMIOS_INLINE static __inline #include #endif #if __ANDROID_API__ < 35 -#define __BIONIC_TERMIOS_WINSIZE_INLINE static inline +#define __BIONIC_TERMIOS_WINSIZE_INLINE static __inline #include #endif diff --git a/libc/include/android/legacy_threads_inlines.h b/libc/include/android/legacy_threads_inlines.h index 06e743813..c614cd01a 100644 --- a/libc/include/android/legacy_threads_inlines.h +++ b/libc/include/android/legacy_threads_inlines.h @@ -32,7 +32,7 @@ #if __ANDROID_API__ < 30 -#define __BIONIC_THREADS_INLINE static inline +#define __BIONIC_THREADS_INLINE static __inline #include #endif diff --git a/libc/include/android/legacy_unistd_inlines.h b/libc/include/android/legacy_unistd_inlines.h index ac9f3b354..4a5206b88 100644 --- a/libc/include/android/legacy_unistd_inlines.h +++ b/libc/include/android/legacy_unistd_inlines.h @@ -32,7 +32,7 @@ #if __ANDROID_API__ < 28 -#define __BIONIC_SWAB_INLINE static inline +#define __BIONIC_SWAB_INLINE static __inline #include #endif diff --git a/libc/include/bits/stdatomic.h b/libc/include/bits/stdatomic.h index 8df86e2ad..c74eafdec 100644 --- a/libc/include/bits/stdatomic.h +++ b/libc/include/bits/stdatomic.h @@ -138,11 +138,11 @@ typedef enum { * 7.17.4 Fences. */ -static inline void atomic_thread_fence(memory_order __order __attribute__((__unused__))) { +static __inline void atomic_thread_fence(memory_order __order __attribute__((__unused__))) { __c11_atomic_thread_fence(__order); } -static inline void atomic_signal_fence(memory_order __order __attribute__((__unused__))) { +static __inline void atomic_signal_fence(memory_order __order __attribute__((__unused__))) { __c11_atomic_signal_fence(__order); } @@ -269,18 +269,18 @@ typedef struct { #define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(false) } -static inline bool atomic_flag_test_and_set_explicit(volatile atomic_flag * _Nonnull __object, memory_order __order) { +static __inline bool atomic_flag_test_and_set_explicit(volatile atomic_flag * _Nonnull __object, memory_order __order) { return (atomic_exchange_explicit(&__object->__flag, 1, __order)); } -static inline void atomic_flag_clear_explicit(volatile atomic_flag * _Nonnull __object, memory_order __order) { +static __inline void atomic_flag_clear_explicit(volatile atomic_flag * _Nonnull __object, memory_order __order) { atomic_store_explicit(&__object->__flag, 0, __order); } -static inline bool atomic_flag_test_and_set(volatile atomic_flag * _Nonnull __object) { +static __inline bool atomic_flag_test_and_set(volatile atomic_flag * _Nonnull __object) { return (atomic_flag_test_and_set_explicit(__object, memory_order_seq_cst)); } -static inline void atomic_flag_clear(volatile atomic_flag * _Nonnull __object) { +static __inline void atomic_flag_clear(volatile atomic_flag * _Nonnull __object) { atomic_flag_clear_explicit(__object, memory_order_seq_cst); } diff --git a/libc/include/bits/swab.h b/libc/include/bits/swab.h index ebb7c7406..9591c2ede 100644 --- a/libc/include/bits/swab.h +++ b/libc/include/bits/swab.h @@ -33,7 +33,7 @@ #include #if !defined(__BIONIC_SWAB_INLINE) -#define __BIONIC_SWAB_INLINE static inline +#define __BIONIC_SWAB_INLINE static __inline #endif __BEGIN_DECLS diff --git a/libc/include/bits/termios_inlines.h b/libc/include/bits/termios_inlines.h index 702f43346..a884b595f 100644 --- a/libc/include/bits/termios_inlines.h +++ b/libc/include/bits/termios_inlines.h @@ -37,7 +37,7 @@ #include #if !defined(__BIONIC_TERMIOS_INLINE) -#define __BIONIC_TERMIOS_INLINE static inline +#define __BIONIC_TERMIOS_INLINE static __inline #endif __BEGIN_DECLS @@ -45,7 +45,7 @@ __BEGIN_DECLS // Supporting separate input and output speeds would require an ABI // change for `struct termios`. -static inline speed_t cfgetspeed(const struct termios* _Nonnull s) { +static __inline speed_t cfgetspeed(const struct termios* _Nonnull s) { return __BIONIC_CAST(static_cast, speed_t, s->c_cflag & CBAUD); } diff --git a/libc/include/bits/termios_winsize_inlines.h b/libc/include/bits/termios_winsize_inlines.h index 0d188e75e..ae246e401 100644 --- a/libc/include/bits/termios_winsize_inlines.h +++ b/libc/include/bits/termios_winsize_inlines.h @@ -36,7 +36,7 @@ #include #if !defined(__BIONIC_TERMIOS_WINSIZE_INLINE) -#define __BIONIC_TERMIOS_WINSIZE_INLINE static inline +#define __BIONIC_TERMIOS_WINSIZE_INLINE static __inline #endif __BEGIN_DECLS diff --git a/libc/include/bits/threads_inlines.h b/libc/include/bits/threads_inlines.h index 074e1ca98..5878e0acc 100644 --- a/libc/include/bits/threads_inlines.h +++ b/libc/include/bits/threads_inlines.h @@ -38,7 +38,7 @@ __BEGIN_DECLS -static inline int __bionic_thrd_error(int __pthread_code) { +static __inline int __bionic_thrd_error(int __pthread_code) { switch (__pthread_code) { case 0: return 0; case ENOMEM: return thrd_nomem; diff --git a/libc/include/ctype.h b/libc/include/ctype.h index 5cad412d6..c15ee5618 100644 --- a/libc/include/ctype.h +++ b/libc/include/ctype.h @@ -42,7 +42,7 @@ * also provide actual symbols for any caller that needs them. */ #if !defined(__BIONIC_CTYPE_INLINE) -#define __BIONIC_CTYPE_INLINE static inline +#define __BIONIC_CTYPE_INLINE static __inline #endif /** Internal implementation detail. Do not use. */ diff --git a/libc/include/strings.h b/libc/include/strings.h index 6ec3bdf58..2f4f7641a 100644 --- a/libc/include/strings.h +++ b/libc/include/strings.h @@ -50,7 +50,7 @@ #include #if !defined(__BIONIC_STRINGS_INLINE) -#define __BIONIC_STRINGS_INLINE static inline +#define __BIONIC_STRINGS_INLINE static __inline #endif #undef ffs @@ -61,13 +61,13 @@ __BEGIN_DECLS /** Deprecated. Use memmove() instead. */ #define bcopy(b1, b2, len) __bionic_bcopy((b1), (b2), (len)) -static inline __always_inline void __bionic_bcopy(const void* _Nonnull b1, void* _Nonnull b2, size_t len) { +static __inline__ __always_inline void __bionic_bcopy(const void* _Nonnull b1, void* _Nonnull b2, size_t len) { __builtin_memmove(b2, b1, len); } /** Deprecated. Use memset() instead. */ #define bzero(b, len) __bionic_bzero((b), (len)) -static inline __always_inline void __bionic_bzero(void* _Nonnull b, size_t len) { +static __inline__ __always_inline void __bionic_bzero(void* _Nonnull b, size_t len) { __builtin_memset(b, 0, len); } diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index 3218d1554..7625d3886 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -260,7 +260,7 @@ * them available externally. FORTIFY'ed functions try to be as close to possible as 'invisible'; * having stack protectors detracts from that (b/182948263). */ -# define __BIONIC_FORTIFY_INLINE static inline __attribute__((__no_stack_protector__)) \ +# define __BIONIC_FORTIFY_INLINE static __inline__ __attribute__((__no_stack_protector__)) \ __always_inline __VERSIONER_FORTIFY_INLINE /* * We should use __BIONIC_FORTIFY_VARIADIC instead of __BIONIC_FORTIFY_INLINE @@ -268,7 +268,7 @@ * The __always_inline attribute is useless, misleading, and could trigger * clang compiler bug to incorrectly inline variadic functions. */ -# define __BIONIC_FORTIFY_VARIADIC static inline +# define __BIONIC_FORTIFY_VARIADIC static __inline__ /* Error functions don't have bodies, so they can just be static. */ # define __BIONIC_ERROR_FUNCTION_VISIBILITY static __attribute__((__unused__)) #else diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py index 0fd6e46f9..08b786ac5 100755 --- a/libc/kernel/tools/cpp.py +++ b/libc/kernel/tools/cpp.py @@ -2345,11 +2345,11 @@ struct something_s { def test_function_keep_attribute_structs(self): text = """\ -static inline struct some_struct1 * function(struct some_struct2 * e) { +static __inline__ struct some_struct1 * function(struct some_struct2 * e) { } """ expected = """\ -static inline struct some_struct1 * function(struct some_struct2 * e) { +static __inline__ struct some_struct1 * function(struct some_struct2 * e) { } """ self.assertEqual(self.parse(text, set(["function"])), expected)