]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Remove emulation of va_copy() in non-C99 compilers
authorSimon McVittie <smcv@collabora.com>
Tue, 19 Jul 2022 19:37:19 +0000 (20:37 +0100)
committerSimon McVittie <smcv@collabora.com>
Tue, 19 Jul 2022 19:50:33 +0000 (20:50 +0100)
dbus now requires a (mostly-)C99 compiler, which guarantees the presence
of Standard C va_copy().

Signed-off-by: Simon McVittie <smcv@collabora.com>
cmake/ConfigureChecks.cmake
cmake/config.h.cmake
configure.ac
dbus/dbus-message.c
dbus/dbus-string.c
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps-win.c
meson.build

index 17b2e201dbf818eebe3b1d896a906ac9be811998..f4680f9b20c06051701d213e61b1c1cb47e8e357 100644 (file)
@@ -80,51 +80,6 @@ int main() {
 epoll_create1 (EPOLL_CLOEXEC);
 }" DBUS_HAVE_LINUX_EPOLL)
 
-CHECK_C_SOURCE_COMPILES("
-#include <stdarg.h>
-#include <stdlib.h>
-static void f (int i, ...) {
-    va_list args1, args2;
-    va_start (args1, i);
-    va_copy (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;
-}
-"  HAVE_VA_COPY)
-
-CHECK_C_SOURCE_COMPILES("
-#include <stdarg.h>
-#include <stdlib.h>
-static void f (int i, ...) {
-    va_list args1, args2;
-    va_start (args1, i);
-    __va_copy (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;
-}
-"  HAVE___VA_COPY)
-
-if(HAVE_VA_COPY)
-    set(DBUS_VA_COPY va_copy CACHE STRING "va_copy function")
-elseif(HAVE___VA_COPY)
-    set(DBUS_VA_COPY __va_copy CACHE STRING "va_copy function")
-elseif(MSVC)
-    # this is used for msvc < 2013
-    set(DBUS_VA_COPY _DBUS_VA_COPY_ASSIGN)
-else()
-    message(FATAL_ERROR "dbus requires an ISO C99-compatible va_copy() macro, or a similar __va_copy(), or MSVC >= 2010")
-endif()
-
 CHECK_C_SOURCE_COMPILES("
 int main() {
     int a = 4;
index 96a74f084b8fe38d76d82b5c3c73c1b1c0330b86..2efc93f2996ca8fd70b63bea686ceaff2fc97ba6 100644 (file)
 # define DBUS_ENABLE_X11_AUTOLAUNCH 1
 #endif
 
-/* A 'va_copy' style function */
-#cmakedefine DBUS_VA_COPY @DBUS_VA_COPY@
-
-/* for msvc */
-#define _DBUS_VA_COPY_ASSIGN(a1,a2) { a1 = a2; }
-
 #cmakedefine DBUS_WITH_GLIB 1
 #cmakedefine GLIB_VERSION_MIN_REQUIRED @GLIB_VERSION_MIN_REQUIRED@
 #cmakedefine GLIB_VERSION_MAX_ALLOWED  @GLIB_VERSION_MAX_ALLOWED@
index c4653c6938bebcf7c88a157bc2ee8c32066aaa9a..e4b75e4276e5e2bfd1aff5205f49cdcaf2ac861b 100644 (file)
@@ -567,59 +567,6 @@ esac
 # the AC_INCLUDES_DEFAULT.
 AC_CHECK_DECLS([environ])
 
-dnl **********************************
-dnl *** va_copy checks (from GLib) ***
-dnl **********************************
-dnl we currently check for all three va_copy possibilities, so we get
-dnl all results in config.log for bug reports.
-AC_CACHE_CHECK([for an implementation of va_copy()],dbus_cv_va_copy,[
-       AC_LINK_IFELSE([AC_LANG_SOURCE([#include <stdarg.h>
-#include <stdlib.h>
-       static void f (int i, ...) {
-       va_list args1, args2;
-       va_start (args1, i);
-       va_copy (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;
-       }])],
-       [dbus_cv_va_copy=yes],
-       [dbus_cv_va_copy=no])
-])
-AC_CACHE_CHECK([for an implementation of __va_copy()],dbus_cv___va_copy,[
-       AC_LINK_IFELSE([AC_LANG_SOURCE([#include <stdarg.h>
-#include <stdlib.h>
-       static void f (int i, ...) {
-       va_list args1, args2;
-       va_start (args1, i);
-       __va_copy (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;
-       }])],
-       [dbus_cv___va_copy=yes],
-       [dbus_cv___va_copy=no])
-])
-
-if test "x$dbus_cv_va_copy" = "xyes"; then
-  dbus_va_copy_func=va_copy
-else if test "x$dbus_cv___va_copy" = "xyes"; then
-  dbus_va_copy_func=__va_copy
-fi
-fi
-
-AS_IF([test -n "$dbus_va_copy_func"],
-  [AC_DEFINE_UNQUOTED([DBUS_VA_COPY], [$dbus_va_copy_func], [A 'va_copy' style function])],
-  [AC_MSG_ERROR([dbus requires an ISO C99-compatible va_copy() macro, or a compatible __va_copy(), or MSVC >= 2010 and CMake])])
-
 #### Atomic integers
 
 AC_CACHE_CHECK([whether $CC knows __sync_sub_and_fetch()],
index 4c36aa39249a713bdcbc8d6c47e159443b019ea6..19a4375093293446b5598a57867041b5d6d01011 100644 (file)
@@ -843,7 +843,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter,
   /* copy var_args first, then we can do another iteration over it to
    * free memory and close unix fds if parse failed at some point.
    */
-  DBUS_VA_COPY (copy_args, var_args);
+  va_copy (copy_args, var_args);
 
   while (spec_type != DBUS_TYPE_INVALID)
     {
index 05c832311185d788ad12ce51d8e7d32e3b7d3a3e..1fecd6dd63f25e31e24078d87034d0e56104e4c8 100644 (file)
@@ -41,8 +41,6 @@
 #include "dbus-marshal-basic.h" /* probably should be removed by moving the usage of DBUS_TYPE
                                  * into the marshaling-related files
                                  */
-/* for DBUS_VA_COPY */
-#include "dbus-sysdeps.h"
 
 /**
  * @defgroup DBusString DBusString class
@@ -1112,7 +1110,7 @@ _dbus_string_append_printf_valist  (DBusString        *str,
 
   DBUS_STRING_PREAMBLE (str);
 
-  DBUS_VA_COPY (args_copy, args);
+  va_copy (args_copy, args);
 
   /* Measure the message length without terminating nul */
   len = _dbus_printf_string_upper_bound (format, args);
index 18bd128282e1b2119719e2540a71bdf5117880a4..252798e3649bab72776a0abac981cad36de8ddfe 100644 (file)
@@ -3825,7 +3825,7 @@ _dbus_printf_string_upper_bound (const char *format,
   int len;
   va_list args_copy;
 
-  DBUS_VA_COPY (args_copy, args);
+  va_copy (args_copy, args);
   len = vsnprintf (static_buf, bufsize, format, args_copy);
   va_end (args_copy);
 
@@ -3843,7 +3843,7 @@ _dbus_printf_string_upper_bound (const char *format,
        * or the real length could be coincidentally the same. Which is it?
        * If vsnprintf returns the truncated length, we'll go to the slow
        * path. */
-      DBUS_VA_COPY (args_copy, args);
+      va_copy (args_copy, args);
 
       if (vsnprintf (static_buf, 1, format, args_copy) == 1)
         len = -1;
@@ -3864,7 +3864,7 @@ _dbus_printf_string_upper_bound (const char *format,
       if (buf == NULL)
         return -1;
 
-      DBUS_VA_COPY (args_copy, args);
+      va_copy (args_copy, args);
       len = vsnprintf (buf, bufsize, format, args_copy);
       va_end (args_copy);
 
@@ -5097,7 +5097,7 @@ _dbus_logv (DBusSystemLogSeverity  severity,
             _dbus_assert_not_reached ("invalid log severity");
         }
 
-      DBUS_VA_COPY (tmp, args);
+      va_copy (tmp, args);
       vsyslog (flags, msg, tmp);
       va_end (tmp);
     }
@@ -5107,7 +5107,7 @@ _dbus_logv (DBusSystemLogSeverity  severity,
   if (log_flags & DBUS_LOG_FLAGS_STDERR)
 #endif
     {
-      DBUS_VA_COPY (tmp, args);
+      va_copy (tmp, args);
       fprintf (stderr, "%s[" DBUS_PID_FORMAT "]: ", syslog_tag, _dbus_getpid ());
       vfprintf (stderr, msg, tmp);
       fputc ('\n', stderr);
index e71f35d28167463afe73b7030c005315f9d5be5f..df4a4ce3fd8018b3c26686ee4a5f58a7b0633bbf 100644 (file)
@@ -744,7 +744,7 @@ int _dbus_printf_string_upper_bound (const char *format,
   va_list args_copy;
 
   bufsize = sizeof (buf);
-  DBUS_VA_COPY (args_copy, args);
+  va_copy (args_copy, args);
   len = _vsnprintf (buf, bufsize - 1, format, args_copy);
   va_end (args_copy);
 
@@ -759,7 +759,7 @@ int _dbus_printf_string_upper_bound (const char *format,
       if (p == NULL)
         return -1;
 
-      DBUS_VA_COPY (args_copy, args);
+      va_copy (args_copy, args);
       len = _vsnprintf (p, bufsize - 1, format, args_copy);
       va_end (args_copy);
       free (p);
@@ -4249,7 +4249,7 @@ _dbus_logv (DBusSystemLogSeverity  severity,
     {
       DBusString out = _DBUS_STRING_INIT_INVALID;
       const char *message = NULL;
-      DBUS_VA_COPY (tmp, args);
+      va_copy (tmp, args);
 
       if (!_dbus_string_init (&out))
         goto out;
@@ -4276,7 +4276,7 @@ out:
 
   if (log_flags & DBUS_LOG_FLAGS_STDERR)
     {
-      DBUS_VA_COPY (tmp, args);
+      va_copy (tmp, args);
       fprintf (stderr, "%s[%lu]: %s: ", log_tag, _dbus_pid_for_log (), s);
       vfprintf (stderr, msg, tmp);
       fprintf (stderr, "\n");
index 8c45522fb37a71e18c7712166560ede56a019e49..c6089c4b8de19e06ad59d661a227d37437c6c135 100644 (file)
@@ -642,56 +642,6 @@ have_backtrace = (cc.has_header('execinfo.h', args: compile_args_c)
 )
 config.set('HAVE_BACKTRACE', have_backtrace)
 
-
-# **********************************
-# *** va_copy checks (from GLib) ***
-# **********************************
-# we currently check for all three va_copy possibilities, so we get
-# all results in config.log for bug reports.
-
-# Can't use cc.has_function here because va_copy is not
-# exactly a function
-va_copy_check = '''
-#include <stdarg.h>
-#include <stdlib.h>
-
-static 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;
-}
-'''
-
-has_va_copy = cc.links(va_copy_check.format('va_copy'), args: compile_args_c)
-has___va_copy = cc.links(va_copy_check.format('__va_copy'), args: compile_args_c)
-
-if has_va_copy
-    va_copy = 'va_copy'
-elif has___va_copy
-    va_copy = '__va_copy'
-elif cc.get_id() == 'msvc'
-    va_copy = '_DBUS_VA_COPY_ASSIGN'
-    config.set('_DBUS_VA_COPY_ASSIGN(a1,a2)', '{ a1 = a2; }')
-else
-    error('dbus requires an ISO C99-compatible va_copy() macro, '
-        + 'or a compatible __va_copy()')
-endif
-config.set('DBUS_VA_COPY', va_copy)
-
-
 # Can't use cc.has_function here because atomic operations are not
 # exactly functions
 config.set10(