mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 22:46:15 +01:00
glib: Always implement G_VA_COPY as va_copy()
C99 guarantees that va_copy() exists, so use it, instead of probing for __va_copy(), va_copy(), or a reimplementation from first principles. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
fe7eb71c43
commit
b8f37a543c
@ -118,6 +118,7 @@ typedef unsigned @glib_intptr_type_define@ guintptr;
|
||||
|
||||
@glib_os@
|
||||
|
||||
#define G_VA_COPY va_copy
|
||||
@glib_vacopy@
|
||||
|
||||
#define G_HAVE_ISO_VARARGS 1
|
||||
|
@ -36,19 +36,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* Define G_VA_COPY() to do the right thing for copying va_list variables.
|
||||
* glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy.
|
||||
*/
|
||||
#if !defined (G_VA_COPY)
|
||||
# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
|
||||
# define G_VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
|
||||
# elif defined (G_VA_COPY_AS_ARRAY)
|
||||
# define G_VA_COPY(ap1, ap2) memmove ((ap1), (ap2), sizeof (va_list))
|
||||
# else /* va_list is a pointer */
|
||||
# define G_VA_COPY(ap1, ap2) ((ap1) = (ap2))
|
||||
# endif /* va_list is a pointer */
|
||||
#endif /* !G_VA_COPY */
|
||||
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
const gchar * g_get_user_name (void);
|
||||
GLIB_AVAILABLE_IN_ALL
|
||||
|
35
meson.build
35
meson.build
@ -1646,38 +1646,11 @@ else
|
||||
endif
|
||||
|
||||
# === va_copy checks ===
|
||||
# we currently check for all three va_copy possibilities, so we get
|
||||
# all results in config.log for bug reports.
|
||||
|
||||
va_copy_func = ''
|
||||
foreach try_func : [ '__va_copy', 'va_copy' ]
|
||||
if cc.compiles('''#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _MSC_VER
|
||||
# include "msvc_recommended_pragmas.h"
|
||||
#endif
|
||||
void f (int i, ...) {
|
||||
va_list args1, args2;
|
||||
va_start (args1, i);
|
||||
@0@ (args2, args1);
|
||||
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
|
||||
exit (1);
|
||||
va_end (args1); va_end (args2);
|
||||
}
|
||||
int main() {
|
||||
f (0, 42);
|
||||
return 0;
|
||||
}'''.format(try_func),
|
||||
name : try_func + ' check')
|
||||
va_copy_func = try_func
|
||||
endif
|
||||
endforeach
|
||||
if va_copy_func != ''
|
||||
glib_conf.set('G_VA_COPY', va_copy_func)
|
||||
glib_vacopy = '#define G_VA_COPY ' + va_copy_func
|
||||
else
|
||||
glib_vacopy = '/* #undef G_VA_COPY */'
|
||||
endif
|
||||
glib_vacopy = ''
|
||||
|
||||
# We check for G_VA_COPY_AS_ARRAY for historical reasons, but we no longer
|
||||
# use it: use Standard C va_copy() instead.
|
||||
|
||||
va_list_val_copy_prog = '''
|
||||
#include <stdarg.h>
|
||||
|
Loading…
Reference in New Issue
Block a user