varargs.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* $OpenBSD: varargs.h,v 1.2 2004/01/03 14:55:34 espie Exp $ */
  2. /*
  3. * Copyright (c) 2003, 2004 Marc espie <espie@openbsd.org>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef _VARARGS_H_
  18. #define _VARARGS_H_
  19. #if defined(__GNUC__) && __GNUC__ >= 3
  20. /* These macros implement traditional (non-ANSI) varargs
  21. for GNU C. */
  22. #define va_alist __builtin_va_alist
  23. #define __va_ellipsis ...
  24. /* ??? We don't process attributes correctly in K&R argument context. */
  25. typedef int __builtin_va_alist_t __attribute__((__mode__(__word__)));
  26. /* ??? It would be nice to get rid of the ellipsis here. It causes
  27. current_function_varargs to be set in cc1. */
  28. #define va_dcl __builtin_va_alist_t __builtin_va_alist; ...
  29. /* Define __gnuc_va_list, just as in stdarg.h. */
  30. #ifndef __GNUC_VA_LIST
  31. #define __GNUC_VA_LIST
  32. typedef __builtin_va_list __gnuc_va_list;
  33. #endif
  34. #define va_start(v) __builtin_varargs_start((v))
  35. #define va_end __builtin_va_end
  36. #define va_arg __builtin_va_arg
  37. #define __va_copy(d,s) __builtin_va_copy((d),(s))
  38. /* Define va_list from __gnuc_va_list. */
  39. typedef __gnuc_va_list va_list;
  40. #else
  41. #include <machine/varargs.h>
  42. #endif
  43. #endif /* _VARARGS_H_ */