For GCC3 and beyond, use the __builtin_va_* types and functions to

deal with variable argument lists.
This commit is contained in:
matt 2005-04-14 20:06:15 +00:00
parent e8e89790f0
commit 1b5520b3d6
2 changed files with 29 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ansi.h,v 1.15 2003/08/07 16:28:13 agc Exp $ */
/* $NetBSD: ansi.h,v 1.16 2005/04/14 20:06:15 matt Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -34,6 +34,7 @@
#ifndef _ANSI_H_
#define _ANSI_H_
#include <sys/cdefs.h>
#include <machine/int_types.h>
/*
@ -50,7 +51,11 @@
#define _BSD_SIZE_T_ unsigned int /* sizeof() */
#define _BSD_SSIZE_T_ int /* byte count or error */
#define _BSD_TIME_T_ long /* time() */
#if __GNUC_PREREQ__(3,0)
#define _BSD_VA_LIST_ __builtin_va_list /* va_list */
#else
#define _BSD_VA_LIST_ char * /* va_list */
#endif
#define _BSD_CLOCKID_T_ int /* clockid_t */
#define _BSD_TIMER_T_ int /* timer_t */
#define _BSD_SUSECONDS_T_ int /* suseconds_t */

View File

@ -1,4 +1,4 @@
/* $NetBSD: stdarg.h,v 1.21 2003/08/07 16:28:15 agc Exp $ */
/* $NetBSD: stdarg.h,v 1.22 2005/04/14 20:06:15 matt Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -40,8 +40,20 @@
typedef _BSD_VA_LIST_ va_list;
#ifdef __lint__
#define __builtin_next_arg(t) ((t) ? 0 : 0)
#endif
#define va_start(ap, last) ((ap) = *(va_list *)0)
#define va_arg(ap, type) (*(type *)(void *)&(ap))
#define va_end(ap)
#define __va_copy(dest, src) ((dest) = (src))
#elif __GNUC_PREREQ__(3,0)
#define va_start(ap, last) __builtin_va_start(ap, last)
#define va_end(ap) __builtin_va_end(ap)
#define va_arg(ap, type) __builtin_va_arg(ap, type)
#define __va_copy(dest, src) __builtin_va_copy(dest, src)
#else
#define __va_size(type) \
(((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
@ -55,13 +67,16 @@ typedef _BSD_VA_LIST_ va_list;
sizeof(type) != __va_size(type) ? \
sizeof(type) : __va_size(type))))
#if !defined(_ANSI_SOURCE) && \
(defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
defined(_NETBSD_SOURCE))
#define va_copy(dest, src) \
#define __va_copy(dest, src) \
((dest) = (src))
#endif
#define va_end(ap)
#endif
#if !defined(_ANSI_SOURCE) && \
(!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) || \
defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L)
#define va_copy(dest, src) __va_copy(dest, src)
#endif
#endif /* !_M68K_STDARG_H_ */