home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume27 / unproto / part02 / stdarg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-17  |  1.8 KB  |  50 lines

  1.  /*
  2.   * @(#) stdarg.h 1.3 92/01/15 21:53:24
  3.   * 
  4.   * Sample stdarg.h file for use with the unproto filter.
  5.   * 
  6.   * This file serves two purposes.
  7.   * 
  8.   * 1 - On systems that do not have a /usr/include/stdarg.h file, it should be
  9.   * included by C source files that implement ANSI-style variadic functions.
  10.   * 
  11.   * 2 - To configure the unprototyper itself. If the _VA_ALIST_ macro is
  12.   * defined, its value will appear in the place of the "..." at the end of
  13.   * argument lists of variadic function *definitions* (not declarations).
  14.   * 
  15.   * Compilers that always pass arguments via the stack can use the default code
  16.   * at the end of this file (this usually applies for the vax, mc68k and
  17.   * 80*86 architectures).
  18.   * 
  19.   * Special tricks are needed for compilers that pass some or all function
  20.   * arguments via registers. Examples of the latter are given for the mips
  21.   * and sparc architectures. Usually the compiler special-cases an argument
  22.   * declaration such as "va_alist" or "__builtin_va_alist". For inspiration,
  23.   * see the local /usr/include/varargs.h file.
  24.   * 
  25.   * You can use the varargs.c program provided with the unproto package to
  26.   * verify that the stdarg.h file has been set up correctly.
  27.   */
  28.  
  29. #ifdef sparc /* tested with SunOS 4.1.1 */
  30.  
  31. #define _VA_ALIST_        "__builtin_va_alist"
  32. typedef char *va_list;
  33. #define va_start(ap, p)        (ap = (char *) &__builtin_va_alist)
  34. #define va_arg(ap, type)    ((type *) __builtin_va_arg_incr((type *) ap))[0]
  35. #define va_end(ap)
  36.  
  37. #elif defined(mips) /* tested with Ultrix 4.0 and 4.2 */
  38.  
  39. #define _VA_ALIST_        "va_alist"
  40. #include <stdarg.h>        /* huh? */
  41.  
  42. #else /* vax, mc68k, 80*86 */
  43.  
  44. typedef char *va_list;
  45. #define va_start(ap, p)        (ap = (char *) (&(p)+1))
  46. #define va_arg(ap, type)    ((type *) (ap += sizeof(type)))[-1]
  47. #define va_end(ap)
  48.  
  49. #endif
  50.