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 - Exterminate haunted evil soul of MIP...



details:   https://anonhg.NetBSD.org/src/rev/e8c152832b93
branches:  trunk
changeset: 473577:e8c152832b93
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Tue Jun 08 00:46:38 1999 +0000

description:
- Exterminate haunted evil soul of MIPS va_arg().  Verified OK with
either endian.  Not a perfect solution which would be revealed on
a certain condition when va_arg() is applied to magical struct
arguments passed by value.  format_bytes() is now saved.  With the
help from Noriyuki Soda and Masanari Tsubai.

diffstat:

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

diffs (43 lines):

diff -r 5a2610a66b0f -r e8c152832b93 sys/arch/mips/include/stdarg.h
--- a/sys/arch/mips/include/stdarg.h    Mon Jun 07 22:33:53 1999 +0000
+++ b/sys/arch/mips/include/stdarg.h    Tue Jun 08 00:46:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stdarg.h,v 1.16 1999/05/03 16:30:33 christos Exp $     */
+/*     $NetBSD: stdarg.h,v 1.17 1999/06/08 00:46:38 nisimura Exp $     */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -46,21 +46,22 @@
 #define __builtin_next_arg(t) ((t) ? 0 : 0)
 #endif
 
-#define        __va_size(type) \
-       (((sizeof(type) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
-
 #define        va_start(ap, last) \
        ((ap) = (va_list)__builtin_next_arg(last))
 
-#ifdef _KERNEL
-#define        va_arg(ap, type) \
-       ((type *)(ap += sizeof(type)))[-1]
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define        va_arg(ap, T)                                                   \
+       (((T *)(                                                        \
+           (ap) += (sizeof(T) <= sizeof(int)                           \
+               ? sizeof(int) : ((long)(ap) & 4) + sizeof(T)),          \
+           (ap) - (sizeof(T) <= sizeof(int) ? sizeof(int) : sizeof(T)) \
+       ))[0])
 #else
-#define        va_arg(ap, type) \
-       ((type *)(ap += sizeof(type) == sizeof(int) ? sizeof(type) : \
-               sizeof(type) > sizeof(int) ? \
-               (-(int)(ap) & (sizeof(type) - 1)) + sizeof(type) : \
-               (abort(), 0)))[-1]
+#define        va_arg(ap, T)                                                   \
+       (((T *)(                                                        \
+           (ap) += (sizeof(T) <= sizeof(int)                           \
+               ? sizeof(int) : ((long)(ap) & 4) + sizeof(T))           \
+       ))[-1])
 #endif
 
 #define        va_end(ap)



Home | Main Index | Thread Index | Old Index