This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update the va_copy() metaconfig unit.
[metaconfig.git] / U / perl / need_va_copy.U
1 ?RCS: $Id$
2 ?RCS:
3 ?RCS: Copyright (c) 2000, Jarkko Hietaniemi
4 ?RCS: 
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
10 ?RCS:
11 ?MAKE:need_va_copy: +ccflags rm cat Compile i_stdarg i_stdlib
12 ?MAKE:  -pick add $@ %<
13 ?S:need_va_copy:
14 ?S:     This symbol, if defined, indicates that the system stores
15 ?S:     the variable argument list datatype, va_list, in a format
16 ?S:     that cannot be copied by simple assignment, so that some
17 ?S:     other means must be used when copying is required.
18 ?S:     As such systems vary in their provision (or non-provision)
19 ?S:     of copying mechanisms, handy.h defines a platform-
20 ?S:     independent macro, Perl_va_copy(src, dst), to do the job.
21 ?S:.
22 ?C:NEED_VA_COPY:
23 ?C:     This symbol, if defined, indicates that the system stores
24 ?C:     the variable argument list datatype, va_list, in a format
25 ?C:     that cannot be copied by simple assignment, so that some
26 ?C:     other means must be used when copying is required.
27 ?C:     As such systems vary in their provision (or non-provision)
28 ?C:     of copying mechanisms, handy.h defines a platform-
29 ?C:     independent macro, Perl_va_copy(src, dst), to do the job.
30 ?C:.
31 ?H:#$need_va_copy       NEED_VA_COPY            /**/
32 ?H:.
33 ?T:okay
34 ?F:!try
35 ?LINT:set need_va_copy
36 : see if we need va_copy
37 echo " "
38 case "$i_stdarg" in
39 "$define")
40         $cat >try.c <<EOCP
41 #include <stdarg.h>
42 #include <stdio.h>
43 #$i_stdlib I_STDLIB
44 #ifdef I_STDLIB
45 #include <stdlib.h>
46 #endif
47 #include <signal.h>
48
49 int
50 ivfprintf(FILE *f, const char *fmt, va_list *valp)
51 {
52   return vfprintf(f, fmt, *valp);
53 }
54  
55 int    
56 myvfprintf(FILE *f, const  char *fmt, va_list val)
57 {
58   return ivfprintf(f, fmt, &val);
59 }
60       
61 int
62 myprintf(char *fmt, ...) 
63 {
64   va_list val;
65   va_start(val, fmt);
66   return myvfprintf(stdout, fmt, val); 
67 }         
68
69 int
70 main(int ac, char **av)
71 {
72   signal(SIGSEGV, exit);
73
74   myprintf("%s%cs all right, then\n", "that", '\'');                            
75   exit(0);      
76 }
77 EOCP
78         set try
79         if eval $compile && ./try 2>&1 >/dev/null; then
80                 case "`./try`" in
81                 "that's all right, then")
82                         okay=yes
83                         ;;
84                 esac
85         fi
86         case "$okay" in
87         yes)    echo "It seems that you don't need va_copy()." >&4
88                 need_va_copy="$undef"
89                 ;;
90         *)      echo "It seems that va_copy() or similar will be needed." >&4
91                 need_va_copy="$define"
92                 ;;
93         esac
94         $rm -f try.* core core.* *.core *.core.*
95         ;;
96 *)      echo "You don't have <stdarg.h>, not checking for va_copy()." >&4
97         ;;
98 esac
99