English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. C/C++ (http://eab.abime.net/forumdisplay.php?f=118)
-   -   vbcc C99 math for the 68k FPU (http://eab.abime.net/showthread.php?t=74692)

matthey 12 August 2014 18:53

vbcc C99 math for the 68k FPU
1 Attachment(s)
I have attached a version of the vbcc C99 fp math libraries and includes for testing. These are updated m881.lib, m040.lib, and m060.lib link libraries with more C99 functions, better compliance with C99 and more optimization than before. After making backups of the original files, the lib files go in the 68k lib directory (vlibos3: on my install) and the includes go in the includes directory (vincludeos3: on my install) for the m68k-amigaos target. The math.h header file needs to be included at the beginning of any programs and then compiling goes something like this:

VC -c99 -O1 -cpu=68060 -fpu=68060 -lm060 program.c -o program
VC -c99 -O1 -cpu=68040 -fpu=68040 -lm040 program.c -o program
VC -c99 -O1 -cpu=68020 -fpu=68881 -lm881 program.c -o program

Plus add any other options wanted. Please post any bugs or comments here.

I attached version 6 (c99lm68k6.lha) of the test archive which needs to be applied to a vbcc 0.9d install with m68k-amigaos target.


Fixes include:

- ldexp, ldexpf for the m060.lib did not produce the correct result
- acoshf and asinhf for m881.lib would cause a link error
- missing function declarations added to math.h
- c99 compliance of some functions improved

Functions included are now the same for all targets:

acos, acosh, asin, asinh, atan, atanh, atan2, cbrt, ceil, copysign, cos, cosh, exp, exp10, exp2, expm1, fabs, fdim, floor, fma, fmax, fmin, fmod, frexp, hypot, ilogb, ldexp, llround (requires -c99), log, log10, log2, log1p, logb, lround, modf, nan, nearbyint, pow, remainder, round, sin, sinh, sqrt, tan, tanh, trunc

macros: fpclassify, isfinite, isnormal, isnan, isinf, signbit isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered

There are also various fenv.h functions although exception handling is currently disabled.

No trapped FPU instructions should be generated now when using m040.lib and m060.lib. I don't know of any other 68k compiler with an Amiga target which can avoid all emulated FPU instructions.

Single precision and long double precision versions of c99 functions are also included although long double=double (64 bit). Intermediate precision is extended precision where practical.

The new libs initialize the FPU so the default rounding mode is round to nearest (ties to even) and the rounding precision is extended precision. Changing the rounding mode should have little effect on the return values of functions (hopefully an improvement). Changing the rounding precision will likely have an effect, especially if changing to round to single precision (not recommended).

Special thanks to Frank Wille for all the help.

All times are GMT +2. The time now is 07:38.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.

Page generated in 0.04663 seconds with 11 queries