Skip to content
Browse files

Don't use obsolete math implementations by default

Enabling the old math code removes some useful functions from the
library, uses some stale code and generally isn't a good plan. The new
math code requires newer compiler features (post 1999).

Signed-off-by: Keith Packard <>
  • Loading branch information
keith-packard committed Oct 8, 2019
1 parent 095508c commit f09de59ce94ff67464dcac13cf2419342feb51a5
Showing with 2 additions and 2 deletions.
  1. +2 −2 newlib/libc/include/machine/ieeefp.h
@@ -461,8 +461,8 @@

/* Use old math code by default. */
/* Use new math code by default. */

2 comments on commit f09de59


This comment has been minimized.

Copy link

innerand replied Nov 29, 2019

The new math uses doubles internally for float functions (eg sinf()).
This pulls in double arithmetic code increasing flash usage by ~3k at my project.

Would you mind making this an configuration option?


This comment has been minimized.

Copy link
Owner Author

keith-packard replied Nov 29, 2019

I didn't look at the math code closely enough to understand all of the differences that this option controlled.

I've fixed a bug in the code used by __OBSOLETE_MATH in sf_log1p.c so that it doesn't pull in double precision __math_divzero and __math_invalid functions.

Then, I reverted the __OBSOLETE_MATH_DEFAULT value back to 1.

Finally, I added a new configuration option 'newlib-obsolete-math', which you can set to 'true' to force
obsolete math, or leave at 'auto', which will use the default value of 1.

I've tested by linking essentially every math function into an application and verifying that no double precision routines were linked. That, sadly, also requires removing floating point printf support as that can only use doubles due to C calling convention. So, anything printing double values will still haul in all of the double math functions.

Please sign in to comment.
You can’t perform that action at this time.