stdarg.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* $OpenBSD: stdarg.h,v 1.8 2011/03/02 18:31:58 matthew 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 _STDARG_H_
  18. #define _STDARG_H_
  19. #include <sys/cdefs.h>
  20. #if (defined(__GNUC__) && __GNUC__ >= 3) || defined(__PCC__)
  21. /* Define __gnuc_va_list. */
  22. #ifndef __GNUC_VA_LIST
  23. #define __GNUC_VA_LIST
  24. typedef __builtin_va_list __gnuc_va_list;
  25. #endif
  26. /* Note that the type used in va_arg is supposed to match the
  27. actual type **after default promotions**.
  28. Thus, va_arg (..., short) is not valid. */
  29. #define va_start(ap, last) __builtin_va_start((ap), last)
  30. #define va_end(ap) __builtin_va_end((ap))
  31. #define va_arg(ap, type) __builtin_va_arg((ap), type)
  32. #define __va_copy(dst, src) __builtin_va_copy((dst),(src))
  33. typedef __gnuc_va_list va_list;
  34. #else
  35. #include <machine/stdarg.h>
  36. #endif
  37. #if __ISO_C_VISIBLE >= 1999
  38. #define va_copy(dst, src) __va_copy((dst), (src))
  39. #endif
  40. #endif /* not _STDARG_H_ */