home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / GNUSRC.Z / va-sparc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-07  |  2.9 KB  |  93 lines

  1. /* This is just like the default gvarargs.h
  2.    except for differences described below.  */
  3.  
  4. /* Define __gnuc_va_list.  */
  5.  
  6. #ifndef __GNUC_VA_LIST
  7. #define __GNUC_VA_LIST
  8.  
  9. #ifndef __svr4__
  10. /* This has to be a char * to be compatible with Sun.
  11.    i.e., we have to pass a `va_list' to vsprintf.  */
  12. typedef char * __gnuc_va_list;
  13. #else
  14. /* This has to be a void * to be compatible with Sun svr4.
  15.    i.e., we have to pass a `va_list' to vsprintf.  */
  16. typedef void * __gnuc_va_list;
  17. #endif
  18. #endif /* not __GNUC_VA_LIST */
  19.  
  20. #ifdef NeXT_PDO
  21. #define NULL_VALIST ((__gnuc_va_list)0)
  22. #endif
  23.  
  24. /* If this is for internal libc use, don't define anything but
  25.    __gnuc_va_list.  */
  26. #if defined (_STDARG_H) || defined (_VARARGS_H)
  27.  
  28. #ifdef _STDARG_H
  29.  
  30. #ifdef __GCC_NEW_VARARGS__
  31. #if defined(NeXT_PDO) && defined(va_start)
  32. #undef va_start
  33. #endif
  34. #define va_start(AP, LASTARG)    (AP = (char *) __builtin_saveregs ())
  35. #else
  36. #define va_start(AP, LASTARG)                    \
  37.   (__builtin_saveregs (), AP = ((char *) __builtin_next_arg ()))
  38. #endif
  39.  
  40. #else
  41.  
  42. #define va_alist  __builtin_va_alist
  43. #define va_dcl    int __builtin_va_alist;
  44.  
  45. #ifdef __GCC_NEW_VARARGS__
  46. #define va_start(AP)        ((AP) = (char *) __builtin_saveregs ())
  47. #else
  48. #define va_start(AP)                         \
  49.  (__builtin_saveregs (), (AP) = ((char *) &__builtin_va_alist))
  50. #endif
  51.  
  52. #endif
  53.  
  54. #ifndef va_end
  55. void va_end (__gnuc_va_list);        /* Defined in libgcc.a */
  56. #endif
  57. #define va_end(pvar)
  58.  
  59. #define __va_rounded_size(TYPE)  \
  60.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  61.  
  62. /* Avoid errors if compiling GCC v2 with GCC v1.  */
  63. #if __GNUC__ == 1
  64. #define __extension__
  65. #endif
  66.  
  67. /* RECORD_TYPE args passed using the C calling convention are
  68.    passed by invisible reference.  ??? RECORD_TYPE args passed
  69.    in the stack are made to be word-aligned; for an aggregate that is
  70.    not word-aligned, we advance the pointer to the first non-reg slot.  */
  71. /* We don't declare the union member `d' to have type TYPE
  72.    because that would lose in C++ if TYPE has a constructor.  */
  73. /* We cast to void * and then to TYPE * because this avoids
  74.    a warning about increasing the alignment requirement.
  75.    The casts to char * avoid warnings about invalid pointer arithmetic.  */
  76. #define va_arg(pvar,TYPE)                    \
  77. __extension__                            \
  78. ({ TYPE __va_temp;                        \
  79.    ((__builtin_classify_type (__va_temp) >= 12)            \
  80.     ? ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE *),    \
  81.        **(TYPE **) (void *) ((char *)(pvar) - __va_rounded_size (TYPE *))) \
  82.     : __va_rounded_size (TYPE) == 8                \
  83.     ? ({ union {char __d[sizeof (TYPE)]; int __i[2];} __u;    \
  84.      __u.__i[0] = ((int *) (void *) (pvar))[0];        \
  85.      __u.__i[1] = ((int *) (void *) (pvar))[1];        \
  86.      (pvar) = (char *)(pvar) + 8;                \
  87.      *(TYPE *) (void *) __u.__d; })                \
  88.     : ((pvar) = (char *)(pvar) + __va_rounded_size (TYPE),    \
  89.        *((TYPE *) (void *) ((char *)(pvar) - __va_rounded_size (TYPE)))));})
  90.  
  91. #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
  92.  
  93.