home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / d / djdev108.zip / INCLUDE / VARARGS.H < prev   
C/C++ Source or Header  |  1992-03-09  |  2KB  |  75 lines

  1. /* This file may have been modified by DJ Delorie (Jan 1991).  If so,
  2. ** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave,
  3. ** Rochester NH, 03867-2954, USA.
  4. */
  5.  
  6. #if 0
  7. #include <stdarg.h>
  8. #else
  9.  
  10. #ifndef __GNUC__
  11. /* Use the system's macros with the system's compiler.  */
  12. #include <varargs.h>
  13. #else
  14. #ifdef __spur__
  15. #include "va-spur.h"
  16. #else
  17. #ifdef __mips__
  18. #include "va-mips.h"
  19. #else
  20. #ifdef __i860__
  21. #include "va-i860.h"
  22. #else
  23. #ifdef __pyr__
  24. #include "va-pyr.h"
  25. #else
  26.  
  27. #ifdef __NeXT__
  28.  
  29. /* On Next, erase any vestiges of stdarg.h.  */
  30.  
  31. #undef va_alist
  32. #undef va_dcl
  33. #undef va_list
  34. #undef va_start
  35. #undef va_end
  36. #undef __va_rounded_size
  37. #undef va_arg
  38.  
  39. /* Record that varargs.h is defined; this turns off stdarg.h.  */
  40.  
  41. #ifndef _VARARGS_H
  42. #define _VARARGS_H
  43. #endif
  44. #endif  /* __NeXT__ */
  45.  
  46. /* These macros implement traditional (non-ANSI) varargs
  47.    for GNU C.  */
  48.  
  49. #define va_alist  __builtin_va_alist
  50. #define va_dcl    int __builtin_va_alist;
  51. #define va_list   char *
  52.  
  53. #ifdef __sparc__
  54. #define va_start(AP)                                            \
  55.  (__builtin_saveregs (),                                        \
  56.   AP = ((void *) &__builtin_va_alist))
  57. #else
  58. #define va_start(AP)  AP=(char *) &__builtin_va_alist
  59. #endif
  60. #define va_end(AP)
  61.  
  62. #define __va_rounded_size(TYPE)  \
  63.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  64.  
  65. #define va_arg(AP, TYPE)                                                \
  66.  (AP += __va_rounded_size (TYPE),                                       \
  67.   *((TYPE *) (AP - __va_rounded_size (TYPE))))
  68.  
  69. #endif /* not pyr */
  70. #endif /* not i860 */
  71. #endif /* not mips */
  72. #endif /* not spur */
  73. #endif /* __GNUC__ */
  74. #endif /* 1 */
  75.