date and time created 90/06/25 13:56:22 by bostic
[unix-history] / usr / src / include / stdarg.h
CommitLineData
c98fe9aa
KB
1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 *
b197dab6 7 * @(#)stdarg.h 5.3 (Berkeley) %G%
c98fe9aa
KB
8 */
9
10typedef char *va_list;
11
0f72c2ef
KB
12/*
13 * ANSI says: "If there is no actual next argument, or if type is not
14 * compatible with the type of the actual next argument (as promoted
15 * according to the default argument promotions), the behavior is
16 * undefined." We read this to mean that we're not allowed to do the
17 * promotion for the user, so shorts and chars drop core.
18 */
c98fe9aa 19#define va_arg(ap, type) \
0f72c2ef 20 ((type *)(ap += sizeof(type) < sizeof(int) ? \
b197dab6 21 (abort(), 0) : sizeof(type)))[-1]
0f72c2ef 22
c98fe9aa 23#define va_end(ap)
0f72c2ef
KB
24
25#define __va_promote(type) \
26 (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
27
c98fe9aa 28#define va_start(ap, last) \
0f72c2ef 29 (ap = ((char *)&(last) + __va_promote(last)))