[libc] Initial support for OpenWatcom soft floating point #2246
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds initial support for software (emulated) floating point to ELKS programs compiled with OpenWatcom C.
Discussed in #2239 (comment).
By default, inline 8087 support is turned off, and
ewcc
uses the-msoft-float
option (-Wc,-fpc) to produce calls to software floating point routines contained in the C library forfloat
anddouble
precision floating point.In order to turn on %f, %e and %g printf output, the following must be included in the application source in a function somewhere, or the dtostr() double-to-string formatting routines will not be linked in, and nothing will be output. Due to technical issues with weak symbols, only medium and large models are currently supported:
The above code is not necessary if floating point numbers do not need to be displayed using printf.
There is currently no math library for OWC. OWC documentation states that software emulated floating point is not IEEE 754 compliant; it is unknown exactly what that means.
This is a feature preview, it is not recommended to start using floating point in your own programs without special testing. This PR has been tested with ELKS basic, which seems to work, although still no math library. Producing a math library may not be easily possible, depending on learning more about non-IEEE support for emulated floating point, and/or porting the OWC math library vs the ELKS math library.
Programmers should remove any inline hardware 8087 code generation options (e.g. -Wc,-fpi or -Wc,-fpi87) and use
ewcc
or add-msoft-float
to their OWCC command line.Support for FP overflow and underflow is non-existent, and may produce entirely incorrect results and/or abort program execution. Fix coming.
The OWC floating point emulation library has some 8087 and 80386 code in it that had to be included - it is not known whether or how well OWC programs will run on older 8086 hardware - this still needs testing. In the future, a
basic.os2
built with OWC will be supplied for testing on 8086 hardware.