Re: module request: EINVAL synonyms?

2010-06-17 Thread Bruno Haible
Hi Sam,

> Sometimes system calls fail not because the operation failed but
> because the argument was not appropriate.
> E.g., fsync(fd) may fail because fd is a TTY.
> Normally errno==EINVAL should indicate that, but on some platforms
> other errno's are used.
> ... 
> I want a module einval which would export
> #define IS_EINVAL
> to config.h
> and IS_EINVAL would be defined to
>  (errno==EINVAL)||(errno==ENOSYS))
> on Irix,
>  (errno==EINVAL)||(errno==EBADF))||(errno==EACCES))||(errno==EBADRQC))
> on cygwin &c, and
>  (errno==EINVAL)
> by default.

The outcome of this discussion thread on bug-gnulib
  
  
was that it is possible to have one such function for fsync, one for
sockets, one for ACLs, and so on. But one should better avoid a generic
function of this kind that is applied to different situations - because
the same errno value means different things in different situations.

Regarding fsync, coreutils/src/shred.c has this definition:

/* Return true when it's ok to ignore an fsync or fdatasync
   failure that set errno to ERRNO_VAL.  */
static bool
ignorable_sync_errno (int errno_val)
{
  return (errno_val == EINVAL
  || errno_val == EBADF
  /* HP-UX does this */
  || errno_val == EISDIR);
}

But of course, the 'shred' program is never applied to ttys, therefore
this function does not care to handle errno values that are specific to
fsync on ttys.

Bruno



module request: EINVAL synonyms?

2010-06-17 Thread Sam Steingold
Sometimes system calls fail not because the operation failed but
because the argument was not appropriate.
E.g., fsync(fd) may fail because fd is a TTY.
Normally errno==EINVAL should indicate that, but on some platforms
other errno's are used.
This results in this code in clisp/src/stream.d:

   #ifdef UNIX_IRIX
if (!(errno==ENOSYS))
   #endif
   #ifdef UNIX_CYGWIN32 /* for Woe95 and xterm/rxvt, and WoeXP /dev/null */
if ((errno != EBADF) && (errno != EACCES) && (errno != EBADRQC))
   #endif
   #ifdef UNIX_DARWIN
if ((errno != EOPNOTSUPP) && (errno != ENOTSUP) && (errno != ENODEV))
   #endif
if (!(errno==EINVAL))
  { OS_error(); }

i.e., errno==ENOSYS must be ignored on IRIX, EBADF on cygwin, ENODEV on mac os x
and EINVAL on all platforms.

I would love to outsource the maintenance of this nightmare to gnulib.
specifically, I want a module einval which would export
#define IS_EINVAL
to config.h
and IS_EINVAL would be defined to
 (errno==EINVAL)||(errno==ENOSYS))
on Irix,
 (errno==EINVAL)||(errno==EBADF))||(errno==EACCES))||(errno==EBADRQC))
on cygwin &c, and
 (errno==EINVAL)
by default.

thanks!

-- 
Sam Steingold 



Re: module request: comparing version numbers

2010-06-17 Thread Ben Pfaff
Sam Steingold  writes:

> On 6/17/10, Eric Blake  wrote:
>> Are you talking about version comparisons at m4 time (if so, is
>>  m4_version_compare from autoconf adequate?), at shell time (if so, is
>>  AS_VERSION_COMPARE from autoconf adequate?), or in your executable (if
>>  so, is either the strverscmp or filevercmp module adequate?).
>
> at shell time, but not in configure.
> I have a shell file foo.in which is processed by configure using
> AC_CONFIG_FILES, and I want to be able to compare versions there.

You could write your shell file in M4sh and use
AS_VERSION_COMPARE.
-- 
Ben Pfaff 
http://benpfaff.org




Re: module request: comparing version numbers

2010-06-17 Thread Sam Steingold
On 6/17/10, Eric Blake  wrote:
> On 06/17/2010 11:33 AM, Sam Steingold wrote:
>  > some gnulib modules (e.g., gnulib/m4/libunistring-base.m4) have
>  > facilities for comparing version numbers, e.g., 1.5.22 with 2.2.8.
>  > it would be nice if there were a module (say, version-compare) which
>  > would export such a facility.
>  > e.g., @VERSION_COMPARE@ would expand to
>  > version_compare() {
>  >   ...
>  > }
>  > which would return 0 or 1 depending on whether $1 is smaller than $2.
>
> Are you talking about version comparisons at m4 time (if so, is
>  m4_version_compare from autoconf adequate?), at shell time (if so, is
>  AS_VERSION_COMPARE from autoconf adequate?), or in your executable (if
>  so, is either the strverscmp or filevercmp module adequate?).

at shell time, but not in configure.
I have a shell file foo.in which is processed by configure using
AC_CONFIG_FILES, and I want to be able to compare versions there.

-- 
Sam Steingold 



Re: module request: comparing version numbers

2010-06-17 Thread Eric Blake
On 06/17/2010 11:33 AM, Sam Steingold wrote:
> Hi,
> some gnulib modules (e.g., gnulib/m4/libunistring-base.m4) have
> facilities for comparing version numbers, e.g., 1.5.22 with 2.2.8.
> it would be nice if there were a module (say, version-compare) which
> would export such a facility.
> e.g., @VERSION_COMPARE@ would expand to
> version_compare() {
>   ...
> }
> which would return 0 or 1 depending on whether $1 is smaller than $2.

Are you talking about version comparisons at m4 time (if so, is
m4_version_compare from autoconf adequate?), at shell time (if so, is
AS_VERSION_COMPARE from autoconf adequate?), or in your executable (if
so, is either the strverscmp or filevercmp module adequate?).

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


module request: comparing version numbers

2010-06-17 Thread Sam Steingold

Hi,
some gnulib modules (e.g., gnulib/m4/libunistring-base.m4) have facilities for 
comparing version numbers, e.g., 1.5.22 with 2.2.8.
it would be nice if there were a module (say, version-compare) which would 
export such a facility.

e.g., @VERSION_COMPARE@ would expand to
version_compare() {
  ...
}
which would return 0 or 1 depending on whether $1 is smaller than $2.
Thanks.
Sam.