Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/arch/mips Pullup fixes from matt-nb5-mips64.



details:   https://anonhg.NetBSD.org/src/rev/d43e57e6c117
branches:  trunk
changeset: 757540:d43e57e6c117
user:      matt <matt%NetBSD.org@localhost>
date:      Fri Sep 03 17:22:51 2010 +0000

description:
Pullup fixes from matt-nb5-mips64.
This makes setjmp/longjmp work again.

diffstat:

 lib/libc/arch/mips/gen/Makefile.inc |  11 +++++++++--
 lib/libc/arch/mips/gen/_setjmp.S    |  16 ++++++++--------
 lib/libc/arch/mips/gen/flt_rounds.c |  11 ++++++++---
 lib/libc/arch/mips/gen/longjmp.c    |   7 +++++--
 lib/libc/arch/mips/gen/setjmp.S     |  10 ++++++----
 lib/libc/arch/mips/sys/cerror.S     |  13 +++++++------
 6 files changed, 43 insertions(+), 25 deletions(-)

diffs (268 lines):

diff -r 7cab14572391 -r d43e57e6c117 lib/libc/arch/mips/gen/Makefile.inc
--- a/lib/libc/arch/mips/gen/Makefile.inc       Fri Sep 03 14:32:50 2010 +0000
+++ b/lib/libc/arch/mips/gen/Makefile.inc       Fri Sep 03 17:22:51 2010 +0000
@@ -1,6 +1,10 @@
-#      $NetBSD: Makefile.inc,v 1.30 2009/12/14 01:07:42 matt Exp $
+#      $NetBSD: Makefile.inc,v 1.31 2010/09/03 17:22:51 matt Exp $
 
+.if ${MKSOFTFLOAT} == "no"
 SRCS+= fabs.S ldexp.S modf.S
+.else
+SRCS+= fabs_ieee754.c ldexp_ieee754.c modf_ieee754.c
+.endif
 
 # Common ieee754 constants and functions
 SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c
@@ -11,9 +15,12 @@
 SRCS+= signbitf_ieee754.c signbitd_ieee754.c
 
 SRCS+= nanf.c
+SRCS+= flt_rounds.c
 
-SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
+.if ${MKSOFTFLOAT} == "no"
+SRCS+= fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
        fpsetround.c fpsetsticky.c
+.endif
 
 SRCS+= setjmp.S longjmp.c
 SRCS+= _setjmp.S
diff -r 7cab14572391 -r d43e57e6c117 lib/libc/arch/mips/gen/_setjmp.S
--- a/lib/libc/arch/mips/gen/_setjmp.S  Fri Sep 03 14:32:50 2010 +0000
+++ b/lib/libc/arch/mips/gen/_setjmp.S  Fri Sep 03 17:22:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _setjmp.S,v 1.21 2009/12/14 01:07:42 matt Exp $        */
+/*     $NetBSD: _setjmp.S,v 1.22 2010/09/03 17:22:51 matt Exp $        */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -46,7 +46,7 @@
 #if 0
        RCSID("from: @(#)_setjmp.s      8.1 (Berkeley) 6/4/93")
 #else
-       RCSID("$NetBSD: _setjmp.S,v 1.21 2009/12/14 01:07:42 matt Exp $")
+       RCSID("$NetBSD: _setjmp.S,v 1.22 2010/09/03 17:22:51 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -68,7 +68,6 @@
        REG_LI  v0, 0xACEDBADE                  # sigcontext magic number
        REG_S   ra, _OFFSETOF_SC_PC(a0)         # sc_pc = return address
        REG_S   v0, _OFFSETOF_SC_REGS(a0)       #   saved in sc_regs[0]
-       REG_S   a1, _OFFSETOF_SC_REGS_V0(a0)    # save return value
        REG_S   s0, _OFFSETOF_SC_REGS_S0(a0)
        REG_S   s1, _OFFSETOF_SC_REGS_S1(a0)
        REG_S   s2, _OFFSETOF_SC_REGS_S2(a0)
@@ -82,13 +81,14 @@
 #if defined(__mips_n32) || defined(__mips_n64)
        REG_S   gp, _OFFSETOF_SC_REGS_GP(a0)    # newabi gp is callee-saved
 #endif
-       cfc1    v0, $31                         # too bad cant check if FP used
        /*
         * In N32, FP registers F20, F22, F24, F26, F28, F30 are callee-saved.
         * In N64, FP registers F23 .. F31 are callee-saved.
         * In O32, FP registers F20 .. F23 are callee-saved.
         */
 #ifndef SOFTFLOAT_FOR_GCC
+       cfc1    v0, $31                         # too bad cant check if FP used
+       INT_S   v0, _OFFSETOF_SC_FPREGS_FCSR(a0)
 #if defined(__mips_n64) || defined(__mips_n32)
        FP_S    $f30, _OFFSETOF_SC_FPREGS_F30(a0)
        FP_S    $f28, _OFFSETOF_SC_FPREGS_F28(a0)
@@ -110,7 +110,6 @@
        FP_S    $f31, _OFFSETOF_SC_FPREGS_F31(a0)
 #endif
 #endif /* SOFTFLOAT_FOR_GCC */
-       INT_S   v0, _OFFSETOF_SC_FPREGS_FCSR(a0)
        REG_EPILOGUE
 
        j       ra
@@ -128,6 +127,7 @@
        REG_LI          t0, 0xACEDBADE
        bne             v0, t0, botch           # jump if error
        PTR_ADDU        sp, sp, CALLFRAME_SIZ   # does not matter, sanity
+       REG_S           a1, _OFFSETOF_SC_REGS_V0(a0)    # save return value
        REG_L           s0, _OFFSETOF_SC_REGS_S0(a0)
        REG_L           s1, _OFFSETOF_SC_REGS_S1(a0)
        REG_L           s2, _OFFSETOF_SC_REGS_S2(a0)
@@ -140,16 +140,16 @@
        REG_L           gp, _OFFSETOF_SC_REGS_GP(a0)
 #endif
        # get fpu status
-       INT_L           v0, _OFFSETOF_SC_FPREGS_FCSR(a0)
        REG_L           sp, _OFFSETOF_SC_REGS_SP(a0)
        REG_L           s8, _OFFSETOF_SC_REGS_S8(a0)
+#ifndef SOFTFLOAT_FOR_GCC
+       INT_L           v0, _OFFSETOF_SC_FPREGS_FCSR(a0)
        ctc1            v0, $31
        /*
         * In N32, FP registers F20, F22, F24, F26, F28, F30 are callee-saved.
         * In N64, FP registers F23 .. F31 are callee-saved.
         * In O32, FP registers F20 .. F23 are callee-saved.
         */
-#ifndef SOFTFLOAT_FOR_GCC
 #if defined(__mips_n64) || defined(__mips_n32)
        FP_L    $f30, _OFFSETOF_SC_FPREGS_F30(a0)
        FP_L    $f28, _OFFSETOF_SC_FPREGS_F28(a0)
@@ -173,7 +173,7 @@
 #endif /* SOFTFLOAT_FOR_GCC */
 
        REG_EPILOGUE
-       REG_L   v0, _OFFSETOF_SC_REGS_V0(a0)
+       move    v0, a1                  # get return value in 1st arg
        j       ra
        nop
 
diff -r 7cab14572391 -r d43e57e6c117 lib/libc/arch/mips/gen/flt_rounds.c
--- a/lib/libc/arch/mips/gen/flt_rounds.c       Fri Sep 03 14:32:50 2010 +0000
+++ b/lib/libc/arch/mips/gen/flt_rounds.c       Fri Sep 03 17:22:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $     */
+/*     $NetBSD: flt_rounds.c,v 1.6 2010/09/03 17:22:51 matt Exp $      */
 
 /*
  * Written by J.T. Conklin, Apr 11, 1995
@@ -7,10 +7,11 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: flt_rounds.c,v 1.5 2005/12/24 23:10:08 perry Exp $");
+__RCSID("$NetBSD: flt_rounds.c,v 1.6 2010/09/03 17:22:51 matt Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <machine/float.h>
+#include <ieeefp.h>
 
 static const int map[] = {
        1,      /* round to nearest */
@@ -22,8 +23,12 @@
 int
 __flt_rounds()
 {
+#ifdef SOFTFLOAT_FOR_GCC
+       return map[fpgetround()];
+#else
        int x;
 
-       __asm("cfc1 %0,$31" : "=r" (x));
+       __asm("cfc1\t%0,$31" : "=r" (x));
        return map[x & 0x03];
+#endif
 }
diff -r 7cab14572391 -r d43e57e6c117 lib/libc/arch/mips/gen/longjmp.c
--- a/lib/libc/arch/mips/gen/longjmp.c  Fri Sep 03 14:32:50 2010 +0000
+++ b/lib/libc/arch/mips/gen/longjmp.c  Fri Sep 03 17:22:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: longjmp.c,v 1.3 2009/02/16 03:23:29 lukem Exp $        */
+/*     $NetBSD: longjmp.c,v 1.4 2010/09/03 17:22:51 matt Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
        uc.uc_link = 0;
 
        /* Save return value in context */
-       uc.uc_mcontext.__gregs[_R_V0] = val;
+       uc.uc_mcontext.__gregs[_REG_V0] = val;
 
        /* Copy saved registers */
        uc.uc_mcontext.__gregs[_REG_S0] = sc->sc_regs[_R_S0];
@@ -82,6 +82,9 @@
        uc.uc_mcontext.__gregs[_REG_S6] = sc->sc_regs[_R_S6];
        uc.uc_mcontext.__gregs[_REG_S7] = sc->sc_regs[_R_S7];
        uc.uc_mcontext.__gregs[_REG_S8] = sc->sc_regs[_R_S8];
+#if defined(__mips_n32) || defined(__mips_n64)
+       uc.uc_mcontext.__gregs[_REG_GP] = sc->sc_regs[_R_GP];
+#endif
        uc.uc_mcontext.__gregs[_REG_SP] = sc->sc_regs[_R_SP];
        uc.uc_mcontext.__gregs[_REG_RA] = sc->sc_regs[_R_RA];
        uc.uc_mcontext.__gregs[_REG_EPC] = sc->sc_pc;
diff -r 7cab14572391 -r d43e57e6c117 lib/libc/arch/mips/gen/setjmp.S
--- a/lib/libc/arch/mips/gen/setjmp.S   Fri Sep 03 14:32:50 2010 +0000
+++ b/lib/libc/arch/mips/gen/setjmp.S   Fri Sep 03 17:22:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setjmp.S,v 1.18 2009/12/14 01:07:42 matt Exp $ */
+/*     $NetBSD: setjmp.S,v 1.19 2010/09/03 17:22:51 matt Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -41,7 +41,7 @@
 #if 0
        RCSID("from: @(#)setjmp.s       8.1 (Berkeley) 6/4/93")
 #else
-       RCSID("$NetBSD: setjmp.S,v 1.18 2009/12/14 01:07:42 matt Exp $")
+       RCSID("$NetBSD: setjmp.S,v 1.19 2010/09/03 17:22:51 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -111,11 +111,13 @@
        REG_S   gp, _OFFSETOF_SC_REGS_GP(a0)
        REG_S   sp, _OFFSETOF_SC_REGS_SP(a0)
        REG_S   s8, _OFFSETOF_SC_REGS_S8(a0)
+#ifdef SOFTFLOAT_FOR_GCC
+       INT_S   zero, _OFFSETOF_SC_FPUSED(a0)   # sc_fpused = 0
+#else
        li      v0, 1                           # be nice if we could tell
        INT_S   v0, _OFFSETOF_SC_FPUSED(a0)     # sc_fpused = 1
        cfc1    v0, $31
        INT_S   v0, _OFFSETOF_SC_FPREGS_FCSR(a0)
-#ifndef SOFTFLOAT_FOR_GCC
 #if defined(__mips_o32) || defined(__mips_o64) || defined(__mips_n32)
        FP_S    $f20, _OFFSETOF_SC_FPREGS_F20(a0)
        FP_S    $f22, _OFFSETOF_SC_FPREGS_F22(a0)
@@ -138,8 +140,8 @@
 #endif
 #endif /* SOFTFLOAT_FOR_GCC */
        REG_EPILOGUE
+       move    v0, zero
        j       ra
-       move    v0, zero
 
 botch:
        jal     _C_LABEL(abort)
diff -r 7cab14572391 -r d43e57e6c117 lib/libc/arch/mips/sys/cerror.S
--- a/lib/libc/arch/mips/sys/cerror.S   Fri Sep 03 14:32:50 2010 +0000
+++ b/lib/libc/arch/mips/sys/cerror.S   Fri Sep 03 17:22:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cerror.S,v 1.14 2009/12/14 01:07:42 matt Exp $ */
+/*     $NetBSD: cerror.S,v 1.15 2010/09/03 17:22:52 matt Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
        RCSID("from: @(#)cerror.s       8.1 (Berkeley) 6/16/93")
 #else
-       RCSID("$NetBSD: cerror.S,v 1.14 2009/12/14 01:07:42 matt Exp $")
+       RCSID("$NetBSD: cerror.S,v 1.15 2010/09/03 17:22:52 matt Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -47,22 +47,23 @@
 NESTED_NOPROFILE(__cerror, CALLFRAME_SIZ, ra)
        .mask   0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ)
        PIC_PROLOGUE(__cerror)
-       PTR_SUBU        sp, sp, CALLFRAME_SIZ
+       PTR_SUBU        sp, CALLFRAME_SIZ
        PTR_S           ra, CALLFRAME_RA(sp)
        INT_S           v0, CALLFRAME_S0(sp)    # save errno value
 
        SAVE_GP(CALLFRAME_GP)
 
        PTR_LA          t9, _C_LABEL(__errno)   # locate address of errno
-       jalr            t9
+       RESTORE_GP64                            # restore GP (from t3)
+       jalr            t9                      # __errno()
 
        INT_L           t0, CALLFRAME_S0(sp)
        PTR_L           ra, CALLFRAME_RA(sp)
        INT_S           t0, 0(v0)               # update errno value
-       PTR_ADDU        sp, sp, CALLFRAME_SIZ
+       PTR_ADDU        sp, CALLFRAME_SIZ
        li              v0, -1
        li              v1, -1
-       PIC_RETURN()
+       j               ra                      # GP has been restored.
 END(__cerror)
 #else          
        .globl  _C_LABEL(errno)



Home | Main Index | Thread Index | Old Index