diff --git a/config.d/library_functions.m4 b/config.d/library_functions.m4 index e53ca3efb..66ff31edc 100644 --- a/config.d/library_functions.m4 +++ b/config.d/library_functions.m4 @@ -7,8 +7,6 @@ AC_FUNC_MEMCMP AC_FUNC_MMAP AC_TYPE_SIGNAL AC_FUNC_VPRINTF -AC_FUNC_VA_COPY -AC_FUNC__VA_COPY AC_CHECK_FUNCS( access _access connect dlopen execvp fcntl ftime _ftime getaddrinfo \ gethostbyname gethostname getnameinfo getpagesize gettimeofday getuid \ @@ -17,6 +15,17 @@ AC_CHECK_FUNCS( _vsnprintf wait ) +AC_FUNC_VA_COPY +AC_FUNC__VA_COPY +AH_VERBATIM([DEFINE_VA_COPY], +[#ifndef HAVE_VA_COPY +# ifdef HAVE__VA_COPY +# define va_copy(d,s) __va_copy ((d), (s)) +# else +# define va_copy(d,s) memcpy (&(d), &(s), sizeof (va_list)) +# endif +#endif]) + DL_LIBS="" if test "x$ac_cv_func_dlopen" != "xyes"; then AC_CHECK_LIB(dl, dlopen, diff --git a/config.d/typedefs_structs_compiler.m4 b/config.d/typedefs_structs_compiler.m4 index a68df83b8..3ba73b7d6 100644 --- a/config.d/typedefs_structs_compiler.m4 +++ b/config.d/typedefs_structs_compiler.m4 @@ -88,8 +88,6 @@ AH_VERBATIM([HAVE___BUILTIN_EXPECT], # define __builtin_expect(x,c) x #endif]) -AC_TYPE_VA_LIST - AC_MSG_CHECKING(for type of fpos_t) AC_TRY_COMPILE( [#include ], diff --git a/libs/util/dstring.c b/libs/util/dstring.c index 7f8fd190e..4e43a0aae 100644 --- a/libs/util/dstring.c +++ b/libs/util/dstring.c @@ -299,23 +299,13 @@ dstring_clearstr (dstring_t *dstr) dstr->str[0] = 0; } -#if defined (HAVE_VA_COPY) -# define VA_COPY(a,b) va_copy (a, b) -#elif defined (HAVE__VA_COPY) -# define VA_COPY(a,b) __va_copy (a, b) -#else -# define VA_COPY(a,b) memcpy (a, b, sizeof (a)) -#endif - static int _dvsprintf (dstring_t *dstr, int offs, const char *fmt, va_list args) { int size; -#ifdef VA_LIST_IS_ARRAY va_list tmp_args; - VA_COPY (tmp_args, args); -#endif + va_copy (tmp_args, args); if (!dstr->truesize) dstring_clearstr (dstr); // Make it a string @@ -324,17 +314,13 @@ _dvsprintf (dstring_t *dstr, int offs, const char *fmt, va_list args) args)) == -1) { dstr->size = (dstr->truesize & ~1023) + 1024; dstring_adjust (dstr); -#ifdef VA_LIST_IS_ARRAY - VA_COPY (args, tmp_args); -#endif + va_copy (args, tmp_args); } dstr->size = size + offs + 2; // "Proper" implementations return the required size if (dstr->size > dstr->truesize) { dstring_adjust (dstr); -#ifdef VA_LIST_IS_ARRAY - VA_COPY (args, tmp_args); -#endif + va_copy (args, tmp_args); vsnprintf (dstr->str + offs, dstr->truesize - offs - 1, fmt, args); } dstr->size = size + offs + 1; diff --git a/libs/util/sys.c b/libs/util/sys.c index d6e9af789..4e2e111e2 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -493,21 +493,11 @@ Sys_Quit (void) exit (0); } -#if defined (HAVE_VA_COPY) -# define VA_COPY(a,b) va_copy (a, b) -#elif defined (HAVE__VA_COPY) -# define VA_COPY(a,b) __va_copy (a, b) -#else -# define VA_COPY(a,b) memcpy (a, b, sizeof (a)) -#endif - VISIBLE void Sys_Error (const char *error, ...) { va_list args; -#ifdef VA_LIST_IS_ARRAY va_list tmp_args; -#endif static int in_sys_error = 0; if (in_sys_error) { @@ -521,9 +511,7 @@ Sys_Error (const char *error, ...) in_sys_error = 1; va_start (args, error); -#ifdef VA_LIST_IS_ARRAY - VA_COPY (tmp_args, args); -#endif + va_copy (tmp_args, args); sys_err_printf_function (error, args); va_end (args); @@ -532,9 +520,7 @@ Sys_Error (const char *error, ...) if (sys_err_printf_function != Sys_ErrPrintf) { // print the message again using the default error printer to increase // the chances of the error being seen. -#ifdef VA_LIST_IS_ARRAY - VA_COPY (args, tmp_args); -#endif + va_copy (args, tmp_args); Sys_ErrPrintf (error, args); } diff --git a/tools/qflmp/lmp.c b/tools/qflmp/lmp.c index f0f41c256..b8021166c 100644 --- a/tools/qflmp/lmp.c +++ b/tools/qflmp/lmp.c @@ -31,6 +31,9 @@ width * height bytes no attached palette */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #ifndef _GNU_SOURCE # define _GNU_SOURCE