stdarg.h
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:2k
- /* $Id$ */
- /* stdarg.h: ANSI X3.159 1989 library header, section 4.8 */
- /* Copyright (C) Codemist Ltd. */
- /* Copyright (C) SGS-THOMSON Microelectronics Ltd. 1996 */
- #ifndef __stdarg_h
- #define __stdarg_h
- #include "stddef.h"
- #include "stdlib.h"
- #include "stdio.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- /* N.B. <stdio.h> is required to declare vfprintf() without defining */
- /* va_list. Clearly the type __va_list there must keep in step. */
- typedef char *va_list[1]; /* see <stdio.h> */
- /* Note that ___type is a syntactic item a bit like the type qualifiers */
- /* 'static', 'register', 'const' etc except that it has no effect! Its */
- /* purpose is to indicate when a type is being introduced and thus */
- /* help (a bit) when the user gets the args to va_arg the wrong way round */
- #ifdef __cplusplus
- /*definitions C++ compatible */
- #define __alignof(type)
- (sizeof(type) < sizeof(int) ? sizeof(type)%sizeof(int):
- sizeof(int) )
- #define __alignuptotype(ptr,type)
- ((char *)((int)(ptr) + (__alignof(type)-1) & ~(__alignof(type)-1)))
- #define va_start(ap,parmN) ((void)(*(ap) = (char *)&(parmN) + sizeof(parmN)))
- #define va_arg(ap,type)
- *( type *)( (*(ap)=__alignuptotype(*(ap),type) + sizeof(type)) -
- sizeof( type) )
- #define va_end(ap) ((void)(*(ap) = (char *)-256))
- #else
- #define __alignof(type)
- ((char *)&(((struct{char __member1;
- ___type type __member2;}*) 0)->__member2) -
- (char *)0)
- #define __alignuptotype(ptr,type)
- ((char *)((int)(ptr) + (__alignof(type)-1) & ~(__alignof(type)-1)))
- #define va_start(ap,parmN) ((void)(*(ap) = (char *)&(parmN) + sizeof(parmN)))
- #define va_arg(ap,type)
- (___assert((___typeof(___type type) & 0x28000481) == 0,
- "Illegal type used with va_arg"),
- *(___type type *)((*(ap)=__alignuptotype(*(ap),type)+sizeof(___type type))-
- sizeof(___type type)))
- #define va_end(ap) ((void)(*(ap) = (char *)-256))
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
- /* end of stdarg.h */