ruby-changes:50348
From: nobu <ko1@a...>
Date: Sun, 18 Feb 2018 14:10:58 +0900 (JST)
Subject: [ruby-changes:50348] nobu:r62463 (trunk): mjit.c: no va_copy
nobu 2018-02-18 14:10:52 +0900 (Sun, 18 Feb 2018) New Revision: 62463 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62463 Log: mjit.c: no va_copy * mjit.c (form_args): do not use va_copy, which cannot detect appropriate way to simulate when cross compiling. Removed files: trunk/tool/m4/ruby_check_va_copy.m4 Modified files: trunk/configure.ac trunk/internal.h trunk/mjit.c Index: tool/m4/ruby_check_va_copy.m4 =================================================================== --- tool/m4/ruby_check_va_copy.m4 (revision 62462) +++ tool/m4/ruby_check_va_copy.m4 (nonexistent) @@ -1,30 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/tool/m4/ruby_check_va_copy.m4#L0 -# -*- Autoconf -*- -AC_DEFUN([RUBY_CHECK_VA_COPY], [ - AS_IF([test "x$rb_cv_va_copy" = x], [dnl - AC_TRY_LINK( -[@%:@include <stdlib.h> -@%:@include <stdarg.h> -@%:@include <string.h> -@%:@define CONFTEST_VA_COPY(dst, src) $2 -void -conftest(int n, ...) -{ - va_list ap, ap2; - int i; - va_start(ap, n); - CONFTEST_VA_COPY(ap2, ap); - for (i = 0; i < n; i++) if ((int)va_arg(ap, int) != n - i - 1) abort(); - va_end(ap); - CONFTEST_VA_COPY(ap, ap2); - for (i = 0; i < n; i++) if ((int)va_arg(ap, int) != n - i - 1) abort(); - va_end(ap); - va_end(ap2); -}], -[ - conftest(10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); -], - [rb_cv_va_copy="$1"], - [rb_cv_va_copy=""])dnl - ])dnl -])dnl -dnl Index: mjit.c =================================================================== --- mjit.c (revision 62462) +++ mjit.c (revision 62463) @@ -286,27 +286,21 @@ args_len(char *const *args) https://github.com/ruby/ruby/blob/trunk/mjit.c#L286 static char ** form_args(int num, ...) { - va_list argp, argp2; - size_t len, disp; + va_list argp; + size_t len, n; int i; char **args, **res; va_start(argp, num); - va_copy(argp2, argp); + res = NULL; for (i = len = 0; i < num; i++) { args = va_arg(argp, char **); - len += args_len(args); + n = args_len(args); + REALLOC_N(res, char *, len + n + 1); + MEMCPY(res + len, args, char *, n + 1); + len += n; } va_end(argp); - res = xmalloc((len + 1) * sizeof(char *)); - for (i = disp = 0; i < num; i++) { - args = va_arg(argp2, char **); - len = args_len(args); - memmove(res + disp, args, len * sizeof(char *)); - disp += len; - } - res[disp] = NULL; - va_end(argp2); return res; } Index: configure.ac =================================================================== --- configure.ac (revision 62462) +++ configure.ac (revision 62463) @@ -1256,24 +1256,6 @@ AS_IF([test "$rb_cv_va_args_macro" = yes https://github.com/ruby/ruby/blob/trunk/configure.ac#L1256 AC_DEFINE(HAVE_VA_ARGS_MACRO) ]) -AC_CACHE_CHECK([appropriate way to simulate va_copy], rb_cv_va_copy, [dnl - RUBY_CHECK_VA_COPY([va_copy], [va_copy((dst),(src))]) - RUBY_CHECK_VA_COPY([VA_COPY macro], [VA_COPY((dst),(src))]) - RUBY_CHECK_VA_COPY([__va_copy], [__va_copy((dst),(src))]) - RUBY_CHECK_VA_COPY([__builtin_va_copy], [__builtin_va_copy((dst),(src))]) - RUBY_CHECK_VA_COPY([va_copy via struct assignment], - [do (dst) = (src); while (0)]) - RUBY_CHECK_VA_COPY([va_copy via pointer assignment], - [do *(dst) = *(src); while (0)]) - RUBY_CHECK_VA_COPY([va_copy via memcpy], - [memcpy(&(dst), &(src), sizeof(va_list))]) -]) -AS_IF([test "x$rb_cv_va_copy" = x], [ - AC_ERROR([no way to simulate va_copy]) -], [ - AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$rb_cv_va_copy)) -]) - AC_CACHE_CHECK([for alignas() syntax], rb_cv_have_alignas, [ rb_cv_have_alignas=no RUBY_WERROR_FLAG([ Index: internal.h =================================================================== --- internal.h (revision 62462) +++ internal.h (revision 62463) @@ -85,25 +85,6 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L85 # define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)] #endif -#if defined(HAVE_VA_COPY) -/* OK, nothing to do */ -#elif defined(HAVE_VA_COPY_MACRO) -#define va_copy(dst, src) VA_COPY((dst), (src)) -#elif defined(HAVE___VA_COPY) -#define va_copy(dst, src) __va_copy((dst), (src)) -#elif defined(HAVE___BUILTIN_VA_COPY) -#define va_copy(dst, src) __builtin_va_copy((dst), (src)) -#elif defined(HAVE_VA_COPY_VIA_STRUCT_ASSIGNMENT) -#define va_copy(dst, src) do (dst) = (src); while (0) -#elif defined(HAVE_VA_COPY_VIA_POINTER_ASSIGNMENT) -#define va_copy(dst, src) do *(dst) = *(src); while (0) -#elif defined(HAVE_VA_COPY_VIA_MEMCPY) -#include <string.h> -#define va_copy(dst, src) memcpy(&(dst), &(src), sizeof(va_list)) -#else -#error >>>> no way to simuate va_copy <<<< -#endif - #define SIGNED_INTEGER_TYPE_P(int_type) (0 > ((int_type)0)-1) #define SIGNED_INTEGER_MAX(sint_type) \ (sint_type) \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/