mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <Jens.Gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: [musl] [C23 feature tests 5/6] add a `__inline_or_static` macro for pre-C99 compilers
Date: Wed, 10 May 2023 14:48:02 +0200	[thread overview]
Message-ID: <cd2ec74ea1f4b1cf29edfb99c0e980da287402da.1684922674.git.Jens.Gustedt@inria.fr> (raw)
In-Reply-To: <cover.1684922674.git.Jens.Gustedt@inria.fr>

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

  parent reply	other threads:[~2023-05-24 13:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-24 10:04 [musl] [C23 feature tests 0/6] tests needed for C23 interfaces Jens Gustedt
2023-05-03  9:44 ` [musl] [C23 feature tests 1/6] C23: provide fallbacks for the use of C attributes Jens Gustedt
2023-05-03 11:26 ` [musl] [C23 feature tests 2/6] C23: add a feature test for the __VA_OPT__ feature Jens Gustedt
2023-05-03 11:40 ` [musl] [C23 feature tests 3/6] C23: add a feature test for the [u]int128_t Jens Gustedt
2023-05-09 15:27 ` [musl] [C23 feature tests 6/6] C23: add an internal interface for the new unsequenced attribute Jens Gustedt
2023-05-10 12:48 ` Jens Gustedt [this message]
2023-05-10 12:57 ` [musl] [C23 feature tests 4/6] Add a feature test for the _BitInt types Jens Gustedt
2023-05-24 13:58 ` [musl] [C23 feature tests 0/6] tests needed for C23 interfaces Rich Felker
2023-05-24 14:11   ` Jₑₙₛ Gustedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd2ec74ea1f4b1cf29edfb99c0e980da287402da.1684922674.git.Jens.Gustedt@inria.fr \
    --to=jens.gustedt@inria.fr \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).