stdarg.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * @(#) stdarg.h 1.2 91/11/30 21:10:39
  3. *
  4. * Sample stdarg.h file for use with the unproto filter.
  5. *
  6. * This file serves two purposes.
  7. *
  8. * 1 - As an include file for use with ANSI-style C source that implements
  9. * variadic functions.
  10. *
  11. * 2 - To configure the unproto filter itself. If the _VA_ALIST_ macro is
  12. * defined, its value will appear in the place of the "..." in argument
  13. * lists of variadic function *definitions* (not declarations).
  14. *
  15. * Compilers that pass arguments via the stack can use the default code at the
  16. * end of this file (this usually applies for the VAX, MC68k and 80*86
  17. * architectures).
  18. *
  19. * RISC-based systems often need special tricks. An example of the latter is
  20. * given for the SPARC architecture. Read your /usr/include/varargs.h for
  21. * more information.
  22. *
  23. * You can use the varargs.c program provided with the unproto package to
  24. * verify that the stdarg.h file has been set up correctly.
  25. */
  26. #ifndef __STDARG_H
  27. #define __STDARG_H
  28. #ifdef sparc
  29. # define _VA_ALIST_ "__builtin_va_alist"
  30. typedef char *va_list;
  31. # define va_start(ap, p) (ap = (char *) &__builtin_va_alist)
  32. # define va_arg(ap, type) ((type *) __builtin_va_arg_incr((type *) ap))[0]
  33. # define va_end(ap)
  34. #else /* vax, mc68k, 80*86 */
  35. typedef char *va_list;
  36. # define va_start(ap, p) (ap = (char *) (&(p)+1))
  37. # define va_arg(ap, type) ((type *) (ap += sizeof(type)))[-1]
  38. # define va_end(ap)
  39. #endif
  40. #endif /* __STDARG_H */
  41. #if __FIRST_ARG_IN_AX__
  42. #error First arg is in a register, stdarg.h cannot take its address
  43. #endif