FreeBSD/Linux Kernel Cross Reference
sys/sys/varargs.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon rights
24 * to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: varargs.h,v $
29 * Revision 2.13 93/02/01 09:50:39 danner
30 * Updated copyright.
31 * [93/01/12 berman]
32 * Added sparc clause to include sun4/varargs.h.
33 * [92/12/24 berman]
34 *
35 * Revision 2.12 93/01/14 18:00:15 danner
36 * Added alpha.
37 * [92/12/01 af]
38 *
39 * Revision 2.11 92/08/03 17:59:48 jfriedl
40 * Include gcc 2.x derived va-m88k.h for m88k [danner] or m88k
41 * Added pc532 support [Johannes Helander (jvh@cs.hut.fi)]
42 * [92/07/24 jfriedl]
43 *
44 * Revision 2.10 91/12/10 16:32:53 jsb
45 * Fixes from Intel
46 * [91/12/10 15:52:01 jsb]
47 *
48 * Revision 2.9 91/09/12 16:54:22 bohman
49 * Added mac2.
50 * [91/09/11 17:22:52 bohman]
51 *
52 * Revision 2.8 91/07/09 23:23:50 danner
53 * Added luna88k support.
54 * [91/06/24 danner]
55 *
56 * Revision 2.7 91/06/18 20:53:02 jsb
57 * Moved i860 varargs code here from i860/i860_varargs.h, thanks to
58 * new copyright from Intel.
59 * [91/06/18 19:15:02 jsb]
60 *
61 * Revision 2.6 91/05/14 17:40:46 mrt
62 * Correcting copyright
63 *
64 * Revision 2.5 91/02/05 17:57:12 mrt
65 * Changed to new Mach copyright
66 * [91/02/01 17:49:51 mrt]
67 *
68 * Revision 2.4 90/11/25 17:48:50 jsb
69 * Added i860 support.
70 * [90/11/25 16:54:09 jsb]
71 *
72 * Revision 2.3 90/05/03 15:51:29 dbg
73 * Added i386.
74 * [90/02/08 dbg]
75 *
76 * Revision 2.2 89/11/29 14:16:44 af
77 * RCS-ed, added mips case. Mips also needs it in Mach standalone
78 * programs.
79 * [89/10/28 10:39:14 af]
80 *
81 */
82
83 #ifndef _SYS_VARARGS_H_
84 #define _SYS_VARARGS_H_
85
86 #if defined(vax) || defined(sun3) || defined(mips) || defined(i386) || defined(mac2) || defined(PC532)
87 #define va_dcl int va_alist;
88 typedef char * va_list;
89
90 #define va_start(pvar) (pvar) = (va_list)&va_alist
91 #define va_end(pvar)
92 #ifdef mips
93 # define va_arg(pvar, type) ((type *)(pvar = \
94 (va_list) (sizeof(type) > 4 ? ((int)pvar + 2*8 - 1) & -8 \
95 : ((int)pvar + 2*4 - 1) & -4)))[-1]
96 #else mips
97 #define va_arg(pvar,type) ( \
98 (pvar) += ((sizeof(type)+3) & ~0x3), \
99 *((type *)((pvar) - ((sizeof(type)+3) & ~0x3))) )
100 #endif mips
101 #endif /* vax */
102
103 /*
104 * Try to make varargs work for the Multimax so that _doprnt can be
105 * declared as
106 * _doprnt(file, fmt, list)
107 * FILE *file;
108 * char *fmt;
109 * va_list *list;
110 * and use
111 *
112 * n = va_arg(*list, type)
113 *
114 * without needing to drag in extra declarations
115 *
116 * and printf becomes
117 *
118 * printf(fmt, va_alist)
119 * char *fmt;
120 * va_dcl
121 * {
122 * va_list listp;
123 * va_start(listp);
124 * _doprnt((FILE *)0, fmt, &listp);
125 * va_end(listp);
126 * }
127 */
128
129 #if defined(multimax) && defined(KERNEL)
130
131 /*
132 * the vararglist pointer is an elaborate structure (ecch)
133 */
134 typedef struct va_list {
135 char *va_item; /* current item */
136 int *va_ptr1, /* arglist pointers for 1, 2, n */
137 *va_ptr2,
138 *va_ptrn;
139 int va_ct; /* current argument number */
140 } va_list;
141
142 #define va_alist va_arg1, va_arg2, va_argn
143 #define va_dcl int va_arg1, va_arg2, va_argn;
144
145 #define va_start(pvar) ( \
146 (pvar).va_ptr1 = &va_arg1, \
147 (pvar).va_ptr2 = &va_arg2, \
148 (pvar).va_ptrn = &va_argn, \
149 (pvar).va_ct = 0 )
150
151 #define va_end(pvar)
152
153 #define va_arg(pvar, type) ( \
154 (pvar).va_ct++, \
155 (pvar).va_item = (char *) \
156 ( ((pvar).va_ct == 1) \
157 ? (pvar).va_ptr1 \
158 : ((pvar).va_ct == 2) \
159 ? (pvar).va_ptr2 \
160 : (pvar).va_ptrn++ ) , \
161 *((type *)((pvar).va_item)) )
162
163 /* what a mess! */
164 #endif /* defined(multimax) && defined(KERNEL) */
165
166 #if i860
167 #include <i860/varargs.h> /* PGI vs. Greenhills */
168 #endif
169
170 #ifdef m88k
171 #include <motorola/m88k/va-m88k.h>
172 #else
173 #ifdef luna88k
174 #include <motorola/m88k/va-m88k.h>
175 #endif
176 #endif
177
178 #ifdef sparc
179 #include <sun4/varargs.h> /* built in varargs when using sun4 compiler */
180 #endif
181
182 #if alpha
183 #include <alpha/varargs.h>
184 #endif
185
186 #endif _SYS_VARARGS_H_
Cache object: 32bcdc371a111cfa5f7ae5a571af708c
|