home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gcc-2.7.2.1-base.tgz / gcc-2.7.2.1-base.tar / fsf / gcc / ginclude / stdarg.h < prev    next >
C/C++ Source or Header  |  1995-09-12  |  5KB  |  175 lines

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