home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / AutoPC / apcsdk10.exe / data1.cab / Emulation_Include_Files / stdarg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-13  |  3.1 KB  |  117 lines

  1. /***
  2. *stdarg.h - defines ANSI-style macros for variable argument functions
  3. *
  4. *    Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *    This file defines ANSI-style macros for accessing arguments
  8. *    of functions which take a variable number of arguments.
  9. *    [ANSI]
  10. *
  11. ****/
  12.  
  13. #ifndef _INC_STDARG
  14. #define _INC_STDARG
  15.  
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19.  
  20.  
  21.  
  22. #ifndef _VA_LIST_DEFINED
  23. #ifdef    _M_ALPHA
  24. typedef struct {
  25.     char *a0;    /* pointer to first homed integer argument */
  26.     int offset;    /* byte offset of next parameter */
  27. } va_list;
  28. #else
  29. typedef char *    va_list;
  30. #endif
  31. #define _VA_LIST_DEFINED
  32. #endif
  33.  
  34. #ifdef    _M_IX86
  35.  
  36.  
  37. #define _INTSIZEOF(n)    ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
  38.  
  39. #define va_start(ap,v)    ( ap = (va_list)&v + _INTSIZEOF(v) )
  40. #define va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
  41. #define va_end(ap)    ( ap = (va_list)0 )
  42.  
  43.  
  44. #elif    defined(_M_MRX000)
  45.  
  46.  
  47. /* Use these types and definitions if generating code for MIPS */
  48.  
  49. #define va_start(ap,v) ap  = (va_list)&v + sizeof(v)
  50. #define va_end(list)
  51. #define va_arg(list, mode) ((mode *)(list =\
  52.  (char *) ((((int)list + (__builtin_alignof(mode)<=4?3:7)) &\
  53.  (__builtin_alignof(mode)<=4?-4:-8))+sizeof(mode))))[-1]
  54.  
  55. /*  +++++++++++++++++++++++++++++++++++++++++++
  56.     Because of parameter passing conventions in C:
  57.     use mode=int for char, and short types
  58.     use mode=double for float types
  59.     use a pointer for array types
  60.     +++++++++++++++++++++++++++++++++++++++++++ */
  61.  
  62.  
  63. #elif    defined(_M_ALPHA)
  64.  
  65.  
  66. /* Use these types and definitions if generating code for ALPHA */
  67.  
  68. /*
  69.  * The Alpha compiler supports two builtin functions that are used to
  70.  * implement stdarg/varargs.  The __builtin_va_start function is used
  71.  * by va_start to initialize the data structure that locates the next
  72.  * argument.  The __builtin_isfloat function is used by va_arg to pick
  73.  * which part of the home area a given register argument is stored in.
  74.  * The home area is where up to six integer and/or six floating point
  75.  * register arguments are stored down (so they can also be referenced
  76.  * by a pointer like any arguments passed on the stack).
  77.  */
  78.  
  79. extern void * __builtin_va_start(va_list, ...);
  80.  
  81. #ifdef    _CFRONT
  82. #define __builtin_isfloat(a) __builtin_alignof(a)
  83. #endif
  84.  
  85. #define va_start(list, v) __builtin_va_start(list, v, 1)
  86. #define va_end(list)
  87. #define va_arg(list, mode) \
  88.     ( *(        ((list).offset += ((int)sizeof(mode) + 7) & -8) , \
  89.         (mode *)((list).a0 + (list).offset - \
  90.                     ((__builtin_isfloat(mode) && (list).offset <= (6 * 8)) ? \
  91.                         (6 * 8) + 8 : ((int)sizeof(mode) + 7) & -8) \
  92.                 ) \
  93.        ) \
  94.     )
  95.  
  96.  
  97. #else
  98.  
  99.  
  100. /* A guess at the proper definitions for other platforms */
  101.  
  102. #define _INTSIZEOF(n)    ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
  103.  
  104. #define va_start(ap,v)    ( ap = (va_list)&v + _INTSIZEOF(v) )
  105. #define va_arg(ap,t)    ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
  106. #define va_end(ap)    ( ap = (va_list)0 )
  107.  
  108.  
  109. #endif
  110.  
  111.  
  112. #ifdef __cplusplus
  113. }
  114. #endif
  115.  
  116. #endif    /* _INC_STDARG */
  117.