home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / va-sparc.h < prev    next >
Text File  |  1991-04-24  |  2KB  |  46 lines

  1. /* This is just like the default gvarargs.h
  2.    except for differences decribed below.  */
  3.  
  4. /* va_list is a structure instead of a char*.  */
  5. typedef struct __va_ctl
  6. {
  7.   char *__stack;   /* Current pointer for fetching args.  */
  8.   char *__beg;     /* Pointer to position of first saved register arg.  */
  9. } va_list;
  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. #define va_alist  __builtin_va_alist
  21. /* The ... causes current_function_varargs to be set in cc1.  */
  22. #define va_dcl    int __builtin_va_alist; __va_ellipsis
  23.  
  24. /* The difference is to store the stack address in both components
  25.    instead of in AP itself.  */
  26. #define va_start(AP)                         \
  27.  (__builtin_saveregs (),                    \
  28.  (AP).__beg = (AP).__stack = ((char *) &__builtin_va_alist))
  29. #define va_end(pvar)
  30.  
  31. #define __va_rounded_size(TYPE)  \
  32.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  33.  
  34. /* The difference is that, for an aggregate that is not word-aligned,
  35.    we advance (pvar).__stack to the first non-reg slot.  */
  36. #define va_arg(pvar,TYPE)                    \
  37. ({ TYPE __va_temp;                        \
  38.    ((__builtin_classify_type (__va_temp) < 12            \
  39.      || __alignof__ __va_temp >= 4)                \
  40.     ? ((pvar).__stack += __va_rounded_size (TYPE),        \
  41.        *((TYPE *) ((pvar).__stack - __va_rounded_size (TYPE))))    \
  42.     : ((((pvar).__stack - (pvar).__beg < 24)            \
  43.     ? (pvar).__stack = (pvar).__beg + 24 : 0),        \
  44.        (pvar).__stack += __va_rounded_size (TYPE),        \
  45.        *((TYPE *) ((pvar).__stack - __va_rounded_size (TYPE)))));})
  46.