add nofpu subarchs to the sh arch, and properly detect compiler's fpu config
authorRich Felker <dalias@aerifal.cx>
Fri, 28 Feb 2014 04:18:42 +0000 (23:18 -0500)
committerRich Felker <dalias@aerifal.cx>
Fri, 28 Feb 2014 04:18:42 +0000 (23:18 -0500)
arch/sh/bits/fenv.h
configure
src/fenv/sh-nofpu/fenv.sub [new file with mode: 0644]
src/fenv/sheb-nofpu/fenv.sub [new file with mode: 0644]
src/setjmp/sh-nofpu/longjmp.s [new file with mode: 0644]
src/setjmp/sh-nofpu/longjmp.sub [new file with mode: 0644]
src/setjmp/sh-nofpu/setjmp.s [new file with mode: 0644]
src/setjmp/sh-nofpu/setjmp.sub [new file with mode: 0644]
src/setjmp/sheb-nofpu/longjmp.sub [new file with mode: 0644]
src/setjmp/sheb-nofpu/setjmp.sub [new file with mode: 0644]

index f454a15..7f1b8b6 100644 (file)
@@ -1,3 +1,10 @@
+#ifndef __SH_FPU_ANY__
+
+#define FE_ALL_EXCEPT 0
+#define FE_TONEAREST  0
+
+#else
+
 #define FE_TONEAREST  0
 #define FE_TOWARDZERO 1
 
@@ -8,6 +15,8 @@
 #define FE_INVALID    0x40
 #define FE_ALL_EXCEPT 0x7c
 
+#endif
+
 typedef unsigned long fexcept_t;
 
 typedef struct {
index 1a092f5..572ea64 100755 (executable)
--- a/configure
+++ b/configure
@@ -421,8 +421,24 @@ fi
 test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \
 && SUBARCH=${SUBARCH}el
 
-test "$ARCH" = "sh" && trycppif __BIG_ENDIAN__ "$t" \
-&& SUBARCH=${SUBARCH}eb
+if test "$ARCH" = "sh" ; then
+trycppif __BIG_ENDIAN__ "$t" && SUBARCH=${SUBARCH}eb
+if trycppif __SH_FPU_ANY__ ; then
+# Some sh configurations are broken and replace double with float
+# rather than using softfloat when the fpu is present but only
+# supports single precision. Reject them.
+printf "checking whether compiler's double type is IEEE double... "
+echo 'typedef char dblcheck[(int)sizeof(double)-5];' >> "$tmpc"
+if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
+printf "yes\n"
+else
+printf "no\n"
+fail "$0: error: compiler's floating point configuration is unsupported"
+fi
+else
+SUBARCH=${SUBARCH}-nofpu
+fi
+fi
 
 test "$SUBARCH" \
 && printf "configured for %s variant: %s\n" "$ARCH" "$ARCH$SUBARCH"
diff --git a/src/fenv/sh-nofpu/fenv.sub b/src/fenv/sh-nofpu/fenv.sub
new file mode 100644 (file)
index 0000000..9cafca5
--- /dev/null
@@ -0,0 +1 @@
+../fenv.c
diff --git a/src/fenv/sheb-nofpu/fenv.sub b/src/fenv/sheb-nofpu/fenv.sub
new file mode 100644 (file)
index 0000000..9cafca5
--- /dev/null
@@ -0,0 +1 @@
+../fenv.c
diff --git a/src/setjmp/sh-nofpu/longjmp.s b/src/setjmp/sh-nofpu/longjmp.s
new file mode 100644 (file)
index 0000000..cda482c
--- /dev/null
@@ -0,0 +1,22 @@
+.global _longjmp
+.global longjmp
+.type   _longjmp, @function
+.type   longjmp,  @function
+_longjmp:
+longjmp:
+       mov.l  @r4+, r8
+       mov.l  @r4+, r9
+       mov.l  @r4+, r10
+       mov.l  @r4+, r11
+       mov.l  @r4+, r12
+       mov.l  @r4+, r13
+       mov.l  @r4+, r14
+       mov.l  @r4+, r15
+       lds.l  @r4+, pr
+
+       tst  r5, r5
+       movt r0
+       add  r5, r0
+
+       rts
+        nop
diff --git a/src/setjmp/sh-nofpu/longjmp.sub b/src/setjmp/sh-nofpu/longjmp.sub
new file mode 100644 (file)
index 0000000..e80331b
--- /dev/null
@@ -0,0 +1 @@
+longjmp.s
diff --git a/src/setjmp/sh-nofpu/setjmp.s b/src/setjmp/sh-nofpu/setjmp.s
new file mode 100644 (file)
index 0000000..c6c7359
--- /dev/null
@@ -0,0 +1,21 @@
+.global __setjmp
+.global _setjmp
+.global setjmp
+.type   __setjmp, @function
+.type   _setjmp,  @function
+.type   setjmp,   @function
+__setjmp:
+_setjmp:
+setjmp:
+       add   #36, r4
+       sts.l  pr,   @-r4
+       mov.l  r15   @-r4
+       mov.l  r14,  @-r4
+       mov.l  r13,  @-r4
+       mov.l  r12,  @-r4
+       mov.l  r11,  @-r4
+       mov.l  r10,  @-r4
+       mov.l  r9,   @-r4
+       mov.l  r8,   @-r4
+       rts
+        mov  #0, r0
diff --git a/src/setjmp/sh-nofpu/setjmp.sub b/src/setjmp/sh-nofpu/setjmp.sub
new file mode 100644 (file)
index 0000000..b7ad221
--- /dev/null
@@ -0,0 +1 @@
+setjmp.s
diff --git a/src/setjmp/sheb-nofpu/longjmp.sub b/src/setjmp/sheb-nofpu/longjmp.sub
new file mode 100644 (file)
index 0000000..62fcd2b
--- /dev/null
@@ -0,0 +1 @@
+../sh-nofpu/longjmp.s
diff --git a/src/setjmp/sheb-nofpu/setjmp.sub b/src/setjmp/sheb-nofpu/setjmp.sub
new file mode 100644 (file)
index 0000000..a5bb294
--- /dev/null
@@ -0,0 +1 @@
+../sh-nofpu/setjmp.s