Home | History | Annotate | only in /src/sys/arch/m68k/fpe
History log of /src/sys/arch/m68k/fpe
RevisionDateAuthorComments
 1.7 21-Aug-2021  andvar fix mainly same typos as in my previous commit but outside sys/dev/dm.
 1.6 20-Apr-2013  isaki Update a list of implement/unimplement functions.
 1.5 15-Oct-2011  tsutsui branches: 1.5.2; 1.5.12;
Update implemented/unimplemented FP functions.
 1.4 05-Nov-1995  briggs Update from Ken Nakata.
 1.3 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.2 03-Nov-1995  briggs Add NetBSD id string and update instructions.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.5.12.1 23-Jun-2013  tls resync from head
 1.5.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.3 19-Apr-2013  isaki Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.2 03-Nov-1995  briggs branches: 1.2.204; 1.2.214;
Add in NetBSD id string.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2.214.1 23-Jun-2013  tls resync from head
 1.2.204.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.9 26-Mar-2013  isaki u_int -> uint32_t
 1.8 19-Mar-2013  isaki Remove 'register'.
 1.7 14-Mar-2009  dsl branches: 1.7.12; 1.7.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.6 11-Dec-2005  christos branches: 1.6.78; 1.6.86; 1.6.92;
merge ktrace-lwp.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 30-May-1999  briggs branches: 1.3.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.2 30-Apr-1996  briggs branches: 1.2.24; 1.2.26; 1.2.28;
Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.2.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.2.24.1 21-Jun-1999  perry pullup 1.2->1.3 (briggs): fix FPE
 1.3.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.36.1 03-Aug-2004  skrll Sync with HEAD
 1.6.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.78.1 04-May-2009  yamt sync with head.
 1.7.22.1 23-Jun-2013  tls resync from head
 1.7.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8 01-Apr-2013  isaki quad_t -> uint64_t
 1.7 26-Mar-2013  isaki u_int -> uint32_t
 1.6 19-Mar-2013  isaki Remove 'register'.
 1.5 24-Dec-2005  perry branches: 1.5.112; 1.5.122;
bare asm -> __asm
 1.4 11-Dec-2005  christos merge ktrace-lwp.
 1.3 07-Aug-2003  agc branches: 1.3.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 30-May-1999  briggs branches: 1.2.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.36.1 03-Aug-2004  skrll Sync with HEAD
 1.3.16.1 21-Jun-2006  yamt sync with head.
 1.5.122.1 23-Jun-2013  tls resync from head
 1.5.112.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.1 03-Nov-1995  briggs branches: 1.1.170; 1.1.178; 1.1.184;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.184.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.1.178.1 28-Apr-2009  skrll Sync with HEAD.
 1.1.170.1 04-May-2009  yamt sync with head.
 1.28 28-Dec-2024  isaki Fix indent.
 1.27 06-Apr-2019  thorpej branches: 1.27.36;
Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.26 18-Jul-2011  isaki branches: 1.26.54;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.25 18-Jul-2011  isaki fix indent. no functional changes.
 1.24 25-May-2011  tsutsui - consistently use #ifdef DEBUG_FPE and #ifdef DIAGNOSTIC
- use DPRINTF() style debug printfs
- use __func__ to print function names
 1.23 25-May-2011  tsutsui KNF. No binary change.
 1.22 06-Jun-2010  mrg branches: 1.22.2;
fix PR 6724 - convert m68k options to defflag's. this means that
M680[12346] are now available from opt_m68k_arch.h. FPSP meantioned
in the PR has already been fixed, and i could not find any more.

i built these kernels to ensure i did not break their builds:

amiga: GENERIC DRACO
atari: HADES FALCON MILAN-PCIIDE
mac68k: GENERIC
sun2: GENERIC
sun3: GENERIC GENERIC3X
cesfic: attempted GENERIC, does not build due to lack of machine/bus.h
hp300: GENERIC
luna68k: GENERIC
mvme68k: GENERIC
news68k: GENERIC
next68k: GENERIC
x68k: GENERIC
 1.21 14-Mar-2009  dsl branches: 1.21.2; 1.21.4;
ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.20 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.19 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.18 09-Mar-2007  tsutsui branches: 1.18.44; 1.18.52; 1.18.58;
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.17 11-Dec-2005  christos branches: 1.17.24; 1.17.26;
merge ktrace-lwp.
 1.16 13-Feb-2004  wiz branches: 1.16.14; 1.16.16;
Uppercase CPU, plural is CPUs.
 1.15 15-Jul-2003  lukem __KERNEL_RCSID()
 1.14 27-Sep-2002  provos branches: 1.14.6;
remove trailing \n in panic(). approved perry.
 1.13 28-Jul-2001  tsutsui branches: 1.13.6;
bcopy -> memcpy
 1.12 05-Jul-2001  toshii branches: 1.12.2;
Fix typo. s/extention/extension/
 1.11 01-Mar-2001  is Don't use the frames' provided EA yet; something is wrong.
 1.10 05-Jan-2001  is Make this actually sort-of-work for 68060 w. disabled FPU (tested), 68LC060,
and I suspect, 68LC040 and 68040V machines. Method used:

1. do NOT use the frames effective address at all
2. do NOT use the frames next instruction address, but
3. restore the "this instruction" pc into the pc field of the frame at the
beginning of the emulation, if we got a frame format 4.

TODO:
A. find the bug in the usage of the frame EA, and revert to using it.
B. find the bug in the usage of the frames next instruction address, and
consider whether it's worthwhile to use it.
C. make the emulation complete.... FEXP FETOM1, and the trigonometric functions
are missing.
 1.9 13-Jun-2000  minoura Argument modreg of fpu_decode_ea() is actually an opecode.
That bug prevented awk(1) to work.
 1.8 30-May-1999  briggs branches: 1.8.2; 1.8.10;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.7 16-Oct-1996  scottr branches: 1.7.22; 1.7.24; 1.7.26;
Eliminate fusword() prototype, as it's now in <sys/systm.h>
 1.6 13-Oct-1996  christos backout previous kprintf change
 1.5 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.4 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.3 04-Feb-1996  briggs sys/types.h -> sys/param.h and remove include of stddef.h.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.7.26.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.7.24.1 21-Jun-1999  thorpej Sync w/ -current.
 1.7.22.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.7.22.1 21-Jun-1999  perry pullup 1.7->1.8 (briggs): fix FPE
 1.8.10.1 22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.8.2.3 12-Mar-2001  bouyer Sync with HEAD.
 1.8.2.2 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.8.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.12.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.12.2.1 03-Aug-2001  lukem update to -current
 1.13.6.2 18-Oct-2002  nathanw Catch up to -current.
 1.13.6.1 28-Jul-2001  nathanw file fpu_calcea.c was added on branch nathanw_sa on 2002-10-18 02:38:14 +0000
 1.14.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.14.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.14.6.1 03-Aug-2004  skrll Sync with HEAD
 1.16.16.1 03-Sep-2007  yamt sync with head.
 1.16.14.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1703):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.17.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.17.24.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #526):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.18.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.18.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.18.44.2 11-Aug-2010  yamt sync with head.
 1.18.44.1 04-May-2009  yamt sync with head.
 1.21.4.2 31-May-2011  rmind sync with head
 1.21.4.1 03-Jul-2010  rmind sync with head
 1.21.2.1 17-Aug-2010  uebayasi Sync with HEAD.
 1.22.2.1 06-Jun-2011  jruoho Sync with HEAD.
 1.26.54.1 10-Jun-2019  christos Sync with HEAD
 1.27.36.1 02-Aug-2025  perseant Sync with HEAD
 1.4 06-Dec-2016  isaki Remove fpu_cordit2() and atanh_table[] completely.
Since cordit1 (for trigonometric functions) and cordit2 (for
hyperbolic functions) are very similar, so I implemented both
at first, but I didn't use cordit2 after all :(
 1.3 04-Aug-2016  isaki Move fpu_cordit2() to #ifdef CORDIC_BOOTSTRAP section.
This reduces ~2KB text segment.
Reported by Krister Walfridsson on tech-kern two months ago.
 1.2 20-Apr-2013  isaki branches: 1.2.4; 1.2.12; 1.2.16; 1.2.20;
s/tayler/taylor/. pointed out by christos@
 1.1 19-Apr-2013  isaki Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.2.20.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.2.20.1 06-Aug-2016  pgoyette Sync with HEAD
 1.2.16.2 05-Feb-2017  skrll Sync with HEAD
 1.2.16.1 05-Oct-2016  skrll Sync with HEAD
 1.2.12.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2.12.1 20-Apr-2013  yamt file fpu_cordic.c was added on branch yamt-pagecache on 2014-05-22 11:39:55 +0000
 1.2.4.3 03-Dec-2017  jdolecek update from HEAD
 1.2.4.2 23-Jun-2013  tls resync from head
 1.2.4.1 20-Apr-2013  tls file fpu_cordic.c was added on branch tls-maxphys on 2013-06-23 06:20:08 +0000
 1.10 01-Jan-2014  isaki indent fix in a comment.
 1.9 01-Jan-2014  isaki Fix a sign when a source or destination is either (plus/minus)zero
or (plus/minus)infinity. Found by XM6i.
 1.8 26-Mar-2013  isaki branches: 1.8.4;
u_int -> uint32_t
 1.7 19-Mar-2013  isaki Remove 'register'.
 1.6 14-Mar-2009  dsl branches: 1.6.12; 1.6.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.86; 1.5.92;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 30-May-1999  briggs branches: 1.2.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.36.1 03-Aug-2004  skrll Sync with HEAD
 1.5.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.6.22.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.22.1 23-Jun-2013  tls resync from head
 1.6.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.4.1 18-May-2014  rmind sync with head
 1.49 06-Jan-2025  isaki m68k/fpe: Avoid an illegal mod/reg before decoding it.
This also works for machines with FPU.
If the kernel defines FPU_EMULATE, even illegal FPU instructions in the real
6888x machines, the FPE will be executed by F line exception. So the FPE
must raise SIGILL appropriately for these.
 1.48 28-Dec-2024  isaki m68k/fpe: Remove duplicated assignments.
These are already stored before. No functional changes intended.
 1.47 28-Dec-2024  isaki m68k/fpe: Fix FTRAPcc emulation raise the correct trap.
Currently fpu_emul_type1() returns SIGFPE only if FTRAPcc's condition is met,
so this works. But I wish there was a better way..
fputest.x(0.24.10.08) about ftrapcc passed 100%.
 1.46 28-Dec-2024  isaki m68k/fpe: Reimplement and simplify test_cc().
This logic was analized by Y.Sugahara (in 2016).
Finally fputest.x(0.24.10.08) about fbcc fdbcc fscc (40960 tests) passed 100%!
 1.45 28-Dec-2024  isaki m68k/fpe: Two bugfixes in test_cc().
- Don't clear the exception byte in FPSR.
According to the manual, all bits except BSUN are "not affected".
- Accumulate AIOP bit always.
XXX Need to look this again later. brcc() looks to have similar one.
 1.44 28-Dec-2024  isaki m68k/fpe: Several bugfixes in FDBcc and FTRAPcc emulation.
In fpu_emul_type1(),
- If test_cc() returns >0, it's an error, that is an illegal instruction in
this case. So it should just return without doing anything.
By this fix, FTRAPcc with illegal cc now causes SIGILL correctly.
- In result, branch can only be 0 or -1 after that. It makes code simple.
By this cleanup, FDBcc with illegal cc now causes SIGILL correctly.
- FTRAPcc must advance PC regardless of whether the condition is met.
(although FTRAPcc does not work at this point by anothor problem)
 1.43 28-Dec-2024  isaki m68k/fpe: Fix several FMOVEM FPctl emulation.
- Fix the write order of FMOVEM FPctl,-(An).
For example, "FMOVEM FPCR/FPSR,-(An)" instruction first decrements An by
the total size (4*2 bytes), then writes FPCR and FPSR in this order.
Therefore, it's differs from "FMOVEM FPCR,-(An); FMOVEM FPSR,-(An)" sequence.
- Support multiple immediate case like "FMOVEM #imm/#imm,FPCR/FPIAR".
- Mask writes to FPSR and FPCR registers correctly.
- Support reglist=0 case too. It's not common case but makes code easier.
 1.42 28-Dec-2024  isaki m68k/fpe: FMOVEM (both FPn and FPctl) must not update accrued byte in FPSR.
 1.41 17-Sep-2023  andvar branches: 1.41.6;
word was changed to sval at rev 1.39, but DPRINTF values were not updated.

Fixes DEBUG_FPE enabled build for 68k FPE code.
 1.40 27-Dec-2019  msaitoh s/opration/operation/
 1.39 06-Apr-2019  thorpej Overhaul the API used to fetch and store individual memory cells in
userspace. The old fetch(9) and store(9) APIs (fubyte(), fuword(),
subyte(), suword(), etc.) are retired and replaced with new ufetch(9)
and ustore(9) APIs that can return proper error codes, etc. and are
implemented consistently across all platforms. The interrupt-safe
variants are no longer supported (and several of the existing attempts
at fuswintr(), etc. were buggy and not actually interrupt-safe).

Also augmement the ucas(9) API, making it consistently available on
all plaforms, supporting uniprocessor and multiprocessor systems, even
those that do not have CAS or LL/SC primitives.

Welcome to NetBSD 8.99.37.
 1.38 25-Oct-2013  martin branches: 1.38.30;
Comment unused stuff (for documentation purposes)
 1.37 26-Mar-2013  isaki branches: 1.37.4;
u_int -> uint32_t
 1.36 15-Oct-2011  tsutsui branches: 1.36.2; 1.36.12;
Add hyperboric and trigonometric functions to m68k FPE, written by isaki@.
With these emulations (~4KB text) xeyes on XM6i works better.
Discussed with isaki@ at OSC 2011 Hiroshima.
 1.35 18-Jul-2011  isaki fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.34 18-Jul-2011  isaki fix indent. no functional changes.
 1.33 23-May-2011  tsutsui - use DPRINTF() style debug printfs
- use __func__ to print function names
- consistently use #ifdef DEBUG_FPE
- add some missing debug messages including \n in error paths
 1.32 23-May-2011  tsutsui KNF, mostly indent. No binary change.
 1.31 14-May-2011  tsutsui Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.

Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.

Should be pulled up to all netbsd-4 and netbsd-5 branches.
 1.30 14-Mar-2009  dsl branches: 1.30.4; 1.30.6;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.29 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.28 20-Jan-2009  tsutsui branches: 1.28.2;
In fpu_emul_arith(), check lower 7 bits in word1 rather than only 6 bits
to check 040/060 FP instructions, and don't call fpu_implode() and
fpu_upd_fpsr() if no vaild emulated result is set otherwise these
functions cause NULL pointer dereference.

Fixes panics triggered by 040/060's FDADD instruction
(which has the same lower 6 bits with fscale instruction)
on 020/030 machines (even with 68881/68882) running kernels
with options FPU_EMULATE.
Problem reported by John Carr on port-sun3.

Should be pulled up to netbsd-4-0, netbsd-4 and netbsd-5.

XXX: m68k 4.0 packages binaries on ftp have this FDADD instruction.
 1.27 09-Mar-2007  tsutsui branches: 1.27.44; 1.27.52; 1.27.54;
Make these compile with options DEBUG_FPE.
 1.26 11-Dec-2005  christos branches: 1.26.24; 1.26.26;
merge ktrace-lwp.
 1.25 22-Sep-2003  cl branches: 1.25.14; 1.25.16;
SA_SIGINFO support for m68k
 1.24 15-Jul-2003  lukem __KERNEL_RCSID()
 1.23 05-Feb-2001  chs branches: 1.23.24;
conditionalize the ddb hook on DDB && DEBUG_FPE rather than DDB && DEBUG,
since that's the condition under which we include the header file that
allows it to compile.
 1.22 05-Jan-2001  is Make this actually sort-of-work for 68060 w. disabled FPU (tested), 68LC060,
and I suspect, 68LC040 and 68040V machines. Method used:

1. do NOT use the frames effective address at all
2. do NOT use the frames next instruction address, but
3. restore the "this instruction" pc into the pc field of the frame at the
beginning of the emulation, if we got a frame format 4.

TODO:
A. find the bug in the usage of the frame EA, and revert to using it.
B. find the bug in the usage of the frames next instruction address, and
consider whether it's worthwhile to use it.
C. make the emulation complete.... FEXP FETOM1, and the trigonometric functions
are missing.
 1.21 30-May-1999  briggs branches: 1.21.2;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.20 04-Jul-1998  jonathan branches: 1.20.8; 1.20.10; 1.20.12;
defopt DDB.
 1.19 03-Nov-1997  is Back out last change, which was a thinko.
 1.18 02-Nov-1997  is Add ftwotox emulation, by using the fscale emulation routine (preload
destination register bit pattern with 1.0), which automatically provides
corner case handling.
Missing ftwotox emulation originally reported by Norman Mackenzie in PR 4237,
but he proposed a different implementation.
 1.17 20-Jul-1997  is Make us pass the full ieeefp except regression test.
XXX This is probably a horrible hack, and wrong. FPU signal handling needs
to be further evaluated.
 1.16 19-Jul-1997  is Fix my own PR port-m68k/3871, nee port-amiga/3871:
- don't erase FPSR exception bits _after_ doing most of the operations in
fpu_implode(), erase them before doing arith and store operations. This fixes
losing the DZ bit.
- create FPSR_OVFL and FPSR_UNFL bits in fpu_implode(). This showed up when
the first error was fixed.
XXX some more work needs to be done. E.g., creating OPERR together with
OVFL looks bogus, but I'm too tired know to re-check docs; and at least we
pass our own regression tests know.
 1.15 17-Jul-1997  veego include <m68k/db_machdep.h> to get the prototype for kdb_trap if DDB and
DEBUG are defined and add a cast for the second argument to the
kdb_trap call.
 1.14 18-Dec-1996  scottr Work around another uninitialized variable warning
 1.13 17-Dec-1996  gwr Fix warnings.
 1.12 30-Oct-1996  is Bug fix for FSINCOS: wouldn't handle FPc == FP1 earlier.
 1.11 16-Oct-1996  scottr Eliminate fusword() prototype, as it's now in <sys/systm.h>
 1.10 13-Oct-1996  christos backout previous kprintf change
 1.9 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.8 07-Oct-1996  scottr The 68LC040 generates a format 4 stack frame for floating point
exceptions, which puts the address of the instruction we faulted
on in a different location. Copy it and handle as we normally would,
restoring the saved PC before returning.

The FPE should probably be reworked to take advantage of the 68LC040's
precalculated effective address, at some point.
 1.7 04-Oct-1996  scottr Fix FMOVEM emulation; postincrement modes use different ordering than
predecrement modes, per 68K Programmer's Manual p. 5-88. Pointed out
by Takeshi Nakayama <takeshi@sakabe.nuie.nagoya-u.ac.jp>, verified by me.
 1.6 15-May-1996  leo branches: 1.6.4;
Fix "might be used uninitialized" warnings.
 1.5 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.4 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.3 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2 10-Mar-1995  gwr Add missing break in switch (not that it mattered 8^)
 1.1 01-Mar-1995  gwr branches: 1.1.1;
Initial revision
 1.1.1.1 01-Mar-1995  gwr First cut at an mc68881 emulator. Works only for fmovem right now.
 1.6.4.1 05-Dec-1996  rat Pullup request 1.11 to 1.12 from Ignatios Souvatzis <ignatios@cs.uni-bonn.de>

>This fixes an oversight/editing error, which would prevent us from emulating
>the FSINCOS opcode, where FPcos == FP1.
 1.20.12.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.20.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.20.8.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.20.8.1 21-Jun-1999  perry pullup 1.20->1.21 (briggs): fix FPE
 1.21.2.2 11-Feb-2001  bouyer Sync with HEAD.
 1.21.2.1 18-Jan-2001  bouyer Sync with head (for UBC+NFS fixes, mostly).
 1.23.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.23.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.23.24.1 03-Aug-2004  skrll Sync with HEAD
 1.25.16.1 03-Sep-2007  yamt sync with head.
 1.25.14.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1703):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.26.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.26.24.2 31-Jan-2009  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1268):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.28
In fpu_emul_arith(), check lower 7 bits in word1 rather than only 6 bits
to check 040/060 FP instructions, and don't call fpu_implode() and
fpu_upd_fpsr() if no vaild emulated result is set otherwise these
functions cause NULL pointer dereference.
Fixes panics triggered by 040/060's FDADD instruction
(which has the same lower 6 bits with fscale instruction)
on 020/030 machines (even with 68881/68882) running kernels
with options FPU_EMULATE.
Problem reported by John Carr on port-sun3.
Should be pulled up to netbsd-4-0, netbsd-4 and netbsd-5.
XXX: m68k 4.0 packages binaries on ftp have this FDADD instruction.
 1.26.24.1 31-Mar-2007  bouyer branches: 1.26.24.1.6;
Pull up following revision(s) (requested by tsutsui in ticket #526):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.26.24.1.6.1 31-Jan-2009  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1268):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.28
In fpu_emul_arith(), check lower 7 bits in word1 rather than only 6 bits
to check 040/060 FP instructions, and don't call fpu_implode() and
fpu_upd_fpsr() if no vaild emulated result is set otherwise these
functions cause NULL pointer dereference.
Fixes panics triggered by 040/060's FDADD instruction
(which has the same lower 6 bits with fscale instruction)
on 020/030 machines (even with 68881/68882) running kernels
with options FPU_EMULATE.
Problem reported by John Carr on port-sun3.
Should be pulled up to netbsd-4-0, netbsd-4 and netbsd-5.
XXX: m68k 4.0 packages binaries on ftp have this FDADD instruction.
 1.27.54.2 18-Jun-2011  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1626):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.31
Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.
Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.
Should be pulled up to all netbsd-4 and netbsd-5 branches.
 1.27.54.1 26-Jan-2009  snj branches: 1.27.54.1.2; 1.27.54.1.6;
Pull up following revision(s) (requested by tsutsui in ticket #308):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.28
In fpu_emul_arith(), check lower 7 bits in word1 rather than only 6 bits
to check 040/060 FP instructions, and don't call fpu_implode() and
fpu_upd_fpsr() if no vaild emulated result is set otherwise these
functions cause NULL pointer dereference.
Fixes panics triggered by 040/060's FDADD instruction
(which has the same lower 6 bits with fscale instruction)
on 020/030 machines (even with 68881/68882) running kernels
with options FPU_EMULATE.
Problem reported by John Carr on port-sun3.
Should be pulled up to netbsd-4-0, netbsd-4 and netbsd-5.
XXX: m68k 4.0 packages binaries on ftp have this FDADD instruction.
 1.27.54.1.6.1 18-Jun-2011  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1626):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.31
Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.
Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.
Should be pulled up to all netbsd-4 and netbsd-5 branches.
 1.27.54.1.2.1 18-Jun-2011  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1626):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.31
Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE.
fpu_upd_fpsr() should be called even in discard_result case if an emulated
instruction gets proper result without signal.
Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and
TME emulating sun3 without 68881.
Should be pulled up to all netbsd-4 and netbsd-5 branches.
 1.27.52.2 28-Apr-2009  skrll Sync with HEAD.
 1.27.52.1 03-Mar-2009  skrll Sync with HEAD.
 1.27.44.1 04-May-2009  yamt sync with head.
 1.28.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.30.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.30.4.1 31-May-2011  rmind sync with head
 1.36.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.36.12.1 23-Jun-2013  tls resync from head
 1.36.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.4.1 18-May-2014  rmind sync with head
 1.38.30.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.38.30.1 10-Jun-2019  christos Sync with HEAD
 1.41.6.1 02-Aug-2025  perseant Sync with HEAD
 1.26 06-Dec-2016  isaki Remove fpu_cordit2() and atanh_table[] completely.
Since cordit1 (for trigonometric functions) and cordit2 (for
hyperbolic functions) are very similar, so I implemented both
at first, but I didn't use cordit2 after all :(
 1.25 04-Aug-2016  isaki Move fpu_cordit2() to #ifdef CORDIC_BOOTSTRAP section.
This reduces ~2KB text segment.
Reported by Krister Walfridsson on tech-kern two months ago.
 1.24 19-Apr-2013  isaki branches: 1.24.12; 1.24.16;
Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.23 11-Apr-2013  isaki Introduce FPU_CONST_* constants to avoid a magic number.
 1.22 26-Mar-2013  isaki u_int -> uint32_t
 1.21 19-Mar-2013  isaki const-ify.
 1.20 19-Mar-2013  isaki Remove 'register'.
 1.19 15-Oct-2011  tsutsui branches: 1.19.2; 1.19.12;
- remove variable names from function declarations
- some KNF
 1.18 15-Oct-2011  tsutsui Add hyperboric and trigonometric functions to m68k FPE, written by isaki@.
With these emulations (~4KB text) xeyes on XM6i works better.
Discussed with isaki@ at OSC 2011 Hiroshima.
 1.17 09-Oct-2011  tsutsui Use static inline structure assignment for CPYFPN(). From isaki@.
Tested on XM6i.
 1.16 18-Jul-2011  isaki fix indent. no functional changes.
 1.15 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.14 27-Jan-2009  martin branches: 1.14.2;
fix include path in previous
 1.13 27-Jan-2009  martin Move FPSR_ register bit definitions into their own file
 1.12 11-Dec-2005  christos branches: 1.12.78; 1.12.86; 1.12.88;
merge ktrace-lwp.
 1.11 13-Aug-2005  he Include <sys/time.h> before <sys/signalvar.h> so that copyinout_t is
defined before it is used in the second of these.

Fixes a build problem for several of our m68k ports. I've been
waiting for a better fix, but now my "proper fix timeout" triggered.
 1.10 22-Sep-2003  cl branches: 1.10.16;
SA_SIGINFO support for m68k
 1.9 05-Jul-2001  toshii branches: 1.9.8; 1.9.24;
Fix typo. s/extention/extension/
 1.8 18-Feb-2001  chs rename round() to fpu_round() to avoid a name conflict with
the "round" assembly function in FPSP when building with ELF.
 1.7 22-Sep-2000  is fpu_emulate.h:
the fmovecr constant table has the internal format
of the constants. So, when changing the mantissa size by a
non-multiple of 32 bits, we'd have to change this table, too. As
all other code changes just chopped of the least significand
32bit word of the mantissa, we correct the mantissa size instead
to (115 - 32 == 83) bits.
fpu_fmovecr.c:
put a safety belt in, to catch the next person who doesn't know this.
fpu_int.c:
in one place, the reduction of the mantissa size was overlooked.
fpu_log.c:
as the most significand 32bit word of the mantissa was changed back to the
old format, change back the table indexing code, too.

This should fix PR 11045.
 1.6 19-Sep-2000  minoura Correct comments.
 1.5 30-May-1999  briggs branches: 1.5.2; 1.5.12;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.4 30-Apr-1996  briggs branches: 1.4.24; 1.4.26; 1.4.28;
Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.3 12-Jan-1996  briggs Remove explicit #define of DEBUG, per PR #1931.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.4.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.4.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.4.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.4.24.1 21-Jun-1999  perry pullup 1.4->1.5 (briggs): fix FPE
 1.5.12.2 26-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

fpu_emulate.h 1.7, fpu_log.c 1.7: synchronize mantissa length % 32 with fpu_fmovecr.c table
fpu_fmovecr.c 1.8: cheap compile-time consistency check for this
fpu_int.c 1.3: fix bug introduced when reducing mantissa size
This fixes PR 11045.
 1.5.12.1 19-Sep-2000  minoura Correct comments.
 1.5.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.5.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.9.24.4 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.24.1 03-Aug-2004  skrll Sync with HEAD
 1.9.8.2 05-Jul-2001  toshii Fix typo. s/extention/extension/
 1.9.8.1 05-Jul-2001  toshii file fpu_emulate.h was added on branch nathanw_sa on 2001-07-05 08:38:26 +0000
 1.10.16.1 21-Jun-2006  yamt sync with head.
 1.12.88.2 02-Feb-2009  snj Pull up following revision(s) (requested by martin in ticket #332):
sys/arch/m68k/fpe/fpu_emulate.h: revision 1.14
fix include path in previous
 1.12.88.1 02-Feb-2009  snj Pull up following revision(s) (requested by martin in ticket #332):
sys/arch/m68k/fpe/fpu_emulate.h: revision 1.13
sys/arch/m68k/include/fpreg.h: revision 1.1
Move FPSR_ register bit definitions into their own file
 1.12.86.2 28-Apr-2009  skrll Sync with HEAD.
 1.12.86.1 03-Mar-2009  skrll Sync with HEAD.
 1.12.78.1 04-May-2009  yamt sync with head.
 1.14.2.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.19.12.2 03-Dec-2017  jdolecek update from HEAD
 1.19.12.1 23-Jun-2013  tls resync from head
 1.19.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.24.16.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.24.16.1 06-Aug-2016  pgoyette Sync with HEAD
 1.24.12.2 05-Feb-2017  skrll Sync with HEAD
 1.24.12.1 05-Oct-2016  skrll Sync with HEAD
 1.11 15-Jan-2017  isaki exp(>11356) is +inf even if extended precision.
exp(<-11401) is 0 even if extended precision.
 1.10 07-Dec-2016  isaki Fix sign of zero in case of x > -(2^18).
# By the way, I will modify this case later.
 1.9 05-Dec-2016  isaki Improve the exponential and hyperbolic function's performance
10..100 times faster.
PR port-m68k/51645 from rin@ (and modified by me)
 1.8 20-Apr-2013  isaki branches: 1.8.12; 1.8.16;
Terminate a loop in EXT_FRACBITS(64bits) instead of FP_NMANT(83bits).
I don't know why the mantissa of the accumulator is 83bits, but 64bits
or more are not affected.
 1.7 20-Apr-2013  isaki Break a loop off to avoid a long loop even if the precision is not enough.
 1.6 20-Apr-2013  isaki Implement exponential and power functions.
o FETOX .. exp(x)
o FETOXM1 .. exp(x) - 1
o FTENTOX .. 10^x
o FTWOTOX .. 2^x
At last all mathematics functions of FPE were implemented.
Thanks to Yosuke Sugahara.
 1.5 18-Jul-2011  isaki branches: 1.5.2; 1.5.12;
fix indent. no functional changes.
 1.4 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.3 11-Dec-2005  christos branches: 1.3.78; 1.3.86; 1.3.92;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.5.12.2 03-Dec-2017  jdolecek update from HEAD
 1.5.12.1 23-Jun-2013  tls resync from head
 1.5.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.16.2 20-Mar-2017  pgoyette Sync with HEAD
 1.8.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.12.1 05-Feb-2017  skrll Sync with HEAD
 1.16 08-Mar-2021  isaki Remove incorrect byte and word conversions from fpu_explode.
The correct operation here is arithmetic right shift, but nobody calls it.
 1.15 05-Feb-2015  isaki branches: 1.15.30;
For the extended precision, the MSB of the mantissa is an integer
part, and this bit must be ignored at Infinity.
found by tests/lib/libc/stdlib/t_strtod.c::strtold_inf.
 1.14 26-Mar-2013  isaki branches: 1.14.12;
u_int -> uint32_t
 1.13 19-Mar-2013  isaki const-ify.
 1.12 19-Mar-2013  isaki Remove 'register'.
 1.11 18-Jul-2011  isaki branches: 1.11.2; 1.11.12;
fix indent. no functional changes.
 1.10 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.9 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.8 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.7 11-Dec-2005  christos branches: 1.7.78; 1.7.86; 1.7.92;
merge ktrace-lwp.
 1.6 23-Oct-2003  kleink While I'm here, retire the FPE code's own copy of ieee.h.
 1.5 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.4 15-Jul-2003  lukem __KERNEL_RCSID()
 1.3 30-May-1999  briggs branches: 1.3.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.2 30-Apr-1996  briggs branches: 1.2.24; 1.2.26; 1.2.28;
Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.2.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.2.24.1 21-Jun-1999  perry pullup 1.2->1.3 (briggs): fix FPE
 1.3.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.3.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.3.36.1 03-Aug-2004  skrll Sync with HEAD
 1.7.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.7.78.1 04-May-2009  yamt sync with head.
 1.11.12.2 03-Dec-2017  jdolecek update from HEAD
 1.11.12.1 23-Jun-2013  tls resync from head
 1.11.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.12.1 06-Apr-2015  skrll Sync with HEAD
 1.15.30.1 03-Apr-2021  thorpej Sync with HEAD.
 1.16 26-Mar-2013  isaki u_int -> uint32_t
 1.15 23-Mar-2013  isaki Use the #error directive.
 1.14 18-Jul-2011  isaki branches: 1.14.2; 1.14.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.13 18-Jul-2011  isaki fix indent. no functional changes.
 1.12 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.11 11-Dec-2005  christos branches: 1.11.78; 1.11.86; 1.11.92;
merge ktrace-lwp.
 1.10 15-Jul-2003  lukem __KERNEL_RCSID()
 1.9 27-Sep-2002  provos branches: 1.9.6;
remove trailing \n in panic(). approved perry.
 1.8 22-Sep-2000  is branches: 1.8.4; 1.8.8;
fpu_emulate.h:
the fmovecr constant table has the internal format
of the constants. So, when changing the mantissa size by a
non-multiple of 32 bits, we'd have to change this table, too. As
all other code changes just chopped of the least significand
32bit word of the mantissa, we correct the mantissa size instead
to (115 - 32 == 83) bits.
fpu_fmovecr.c:
put a safety belt in, to catch the next person who doesn't know this.
fpu_int.c:
in one place, the reduction of the mantissa size was overlooked.
fpu_log.c:
as the most significand 32bit word of the mantissa was changed back to the
old format, change back the table indexing code, too.

This should fix PR 11045.
 1.7 30-May-1999  briggs branches: 1.7.2; 1.7.12;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.6 13-Oct-1996  christos branches: 1.6.22; 1.6.24; 1.6.26;
backout previous kprintf change
 1.5 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.4 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.3 04-Feb-1996  briggs sys/types.h -> sys/param.h and remove include of stddef.h.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.6.26.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.6.24.1 21-Jun-1999  thorpej Sync w/ -current.
 1.6.22.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.6.22.1 21-Jun-1999  perry pullup 1.6->1.7 (briggs): fix FPE
 1.7.12.1 26-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

fpu_emulate.h 1.7, fpu_log.c 1.7: synchronize mantissa length % 32 with fpu_fmovecr.c table
fpu_fmovecr.c 1.8: cheap compile-time consistency check for this
fpu_int.c 1.3: fix bug introduced when reducing mantissa size
This fixes PR 11045.
 1.7.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.8.8.1 18-Oct-2002  nathanw Catch up to -current.
 1.8.4.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.9.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.9.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.9.6.1 03-Aug-2004  skrll Sync with HEAD
 1.11.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.11.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.78.1 04-May-2009  yamt sync with head.
 1.14.12.1 23-Jun-2013  tls resync from head
 1.14.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17 06-Jan-2025  isaki m68k/fpe: Avoid an illegal mod/reg before decoding it.
This also works for machines with FPU.
If the kernel defines FPU_EMULATE, even illegal FPU instructions in the real
6888x machines, the FPE will be executed by F line exception. So the FPE
must raise SIGILL appropriately for these.
 1.16 26-Mar-2013  isaki branches: 1.16.72;
u_int -> uint32_t
 1.15 18-Jul-2011  isaki branches: 1.15.2; 1.15.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.14 18-Jul-2011  isaki fix indent. no functional changes.
 1.13 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.12 11-Dec-2005  christos branches: 1.12.78; 1.12.86; 1.12.92;
merge ktrace-lwp.
 1.11 15-Jul-2003  lukem __KERNEL_RCSID()
 1.10 30-May-1999  briggs branches: 1.10.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.9 03-Nov-1997  is branches: 1.9.8; 1.9.10; 1.9.12;
Back out last change, which was a thinko.
 1.8 02-Nov-1997  is Add ftwotox emulation, by using the fscale emulation routine (preload
destination register bit pattern with 1.0), which automatically provides
corner case handling.
Missing ftwotox emulation originally reported by Norman Mackenzie in PR 4237,
but he proposed a different implementation.
 1.7 09-Oct-1997  is Don't forget to set the scale variable even if we dont need to sign-extend it.
From PR 4236 by Norman Mackenzie.
 1.6 13-Oct-1996  christos branches: 1.6.10;
backout previous kprintf change
 1.5 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.4 15-May-1996  leo Fix "might be used uninitialized" warnings.
 1.3 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.6.10.1 14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.9.12.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.9.10.1 21-Jun-1999  thorpej Sync w/ -current.
 1.9.8.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.9.8.1 21-Jun-1999  perry pullup 1.9->1.10 (briggs): fix FPE
 1.10.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.10.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.10.36.1 03-Aug-2004  skrll Sync with HEAD
 1.12.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.12.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.12.78.1 04-May-2009  yamt sync with head.
 1.15.12.1 23-Jun-2013  tls resync from head
 1.15.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.72.1 02-Aug-2025  perseant Sync with HEAD
 1.17 06-Jan-2025  isaki m68k/fpe: Remove redundant code.
This was assigned before the function was called.
 1.16 03-Jan-2025  isaki m68k/fpe: Check an illegal mod/reg before decoding it.
This avoids a kernel panic if an instruction has illegal mod/reg bits
like FMOVE.X FPn,#imm (Of course normally assemblers never emit these).
XXX Other instructions probably need such treatment...
 1.15 03-Jan-2025  isaki m68k/fpe: Add a missing return.
FMOVE.P FPn,<ea> now raises SIGFPE. (Our FPE doesn't support .P)
 1.14 26-Mar-2013  isaki branches: 1.14.72;
u_int -> uint32_t
 1.13 18-Jul-2011  isaki branches: 1.13.2; 1.13.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.12 18-Jul-2011  isaki fix indent. no functional changes.
 1.11 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.10 09-Mar-2007  tsutsui branches: 1.10.44; 1.10.52; 1.10.58;
Make these compile with options DEBUG_FPE.
 1.9 11-Dec-2005  christos branches: 1.9.24; 1.9.26;
merge ktrace-lwp.
 1.8 15-Jul-2003  lukem branches: 1.8.14; 1.8.16;
__KERNEL_RCSID()
 1.7 30-May-1999  briggs branches: 1.7.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.6 19-Jul-1997  is branches: 1.6.14; 1.6.16; 1.6.18;
Fix my own PR port-m68k/3871, nee port-amiga/3871:
- don't erase FPSR exception bits _after_ doing most of the operations in
fpu_implode(), erase them before doing arith and store operations. This fixes
losing the DZ bit.
- create FPSR_OVFL and FPSR_UNFL bits in fpu_implode(). This showed up when
the first error was fixed.
XXX some more work needs to be done. E.g., creating OPERR together with
OVFL looks bogus, but I'm too tired know to re-check docs; and at least we
pass our own regression tests know.
 1.5 13-Oct-1996  christos backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.6.18.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.6.16.1 21-Jun-1999  thorpej Sync w/ -current.
 1.6.14.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.6.14.1 21-Jun-1999  perry pullup 1.6->1.7 (briggs): fix FPE
 1.7.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.36.1 03-Aug-2004  skrll Sync with HEAD
 1.8.16.1 03-Sep-2007  yamt sync with head.
 1.8.14.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1703):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.9.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.9.24.1 31-Mar-2007  bouyer Pull up following revision(s) (requested by tsutsui in ticket #526):
sys/arch/m68k/fpe/fpu_emulate.c: revision 1.27
sys/arch/m68k/fpe/fpu_calcea.c: revision 1.18
sys/arch/m68k/fpe/fpu_fstore.c: revision 1.10
Make these compile with options DEBUG_FPE.
Don't disable EA_DIRECT in fpu_load_ea(), which seems disabled
accidentally in rev 1.11 about six years ago, otherwise
fmovel %dN,%fpN instructions cause unexpected memory access.
 1.10.58.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.10.52.1 28-Apr-2009  skrll Sync with HEAD.
 1.10.44.1 04-May-2009  yamt sync with head.
 1.13.12.1 23-Jun-2013  tls resync from head
 1.13.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.14.72.1 02-Aug-2025  perseant Sync with HEAD
 1.5 18-Jul-2011  isaki fix indent. no functional changes.
 1.4 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.3 11-Dec-2005  christos branches: 1.3.78; 1.3.86; 1.3.92;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.17 05-Dec-2016  isaki Improve the exponential and hyperbolic function's performance
10..100 times faster.
PR port-m68k/51645 from rin@ (and modified by me)
 1.16 11-Oct-2013  isaki branches: 1.16.6; 1.16.10;
FATANH(-0) is -0, not +0.
This bug was introduced by the mistake of my test program.
Last week, I talked about the probelm (my FATANH(-0) returns +0 ?)
by NetBSD seminar at Open Source Conference 2013 Hiroshima,
and tsutsui@ confirmed that returns -0.
 1.15 20-Apr-2013  isaki branches: 1.15.4;
Support sinh(-0.0) and tanh(-0.0).
 1.14 20-Apr-2013  isaki Clean up some useless codes.
 1.13 20-Apr-2013  isaki Fix typo in comment.
 1.12 20-Apr-2013  isaki Terminate a loop in EXT_FRACBITS(64bits) instead of FP_NMANT(83bits).
I don't know why the mantissa of the accumulator is 83bits, but 64bits
or more are not affected.
 1.11 20-Apr-2013  isaki Break a loop off to avoid a long loop even if the precision is not enough.
 1.10 19-Apr-2013  isaki Implement a hyperbolic arctangent (FATANH).
 1.9 19-Apr-2013  isaki Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.8 11-Apr-2013  isaki Introduce FPU_CONST_* constants to avoid a magic number.
 1.7 23-Mar-2013  isaki Remove about updating fpsr. It was introduced by me but obviously
duplicated with fpu_emul_arith().
 1.6 15-Oct-2011  tsutsui branches: 1.6.2; 1.6.12;
Add hyperboric and trigonometric functions to m68k FPE, written by isaki@.
With these emulations (~4KB text) xeyes on XM6i works better.
Discussed with isaki@ at OSC 2011 Hiroshima.
 1.5 18-Jul-2011  isaki fix indent. no functional changes.
 1.4 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.3 11-Dec-2005  christos branches: 1.3.78; 1.3.86; 1.3.92;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.6.12.3 03-Dec-2017  jdolecek update from HEAD
 1.6.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.12.1 23-Jun-2013  tls resync from head
 1.6.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.4.1 18-May-2014  rmind sync with head
 1.16.10.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.16.6.1 05-Feb-2017  skrll Sync with HEAD
 1.15 26-Mar-2013  isaki u_int -> uint32_t
 1.14 22-Mar-2013  isaki Fix fpu_ftox().
Update not only exponential but also mantissa when an integer part
becomes 2 by rounding up. Without this fix, the extended precision
value becomes 0.0 because mantissa (including explicit integer bit)
is all-zero.
 1.13 19-Mar-2013  isaki Remove 'register'.
 1.12 18-Jul-2011  isaki branches: 1.12.2; 1.12.12;
fix indent. no functional changes.
 1.11 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.10 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.9 11-Dec-2005  christos branches: 1.9.78; 1.9.86; 1.9.92;
merge ktrace-lwp.
 1.8 23-Oct-2003  kleink While I'm here, retire the FPE code's own copy of ieee.h.
 1.7 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.6 15-Jul-2003  lukem __KERNEL_RCSID()
 1.5 18-Feb-2001  chs branches: 1.5.24;
rename round() to fpu_round() to avoid a name conflict with
the "round" assembly function in FPSP when building with ELF.
 1.4 30-May-1999  briggs branches: 1.4.2;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.3 19-Jul-1997  is branches: 1.3.14; 1.3.16; 1.3.18;
Fix my own PR port-m68k/3871, nee port-amiga/3871:
- don't erase FPSR exception bits _after_ doing most of the operations in
fpu_implode(), erase them before doing arith and store operations. This fixes
losing the DZ bit.
- create FPSR_OVFL and FPSR_UNFL bits in fpu_implode(). This showed up when
the first error was fixed.
XXX some more work needs to be done. E.g., creating OPERR together with
OVFL looks bogus, but I'm too tired know to re-check docs; and at least we
pass our own regression tests know.
 1.2 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.3.18.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.3.16.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.14.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.3.14.1 21-Jun-1999  perry pullup 1.3->1.4 (briggs): fix FPE
 1.4.2.1 12-Mar-2001  bouyer Sync with HEAD.
 1.5.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.24.1 03-Aug-2004  skrll Sync with HEAD
 1.9.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.78.1 04-May-2009  yamt sync with head.
 1.12.12.1 23-Jun-2013  tls resync from head
 1.12.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12 19-Mar-2013  isaki Remove 'register'.
 1.11 25-Jun-2012  isaki branches: 1.11.2;
Rewrite fpu_int().
Especially, remove the special treatment when |x| < 1
because it forgets to consider FPCR round mode.
See PR/46627 for the detail. Thanks Y.Sugahara for advice.
 1.10 18-Jul-2011  isaki branches: 1.10.2; 1.10.8;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.9 18-Jul-2011  isaki fix indent. no functional changes.
 1.8 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.7 11-Dec-2005  christos branches: 1.7.78; 1.7.86; 1.7.92;
merge ktrace-lwp.
 1.6 15-Jul-2003  lukem __KERNEL_RCSID()
 1.5 30-May-2002  thorpej branches: 1.5.6;
Fix undefined operation (= is not a sequence point).
 1.4 18-Feb-2001  chs branches: 1.4.4; 1.4.8; 1.4.16;
rename round() to fpu_round() to avoid a name conflict with
the "round" assembly function in FPSP when building with ELF.
 1.3 22-Sep-2000  is fpu_emulate.h:
the fmovecr constant table has the internal format
of the constants. So, when changing the mantissa size by a
non-multiple of 32 bits, we'd have to change this table, too. As
all other code changes just chopped of the least significand
32bit word of the mantissa, we correct the mantissa size instead
to (115 - 32 == 83) bits.
fpu_fmovecr.c:
put a safety belt in, to catch the next person who doesn't know this.
fpu_int.c:
in one place, the reduction of the mantissa size was overlooked.
fpu_log.c:
as the most significand 32bit word of the mantissa was changed back to the
old format, change back the table indexing code, too.

This should fix PR 11045.
 1.2 30-May-1999  briggs branches: 1.2.2; 1.2.12;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.12.1 26-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

fpu_emulate.h 1.7, fpu_log.c 1.7: synchronize mantissa length % 32 with fpu_fmovecr.c table
fpu_fmovecr.c 1.8: cheap compile-time consistency check for this
fpu_int.c 1.3: fix bug introduced when reducing mantissa size
This fixes PR 11045.
 1.2.2.2 12-Mar-2001  bouyer Sync with HEAD.
 1.2.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.4.16.1 14-Jul-2002  gehenna catch up with -current.
 1.4.8.1 20-Jun-2002  nathanw Catch up to -current.
 1.4.4.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.5.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.5.6.1 03-Aug-2004  skrll Sync with HEAD
 1.7.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.7.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.7.78.1 04-May-2009  yamt sync with head.
 1.10.8.1 04-Jul-2012  jdc Pull up revision 1.11 (requested by isaki in ticket #384).

Rewrite fpu_int().
Especially, remove the special treatment when |x| < 1
because it forgets to consider FPCR round mode.
See PR/46627 for the detail. Thanks Y.Sugahara for advice.
 1.10.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.10.2.1 30-Oct-2012  yamt sync with head
 1.11.2.1 23-Jun-2013  tls resync from head
 1.18 04-Jan-2014  isaki FLOGNP1(-0.0) is -0.0, not +0.0. Found by XM6i.
 1.17 20-Apr-2013  isaki branches: 1.17.4;
Clean up some useless codes.
 1.16 11-Apr-2013  isaki Introduce FPU_CONST_* constants to avoid a magic number.
 1.15 26-Mar-2013  isaki u_int -> uint32_t
 1.14 18-Jul-2011  isaki branches: 1.14.2; 1.14.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.13 18-Jul-2011  isaki fix indent. no functional changes.
 1.12 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.11 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.10 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.9 11-Dec-2005  christos branches: 1.9.78; 1.9.86; 1.9.92;
merge ktrace-lwp.
 1.8 15-Jul-2003  lukem __KERNEL_RCSID()
 1.7 22-Sep-2000  is branches: 1.7.24;
fpu_emulate.h:
the fmovecr constant table has the internal format
of the constants. So, when changing the mantissa size by a
non-multiple of 32 bits, we'd have to change this table, too. As
all other code changes just chopped of the least significand
32bit word of the mantissa, we correct the mantissa size instead
to (115 - 32 == 83) bits.
fpu_fmovecr.c:
put a safety belt in, to catch the next person who doesn't know this.
fpu_int.c:
in one place, the reduction of the mantissa size was overlooked.
fpu_log.c:
as the most significand 32bit word of the mantissa was changed back to the
old format, change back the table indexing code, too.

This should fix PR 11045.
 1.6 30-May-1999  briggs branches: 1.6.2; 1.6.12;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.5 13-Oct-1996  christos branches: 1.5.22; 1.5.24; 1.5.26;
backout previous kprintf change
 1.4 11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.3 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.2 05-Nov-1995  briggs Fixes from Ken Nakata. Mainly renaming debug_level to fpu_debug_level.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.5.26.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.5.24.1 21-Jun-1999  thorpej Sync w/ -current.
 1.5.22.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.5.22.1 21-Jun-1999  perry pullup 1.5->1.6 (briggs): fix FPE
 1.6.12.1 26-Sep-2000  is Pullup from -current, requested by is, approved by thorpej:

fpu_emulate.h 1.7, fpu_log.c 1.7: synchronize mantissa length % 32 with fpu_fmovecr.c table
fpu_fmovecr.c 1.8: cheap compile-time consistency check for this
fpu_int.c 1.3: fix bug introduced when reducing mantissa size
This fixes PR 11045.
 1.6.2.1 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.7.24.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.7.24.2 18-Sep-2004  skrll Sync with HEAD.
 1.7.24.1 03-Aug-2004  skrll Sync with HEAD
 1.9.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.9.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.9.78.1 04-May-2009  yamt sync with head.
 1.14.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.14.12.1 23-Jun-2013  tls resync from head
 1.14.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.17.4.1 18-May-2014  rmind sync with head
 1.9 06-Dec-2016  isaki Fix sign of NAN. Found by XM6i.
 1.8 26-Mar-2013  isaki branches: 1.8.12; 1.8.16;
u_int -> uint32_t
 1.7 19-Mar-2013  isaki Remove 'register'.
 1.6 14-Mar-2009  dsl branches: 1.6.12; 1.6.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.86; 1.5.92;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 30-May-1999  briggs branches: 1.2.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.36.1 03-Aug-2004  skrll Sync with HEAD
 1.5.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.6.22.2 03-Dec-2017  jdolecek update from HEAD
 1.6.22.1 23-Jun-2013  tls resync from head
 1.6.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8.16.1 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.8.12.1 05-Feb-2017  skrll Sync with HEAD
 1.18 19-Nov-2023  isaki m68k: Remove an unused variable since rev 1.1.
Detected by clang15 (nono emulator has imported and used this FPE).
 1.17 05-Feb-2015  isaki Fix typo in comment. pointed out by Y.Sugahara.
 1.16 11-May-2013  isaki branches: 1.16.10;
Revise the algorithm after Step3.
almost written by Y.Sugahara and minor modify by me.
This works for all input of FMOD/FREM and of course solves PR/47810.
 1.15 05-May-2013  isaki R := X even if L < 0 in Step2, according to algorithm of the comment.
This solves many cases of |X| < |Y|.
 1.14 05-May-2013  isaki Rename modrem -> is_mod for a readability.
 1.13 26-Mar-2013  isaki u_int -> uint32_t
 1.12 26-Mar-2013  isaki Fix a wrong "raw" comparison in step3.2.
It should solve a PR kern/47692.
 1.11 18-Jul-2011  isaki branches: 1.11.2; 1.11.12;
fix indent again.
- "Second level indents are four spaces." pointed out by tsutsui@
- fold long line.
 1.10 18-Jul-2011  isaki fix indent. no functional changes.
 1.9 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.8 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.7 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.6 11-Dec-2005  christos branches: 1.6.78; 1.6.86; 1.6.92;
merge ktrace-lwp.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 30-May-1999  briggs branches: 1.4.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.3 30-Apr-1996  briggs branches: 1.3.24; 1.3.26; 1.3.28;
Bring back Step9 and fix an oversight from Ken Nakata <kenn@remus.rutgers.edu>
 1.2 30-Apr-1996  briggs Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.3.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.3.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.3.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.3.24.1 21-Jun-1999  perry pullup 1.3->1.4 (briggs): fix FPE
 1.4.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.36.1 03-Aug-2004  skrll Sync with HEAD
 1.6.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.78.1 04-May-2009  yamt sync with head.
 1.11.12.2 03-Dec-2017  jdolecek update from HEAD
 1.11.12.1 23-Jun-2013  tls resync from head
 1.11.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.16.10.1 06-Apr-2015  skrll Sync with HEAD
 1.9 24-May-2022  andvar s/equivalant/equivalent/ in copy pasted comment.
 1.8 26-Mar-2013  isaki u_int -> uint32_t
 1.7 19-Mar-2013  isaki Remove 'register'.
 1.6 14-Mar-2009  dsl branches: 1.6.12; 1.6.22;
Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.5 11-Dec-2005  christos branches: 1.5.78; 1.5.86; 1.5.92;
merge ktrace-lwp.
 1.4 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.3 15-Jul-2003  lukem __KERNEL_RCSID()
 1.2 30-May-1999  briggs branches: 1.2.36;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.1 03-Nov-1995  briggs branches: 1.1.24; 1.1.26; 1.1.28;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.1.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.1.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.1.24.1 21-Jun-1999  perry pullup 1.1->1.2 (briggs): fix FPE
 1.2.36.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.36.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.36.1 03-Aug-2004  skrll Sync with HEAD
 1.5.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.5.78.1 04-May-2009  yamt sync with head.
 1.6.22.1 23-Jun-2013  tls resync from head
 1.6.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12 21-Apr-2013  isaki M68010 -> __mc68010__, pointed out by tsutsui@
 1.11 20-Apr-2013  isaki Rewrite around BFFFO inline asm.
o Prepare C version of BFFFO (from XM6i).
It is helpful in running FPE on other platforms (for example, for a
test). It is also helpful in porting to non-m68k 3rd party :)
o A BFFFO is supported on 68020 or later (though I'm not sure whether
sun2/68010 uses this FPE correctly or not).
 1.10 26-Mar-2013  isaki u_int -> uint32_t
 1.9 19-Mar-2013  isaki Remove 'register'.
 1.8 24-Dec-2005  perry branches: 1.8.112; 1.8.122;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.
 1.7 11-Dec-2005  christos merge ktrace-lwp.
 1.6 07-Aug-2003  agc branches: 1.6.16;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.5 15-Jul-2003  lukem __KERNEL_RCSID()
 1.4 29-Dec-2002  kristerw branches: 1.4.2;
Use "__asm __volatile" instead of "asm volatile" to pacify lint.
 1.3 30-May-1999  briggs branches: 1.3.20;
PR 7220 from Ken Nakata:
I've fixed most (not all) m68k FPE bugs that give bogus
calculation results, esp. fsqrt instruction. Also, the internal FP
representation has been reduced from 115-bit mantissa to 67-bit
mantissa which reduced the required mantissa operation roughly by one
fourth. I've done an extensive (though not exhaustive - it's
impossible!) test on the internal routines by feeding them randomly
generated FP numbers, and found that the new code is more precise than
MC68040 FPU (it seems to have a rounding bug).

[ Only change was to keep fpu_calcea.c's name instead of renaming to
fpu_ea.c in Ken's patch. --akb ]
 1.2 30-Apr-1996  briggs branches: 1.2.24; 1.2.26; 1.2.28;
Update for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized.
 1.1 03-Nov-1995  briggs Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.2.28.1 30-Nov-1999  itojun bring in latest KAME (as of 19991130, KAME/NetBSD141) into kame branch
just for reference purposes.
This commit includes 1.4 -> 1.4.1 sync for kame branch.

The branch does not compile at all (due to the lack of ALTQ and some other
source code). Please do not try to modify the branch, this is just for
referenre purposes.

synchronization to latest KAME will take place on HEAD branch soon.
 1.2.26.1 21-Jun-1999  thorpej Sync w/ -current.
 1.2.24.2 06-Feb-2000  he Apply patch (requested by is):
Revert floating point emulation software to the version released
as NetBSD 1.4. The upgrade done in 1.4.1 had problems.
 1.2.24.1 21-Jun-1999  perry pullup 1.2->1.3 (briggs): fix FPE
 1.3.20.1 29-Dec-2002  thorpej Sync with HEAD.
 1.4.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.4.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.4.2.1 03-Aug-2004  skrll Sync with HEAD
 1.6.16.1 21-Jun-2006  yamt sync with head.
 1.8.122.1 23-Jun-2013  tls resync from head
 1.8.112.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.18 16-Jan-2017  isaki FSINCOS: Fix register address which writes cosine value back.
 1.17 06-Aug-2016  isaki branches: 1.17.2;
Modify fpu_sin()'s logic to avoid GCC's warning that has been
pointed out in the previous commit.
For fpu_cos() there is no such problem, but sync with fpu_sin().
 1.16 23-Mar-2016  mrg branches: 1.16.2;
avoid a GCC warning with this:

+#if defined(__GNUC__) && (__GNUC__ >= 5) && defined(__OPTIMIZE__)
+ x.fp_sign = 0;
+#endif

(ridiculous, but seems better than disabling the warning entirely.)
 1.15 20-Apr-2013  isaki branches: 1.15.12;
Support sin(-0.0).
 1.14 20-Apr-2013  isaki Clean up some useless codes.
 1.13 20-Apr-2013  isaki Support tan(-0.0).
 1.12 19-Apr-2013  isaki Implement inverse trigonometric functions (i.e., FACOS, FASIN, FATAN
instructions).
o arccos is calculated using arcsin.
o arcsin is calculated using arctan.
o arctan is calculated by the CORDIC.
 1.11 19-Apr-2013  isaki Introduce the CORDIC algorithm.
o sine and cosine (e.g., FSIN, FCOS and FSINCOS instructions) is now
calculated in the CORDIC instead of Taylor expansion.
o tangent (FTAN) is not touched from a viewpoint of the code size.
o The CORDIC is applicable for hyperbolic functions (e.g., FSINH,
FCOSH, FTANH instructions), but I didn't use it because its working
range is poor.
o The CORDIC is also usable for inverse trigonometric functions,
I will commit it at next phase.
o The code size becomes a bit big. I cannot evaluate speed on m68k
for some reasons, but in test on i386 the CORDIC is approximately
100 times faster in sin/cos.
 1.10 18-Apr-2013  isaki Improve how to use cmp/sub.
 1.9 11-Apr-2013  isaki Introduce FPU_CONST_* constants to avoid a magic number.
 1.8 26-Mar-2013  isaki u_int -> uint32_t
 1.7 23-Mar-2013  isaki Remove about updating fpsr. It was introduced by me but obviously
duplicated with fpu_emul_arith().
 1.6 15-Oct-2011  tsutsui branches: 1.6.2; 1.6.12;
Add hyperboric and trigonometric functions to m68k FPE, written by isaki@.
With these emulations (~4KB text) xeyes on XM6i works better.
Discussed with isaki@ at OSC 2011 Hiroshima.
 1.5 18-Jul-2011  isaki fix indent. no functional changes.
 1.4 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.3 11-Dec-2005  christos branches: 1.3.78; 1.3.86; 1.3.92;
merge ktrace-lwp.
 1.2 15-Jul-2003  lukem __KERNEL_RCSID()
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.64.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD
 1.3.92.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.86.1 28-Apr-2009  skrll Sync with HEAD.
 1.3.78.1 04-May-2009  yamt sync with head.
 1.6.12.2 03-Dec-2017  jdolecek update from HEAD
 1.6.12.1 23-Jun-2013  tls resync from head
 1.6.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.15.12.3 05-Feb-2017  skrll Sync with HEAD
 1.15.12.2 05-Oct-2016  skrll Sync with HEAD
 1.15.12.1 22-Apr-2016  skrll Sync with HEAD
 1.16.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.17.2.1 21-Apr-2017  bouyer Sync with HEAD
 1.3 23-Oct-2003  kleink While I'm here, retire the FPE code's own copy of ieee.h.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 03-Nov-1995  briggs branches: 1.1.64;
Still incomplete, but much more complete FPE from Ken Nakata
<kenn@remus.rutgers.edu>. This emulator does not yet emulate
the following functions:
FSINH, FETOXM1, FTANH, FATAN, FASIN, FATANH, FSIN, FTAN,
FETOX, FTWOTOX, FTENTOX, FCOSH, FACOS, FCOS, FSINCOS
It is sufficient, however, to allow programs like df, w, and newfs,
to run to completion with correct results.
Portions of this code were based on the sparc fpe and on initial
work by gwr.
 1.1.64.1 03-Aug-2004  skrll Sync with HEAD

RSS XML Feed