diff --git a/benchmarks/util.h b/benchmarks/util.h index 99eed5f0a..347dc3571 100644 --- a/benchmarks/util.h +++ b/benchmarks/util.h @@ -71,7 +71,7 @@ char* GetAlignedPtrFilled(std::vector* buf, size_t alignment, size_t nbyte bool LockToCPU(int cpu_to_lock); -static __inline __attribute__ ((__always_inline__)) void MakeAllocationResident( +static inline __attribute__((__always_inline__)) void MakeAllocationResident( void* ptr, size_t nbytes, int pagesize) { uint8_t* data = reinterpret_cast(ptr); for (size_t i = 0; i < nbytes; i += pagesize) { diff --git a/libc/bionic/sys_statvfs.cpp b/libc/bionic/sys_statvfs.cpp index b3a0aca0c..3a05c3fa6 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/include/bits/threads_inlines.h b/libc/include/bits/threads_inlines.h index 5878e0acc..459866ed8 100644 --- a/libc/include/bits/threads_inlines.h +++ b/libc/include/bits/threads_inlines.h @@ -124,7 +124,7 @@ struct __bionic_thrd_data { }; #pragma clang diagnostic pop -static inline void* _Nonnull __bionic_thrd_trampoline(void* _Nonnull __arg) { +static __inline void* _Nonnull __bionic_thrd_trampoline(void* _Nonnull __arg) { struct __bionic_thrd_data __data = *__BIONIC_CAST(static_cast, struct __bionic_thrd_data*, __arg); free(__arg); diff --git a/libc/include/strings.h b/libc/include/strings.h index 2f4f7641a..4b8cc08e3 100644 --- a/libc/include/strings.h +++ b/libc/include/strings.h @@ -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 7625d3886..5d1718e94 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -87,9 +87,12 @@ #define __STRING(x) #x #define ___STRING(x) __STRING(x) -#if defined(__cplusplus) -#define __inline inline /* convert to C++ keyword */ -#endif /* !__cplusplus */ +// C++ has `inline` as a keyword, as does C99, but ANSI C (aka C89 aka C90) +// does not. Everything accepts the `__inline__` extension though. We could +// just use that directly in our own code, but there's historical precedent +// for `__inline` meaning it's still used in upstream BSD code (and potentially +// downstream in vendor or app code). +#define __inline __inline__ #define __always_inline __attribute__((__always_inline__)) #define __attribute_const__ __attribute__((__const__)) @@ -260,7 +263,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,9 +271,9 @@ * 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__)) +# define __BIONIC_ERROR_FUNCTION_VISIBILITY static __unused #else /* Further increase sharing for some inline functions */ # define __pass_object_size_n(n)