home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / pgccgcc.zip / emx / include.new / stdarg.h < prev    next >
C/C++ Source or Header  |  1998-04-28  |  2KB  |  65 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. /* Define __gnuc_va_list.  */
  15.  
  16. #ifndef __GNUC_VA_LIST
  17.  
  18. #  define __GNUC_VA_LIST
  19.    typedef void *__gnuc_va_list;
  20.  
  21. #  ifndef _VA_LIST
  22. #    define _VA_LIST
  23.      typedef __gnuc_va_list va_list;
  24. #  endif
  25.  
  26. #endif
  27.  
  28. /* Define the standard macros for the user,
  29.    if this invocation was from the user program.  */
  30. #ifdef _STDARG_H
  31.  
  32. /* Amount of space required in an argument list for an arg of type TYPE.
  33.    TYPE may alternatively be an expression whose type is used.  */
  34.  
  35. #define __va_rounded_size(TYPE)  \
  36.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  37.  
  38. #define va_start(AP, LASTARG)                         \
  39.  (AP = ((__gnuc_va_list) __builtin_next_arg (LASTARG)))
  40.  
  41. #undef va_end
  42. #define va_end(AP)    ((void)0)
  43.  
  44. /* We cast to void * and then to TYPE * because this avoids
  45.    a warning about increasing the alignment requirement.  */
  46.  
  47. #define va_arg(AP, TYPE)                        \
  48.  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),    \
  49.   *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
  50.  
  51. /* Copy __gnuc_va_list into another variable of this type.  */
  52. #define __va_copy(dest, src) (dest) = (src)
  53.  
  54. /* Define va_list, if desired, from __gnuc_va_list. */
  55. /* We deliberately do not define va_list when called from
  56.    stdio.h, because ANSI C says that stdio.h is not supposed to define
  57.    va_list.  stdio.h needs to have access to that data type,
  58.    but must not use that name.  It should use the name __gnuc_va_list,
  59.    which is safe because it is reserved for the implementation.  */
  60.  
  61. #endif /* _STDARG_H */
  62.  
  63. #endif /* not _ANSI_STDARG_H_ */
  64. #endif /* not _STDARG_H */
  65.