home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / va-spur.h < prev    next >
C/C++ Source or Header  |  1991-04-24  |  2KB  |  56 lines

  1. /*  varargs.h for SPUR */
  2.  
  3. /* NB.  This is NOT the definition needed for the new ANSI proposed
  4.    standard */
  5.  
  6.  
  7. struct __va_struct { char __regs[20]; };
  8.  
  9. #define va_alist __va_regs, __va_stack
  10.  
  11. /* In GCC version 2, we want an ellipsis at the end of the declaration
  12.    of the argument list.  GCC version 1 can't parse it.  */
  13.  
  14. #if __GNUC__ > 1
  15. #define __va_ellipsis ...
  16. #else
  17. #define __va_ellipsis
  18. #endif
  19.  
  20. /* The ... causes current_function_varargs to be set in cc1.  */
  21. #define va_dcl struct __va_struct __va_regs; int __va_stack; 
  22.  
  23. typedef struct {
  24.     int __pnt;
  25.     char *__regs;
  26.     char *__stack;
  27. } va_list;
  28.  
  29. #define va_start(pvar) \
  30.      ((pvar).__pnt = 0, (pvar).__regs = __va_regs.__regs, \
  31.       (pvar).__stack = (char *) &__va_stack)
  32. #define va_end(pvar)
  33.  
  34. #define va_arg(pvar,type)  \
  35.     ({  type __va_result; \
  36.         if ((pvar).__pnt >= 20) { \
  37.            __va_result = *( (type *) ((pvar).__stack + (pvar).__pnt - 20)); \
  38.        (pvar).__pnt += (sizeof(type) + 7) & ~7; \
  39.     } \
  40.     else if ((pvar).__pnt + sizeof(type) > 20) { \
  41.        __va_result = * (type *) (pvar).__stack; \
  42.        (pvar).__pnt = 20 + ( (sizeof(type) + 7) & ~7); \
  43.     } \
  44.     else if (sizeof(type) == 8) { \
  45.        union {double d; int i[2];} __u; \
  46.        __u.i[0] = *(int *) ((pvar).__regs + (pvar).__pnt); \
  47.        __u.i[1] = *(int *) ((pvar).__regs + (pvar).__pnt + 4); \
  48.        __va_result = * (type *) &__u; \
  49.        (pvar).__pnt += 8; \
  50.     } \
  51.     else { \
  52.        __va_result = * (type *) ((pvar).__regs + (pvar).__pnt); \
  53.        (pvar).__pnt += (sizeof(type) + 3) & ~3; \
  54.     } \
  55.     __va_result; })
  56.