stdarg.h File Reference
declares types and macros for advancing through variable number of arguments
More...
#include <nlibc.h>
Include dependency graph for stdarg.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
|
Defines |
#define | argwidth(n) ((sizeof(n)+sizeof(int)-1) & ~(sizeof(int)-1)) |
#define | va_rounded_size(type) (((sizeof(type)+sizeof(int)-1)/sizeof(int))*sizeof(int)) |
#define | va_start(list, start) |
#define | va_end(list) asm("\t!! va_end()") |
#define | va_arg(ap, type) (ap.lo++, ap.hi--, *(type *)((ap).lo++)) |
#define | _va_info(ap) (*(vector int *)((ap).lo++)) |
#define | _va_arg(ap, type) (*(type *)((ap).lo++)) |
#define | _va_ptr(ap) ((void *)((ap).lo)) |
#define | _va_args(ap) ((ap).hi) |
#define | _va_skip(ap, size) do { (ap).lo += size; } while(0) |
#define | va_copy(dest, src) ((dest) = (src)) |
Typedefs |
typedef nodeprivate vector int | va_list |
| type to hold the current argument pointer
|
Detailed Description
declares types and macros for advancing through variable number of arguments
- Id
- stdarg.h,v 1.17 2005/06/08 14:06:53 pleiter Exp
ISO/IEC 9899:1999 (E) Standard variable argument lists <stdarg.h>
The header <stdarg.h> declares a type and defines four required macros, for advancing through a list of arguments whose number and types are not known to the called function when it is translated.
A function may be called with a variable number of arguments of varying types. As described in C99 6.9.1, its parameter list contains one or more parameters. The rightmost parameter plays a special role in the access mechanism, and will be designated parmN in this description.
- IMPLEMENTATION for apeNEXT:
- possible (stdarg.h)
Definition in file stdarg.h.
Define Documentation
#define _va_arg |
( |
ap, |
|
|
type |
|
) |
(*(type *)((ap).lo++))
|
|
|
access to the argument value *without* skipping any info field. To be used _only_ after _va_info
Definition at line 175 of file stdarg.h. |
#define _va_args |
( |
ap |
|
) |
((ap).hi)
|
|
|
return only the counter of the remaining args
Definition at line 188 of file stdarg.h. |
#define _va_info |
( |
ap |
|
) |
(*(vector int *)((ap).lo++))
|
|
|
access to the extra argument info value. To be used together with _va_arg or _va_skip. The returned value is a vector int, hi=typecode, lo=size
Definition at line 168 of file stdarg.h. |
#define _va_ptr |
( |
ap |
|
) |
((void *)((ap).lo))
|
|
|
return only the address of the next arg
To be used _only_ after _va_info
Definition at line 182 of file stdarg.h. |
#define _va_skip |
( |
ap, |
|
|
size |
|
) |
do { (ap).lo += size; } while(0)
|
|
|
increment argument ptr by size.
Does not decrement the counter part !
To be used _only_ after _va_info
Definition at line 196 of file stdarg.h. |
#define argwidth |
( |
n |
|
) |
((sizeof(n)+sizeof(int)-1) & ~(sizeof(int)-1))
|
|
#define va_arg |
( |
ap, |
|
|
type |
|
) |
(ap.lo++, ap.hi--, *(type *)((ap).lo++))
|
|
|
- SYNOPSIS
#include <stdarg.h>
type va_arg(va_list ap, type);
- DESCRIPTION
The va_arg macro expands to an expression that has the specified
type and the value of the next argument in the call. The parameter
ap shall have been initialized by the va_start or va_copy macro
(without an intervening invocation of the va_end macro for
the same ap). Each invocation of the va_arg macro modifies
ap so that the values of successive arguments are returned in
turn. The parameter type shall be a type name specified such
that the type of a pointer to an object that has the specified
type can be obtained simply by postfixing a * to type. If there
is no actual next argument, or if type is not compatible with
the type of the actual next argument (as promoted according to
the default argument promotions), the behavior is undefined,
except for the following cases:
- one type is a signed integer type, the other type is the
corresponding unsigned integer type, and the value is representable
in both types;
- one type is pointer to void and the other is a pointer to a character
type.
- RETURN VALUE
The first invocation of the va_arg macro after that of the
va_start macro returns the value of the argument after that
specified by its parmN parameter. Successive invocations return the
values of the remaining arguments in succession.
- IMPLEMENTATION FOR apeNEXT:
Variadic arguments in apeNEXT have an extra info field before
the actual argument data on the stack.
va_arg() therefore
- first increments ap.lo by one (advancing the pointer) and
decrements the .hi part by one (decreasing the number of
arguments).
- returns an explicit cast to the desired type from the current
pointer destination and increments the pointer by the size of
type.
Definition at line 160 of file stdarg.h.
Referenced by mfputva(), and mfputxa(). |
#define va_copy |
( |
dest, |
|
|
src |
|
) |
((dest) = (src))
|
|
|
def va_copy(dest,src) - SYNOPSIS
#include <stdarg.h>
void va_copy(va_list dest, va_list src);
- DESCRIPTION
The va_copy macro initializes dest as a copy of src, as if the
va_start macro had been applied to dest followed by the same
sequence of uses of the va_arg macro as had previously been
used to reach the present state of src. Neither the va_copy nor
va_start macro shall be invoked to reinitialize dest without an
intervening invocation of the va_end macro for the same dest.
- RETURN VALUE
The va_copy macro returns no value.
Definition at line 218 of file stdarg.h. |
#define va_end |
( |
list |
|
) |
asm("\t!! va_end()")
|
|
|
- SYNOPSIS
#include <stdarg.h>
void va_end(va_list ap);
- DESCRIPTION
The va_end macro facilitates a normal return from the function
whose variable argument list was referred to by the expansion of
the va_start macro, or the function containing the expansion of
the va_copy macro, that initialized the va_list ap. The va_end
macro may modify ap so that it is no longer usable (without
being reinitialized by the va_start or va_copy macro). If there
is no corresponding invocation of the va_start or va_copy macro,
or if the va_end macro is not invoked before the return, the
behavior is undefined.
- RETURN VALUE
The va_end macro returns no value.
Definition at line 109 of file stdarg.h. |
#define va_rounded_size |
( |
type |
|
) |
(((sizeof(type)+sizeof(int)-1)/sizeof(int))*sizeof(int))
|
|
#define va_start |
( |
list, |
|
|
start |
|
) |
|
|
|
Value: do { \
asm("\t!! begin va_start()"); \
(list).lo = (int)(__builtin_argoffset(start)+1); \
(list).hi = (int)(__builtin_argcount(start)); \
asm("\t!! end va_start()"); \
} while(0)
- SYNOPSIS
#include <stdarg.h>
void va_start(va_list ap, parmN);
- DESCRIPTION
The va_start macro shall be invoked before any access to the
unnamed arguments.
The va_start macro initializes ap for subsequent use by the
va_arg and va_end macros. Neither the va_start nor va_copy
macro shall be invoked to reinitialize ap without an intervening
invocation of the va_end macro for the same ap.
The parameter parmN is the identifier of the rightmost parameter
in the variable parameter list in the function definition (the
one just before the , ...). If the parameter parmN is declared
with the register storage class, with a function or array type,
or with a type that is not compatible with the type that results
after application of the default argument promotions, the behavior
is undefined.
- RETURN VALUE
The va_start macro returns no value.
- IMPLEMENTATION FOR apeNEXT:
- The va_list type holds both a pointer to the 1st argument on the stack
that is beyond parmN and (in the high bank) teh number of arguments
that follow parmN. The latter is used to pass the argument count to
functions like vpintf that have otherewise no way of telling the
argument number.
Definition at line 78 of file stdarg.h. |
Typedef Documentation
|
type to hold the current argument pointer
object type suitable for holding information needed by the macros va_start, va_arg, va_end, and va_copy.
Definition at line 37 of file stdarg.h. |
Generated on Tue Jan 10 12:43:51 2006 for nlibc by
1.3.5