stdarg.h

00001 /*  wcecompat: Windows CE C Runtime Library "compatibility" library.
00002  *
00003  *  Copyright (C) 2001-2002 Essemer Pty Ltd.  All rights reserved.
00004  *  http://www.essemer.com.au/
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2.1 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 
00022 #ifndef __wcecompat__STDARG_H__
00023 #define __wcecompat__STDARG_H__
00024 
00025 #include "stddef.h"
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 #if defined (_M_CEE)
00032         typedef struct { void* p[4]; } va_list;
00033 #else
00034         typedef char *va_list;
00035 #endif
00036 
00037 #ifdef MIPS
00038 
00039 #define va_start(ap,v) ap  = (va_list)&v + sizeof(v)
00040 #define va_end(list) ( list = (va_list)0 )
00041 #define va_arg(list, mode) ((mode *)(list =\
00042  (char *) ((((int)list + (__builtin_alignof(mode)<=4?3:7)) &\
00043  (__builtin_alignof(mode)<=4?-4:-8))+sizeof(mode))))[-1]
00044 
00045 #elif defined(PPC)
00046 
00047 // PPC uses 8-byte alignment of 8-byte quantities
00048 #define _ALIGNIT(ap,t)  ((((int)(ap))+(sizeof(t)<8?3:7)) & (sizeof(t)<8?~3:~7))
00049 
00050 #define _INTSIZEOF(n)   ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
00051 #define va_start(ap,v)  ( ap = (va_list)&v + _INTSIZEOF(v) )
00052 #define va_arg(ap,t)    ( *(t *)((ap = (char *) (_ALIGNIT(ap, t) + _INTSIZEOF(t))) - _INTSIZEOF(t)) )
00053 #define va_end(ap)      ( ap = (va_list)0 )
00054 
00055 #elif defined (_M_CEE)
00056 
00057 extern void __cdecl   __va_start(va_list*, ...);
00058 extern void* __cdecl  __va_arg(va_list*, ...);
00059 extern void __cdecl   __va_end(va_list*);
00060 
00061 #define va_start(ap,v)  (__va_start(&ap, &v, sizeof(v), __builtin_alignof(v), &v))
00062 #define va_arg(ap,t)    (*((t*)__va_arg(&ap, sizeof(t), __builtin_alignof(t), (t*)0)))
00063 #define va_end(ap)      (__va_end(&ap))
00064 
00065 #else
00066 
00067 #define _INTSIZEOF(n)   ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
00068 #define va_start(ap,v)  ( ap = (va_list)&v + _INTSIZEOF(v) )
00069 #define va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
00070 #define va_end(ap)      ( ap = (va_list)0 )
00071 
00072 #endif
00073 
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077 
00078 #endif /* __wcecompat__STDARG_H__ */

Generated on Mon Jun 5 10:20:45 2006 for Intelligence.kdevelop by  doxygen 1.4.6