English Amiga Board

Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

Thread Tools
Old 12 August 2014, 19:53   #1
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.

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

Last edited by matthey; 16 January 2015 at 23:57.
matthey is offline  

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Discovery: Math Audio Snow request.Old Rare Games 30 20 August 2018 13:17
Mixed 68k / PPC code on VBCC. Cowcat Coders. General 10 01 August 2013 17:01
Math library? Tiddlypeeps Coders. General 5 08 April 2010 20:45
Math apps mtb support.Apps 1 08 September 2002 19:59

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 00:11.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Page generated in 0.11345 seconds with 16 queries