Re: support for bitwise comparison of floats

2007-03-25 Thread Bruno Haible
Eric Blake wrote:
> You can also assume IEEE rules, and compare against signed infinity:
> 1 / +0. => +infinity
> 1 / -0. => -infinity

Nice trick :-)

But here you depend on the IEEE rules for exceptions upon division by zero.
  - On Alpha processors, division by zero (and even overflow!) leads to a SIGFPE
signal by default. And it requires the use of a system call to change
the FP exceptions control mask (the  routines in glibc >= 2.1,
the __setfpucw function in glibc 2.0). memcmp is certainly much cheaper.
  - On all processors, the caller could also have modified the FP exceptions
control mask, through the facilities declared in  or 
(FreeBSD, IRIX) or  (AIX) or  (AIX). For this case,
we would need to deal with all possible CPU / OS / kernel combinations...

Bruno





Re: gnulib support for st_birthtime

2007-03-25 Thread James Youngman

On 3/25/07, Bruno Haible <[EMAIL PROTECTED]> wrote:

This is Paul's domain; nevertheless I'd like to mention that native Woe32
platforms (mingw, msvc, but not Cygwin) implementation of stat() and
fstat() store the "file creation time" in st_ctime. This is even documented
on msdn.microsoft.com. Therefore you should be able to write

#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
static inline int
get_stat_birthtime (struct stat const *st, struct timespec *pts)
{
  pts->tv_sec = st->st_ctime;
  pts->tv_nsec = 0;
  return 0;
}
#else
...
#endif


OK.   That's a useful change (except that the function should return 1
for this case).  However, this is a change which I cannot test since I
have no Woe32 system.  I will push the change into findutils (instead
of using it indirectly in gnulib) and test it there for a bit.

There's at least one Cygwin user on the findutils mailing list who
might also be able to test this under mingw.

So, please don't apply my previous patch, since it needs this update
(and I will also update my change to support birthtime on Cygwin).

James.




Re: support for bitwise comparison of floats

2007-03-25 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 3/25/2007 4:54 AM:
> Eric Blake wrote:
>> You can also assume IEEE rules, and compare against signed infinity:
>> 1 / +0. => +infinity
>> 1 / -0. => -infinity
> 
> Nice trick :-)

Thanks for correcting my typo; which I realized after I sent my other
message. :)

> 
> But here you depend on the IEEE rules for exceptions upon division by zero.
>   - On Alpha processors, division by zero (and even overflow!) leads to a 
> SIGFPE
> signal by default. And it requires the use of a system call to change
> the FP exceptions control mask (the  routines in glibc >= 2.1,
> the __setfpucw function in glibc 2.0). memcmp is certainly much cheaper.

Raw operations on bits is much faster than actual floating point in a
number of cases; as you have noted, the problem is the portability in
detecting where the raw bits are.  Your method appears fine to me.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBoBe84KuGfSFAYARAqLNAJ4tA6sWiQhBHpuCW99z55TcvPEvDgCfXOKB
519nbAi5YgVMyMX8AuaRyvI=
=IMUI
-END PGP SIGNATURE-




Re: add limited support for Solaris 10 ZFS-style ACLs to gnulib

2007-03-25 Thread Bruno Haible
Paul Eggert wrote:
> Index: lib/acl-internal.h
> ===
> RCS file: lib/acl-internal.h
> diff -N lib/acl-internal.h
> --- /dev/null 1 Jan 1970 00:00:00 -
> +++ lib/acl-internal.h19 Mar 2007 21:58:54 -
> @@ -0,0 +1,90 @@
...
> +#include 

This .h file does not need to include , since the three users of
this file (acl.c, acl_entries.c, file-has-acl.c) already include it.

Bruno





Re: support for bitwise comparison of floats

2007-03-25 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 3/25/2007 4:54 AM:
> Eric Blake wrote:
>> You can also assume IEEE rules, and compare against signed infinity:
>> 1 / +0. => +infinity
>> 1 / -0. => -infinity
> 
> Nice trick :-)
> 
> But here you depend on the IEEE rules for exceptions upon division by zero.

Is this any more portable, by avoiding floating point division altogether?
  It works on x86, at any rate.  It assumes that a long is big enough that
twiddling the low-order bit in the long will make the long double non-zero
without also making it a NaN.  Although it doesn't work on signaling NaN
as is.

/* return true iff the representation of d needs a leading '-' */
bool
is_negative (long double d)
{
  if (d == 0)
{
  union {
long double d;
long l;
  } u;
  u.d = d;
  u.l |= 1;
  return u.d < 0;
}
  return d < 0;
}

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBo2B84KuGfSFAYARArwyAKCZxGSMrhTt7U0rEjKuFnBCzXzmGgCeKsQK
/Ged2WRa7qx6dq0lLDb3k0w=
=hxtk
-END PGP SIGNATURE-




Re: support for bitwise comparison of floats

2007-03-25 Thread Bruno Haible
PS: I wrote:
>   - On Alpha processors, division by zero (and even overflow!) leads to a 
> SIGFPE
> signal by default. And it requires the use of a system call to change
> the FP exceptions control mask (the  routines in glibc >= 2.1,
> the __setfpucw function in glibc 2.0). memcmp is certainly much cheaper.

This is for glibc/Alpha systems and maybe older OSF/1 systems. On OSF/1 5.1,
things appear to be better.

Bruno





time: invalid Makefile syntax

2007-03-25 Thread Bruno Haible
Hi,

When editing a gnulib generated Makefile, emacs told me about "suspicious 
lines".
Action lines should start with a tab, not a space. I'm applying this:


2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* modules/time (Makefile.am): Ensure all rule action lines start with a
tab.

--- modules/time22 Feb 2007 14:08:02 -  1.3
+++ modules/time25 Mar 2007 15:30:26 -
@@ -21,12 +21,12 @@
rm -f [EMAIL PROTECTED] $@
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
  sed -e 's|@ABSOLUTE_TIME_H''@|$(ABSOLUTE_TIME_H)|g' \
- -e 's|@REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
- -e 's|@REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
- -e 's|@REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \
- -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
- -e 
's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g'
 \
- -e 
's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+ -e 's|@REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+ -e 's|@REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+ -e 's|@REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \
+ -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+ -e 
's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g'
 \
+ -e 
's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
  < $(srcdir)/time_.h; \
} > [EMAIL PROTECTED]
mv [EMAIL PROTECTED] $@





Re: support for bitwise comparison of floats

2007-03-25 Thread Bruno Haible
Eric Blake wrote:
> Is this any more portable, by avoiding floating point division altogether?
> 
> /* return true iff the representation of d needs a leading '-' */
> bool
> is_negative (long double d)
> {
>   if (d == 0)
> {
>   union {
> long double d;
> long l;
>   } u;
>   u.d = d;
>   u.l |= 1;
>   return u.d < 0;
> }
>   return d < 0;
> }

You are picking a particular bit in a 'long double' representation. If you
picked any bit different from the sign bit, this code is fine (assuming
!isnanl(d) is already known). If you picked the sign bit, +0.0 will be
considered negative too. It's an endianness issue and depends on the bit
storage order in words. You might have picked the wrong bit for m68k...
It's safer to use   u.l |= 8;   since noone will put the sign bit at
bit 3 or 28 (except the HP-PA designers perhaps :-)).

More generally, for some operations such as isnanl(), one needs to know
the precise bit positions of the sign, exponent and mantissa in the binary
representation. But when it can be avoided, I prefer to look at the binary
representation as a black box, knowing only its size.

Bruno





Re: gnulib support for st_birthtime

2007-03-25 Thread Bruno Haible
James Youngman wrote:
> this is a change which I cannot test since I
> have no Woe32 system.  I will push the change into findutils (instead
> of using it indirectly in gnulib) and test it there for a bit.

On the contrary, pushing the change into gnulib will make testing easier:
If you provide a unit test, I can do "./gnulib-tool --create-testdir ..."
and test it on the mingw machine I have access to; other people here on
this list have access to Cygwin, Solaris and other machines.

A unit test can basically do the following:
   echo > stamp1
   sleep 2
   echo > testfile
   sleep 2
   echo > stamp2
   sleep 2
   mv testfile renamed
   sleep 2
   echo > stamp3
and then verify that
   mtime(stamp1) < birthtime(renamed) < mtime(stamp2) < ctime(renamed) < 
mtime(stamp3).

Bruno





argp: fix __restrict for older compilers

2007-03-25 Thread Bruno Haible
On BeOS, which has a gcc compiler older than 2.95, one gets syntax errors
in gnulib's  due to 'restrict'. The reason is that
  - configure does a "#define restrict __restrict", since gcc supports that
keyword.
  - argp.h does "#define __restrict restrict", since it sees that 'restrict'
is defined as a macro.
  - The uses of 'restrict' in  expand to 'restrict', according to
ANSI C. But gcc does not support 'restrict'; this is why configure had
defined it in the first place.

One could use an alternate keyword, such as '_Restrict_', as done in
regex.h, but there are dozens of occurrences of '__restrict' which would need
to be changed. It's less intrusive the define '__restrict' to a different
value. I'm applying this:


2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/argp.h (__restrict): Define to empty, rather than to 'restrict',
if the compiler does not support C99.

--- lib/argp.h  28 Dec 2006 23:36:43 -  1.16
+++ lib/argp.h  25 Mar 2007 17:37:41 -
@@ -1,5 +1,5 @@
 /* Hierarchial argument parsing, layered over getopt.
-   Copyright (C) 1995-1999,2003-2006 Free Software Foundation, Inc.
+   Copyright (C) 1995-1999,2003-2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Miles Bader <[EMAIL PROTECTED]>.
 
@@ -49,10 +49,12 @@
 #endif
 
 /* GCC 2.95 and later have "__restrict"; C99 compilers have
-   "restrict", and "configure" may have defined "restrict".  */
+   "restrict", and "configure" may have defined "restrict".
+   Other compilers use __restrict, __restrict__, and _Restrict, and
+   'configure' might #define 'restrict' to those words.  */
 #ifndef __restrict
 # if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
-#  if defined restrict || 199901L <= __STDC_VERSION__
+#  if 199901L <= __STDC_VERSION__
 #   define __restrict restrict
 #  else
 #   define __restrict





warning in sincosl.c

2007-03-25 Thread Bruno Haible
Hi Paolo,

On Solaris 10 with "cc", I get this warning:

"./sincosl.c", line 233: warning: identifier redeclared; ANSI C requires 
"static": sincosl_table

and on HP-UX 11 with "cc":

cc: "sincosl.c", line 233: warning 562: Redeclaration of "sincosl_table" with a 
different storage class specifier: "sincosl_table" will have internal linkage.

Presumably this fix is ok with you?


2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/sincosl.c (sincosl_table): Make static.

diff -u -r1.5 sincosl.c
--- lib/sincosl.c   18 Feb 2007 15:10:28 -  1.5
+++ lib/sincosl.c   25 Mar 2007 17:57:05 -
@@ -230,7 +230,7 @@
Computed using gmp.
  */
 
-const long double sincosl_table[] = {
+static const long double sincosl_table[] = {
 
 /* x =  1.4843750e-01L 
3ffc3000 */
 /* cos(x) = 
0.fd2f5320e1b790209b4dda2f98f79caaa7b873aff1014b0fbc5243766d03cb006bc837c4358 */





trigl.c warning

2007-03-25 Thread Bruno Haible
HP-UX cc gives this warning:
cc: "trigl.c", line 427: warning 562: Redeclaration of "kernel_rem_pio2" with a 
different storage class specifier: "kernel_rem_pio2" will have internal linkage.

I'm applying this fix.


2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/trigl.c (kernel_rem_pio2): Make static.

--- lib/trigl.c 18 Feb 2007 15:10:28 -  1.4
+++ lib/trigl.c 25 Mar 2007 17:59:47 -
@@ -423,7 +423,7 @@
 static const double zero = 0.0, one = 1.0, two24 = 1.67772160e+07, 
/* 0x4170, 0x */
   twon24 = 5.9604644775390625e-08; /* 0x3E70, 0x */
 
-int
+static int
 kernel_rem_pio2 (double *x, double *y, int e0, int nx, int prec,
 const int *ipio2)
 {





lib/regexec.c warning

2007-03-25 Thread Bruno Haible
HP-UX cc gives this warning:

cc: "regexec.c", line 2343: warning 562: Redeclaration of 
"merge_state_with_log" with a different storage class specifier: 
"merge_state_with_log" will have internal linkage.

This fixes it. I hope this patch is not too hard to push back to glibc, Paul?


2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/regexec.c (merge_state_with_log): Make static.

--- lib/regexec.c   29 Jan 2007 00:37:14 -  1.24
+++ lib/regexec.c   25 Mar 2007 18:04:32 -
@@ -1,5 +1,6 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation,
+   Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <[EMAIL PROTECTED]>.
 
@@ -2338,7 +2339,7 @@
 }
 
 /* Update the state_log if we need */
-re_dfastate_t *
+static re_dfastate_t *
 internal_function
 merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx,
  re_dfastate_t *next_state)





glob: fix warnings on AIX

2007-03-25 Thread Bruno Haible
On AIX 5.1, the compiler shows these warnings:

"glob.c", line 666.47: 1506-280 (E) Function argument assignment between types 
"struct stat*" and "struct stat64*" is not allowed.
"glob.c", line 1016.42: 1506-280 (E) Function argument assignment between types 
"struct stat*" and "struct stat64*" is not allowed.
"glob.c", line 1066.43: 1506-280 (E) Function argument assignment between types 
"struct stat*" and "struct stat64*" is not allowed.

This warning sounds more dangerous than it is. Nevertheless, it's good to
silence it.

What's happening, is that config.h defines
   #define _LARGE_FILES 1
which instructs sys/stat.h to enable LFS variants of the structs and functions.
In particular it defines 'struct stat64' and then does
   #define stat stat64
Now, when glob.c is compiled, glob-libc.h defines function types that use
'struct stat' (using just a forward declaration). Then later 
is included, and further references to 'stat' macroexpand to 'stat64'.

So the fix is simply to make sure the
   #define stat stat64
is in place before glob-libc.h starts dealing with it. I'm applying this:


2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/glob_.h: Include . Avoids warnings on AIX 5.1.

*** lib/glob_.h 3 Mar 2007 12:35:26 -   1.7
--- lib/glob_.h 25 Mar 2007 19:27:58 -
***
*** 27,32 
--- 27,37 
  
  #include 
  
+ /* On some systems, such as AIX 5.1,  does a "#define stat 
stat64".
+Make sure this definition is seen before glob-libc.h defines types that
+rely on 'struct stat'.  */
+ #include 
+ 
  #ifndef __BEGIN_DECLS
  # define __BEGIN_DECLS
  # define __END_DECLS





isnan: work around a DEC C compiler bug

2007-03-25 Thread Bruno Haible
The DEC C 6.4 compiler on Tru64 fails with an error message when it encounters
the expression 0.0 / 0.0, even in a context where no constant expression is
required. Strangely enough, it groks 0.0L / 0.0L with just a warning. Here is
a workaround:

2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/isnan.c (FUNC): Work around a DEC C compiler bug.

*** lib/isnan.c 25 Mar 2007 01:06:39 -  1.4
--- lib/isnan.c 25 Mar 2007 19:41:35 -
***
*** 64,74 
   because x may be a signaling NaN.  */
  # if defined __SUNPRO_C || defined __DECC
/* The Sun C 5.0 compilers and the Compaq (ex-DEC) 6.4 compilers don't
!  recognize the initializers as constant expressions.  */
memory_double nan;
DOUBLE plus_inf = L_(1.0) / L_(0.0);
DOUBLE minus_inf = -L_(1.0) / L_(0.0);
!   nan.value = L_(0.0) / L_(0.0);
  # else
static memory_double nan = { L_(0.0) / L_(0.0) };
static DOUBLE plus_inf = L_(1.0) / L_(0.0);
--- 64,77 
   because x may be a signaling NaN.  */
  # if defined __SUNPRO_C || defined __DECC
/* The Sun C 5.0 compilers and the Compaq (ex-DEC) 6.4 compilers don't
!  recognize the initializers as constant expressions.  The latter compiler
!  also fails when constant-folding 0.0 / 0.0 even when constant-folding is
!  not required.  */
!   static DOUBLE zero = L_(0.0);
memory_double nan;
DOUBLE plus_inf = L_(1.0) / L_(0.0);
DOUBLE minus_inf = -L_(1.0) / L_(0.0);
!   nan.value = zero / zero;
  # else
static memory_double nan = { L_(0.0) / L_(0.0) };
static DOUBLE plus_inf = L_(1.0) / L_(0.0);





EX_OK collision

2007-03-25 Thread Bruno Haible
Warning seen on IRIX 6.5:

"///usr/include/unistd.h", line 43: warning(1047): macro redefined differently

IRIX 6.5 has two definitions of EX_OK:
  - one in , protected with "#if _SGIAPI", as a flag that can be
passed to the access() function, with value 020,
  - one in , always active, as an exit code, with value 0.

Which definition is active, thus depends on the order of inclusion.

What should we do?

  (a) Do nothing.

  (b) Create a replacement  that does

 #include 
 #undef EX_OK
 #include 

  (c) Create a replacement  that does

 #include 
 #undef EX_OK

  and a replacement  that does

 #include 
 #include 

Which of the three is best? Why?

Bruno





[Bug-gne] Dewitt Symantec site

2007-03-25 Thread Angie Leonard
Autodesk AutoCAD 2007Retail Price
$3995.00Our Price $129.95You save $3865.05 Adobe Creative Suite 2 Premium for
WindowsRetail Price $1199.00Our Price $149.95You save
$1049.05 CorelDraw Graphics Suite X3Retail Price
$399.00Our Price $59.95You save $339.05 Macromedia Studio 8Retail Price 
$999.00Our
Price $99.95You save $899.05 MS Windows XP Professional with SP2Retail Price
$269.99Our Price $49.95You save $220.04 Adobe Photoshop CS2 V 9.0Retail Price
$599.00Our Price $69.95You save $529.05 Adobe Acrobat 8.0 ProfessionalRetail 
Price
$449.00Our Price $79.95You save $369.05 Microsoft Office 2007 EnterpriseRetail 
Price
$899.00Our Price $79.95You save $819.05 Microsoft Windows Vista BusinessRetail 
Price
$299.00Our Price $79.95You save $219.05 http://furtadovpizdu.eu___
Bug-gne mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/bug-gne

mathl and NaN

2007-03-25 Thread Bruno Haible
Hi Paolo,

The mathl module uses the idiom   x != x
to test for a NaN. The IRIX 6.5 cc compiler, however, simplifies this expression
to false, both for 'double' and 'long double' variables. The two workarounds
that I found are:
  - Use the isnanl function,
  - Copy one of the operands into a 'volatile' variable:
   volatile double y = x;
   if (x != y) ...

Also, do you know which are the operations that can be performed on a
signalling NaN without getting an exception? Only an isnanl test? Or also
comparisons?

So, your opinion about the following patch?

2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/atanl.c: Include isnanl.h.
(atanl): Use isnanl, instead of the x != x idiom.
* lib/ldexpl.c: Include isnanl.h.
(ldexpl): Use isnanl, instead of the x != x idiom.
* lib/logl.c: Include isnanl.h.
(logl): Use isnanl, instead of the x != x idiom.
* lib/sinl.c: Include isnanl.h.
(sinl): Use isnanl, instead of the x != x idiom.
* lib/sqrtl.c: Include isnanl.h.
(sqrtl): Use isnanl, instead of the x != x idiom.
* lib/tanl.c: Include isnanl.h.
(tanl): Use isnanl, instead of the x != x idiom.
* lib/trigl.c: Include isnanl.h.
(ieee754_rem_pio2l): Use isnanl, instead of the x != x idiom.
* modules/mathl (Depends-on): Add isnanl.

--- lib/atanl.c 18 Feb 2007 15:10:28 -  1.4
+++ lib/atanl.c 25 Mar 2007 20:34:50 -
@@ -64,6 +64,7 @@
  *
  */
 
+#include "isnanl.h"
 
 /* arctan(k/8), k = 0, ..., 82 */
 static const long double atantbl[84] = {
@@ -178,12 +179,12 @@
   int k, sign;
   long double t, u, p, q;
 
-  sign = x < 0.0;
-
   /* Check for zero or NaN.  */
-  if (x != x || x == 0.0)
+  if (isnanl (x) || x == 0.0)
 return x + x;
 
+  sign = x < 0.0;
+
   if (x + x == x)
 {
   /* Infinity. */
--- lib/ldexpl.c18 Feb 2007 15:10:28 -  1.5
+++ lib/ldexpl.c25 Mar 2007 20:34:50 -
@@ -25,6 +25,7 @@
 #include 
 
 #include 
+#include "isnanl.h"
 
 long double
 ldexpl(long double x, int exp)
@@ -33,7 +34,7 @@
   int bit;
 
   /* Check for zero, nan and infinity. */
-  if (x != x || x + x == x )
+  if (isnanl (x) || x + x == x)
 return x;
 
   if (exp < 0)
--- lib/logl.c  18 Feb 2007 15:10:28 -  1.4
+++ lib/logl.c  25 Mar 2007 20:34:50 -
@@ -64,6 +64,8 @@
  *
  */
 
+#include "isnanl.h"
+
 /* log(1+x) = x - .5 x^2 + x^3 l(x)
-.0078125 <= x <= +.0078125
peak relative error 1.2e-37 */
@@ -207,7 +209,7 @@
   return (x - x) / ZERO;
 }
   /* log (infinity or NaN) */
-  if (x + x == x || x != x)
+  if (isnanl (x) || x + x == x)
 {
   return x + x;
 }
--- lib/sinl.c  18 Feb 2007 15:10:28 -  1.3
+++ lib/sinl.c  25 Mar 2007 20:34:50 -
@@ -52,6 +52,7 @@
 #include "trigl.h"
 #include "trigl.c"
 #include "sincosl.c"
+#include "isnanl.h"
 
 long double
 sinl (long double x)
@@ -65,7 +66,7 @@
 return kernel_sinl (x, z, 0);
 
 /* sinl(Inf or NaN) is NaN, sinl(0) is 0 */
-  else if (x + x == x || x != x)
+  else if (isnanl (x) || x + x == x)
 return x - x;  /* NaN */
 
   /* argument reduction needed */
--- lib/sqrtl.c 18 Feb 2007 15:10:28 -  1.4
+++ lib/sqrtl.c 25 Mar 2007 20:34:50 -
@@ -25,6 +25,7 @@
 #include 
 
 #include 
+#include "isnanl.h"
 
 /* A simple Newton-Raphson method. */
 long double
@@ -38,7 +39,7 @@
 return (long double) sqrt(-1);
 
   /* Check for zero, NANs and infinites */
-  if (x + x == x || x != x)
+  if (isnanl (x) || x + x == x)
 return x;
 
   frexpl (x, &exponent);
--- lib/tanl.c  18 Feb 2007 15:10:28 -  1.3
+++ lib/tanl.c  25 Mar 2007 20:34:50 -
@@ -55,6 +55,7 @@
 #include "trigl.c"
 #endif
 #endif
+#include "isnanl.h"
 
 /*
  * 
@@ -197,7 +198,7 @@
 return kernel_tanl (x, z, 1);
 
   /* tanl(Inf or NaN) is NaN, tanl(0) is 0 */
-  else if (x + x == x || x != x)
+  else if (isnanl (x) || x + x == x)
 return x - x;  /* NaN */
 
   /* argument reduction needed */
--- lib/trigl.c 25 Mar 2007 18:03:15 -  1.5
+++ lib/trigl.c 25 Mar 2007 20:34:50 -
@@ -23,6 +23,7 @@
 #include 
 
 #include 
+#include "isnanl.h"
 
 /* Table of constants for 2/pi, 5628 hexadecimal digits of 2/pi */
 static const int two_over_pi[] = {
@@ -233,7 +234,7 @@
return -1;
   }
 
-  if (x + x == x || x != x)/* x is +=oo or NaN */
+  if (isnanl (x) || x + x == x)/* x is +=oo or NaN */
 {
   y[0] = x - x;
   y[1] = y[0];
--- modules/mathl   23 Mar 2007 01:26:24 -  1.7
+++ modules/mathl   25 Mar 2007 20:34:50 -
@@ -22,6 +22,7 @@
 Depends-on:
 math
 frexpl
+isnanl
 
 configure.ac:
 gl_FUNC_LONG_DOUBLE_MATH





frexp: avoid bug on IRIX

2007-03-25 Thread Bruno Haible
frexp(Infinity) on IRIX 6.5 does not return Infinity, as it should according to
POSIX/MX. I'm adding a configure check against it:

2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* m4/frexp.m4 (gl_FUNC_FREXP_WORKS): Add check whether frexp(inf)
returns inf. Needed on IRIX 6.5.

*** m4/frexp.m4 22 Mar 2007 11:35:12 -  1.2
--- m4/frexp.m4 25 Mar 2007 21:19:53 -
***
*** 1,4 
! # frexp.m4 serial 1
  dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 
! # frexp.m4 serial 2
  dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
***
*** 55,62 
fi
  ])
  
! dnl Test whether frexp() works also on denormalized numbers.
! dnl This test fails e.g. on NetBSD.
  AC_DEFUN([gl_FUNC_FREXP_WORKS],
  [
AC_REQUIRE([AC_PROG_CC])
--- 55,62 
fi
  ])
  
! dnl Test whether frexp() works also on denormalized numbers (this fails e.g. 
on
! dnl NetBSD 3.0) and on infinite numbers (this fails e.g. on IRIX 6.5).
  AC_DEFUN([gl_FUNC_FREXP_WORKS],
  [
AC_REQUIRE([AC_PROG_CC])
***
*** 70,75 
--- 70,76 
  {
int i;
volatile double x;
+   /* Test on denormalized numbers.  */
for (i = 1, x = 1.0; i >= DBL_MIN_EXP; i--, x *= 0.5)
  ;
if (x > 0.0)
***
*** 81,91 
if (y != 0.5)
  return 1;
  }
return 0;
  }], [gl_cv_func_frexp_works=yes], [gl_cv_func_frexp_works=no],
[case "$host_os" in
!  netbsd*) gl_cv_func_frexp_works="guessing no";;
!  *)   gl_cv_func_frexp_works="guessing yes";;
 esac
])
  ])
--- 82,100 
if (y != 0.5)
  return 1;
  }
+   /* Test on infinite numbers.  */
+   {
+ x = 1.0 / 0.0;
+ int exp;
+ double y = frexp (x, &exp);
+ if (y != x)
+   return 1;
+   }
return 0;
  }], [gl_cv_func_frexp_works=yes], [gl_cv_func_frexp_works=no],
[case "$host_os" in
!  netbsd* | irix*) gl_cv_func_frexp_works="guessing no";;
!  *)   gl_cv_func_frexp_works="guessing yes";;
 esac
])
  ])





frexpl: avoid bug on IRIX

2007-03-25 Thread Bruno Haible
frexpl(Infinity) on IRIX 6.5 does not return Infinity, as it should according to
POSIX/MX. I'm adding a configure check against it:

2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* m4/frexpl.m4 (gl_FUNC_FREXPL_WORKS): New macro.
(gl_FUNC_FREXPL): Invoke it. Set REPLACE_FREXPL to 1 if it frexpl
exists but doesn't work.
* lib/math_.h (frexpl): Define as a replacement macro if REPLACE_FREXPL
is set. Don't provide a prototype if REPLACE_FREXPL is not set.
* m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize REPLACE_FREXPL.
* modules/math (Makefile.am) Substibute also REPLACE_FREXPL into math.h.

*** m4/frexpl.m423 Mar 2007 01:26:24 -  1.1
--- m4/frexpl.m425 Mar 2007 21:26:37 -
***
*** 1,4 
! # frexpl.m4 serial 1
  dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 
! # frexpl.m4 serial 2
  dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
***
*** 36,41 
--- 36,53 
fi
if test $gl_cv_func_frexpl_no_libm = yes \
   || test $gl_cv_func_frexpl_in_libm = yes; then
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $FREXPL_LIBM"
+ gl_FUNC_FREXPL_WORKS
+ LIBS="$save_LIBS"
+ case "$gl_cv_func_frexpl_works" in
+   *yes) gl_func_frexpl=yes ;;
+   *)gl_func_frexpl=no; REPLACE_FREXPL=1; FREXPL_LIBM= ;;
+ esac
+   else
+ gl_func_frexpl=no
+   fi
+   if test $gl_func_frexpl = yes; then
  AC_DEFINE([HAVE_FREXPL], 1,
[Define if the frexpl() function is available.])
  dnl Also check whether it's declared.
***
*** 45,47 
--- 57,90 
  AC_LIBOBJ([frexpl])
fi
  ])
+ 
+ dnl Test whether frexpl() works also on infinite numbers (this fails e.g. on
+ dnl IRIX 6.5).
+ AC_DEFUN([gl_FUNC_FREXPL_WORKS],
+ [
+   AC_REQUIRE([AC_PROG_CC])
+   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+   AC_CACHE_CHECK([whether frexpl works], [gl_cv_func_frexpl_works],
+ [
+   AC_TRY_RUN([
+ #include 
+ int main()
+ {
+   volatile long double x;
+   /* Test on infinite numbers.  */
+   {
+ x = 1.0L / 0.0L;
+ int exp;
+ long double y = frexpl (x, &exp);
+ if (y != x)
+   return 1;
+   }
+   return 0;
+ }], [gl_cv_func_frexpl_works=yes], [gl_cv_func_frexpl_works=no],
+   [case "$host_os" in
+  irix*) gl_cv_func_frexpl_works="guessing no";;
+  *) gl_cv_func_frexpl_works="guessing yes";;
+esac
+   ])
+ ])
+ ])
*** m4/math_h.m423 Mar 2007 01:26:24 -  1.4
--- m4/math_h.m425 Mar 2007 21:26:37 -
***
*** 39,42 
--- 39,43 
HAVE_DECL_SQRTL=1;  AC_SUBST([HAVE_DECL_SQRTL])
HAVE_DECL_TANL=1;   AC_SUBST([HAVE_DECL_TANL])
REPLACE_FREXP=0;AC_SUBST([REPLACE_FREXP])
+   REPLACE_FREXPL=0;   AC_SUBST([REPLACE_FREXPL])
  ])
*** lib/math_.h 23 Mar 2007 03:06:51 -  1.6
--- lib/math_.h 25 Mar 2007 21:26:37 -
***
*** 135,141 
   If x is zero: mantissa = x, exp = 0.
   If x is infinite or NaN: mantissa = x, exp unspecified.
 Store exp and return mantissa.  */
! #if @GNULIB_FREXPL@ || [EMAIL PROTECTED]@
  extern long double frexpl (long double x, int *exp);
  #endif
  #if [EMAIL PROTECTED]@ && defined GNULIB_POSIXCHECK
--- 135,144 
   If x is zero: mantissa = x, exp = 0.
   If x is infinite or NaN: mantissa = x, exp unspecified.
 Store exp and return mantissa.  */
! #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
! # define frexpl rpl_frexpl
! #endif
! #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || [EMAIL PROTECTED]@
  extern long double frexpl (long double x, int *exp);
  #endif
  #if [EMAIL PROTECTED]@ && defined GNULIB_POSIXCHECK
*** modules/math23 Mar 2007 01:26:24 -  1.4
--- modules/math25 Mar 2007 21:26:37 -
***
*** 38,43 
--- 38,44 
  -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \
  -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \
  -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
+ -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
  -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
  < $(srcdir)/math_.h; \
} > [EMAIL PROTECTED]





getaddrinfo: fix crash on IRIX

2007-03-25 Thread Bruno Haible
Hi Simon,

On IRIX 6.5, the replacement getaddrinfo is used, and since the testsuite
exercises calling it will a hints = NULL pointer, it crashes in line 182.

Here is a proposed patch.


2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/getaddrinfo.c (getaddrinfo): Don't access hints->ai_flags when
hints is NULL.

--- lib/getaddrinfo.c   21 Feb 2007 02:19:34 -  1.22
+++ lib/getaddrinfo.c   25 Mar 2007 22:03:03 -
@@ -179,7 +179,7 @@
   const char *proto =
(hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp";
 
-  if (!(hints->ai_flags & AI_NUMERICSERV))
+  if (hints == NULL || !(hints->ai_flags & AI_NUMERICSERV))
/* FIXME: Use getservbyname_r if available. */
se = getservbyname (servname, proto);
 





Re: support for bitwise comparison of floats

2007-03-25 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 3/25/2007 9:57 AM:
> Eric Blake wrote:
>> Is this any more portable, by avoiding floating point division altogether?
>>
>> /* return true iff the representation of d needs a leading '-' */
>> bool
>> is_negative (long double d)
>> {
>>   if (d == 0)
>> {
>>   union {
>> long double d;
>> long l;
>>   } u;
>>   u.d = d;
>>   u.l |= 1;
>>   return u.d < 0;
>> }
>>   return d < 0;
>> }
> 
> You are picking a particular bit in a 'long double' representation. If you
> picked any bit different from the sign bit, this code is fine (assuming
> !isnanl(d) is already known). If you picked the sign bit, +0.0 will be
> considered negative too.

Actually, if I picked the sign bit, then both -0 and +0 would be
considered positive, since neither 0 compares less than 0.

> It's an endianness issue and depends on the bit
> storage order in words. You might have picked the wrong bit for m68k...
> It's safer to use   u.l |= 8;   since noone will put the sign bit at
> bit 3 or 28 (except the HP-PA designers perhaps :-)).

Yes, I like your idea of using a bit other than the LSB as a way to ensure
that the sign bit is not hit.  But you also have to pick a bit that does
not fall in the 2-byte padding of the 10-byte x86 long double.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBvOH84KuGfSFAYARAnsVAKDBDe0uwPWfPZ7j8/RYKbQqVsqIfgCdGI+Y
gHxqppJppVeJPVQyLSq0r30=
=vvsY
-END PGP SIGNATURE-




getaddrinfo: test failures

2007-03-25 Thread Bruno Haible
Hi Simon,

The getaddrinfo test fails on most machines I tried. But since I am not a
networking expert, and don't know how getaddrinfo is supposed to work, its
output is chinese to me. For example I don't know whether it's ok or not
if https://www.ibm.com cannot be looked up.

Can you go through the test and ask yourself which results are expected or
not expected? If you drop the output of expected situations and produce
output and failure for unexpected situations, the test will become more useful.

Bruno

== Failure output on Solaris 10 ==
Finding www.gnu.org service http...
res 9: service name not available for the specified socket type
Finding www.ibm.com service https...
res 9: service name not available for the specified socket type
Finding microsoft.com service http...
res 9: service name not available for the specified socket type
Finding google.org service ldap...
res 0: name translation error 0 (no error)
flags 0
family 2
socktype 2
protocol 0
addrlen 16: Found 64.233.161.104
getnameinfo 0: name translation error 0 (no error)
ip 64.233.161.104
port 389
flags 0
family 2
socktype 2
protocol 0
addrlen 16: Found 66.102.7.104
getnameinfo 0: name translation error 0 (no error)
ip 66.102.7.104
port 389
flags 0
family 2
socktype 2
protocol 0
addrlen 16: Found 66.249.93.104
getnameinfo 0: name translation error 0 (no error)
ip 66.249.93.104
port 389
=== Failure output on HP-UX 11 ===
Finding www.gnu.org service http...
res 0: Unknown error
flags 0
family 2
socktype 0
protocol 0
addrlen 16: Found 199.232.41.10
getnameinfo 0: Unknown error
ip 199.232.41.10
port 80
Finding www.ibm.com service https...
res -2: Name or service not known
Finding microsoft.com service http...
res 0: Unknown error
flags 0
family 2
socktype 0
protocol 0
addrlen 16: Found 207.46.197.32
getnameinfo 0: Unknown error
ip 207.46.197.32
port 80
Finding google.org service ldap...
res 0: Unknown error
flags 0
family 2
socktype 0
protocol 0
addrlen 16: Found 64.233.161.104
getnameinfo 0: Unknown error
ip 64.233.161.104
port 389
= Failure output on AIX 5.1 ==
Finding www.gnu.org service http...
res 0: No Error
flags 0
family 2
socktype 1
protocol 6
addrlen 16: Found 199.232.41.10
getnameinfo 0: No Error
ip 199.232.41.10
port 80
Finding www.ibm.com service https...
res 7: Host not found
Finding microsoft.com service http...
res 0: No Error
flags 0
family 2
socktype 1
protocol 6
addrlen 16: Found 207.46.232.182
getnameinfo 0: No Error
ip 207.46.232.182
port 80
flags 0
family 2
socktype 1
protocol 6
addrlen 16: Found 207.46.197.32
getnameinfo 0: No Error
ip 207.46.197.32
port 80
Finding google.org service ldap...
res 0: No Error
flags 0
family 2
socktype 1
protocol 6
addrlen 16: Found 66.249.93.104
getnameinfo 0: No Error
ip 66.249.93.104
port 389
flags 0
family 2
socktype 1
protocol 6
addrlen 16: Found 64.233.161.104
getnameinfo 0: No Error
ip 64.233.161.104
port 389
flags 0
family 2
socktype 1
protocol 6
addrlen 16: Found 66.102.7.104
getnameinfo 0: No Error
ip 66.102.7.104
port 389
flags 0
family 2
socktype 2
protocol 11
addrlen 16: Found 66.249.93.104
getnameinfo 0: No Error
ip 66.249.93.104
port 389
flags 0
family 2
socktype 2
protocol 11
addrlen 16: Found 64.233.161.104
getnameinfo 0: No Error
ip 64.233.161.104
port 389
flags 0
family 2
socktype 2
protocol 11
addrlen 16: Found 66.102.7.104
getnameinfo 0: No Error
ip 66.102.7.104
port 389
 Failure output on OSF/1 5.1 (with NULL access fixed) =
Finding www.gnu.org service http...
res 

frexpl: avoid bug on AIX

2007-03-25 Thread Bruno Haible
The function frexpl() on AIX doesn't return reasonable values at all. It has
to be disabled in a configure test. I'm applying this:

2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* m4/frexpl.m4 (gl_FUNC_FREXPL_WORKS): Test also finite numbers.

*** m4/frexpl.m425 Mar 2007 21:35:38 -  1.2
--- m4/frexpl.m425 Mar 2007 22:17:45 -
***
*** 58,65 
fi
  ])
  
! dnl Test whether frexpl() works also on infinite numbers (this fails e.g. on
! dnl IRIX 6.5).
  AC_DEFUN([gl_FUNC_FREXPL_WORKS],
  [
AC_REQUIRE([AC_PROG_CC])
--- 58,65 
fi
  ])
  
! dnl Test whether frexpl() works on finite numbers (this fails on AIX 5.1) and
! dnl also on infinite numbers (this fails e.g. on IRIX 6.5).
  AC_DEFUN([gl_FUNC_FREXPL_WORKS],
  [
AC_REQUIRE([AC_PROG_CC])
***
*** 71,76 
--- 71,84 
  int main()
  {
volatile long double x;
+   /* Test on finite numbers.  */
+   {
+ int exp = -;
+ x = 16.0L;
+ frexpl (x, &exp);
+ if (exp != 5)
+   return 1;
+   }
/* Test on infinite numbers.  */
{
  x = 1.0L / 0.0L;
***
*** 82,89 
return 0;
  }], [gl_cv_func_frexpl_works=yes], [gl_cv_func_frexpl_works=no],
[case "$host_os" in
!  irix*) gl_cv_func_frexpl_works="guessing no";;
!  *) gl_cv_func_frexpl_works="guessing yes";;
 esac
])
  ])
--- 90,97 
return 0;
  }], [gl_cv_func_frexpl_works=yes], [gl_cv_func_frexpl_works=no],
[case "$host_os" in
!  aix* | irix*) gl_cv_func_frexpl_works="guessing no";;
!  *)gl_cv_func_frexpl_works="guessing yes";;
 esac
])
  ])





Re: support for bitwise comparison of floats

2007-03-25 Thread Ben Pfaff
Eric Blake <[EMAIL PROTECTED]> writes:

> According to Bruno Haible on 3/25/2007 9:57 AM:
>> Eric Blake wrote:
>>> /* return true iff the representation of d needs a leading '-' */
>>> bool
>>> is_negative (long double d)
>>> {
>>>   if (d == 0)
>>> {
>>>   union {
>>> long double d;
>>> long l;
>>>   } u;
>>>   u.d = d;
>>>   u.l |= 1;
>>>   return u.d < 0;
>>> }
>>>   return d < 0;
>>> }
[...]
>> It's safer to use   u.l |= 8;   since noone will put the sign bit at
>> bit 3 or 28 (except the HP-PA designers perhaps :-)).
>
> Yes, I like your idea of using a bit other than the LSB as a way to ensure
> that the sign bit is not hit.  But you also have to pick a bit that does
> not fall in the 2-byte padding of the 10-byte x86 long double.

I think that you can detect that you hit the padding by testing
whether u.d == 0.  If it's still 0, then you changed a padding
bit.
-- 
I love deadlines.
I love the whooshing noise they make as they go by.
--Douglas Adams





Re: EX_OK collision

2007-03-25 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 3/25/2007 2:22 PM:
> Warning seen on IRIX 6.5:
> 
> "///usr/include/unistd.h", line 43: warning(1047): macro redefined differently
> 
> IRIX 6.5 has two definitions of EX_OK:
>   - one in , protected with "#if _SGIAPI", as a flag that can be
> passed to the access() function, with value 020,
>   - one in , always active, as an exit code, with value 0.
> 
> Which definition is active, thus depends on the order of inclusion.

Hmm.  EX_OK is not standardized, nor does it fall within the namespace
reserved for use by unistd.h.  But sysexits.h is not even a standardized
header, so it is less likely to be used in a portable program.  Also,
EXIT_SUCCESS of stdlib.h has been standardized.  And looking at the name,
I recognized the _OK suffix more than the EX_ prefix.

> 
> What should we do?
> 
I would go with option d)

Create a replacement  that does
  #if HAVE_SYSEXITS_H
  # include 
  #endif
  #undef EX_OK
  #include 

with no change to sysexits.h

thereby preventing portable programs from falling into the trap of using
non-portable EX_OK as an exit status, while still allowing IRIX-specific
code to query the extended access() attribute.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBvgd84KuGfSFAYARAqlGAJ0UAzmjQnlNgY2kkNONHmvKkXIL3ACfaSb9
gbDfIJk4232yYTUOZra53MI=
=LGbS
-END PGP SIGNATURE-




Re: support for bitwise comparison of floats

2007-03-25 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 3/24/2007 7:04 PM:
> 
> 2007-03-24  Bruno Haible  <[EMAIL PROTECTED]>
> 
>   * lib/float+.h: New file.

Is + a reasonable file name character these days?  On the one hand, it is
not listed in the "portable filename character set" in POSIX.  On the
other hand, recent coreutils snapshots have used it, and no one has
complained so far.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBvsB84KuGfSFAYARAqf8AJ98JolwUz8oa3Lf1ZfxlHX+rqf1zACggB0E
B7wUGuCTCWcYle+t88XHpWk=
=QW5G
-END PGP SIGNATURE-




sysexits: test failure on HP-UX

2007-03-25 Thread Bruno Haible
The sysexits test that I wrote verifies that all values from EX_OK to EX_CONFIG
are present and have distinct values.

This fails on HP-UX. It has a  file which contains only te values
up to EX_NOPERM. The values are the same, though (at least :-)).

Here is a proposed patch to extend the HP-UX  with the missing
value.


2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/sysexit_,h: If HAVE_SYSEXITS_H is defined, include the original
 file, and only add EX_CONFIG.
* m4/sysexits.m4 (gl_SYSEXITS): If  exists, check its
absolute file name and whether it is sufficient. Substitute also
HAVE_SYSEXITS_H and ABSOLUTE_SYSEXITS_H.
* modules/sysexits (Makefile.am): Substitute HAVE_SYSEXITS_H and
ABSOLUTE_SYSEXITS_H into sysexits.h.

*** lib/sysexit_.h  9 Jan 2006 21:48:50 -   1.3
--- lib/sysexit_.h  25 Mar 2007 22:48:15 -
***
*** 1,5 
  /* exit() exit codes for some BSD system programs.
!Copyright (C) 2003, 2006 Free Software Foundation, Inc.
  
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
--- 1,5 
  /* exit() exit codes for some BSD system programs.
!Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc.
  
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
***
*** 20,41 
  #ifndef _SYSEXITS_H
  #define _SYSEXITS_H
  
! #define EX_OK 0 /* same value as EXIT_SUCCESS */
  
! #define EX_USAGE 64
! #define EX_DATAERR 65
! #define EX_NOINPUT 66
! #define EX_NOUSER 67
! #define EX_NOHOST 68
! #define EX_UNAVAILABLE 69
! #define EX_SOFTWARE 70
! #define EX_OSERR 71
! #define EX_OSFILE 72
! #define EX_CANTCREAT 73
! #define EX_IOERR 74
! #define EX_TEMPFAIL 75
! #define EX_PROTOCOL 76
! #define EX_NOPERM 77
! #define EX_CONFIG 78
  
  #endif /* _SYSEXITS_H */
--- 20,54 
  #ifndef _SYSEXITS_H
  #define _SYSEXITS_H
  
! #if @HAVE_SYSEXITS_H@
  
! # include @ABSOLUTE_SYSEXITS_H@
! 
! /* HP-UX 11  ends at EX_NOPERM.  */
! # ifndef EX_CONFIG
! #  define EX_CONFIG 78
! # endif
! 
! #else
! 
! # define EX_OK 0 /* same value as EXIT_SUCCESS */
! 
! # define EX_USAGE 64
! # define EX_DATAERR 65
! # define EX_NOINPUT 66
! # define EX_NOUSER 67
! # define EX_NOHOST 68
! # define EX_UNAVAILABLE 69
! # define EX_SOFTWARE 70
! # define EX_OSERR 71
! # define EX_OSFILE 72
! # define EX_CANTCREAT 73
! # define EX_IOERR 74
! # define EX_TEMPFAIL 75
! # define EX_PROTOCOL 76
! # define EX_NOPERM 77
! # define EX_CONFIG 78
! 
! #endif
  
  #endif /* _SYSEXITS_H */
*** m4/sysexits.m4  24 Jan 2005 10:02:25 -  1.3
--- m4/sysexits.m4  25 Mar 2007 22:48:15 -
***
*** 1,13 
! # sysexits.m4 serial 2
! dnl Copyright (C) 2003,2005 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
  dnl with or without modifications, as long as this notice is preserved.
  
  AC_DEFUN([gl_SYSEXITS],
  [
!   AC_CHECK_HEADERS(sysexits.h,
! [SYSEXITS_H=],
! [SYSEXITS_H=sysexits.h])
AC_SUBST([SYSEXITS_H])
  ])
--- 1,45 
! # sysexits.m4 serial 3
! dnl Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
  dnl with or without modifications, as long as this notice is preserved.
  
  AC_DEFUN([gl_SYSEXITS],
  [
!   AC_CHECK_HEADERS_ONCE([sysexits.h])
!   if test $ac_cv_header_sysexits_h = yes; then
! HAVE_SYSEXITS_H=1
! gl_ABSOLUTE_HEADER([sysexits.h])
! ABSOLUTE_SYSEXITS_H=\"$gl_cv_absolute_sysexits_h\"
! AC_TRY_COMPILE([#include ],
!   [switch (0)
!{
!case EX_OK:
!case EX_USAGE:
!case EX_DATAERR:
!case EX_NOINPUT:
!case EX_NOUSER:
!case EX_NOHOST:
!case EX_UNAVAILABLE:
!case EX_SOFTWARE:
!case EX_OSERR:
!case EX_OSFILE:
!case EX_CANTCREAT:
!case EX_IOERR:
!case EX_TEMPFAIL:
!case EX_PROTOCOL:
!case EX_NOPERM:
!case EX_CONFIG:
!  break;
!}
!   ],
!   [SYSEXITS_H=],
!   [SYSEXITS_H=sysexits.h])
!   else
! HAVE_SYSEXITS_H=0
! SYSEXITS_H=sysexits.h
!   fi
!   AC_SUBST([HAVE_SYSEXITS_H])
!   AC_SUBST([ABSOLUTE_SYSEXITS_H])
AC_SUBST([SYSEXITS_H])
  ])
*** modules/sysexits13 Oct 2006 12:40:23 -  1.11
--- modules/sysexits25 Mar 2007 22:48:15 -
***
*** 17,23 
  # doesn't have one that works with the given compiler.
  sysexits.h: sysexit_.h
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
! cat $(srcdir)/sysexit_.h; \
} > [EMAIL PROTECTED]
mv -f [EMAIL PROTECTED] $@
  MOSTLYCLEANFILES += sysexits.h sysexits

Re: support for bitwise comparison of floats

2007-03-25 Thread Bruno Haible
Eric Blake wrote:
> recent coreutils snapshots have used it, and no one has complained so far.

Plenty of packages have used it for 10 years or longer: GCC installs or
installed files in $prefix/include/g++, and a library called libstdc++.
binutils has a program called 'c++filt'. gettext is using a ansi-c++.m4 and
source file names starting with 'c++'. Etc. Just do a "locate +"...

I think it may have resulted in portability problems to VMS. But that's a
decade in the past.

Bruno





Re: add limited support for Solaris 10 ZFS-style ACLs to gnulib

2007-03-25 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 3/25/2007 8:24 AM:
> Paul Eggert wrote:
>> Index: lib/acl-internal.h
>> ===
>> RCS file: lib/acl-internal.h
>> diff -N lib/acl-internal.h
>> --- /dev/null1 Jan 1970 00:00:00 -
>> +++ lib/acl-internal.h   19 Mar 2007 21:58:54 -
>> @@ -0,0 +1,90 @@
> ...
>> +#include 
> 
> This .h file does not need to include , since the three users of
> this file (acl.c, acl_entries.c, file-has-acl.c) already include it.

In general, ALL gnulib .h files should assume that  was
previously included.

How about this patch, which also fixes one other ACL issue?  A long time
ago [1], it was pointed out that cygwin fails acl() with EBUSY when a file
is locked (stat() likewise fails, due to Windows annoying insistence that
you cannot query a file's metadata when it is locked).  I have been
including a variant of this patch in all cygwin versions of coreutils for
the past year and a half.

[1] http://lists.gnu.org/archive/html/bug-coreutils/2005-06/msg00191.html

Oh, and my comment later in that thread ("Any script that tries to parse
ls output is inherently non-portable to begin with.") still holds - I am
awaiting a review for this automake patch to fix mdate-sh, since it bit me
when trying to generate the M4 1.4.9 manual under cygwin [2].  gnulib
still syncs its version of build-aux/mdate-sh from automake.

[2] http://lists.gnu.org/archive/html/automake-patches/2007-03/msg1.html

2007-03-25  Eric Blake  <[EMAIL PROTECTED]>

* lib/acl-internal.h: Remove redundant include.
(ACL_NOT_WELL_SUPPORTED): Also filter on EBUSY, returned by
Cygwin when a file is locked.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBwT184KuGfSFAYARAoJ7AJ9wdUq/2eL8lvTrxv7eK2uk69H//QCgxHMk
pRNrU35DW0Zh+xKvyiBnEdU=
=sUF6
-END PGP SIGNATURE-
diff --git a/ChangeLog b/ChangeLog
index 4306d1e..9eb7553 100644
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index e224a78..f92e7af 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -18,8 +18,6 @@
 
Written by Paul Eggert and Andreas Gruenbacher.  */
 
-#include 
-
 #include "acl.h"
 
 #include 
@@ -77,7 +75,8 @@
 #endif
 
 #define ACL_NOT_WELL_SUPPORTED(Errno) \
-  ((Errno) == ENOTSUP || (Errno) == ENOSYS || (Errno) == EINVAL)
+  ((Errno) == ENOTSUP || (Errno) == ENOSYS || (Errno) == EINVAL \
+   || (Errno) == EBUSY)
 
 /* Define a replacement for acl_entries if needed.  */
 #if USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_FREE && !HAVE_ACL_ENTRIES


Re: support for bitwise comparison of floats

2007-03-25 Thread Bruno Haible
Clarification:

> >   - On Alpha processors, division by zero (and even overflow!) leads to a 
> > SIGFPE
> > signal by default. And it requires the use of a system call to change
> > the FP exceptions control mask (the  routines in glibc >= 2.1,
> > the __setfpucw function in glibc 2.0). memcmp is certainly much cheaper.

This is true. "By default" means in the absence of specific compiler options.

> This is for glibc/Alpha systems and maybe older OSF/1 systems. On OSF/1 5.1,
> things appear to be better.

This was nonsense. All three systems have the problem equally.

Bruno





new module 'fpieee'

2007-03-25 Thread Bruno Haible
The code needed for isnan() needs to construct a NaN or Inf object. But
doing so leads to a SIGFPE by default on Alpha systems. There's only one
way to get IEEE compliant behaviour of elementary arithmetic operations on
this platform: instruct the compiler to emit different (more expensive)
floating-point instructions. This module implements it.

2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* modules/fpieee: New file.
* m4/fpieee.m4: New file.
* modules/isnan-nolibm (Depends-on): Add fpieee.
* modules/isnanl-nolibm (Depends-on): Add fpieee.
* modules/isnanl (Depends-on): Add fpieee.

=== modules/fpieee 
Description:
Ensure IEEE compliant floating-point operations (overflow and division by zero).

Files:
m4/fpieee.m4

Depends-on:

configure.ac-early:
AC_REQUIRE([gl_FP_IEEE])

configure.ac:

Makefile.am:

Include:

License:
LGPL

Maintainer:
Bruno Haible

 m4/fpieee.m4 =
# fpieee.m4 serial 1
dnl Copyright (C) 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

dnl IEEE 754 standardized three items:
dnl - The formats of single-float and double-float - nowadays commonly
dnl   available as 'float' and 'double' in C and C++.
dnl   No autoconf test needed.
dnl - The overflow and division by zero behaviour: The result are values
dnl   '±Inf' and 'NaN', rather than exceptions as it was before.
dnl   This file provides an autoconf macro for ensuring this behaviour of
dnl   floating-point operations.
dnl - A set of conditions (overflow, underflow, inexact, etc.) which can
dnl   be configured to trigger an exception.
dnl   This cannot be done in a portable way: it depends on the compiler,
dnl   libc, kernel, and CPU.  No autoconf macro is provided for this.

dnl Ensure non-trapping behaviour of floating-point overflow and
dnl floating-point division by zero.
dnl (For integer overflow, see gcc's -ftrapv option; for integer division by
dnl zero, see the autoconf macro in intdiv0.m4.)

AC_DEFUN([gl_FP_IEEE],
[
  AC_REQUIRE([AC_PROG_CC])
  AC_REQUIRE([AC_CANONICAL_HOST])
  # IEEE behaviour is the default on all CPUs except Alpha
  # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4).
  case "$host_cpu" in
alpha*)
  # On Alpha systems, a compiler option provides the behaviour.
  # See the ieee(3) manual page, also available at
  # 

  if test -n "$GCC"; then
# GCC has the option -mieee.
CPPFLAGS="$CPPFLAGS -mieee"
  else
# Compaq (ex-DEC) C has the option -ieee. 
CPPFLAGS="$CPPFLAGS -mieee"
  fi
  ;;
  esac
])
===
*** modules/isnan-nolibm25 Mar 2007 01:06:39 -  1.2
--- modules/isnan-nolibm25 Mar 2007 23:48:24 -
***
*** 8,13 
--- 8,14 
  m4/isnan.m4
  
  Depends-on:
+ fpieee
  
  configure.ac:
  gl_FUNC_ISNAN_NO_LIBM
*** modules/isnanl-nolibm   25 Mar 2007 01:06:39 -  1.4
--- modules/isnanl-nolibm   25 Mar 2007 23:48:24 -
***
*** 10,15 
--- 10,16 
  m4/longdouble.m4
  
  Depends-on:
+ fpieee
  
  configure.ac:
  gl_FUNC_ISNANL_NO_LIBM
*** modules/isnanl  25 Mar 2007 01:06:39 -  1.2
--- modules/isnanl  25 Mar 2007 23:48:24 -
***
*** 10,15 
--- 10,16 
  m4/longdouble.m4
  
  Depends-on:
+ fpieee
  
  configure.ac:
  gl_FUNC_ISNANL





Re: new module 'fpieee'

2007-03-25 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Bruno Haible on 3/25/2007 5:59 PM:
> alpha*)
>   # On Alpha systems, a compiler option provides the behaviour.
>   # See the ieee(3) manual page, also available at
>   # 
> 
>   if test -n "$GCC"; then
> # GCC has the option -mieee.
> CPPFLAGS="$CPPFLAGS -mieee"
>   else
> # Compaq (ex-DEC) C has the option -ieee. 
> CPPFLAGS="$CPPFLAGS -mieee"

Typo?

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGBw5A84KuGfSFAYARArVQAKCrA+PzwnpAo7ZVeofFxkL8/fb3wACfWsAl
nWqW/yFOhARKSQyq9O1HDRs=
=k1Xm
-END PGP SIGNATURE-




Re: new module 'fpieee'

2007-03-25 Thread Ben Pfaff
Bruno Haible <[EMAIL PROTECTED]> writes:

> The code needed for isnan() needs to construct a NaN or Inf object. But
> doing so leads to a SIGFPE by default on Alpha systems. There's only one
> way to get IEEE compliant behaviour of elementary arithmetic operations on
> this platform: instruct the compiler to emit different (more expensive)
> floating-point instructions. This module implements it.

Is this also necessary on SH systems?  The GCC manual has this in
the page specific to SH:

`-mieee'
 Increase IEEE-compliance of floating-point code.  At the moment,
 this is equivalent to `-fno-finite-math-only'.  When generating 16
 bit SH opcodes, getting IEEE-conforming results for comparisons of
 NANs / infinities incurs extra overhead in every floating point
 comparison, therefore the default is set to `-ffinite-math-only'.

In GNU PSPP, I have a configure test that just checks whether the
compiler accepts -mieee and uses it if it is available.  I wonder
whether this is an approach that is more likely to automatically
work as architectures appear.

Here's what PSPP is using:

dnl Check whether a C compiler option is accepted.
dnl If so, add it to CFLAGS.
dnl Example: PSPP_ENABLE_OPTION(-Wdeclaration-after-statement)
AC_DEFUN([PSPP_ENABLE_OPTION],
[
  m4_define([pspp_cv_name], [pspp_cv_[]m4_translit([$1], [-], [_])])dnl
  AC_CACHE_CHECK([whether $CC accepts $1], [pspp_cv_name], 
[pspp_save_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS $1"
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,)], [pspp_cv_name[]=yes], 
[pspp_cv_name[]=no])
 CFLAGS="$pspp_save_CFLAGS"])
  if test $pspp_cv_name = yes; then
CFLAGS="$CFLAGS $1"
  fi
])

...

PSPP_ENABLE_OPTION(-mieee)
-- 
Only wimps use tape backup: _real_ men just upload their important stuff
on ftp, and let the rest of the world mirror it ;)
-- Linus Torvalds





vasnprintf: support %jd on all platforms

2007-03-25 Thread Bruno Haible
So far, vasnprintf had support for the 'j' size specifier only on platforms
which have intmax_t. OSF/1 5.1 is a platform which doesn't have intmax_t and
where the intmax_t comes from gnulib's  or from gettext's intmax_t.m4.
The testsuite caught it. This patch should fix it.

2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/printf-parse.c [!IN_LIBINTL]: Include , for intmax_t.
(PRINTF_PARSE): Make the support for size specifier 'j' unconditional.
* modules/vasnprintf (Depends-on): Add stdint.

*** lib/printf-parse.c  30 Jan 2007 01:07:22 -  1.10
--- lib/printf-parse.c  26 Mar 2007 00:05:24 -
***
*** 28,39 
  #include 
  
  /* Get intmax_t.  */
! #if HAVE_STDINT_H_WITH_UINTMAX
  # include 
  #endif
- #if HAVE_INTTYPES_H_WITH_UINTMAX
- # include 
- #endif
  
  /* malloc(), realloc(), free().  */
  #include 
--- 28,43 
  #include 
  
  /* Get intmax_t.  */
! #ifdef IN_LIBINTL
! # if HAVE_STDINT_H_WITH_UINTMAX
! #  include 
! # endif
! # if HAVE_INTTYPES_H_WITH_UINTMAX
! #  include 
! # endif
! #else
  # include 
  #endif
  
  /* malloc(), realloc(), free().  */
  #include 
***
*** 326,332 
  flags += 8;
  cp++;
}
- #if HAVE_INTMAX_T
  else if (*cp == 'j')
{
  if (sizeof (intmax_t) > sizeof (long))
--- 330,335 
***
*** 341,347 
}
  cp++;
}
- #endif
  else if (*cp == 'z' || *cp == 'Z')
{
  /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
--- 344,349 
*** modules/vasnprintf  25 Mar 2007 02:22:44 -  1.12
--- modules/vasnprintf  26 Mar 2007 00:05:24 -
***
*** 22,27 
--- 22,28 
  
  Depends-on:
  alloca-opt
+ stdint
  xsize
  
  configure.ac:





Re: new module 'fpieee'

2007-03-25 Thread Bruno Haible
Ben Pfaff wrote:
> Is this also necessary on SH systems?  The GCC manual has this in
> the page specific to SH:
> 
> `-mieee'
>  Increase IEEE-compliance of floating-point code.  At the moment,
>  this is equivalent to `-fno-finite-math-only'.  When generating 16
>  bit SH opcodes, getting IEEE-conforming results for comparisons of
>  NANs / infinities incurs extra overhead in every floating point
>  comparison, therefore the default is set to `-ffinite-math-only'.

Indeed, this appears to be the same issue: generation of NaN and Inf
results. I'm applying the appended patch. Thanks!

> In GNU PSPP, I have a configure test that just checks whether the
> compiler accepts -mieee and uses it if it is available.

Hmm, I'm not a fan of throwing particular options at any compiler, without
having looked at the effects. For example, the option stuck into LDFLAGS
by m4/lib-ignore.m4 leads to a bold warning every time a program is linked
on IRIX.

> I wonder whether this is an approach that is more likely to automatically
> work as architectures appear.

My favourite approach for coping with new architectures is to write tests.
This will catch the expected and unexpected portability problems. Whereas the
approach of trying GCC options at random will catch only portability problems
that you have encountered in the past, not the new ones.

Bruno

*** m4/fpieee.m426 Mar 2007 00:16:46 -  1.2
--- m4/fpieee.m426 Mar 2007 00:28:05 -
***
*** 26,33 
  [
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
!   # IEEE behaviour is the default on all CPUs except Alpha
!   # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4).
case "$host_cpu" in
  alpha*)
# On Alpha systems, a compiler option provides the behaviour.
--- 26,34 
  [
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST])
!   # IEEE behaviour is the default on all CPUs except Alpha and SH
!   # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4
!   # and the GCC 4.1.2 manual).
case "$host_cpu" in
  alpha*)
# On Alpha systems, a compiler option provides the behaviour.
***
*** 41,45 
--- 42,52 
  CPPFLAGS="$CPPFLAGS -ieee"
fi
;;
+ sh*)
+   if test -n "$GCC"; then
+ # GCC has the option -mieee.
+ CPPFLAGS="$CPPFLAGS -mieee"
+   fi
+   ;;
esac
  ])





Re: use of thread-unsafe localeconv in vasprintf

2007-03-25 Thread Bruno Haible
After testing on a few platforms, I applied this patch now.

2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>

* lib/vasnprintf.c: Include langinfo.h.
(VASNPRINTF): Prefer nl_langinfo over localeconv, since it's more
multithread-safe.
* m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_DIRECTIVE_A): New macro.
* m4/fprintf-posix.m4 (gl_FUNC_FPRINTF_POSIX): Invoke it.
* m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Likewise.
* m4/sprintf-posix.m4 (gl_FUNC_SPRINTF_POSIX): Likewise.
* m4/vasnprintf-posix.m4 (gl_FUNC_VASNPRINTF_POSIX): Likewise.
* m4/vasprintf-posix.m4 (gl_FUNC_VASPRINTF_POSIX): Likewise.
* m4/vfprintf-posix.m4 (gl_FUNC_VFPRINTF_POSIX): Likewise.
* m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_POSIX: Likewise.
* m4/vsprintf-posix.m4 (gl_FUNC_VSPRINTF_POSIX): Likewise.
Reported by Simon Josefsson.

*** lib/vasnprintf.c25 Mar 2007 02:30:04 -  1.35
--- lib/vasnprintf.c26 Mar 2007 02:08:17 -
***
*** 41,46 
--- 41,49 
  #include /* errno */
  #include/* CHAR_BIT */
  #include /* DBL_MAX_EXP, LDBL_MAX_EXP */
+ #if HAVE_NL_LANGINFO
+ # include 
+ #endif
  #if WIDE_CHAR_VERSION
  # include "wprintf-parse.h"
  #else
***
*** 507,514 
  if ((flags & FLAG_ALT)
  || mantissa > 0.0L || precision > 0)
{
! const char *point =
!   localeconv () -> decimal_point;
  /* The decimal point is always a single byte:
 either '.' or ','.  */
  *p++ = (point[0] != '\0' ? point[0] : '.');
--- 510,524 
  if ((flags & FLAG_ALT)
  || mantissa > 0.0L || precision > 0)
{
! const char *point;
! /* Prefer nl_langinfo() over localeconv(),
!since the latter is not multithread-
!safe.  */
! #  if HAVE_NL_LANGINFO
! point = nl_langinfo (RADIXCHAR);
! #  else
! point = localeconv () -> decimal_point;
! #  endif
  /* The decimal point is always a single byte:
 either '.' or ','.  */
  *p++ = (point[0] != '\0' ? point[0] : '.');
***
*** 657,664 
  if ((flags & FLAG_ALT)
  || mantissa > 0.0 || precision > 0)
{
! const char *point =
!   localeconv () -> decimal_point;
  /* The decimal point is always a single byte:
 either '.' or ','.  */
  *p++ = (point[0] != '\0' ? point[0] : '.');
--- 667,681 
  if ((flags & FLAG_ALT)
  || mantissa > 0.0 || precision > 0)
{
! const char *point;
! /* Prefer nl_langinfo() over localeconv(),
!since the latter is not multithread-
!safe.  */
! #  if HAVE_NL_LANGINFO
! point = nl_langinfo (RADIXCHAR);
! #  else
! point = localeconv () -> decimal_point;
! #  endif
  /* The decimal point is always a single byte:
 either '.' or ','.  */
  *p++ = (point[0] != '\0' ? point[0] : '.');
*** m4/vasnprintf.m47 Mar 2007 01:34:55 -   1.13
--- m4/vasnprintf.m426 Mar 2007 02:08:17 -
***
*** 1,4 
! # vasnprintf.m4 serial 9
  dnl Copyright (C) 2002-2004, 2006-2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 
! # vasnprintf.m4 serial 10
  dnl Copyright (C) 2002-2004, 2006-2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
***
*** 62,67 
--- 62,79 
AC_CHECK_FUNCS(snprintf wcslen)
  ])
  
+ # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
+ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
+ [
+   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
+   if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then
+ AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
+   [Define 

Re: mathl and NaN

2007-03-25 Thread Paolo Bonzini

> So, your opinion about the following patch?

Ok; at the time i wrote mathl, there was (as you know)
no isnanl package.

I think ==, !=, isordered, isunordered comparisons are
the sole operations you can safely perform on a SNaN.

Paolo




Re: use of thread-unsafe localeconv in vasprintf

2007-03-25 Thread Ralf Wildenhues
Hello Bruno,

* Bruno Haible wrote on Mon, Mar 26, 2007 at 04:18:35AM CEST:
> After testing on a few platforms, I applied this patch now.
>
> 2007-03-25  Bruno Haible  <[EMAIL PROTECTED]>
> 
>   * lib/vasnprintf.c: Include langinfo.h.
>   (VASNPRINTF): Prefer nl_langinfo over localeconv, since it's more
>   multithread-safe.
>   * m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_DIRECTIVE_A): New macro.
[...]

Drive-by spotting:

> *** m4/vasnprintf.m4  7 Mar 2007 01:34:55 -   1.13
> --- m4/vasnprintf.m4  26 Mar 2007 02:08:17 -


> + # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
> + AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
> + [
> +   AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
> +   if ! expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null; then

`if !' is not portable, please use
  if $cmd; then :; else

instead; I think you removed several other instances of this in the
patch already.

Cheers,
Ralf