lib: Fix va_start macro to work for 64-bit arches.

* include/stdarg.h (va_start): Fix to point to correct location.
This commit is contained in:
Andrius Štikonas 2023-10-25 01:28:22 +01:00 committed by Janneke Nieuwenhuizen
parent 9387d36f75
commit 542f015135

View file

@ -2,6 +2,7 @@
* GNU Mes --- Maxwell Equations of Software * GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org> * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com> * Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
* *
* This file is part of GNU Mes. * This file is part of GNU Mes.
* *
@ -72,7 +73,7 @@ typedef __builtin_va_list va_list;
#endif #endif
typedef char *va_list; typedef char *va_list;
#define va_start(ap, last) (void)((ap) = (char*)(&(last) + 1)) #define va_start(ap, last) (void)((ap) = (char*)(&(last)) + sizeof (void*))
#define va_arg(ap, type) (type)(((long*)((ap) = ((ap) + sizeof (void*))))[-1]) #define va_arg(ap, type) (type)(((long*)((ap) = ((ap) + sizeof (void*))))[-1])
#define va_align(ap, alignment) ((char*)((((unsigned long) (ap)) + (alignment) - 1) &~ ((alignment) - 1))) #define va_align(ap, alignment) ((char*)((((unsigned long) (ap)) + (alignment) - 1) &~ ((alignment) - 1)))
#define va_arg8(ap, type) (type)(((double*)((ap) = (va_align((ap), 8) + sizeof(double))))[-1]) #define va_arg8(ap, type) (type)(((double*)((ap) = (va_align((ap), 8) + sizeof(double))))[-1])