Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ignore binaries in examples of tracing
[simgrid.git] / buildtools / Cmake / prog_test / prog_va_copy.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <stdlib.h>
8 #include <stdarg.h>
9 #include <string.h>
10 #define DO_VA_COPY(d,s) memcpy((void *)(d), (void *)(s)), sizeof(*(s))
11 void test(char *str, ...)
12 {
13    va_list ap, ap2;
14    int i;
15    va_start(ap, str);
16    DO_VA_COPY(ap2, ap);
17    for (i = 1; i <= 9; i++) {
18       int k = (int)va_arg(ap, int);
19       if (k != i)
20         abort();
21    }
22    DO_VA_COPY(ap, ap2);
23    for (i = 1; i <= 9; i++) {
24       int k = (int)va_arg(ap, int);
25       if (k != i)
26         abort();
27    }
28    va_end(ap);
29 }
30 int main(int argc, char *argv[])
31 {
32    test(test, 1, 2, 3, 4, 5, 6, 7, 8, 9);
33    exit(0);
34 }