mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
mjit.c: no va_copy
* mjit.c (form_args): do not use va_copy, which cannot detect appropriate way to simulate when cross compiling. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ecd2c08a4c
commit
0f0c32f24e
4 changed files with 7 additions and 80 deletions
18
configure.ac
18
configure.ac
|
@ -1256,24 +1256,6 @@ AS_IF([test "$rb_cv_va_args_macro" = yes], [
|
||||||
AC_DEFINE(HAVE_VA_ARGS_MACRO)
|
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, [
|
AC_CACHE_CHECK([for alignas() syntax], rb_cv_have_alignas, [
|
||||||
rb_cv_have_alignas=no
|
rb_cv_have_alignas=no
|
||||||
RUBY_WERROR_FLAG([
|
RUBY_WERROR_FLAG([
|
||||||
|
|
19
internal.h
19
internal.h
|
@ -85,25 +85,6 @@ extern "C" {
|
||||||
# define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
|
# define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
|
||||||
#endif
|
#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_TYPE_P(int_type) (0 > ((int_type)0)-1)
|
||||||
#define SIGNED_INTEGER_MAX(sint_type) \
|
#define SIGNED_INTEGER_MAX(sint_type) \
|
||||||
(sint_type) \
|
(sint_type) \
|
||||||
|
|
20
mjit.c
20
mjit.c
|
@ -286,27 +286,21 @@ args_len(char *const *args)
|
||||||
static char **
|
static char **
|
||||||
form_args(int num, ...)
|
form_args(int num, ...)
|
||||||
{
|
{
|
||||||
va_list argp, argp2;
|
va_list argp;
|
||||||
size_t len, disp;
|
size_t len, n;
|
||||||
int i;
|
int i;
|
||||||
char **args, **res;
|
char **args, **res;
|
||||||
|
|
||||||
va_start(argp, num);
|
va_start(argp, num);
|
||||||
va_copy(argp2, argp);
|
res = NULL;
|
||||||
for (i = len = 0; i < num; i++) {
|
for (i = len = 0; i < num; i++) {
|
||||||
args = va_arg(argp, char **);
|
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);
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
# -*- 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
|
|
Loading…
Add table
Add a link
Reference in a new issue