Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.0 KiB

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