]> git.saurik.com Git - apple/xnu.git/blame - osfmk/sys/varargs.h
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / sys / varargs.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31/*
32 * HISTORY
33 *
34 * Revision 1.1.1.1 1998/09/22 21:05:49 wsanchez
35 * Import of Mac OS X kernel (~semeria)
36 *
37 * Revision 1.1.1.1 1998/03/07 02:25:59 wsanchez
38 * Import of OSF Mach kernel (~mburg)
39 *
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]
44 *
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]
48 *
49 * Merged '64-bit safe' changes from DEC alpha port.
50 * [1995/11/21 18:10:39 jfraser]
51 *
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]
55 *
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]
59 *
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]
63 *
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]
67 *
68 * Revision 1.1 1992/09/30 02:37:05 robert
69 * Initial revision
70 *
71 * $EndLog$
72 */
73/* CMU_HIST */
74/*
75 * Revision 2.10 91/12/10 16:32:53 jsb
76 * Fixes from Intel
77 * [91/12/10 15:52:01 jsb]
78 *
79 * Revision 2.9 91/09/12 16:54:22 debo
80 * Added mac2.
81 * [91/09/11 17:22:52 debo]
82 *
83 * Revision 2.8 91/07/09 23:23:50 danner
84 * Added luna88k support.
85 * [91/06/24 danner]
86 *
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]
91 *
92 * Revision 2.6 91/05/14 17:40:46 mrt
93 * Correcting copyright
94 *
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]
98 *
99 * Revision 2.4 90/11/25 17:48:50 jsb
100 * Added i860 support.
101 * [90/11/25 16:54:09 jsb]
102 *
103 * Revision 2.3 90/05/03 15:51:29 dbg
104 * Added i386.
105 * [90/02/08 dbg]
106 *
107 * Revision 2.2 89/11/29 14:16:44 af
108 * RCS-ed, added mips case. Mips also needs it in Mach standalone
109 * programs.
110 * [89/10/28 10:39:14 af]
111 *
112 */
113/* CMU_ENDHIST */
114/*
115 * Mach Operating System
116 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
117 * All Rights Reserved.
118 *
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.
124 *
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.
128 *
129 * Carnegie Mellon requests users of this software to return to
130 *
131 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
132 * School of Computer Science
133 * Carnegie Mellon University
134 * Pittsburgh PA 15213-3890
135 *
136 * any improvements or extensions that they make and grant Carnegie Mellon rights
137 * to redistribute these changes.
138 */
139/*
140 */
141
142#ifndef _SYS_VARARGS_H_
143#define _SYS_VARARGS_H_
144
145#if defined(vax) || defined(sun3) || defined(mips) || defined(i386) || defined(mac2)
146#define va_dcl int va_alist;
147typedef char * va_list;
148
149#define va_start(pvar) (pvar) = (va_list)&va_alist
150#define va_end(pvar)
151#ifdef mips
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]
155#else /* mips */
156#define va_arg(pvar,type) ( \
157 (pvar) += ((sizeof(type)+3) & ~0x3), \
158 *((type *)((pvar) - ((sizeof(type)+3) & ~0x3))) )
159#endif /* mips */
160#endif /* vax */
161
162/*
163 * Try to make varargs work for the Multimax so that _doprnt can be
164 * declared as
165 * _doprnt(file, fmt, list)
166 * FILE *file;
167 * char *fmt;
168 * va_list *list;
169 * and use
170 *
171 * n = va_arg(*list, type)
172 *
173 * without needing to drag in extra declarations
174 *
175 * and printf becomes
176 *
177 * printf(fmt, va_alist)
178 * char *fmt;
179 * va_dcl
180 * {
181 * va_list listp;
182 * va_start(listp);
183 * _doprnt((FILE *)0, fmt, &listp);
184 * va_end(listp);
185 * }
186 */
187
188#if defined(multimax) && defined(MACH_KERNEL)
189
190/*
191 * the vararglist pointer is an elaborate structure (ecch)
192 */
193typedef struct va_list {
194 char *va_item; /* current item */
195 int *va_ptr1, /* arglist pointers for 1, 2, n */
196 *va_ptr2,
197 *va_ptrn;
198 int va_ct; /* current argument number */
199} va_list;
200
201#define va_alist va_arg1, va_arg2, va_argn
202#define va_dcl int va_arg1, va_arg2, va_argn;
203
204#define va_start(pvar) ( \
205 (pvar).va_ptr1 = &va_arg1, \
206 (pvar).va_ptr2 = &va_arg2, \
207 (pvar).va_ptrn = &va_argn, \
208 (pvar).va_ct = 0 )
209
210#define va_end(pvar)
211
212#define va_arg(pvar, type) ( \
213 (pvar).va_ct++, \
214 (pvar).va_item = (char *) \
215 ( ((pvar).va_ct == 1) \
216 ? (pvar).va_ptr1 \
217 : ((pvar).va_ct == 2) \
218 ? (pvar).va_ptr2 \
219 : (pvar).va_ptrn++ ) , \
220 *((type *)((pvar).va_item)) )
221
222/* what a mess! */
223#endif /* defined(multimax) && defined(MACH_KERNEL) */
224
225#if i860
226#include <i860/varargs.h> /* PGI vs. Greenhills */
227#endif
228
229#ifdef luna88k
230#include <luna88k/varargs.h> /* How nice */
231#endif
232
233#if defined (__PPC__) && defined (_CALL_SYSV)
234#include <ppc/va-ppc.h> /* care of gcc compiler - TEMPORARY 2.7.1 TODO NMGS*/
235#endif
236
237#if defined(__alpha)
238# include <varargs.h>
239#endif /* defined(__alpha) */
240
241#endif /* _SYS_VARARGS_H_ */