]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/sys/varargs.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
34 * Revision 1.1.1.1 1998/09/22 21:05:49 wsanchez
35 * Import of Mac OS X kernel (~semeria)
37 * Revision 1.1.1.1 1998/03/07 02:25:59 wsanchez
38 * Import of OSF Mach kernel (~mburg)
40 * Revision 1.2.28.1 1996/11/29 16:59:53 stephen
41 * nmklinux_1.0b3_shared into pmk1.1
42 * Added powerpc special case
43 * [1996/11/29 16:34:18 stephen]
45 * Revision 1.2.15.2 1996/01/09 19:23:16 devrcs
46 * Added alpha varargs.h
47 * [1995/12/01 20:39:10 jfraser]
49 * Merged '64-bit safe' changes from DEC alpha port.
50 * [1995/11/21 18:10:39 jfraser]
52 * Revision 1.2.15.1 1994/09/23 03:13:46 ezf
53 * change marker to not FREE
54 * [1994/09/22 21:59:07 ezf]
56 * Revision 1.2.4.3 1993/08/03 18:30:40 gm
57 * CR9596: Change KERNEL to MACH_KERNEL.
58 * [1993/08/02 19:03:10 gm]
60 * Revision 1.2.4.2 1993/06/09 02:55:42 gm
61 * Added to OSF/1 R1.3 from NMK15.0.
62 * [1993/06/02 21:31:11 jeffc]
64 * Revision 1.2 1993/04/19 17:17:26 devrcs
65 * correct endif tags for ansi
66 * [1993/02/25 17:56:02 david]
68 * Revision 1.1 1992/09/30 02:37:05 robert
75 * Revision 2.10 91/12/10 16:32:53 jsb
77 * [91/12/10 15:52:01 jsb]
79 * Revision 2.9 91/09/12 16:54:22 debo
81 * [91/09/11 17:22:52 debo]
83 * Revision 2.8 91/07/09 23:23:50 danner
84 * Added luna88k support.
87 * Revision 2.7 91/06/18 20:53:02 jsb
88 * Moved i860 varargs code here from i860/i860_varargs.h, thanks to
89 * new copyright from Intel.
90 * [91/06/18 19:15:02 jsb]
92 * Revision 2.6 91/05/14 17:40:46 mrt
93 * Correcting copyright
95 * Revision 2.5 91/02/05 17:57:12 mrt
96 * Changed to new Mach copyright
97 * [91/02/01 17:49:51 mrt]
99 * Revision 2.4 90/11/25 17:48:50 jsb
100 * Added i860 support.
101 * [90/11/25 16:54:09 jsb]
103 * Revision 2.3 90/05/03 15:51:29 dbg
107 * Revision 2.2 89/11/29 14:16:44 af
108 * RCS-ed, added mips case. Mips also needs it in Mach standalone
110 * [89/10/28 10:39:14 af]
115 * Mach Operating System
116 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
117 * All Rights Reserved.
119 * Permission to use, copy, modify and distribute this software and its
120 * documentation is hereby granted, provided that both the copyright
121 * notice and this permission notice appear in all copies of the
122 * software, derivative works or modified versions, and any portions
123 * thereof, and that both notices appear in supporting documentation.
125 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
126 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
127 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
129 * Carnegie Mellon requests users of this software to return to
131 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
132 * School of Computer Science
133 * Carnegie Mellon University
134 * Pittsburgh PA 15213-3890
136 * any improvements or extensions that they make and grant Carnegie Mellon rights
137 * to redistribute these changes.
142 #ifndef _SYS_VARARGS_H_
143 #define _SYS_VARARGS_H_
145 #if defined(vax) || defined(sun3) || defined(mips) || defined(i386) || defined(mac2)
146 #define va_dcl int va_alist;
147 typedef char * va_list;
149 #define va_start(pvar) (pvar) = (va_list)&va_alist
152 # define va_arg(pvar, type) ((type *)(pvar = \
153 (va_list) (sizeof(type) > 4 ? ((int)pvar + 2*8 - 1) & -8 \
154 : ((int)pvar + 2*4 - 1) & -4)))[-1]
156 #define va_arg(pvar,type) ( \
157 (pvar) += ((sizeof(type)+3) & ~0x3), \
158 *((type *)((pvar) - ((sizeof(type)+3) & ~0x3))) )
163 * Try to make varargs work for the Multimax so that _doprnt can be
165 * _doprnt(file, fmt, list)
171 * n = va_arg(*list, type)
173 * without needing to drag in extra declarations
177 * printf(fmt, va_alist)
183 * _doprnt((FILE *)0, fmt, &listp);
188 #if defined(multimax) && defined(MACH_KERNEL)
191 * the vararglist pointer is an elaborate structure (ecch)
193 typedef struct va_list {
194 char *va_item
; /* current item */
195 int *va_ptr1
, /* arglist pointers for 1, 2, n */
198 int va_ct
; /* current argument number */
201 #define va_alist va_arg1, va_arg2, va_argn
202 #define va_dcl int va_arg1, va_arg2, va_argn;
204 #define va_start(pvar) ( \
205 (pvar).va_ptr1 = &va_arg1, \
206 (pvar).va_ptr2 = &va_arg2, \
207 (pvar).va_ptrn = &va_argn, \
212 #define va_arg(pvar, type) ( \
214 (pvar).va_item = (char *) \
215 ( ((pvar).va_ct == 1) \
217 : ((pvar).va_ct == 2) \
219 : (pvar).va_ptrn++ ) , \
220 *((type *)((pvar).va_item)) )
223 #endif /* defined(multimax) && defined(MACH_KERNEL) */
226 #include <i860/varargs.h> /* PGI vs. Greenhills */
230 #include <luna88k/varargs.h> /* How nice */
233 #if defined (__PPC__) && defined (_CALL_SYSV)
234 #include <ppc/va-ppc.h> /* care of gcc compiler - TEMPORARY 2.7.1 TODO NMGS*/
238 # include <varargs.h>
239 #endif /* defined(__alpha) */
241 #endif /* _SYS_VARARGS_H_ */