mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [C23 divers headers 00/17]
@ 2023-05-31  9:22 Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 01/17] C23: add the WIDTH macros for the standard integer types Jens Gustedt
                   ` (16 more replies)
  0 siblings, 17 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

A new version (v7 in my counting) that better protects against name
space intrusion.

Jens Gustedt (17):
  C23: add the WIDTH macros for the standard integer types
  C23: Add the *_WIDTH macros to stdint.h
  C23: add call_once to stdlib.h
  C23: add timegm, gmtime_r and localtime_r to time.h in C23 mode
  C23: memccpy, strdup and strndup are now standard C
  C23: adapt setjmp.h
  C23: change the noreturn functions in stdlib.h
  C23: change the noreturn function in threads.h
  C23: update stdbool.h
  C23: remove the contents of stdalign.h
  C23: remove the static_assert macro
  C23: change the assert macro to ... arguments
  C23: add the __STDC_VERSION_ASSERT_H__ macro
  C23: allow va_start to receive only one argument
  C23: add the unreachable macro
  C23: add the nullptr_t type
  C23: add the __STDC_VERSION_STDDEF_H__ macro

 include/assert.h       | 17 +++++++---
 include/limits.h       | 18 ++++++++++
 include/setjmp.h       |  6 ++--
 include/stdalign.h     | 15 +++++---
 include/stdarg.h       |  9 +++--
 include/stdbool.h      | 10 ++++--
 include/stddef.h       | 17 ++++++++--
 include/stdint.h       | 77 ++++++++++++++++++++++++++++++++++++++++--
 include/stdlib.h       | 14 +++++---
 include/string.h       | 11 +++---
 include/threads.h      |  2 +-
 include/time.h         |  7 ++--
 src/exit/_Exit.c       |  2 +-
 src/exit/abort.c       |  2 +-
 src/exit/exit.c        |  2 +-
 src/exit/quick_exit.c  |  2 +-
 src/thread/thrd_exit.c |  2 +-
 17 files changed, 172 insertions(+), 41 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 01/17] C23: add the WIDTH macros for the standard integer types
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 02/17] C23: Add the *_WIDTH macros to stdint.h Jens Gustedt
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

These have not previously reserved, nevertheless we define them
without feature macro. This is because these are now the fundamental
definitions for standard integer types, basically all other features
of standard integer types can now be derived from them. We could later
add a cleanup patch, that would exactly do that: provide the width of
all integer types and then derive MIN and MAX macros systematically
from that.
---
 include/limits.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/include/limits.h b/include/limits.h
index 53a27b9d..476f4891 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -5,6 +5,24 @@
 
 #include <bits/alltypes.h> /* __LONG_MAX */
 
+#define BOOL_WIDTH 1
+#define CHAR_WIDTH 8
+#define UCHAR_WIDTH 8
+#define SCHAR_WIDTH 8
+#define USHRT_WIDTH 16
+#define SHRT_WIDTH 16
+#define UINT_WIDTH 32
+#define INT_WIDTH 32
+#define ULLONG_WIDTH 64
+#define LLONG_WIDTH 64
+#if __LONG_MAX == 0x7fffffff
+#define ULONG_WIDTH 32
+#define LONG_WIDTH 32
+#else
+#define ULONG_WIDTH 64
+#define LONG_WIDTH 64
+#endif
+
 /* Support signed or unsigned plain-char */
 
 #if '\xff' > 0
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 02/17] C23: Add the *_WIDTH macros to stdint.h
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 01/17] C23: add the WIDTH macros for the standard integer types Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 03/17] C23: add call_once to stdlib.h Jens Gustedt
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

This basically doubles the strategies as are already in place to
determine the correct values.

All this generation of these macros would merrit some refactoring.

We also set the include guard to the macro name requested by C23, only
that we do not yet use the final version number. This should be done
once it is agreed that this part of the headers are C23 compliant.
---
 include/stdint.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 75 insertions(+), 2 deletions(-)

diff --git a/include/stdint.h b/include/stdint.h
index a2968197..1f68b3bb 100644
--- a/include/stdint.h
+++ b/include/stdint.h
@@ -1,5 +1,5 @@
-#ifndef _STDINT_H
-#define _STDINT_H
+#ifndef __STDC_VERSION_STDINT_H__
+#define __STDC_VERSION_STDINT_H__ 201711L
 
 #define __NEED_int8_t
 #define __NEED_int16_t
@@ -35,6 +35,11 @@ typedef uint16_t uint_least16_t;
 typedef uint32_t uint_least32_t;
 typedef uint64_t uint_least64_t;
 
+#define INT8_WIDTH   8
+#define INT16_WIDTH  16
+#define INT32_WIDTH  32
+#define INT64_WIDTH  64
+
 #define INT8_MIN   (-1-0x7f)
 #define INT16_MIN  (-1-0x7fff)
 #define INT32_MIN  (-1-0x7fffffff)
@@ -45,14 +50,27 @@ typedef uint64_t uint_least64_t;
 #define INT32_MAX  (0x7fffffff)
 #define INT64_MAX  (0x7fffffffffffffff)
 
+#define UINT8_WIDTH   8
+#define UINT16_WIDTH  16
+#define UINT32_WIDTH  32
+#define UINT64_WIDTH  64
+
 #define UINT8_MAX  (0xff)
 #define UINT16_MAX (0xffff)
 #define UINT32_MAX (0xffffffffu)
 #define UINT64_MAX (0xffffffffffffffffu)
 
+#define INT_FAST8_WIDTH   8
+#define INT_FAST64_WIDTH  64
+
 #define INT_FAST8_MIN   INT8_MIN
 #define INT_FAST64_MIN  INT64_MIN
 
+#define INT_LEAST8_WIDTH   8
+#define INT_LEAST16_WIDTH  16
+#define INT_LEAST32_WIDTH  32
+#define INT_LEAST64_WIDTH  64
+
 #define INT_LEAST8_MIN   INT8_MIN
 #define INT_LEAST16_MIN  INT16_MIN
 #define INT_LEAST32_MIN  INT32_MIN
@@ -66,21 +84,36 @@ typedef uint64_t uint_least64_t;
 #define INT_LEAST32_MAX  INT32_MAX
 #define INT_LEAST64_MAX  INT64_MAX
 
+#define UINT_FAST8_WIDTH   8
+#define UINT_FAST64_WIDTH  64
+
 #define UINT_FAST8_MAX  UINT8_MAX
 #define UINT_FAST64_MAX UINT64_MAX
 
+#define UINT_LEAST8_WIDTH   8
+#define UINT_LEAST16_WIDTH  16
+#define UINT_LEAST32_WIDTH  32
+#define UINT_LEAST64_WIDTH  64
+
 #define UINT_LEAST8_MAX  UINT8_MAX
 #define UINT_LEAST16_MAX UINT16_MAX
 #define UINT_LEAST32_MAX UINT32_MAX
 #define UINT_LEAST64_MAX UINT64_MAX
 
+#define INTMAX_WIDTH 64
+#define UINTMAX_WIDTH 64
+
 #define INTMAX_MIN  INT64_MIN
 #define INTMAX_MAX  INT64_MAX
 #define UINTMAX_MAX UINT64_MAX
 
+#define WINT_WIDTH 32
+
 #define WINT_MIN 0U
 #define WINT_MAX UINT32_MAX
 
+#define WCHAR_WIDTH 32
+
 #if L'\0'-1 > 0
 #define WCHAR_MAX (0xffffffffu+L'\0')
 #define WCHAR_MIN (0+L'\0')
@@ -89,6 +122,8 @@ typedef uint64_t uint_least64_t;
 #define WCHAR_MIN (-1-0x7fffffff+L'\0')
 #endif
 
+#define SIG_ATOMIC_WIDTH 32
+
 #define SIG_ATOMIC_MIN  INT32_MIN
 #define SIG_ATOMIC_MAX  INT32_MAX
 
@@ -103,15 +138,53 @@ typedef uint64_t uint_least64_t;
 #define UINT32_C(c) c ## U
 
 #if UINTPTR_MAX == UINT64_MAX
+#define INTPTR_WIDTH 64
+#define UINTPTR_WIDTH 64
 #define INT64_C(c) c ## L
 #define UINT64_C(c) c ## UL
 #define INTMAX_C(c)  c ## L
 #define UINTMAX_C(c) c ## UL
 #else
+#define INTPTR_WIDTH 32
+#define UINTPTR_WIDTH 32
 #define INT64_C(c) c ## LL
 #define UINT64_C(c) c ## ULL
 #define INTMAX_C(c)  c ## LL
 #define UINTMAX_C(c) c ## ULL
 #endif
 
+#if UINT_FAST16_MAX == UINT32_MAX
+#define INT_FAST16_WIDTH 32
+#define UINT_FAST16_WIDTH 32
+#else
+#define INT_FAST16_WIDTH 16
+#define UINT_FAST16_WIDTH 16
+#endif
+
+#if UINT_FAST32_MAX == UINT64_MAX
+#define INT_FAST32_WIDTH 64
+#define UINT_FAST32_WIDTH 64
+#else
+#define INT_FAST32_WIDTH 32
+#define UINT_FAST32_WIDTH 32
+#endif
+
+#if PTRDIFF_MAX == INT64_MAX
+#define PTRDIFF_WIDTH 64
+#else
+#define PTRDIFF_WIDTH 32
+#endif
+
+#if SIZE_MAX == UINT64_MAX
+#define SIZE_WIDTH 64
+#else
+#define SIZE_WIDTH 32
+#endif
+
+// Enable support for _BitInt(N) types, if that comes not from the
+// compiler directly.
+#if (__STDC_VERSION__ >= 201900L) && !BITINT_MAXWIDTH && __BITINT_MAXWIDTH__
+#define BITINT_MAXWIDTH __BITINT_MAXWIDTH__
+#endif
+
 #endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 03/17] C23: add call_once to stdlib.h
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 01/17] C23: add the WIDTH macros for the standard integer types Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 02/17] C23: Add the *_WIDTH macros to stdint.h Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 04/17] C23: add timegm, gmtime_r and localtime_r to time.h in C23 mode Jens Gustedt
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

Since C23, call_once, once_flag and ONCE_FLAG_INIT are also accessible
even if the platform does not have the threads option. Add them to the
header.

The identifiers once_flag and ONCE_FLAG_INIT were not reserved in C17
if the header threads.h was not included, so we protect this with the
version macro.
---
 include/stdlib.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/stdlib.h b/include/stdlib.h
index 475190bf..0e66f84a 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -172,6 +172,12 @@ long double strtold_l(const char *__restrict, char **__restrict, struct __locale
 #endif
 #endif
 
+#if __STDC_VERSION__ >= 202000L
+#define ONCE_FLAG_INIT 0
+typedef int once_flag;
+void call_once(once_flag *, void (*)(void));
+#endif
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 04/17] C23: add timegm, gmtime_r and localtime_r to time.h in C23 mode
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (2 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 03/17] C23: add call_once to stdlib.h Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 05/17] C23: memccpy, strdup and strndup are now standard C Jens Gustedt
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

These are already present in musl, only they had been protected under
some POSIX or BSD macros. Make them available generally.

Their names were not reserved previously, so there are potential
naming conflicts with application code.
---
 include/time.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/time.h b/include/time.h
index 3d948372..e94b3a01 100644
--- a/include/time.h
+++ b/include/time.h
@@ -66,14 +66,16 @@ int timespec_get(struct timespec *, int);
 
 #define TIME_UTC 1
 
+struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
+struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
+time_t timegm(struct tm *);
+
 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  || defined(_BSD_SOURCE)
 
 size_t strftime_l (char *  __restrict, size_t, const char *  __restrict, const struct tm *  __restrict, locale_t);
 
-struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
-struct tm *localtime_r (const time_t *__restrict, struct tm *__restrict);
 char *asctime_r (const struct tm *__restrict, char *__restrict);
 char *ctime_r (const time_t *, char *);
 
@@ -129,7 +131,6 @@ struct tm *getdate (const char *);
 
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 int stime(const time_t *);
-time_t timegm(struct tm *);
 #endif
 
 #if _REDIR_TIME64
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 05/17] C23: memccpy, strdup and strndup are now standard C
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (3 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 04/17] C23: add timegm, gmtime_r and localtime_r to time.h in C23 mode Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 06/17] C23: adapt setjmp.h Jens Gustedt
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

Just remove the feature guards around these. These guards had not even
strictly been necessary before, because prefixes mem and str are
reserved.
---
 include/string.h | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/string.h b/include/string.h
index db73d2a9..7df7a402 100644
--- a/include/string.h
+++ b/include/string.h
@@ -55,6 +55,10 @@ size_t strlen (const char *);
 
 char *strerror (int);
 
+char *strdup (const char *);
+char *strndup (const char *, size_t);
+void *memccpy (void *__restrict, const void *__restrict, int, size_t);
+
 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
 #include <strings.h>
 #endif
@@ -67,8 +71,6 @@ int strerror_r (int, char *, size_t);
 char *stpcpy(char *__restrict, const char *__restrict);
 char *stpncpy(char *__restrict, const char *__restrict, size_t);
 size_t strnlen (const char *, size_t);
-char *strdup (const char *);
-char *strndup (const char *, size_t);
 char *strsignal(int);
 char *strerror_l (int, locale_t);
 int strcoll_l (const char *, const char *, locale_t);
@@ -76,11 +78,6 @@ size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
 void *memmem(const void *, size_t, const void *, size_t);
 #endif
 
-#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
- || defined(_BSD_SOURCE)
-void *memccpy (void *__restrict, const void *__restrict, int, size_t);
-#endif
-
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
 char *strsep(char **, const char *);
 size_t strlcat (char *, const char *, size_t);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 06/17] C23: adapt setjmp.h
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (4 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 05/17] C23: memccpy, strdup and strndup are now standard C Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 07/17] C23: change the noreturn functions in stdlib.h Jens Gustedt
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

---
 include/setjmp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/setjmp.h b/include/setjmp.h
index 1976af23..beb9481c 100644
--- a/include/setjmp.h
+++ b/include/setjmp.h
@@ -1,5 +1,5 @@
-#ifndef	_SETJMP_H
-#define	_SETJMP_H
+#ifndef	__STDC_VERSION_SETJMP_H__
+#define	__STDC_VERSION_SETJMP_H__ 202311L
 
 #ifdef __cplusplus
 extern "C" {
@@ -36,7 +36,7 @@ _Noreturn void _longjmp (jmp_buf, int);
 #endif
 
 int setjmp (jmp_buf) __setjmp_attr;
-_Noreturn void longjmp (jmp_buf, int);
+__noreturn void longjmp (jmp_buf, int);
 
 #define setjmp setjmp
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 07/17] C23: change the noreturn functions in stdlib.h
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (5 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 06/17] C23: adapt setjmp.h Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 08/17] C23: change the noreturn function in threads.h Jens Gustedt
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

---
 include/stdlib.h      | 8 ++++----
 src/exit/_Exit.c      | 2 +-
 src/exit/abort.c      | 2 +-
 src/exit/exit.c       | 2 +-
 src/exit/quick_exit.c | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/stdlib.h b/include/stdlib.h
index 0e66f84a..037e4dc4 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -43,12 +43,12 @@ void *realloc (void *, size_t);
 void free (void *);
 void *aligned_alloc(size_t, size_t);
 
-_Noreturn void abort (void);
+__noreturn void abort (void);
 int atexit (void (*) (void));
-_Noreturn void exit (int);
-_Noreturn void _Exit (int);
+__noreturn void exit (int);
+__noreturn void _Exit (int);
 int at_quick_exit (void (*) (void));
-_Noreturn void quick_exit (int);
+__noreturn void quick_exit (int);
 
 char *getenv (const char *);
 
diff --git a/src/exit/_Exit.c b/src/exit/_Exit.c
index 7a6115c7..344e0194 100644
--- a/src/exit/_Exit.c
+++ b/src/exit/_Exit.c
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "syscall.h"
 
-_Noreturn void _Exit(int ec)
+__noreturn void _Exit(int ec)
 {
 	__syscall(SYS_exit_group, ec);
 	for (;;) __syscall(SYS_exit, ec);
diff --git a/src/exit/abort.c b/src/exit/abort.c
index f21f458e..276eb754 100644
--- a/src/exit/abort.c
+++ b/src/exit/abort.c
@@ -6,7 +6,7 @@
 #include "lock.h"
 #include "ksigaction.h"
 
-_Noreturn void abort(void)
+__noreturn void abort(void)
 {
 	raise(SIGABRT);
 
diff --git a/src/exit/exit.c b/src/exit/exit.c
index a6869b37..6ceb4f6d 100644
--- a/src/exit/exit.c
+++ b/src/exit/exit.c
@@ -24,7 +24,7 @@ static void libc_exit_fini(void)
 
 weak_alias(libc_exit_fini, __libc_exit_fini);
 
-_Noreturn void exit(int code)
+__noreturn void exit(int code)
 {
 	__funcs_on_exit();
 	__libc_exit_fini();
diff --git a/src/exit/quick_exit.c b/src/exit/quick_exit.c
index ada91348..e4167836 100644
--- a/src/exit/quick_exit.c
+++ b/src/exit/quick_exit.c
@@ -4,7 +4,7 @@
 static void dummy() { }
 weak_alias(dummy, __funcs_on_quick_exit);
 
-_Noreturn void quick_exit(int code)
+__noreturn void quick_exit(int code)
 {
 	__funcs_on_quick_exit();
 	_Exit(code);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 08/17] C23: change the noreturn function in threads.h
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (6 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 07/17] C23: change the noreturn functions in stdlib.h Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 09/17] C23: update stdbool.h Jens Gustedt
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

---
 include/threads.h      | 2 +-
 src/thread/thrd_exit.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/threads.h b/include/threads.h
index 52ec3100..608ff2a3 100644
--- a/include/threads.h
+++ b/include/threads.h
@@ -41,7 +41,7 @@ enum {
 #define ONCE_FLAG_INIT 0
 
 int thrd_create(thrd_t *, thrd_start_t, void *);
-_Noreturn void thrd_exit(int);
+__noreturn void thrd_exit(int);
 
 int thrd_detach(thrd_t);
 int thrd_join(thrd_t, int *);
diff --git a/src/thread/thrd_exit.c b/src/thread/thrd_exit.c
index 9b291ae3..fd094441 100644
--- a/src/thread/thrd_exit.c
+++ b/src/thread/thrd_exit.c
@@ -2,7 +2,7 @@
 #include <pthread.h>
 #include <stdint.h>
 
-_Noreturn void thrd_exit(int result)
+__noreturn void thrd_exit(int result)
 {
 	__pthread_exit((void*)(intptr_t)result);
 }
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 09/17] C23: update stdbool.h
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (7 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 08/17] C23: change the noreturn function in threads.h Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31 12:58   ` Joakim Sindholt
  2023-05-31  9:22 ` [musl] [C23 divers headers 10/17] C23: remove the contents of stdalign.h Jens Gustedt
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

C23 has false, true and bool as keywords, so this file is basically
not needed for modern applications. It is only provided for backwards
compatibility. Implementations may also provide macros in addition to
the keywords, so we do that because some user code may rely on these.
---
 include/stdbool.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/stdbool.h b/include/stdbool.h
index a9d7ab78..d9df7524 100644
--- a/include/stdbool.h
+++ b/include/stdbool.h
@@ -1,11 +1,17 @@
-#ifndef _STDBOOL_H
-#define _STDBOOL_H
+#ifndef __STDC_VERSION_STDBOOL_H__
+#define __STDC_VERSION_STDBOOL_H__ 202311L
 
 #ifndef __cplusplus
 
+#if __STDC_VERSION__ >= 202311L
+#define true true
+#define false false
+#define bool bool
+#else
 #define true 1
 #define false 0
 #define bool _Bool
+#endif
 
 #endif
 
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 10/17] C23: remove the contents of stdalign.h
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (8 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 09/17] C23: update stdbool.h Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 11/17] C23: remove the static_assert macro Jens Gustedt
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

This now has no contents because the features have been promoted to
keywords.
---
 include/stdalign.h | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/include/stdalign.h b/include/stdalign.h
index 2cc94be3..0f4f28ac 100644
--- a/include/stdalign.h
+++ b/include/stdalign.h
@@ -1,20 +1,25 @@
-#ifndef _STDALIGN_H
-#define _STDALIGN_H
+#ifndef __STDC_VERSION_STDALIGN_H__
+#define __STDC_VERSION_STDALIGN_H__ 202311L
 
 #ifndef __cplusplus
 
 /* this whole header only works in C11 or with compiler extensions */
 #if __STDC_VERSION__ < 201112L && defined( __GNUC__)
-#define _Alignas(t) __attribute__((__aligned__(t)))
-#define _Alignof(t) __alignof__(t)
+# define _Alignas(t) __attribute__((__aligned__(t)))
+# define _Alignof(t) __alignof__(t)
 #endif
 
+#if __STDC_VERSION__ < 202311L
 #define alignas _Alignas
 #define alignof _Alignof
-
 #endif
 
+/* Starting with C23 this header has no contents because these are keywords. */
+#if __STDC_VERSION__ < 202311L
 #define __alignas_is_defined 1
 #define __alignof_is_defined 1
+#endif
+
+#endif
 
 #endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 11/17] C23: remove the static_assert macro
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (9 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 10/17] C23: remove the contents of stdalign.h Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:22 ` [musl] [C23 divers headers 12/17] C23: change the assert macro to ... arguments Jens Gustedt
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

This is now a keyword.
---
 include/assert.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/assert.h b/include/assert.h
index d14ec94e..71007a10 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -8,8 +8,8 @@
 #define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
 #endif
 
-#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
-#define static_assert _Static_assert
+#if __STDC_VERSION__ >= 201112L && __STDC_VERSION__ < 202311L && !defined(__cplusplus)
+# define static_assert _Static_assert
 #endif
 
 #ifdef __cplusplus
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 12/17] C23: change the assert macro to ... arguments
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (10 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 11/17] C23: remove the static_assert macro Jens Gustedt
@ 2023-05-31  9:22 ` Jens Gustedt
  2023-05-31  9:23 ` [musl] [C23 divers headers 13/17] C23: add the __STDC_VERSION_ASSERT_H__ macro Jens Gustedt
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:22 UTC (permalink / raw)
  To: musl

Macro arguments are ambiguate fellows. A single C expression such as
(struct toto){ 1, 2}.a appears as two macro arguments.

This mandatory change has the macro accept an unlimited number of
macro-parameters, but which then must resolve to a single C
expression. This is achieved by squeezing the argument list through a
trivial function call to a static function.  By that we ensure that
lists that represent more than one expression (such as `1, 2`) and
empty lists are diagnosed.
---
 include/assert.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/assert.h b/include/assert.h
index 71007a10..034c4aa7 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -2,10 +2,17 @@
 
 #undef assert
 
+// Ensure that this version only accepts arguments that resolve to one
+// C expression after preprocessing.
+#ifndef __ASSERT_EXPRESSION
+#define __ASSERT_EXPRESSION(...) __assert_expression(__VA_ARGS__)
+static inline _Bool __assert_expression(_Bool __x) { return __x; }
+#endif
+
 #ifdef NDEBUG
-#define	assert(x) (void)0
+#define	assert(...) (void)0
 #else
-#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0)))
+#define assert(...) ((void)(__ASSERT_EXPRESSION(__VA_ARGS__) || (__assert_fail(#__VA_ARGS__, __FILE__, __LINE__, __func__),0)))
 #endif
 
 #if __STDC_VERSION__ >= 201112L && __STDC_VERSION__ < 202311L && !defined(__cplusplus)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 13/17] C23: add the __STDC_VERSION_ASSERT_H__ macro
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (11 preceding siblings ...)
  2023-05-31  9:22 ` [musl] [C23 divers headers 12/17] C23: change the assert macro to ... arguments Jens Gustedt
@ 2023-05-31  9:23 ` Jens Gustedt
  2023-05-31  9:23 ` [musl] [C23 divers headers 14/17] C23: allow va_start to receive only one argument Jens Gustedt
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:23 UTC (permalink / raw)
  To: musl

---
 include/assert.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/assert.h b/include/assert.h
index 034c4aa7..0184400c 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -2,6 +2,8 @@
 
 #undef assert
 
+#define __STDC_VERSION_ASSERT_H__ 202300L
+
 // Ensure that this version only accepts arguments that resolve to one
 // C expression after preprocessing.
 #ifndef __ASSERT_EXPRESSION
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 14/17] C23: allow va_start to receive only one argument
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (12 preceding siblings ...)
  2023-05-31  9:23 ` [musl] [C23 divers headers 13/17] C23: add the __STDC_VERSION_ASSERT_H__ macro Jens Gustedt
@ 2023-05-31  9:23 ` Jens Gustedt
  2023-05-31  9:23 ` [musl] [C23 divers headers 15/17] C23: add the unreachable macro Jens Gustedt
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:23 UTC (permalink / raw)
  To: musl

C23 allows functions that only have ... and no other
arguments. Therefore the second argument to va_start, that was not
useful anymore, has been removed. For backwards compatibility it is
still possible to provide such an argument and the va_start macro has
to be adapted such that it is able to cope with one or two arguments.
---
 include/stdarg.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/stdarg.h b/include/stdarg.h
index 3256f805..38db6257 100644
--- a/include/stdarg.h
+++ b/include/stdarg.h
@@ -1,5 +1,5 @@
-#ifndef _STDARG_H
-#define _STDARG_H
+#ifndef __STDC_VERSION_STDARG_H__
+#define __STDC_VERSION_STDARG_H__ 202311L
 
 #ifdef __cplusplus
 extern "C" {
@@ -9,7 +9,10 @@ extern "C" {
 
 #include <bits/alltypes.h>
 
-#define va_start(v,l)   __builtin_va_start(v,l)
+#define va_start(...) __va_start1(__VA_ARGS__ , 0, )
+#define __va_start1(...) __va_start2(__VA_ARGS__)
+#define __va_start2(v, l, ...) __builtin_va_start(v, l)
+
 #define va_end(v)       __builtin_va_end(v)
 #define va_arg(v,l)     __builtin_va_arg(v,l)
 #define va_copy(d,s)    __builtin_va_copy(d,s)
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 15/17] C23: add the unreachable macro
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (13 preceding siblings ...)
  2023-05-31  9:23 ` [musl] [C23 divers headers 14/17] C23: allow va_start to receive only one argument Jens Gustedt
@ 2023-05-31  9:23 ` Jens Gustedt
  2023-05-31  9:23 ` [musl] [C23 divers headers 16/17] C23: add the nullptr_t type Jens Gustedt
  2023-05-31  9:23 ` [musl] [C23 divers headers 17/17] C23: add the __STDC_VERSION_STDDEF_H__ macro Jens Gustedt
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:23 UTC (permalink / raw)
  To: musl

This was not previously reserved and uses a common word, so protect
it.
---
 include/stddef.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/stddef.h b/include/stddef.h
index f25b8639..f77a1b49 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -24,4 +24,8 @@
 #define offsetof(type, member) ((size_t)( (char *)&(((type *)0)->member) - (char *)0 ))
 #endif
 
+#if __STDC_VERSION__ >= 202000L
+#define unreachable() __builtin_unreachable()
+#endif
+
 #endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 16/17] C23: add the nullptr_t type
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (14 preceding siblings ...)
  2023-05-31  9:23 ` [musl] [C23 divers headers 15/17] C23: add the unreachable macro Jens Gustedt
@ 2023-05-31  9:23 ` Jens Gustedt
  2023-05-31  9:23 ` [musl] [C23 divers headers 17/17] C23: add the __STDC_VERSION_STDDEF_H__ macro Jens Gustedt
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:23 UTC (permalink / raw)
  To: musl

This will only work with compilers that implement typeof and
nullptr. Currently this doesn't work for gcc but this will probably be
in gcc-13. Therefore the version test uses the future date of 202311L
which is the foreseen value for C23 final.

For transition time this feature will not yet be implement on all
compilers that people will try out. Use a heuristic that finds out if
it is enabled for c2x compilers.
---
 include/stddef.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/stddef.h b/include/stddef.h
index f77a1b49..70f299a6 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -28,4 +28,13 @@
 #define unreachable() __builtin_unreachable()
 #endif
 
+#if __STDC_VERSION__ >= 202311L
+typedef typeof(nullptr) nullptr_t;
+// Some compilers still only have partial support for C23
+#elif __STDC_VERSION__ >= 202000L && defined(__is_identifier)
+#if !__is_identifier(nullptr)
+typedef typeof(nullptr) nullptr_t;
+#endif
+#endif
+
 #endif
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 17/17] C23: add the __STDC_VERSION_STDDEF_H__ macro
  2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
                   ` (15 preceding siblings ...)
  2023-05-31  9:23 ` [musl] [C23 divers headers 16/17] C23: add the nullptr_t type Jens Gustedt
@ 2023-05-31  9:23 ` Jens Gustedt
  16 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-05-31  9:23 UTC (permalink / raw)
  To: musl

Currently we don't know of such a compiler, yet, that fully supports
all the features but this will probably be gcc-13 and
clang-17.
---
 include/stddef.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/stddef.h b/include/stddef.h
index 70f299a6..e0a00129 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -1,5 +1,5 @@
-#ifndef _STDDEF_H
-#define _STDDEF_H
+#ifndef _STDC_VERSION_STDDEF_H__
+#define _STDC_VERSION_STDDEF_H__ 201900L
 
 #if __cplusplus >= 201103L
 #define NULL nullptr
-- 
2.34.1


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [musl] [C23 divers headers 09/17] C23: update stdbool.h
  2023-05-31  9:22 ` [musl] [C23 divers headers 09/17] C23: update stdbool.h Jens Gustedt
@ 2023-05-31 12:58   ` Joakim Sindholt
  2023-05-31 13:53     ` Jₑₙₛ Gustedt
  0 siblings, 1 reply; 24+ messages in thread
From: Joakim Sindholt @ 2023-05-31 12:58 UTC (permalink / raw)
  To: musl

On Wed, 31 May 2023 11:22:56 +0200, Jens Gustedt <Jens.Gustedt@inria.fr> wrote:
> C23 has false, true and bool as keywords, so this file is basically
> not needed for modern applications. It is only provided for backwards
> compatibility. Implementations may also provide macros in addition to
> the keywords, so we do that because some user code may rely on these.
> ---
>  include/stdbool.h | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/include/stdbool.h b/include/stdbool.h
> index a9d7ab78..d9df7524 100644
> --- a/include/stdbool.h
> +++ b/include/stdbool.h
> @@ -1,11 +1,17 @@
> -#ifndef _STDBOOL_H
> -#define _STDBOOL_H
> +#ifndef __STDC_VERSION_STDBOOL_H__
> +#define __STDC_VERSION_STDBOOL_H__ 202311L
>  
>  #ifndef __cplusplus
>  
> +#if __STDC_VERSION__ >= 202311L
> +#define true true
> +#define false false
> +#define bool bool
> +#else

Why is this not simply
> +#if __STDC_VERSION__ < 202311L
>  #define true 1
>  #define false 0
>  #define bool _Bool
> +#endif

I can't find anything in C23 that says we need to re#define these keywords.

>  
>  #endif
>  
> -- 
> 2.34.1

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [musl] [C23 divers headers 09/17] C23: update stdbool.h
  2023-05-31 12:58   ` Joakim Sindholt
@ 2023-05-31 13:53     ` Jₑₙₛ Gustedt
  2023-05-31 14:13       ` Joakim Sindholt
  0 siblings, 1 reply; 24+ messages in thread
From: Jₑₙₛ Gustedt @ 2023-05-31 13:53 UTC (permalink / raw)
  To: Joakim Sindholt; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

Joakim,

on Wed, 31 May 2023 14:58:52 +0200 you (Joakim Sindholt
<opensource@zhasha.com>) wrote:

> Implementations may also provide macros in addition to
> > the keywords, so we do that because some user code may rely on
> > these.

Is this not explanation enough?

  Implementations may also provide macros in addition to the keywords,
  so we do that because some user code may rely on these.

Thanks
Jₑₙₛ

-- 
:: ICube :::::::::::::::::::::::::::::: deputy director ::
:: Université de Strasbourg :::::::::::::::::::::: ICPS ::
:: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus ::
:: :::::::::::::::::::::::::::::::::::: ☎ +33 368854536 ::
:: https://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [musl] [C23 divers headers 09/17] C23: update stdbool.h
  2023-05-31 13:53     ` Jₑₙₛ Gustedt
@ 2023-05-31 14:13       ` Joakim Sindholt
  2023-05-31 14:18         ` Rich Felker
  2023-05-31 14:19         ` Jₑₙₛ Gustedt
  0 siblings, 2 replies; 24+ messages in thread
From: Joakim Sindholt @ 2023-05-31 14:13 UTC (permalink / raw)
  To: musl

On Wed, 31 May 2023 15:53:37 +0200, Jₑₙₛ Gustedt <jens.gustedt@inria.fr> wrote:
> Joakim,
> 
> on Wed, 31 May 2023 14:58:52 +0200 you (Joakim Sindholt
> <opensource@zhasha.com>) wrote:
> 
> > Implementations may also provide macros in addition to
> > > the keywords, so we do that because some user code may rely on
> > > these.
> 
> Is this not explanation enough?
> 
>   Implementations may also provide macros in addition to the keywords,
>   so we do that because some user code may rely on these.

I guess I just don't see the point. This is allowed for literally every
symbol in libc.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [musl] [C23 divers headers 09/17] C23: update stdbool.h
  2023-05-31 14:13       ` Joakim Sindholt
@ 2023-05-31 14:18         ` Rich Felker
  2023-05-31 14:19         ` Jₑₙₛ Gustedt
  1 sibling, 0 replies; 24+ messages in thread
From: Rich Felker @ 2023-05-31 14:18 UTC (permalink / raw)
  To: Joakim Sindholt; +Cc: musl

On Wed, May 31, 2023 at 04:13:38PM +0200, Joakim Sindholt wrote:
> On Wed, 31 May 2023 15:53:37 +0200, Jₑₙₛ Gustedt <jens.gustedt@inria.fr> wrote:
> > Joakim,
> > 
> > on Wed, 31 May 2023 14:58:52 +0200 you (Joakim Sindholt
> > <opensource@zhasha.com>) wrote:
> > 
> > > Implementations may also provide macros in addition to
> > > > the keywords, so we do that because some user code may rely on
> > > > these.
> > 
> > Is this not explanation enough?
> > 
> >   Implementations may also provide macros in addition to the keywords,
> >   so we do that because some user code may rely on these.
> 
> I guess I just don't see the point. This is allowed for literally every
> symbol in libc.

I think the point is avoiding stupid things happening when programs
(or cursed library headers they're using, iirc including nncurses) do
things like:

#ifndef bool
#define bool int
#endif

If the application itself is including stdbool.h explicitly, I would
not expect it to do such a thing. But it might only be including
stdbool.h indirectly via the headers for a third party library it's
using. C11 introduced the notion that you can test for the presence of
bool with #ifdef, and it seems unfortunate to turn around and break
that.

Rich

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [musl] [C23 divers headers 09/17] C23: update stdbool.h
  2023-05-31 14:13       ` Joakim Sindholt
  2023-05-31 14:18         ` Rich Felker
@ 2023-05-31 14:19         ` Jₑₙₛ Gustedt
  1 sibling, 0 replies; 24+ messages in thread
From: Jₑₙₛ Gustedt @ 2023-05-31 14:19 UTC (permalink / raw)
  To: Joakim Sindholt; +Cc: musl

[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]

Joakim,

on Wed, 31 May 2023 16:13:38 +0200 you (Joakim Sindholt
<opensource@zhasha.com>) wrote:

> On Wed, 31 May 2023 15:53:37 +0200, Jₑₙₛ Gustedt
> <jens.gustedt@inria.fr> wrote:
> > Joakim,
> > 
> > on Wed, 31 May 2023 14:58:52 +0200 you (Joakim Sindholt
> > <opensource@zhasha.com>) wrote:
> >   
> > > Implementations may also provide macros in addition to  
>  [...]  
> > 
> > Is this not explanation enough?
> > 
> >   Implementations may also provide macros in addition to the
> > keywords, so we do that because some user code may rely on these.  
> 
> I guess I just don't see the point. This is allowed for literally
> every symbol in libc.

Yes, but these change status from identifiers to keywords, so now
without that extra permission they would not be allowed as macros when
you include any standard header.

(But I am not very attached to doing this either.)

Thanks
Jₑₙₛ

-- 
:: ICube :::::::::::::::::::::::::::::: deputy director ::
:: Université de Strasbourg :::::::::::::::::::::: ICPS ::
:: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus ::
:: :::::::::::::::::::::::::::::::::::: ☎ +33 368854536 ::
:: https://icube-icps.unistra.fr/index.php/Jens_Gustedt ::

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* [musl] [C23 divers headers 14/17] C23: allow va_start to receive only one argument
  2023-05-24 12:54 [musl] [C23 divers headers 00/17] boring header update Jens Gustedt
@ 2023-04-19 13:56 ` Jens Gustedt
  0 siblings, 0 replies; 24+ messages in thread
From: Jens Gustedt @ 2023-04-19 13:56 UTC (permalink / raw)
  To: musl

C23 allows functions that only have ... and no other
arguments. Therefore the second argument to va_start, that was not
useful anymore, has been removed. For backwards compatibility it is
still possible to provide such an argument and the va_start macro has
to be adapted such that it is able to cope with one or two arguments.

We take care of this by using the new __VA_OPT__ preprocessing
feature, for which we also construct a feature test on the fly.
---
 include/stdarg.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/stdarg.h b/include/stdarg.h
index 3256f805..38db6257 100644
--- a/include/stdarg.h
+++ b/include/stdarg.h
@@ -1,5 +1,5 @@
-#ifndef _STDARG_H
-#define _STDARG_H
+#ifndef __STDC_VERSION_STDARG_H__
+#define __STDC_VERSION_STDARG_H__ 202311L
 
 #ifdef __cplusplus
 extern "C" {
@@ -9,7 +9,10 @@ extern "C" {
 
 #include <bits/alltypes.h>
 
-#define va_start(v,l)   __builtin_va_start(v,l)
+#define va_start(...) __va_start1(__VA_ARGS__ , 0, )
+#define __va_start1(...) __va_start2(__VA_ARGS__)
+#define __va_start2(v, l, ...) __builtin_va_start(v, l)
+
 #define va_end(v)       __builtin_va_end(v)
 #define va_arg(v,l)     __builtin_va_arg(v,l)
 #define va_copy(d,s)    __builtin_va_copy(d,s)
-- 
2.34.1

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-05-31 14:19 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31  9:22 [musl] [C23 divers headers 00/17] Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 01/17] C23: add the WIDTH macros for the standard integer types Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 02/17] C23: Add the *_WIDTH macros to stdint.h Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 03/17] C23: add call_once to stdlib.h Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 04/17] C23: add timegm, gmtime_r and localtime_r to time.h in C23 mode Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 05/17] C23: memccpy, strdup and strndup are now standard C Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 06/17] C23: adapt setjmp.h Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 07/17] C23: change the noreturn functions in stdlib.h Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 08/17] C23: change the noreturn function in threads.h Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 09/17] C23: update stdbool.h Jens Gustedt
2023-05-31 12:58   ` Joakim Sindholt
2023-05-31 13:53     ` Jₑₙₛ Gustedt
2023-05-31 14:13       ` Joakim Sindholt
2023-05-31 14:18         ` Rich Felker
2023-05-31 14:19         ` Jₑₙₛ Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 10/17] C23: remove the contents of stdalign.h Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 11/17] C23: remove the static_assert macro Jens Gustedt
2023-05-31  9:22 ` [musl] [C23 divers headers 12/17] C23: change the assert macro to ... arguments Jens Gustedt
2023-05-31  9:23 ` [musl] [C23 divers headers 13/17] C23: add the __STDC_VERSION_ASSERT_H__ macro Jens Gustedt
2023-05-31  9:23 ` [musl] [C23 divers headers 14/17] C23: allow va_start to receive only one argument Jens Gustedt
2023-05-31  9:23 ` [musl] [C23 divers headers 15/17] C23: add the unreachable macro Jens Gustedt
2023-05-31  9:23 ` [musl] [C23 divers headers 16/17] C23: add the nullptr_t type Jens Gustedt
2023-05-31  9:23 ` [musl] [C23 divers headers 17/17] C23: add the __STDC_VERSION_STDDEF_H__ macro Jens Gustedt
  -- strict thread matches above, loose matches on Subject: below --
2023-05-24 12:54 [musl] [C23 divers headers 00/17] boring header update Jens Gustedt
2023-04-19 13:56 ` [musl] [C23 divers headers 14/17] C23: allow va_start to receive only one argument Jens Gustedt

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