From fcb64311dc7a8b28bfce0f774a211a2e15786b55 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 28 Feb 2022 18:48:32 -0700 Subject: [PATCH] LibC: Don't export ALWAYS_INLINE from sys/cdefs.h POSIX doesn't tell us to export a macro like this, and it's largely going to never be defined when compiling a serenity-native C++ file, since AK defines it already. This does raise a strange issue where some futex-related helpers in serenity.h are declared with ALWAYS_INLINE. Whether these helpers belong in a C-visible header as file-static methods is questionable, but let's work around the issue but adding some preprocessor magic to make sure these declarations get the behavior they used to have without leaking macros. --- Userland/Libraries/LibC/serenity.h | 9 +++++++++ Userland/Libraries/LibC/sys/cdefs.h | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibC/serenity.h b/Userland/Libraries/LibC/serenity.h index 7771026a11c900..c60625494b19d9 100644 --- a/Userland/Libraries/LibC/serenity.h +++ b/Userland/Libraries/LibC/serenity.h @@ -22,6 +22,11 @@ int profiling_free_buffer(pid_t); int futex(uint32_t* userspace_address, int futex_op, uint32_t value, const struct timespec* timeout, uint32_t* userspace_address2, uint32_t value3); +#ifndef ALWAYS_INLINE +# define ALWAYS_INLINE inline __attribute__((always_inline)) +# define ALWAYS_INLINE_SERENITY_H +#endif + static ALWAYS_INLINE int futex_wait(uint32_t* userspace_address, uint32_t value, const struct timespec* abstime, int clockid) { int op; @@ -42,6 +47,10 @@ static ALWAYS_INLINE int futex_wake(uint32_t* userspace_address, uint32_t count) return futex(userspace_address, FUTEX_WAKE, count, NULL, NULL, 0); } +#ifdef ALWAYS_INLINE_SERENITY_H +# undef ALWAYS_INLINE +#endif + int purge(int mode); int perf_event(int type, uintptr_t arg1, uintptr_t arg2); diff --git a/Userland/Libraries/LibC/sys/cdefs.h b/Userland/Libraries/LibC/sys/cdefs.h index 15ee0b0a8d6106..00d6444102737c 100644 --- a/Userland/Libraries/LibC/sys/cdefs.h +++ b/Userland/Libraries/LibC/sys/cdefs.h @@ -8,10 +8,6 @@ #define _POSIX_VERSION 200809L -#ifndef ALWAYS_INLINE -# define ALWAYS_INLINE inline __attribute__((always_inline)) -#endif - #ifdef __cplusplus # ifndef __BEGIN_DECLS # define __BEGIN_DECLS extern "C" {