diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2013-06-05 20:15:02 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2013-06-05 20:15:02 +0000 |
commit | 46e4d46688f63864767ac919b30c9e22e659b4ea (patch) | |
tree | ede71c4bfca4073c9e332aa23d202879f176ef75 /lib/libc | |
parent | 76a99d8656f7a5319566c126a90636ccb25c600a (diff) |
Add __divsi3 and __udivsi3 gcc-compatible routines. Not used by anything yet
(as gcc does not emit code calling them), but will be shortly; belatedly
riding the libc minor bump.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/arch/m88k/gen/Makefile.inc | 8 | ||||
-rw-r--r-- | lib/libc/arch/m88k/gen/divsi3.S | 59 | ||||
-rw-r--r-- | lib/libc/arch/m88k/gen/udivsi3.S | 32 |
3 files changed, 93 insertions, 6 deletions
diff --git a/lib/libc/arch/m88k/gen/Makefile.inc b/lib/libc/arch/m88k/gen/Makefile.inc index 3bc3b352968..60328113560 100644 --- a/lib/libc/arch/m88k/gen/Makefile.inc +++ b/lib/libc/arch/m88k/gen/Makefile.inc @@ -1,12 +1,8 @@ -# $OpenBSD: Makefile.inc,v 1.14 2012/09/15 15:06:09 martynas Exp $ +# $OpenBSD: Makefile.inc,v 1.15 2013/06/05 20:15:01 miod Exp $ # $NetBSD: Makefile.inc,v 1.3 1995/04/10 21:09:06 jtc Exp $ -#SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.c nan.c -#SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ -# fpsetround.c fpsetsticky.c -#SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S setjmp.S sigsetjmp.S - SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.c nan.c SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ fpsetround.c fpsetsticky.c SRCS+= setjmp.S sigsetjmp.S +SRCS+= divsi3.S udivsi3.S diff --git a/lib/libc/arch/m88k/gen/divsi3.S b/lib/libc/arch/m88k/gen/divsi3.S new file mode 100644 index 00000000000..0a9ac5048e9 --- /dev/null +++ b/lib/libc/arch/m88k/gen/divsi3.S @@ -0,0 +1,59 @@ +/* $OpenBSD: divsi3.S,v 1.1 2013/06/05 20:15:01 miod Exp $ */ + +/* + * Copyright (c) 2013 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "SYS.h" + +/* + * int __divsi3(int n, int d); + */ + +ENTRY(__divsi3) + /* if divider is zero, trap */ + tcnd eq0, %r3, 503 + + bb1 31, %r2, 1f + bb1 31, %r3, 2f + + /* both operands are positive */ + jmp.n %r1 + divu %r2, %r2, %r3 + +1: + bb1 31, %r3, 3f + + /* r2 is negative, r3 is positive */ + subu %r4, %r0, %r2 + divu %r5, %r4, %r3 + jmp.n %r1 + subu %r2, %r0, %r5 + +2: + /* r2 is positive, r3 is negative */ + subu %r5, %r0, %r3 + divu %r4, %r2, %r5 + jmp.n %r1 + subu %r2, %r0, %r4 + +3: + /* both operands are negative */ + subu %r4, %r0, %r2 + subu %r5, %r0, %r3 + jmp.n %r1 + divu %r2, %r4, %r5 +END(__divsi3) diff --git a/lib/libc/arch/m88k/gen/udivsi3.S b/lib/libc/arch/m88k/gen/udivsi3.S new file mode 100644 index 00000000000..0ee987eb156 --- /dev/null +++ b/lib/libc/arch/m88k/gen/udivsi3.S @@ -0,0 +1,32 @@ +/* $OpenBSD: udivsi3.S,v 1.1 2013/06/05 20:15:01 miod Exp $ */ + +/* + * Copyright (c) 2013 Miodrag Vallat. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#include "SYS.h" + +/* + * uint __udivsi3(uint n, uint d); + */ + +ENTRY(__udivsi3) + /* if divider is zero, trap */ + tcnd eq0, %r3, 503 + + jmp.n %r1 + divu %r2, %r2, %r3 +END(__udivsi3) |