home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gcc-2.4.5 / gvarargs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-17  |  4.1 KB  |  170 lines

  1. #ifndef __GNUC__
  2. /* Use the system's macros with the system's compiler.  */
  3. #include <varargs.h>
  4. #else
  5. /* Record that this is varargs.h; this turns off stdarg.h.  */
  6.  
  7. #ifndef _VARARGS_H
  8. #define _VARARGS_H
  9.  
  10. #ifdef __sparc__
  11. #include <va-sparc.h>
  12. #else
  13. #ifdef __spur__
  14. #include <va-spur.h>
  15. #else
  16. #ifdef __mips__
  17. #include <va-mips.h>
  18. #else
  19. #ifdef __i860__
  20. #include <va-i860.h>
  21. #else
  22. #ifdef __pyr__
  23. #include <va-pyr.h>
  24. #else
  25. #ifdef __clipper__
  26. #include <va-clipper.h>
  27. #else
  28. #ifdef __m88k__
  29. #include <va-m88k.h>
  30. #else
  31. #if defined(__hppa__) || defined(hp800)
  32. #include <va-pa.h>
  33. #else
  34. #ifdef __i960__
  35. #include <va-i960.h>
  36. #else
  37. #ifdef __alpha__
  38. #include <va-alpha.h>
  39. #else
  40.  
  41. #ifdef __NeXT__
  42.  
  43. /* On Next, erase any vestiges of stdarg.h.  */
  44.  
  45. #ifdef _ANSI_STDARG_H_
  46. #define _VA_LIST_
  47. #endif
  48. #define _ANSI_STDARG_H_ 
  49.  
  50. #undef va_alist
  51. #undef va_dcl
  52. #undef va_list
  53. #undef va_start
  54. #undef va_end
  55. #undef __va_rounded_size
  56. #undef va_arg
  57. #endif  /* __NeXT__ */
  58.  
  59. /* In GCC version 2, we want an ellipsis at the end of the declaration
  60.    of the argument list.  GCC version 1 can't parse it.  */
  61.  
  62. #if __GNUC__ > 1
  63. #define __va_ellipsis ...
  64. #else
  65. #define __va_ellipsis
  66. #endif
  67.  
  68. /* These macros implement traditional (non-ANSI) varargs
  69.    for GNU C.  */
  70.  
  71. #define va_alist  __builtin_va_alist
  72. /* The ... causes current_function_varargs to be set in cc1.  */
  73. #define va_dcl    int __builtin_va_alist; __va_ellipsis
  74.  
  75. /* Define __gnuc_va_list, just as in gstdarg.h.  */
  76.  
  77. #ifndef __GNUC_VA_LIST
  78. #define __GNUC_VA_LIST
  79. #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX)
  80. typedef char *__gnuc_va_list;
  81. #else
  82. typedef void *__gnuc_va_list;
  83. #endif
  84. #endif
  85.  
  86. #define va_start(AP)  AP=(char *) &__builtin_va_alist
  87.  
  88. #define va_end(AP)
  89.  
  90. #define __va_rounded_size(TYPE)  \
  91.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  92.  
  93. #if defined (__arm__) || defined (__i386__) || defined (__ns32000__) || defined (__vax__)
  94. /* This is for little-endian machines; small args are padded upward.  */
  95. #define va_arg(AP, TYPE)                        \
  96.  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),    \
  97.   *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
  98. #else /* big-endian */
  99. /* This is for big-endian machines; small args are padded downward.  */
  100. #define va_arg(AP, TYPE)                        \
  101.  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),    \
  102.   *((TYPE *) (void *) ((char *) (AP) - ((sizeof (TYPE) < 4        \
  103.                      ? sizeof (TYPE)        \
  104.                      : __va_rounded_size (TYPE))))))
  105. #endif /* big-endian */
  106.  
  107. #endif /* not alpha */
  108. #endif /* not i960 */
  109. #endif /* not hppa */
  110. #endif /* not m88k */
  111. #endif /* not clipper */
  112. #endif /* not pyr */
  113. #endif /* not i860 */
  114. #endif /* not mips */
  115. #endif /* not spur */
  116. #endif /* not sparc */
  117. #endif /* not _VARARGS_H */
  118.  
  119. /* Define va_list from __gnuc_va_list.  */
  120.  
  121. #ifdef _HIDDEN_VA_LIST  /* On OSF1, this means varargs.h is "half-loaded".  */
  122. #undef _VA_LIST
  123. #endif
  124.  
  125. #ifdef __svr4__
  126. /* SVR4.2 uses _VA_LIST for an internal alias for va_list,
  127.    so we must avoid testing it and setting it here.
  128.    SVR4 uses _VA_LIST as a flag in stdarg.h, but we should
  129.    have no conflict with that.  */
  130. #ifndef _VA_LIST_
  131. #define _VA_LIST_
  132. #ifdef __i860__
  133. #ifndef _VA_LIST
  134. #define _VA_LIST va_list
  135. #endif
  136. #endif /* __i860__ */
  137. typedef __gnuc_va_list va_list;
  138. #endif /* _VA_LIST_ */
  139.  
  140. #else /* not __svr4__ */
  141.  
  142. /* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
  143.    But on BSD NET2 we must not test or define or undef it.
  144.    (Note that the comments in NET 2's ansi.h
  145.    are incorrect for _VA_LIST_--see stdio.h!)  */
  146. #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____)
  147. /* The macro _VA_LIST is used in SCO Unix 3.2.  */
  148. #ifndef _VA_LIST
  149. /* The macro _VA_LIST_T_H is used in the Bull dpx2  */
  150. #ifndef _VA_LIST_T_H
  151. #define _VA_LIST_T_H
  152. #if !(defined (__BSD_NET2__) || defined (____386BSD____))
  153. #define _VA_LIST_
  154. #endif
  155. #define _VA_LIST
  156. typedef __gnuc_va_list va_list;
  157. #endif /* not _VA_LIST_T_H */
  158. #endif /* not _VA_LIST */
  159. #endif /* not _VA_LIST_ */
  160.  
  161. #endif /* not __svr4__ */
  162.  
  163. /* The next BSD release (if there is one) wants this symbol to be
  164.    undefined instead of _VA_LIST_.  */
  165. #ifdef _BSD_VA_LIST
  166. #undef _BSD_VA_LIST
  167. #endif
  168.  
  169. #endif /* __GNUC__ */
  170.