Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <cd2ec74ea1f4b1cf29edfb99c0e980da287402da.1684922674.git.Jens.Gustedt@inria.fr>
Date: Wed, 10 May 2023 14:48:02 +0200
From: Jens Gustedt <Jens.Gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: [C23 feature tests 5/6] add a `__inline_or_static` macro for
 pre-C99 compilers

pre-C99 may not have `inline`. To be able to emulate `inline` for
those compilers we use `__inline_or_static`, which for all other
compilers is set to `inline`. For pre-C99 compilers it is set in the
application visible header to `static`. For the compilation of musl
itself it is set to empty, such that the symbol is produced and
available in musl.

So under all circumstances the symbol will be available as external
symbol in musl.

Applications that link against such a compiled library and that don't
have inline, a compilation will produce a `static` symbol in each
TU. This is not completely conforming, but we cannot expect much more
for pre-C99 compilers.

On the other hand if the application is compiled with existing
`inline`, this does whatever the compiler thinks is best. If it then
needs an external symbol in the C library, that symbol is available
under all versions.
---
 include/features.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/features.h b/include/features.h
index f200a6b4..5d460800 100644
--- a/include/features.h
+++ b/include/features.h
@@ -24,9 +24,13 @@
 
 #if __STDC_VERSION__ >= 199901L || defined(__cplusplus)
 #define __inline inline
-#elif !defined(__GNUC__)
+#define __inline_or_static inline
+#else
+#if !defined(__GNUC__)
 #define __inline
 #endif
+#define __inline_or_static static
+#endif
 
 #if __STDC_VERSION__ >= 201112L
 #elif defined(__GNUC__)
-- 
2.34.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.