Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/arch/sparc64/gen Add _dtoul() which gcc generates a...



details:   https://anonhg.NetBSD.org/src/rev/517368ae748d
branches:  trunk
changeset: 471552:517368ae748d
user:      eeh <eeh%NetBSD.org@localhost>
date:      Sun Apr 04 21:01:39 1999 +0000

description:
Add _dtoul() which gcc generates a lot.  Maybe it should go in another file.

diffstat:

 lib/libc/arch/sparc64/gen/fixunsdfsi.S |  44 ++++++++++++++++++++++++++++++++-
 1 files changed, 42 insertions(+), 2 deletions(-)

diffs (66 lines):

diff -r 22f712aea439 -r 517368ae748d lib/libc/arch/sparc64/gen/fixunsdfsi.S
--- a/lib/libc/arch/sparc64/gen/fixunsdfsi.S    Sun Apr 04 20:17:54 1999 +0000
+++ b/lib/libc/arch/sparc64/gen/fixunsdfsi.S    Sun Apr 04 21:01:39 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fixunsdfsi.S,v 1.1 1998/09/11 04:56:22 eeh Exp $       */
+/*     $NetBSD: fixunsdfsi.S,v 1.2 1999/04/04 21:01:39 eeh Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -40,11 +40,13 @@
  */
 
 #include <machine/asm.h>
+#define _LOCORE
+#include <machine/frame.h>
 #if defined(LIBC_SCCS) && !defined(lint)
 #if 0
        .asciz "@(#)fixunsdfsi.s        8.1 (Berkeley) 6/4/93"
 #else
-       RCSID("$NetBSD: fixunsdfsi.S,v 1.1 1998/09/11 04:56:22 eeh Exp $")
+       RCSID("$NetBSD: fixunsdfsi.S,v 1.2 1999/04/04 21:01:39 eeh Exp $")
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -95,3 +97,41 @@
        ld      [%sp + 64 + BIAS], %o0
        retl
        add     %sp, 8, %sp
+
+/*
+ * Same as above but to unsigned long
+ */
+ENTRY(__dtoul)
+       sub     %sp, 8, %sp
+       stx     %o0, [%sp + 64 + BIAS]  ! get argument into fpu reg
+       ldd     [%sp + 64 + BIAS], %f0
+#ifdef PIC
+       PICCY_SET(Lbig, %g1, %o0)
+       ldd     [%g1], %f2
+#else
+       sethi   %hi(Lbig), %g1
+       ldd     [%g1 + %lo(Lbig)], %f2
+#endif
+       fcmped  %f0, %f2                ! d < 2^31, or NaN, or -Inf?
+       nop                             ! (fpop2 delay)
+       fbul,a  1f                      ! if so, use fdtoi to convert to int
+       fdtox   %f0, %f0                !        (this includes negatives!)
+
+       ! d does not fit in an int, so subtract 2^31, convert,
+       ! and add 2^31 again (sigh).  Just hope the intermediate
+       ! fits (if not, the result is undefined anyway).
+
+       fsubd   %f0, %f2, %f0           ! d -= 2^31
+       fdtox   %f0, %f0                ! convert to int
+       std     %f0, [%sp + 64 + BIAS]  ! move into return reg
+       ldx     [%sp + 64 + BIAS], %o0
+       sethi   %hi(0x80000000), %o1
+       add     %o0, %o1, %o0           ! add 2^31
+       retl
+       add     %sp, 8, %sp
+
+1:
+       std     %f0, [%sp + 64 + BIAS]  ! return result
+       ldx     [%sp + 64 + BIAS], %o0
+       retl
+       add     %sp, 8, %sp



Home | Main Index | Thread Index | Old Index