Merge "Tidy and document the inline/__inline/__inline__ situation." into main am: a13b3b32e0 am: 886e93a740

Original change: https://android-review.googlesource.com/c/platform/bionic/+/3086727

Change-Id: Ia6ffb3ee43476716f8bc3295ace89c7022f2b7c7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Elliott Hughes 2024-05-21 12:29:11 +00:00 committed by Automerger Merge Worker
commit 39c816e5d6
5 changed files with 14 additions and 11 deletions

View file

@ -71,7 +71,7 @@ char* GetAlignedPtrFilled(std::vector<char>* 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<uint8_t*>(ptr);
for (size_t i = 0; i < nbytes; i += pagesize) {

View file

@ -17,7 +17,7 @@
#include <sys/statfs.h>
#include <sys/statvfs.h>
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;

View file

@ -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);

View file

@ -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);
}

View file

@ -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)