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