View Single Post
Old 12 August 2014, 18:53   #1
matthey
Banned
 
Join Date: Jan 2010
Location: Kansas
Posts: 1,284
vbcc C99 math for the 68k FPU

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.

Edit:
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.

http://sun.hasenbraten.de/vbcc/

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.
Attached Files
File Type: lha c99lm68k6.lha (89.4 KB, 192 views)

Last edited by matthey; 16 January 2015 at 22:57.
matthey is offline  
 
Page generated in 0.08005 seconds with 12 queries