stdarg.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* stdarg.h for GNU.
  2. Note that the type used in va_arg is supposed to match the
  3. actual type **after default promotions**.
  4. Thus, va_arg (..., short) is not valid. */
  5. #ifndef _STDARG_H
  6. #ifndef _ANSI_STDARG_H_
  7. #ifndef __need___va_list
  8. #define _STDARG_H
  9. #define _ANSI_STDARG_H_
  10. #endif /* not __need___va_list */
  11. #undef __need___va_list
  12. #ifdef __clipper__
  13. #include "va-clipper.h"
  14. #else
  15. #ifdef __m88k__
  16. #include "va-m88k.h"
  17. #else
  18. #ifdef __i860__
  19. #include "va-i860.h"
  20. #else
  21. #ifdef __hppa__
  22. #include "va-pa.h"
  23. #else
  24. #ifdef __mips__
  25. #include "va-mips.h"
  26. #else
  27. #ifdef __sparc__
  28. #include "va-sparc.h"
  29. #else
  30. #ifdef __i960__
  31. #include "va-i960.h"
  32. #else
  33. #ifdef __alpha__
  34. #include "va-alpha.h"
  35. #else
  36. #if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__)
  37. #include "va-h8300.h"
  38. #else
  39. #if defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
  40. #include "va-ppc.h"
  41. #else
  42. #ifdef __arc__
  43. #include "va-arc.h"
  44. #else
  45. #ifdef __M32R__
  46. #include "va-m32r.h"
  47. #else
  48. #ifdef __sh__
  49. #include "va-sh.h"
  50. #else
  51. #ifdef __mn10300__
  52. #include "va-mn10300.h"
  53. #else
  54. #ifdef __mn10200__
  55. #include "va-mn10200.h"
  56. #else
  57. #ifdef __v850__
  58. #include "va-v850.h"
  59. #else
  60. /* Define __gnuc_va_list. */
  61. #ifndef __GNUC_VA_LIST
  62. #define __GNUC_VA_LIST
  63. #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX) || defined(__NetBSD__)
  64. typedef char *__gnuc_va_list;
  65. #else
  66. typedef void *__gnuc_va_list;
  67. #endif
  68. #endif
  69. /* Define the standard macros for the user,
  70. if this invocation was from the user program. */
  71. #ifdef _STDARG_H
  72. /* Amount of space required in an argument list for an arg of type TYPE.
  73. TYPE may alternatively be an expression whose type is used. */
  74. #if defined(sysV68)
  75. #define __va_rounded_size(TYPE) \
  76. (((sizeof (TYPE) + sizeof (short) - 1) / sizeof (short)) * sizeof (short))
  77. #else
  78. #define __va_rounded_size(TYPE) \
  79. (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  80. #endif
  81. #define va_start(AP, LASTARG) \
  82. (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
  83. #undef va_end
  84. void va_end (__gnuc_va_list); /* Defined in libgcc.a */
  85. #define va_end(AP) ((void)0)
  86. /* We cast to void * and then to TYPE * because this avoids
  87. a warning about increasing the alignment requirement. */
  88. #if (defined (__arm__) && ! defined (__ARMEB__)) || defined (__i386__) || defined (__i860__) || defined (__ns32000__) || defined (__vax__)
  89. /* This is for little-endian machines; small args are padded upward. */
  90. #define va_arg(AP, TYPE) \
  91. (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
  92. *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
  93. #else /* big-endian */
  94. /* This is for big-endian machines; small args are padded downward. */
  95. #define va_arg(AP, TYPE) \
  96. (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
  97. *((TYPE *) (void *) ((char *) (AP) \
  98. - ((sizeof (TYPE) < __va_rounded_size (char) \
  99. ? sizeof (TYPE) : __va_rounded_size (TYPE))))))
  100. #endif /* big-endian */
  101. /* Copy __gnuc_va_list into another variable of this type. */
  102. #define __va_copy(dest, src) (dest) = (src)
  103. #endif /* _STDARG_H */
  104. #endif /* not v850 */
  105. #endif /* not mn10200 */
  106. #endif /* not mn10300 */
  107. #endif /* not sh */
  108. #endif /* not m32r */
  109. #endif /* not arc */
  110. #endif /* not powerpc with V.4 calling sequence */
  111. #endif /* not h8300 */
  112. #endif /* not alpha */
  113. #endif /* not i960 */
  114. #endif /* not sparc */
  115. #endif /* not mips */
  116. #endif /* not hppa */
  117. #endif /* not i860 */
  118. #endif /* not m88k */
  119. #endif /* not clipper */
  120. #ifdef _STDARG_H
  121. /* Define va_list, if desired, from __gnuc_va_list. */
  122. /* We deliberately do not define va_list when called from
  123. stdio.h, because ANSI C says that stdio.h is not supposed to define
  124. va_list. stdio.h needs to have access to that data type,
  125. but must not use that name. It should use the name __gnuc_va_list,
  126. which is safe because it is reserved for the implementation. */
  127. #ifdef _HIDDEN_VA_LIST /* On OSF1, this means varargs.h is "half-loaded". */
  128. #undef _VA_LIST
  129. #endif
  130. #ifdef _BSD_VA_LIST
  131. #undef _BSD_VA_LIST
  132. #endif
  133. #if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST))
  134. /* SVR4.2 uses _VA_LIST for an internal alias for va_list,
  135. so we must avoid testing it and setting it here.
  136. SVR4 uses _VA_LIST as a flag in stdarg.h, but we should
  137. have no conflict with that. */
  138. #ifndef _VA_LIST_
  139. #define _VA_LIST_
  140. #ifdef __i860__
  141. #ifndef _VA_LIST
  142. #define _VA_LIST va_list
  143. #endif
  144. #endif /* __i860__ */
  145. typedef __gnuc_va_list va_list;
  146. #ifdef _SCO_DS
  147. #define __VA_LIST
  148. #endif
  149. #endif /* _VA_LIST_ */
  150. #else /* not __svr4__ || _SCO_DS */
  151. /* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
  152. But on BSD NET2 we must not test or define or undef it.
  153. (Note that the comments in NET 2's ansi.h
  154. are incorrect for _VA_LIST_--see stdio.h!) */
  155. #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT)
  156. /* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */
  157. #ifndef _VA_LIST_DEFINED
  158. /* The macro _VA_LIST is used in SCO Unix 3.2. */
  159. #ifndef _VA_LIST
  160. /* The macro _VA_LIST_T_H is used in the Bull dpx2 */
  161. #ifndef _VA_LIST_T_H
  162. typedef __gnuc_va_list va_list;
  163. #endif /* not _VA_LIST_T_H */
  164. #endif /* not _VA_LIST */
  165. #endif /* not _VA_LIST_DEFINED */
  166. #if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__))
  167. #define _VA_LIST_
  168. #endif
  169. #ifndef _VA_LIST
  170. #define _VA_LIST
  171. #endif
  172. #ifndef _VA_LIST_DEFINED
  173. #define _VA_LIST_DEFINED
  174. #endif
  175. #ifndef _VA_LIST_T_H
  176. #define _VA_LIST_T_H
  177. #endif
  178. #endif /* not _VA_LIST_, except on certain systems */
  179. #endif /* not __svr4__ */
  180. #endif /* _STDARG_H */
  181. #endif /* not _ANSI_STDARG_H_ */
  182. #endif /* not _STDARG_H */