From e491f387476b3519d03f090cea56195df3d29062 Mon Sep 17 00:00:00 2001 From: twilen Date: Tue, 31 Jul 2012 15:28:14 +0000 Subject: [PATCH] Set AOS compatible FPU rounding and precision modes. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@45366 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/m68k-all/mathieeedoubbas/fpu.S | 8 ++++++++ arch/m68k-all/mathieeedoubbas/mathieeedoubbas_init.c | 9 +++++++++ arch/m68k-all/mathieeedoubtrans/mathieeedoubtrans_init.c | 14 ++++++++++++++ arch/m68k-all/mathieeesingbas/fpu.S | 12 ++++++++++-- arch/m68k-all/mathieeesingbas/mathieeesingbas_init.c | 9 +++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/arch/m68k-all/mathieeedoubbas/fpu.S b/arch/m68k-all/mathieeedoubbas/fpu.S index 5eae55fc5d..2183d1604c 100644 --- a/arch/m68k-all/mathieeedoubbas/fpu.S +++ b/arch/m68k-all/mathieeedoubbas/fpu.S @@ -84,3 +84,11 @@ AROS_SLIB_ENTRY(Flt_6888x,MathIeeeDoubBas, 6): fmove.d %fp0,%sp@- movem.l %sp@+,%d0-%d1 rts + + .globl init_6888x_double +init_6888x_double: + /* Round to zero, double precision */ + moveq #0,%d0 + move.w #0x10+0x80,%d0 + fmove.l %d0,%fpcr + rts \ No newline at end of file diff --git a/arch/m68k-all/mathieeedoubbas/mathieeedoubbas_init.c b/arch/m68k-all/mathieeedoubbas/mathieeedoubbas_init.c index 794bd62a76..d2a576b49b 100644 --- a/arch/m68k-all/mathieeedoubbas/mathieeedoubbas_init.c +++ b/arch/m68k-all/mathieeedoubbas/mathieeedoubbas_init.c @@ -22,6 +22,14 @@ extern void AROS_SLIB_ENTRY(Add_6888x,MathIeeeDoubBas,11)(void); extern void AROS_SLIB_ENTRY(Sub_6888x,MathIeeeDoubBas,12)(void); extern void AROS_SLIB_ENTRY(Mul_6888x,MathIeeeDoubBas,13)(void); extern void AROS_SLIB_ENTRY(Div_6888x,MathIeeeDoubBas,14)(void); +extern void init_6888x_double(void); + +static int IEEEDP_Open(struct MathIeeeDoubBasBase *lh) +{ + if (SysBase->AttnFlags & (AFF_68881 | AFF_68882 | AFF_FPU40)) + init_6888x_double(); + return TRUE; +} static int IEEEDP_Init(struct MathIeeeDoubBasBase *lh) { @@ -43,3 +51,4 @@ static int IEEEDP_Init(struct MathIeeeDoubBasBase *lh) } ADD2INITLIB(IEEEDP_Init, 0) +ADD2OPENLIB(IEEEDP_Open, 0) diff --git a/arch/m68k-all/mathieeedoubtrans/mathieeedoubtrans_init.c b/arch/m68k-all/mathieeedoubtrans/mathieeedoubtrans_init.c index de86c2d224..c8b3a039ee 100644 --- a/arch/m68k-all/mathieeedoubtrans/mathieeedoubtrans_init.c +++ b/arch/m68k-all/mathieeedoubtrans/mathieeedoubtrans_init.c @@ -31,8 +31,14 @@ extern void AROS_SLIB_ENTRY(Asin_6888x,MathIeeeDoubTrans,19)(void); extern void AROS_SLIB_ENTRY(Acos_6888x,MathIeeeDoubTrans,20)(void); extern void AROS_SLIB_ENTRY(Log10_6888x,MathIeeeDoubTrans,21)(void); +struct Library *MathIeeeDoubBasBase; + static int IEEEDPT_Init(struct MathIeeeDoubTransBase *lh) { + MathIeeeDoubBasBase = OpenLibrary("mathieeedoubbas.library", 39); + if (!MathIeeeDoubBasBase) + return FALSE; + if (SysBase->AttnFlags & (AFF_68881 | AFF_68882 | AFF_FPU40)) { SetFunc(5, ATan_6888x); SetFunc(6, Sin_6888x); @@ -55,4 +61,12 @@ static int IEEEDPT_Init(struct MathIeeeDoubTransBase *lh) return TRUE; } +static int IEEEDPT_Expunge(struct Library *lh) +{ + if (MathIeeeDoubBasBase) + CloseLibrary (MathIeeeDoubBasBase); + return TRUE; +} + ADD2INITLIB(IEEEDPT_Init, 0) +ADD2EXPUNGELIB(IEEEDPT_Expunge, 0); diff --git a/arch/m68k-all/mathieeesingbas/fpu.S b/arch/m68k-all/mathieeesingbas/fpu.S index b95a68989d..c494c3ab7f 100644 --- a/arch/m68k-all/mathieeesingbas/fpu.S +++ b/arch/m68k-all/mathieeesingbas/fpu.S @@ -67,6 +67,14 @@ AROS_SLIB_ENTRY(Fix_6888x,MathIeeeSingBas,5): .globl AROS_SLIB_ENTRY(Flt_6888x,MathIeeeSingBas,6) .type AROS_SLIB_ENTRY(Flt_6888x,MathIeeeSingBas,6),@function AROS_SLIB_ENTRY(Flt_6888x,MathIeeeSingBas,6): - fmove.l %d0,%fp0 - fmove.s %fp0,%d0 + fmove.l %d0,%fp0 + fmove.s %fp0,%d0 rts + + .globl init_6888x_single +init_6888x_single: + /* Round to nearest, single precision */ + moveq #0,%d0 + move.w #0x00+0x40,%d0 + fmove.l %d0,%fpcr + rts \ No newline at end of file diff --git a/arch/m68k-all/mathieeesingbas/mathieeesingbas_init.c b/arch/m68k-all/mathieeesingbas/mathieeesingbas_init.c index f31dab23e4..5af71aabf6 100644 --- a/arch/m68k-all/mathieeesingbas/mathieeesingbas_init.c +++ b/arch/m68k-all/mathieeesingbas/mathieeesingbas_init.c @@ -22,6 +22,14 @@ extern void AROS_SLIB_ENTRY(Add_6888x,MathIeeeSingBas,11)(void); extern void AROS_SLIB_ENTRY(Sub_6888x,MathIeeeSingBas,12)(void); extern void AROS_SLIB_ENTRY(Mul_6888x,MathIeeeSingBas,13)(void); extern void AROS_SLIB_ENTRY(Div_6888x,MathIeeeSingBas,14)(void); +extern void init_6888x_single(void); + +static int IEEESP_Open(struct Library *lh) +{ + if (SysBase->AttnFlags & (AFF_68881 | AFF_68882 | AFF_FPU40)) + init_6888x_single(); + return TRUE; +} static int IEEESP_Init(struct Library *lh) { @@ -43,3 +51,4 @@ static int IEEESP_Init(struct Library *lh) } ADD2INITLIB(IEEESP_Init, 0) +ADD2OPENLIB(IEEESP_Open, 0) -- 2.11.4.GIT