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