Re: svn commit: r322418 - head/lib/msun/src

2017-08-12 Thread Ryan Libby
On Sat, Aug 12, 2017 at 2:53 PM, Ngie Cooper (yaneurabeya)
 wrote:
[...]
> Here are the full gamut of definitions for LDBL_MAX_EXP. It seems 
> that sparc64 isn’t the only architecture using this pattern:
>
> $ grep -r DBL_MAX_EXP sys/*/include
> sys/arm/include/float.h:#define DBL_MAX_EXP 1024
> sys/arm/include/float.h:#define LDBL_MAX_EXPDBL_MAX_EXP
> sys/arm64/include/float.h:#define   DBL_MAX_EXP 1024
> sys/arm64/include/float.h:#define   LDBL_MAX_EXP(+16384)
> sys/mips/include/float.h:#defineDBL_MAX_EXP 1024
> sys/mips/include/float.h:#defineLDBL_MAX_EXPDBL_MAX_EXP
> sys/powerpc/include/float.h:#define DBL_MAX_EXP 1024
> sys/powerpc/include/float.h:#define LDBL_MAX_EXPDBL_MAX_EXP
> sys/riscv/include/float.h:#define   DBL_MAX_EXP 1024
> sys/riscv/include/float.h:#define   LDBL_MAX_EXP(+16384)
> sys/sparc64/include/float.h:#define DBL_MAX_EXP 1024
> sys/sparc64/include/float.h:#define LDBL_MAX_EXP(+16384)
> sys/x86/include/float.h:#define DBL_MAX_EXP 1024
> sys/x86/include/float.h:#define LDBL_MAX_EXP16384
>
> It might also be an inconsistency with how clang vs gcc [4.2.1] 
> handles __CONCAT, and what -std= flags are passed to ${CC} in the Makefile, 
> since the implementation is predicated by whether or not it’s C++ or __STDC__ 
> is defined. There might be an update that we can grab from NetBSD (since the 
> macro originated there).
> I don’t understand [right now] why the (+foo) form is used *shrugs*.

Yeah, unsure.  Aesthetically it mirrors the declaration for the macros
with negative values such as LDBL_MIN_EXP (where the parentheses do have
a functional purpose), but in sys/*/include/{_limits.h,_stdint.h} by
comparison we don't have parens around the positive values.

Anyway maybe the macro pasting method is just too fragile of a hack.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Re: svn commit: r322418 - head/lib/msun/src

2017-08-12 Thread Ngie Cooper (yaneurabeya)

> On Aug 12, 2017, at 14:45, Ngie Cooper (yaneurabeya)  
> wrote:
> 
>> 
>> On Aug 12, 2017, at 10:55, Ryan Libby  wrote:
> 
> …
> 
>> A few possible quick fixes:
>> 
>> - Change the {arm64,riscv,sparc64}/include/float.h LDBL_MAX_EXP
>>  definitions from (+16384) to 16384.
>> 
>> - Change HALF_LDBL_MAX from
>> #define HALF_LDBL_MAX __CONCAT(__CONCAT(0x0.8p, LDBL_MAX_EXP), L)
>>  to
>> #if LDBL_MAX_EXP != 0x4000
>> #error "Unsupported long double format"
>> #endif
>> #define HALF_LDBL_MAX 0x0.8p16384L
>> 
>> - Change the HALF_LDBL_MAX constant to a variable constructed with
>>  LD80C(), I think with
>> LD80C(0x8000, 16383, 5.9486574767861588254e+4931L)
>>  but this also requires #error for LDBL_MAX_EXP != 0x4000, so not
>>  really any better than the above.
>> 
>> I think I will back the patch out for now and go back to review.
> 
> The issue is an inconsistency with how LDBL_MAX_EXP is defined in the MD 
> headers:

* is an -> is due to an

> $ grep -r LDBL_MAX_EXP sys/sparc64/
> sys/sparc64/include/float.h:#define LDBL_MAX_EXP(+16384)
> $ grep -r LDBL_MAX_EXP sys/x86/
> sys/x86/include/float.h:#define LDBL_MAX_EXP16384

Here are the full gamut of definitions for LDBL_MAX_EXP. It seems that 
sparc64 isn’t the only architecture using this pattern:

$ grep -r DBL_MAX_EXP sys/*/include
sys/arm/include/float.h:#define DBL_MAX_EXP 1024
sys/arm/include/float.h:#define LDBL_MAX_EXPDBL_MAX_EXP
sys/arm64/include/float.h:#define   DBL_MAX_EXP 1024
sys/arm64/include/float.h:#define   LDBL_MAX_EXP(+16384)
sys/mips/include/float.h:#defineDBL_MAX_EXP 1024
sys/mips/include/float.h:#defineLDBL_MAX_EXPDBL_MAX_EXP
sys/powerpc/include/float.h:#define DBL_MAX_EXP 1024
sys/powerpc/include/float.h:#define LDBL_MAX_EXPDBL_MAX_EXP
sys/riscv/include/float.h:#define   DBL_MAX_EXP 1024
sys/riscv/include/float.h:#define   LDBL_MAX_EXP(+16384)
sys/sparc64/include/float.h:#define DBL_MAX_EXP 1024
sys/sparc64/include/float.h:#define LDBL_MAX_EXP(+16384)
sys/x86/include/float.h:#define DBL_MAX_EXP 1024
sys/x86/include/float.h:#define LDBL_MAX_EXP16384

It might also be an inconsistency with how clang vs gcc [4.2.1] handles 
__CONCAT, and what -std= flags are passed to ${CC} in the Makefile, since the 
implementation is predicated by whether or not it’s C++ or __STDC__ is defined. 
There might be an update that we can grab from NetBSD (since the macro 
originated there).
I don’t understand [right now] why the (+foo) form is used *shrugs*.
Cheers,
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r322418 - head/lib/msun/src

2017-08-12 Thread Ngie Cooper (yaneurabeya)

> On Aug 12, 2017, at 10:55, Ryan Libby  wrote:

…

> A few possible quick fixes:
> 
> - Change the {arm64,riscv,sparc64}/include/float.h LDBL_MAX_EXP
>   definitions from (+16384) to 16384.
> 
> - Change HALF_LDBL_MAX from
> #define HALF_LDBL_MAX __CONCAT(__CONCAT(0x0.8p, LDBL_MAX_EXP), L)
>   to
> #if LDBL_MAX_EXP != 0x4000
> #error "Unsupported long double format"
> #endif
> #define HALF_LDBL_MAX 0x0.8p16384L
> 
> - Change the HALF_LDBL_MAX constant to a variable constructed with
>   LD80C(), I think with
> LD80C(0x8000, 16383, 5.9486574767861588254e+4931L)
>   but this also requires #error for LDBL_MAX_EXP != 0x4000, so not
>   really any better than the above.
> 
> I think I will back the patch out for now and go back to review.

The issue is an inconsistency with how LDBL_MAX_EXP is defined in the MD 
headers:

$ grep -r LDBL_MAX_EXP sys/sparc64/
sys/sparc64/include/float.h:#define LDBL_MAX_EXP(+16384)
$ grep -r LDBL_MAX_EXP sys/x86/
sys/x86/include/float.h:#define LDBL_MAX_EXP16384

Cheers,
-Ngie


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: svn commit: r322418 - head/lib/msun/src

2017-08-12 Thread Ryan Libby
On Sat, Aug 12, 2017 at 9:57 AM, Ryan Libby  wrote:
> On Sat, Aug 12, 2017 at 9:26 AM, Ian Lepore  wrote:
>> On Fri, 2017-08-11 at 22:41 +, Ryan Libby wrote:
>>> Author: rlibby
>>> Date: Fri Aug 11 22:41:24 2017
>>> New Revision: 322418
>>> URL: https://svnweb.freebsd.org/changeset/base/322418
>>>
>>> Log:
>>>   lib/msun: avoid referring to broken LDBL_MAX
>>>
>>>   LDBL_MAX is broken on i386:
>>>   https://lists.freebsd.org/pipermail/freebsd-numerics/2012-September
>>> /000288.html
>>>
>>>   Gcc has produced +Infinity for LDBL_MAX on i386 and amd64 with -m32
>>>   for some time, and newer versions of gcc are now warning that the
>>>   "floating constant exceeds range of 'long double'".  Avoid this by
>>>   referring to half the value of LDBL_MAX instead.
>>>
>>>   Reviewed by:bde
>>>   Approved by:markj (mentor)
>>>   Sponsored by:   Dell EMC Isilon
>>>
>>
>> I now get this error when building toolchain for sparc:
>>
>> cc -isystem 
>> /b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp/usr/include
>>  -L/b/staging/freebsd/head/obj/sparc64.spar
>> c64/b/staging/freebsd/head/src/tmp/usr/lib 
>> -B/b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp/usr/lib
>>  --sysroot=/b/
>> staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp 
>> -B/b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/
>> src/tmp/usr/bin -fPIC -DPIC -g -O2 -pipe 
>> -I/b/staging/freebsd/head/src/lib/msun/ld128 
>> -I/b/staging/freebsd/head/src/lib/msun/sparc64 -I/b/sta
>> ging/freebsd/head/src/lib/msun/src 
>> -I/b/staging/freebsd/head/src/lib/libc/include  
>> -I/b/staging/freebsd/head/src/lib/libc/sparc64   -MD  -MF.
>> depend.catrigl.pico -MTcatrigl.pico -std=gnu99 -fstack-protector-strong 
>> -Wsystem-headers -Werror -Wno-pointer-sign -Wno-unknown-pragmas -
>> c /b/staging/freebsd/head/src/lib/msun/src/catrigl.c -o catrigl.pico
>> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: pasting 
>> "0x0.8p" and "(" does not give a valid preprocessing token
>> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: exponent 
>> has no digits
>> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: pasting ")" 
>> and "L" does not give a valid preprocessing token
>> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c: In function 
>> 'clog_for_large_values':
>> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310: error: expected ')' 
>> before 'L'
>> *** [catrigl.pico] Error code 1
>
> Thanks, I see it.  It also shows up on the sparc64 ci build [1].  Let me
> see if I can find a quick fix, else I guess we can just back it out for
> now.
>
> [1] https://ci.freebsd.org/job/FreeBSD-head-sparc64-build/2534/

A few possible quick fixes:

 - Change the {arm64,riscv,sparc64}/include/float.h LDBL_MAX_EXP
   definitions from (+16384) to 16384.

 - Change HALF_LDBL_MAX from
#define HALF_LDBL_MAX __CONCAT(__CONCAT(0x0.8p, LDBL_MAX_EXP), L)
   to
#if LDBL_MAX_EXP != 0x4000
#error "Unsupported long double format"
#endif
#define HALF_LDBL_MAX 0x0.8p16384L

 - Change the HALF_LDBL_MAX constant to a variable constructed with
   LD80C(), I think with
LD80C(0x8000, 16383, 5.9486574767861588254e+4931L)
   but this also requires #error for LDBL_MAX_EXP != 0x4000, so not
   really any better than the above.

I think I will back the patch out for now and go back to review.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r322418 - head/lib/msun/src

2017-08-12 Thread Ryan Libby
On Sat, Aug 12, 2017 at 9:26 AM, Ian Lepore  wrote:
> On Fri, 2017-08-11 at 22:41 +, Ryan Libby wrote:
>> Author: rlibby
>> Date: Fri Aug 11 22:41:24 2017
>> New Revision: 322418
>> URL: https://svnweb.freebsd.org/changeset/base/322418
>>
>> Log:
>>   lib/msun: avoid referring to broken LDBL_MAX
>>
>>   LDBL_MAX is broken on i386:
>>   https://lists.freebsd.org/pipermail/freebsd-numerics/2012-September
>> /000288.html
>>
>>   Gcc has produced +Infinity for LDBL_MAX on i386 and amd64 with -m32
>>   for some time, and newer versions of gcc are now warning that the
>>   "floating constant exceeds range of 'long double'".  Avoid this by
>>   referring to half the value of LDBL_MAX instead.
>>
>>   Reviewed by:bde
>>   Approved by:markj (mentor)
>>   Sponsored by:   Dell EMC Isilon
>>
>
> I now get this error when building toolchain for sparc:
>
> cc -isystem 
> /b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp/usr/include
>  -L/b/staging/freebsd/head/obj/sparc64.spar
> c64/b/staging/freebsd/head/src/tmp/usr/lib 
> -B/b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp/usr/lib
>  --sysroot=/b/
> staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp 
> -B/b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/
> src/tmp/usr/bin -fPIC -DPIC -g -O2 -pipe 
> -I/b/staging/freebsd/head/src/lib/msun/ld128 
> -I/b/staging/freebsd/head/src/lib/msun/sparc64 -I/b/sta
> ging/freebsd/head/src/lib/msun/src 
> -I/b/staging/freebsd/head/src/lib/libc/include  
> -I/b/staging/freebsd/head/src/lib/libc/sparc64   -MD  -MF.
> depend.catrigl.pico -MTcatrigl.pico -std=gnu99 -fstack-protector-strong 
> -Wsystem-headers -Werror -Wno-pointer-sign -Wno-unknown-pragmas -
> c /b/staging/freebsd/head/src/lib/msun/src/catrigl.c -o catrigl.pico
> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: pasting 
> "0x0.8p" and "(" does not give a valid preprocessing token
> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: exponent has 
> no digits
> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: pasting ")" 
> and "L" does not give a valid preprocessing token
> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c: In function 
> 'clog_for_large_values':
> /b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310: error: expected ')' 
> before 'L'
> *** [catrigl.pico] Error code 1

Thanks, I see it.  It also shows up on the sparc64 ci build [1].  Let me
see if I can find a quick fix, else I guess we can just back it out for
now.

[1] https://ci.freebsd.org/job/FreeBSD-head-sparc64-build/2534/
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r322418 - head/lib/msun/src

2017-08-12 Thread Ian Lepore
On Fri, 2017-08-11 at 22:41 +, Ryan Libby wrote:
> Author: rlibby
> Date: Fri Aug 11 22:41:24 2017
> New Revision: 322418
> URL: https://svnweb.freebsd.org/changeset/base/322418
> 
> Log:
>   lib/msun: avoid referring to broken LDBL_MAX
>   
>   LDBL_MAX is broken on i386:
>   https://lists.freebsd.org/pipermail/freebsd-numerics/2012-September
> /000288.html
>   
>   Gcc has produced +Infinity for LDBL_MAX on i386 and amd64 with -m32
>   for some time, and newer versions of gcc are now warning that the
>   "floating constant exceeds range of 'long double'".  Avoid this by
>   referring to half the value of LDBL_MAX instead.
>   
>   Reviewed by:bde
>   Approved by:markj (mentor)
>   Sponsored by:   Dell EMC Isilon
> 

I now get this error when building toolchain for sparc:

cc -isystem 
/b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp/usr/include
 -L/b/staging/freebsd/head/obj/sparc64.spar
c64/b/staging/freebsd/head/src/tmp/usr/lib 
-B/b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp/usr/lib
 --sysroot=/b/
staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/src/tmp 
-B/b/staging/freebsd/head/obj/sparc64.sparc64/b/staging/freebsd/head/
src/tmp/usr/bin -fPIC -DPIC -g -O2 -pipe 
-I/b/staging/freebsd/head/src/lib/msun/ld128 
-I/b/staging/freebsd/head/src/lib/msun/sparc64 -I/b/sta
ging/freebsd/head/src/lib/msun/src 
-I/b/staging/freebsd/head/src/lib/libc/include  
-I/b/staging/freebsd/head/src/lib/libc/sparc64   -MD  -MF.
depend.catrigl.pico -MTcatrigl.pico -std=gnu99 -fstack-protector-strong 
-Wsystem-headers -Werror -Wno-pointer-sign -Wno-unknown-pragmas -
c /b/staging/freebsd/head/src/lib/msun/src/catrigl.c -o catrigl.pico
/b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: pasting 
"0x0.8p" and "(" does not give a valid preprocessing token
/b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: exponent has 
no digits
/b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310:1: error: pasting ")" 
and "L" does not give a valid preprocessing token
/b/staging/freebsd/head/src/lib/msun/src/catrigl.c: In function 
'clog_for_large_values':
/b/staging/freebsd/head/src/lib/msun/src/catrigl.c:310: error: expected ')' 
before 'L'
*** [catrigl.pico] Error code 1

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r322418 - head/lib/msun/src

2017-08-11 Thread Ryan Libby
Author: rlibby
Date: Fri Aug 11 22:41:24 2017
New Revision: 322418
URL: https://svnweb.freebsd.org/changeset/base/322418

Log:
  lib/msun: avoid referring to broken LDBL_MAX
  
  LDBL_MAX is broken on i386:
  
https://lists.freebsd.org/pipermail/freebsd-numerics/2012-September/000288.html
  
  Gcc has produced +Infinity for LDBL_MAX on i386 and amd64 with -m32
  for some time, and newer versions of gcc are now warning that the
  "floating constant exceeds range of 'long double'".  Avoid this by
  referring to half the value of LDBL_MAX instead.
  
  Reviewed by:  bde
  Approved by:  markj (mentor)
  Sponsored by: Dell EMC Isilon

Modified:
  head/lib/msun/src/catrigl.c
  head/lib/msun/src/math_private.h
  head/lib/msun/src/s_csqrtl.c

Modified: head/lib/msun/src/catrigl.c
==
--- head/lib/msun/src/catrigl.c Fri Aug 11 22:39:38 2017(r322417)
+++ head/lib/msun/src/catrigl.c Fri Aug 11 22:41:24 2017(r322418)
@@ -307,7 +307,7 @@ clog_for_large_values(long double complex z)
ay = t;
}
 
-   if (ax > LDBL_MAX / 2)
+   if (ax >= HALF_LDBL_MAX)
return (CMPLXL(logl(hypotl(x / m_e, y / m_e)) + 1,
atan2l(y, x)));
 

Modified: head/lib/msun/src/math_private.h
==
--- head/lib/msun/src/math_private.hFri Aug 11 22:39:38 2017
(r322417)
+++ head/lib/msun/src/math_private.hFri Aug 11 22:41:24 2017
(r322418)
@@ -272,6 +272,15 @@ do {   
\
 #defineLD80C(m, ex, v) { .e = (v), }
 #endif
 
+/*
+ * XXX LDBL_MAX is broken on i386.  If the precise value of LDBL_MAX is not
+ * needed, this may be worked around by instead referring to a proxy, such
+ * as HALF_LDBL_MAX, below.  HALF_LDBL_MAX is approximately LDBL_MAX / 2,
+ * actually just greater than.  Note that 2 * HALF_LDBL_MAX will always
+ * overflow to infinity, regardless of the precision and rounding modes.
+ */
+#defineHALF_LDBL_MAX   __CONCAT(__CONCAT(0x0.8p, LDBL_MAX_EXP), L)
+
 #ifdef FLT_EVAL_METHOD
 /*
  * Attempt to get strict C99 semantics for assignment with non-C99 compilers.

Modified: head/lib/msun/src/s_csqrtl.c
==
--- head/lib/msun/src/s_csqrtl.cFri Aug 11 22:39:38 2017
(r322417)
+++ head/lib/msun/src/s_csqrtl.cFri Aug 11 22:41:24 2017
(r322418)
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
 #pragmaSTDC CX_LIMITED_RANGE   ON
 
 /* We risk spurious overflow for components >= LDBL_MAX / (1 + sqrt(2)). */
-#defineTHRESH  (LDBL_MAX / 2.414213562373095048801688724209698L)
+#defineTHRESH  (HALF_LDBL_MAX / 1.207106781186547524400844362104849L)
 
 long double complex
 csqrtl(long double complex z)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"