home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 6 / FreshFish_September1994.bin / bbs / gnu / gcc-2.6.0-src.lha / GNU / src / amiga / gcc-2.6.0 / ginclude / va-mips.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  2.6 KB  |  85 lines

  1. /* ---------------------------------------- */
  2. /*           VARARGS  for MIPS/GNU CC       */
  3. /*                                          */
  4. /*                                          */
  5. /*                                          */
  6. /*                                          */
  7. /* ---------------------------------------- */
  8.  
  9.  
  10. /* These macros implement varargs for GNU C--either traditional or ANSU.  */
  11.  
  12. /* Define __gnuc_va_list.  */
  13.  
  14. #ifndef __GNUC_VA_LIST
  15. #define __GNUC_VA_LIST
  16. typedef char * __gnuc_va_list;
  17. #endif /* not __GNUC_VA_LIST */
  18.  
  19. /* If this is for internal libc use, don't define anything but
  20.    __gnuc_va_list.  */
  21. #if defined (_STDARG_H) || defined (_VARARGS_H)
  22.  
  23. /* In GCC version 2, we want an ellipsis at the end of the declaration
  24.    of the argument list.  GCC version 1 can't parse it.  */
  25.  
  26. #if __GNUC__ > 1
  27. #define __va_ellipsis ...
  28. #else
  29. #define __va_ellipsis
  30. #endif
  31.  
  32. #if __mips==3
  33. #define __va_rounded_size(__TYPE)  \
  34.   (((sizeof (__TYPE) + 8 - 1) / 8) * 8)
  35. #else
  36. #define __va_rounded_size(__TYPE)  \
  37.   (((sizeof (__TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  38. #endif
  39.  
  40. #ifdef _STDARG_H
  41. #define va_start(__AP, __LASTARG)    (__AP = __builtin_next_arg (__LASTARG))
  42.  
  43. #else
  44. #define va_alist  __builtin_va_alist
  45. #if __mips==3
  46. /* This assumes that `long long int' is always a 64 bit type.  */
  47. #define va_dcl    long long int __builtin_va_alist; __va_ellipsis
  48. #else
  49. #define va_dcl    int __builtin_va_alist; __va_ellipsis
  50. #endif
  51. #define va_start(__AP)  __AP = (char *) &__builtin_va_alist
  52. #endif
  53.  
  54. #ifndef va_end
  55. void va_end (__gnuc_va_list);        /* Defined in libgcc.a */
  56. #endif
  57. #define va_end(__AP)
  58.  
  59. /* We cast to void * and then to TYPE * because this avoids
  60.    a warning about increasing the alignment requirement.  */
  61. #if __mips==3
  62. #define va_arg(__AP, __type)                                    \
  63.   ((__type *) (void *) (__AP = (char *) ((((int)__AP + 8 - 1) & -8)     \
  64.                      + __va_rounded_size (__type))))[-1]
  65. #else
  66. #ifdef __MIPSEB__
  67. /* For big-endian machines.  */
  68. #define va_arg(__AP, __type)                    \
  69.   ((__AP = (char *) ((__alignof__ (__type) > 4            \
  70.               ? ((int)__AP + 8 - 1) & -8        \
  71.               : ((int)__AP + 4 - 1) & -4)        \
  72.              + __va_rounded_size (__type))),        \
  73.    *(__type *) (void *) (__AP - __va_rounded_size (__type)))
  74. #else
  75. /* For little-endian machines.  */
  76. #define va_arg(__AP, __type)                            \
  77.   ((__type *) (void *) (__AP = (char *) ((__alignof__(__type) > 4        \
  78.                       ? ((int)__AP + 8 - 1) & -8        \
  79.                       : ((int)__AP + 4 - 1) & -4)        \
  80.                      + __va_rounded_size(__type))))[-1]
  81. #endif
  82. #endif
  83.  
  84. #endif /* defined (_STDARG_H) || defined (_VARARGS_H) */
  85.