Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/mips/include Fix va_arg() problem when adjusting ar...



details:   https://anonhg.NetBSD.org/src/rev/e5ddddeb27ed
branches:  trunk
changeset: 513911:e5ddddeb27ed
user:      simonb <simonb%NetBSD.org@localhost>
date:      Fri Aug 17 07:15:16 2001 +0000

description:
Fix va_arg() problem when adjusting argument pointer when a structure is
passed which is larger than an int but has int alignment.  As well as
fixing the described problem, this is the same way it is handled in the
Irix and Ultrix header files.

Problem and suggested solution by Uros Prestor in port-mips mailling
list.

diffstat:

 sys/arch/mips/include/stdarg.h |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r b3385f643f30 -r e5ddddeb27ed sys/arch/mips/include/stdarg.h
--- a/sys/arch/mips/include/stdarg.h    Fri Aug 17 07:15:12 2001 +0000
+++ b/sys/arch/mips/include/stdarg.h    Fri Aug 17 07:15:16 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stdarg.h,v 1.19 2000/02/19 09:23:44 mycroft Exp $      */
+/*     $NetBSD: stdarg.h,v 1.20 2001/08/17 07:15:16 simonb Exp $       */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -41,6 +41,10 @@
 #include <machine/ansi.h>
 #include <sys/featuretest.h>
 
+#if defined(_MIPS_BSD_API) && _MIPS_BSD_API != _MIPS_BSD_API_LP32
+#error stdargs.h does not work with 64 bit ABIs
+#endif
+
 typedef _BSD_VA_LIST_  va_list;
 
 #ifdef __lint__
@@ -53,15 +57,15 @@
 #if BYTE_ORDER == LITTLE_ENDIAN
 #define        va_arg(ap, T)                                                   \
        (((T *)(                                                        \
-           (ap) += (/*CONSTCOND*/ sizeof(T) <= sizeof(int)             \
+           (ap) += (/*CONSTCOND*/ __alignof__(T) <= sizeof(int)        \
                ? sizeof(int) : ((long)(ap) & 4) + sizeof(T)),          \
-           (ap) - (/*CONSTCOND*/ sizeof(T) <= sizeof(int)              \
+           (ap) - (/*CONSTCOND*/ __alignof__(T) <= sizeof(int)         \
                ? sizeof(int) : sizeof(T))                              \
        ))[0])
 #else
 #define        va_arg(ap, T)                                                   \
        (((T *)(                                                        \
-           (ap) += (/*CONSTCOND*/ sizeof(T) <= sizeof(int)             \
+           (ap) += (/*CONSTCOND*/ __alignof__(T) <= sizeof(int)        \
                ? sizeof(int) : ((long)(ap) & 4) + sizeof(T))           \
        ))[-1])
 #endif



Home | Main Index | Thread Index | Old Index