home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / languages / gnuawk / src / varargs.h < prev    next >
C/C++ Source or Header  |  1990-09-27  |  1KB  |  59 lines

  1. /* These macros implement traditional (non-ANSI) varargs for GNU C.
  2.  *
  3.  * Amiga/Lattice support by Robert. L. Pyron, 900927
  4.  *
  5.  */
  6.  
  7. #if defined(AMIGA) && defined(LATTICE)
  8. #ifndef    VARARGS_H
  9. #define VARARGS_H
  10. #define va_alist    __builtin_va_alist
  11. #define va_dcl        int __builtin_va_alist;
  12. #define va_list        char *
  13. #define va_start(AP)    AP=(char *) &__builtin_va_alist
  14. #define va_arg(AP,TYPE) *((TYPE *)( (AP+=sizeof(TYPE)) - sizeof(TYPE) ))
  15. #define va_end(AP)
  16. #endif /* VARARGS_H */
  17. #else
  18.  
  19. #ifndef __GNUC__
  20. /* Use the system's macros with the system's compiler.  */
  21. #include <varargs.h>
  22. #else
  23. #ifdef __spur__
  24. #include "va-spur.h"
  25. #else
  26. #ifdef __mips__
  27. #include "va-mips.h"
  28. #else
  29.  
  30. /* These macros implement traditional (non-ANSI) varargs
  31.    for GNU C.  */
  32.  
  33. #define va_alist  __builtin_va_alist
  34. #define va_dcl    int __builtin_va_alist;
  35. #define va_list   char *
  36.  
  37. #ifdef __sparc__
  38. #define va_start(AP)                         \
  39.  (__builtin_saveregs (),                    \
  40.   AP = ((void *) &__builtin_va_alist))
  41. #else
  42. #define va_start(AP)  AP=(char *) &__builtin_va_alist
  43. #endif
  44. #define va_end(AP)
  45.  
  46. #define __va_rounded_size(TYPE)  \
  47.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  48.  
  49. #define va_arg(AP, TYPE)                        \
  50.  (AP += __va_rounded_size (TYPE),                    \
  51.   *((TYPE *) (AP - __va_rounded_size (TYPE))))
  52.  
  53. #endif /* not mips */
  54. #endif /* not spur */
  55. #endif /* __GNUC__ */
  56.  
  57. #endif /* AMIGA && LATTICE */
  58.  
  59.