summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include/varargs.h
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-06-21 16:20:55 +0000
committerbde <bde@FreeBSD.org>1997-06-21 16:20:55 +0000
commitba2ba2591f546e080bc813c96d09630c46505419 (patch)
tree04349fc4fc31942b96495739635d6034515dea78 /sys/amd64/include/varargs.h
parent793295a94d96fd8954918d322646bb6dd2219c2d (diff)
downloadFreeBSD-src-ba2ba2591f546e080bc813c96d09630c46505419.zip
FreeBSD-src-ba2ba2591f546e080bc813c96d09630c46505419.tar.gz
Fixed va_arg() to work for small args (as in stdarg.h).
Diffstat (limited to 'sys/amd64/include/varargs.h')
-rw-r--r--sys/amd64/include/varargs.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/sys/amd64/include/varargs.h b/sys/amd64/include/varargs.h
index 10b5787..5661462 100644
--- a/sys/amd64/include/varargs.h
+++ b/sys/amd64/include/varargs.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)varargs.h 8.2 (Berkeley) 3/22/94
- * $Id: varargs.h,v 1.5 1997/02/22 09:35:22 peter Exp $
+ * $Id: varargs.h,v 1.6 1997/02/28 07:12:34 bde Exp $
*/
#ifndef _VARARGS_H_
@@ -44,6 +44,9 @@
typedef char *va_list;
+#define __va_size(type) \
+ (((sizeof(type) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
+
#ifdef __GNUC__
#define va_alist __builtin_va_alist
#endif
@@ -54,16 +57,10 @@ typedef char *va_list;
#endif
#define va_start(ap) \
- ap = (char *)&va_alist
+ ((ap) = (va_list)&va_alist)
-#ifdef KERNEL
-#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type)))[-1]
-#else
#define va_arg(ap, type) \
- ((type *)(ap += sizeof(type) < sizeof(int) ? \
- (abort(), 0) : sizeof(type)))[-1]
-#endif
+ (*(type *)((ap) += __va_size(type), (ap) - __va_size(type)))
#define va_end(ap)
OpenPOWER on IntegriCloud