[PATCH] libm fixes for 16-bit targets

jon@beniston.com jon@beniston.com
Fri Aug 31 22:34:00 GMT 2018


Hi,

Attached are a couple of patches to libm to fix warnings when compiling for
16-bit targets.

The first in e_scalb.c calls scalbln instead of scalbn, as 65000 is out of
range for an 'int'.

+#if INT_MAX == 32767
+	if ( fn > 65000.0) return scalbln(x, 65000);
+	if (-fn > 65000.0) return scalbln(x,-65000);
+#else
 	if ( fn > 65000.0) return scalbn(x, 65000);
 	if (-fn > 65000.0) return scalbn(x,-65000);
+#endif

The second in math_config.h (issignalingf_inline) fixes the signed overflow
warning that occurs.

-  return 2 * (ix ^ 0x00400000) > 2u * 0x7fc00000;
+  return 2 * (ix ^ 0x00400000) > 0xFF800000u;

Although I hope I'm not missing something subtle with the mixing of the
types there.

Cheers,
Jon

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-e_scalb.c-Call-scalbln-instead-of-scalbn-on-16-bit-t.patch
Type: application/octet-stream
Size: 885 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20180831/708e34fb/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-math_config.h-Fix-signed-overflow-warning-for-16-bit.patch
Type: application/octet-stream
Size: 805 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20180831/708e34fb/attachment-0001.obj>


More information about the Newlib mailing list