Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201523a466d22fe81ce15f884e3d404be9a32f8c.1684932861.git.Jens.Gustedt@inria.fr>
Date: Wed, 19 Apr 2023 15:56:43 +0200
From: Jens Gustedt <Jens.Gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: [C23 divers headers 14/17] C23: allow va_start to receive only one
 argument

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

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.