summaryrefslogtreecommitdiff
path: root/tool/m4/ruby_check_va_copy.m4
blob: 99d11b5fb93aef5f7367bb5e006d28c04d7c51b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- 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