mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +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@
|
@glib_os@
|
||||||
|
|
||||||
|
#define G_VA_COPY va_copy
|
||||||
@glib_vacopy@
|
@glib_vacopy@
|
||||||
|
|
||||||
#define G_HAVE_ISO_VARARGS 1
|
#define G_HAVE_ISO_VARARGS 1
|
||||||
|
@ -36,19 +36,6 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
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
|
GLIB_AVAILABLE_IN_ALL
|
||||||
const gchar * g_get_user_name (void);
|
const gchar * g_get_user_name (void);
|
||||||
GLIB_AVAILABLE_IN_ALL
|
GLIB_AVAILABLE_IN_ALL
|
||||||
|
35
meson.build
35
meson.build
@ -1646,38 +1646,11 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# === va_copy checks ===
|
# === 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 = ''
|
glib_vacopy = ''
|
||||||
foreach try_func : [ '__va_copy', 'va_copy' ]
|
|
||||||
if cc.compiles('''#include <stdarg.h>
|
# We check for G_VA_COPY_AS_ARRAY for historical reasons, but we no longer
|
||||||
#include <stdlib.h>
|
# use it: use Standard C va_copy() instead.
|
||||||
#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
|
|
||||||
|
|
||||||
va_list_val_copy_prog = '''
|
va_list_val_copy_prog = '''
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user