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