2 * This file has been modified for the cdrkit suite.
4 * The behaviour and appearence of the program code below can differ to a major
5 * extent from the version distributed by the original author(s).
7 * For details, see Changelog file distributed with the cdrkit package. If you
8 * received this file from another source then ask the distributing person for
9 * a log of modifications.
13 /* @(#)vadefs.h 1.5 01/07/15 Copyright 1998 J. Schilling */
15 * Generic header for users of var args ...
17 * Includes a default definition for va_copy()
18 * and some magic know how about the SVr4 Power PC var args ABI
19 * to create a __va_arg_list() macro.
21 * Copyright (c) 1998 J. Schilling
24 * This program is free software; you can redistribute it and/or modify
25 * it under the terms of the GNU General Public License version 2
26 * as published by the Free Software Foundation.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
33 * You should have received a copy of the GNU General Public License along with
34 * this program; see the file COPYING. If not, write to the Free Software
35 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
47 * For ANSI C-compilers prefer stdarg.h
50 # ifndef _INCL_STDARG_H
52 # define _INCL_STDARG_H
55 # ifndef _INCL_VARARGS_H
57 # define _INCL_VARARGS_H
62 * For K&R C-compilers prefer varargs.h
64 # ifdef HAVE_VARARGS_H
65 # ifndef _INCL_VARARGS_H
67 # define _INCL_VARARGS_H
70 # ifndef _INCL_STDARG_H
72 # define _INCL_STDARG_H
77 #if (defined(__linux__) || defined(__linux) || defined(sun)) && \
78 (defined(__ppc) || defined(__PPC) || defined(powerpc) || defined(__powerpc__))
80 # ifndef VA_LIST_IS_ARRAY
81 # define VA_LIST_IS_ARRAY
87 * __va_copy() is used by GCC 2.8 or newer until va_copy() becomes
88 * a final ISO standard.
90 #if !defined(va_copy) && !defined(HAVE_VA_COPY)
91 # if defined(__va_copy)
92 # define va_copy(to, from) __va_copy(to, from)
97 * va_copy() is a Solaris extension to provide a portable way to perform a
98 * variable argument list "bookmarking" function.
99 * If it is not available via stdarg.h, use a simple assignement for backward
102 #if !defined(va_copy) && !defined(HAVE_VA_COPY)
103 #ifdef VA_LIST_IS_ARRAY
104 # define va_copy(to, from) ((to)[0] = (from)[0])
106 # define va_copy(to, from) ((to) = (from))
111 * I don't know any portable way to get an arbitrary
112 * C object from a var arg list so I use a
113 * system-specific routine __va_arg_list() that knows
114 * if 'va_list' is an array. You will not be able to
115 * assign the value of __va_arg_list() but it works
116 * to be used as an argument of a function.
117 * It is a requirement for recursive printf to be able
118 * to use this function argument. If your system
119 * defines va_list to be an array you need to know this
120 * via autoconf or another mechanism.
121 * It would be nice to have something like
122 * __va_arg_list() in stdarg.h
125 #ifdef VA_LIST_IS_ARRAY
126 # define __va_arg_list(list) va_arg(list, void *)
128 # define __va_arg_list(list) va_arg(list, va_list)
131 #endif /* _VADEFS_H */