RE : Re: error and program_name

2010-12-23 Thread Bastien ROUCARIES
If chdir is a problem, why not using a heavy weight approach (better safe
than sorry particularly if gnulib is used for a lot of project):
- fork and exec an helper for name resolution
- pass fd using a socket

It is really heavy but it is on the safe side

Bastien

Le 23 déc. 2010 03:12, "Paul Eggert"  a écrit :

On 12/22/2010 03:32 PM, Bruno Haible wrote:
> For example, if save_cwd called
> currdir_fd = open ...
Hmm, well, no, the fchdir could also fail if the directory is
on a remote file system and the network is down.  Or
if there is an I/O error (errno == EIO).  Or if search
permission is absent from the directory, assuming the
usual case where the directory was opened with O_RDONLY.
There are probably other reasons.

One workaround would be to wrap every system call
that resolves file names, so that all of these system calls
fail if given a relative file name after the fchdir failed.
But that sounds pretty drastic.


Re: error and program_name

2010-12-23 Thread Jim Meyering
Eric Blake wrote:
> On 12/22/2010 03:19 PM, Jim Meyering wrote:
>> Bruno Haible wrote:
>>
>>> Ping? No one wants to solve this? It's a critical issue for libposix.
>>>
>>> Eric Blake wrote:
 error() is not POSIX.  Maybe the thing to do is figure out what in
 libposix is dragging in error(), and work on breaking that dependency.
 That way, a package using libposix then makes their own decision of
 whether to supplement things with error() and program_name.
>>>
>>> I replied:
 Very good point. The dependency comes from

   openat -->  openat-die  -->  error
   fdopendir

 Can you work on breaking this dependency? I mean, for example,
 instead of directly calling openat_save_fail() and
 openat_restore_fail(), go through a variable that contains two
 function pointers, and have openat() and fdopendir() return an error code
 if these function pointers are NULL. Like we do with
   argp_program_version_hook
   error_print_progname
   obstack_alloc_failed_handler
 See also
   c_stack_action
   install_sigpipe_die_handler
>>
>> Hi Bruno,
>>
>> Perhaps I don't understand the proposal, but here is my reaction:
>>
>> IMHO, those functions must never return in the unusual case for which
>> they now call error and then exit.  The failures are too fundamental[0],
>> and we cannot require that all callers handle any new error code or
>> interpret existing error codes differently, can we?
>
> Perhaps the thing to do would be:
>
> The openat module has a function pointer openat_failed_handler,
> defaulting to NULL.  If we get into the situation where we changed
> directories but can't return, then call any non-NULL handler, and resort
> to calling abort() if the handler returns or if it was NULL.

Good idea, but any application built upon libposix deserves better than
a bare "abort".  Imagine running a libposix-using du in an unreadable
directory for which getcwd does not work -- it would simply abort because
it is incapable of recording the initial working directory.  Users and
those handling bug reports would not be happy, and would rightly call it
a bug.  So, it would be best to also print the usual diagnostic -- and
even the program name, when possible to do so without the global variable.

Sounds like I'd like a variant of the error module that does not use
the program_name global.

> The openat-die module then populates the openat_failed_handler with a
> function that uses error() rather than abort.
>
> That way, posix modules use just openat and don't drag in error(), but
> coreutils imports openat-die to get the nicer behavior than an abort()
> (that is, no change from current behavior).



RE: porting stdioext to HP-NonStop

2010-12-23 Thread Joachim Schmitz
Hi Bruno

OK,  a couple of problems:

During compile of gllib:
NSIG missing, I added it to gllib/spwani.c, in  a brute force fashion (#define 
NSIG 32) without really know what I'm doing here...
"/bin/kill -l | wc -w" returns 33.

During compile of gltests:
Something very weird errors in test-allignof.c:
source='test-alignof.c' object='test-alignof.o' libtool=no  DEPDIR=.deps 
depmode=none /bin/sh ./../build-aux/depcomp  cc -DHAVE_CONFIG_H -I.  
-DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib -I./../gllib  
-I/usr/local/include  -g -Wnowarn -c -o test-alignof.o test-alignof.c
  CHECK (char)
  ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/test-alignof.c", line 40: 
error(197):
  invalid size for bit field
...


alphasort missing, need to modify gllib/dirent.in.h? How?
source='test-dirent-c++.cc' object='test-dirent-c++.o' libtool=no  
DEPDIR=.depsdepmode=none /bin/sh ./../build-aux/depcomp  c++ -HAVE_CONFIG_H -I. 
  -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib -I./../gllib 
-I/usr/local/include  -Wnowarn -c -o test-dirent-c++.o test-dirent-c++.cc
  _GL_CXXALIAS_SYS_CAST (alphasort, int,
  ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/dirent.h", line 471: 
error(363):
  the global scope has no "alphasort"


gethostname missing (resp. not found, it is available and declared in 
), in various places. I added it to gllib/unistd.in.h
source='test-fcntl-h-c++.cc' object='test-fcntl-h-c++.o' libtool=no  
DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  c++ -DHAVE_CONFIG_H 
-I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib -I./../gllib 
-I/usr/local/include  -Wnowarn -c -o test-fcntl-h-c++.o test-fcntl-h-c++.cc
  _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
  ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/unistd.h", line 972: 
error(363):
  the global scope has no "gethostname"

Problem with HOST_NAME_MAX (MAXHOSTNAMELEN is set to 64 in , 
added this to gllib/unistd.in.h, but don't think it belongs there):
char buf[HOST_NAME_MAX];
 ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/test-gethostname.c", line 38: 
error(163):
  incomplete type is not allowed


if (strlen (NOHOSTNAME) >= HOST_NAME_MAX)
^
"/usr/local/Floss/gnulib/testdir-posix/gltests/test-gethostname.c", line 41: 
error(123):
  expected an expression


Incompatible prototype for inet_ntop 
source='test-getaddrinfo.c' object='test-getaddrinfo.o' libtool=no  
DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  cc -DHAVE_CONFIG_H 
-I.  -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib -I./../gllib  
-I/usr/local/include  -g -Wnowarn -c -o test-getaddrinfo.o test-getaddrinfo.c
  extern const char *inet_ntop (int af, const void *restrict src,
 ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/arpa/inet.h", line 
129: error(235):
  declaration is incompatible with
  "const char *inet_ntop(int, const void *, char *, size_t)" (declared
  at line 421 of "/usr/include/netdb.h")

and connect, bind, sendto, setsockopt (socklen_t vs. size_t), 'fixed' it in 
gllib/sys_socket.in.h (brute force, "#define socklen_t size_t")
source='test-sys_select-c++.cc' object='test-sys_select-c++.o' libtool=no  
DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  c++ -DHAVE_CONFIG_H 
-I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib -I./../gllib 
-I/usr/local/include  -Wnowarn -c -o test-sys_select-c++.o 
test-sys_select-c++.cc
  _GL_CXXALIAS_SYS (connect, int,
  ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
560: error(232):
  a value of type "extern "C" int (*)(int, const sockaddr *, size_t)"
  cannot be used to initialize an entity of type
  "int (*)(int, const sockaddr *, socklen_t)"

  _GL_CXXALIAS_SYS (bind, int,
  ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
615: error(232):
  a value of type "extern "C" int (*)(int, const sockaddr *, size_t)"
  cannot be used to initialize an entity of type
  "int (*)(int, const sockaddr *, socklen_t)"

  _GL_CXXALIAS_SYS (sendto, ssize_t,
  ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
837: error(232):
  a value of type "extern "C" ssize_t (*)(int, const void *, size_t,
  int, const sockaddr *, size_t)" cannot be used to initialize an
  entity of type "ssize_t (*)(int, const void *, size_t, int, const
  sockaddr *, socklen_t)"

  _GL_CXXALIAS_SYS (setsockopt, int, (int fd, int level, int optname,
  ^
"/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
865: error(232):
  a value of type
  "extern "C" int (*)(int, int, int, const void *, size_t)" cannot be
  used to initialize an entity of type
  "int (*)(int, int, 

Re: openat, failing fchdir

2010-12-23 Thread Bruno Haible
Hi Paul,

> > For example, if save_cwd called
> >   currdir_fd = open (".");
> > then on a platform that supports fchdir() natively [not gnulib's
> > emulation], a failure to do  fchdir (currdir_fd)  is of type (a).
> > It can only occur if some other part of the program did side
> > effects on currdir_fd.
> 
> Hmm, well, no, the fchdir could also fail if the directory is
> on a remote file system and the network is down.  Or
> if there is an I/O error (errno == EIO).

Really? fchdir is basically only copying a pointer in kernel space to a
special place in the process descriptor. But I agree with your essential
point: Not all possible fchdir() failures be detected ahead of time.

I just looked in the source code of Linux, FreeBSD, and OpenSolaris.

linux-2.6.36.2/fs/open.c
Possible errors:
  EBADF if fd is invalid
  ENOTDIR if fd does not denote a directory
  EACCES and similar if directory does not have EXEC and CHDIR permissions

FreeBSD CVS src/sys/kern/vfs_syscalls.c
Possible errors:
  EBADF if fd is invalid
  EINVAL if fd does not have a vnode
  ENOTDIR if fd does not denote a directory
  EACCES and similar if directory does not have VEXEC permissions
  ?? if filesystem root lookup failed

OpenSolaris SVN trunk/usr/src/uts/common/syscall/chdir.c
Possible errors:
  EBADF if fd is invalid
  ENOTDIR if fd does not denote a directory
  EACCES and similar if directory does not have VEXEC permissions
  ?? if directory has been hidden by autofs magic

So, while "network down" and "disk I/O error" will likely not
threaten fchdir() (since the necessary info is cached in the kernel),
a real threat is that someone does a "chmod 000 directory" and that
fchdir() then fails with EACCES.

Test program:
=
#include 
#include 
#include 

int main ()
{
  int fd;

  chdir ("/tmp/origdir");
  fd = open (".", O_RDONLY);
  chdir ("/tmp/origdir/subdir");
  sleep (10);
  if (fchdir (fd) < 0)
{
  perror ("fchdir failed");
}
  else
{
  fprintf (stderr, "fchdir succeeded\n");
}
  return 0;
}
=
$ mkdir -p /tmp/origdir/subdir
Then, while a.out is running, do "chmod 000 /tmp/origdir".
The result is:
  fchdir failed: Permission denied

Conclusion: Not all possible fchdir() failures be detected ahead of time.

Bruno



Re: openat, failing fchdir

2010-12-23 Thread Bruno Haible
Bastien ROUCARIES wrote:
> If chdir is a problem, why not using a heavy weight approach (better safe
> than sorry particularly if gnulib is used for a lot of project):
> - fork and exec an helper for name resolution
> - pass fd using a socket
> 
> It is really heavy but it is on the safe side

I like your idea. It would be a safe way to implement openat().

How does "pass fd using a socket" actually work? There are apparently two
ways to do it [1]:
  - On Unix domain sockets, using sendmsg SCM_RIGHTS [2][3].
Likely portable to glibc, MacOS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX,
IRIX, OSF/1, Solaris, Cygwin, Haiku. But not to Interix, mingw, BeOS.
  - On SystemV streams, using ioctl I_SENDFD [4].
Likely portable to glibc, AIX, HP-UX, IRIX, OSF/1, Solaris.

I don't care much about Interix and BeOS these days any more.

And on mingw, REPLACE_FCHDIR is 1, which means we assume that we use the
emulated fchdir, which associates a file name to every file descriptor
that maps to a directory. In this case, we could implement openat through
filename concatenation.

Bruno

[1] http://archives.neohapsis.com/archives/postfix/2000-09/1476.html
[2] http://linux.die.net/man/7/unix
[3] http://www.normalesup.org/~george/comp/libancillary/
[4] 
http://book.chinaunix.net/special/ebook/addisonWesley/APUE2/0201433079/ch17lev1sec4.html



Re: on HP-NonStop

2010-12-23 Thread Bruno Haible
Hello Joachim,

Please, let's use different mails with different subject for each topic.
Otherwise I cannot keep track which issues have been dealt with, and
the conversation dies down in confusion.

> During compile of gllib:
> NSIG missing, I added it to gllib/spwani.c, in  a brute force fashion 
> (#define NSIG 32) without really know what I'm doing here...
> "/bin/kill -l | wc -w" returns 33.

NSIG should be larger than any predefined signal value. Since you say
that your system has 33 signals, the value 32 is not right. Probably 33,
34, or 64 is better then. You need to look at the values in your
.

And the definition belongs in .

> SA_RESTART and SA_RESETHAND are missing
> source='test-sigaction.c' object='test-sigaction.o' libtool=no  DEPDIR=.deps 
> depmode=none /bin/sh ./../build-aux/depcomp  cc -DHAVE_CONFIG_H -I.  
> -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib -I./../gllib  
> -I/usr/local/include  -g -Wnowarn -c -o test-sigaction.o test-sigaction.c
> ASSERT ((sa.sa_flags & SA_RESETHAND) == 0);
> ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-sigaction.c", line 67: 
> error(114):
>   identifier "SA_RESETHAND" is undefined
> ...
> ASSERT ((old_sa.sa_flags & MASK_SA_FLAGS) == 0);
> ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-sigaction.c", line 97: 
> error(114):
>   identifier "SA_RESTART" is undefined

These two are specified by POSIX
.
Does NonStop Kernel really lack these flags, or are they merely available under
different names?

Bruno



Re: porting alignof to HP-NonStop

2010-12-23 Thread Bruno Haible
Joachim Schmitz wrote:
> During compile of gltests:
> Something very weird errors in test-allignof.c:
> source='test-alignof.c' object='test-alignof.o' libtool=no  DEPDIR=.deps 
> depmode=none /bin/sh ./../build-aux/depcomp  cc -DHAVE_CONFIG_H -I.  
> -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib -I./../gllib  
> -I/usr/local/include  -g -Wnowarn -c -o test-alignof.o test-alignof.c
>   CHECK (char)
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-alignof.c", line 40: 
> error(197):
>           invalid size for bit field
> ...

This looks pretty weird:
alignof_slot (char) and offsetof (char_helper, slot2) should be different??
Where alignof_slot (char) is defined as
  offsetof (struct { char __slot1; char __slot2; }, __slot2)
and char_helper is defined through
  typedef struct { char slot1; char slot2; } char_helper;

The only differences between the left-hand side and the right-hand side
are the names of the struct fields, and the use of 'typedef'.

You need to look at the preprocessed output (cc -E) of test-alignof.c
and trim it down to produce a minimal test case.

Bruno



Re: alphasort on HP-NonStop

2010-12-23 Thread Bruno Haible
Joachim Schmitz wrote:
> alphasort missing, need to modify gllib/dirent.in.h? How?
> source='test-dirent-c++.cc' object='test-dirent-c++.o' libtool=no  
> DEPDIR=.depsdepmode=none /bin/sh ./../build-aux/depcomp  c++ -HAVE_CONFIG_H 
> -I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib 
> -I./../gllib -I/usr/local/include  -Wnowarn -c -o test-dirent-c++.o 
> test-dirent-c++.cc
>   _GL_CXXALIAS_SYS_CAST (alphasort, int,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/dirent.h", line 
> 471: error(363):
>           the global scope has no "alphasort"

Gnulib has an 'alphasort' module that provides a replacement when the
function is missing. The error message here makes me think that the function
exists on your system but its declaration is missing.

Can you add the declaration to ?

References:



Bruno



Re: gethostname on HP-NonStop

2010-12-23 Thread Bruno Haible
Joachim Schmitz wrote:
> gethostname missing (resp. not found, it is available and declared in 
> ), in various places. I added it to gllib/unistd.in.h
> source='test-fcntl-h-c++.cc' object='test-fcntl-h-c++.o' libtool=no  
> DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  c++ -DHAVE_CONFIG_H 
> -I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib 
> -I./../gllib -I/usr/local/include  -Wnowarn -c -o test-fcntl-h-c++.o 
> test-fcntl-h-c++.cc
>   _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/unistd.h", line 
> 972: error(363):
>           the global scope has no "gethostname"

gethostname ought to be declared in , not in .

Reference:


Bruno



Re: HOST_NAME_MAX on HP-NonStop

2010-12-23 Thread Bruno Haible
Joachim Schmitz wrote:
> Problem with HOST_NAME_MAX (MAXHOSTNAMELEN is set to 64 in , 
> added this to gllib/unistd.in.h, but don't think it belongs there):
>     char buf[HOST_NAME_MAX];
>          ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-gethostname.c", line 38: 
> error(163):
>           incomplete type is not allowed
> 
> 
>     if (strlen (NOHOSTNAME) >= HOST_NAME_MAX)
>                                             ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-gethostname.c", line 41: 
> error(123):
>           expected an expression

What's going on here? If HOST_NAME_MAX is not defined in ,
HOST_NAME_MAX ought to be defined in config.h, after the code from
m4/gethostname.m4 has been executed. A look in config.log should tell
you what went on here (check out for "checking for HOST_NAME_MAX").

Bruno



Re: porting stdioext to HP-NonStop

2010-12-23 Thread Bruno Haible
Joachim Schmitz wrote:
> Our select() needs  (for fd_set and friends), I added this to 
> gllib/sys_select.in.h

gnulib's lib/sys_select.in.h already contains an inclusion of .

What was the symptom that you observed?

Bruno



Re: printf.o HP-NonStop

2010-12-23 Thread Bruno Haible
Joachim Schmitz wrote:
> rpl_printf missing (during linking) (and an empty .o file created)
>  ERROR  [1210]:
>    test-stdio-c++.o (.rodata + 0x10): unresolved reference to rpl_printf.

Hmm, an empty .o file indicates some other kind of error. Is it
reproducible when you try to build printf.o again?

Bruno



RE: on HP-NonStop

2010-12-23 Thread Joachim Schmitz
Hi Bruno

OK, the highest number for any SIG is 31, so NSIG should really be 
32.

The only SA_ Macros I can find are SA_DATA_SITE in , 
most probably unrated, and SA_NOCLDSTOP and SA_RESERVED_31 in , and 
nothing that looks remotely like a replacement, signal.h attached

Bye, Jojo

-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 1:30 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re:  on HP-NonStop

Hello Joachim,

Please, let's use different mails with different subject for each topic.
Otherwise I cannot keep track which issues have been dealt with, and the 
conversation dies down in confusion.

> During compile of gllib:
> NSIG missing, I added it to gllib/spwani.c, in  a brute force fashion 
> (#define NSIG 32) without really know what I'm doing here...
> "/bin/kill -l | wc -w" returns 33.

NSIG should be larger than any predefined signal value. Since you say that your 
system has 33 signals, the value 32 is not right. Probably 33, 34, or 64 is 
better then. You need to look at the values in your .

And the definition belongs in .

> SA_RESTART and SA_RESETHAND are missing source='test-sigaction.c' 
> object='test-sigaction.o' libtool=no  DEPDIR=.deps depmode=none /bin/sh 
> ./../build-aux/depcomp  cc -DHAVE_CONFIG_H -I.  -DGNULIB_STRICT_CHECKING=1  
> -I. -I.  -I.. -I./..  -I../gllib -I./../gllib  -I/usr/local/include  -g 
> -Wnowarn -c -o test-sigaction.o test-sigaction.c
> ASSERT ((sa.sa_flags & SA_RESETHAND) == 0);
> ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-sigaction.c", line 67: 
> error(114):
>   identifier "SA_RESETHAND" is undefined ...
> ASSERT ((old_sa.sa_flags & MASK_SA_FLAGS) == 0);
> ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-sigaction.c", line 97: 
> error(114):
>   identifier "SA_RESTART" is undefined

These two are specified by POSIX
.
Does NonStop Kernel really lack these flags, or are they merely available under 
different names?

Bruno
#ifdef __TANDEM
#pragma columns 80
#if _TANDEM_ARCH_ != 0
#pragma ONCE
#endif
#endif
#ifndef _SIGNAL
#define _SIGNAL

/* T8645H02 - (21MAY2008) - signal.h   signal/job-control definitions */
/* T8645G08^AAX - (10MAY2007) */

/*
 *  Copyright 2008 Hewlett Packard Development Company, L.P.
 *
 * ALL RIGHTS RESERVED
 */

#ifdef __cplusplus
   extern "C" {
#endif

#ifdef __OLDCALLS  /* TNS C legacy header */
#pragma nooldcalls
#define REVERT_TO_OLDCALLS
#endif


/* Supports TNS and TNS/R (where both Guardian and OSS processes
 * can have signals); and native mode 128-bit signal facilities
 */

#if defined(_POSIX_SOURCE) || _POSIX_C_SOURCE == 1 || \
defined(_XOPEN_SOURCE) || _POSIX_C_SOURCE == 2 || \
defined(_TANDEM_SOURCE)

#ifndef _GUARDIAN_TARGET
#ifndef _GUARDIAN_HOST
#include 
#else
#include  nolist
#endif /* _GUARDIAN_HOST */
#endif /* !_GUARDIAN_TARGET */

/* sigset_t required even for TNS because parts of SL need it */
#if _TANDEM_ARCH_ != 0 || !defined(__TANDEM)
   #ifdef __TANDEM
   #pragma fieldalign shared8 __sigset_template
   #endif
   struct __sigset_template { long long item64[2]; }; /* 128 bit */
   typedef struct __sigset_template sigset_t; /* native size 128 bits */
#else  /* _TANDEM_ARCH_ == 0 */
   typedef long  sigset_t;/* TNS size 32 bits */
#endif /* _TANDEM_ARCH_ == 0 */

#if _TANDEM_ARCH_ != 0 || !defined(_GUARDIAN_TARGET)  /* native or TNS OSS */

   #ifdef __TANDEM
   #pragma fieldalign shared8 sigaction
   #endif

   #if _TANDEM_ARCH_ != 0 || !defined(__TANDEM)   /* native */
  struct sigaction
  {
  sigset_t  sa_mask;
  void(*sa_handler)(int);
  int   sa_flags;
  };
   #else  /* OSS TNS (sigaction meaningful) */
  struct sigaction
  {
  void(*sa_handler)(int);
  sigset_t  sa_mask;
  int   sa_flags;
   #ifndef filler_0
  char  filler_0[8];
   #else
  char  __filler_0[8];
   #endif /* !filler_0 */
  };
   #endif /* OSS TNS (sigaction meaningful) */

   #ifdef _TANDEM_SOURCE
   typedef  struct sigaction sigaction_t;
   #endif /* _TANDEM_SOURCE */

#endif /* _TANDEM_ARCH_ != 0 || !_GUARDIAN_TARGET */

#endif /* _POSIX_SOURCE || ... || _XOPEN_SOURCE || _TANDEM_SOURCE */

typedef short sig_atomic_t;


/* signal numbers and miscellaneous definitions:
  OSS/native signals are a superset of TNS-Guardian signals (same numbers).
  OSS/native values for SIG_DFL, SIG_IGN and SIG_ERR don't agree with
  Guardian TNS definitions.  The OSS values represent invalid
  routine addresses in both TNS and TNS/R realms.
*/
#if _TANDEM_ARCH_ == 0 && defined(_GUARDIAN_TARGET)
   /* Standard C signals for TNS Guardian */

   #define SIGINT2  /* Interactive Attention */
   #define SIGILL4  /* Instruction Failure(G

RE: gethostname on HP-NonStop

2010-12-23 Thread Joachim Schmitz
Oh well, it is not here. So some kind of workaround is needed.

-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 1:43 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re: gethostname on HP-NonStop

Joachim Schmitz wrote:
> gethostname missing (resp. not found, it is available and declared in 
> ), in various places. I added it to gllib/unistd.in.h 
> source='test-fcntl-h-c++.cc' object='test-fcntl-h-c++.o' libtool=no  
> DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  c++ 
> -DHAVE_CONFIG_H -I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  
> -I../gllib -I./../gllib -I/usr/local/include  -Wnowarn -c -o 
> test-fcntl-h-c++.o test-fcntl-h-c++.cc
>   _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/unistd.h", line 
> 972: error(363):
>   the global scope has no "gethostname"

gethostname ought to be declared in , not in .

Reference:


Bruno




RE: HOST_NAME_MAX on HP-NonStop

2010-12-23 Thread Joachim Schmitz
Good question. In config.h I can only see:

#define HOST_NAME_MAX

So it gets #define'd but with no value

>From config.log:

configure:33394: checking for HOST_NAME_MAX
configure:33420: cc -o conftest -g -I/usr/local/include  conftest.c  >&5
  static long int longval () { return MAXHOSTNAMELEN; }
  ^
"/usr/local/Floss/gnulib/testdir-posix/conftest.c", line 382: error(114):
  identifier "MAXHOSTNAMELEN" is undefined


  static unsigned long int ulongval () { return MAXHOSTNAMELEN; }
^
"/usr/local/Floss/gnulib/testdir-posix/conftest.c", line 383: error(114):
  identifier "MAXHOSTNAMELEN" is undefined


if ((MAXHOSTNAMELEN) < 0)
 ^
"/usr/local/Floss/gnulib/testdir-posix/conftest.c", line 393: error(114):
  identifier "MAXHOSTNAMELEN" is undefined


return 0;
^
"/usr/local/Floss/gnulib/testdir-posix/conftest.c", line 412: warning(203):
  statement is unreachable


3 errors detected in the compilation of "conftest.c".
c89: /usr/cmplr/ccombe exited, returning 2.


Possibly because it does not #include 

Bye, Jojo
-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 1:48 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re: HOST_NAME_MAX on HP-NonStop

Joachim Schmitz wrote:
> Problem with HOST_NAME_MAX (MAXHOSTNAMELEN is set to 64 in , 
> added this to gllib/unistd.in.h, but don't think it belongs there):
> char buf[HOST_NAME_MAX];
>  ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-gethostname.c", line 38: 
> error(163):
>   incomplete type is not allowed
> 
> 
> if (strlen (NOHOSTNAME) >= HOST_NAME_MAX)
> ^ 
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-gethostname.c", line 41: 
> error(123):
>   expected an expression

What's going on here? If HOST_NAME_MAX is not defined in , 
HOST_NAME_MAX ought to be defined in config.h, after the code from
m4/gethostname.m4 has been executed. A look in config.log should tell you what 
went on here (check out for "checking for HOST_NAME_MAX").

Bruno




Re: RE : Re: error and program_name

2010-12-23 Thread Jim Meyering
Bastien ROUCARIES wrote:
> If chdir is a problem, why not using a heavy weight approach (better safe than
> sorry particularly if gnulib is used for a lot of project):
> - fork and exec an helper for name resolution
> - pass fd using a socket
>
> It is really heavy but it is on the safe side

Expensive indeed.
We've used that approach as a fallback in a couple of other areas
(see gnulib's lib/savewd.c and its uses in coreutils:
http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=b67faf329ce),
but never in functions as heavily used as openat, statat, chownat, etc.

Adding a single "stat" call to the inner loop behind "chown -R ..."
can add about 25% to the run-time duration.  Adding a fork may be
prohibitive.  The trouble is that we cannot resort to using "fork"
only when the faster f?chdir-based implementation fails, since once it
has failed it is too late.

If someone tries this, I'll be interested to see the cost it incurs.



RE: porting stdioext to HP-NonStop

2010-12-23 Thread Joachim Schmitz
Yes, but with a condition that apparently is not met (and to deeply nested and 
complicated for me to grasp), hence my change:

diff -u ./gllib/sys_select.in.h.orig ./gllib/sys_select.in.h
--- ./gllib/sys_select.in.h.orig2010-10-10 16:05:05.0 -0500
+++ ./gllib/sys_select.in.h 2010-12-23 03:38:34.0 -0600
@@ -60,6 +60,8 @@
 /* The include_next requires a split double-inclusion guard.  */
 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@

+#elif defined __TANDEM /* HP NonStop */
+# include 
 #endif

 #ifndef _GL_SYS_SELECT_H


Symptoms were error reg. timeval, fd_set, FD_ISSET not being available

Bye, Jojo
-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 1:50 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re: porting stdioext to HP-NonStop

Joachim Schmitz wrote:
> Our select() needs  (for fd_set and friends), I added this to 
> gllib/sys_select.in.h

gnulib's lib/sys_select.in.h already contains an inclusion of .

What was the symptom that you observed?

Bruno




RE: printf.o HP-NonStop

2010-12-23 Thread Joachim Schmitz
Hi Bruno

test-stdio-c++.o was the empty file

gllig/printf.o is not, but does not contain rpl_printf:
$ nm -Pe gllib/printf.o
 E __stdio_fp
 F printf
 E rpl_vfprintf

Bye, Jojo
-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 1:52 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re: printf.o HP-NonStop

Joachim Schmitz wrote:
> rpl_printf missing (during linking) (and an empty .o file created)
>  ERROR  [1210]:
>test-stdio-c++.o (.rodata + 0x10): unresolved reference to rpl_printf.

Hmm, an empty .o file indicates some other kind of error. Is it reproducible 
when you try to build printf.o again?

Bruno




RE: alphasort on HP-NonStop

2010-12-23 Thread Joachim Schmitz
You mean add alphasort to gllib/dirent.in.h?

We don't have an alphasort elsewhere
And yes, we're quite a bit behind the current POSIX...

-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 1:40 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re: alphasort on HP-NonStop

Joachim Schmitz wrote:
> alphasort missing, need to modify gllib/dirent.in.h? How?
> source='test-dirent-c++.cc' object='test-dirent-c++.o' libtool=no  
> DEPDIR=.depsdepmode=none /bin/sh ./../build-aux/depcomp  c++ 
> -HAVE_CONFIG_H -I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  
> -I../gllib -I./../gllib -I/usr/local/include  -Wnowarn -c -o 
> test-dirent-c++.o test-dirent-c++.cc
>   _GL_CXXALIAS_SYS_CAST (alphasort, int,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/dirent.h", line 
> 471: error(363):
>   the global scope has no "alphasort"

Gnulib has an 'alphasort' module that provides a replacement when the function 
is missing. The error message here makes me think that the function exists on 
your system but its declaration is missing.

Can you add the declaration to ?

References:



Bruno




Re: socket functions on HP-NonStop

2010-12-23 Thread Bruno Haible
Joachim Schmitz wrote:
> Incompatible prototype for inet_ntop 
> source='test-getaddrinfo.c' object='test-getaddrinfo.o' libtool=no  
> DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  cc -DHAVE_CONFIG_H 
> -I.  -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib 
> -I./../gllib  -I/usr/local/include  -g -Wnowarn -c -o test-getaddrinfo.o 
> test-getaddrinfo.c
>   extern const char *inet_ntop (int af, const void *restrict src,
>                      ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/arpa/inet.h", line 
> 129: error(235):
>           declaration is incompatible with
>           "const char *inet_ntop(int, const void *, char *, size_t)" (declared
>           at line 421 of "/usr/include/netdb.h")
> 
> and connect, bind, sendto, setsockopt (socklen_t vs. size_t), 'fixed' it in 
> gllib/sys_socket.in.h (brute force, "#define socklen_t size_t")
> source='test-sys_select-c++.cc' object='test-sys_select-c++.o' libtool=no  
> DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  c++ -DHAVE_CONFIG_H 
> -I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  -I../gllib 
> -I./../gllib -I/usr/local/include  -Wnowarn -c -o test-sys_select-c++.o 
> test-sys_select-c++.cc
>   _GL_CXXALIAS_SYS (connect, int,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
> 560: error(232):
>           a value of type "extern "C" int (*)(int, const sockaddr *, size_t)"
>           cannot be used to initialize an entity of type
>           "int (*)(int, const sockaddr *, socklen_t)"
> 
>   _GL_CXXALIAS_SYS (bind, int,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
> 615: error(232):
>           a value of type "extern "C" int (*)(int, const sockaddr *, size_t)"
>           cannot be used to initialize an entity of type
>           "int (*)(int, const sockaddr *, socklen_t)"
> 
>   _GL_CXXALIAS_SYS (sendto, ssize_t,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
> 837: error(232):
>           a value of type "extern "C" ssize_t (*)(int, const void *, size_t,
>           int, const sockaddr *, size_t)" cannot be used to initialize an
>           entity of type "ssize_t (*)(int, const void *, size_t, int, const
>           sockaddr *, socklen_t)"
> 
>   _GL_CXXALIAS_SYS (setsockopt, int, (int fd, int level, int optname,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
> 865: error(232):
>           a value of type
>           "extern "C" int (*)(int, int, int, const void *, size_t)" cannot be
>           used to initialize an entity of type
>           "int (*)(int, int, int, const void *, socklen_t)"

Is socklen_t already defined in the system or libfloss includes on this system?
Or does its definition come from gnulib (either from config.h or gnulib's
sys/socket.h replacement)?

Bruno



RE: gethostname on HP-NonStop

2010-12-23 Thread Joachim Schmitz
Mine was:
diff -u ./gllib/unistd.in.h.orig ./gllib/unistd.in.h
--- ./gllib/unistd.in.h.orig2010-12-20 19:57:37.0 -0600
+++ ./gllib/unistd.in.h 2010-12-23 07:57:13.0 -0600
@@ -51,6 +51,14 @@
 # undef _GL_INCLUDING_WINSOCK2_H
 #endif

+#ifdef __TANDEM /* HP-Nonstop has gethostname() in  */
+#include 
+/* and MAXHOSTNAMELEN in  */
+#include 
+#undef HOST_NAME_MAX
+#define HOST_NAME_MAX MAXHOSTNAMELEN
+#endif
+
 #if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
 #define _GL_UNISTD_H


Fixes the HOST_NAME_MAX problem too...


-Original Message-
From: Joachim Schmitz [mailto:j...@schmitz-digital.de] 
Sent: Thursday, December 23, 2010 1:55 PM
To: 'Bruno Haible'
Cc: 'bug-gnulib@gnu.org'
Subject: RE: gethostname on HP-NonStop

Oh well, it is not here. So some kind of workaround is needed.

-Original Message-
From: Bruno Haible [mailto:br...@clisp.org]
Sent: Thursday, December 23, 2010 1:43 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re: gethostname on HP-NonStop

Joachim Schmitz wrote:
> gethostname missing (resp. not found, it is available and declared in 
> ), in various places. I added it to gllib/unistd.in.h 
> source='test-fcntl-h-c++.cc' object='test-fcntl-h-c++.o' libtool=no 
> DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  c++ 
> -DHAVE_CONFIG_H -I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..
> -I../gllib -I./../gllib -I/usr/local/include  -Wnowarn -c -o
> test-fcntl-h-c++.o test-fcntl-h-c++.cc
>   _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/unistd.h", line 
> 972: error(363):
>   the global scope has no "gethostname"

gethostname ought to be declared in , not in .

Reference:


Bruno




Re: RE : Re: error and program_name

2010-12-23 Thread Jim Meyering
Bastien ROUCARIÈS wrote:
> We could amortize the fork daemonize the daemon only once but we must
> care about security... but i could be done if fork is prohibitive.

Starting a daemon...
Yes, that sounds challenging.

> Unfortunatly context switching is the main cost so, i expext a heavy use
>
> However the probability of faillure times the damage are too high.

We also take into account the fact that any work-around code
will run only on systems that lack *at function support
and that lack the means to emulate them robustly (via /proc).
I.e., any new code would be used only on systems that are
not evolving with POSIX.

> I really prefer to be slow but safe than fast but sometimes loss my data.

How how could the current situation lead to data loss?
Or do you mean something else?

FYI, on modern systems, the tools are fast *and* safe.
We're talking about what happens only on systems with
inferior system/library support.



RE: socket functions on HP-NonStop

2010-12-23 Thread Joachim Schmitz
Libfloss is not used (yet?), but has some hooks for this problem, the compiler 
wrapper script it contains uses -DSOCKLEN_T=socklen_t.

Other than that socklen_t is typedef'ed in  (and as an int) but, 
for some strange and probably historical reason, not used anywhere, in 
particular not in those socket funktions with use a size_t instead (which is 
typedefe'ed to an unsigned integer)

My 'fix' so far:
diff -u ./gllib/sys_socket.in.h.orig ./gllib/sys_socket.in.h
--- ./gllib/sys_socket.in.h.orig2010-11-30 14:19:12.0 -0600
+++ ./gllib/sys_socket.in.h 2010-12-23 04:43:53.0 -0600
@@ -165,6 +165,10 @@

 #endif

+#ifdef __TANDEM
+#define socklen_t size_t
+#endif
+
 #if @HAVE_WINSOCK2_H@

 /* Re-define FD_ISSET to avoid a WSA call while we are not using

-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 3:05 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re: socket functions on HP-NonStop

Joachim Schmitz wrote:
> Incompatible prototype for inet_ntop
> source='test-getaddrinfo.c' object='test-getaddrinfo.o' libtool=no  
> DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  cc 
> -DHAVE_CONFIG_H -I.  -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  
> -I../gllib -I./../gllib  -I/usr/local/include  -g -Wnowarn -c -o 
> test-getaddrinfo.o test-getaddrinfo.c
>   extern const char *inet_ntop (int af, const void *restrict src,
>  ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/./../gllib/arpa/inet.h", line 
> 129: error(235):
>   declaration is incompatible with
>   "const char *inet_ntop(int, const void *, char *, size_t)" 
> (declared
>   at line 421 of "/usr/include/netdb.h")
> 
> and connect, bind, sendto, setsockopt (socklen_t vs. size_t), 'fixed' 
> it in gllib/sys_socket.in.h (brute force, "#define socklen_t size_t") 
> source='test-sys_select-c++.cc' object='test-sys_select-c++.o' 
> libtool=no  DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  
> c++ -DHAVE_CONFIG_H -I.   -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. 
> -I./..  -I../gllib -I./../gllib -I/usr/local/include  -Wnowarn -c -o 
> test-sys_select-c++.o test-sys_select-c++.cc
>   _GL_CXXALIAS_SYS (connect, int,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
> 560: error(232):
>   a value of type "extern "C" int (*)(int, const sockaddr *, size_t)"
>   cannot be used to initialize an entity of type
>   "int (*)(int, const sockaddr *, socklen_t)"
> 
>   _GL_CXXALIAS_SYS (bind, int,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
> 615: error(232):
>   a value of type "extern "C" int (*)(int, const sockaddr *, size_t)"
>   cannot be used to initialize an entity of type
>   "int (*)(int, const sockaddr *, socklen_t)"
> 
>   _GL_CXXALIAS_SYS (sendto, ssize_t,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
> 837: error(232):
>   a value of type "extern "C" ssize_t (*)(int, const void *, 
> size_t,
>   int, const sockaddr *, size_t)" cannot be used to initialize 
> an
>   entity of type "ssize_t (*)(int, const void *, size_t, int, 
> const
>   sockaddr *, socklen_t)"
> 
>   _GL_CXXALIAS_SYS (setsockopt, int, (int fd, int level, int optname,
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/../gllib/sys/socket.h", line 
> 865: error(232):
>   a value of type
>   "extern "C" int (*)(int, int, int, const void *, size_t)" 
> cannot be
>   used to initialize an entity of type
>   "int (*)(int, int, int, const void *, socklen_t)"

Is socklen_t already defined in the system or libfloss includes on this system?
Or does its definition come from gnulib (either from config.h or gnulib's 
sys/socket.h replacement)?

Bruno




RE: on HP-NonStop

2010-12-23 Thread Joachim Schmitz
My fix for NSIG:
diff -u ./gllib/signal.in.h.orig ./gllib/signal.in.h
--- ./gllib/signal.in.h.orig2010-10-10 16:05:05.0 -0500
+++ ./gllib/signal.in.h 2010-12-23 06:52:43.0 -0600
@@ -73,7 +73,7 @@


 #if @GNULIB_SIGPROCMASK@
-# if !...@have_posix_signalblocking@
+# if !...@have_posix_signalblocking@ || defined __TANDEM

 /* Maximum signal number + 1.  */
 #  ifndef NSIG


And reg. SA_RESETHAND and SA_RESTART: yes we're  behind the current POSIX by 
quite a bit unfortunatly. 
And if I read 
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html 
correclty, these have been optional up to Issue 6.

Bye, Jojo
-Original Message-
From: Joachim Schmitz [mailto:j...@schmitz-digital.de] 
Sent: Thursday, December 23, 2010 1:52 PM
To: 'Bruno Haible'
Cc: 'bug-gnulib@gnu.org'
Subject: RE:  on HP-NonStop

Hi Bruno

OK, the highest number for any SIG is 31, so NSIG should really be 
32.

The only SA_ Macros I can find are SA_DATA_SITE in , 
most probably unrated, and SA_NOCLDSTOP and SA_RESERVED_31 in , and 
nothing that looks remotely like a replacement, signal.h attached

Bye, Jojo

-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 1:30 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re:  on HP-NonStop

Hello Joachim,

Please, let's use different mails with different subject for each topic.
Otherwise I cannot keep track which issues have been dealt with, and the 
conversation dies down in confusion.

> During compile of gllib:
> NSIG missing, I added it to gllib/spwani.c, in  a brute force fashion 
> (#define NSIG 32) without really know what I'm doing here...
> "/bin/kill -l | wc -w" returns 33.

NSIG should be larger than any predefined signal value. Since you say that your 
system has 33 signals, the value 32 is not right. Probably 33, 34, or 64 is 
better then. You need to look at the values in your .

And the definition belongs in .

> SA_RESTART and SA_RESETHAND are missing source='test-sigaction.c' 
> object='test-sigaction.o' libtool=no  DEPDIR=.deps depmode=none /bin/sh 
> ./../build-aux/depcomp  cc -DHAVE_CONFIG_H -I.  -DGNULIB_STRICT_CHECKING=1  
> -I. -I.  -I.. -I./..  -I../gllib -I./../gllib  -I/usr/local/include  -g 
> -Wnowarn -c -o test-sigaction.o test-sigaction.c
> ASSERT ((sa.sa_flags & SA_RESETHAND) == 0);
> ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-sigaction.c", line 67: 
> error(114):
>   identifier "SA_RESETHAND" is undefined ...
> ASSERT ((old_sa.sa_flags & MASK_SA_FLAGS) == 0);
> ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-sigaction.c", line 97: 
> error(114):
>   identifier "SA_RESTART" is undefined

These two are specified by POSIX
.
Does NonStop Kernel really lack these flags, or are they merely available under 
different names?

Bruno




list protocol [was: on HP-NonStop]

2010-12-23 Thread Eric Blake
On 12/23/2010 05:30 AM, Bruno Haible wrote:
> Hello Joachim,
> 
> Please, let's use different mails with different subject for each topic.
> Otherwise I cannot keep track which issues have been dealt with, and
> the conversation dies down in confusion.

Also, it would be nice if you didn't top-post, and trimmed your replies
to remove material that is not relevant to the particular email.

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



signature.asc
Description: OpenPGP digital signature


Re: openat, failing fchdir

2010-12-23 Thread Eric Blake
On 12/23/2010 05:08 AM, Bruno Haible wrote:
> Bastien ROUCARIES wrote:
>> If chdir is a problem, why not using a heavy weight approach (better safe
>> than sorry particularly if gnulib is used for a lot of project):
>> - fork and exec an helper for name resolution
>> - pass fd using a socket
>>
>> It is really heavy but it is on the safe side
> 
> I like your idea. It would be a safe way to implement openat().
> 
> How does "pass fd using a socket" actually work? There are apparently two
> ways to do it [1]:
>   - On Unix domain sockets, using sendmsg SCM_RIGHTS [2][3].
> Likely portable to glibc, MacOS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX,
> IRIX, OSF/1, Solaris, Cygwin, Haiku. But not to Interix, mingw, BeOS.

Unfortunately, it is not possible to pass fds on cygwin; it is not
possible to implement SCM_RIGHTS on top of what Windows provides.  Then
again, cygwin's *at functions don't need replacing, so it's a moot
point.  The whole exercise here is how to cater to systems that don't
support native *at correctly.

> And on mingw, REPLACE_FCHDIR is 1, which means we assume that we use the
> emulated fchdir, which associates a file name to every file descriptor
> that maps to a directory. In this case, we could implement openat through
> filename concatenation.

Indeed; furthermore, mingw has the (in this case, nice) property that
absolute pathnames cannot be larger than about 256 bytes, so there's not
as much risk of the O(n^2) behavior that filename concatenation would
have on other systems with unlimited directory depth.

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



signature.asc
Description: OpenPGP digital signature


RE: porting alignof to HP-NonStop

2010-12-23 Thread Joachim Schmitz
Here's one of those CHECK macros expanded

typedef struct { char slot1; char slot2; } char_helper; extern int (* 
verify_function40 (void)) [(! !sizeof (struct { unsigned int 
verify_error_if_negative_size__: (((size_t)__INTADDR__(&(((struct { char 
__slot1; char __slot2; } *)0)->__slot2))) == 
((size_t)__INTADDR__(&(((char_helper *)0)->slot2 ? 1 : -1; }))]; const int 
char_slot_alignment = ((size_t)__INTADDR__(&(((struct { char __slot1; char 
__slot2; } *)0)->__slot2))); const int char_type_alignment = 
((size_t)__INTADDR__(&(((struct { char __slot1; char __slot2; } 
*)0)->__slot2)));

Seem like the bit filed it complains about starts with the 
unsigned int verify_error_if_negative_size__: ...
looks like 

(((size_t)__INTADDR__(&(((struct { char __slot1; char __slot2; } 
*)0)->__slot2))) == ((size_t)__INTADDR__(&(((char_helper *)0)->slot2 ? 1 : 
-1;

Goes negative (-1), because 

((size_t)__INTADDR__(&(((struct { char __slot1; char __slot2; } *)0)->__slot2)))

Is not equal to

((size_t)__INTADDR__(&(((char_helper *)0)->slot2)))

do you see why, resp. what's wrong here?

-Original Message-
From: Bruno Haible [mailto:br...@clisp.org] 
Sent: Thursday, December 23, 2010 1:36 PM
To: Joachim Schmitz
Cc: bug-gnulib@gnu.org
Subject: Re: porting alignof to HP-NonStop

Joachim Schmitz wrote:
> During compile of gltests:
> Something very weird errors in test-allignof.c:
> source='test-alignof.c' object='test-alignof.o' libtool=no  
> DEPDIR=.deps depmode=none /bin/sh ./../build-aux/depcomp  cc 
> -DHAVE_CONFIG_H -I.  -DGNULIB_STRICT_CHECKING=1  -I. -I.  -I.. -I./..  
> -I../gllib -I./../gllib  -I/usr/local/include  -g -Wnowarn -c -o 
> test-alignof.o test-alignof.c
>   CHECK (char)
>   ^
> "/usr/local/Floss/gnulib/testdir-posix/gltests/test-alignof.c", line 40: 
> error(197):
>   invalid size for bit field
> ...

This looks pretty weird:
alignof_slot (char) and offsetof (char_helper, slot2) should be different??
Where alignof_slot (char) is defined as
  offsetof (struct { char __slot1; char __slot2; }, __slot2) and char_helper is 
defined through
  typedef struct { char slot1; char slot2; } char_helper;

The only differences between the left-hand side and the right-hand side are the 
names of the struct fields, and the use of 'typedef'.

You need to look at the preprocessed output (cc -E) of test-alignof.c and trim 
it down to produce a minimal test case.

Bruno




[PATCH] sigpipe: relax to LGPLv2+, since it did not have any LGPLv3+ parts

2010-12-23 Thread Eric Blake
* modules/sigpipe (License): Relax license.

Signed-off-by: Eric Blake 
---

Right now, the sigpipe module depends only on:

signal
sigprocmask
stdio
unistd

all of which are LGPLv2+.  It also adds a single file, m4/sigpipe.m4,
which is under the permissive .m4 file license.  Therefore, since
there are no components of this module under LGPLv3+, I'm pushing this
patch (so that libvirt can use the module on mingw).

 ChangeLog   |5 +
 modules/sigpipe |2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4499fa2..0bf5a4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-23  Eric Blake  
+
+   sigpipe: relax to LGPLv2+, since it did not have any LGPLv3+ parts
+   * modules/sigpipe (License): Relax license.
+
 2010-12-14  Eric Blake  

configmake: provide fallbacks for oldest supported autotools
diff --git a/modules/sigpipe b/modules/sigpipe
index 56cb57b..99e3e9e 100644
--- a/modules/sigpipe
+++ b/modules/sigpipe
@@ -35,7 +35,7 @@ Include:
 

 License:
-LGPL
+LGPLv2+

 Maintainer:
 Bruno Haible
-- 
1.7.3.3




Re: openat, failing fchdir

2010-12-23 Thread Bruce Korb
On 12/23/10 06:52, Eric Blake wrote:
> Unfortunately, it is not possible to pass fds on cygwin; it is not
> possible to implement SCM_RIGHTS on top of what Windows provides.  Then
> again, cygwin's *at functions don't need replacing, so it's a moot
> point.  The whole exercise here is how to cater to systems that don't
> support native *at correctly.

It is slightly more complicated than that:  The *at gnulib modules
need to not drag in gnulib modules that have an extended interface
requirement.  viz. a call to set_program_name().

As has been pointed out in this thread, there are lots of end-case
issues that need resolution for a perfect implementation.
An "adequate" implementation needs to not seg fault during
an attempt to print an informative message.  That can be handled
by either not necessarily calling error() on an error, or by
changing error() to not require that program_name be set.

When I get back from my Christmas weekend, I propose fiddling the
code the least invasive way possible for libposix and let the
Perfect Implementation come later.  I'd rather to rework than
stall around any more.



RE : Re: openat, failing fchdir

2010-12-23 Thread Bastien ROUCARIES
For cygwin and windows plateform see ntcreatefile that allow to open an
handle relativly to another handle

Bastien

Le 23 déc. 2010 15:52, "Eric Blake"  a écrit :

On 12/23/2010 05:08 AM, Bruno Haible wrote:
> Bastien ROUCARIES wrote:
>> If chdir is a problem, why...
Unfortunately, it is not possible to pass fds on cygwin; it is not
possible to implement SCM_RIGHTS on top of what Windows provides.  Then
again, cygwin's *at functions don't need replacing, so it's a moot
point.  The whole exercise here is how to cater to systems that don't
support native *at correctly.


> And on mingw, REPLACE_FCHDIR is 1, which means we assume that we use the
> emulated fchdir, which...
Indeed; furthermore, mingw has the (in this case, nice) property that
absolute pathnames cannot be larger than about 256 bytes, so there's not
as much risk of the O(n^2) behavior that filename concatenation would
have on other systems with unlimited directory depth.

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


RE : Re: openat, failing fchdir

2010-12-23 Thread Bastien ROUCARIES
Dear bruce,

See my attempt to provide program name under aix hpux and irix,

If you could test it, i could help you

Btw instead of creating our own interface why not use the well known bsd
interface?

Getprogname() and setprogname()?

Bastien

Le 23 déc. 2010 18:19, "Bruce Korb"  a écrit :

On 12/23/10 06:52, Eric Blake wrote:
> Unfortunately, it is not possible to pass fds on cygwin; it i...
It is slightly more complicated than that:  The *at gnulib modules
need to not drag in gnulib modules that have an extended interface
requirement.  viz. a call to set_program_name().

As has been pointed out in this thread, there are lots of end-case
issues that need resolution for a perfect implementation.
An "adequate" implementation needs to not seg fault during
an attempt to print an informative message.  That can be handled
by either not necessarily calling error() on an error, or by
changing error() to not require that program_name be set.

When I get back from my Christmas weekend, I propose fiddling the
code the least invasive way possible for libposix and let the
Perfect Implementation come later.  I'd rather to rework than
stall around any more.


Re: RE : Re: openat, failing fchdir

2010-12-23 Thread Eric Blake
On 12/23/2010 10:44 AM, Bastien ROUCARIES wrote:

Bastien, can you please convince your mailer to preserve threading?  Thanks.

> For cygwin and windows plateform see ntcreatefile that allow to open an
> handle relativly to another handle

Yes, cygwin's already using that.  Whether it makes sense to teach
gnulib how to use it for the mingw implementation of *at is a different
question.

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



signature.asc
Description: OpenPGP digital signature


Re: openat, failing fchdir

2010-12-23 Thread Bastien ROUCARIES
Le jeudi 23 décembre 2010 18:58:37, vous avez écrit :
> On 12/23/2010 10:44 AM, Bastien ROUCARIES wrote:
> 
> Bastien, can you please convince your mailer to preserve threading? 
(sorry was on a long day train run and could only use the crappy android client)

> > For cygwin and windows plateform see ntcreatefile that allow to open an
> > handle relativly to another handle
> 
> Yes, cygwin's already using that.  Whether it makes sense to teach
> gnulib how to use it for the mingw implementation of *at is a different
> question.
We already use  _get_osfhandle for poll emulation, for lseek and a lot of other 
function. 
I believe it is a good alternative and the code will not be too hard to follow

Bastien



Re: RE : Re: error and program_name

2010-12-23 Thread Paul Eggert
On 12/23/2010 06:13 AM, Jim Meyering wrote:
> Starting a daemon...
> Yes, that sounds challenging.

We'd have to start a new daemon for each directory, right?
So we'd need a hash table mapping directory FDs to info about
each daemon.

There's also the issue of signal safety, which we'd need to
think about regardless of whether we use a daemon.

I dunno, this solution initially sounds nice (it had already
occurred to me before this discussion), but given that we're
only talking about systems with low-quality libraries, and
given that any solution will be pretty hard to test, I'm
inclined to think that going with subprocesses would be more
trouble than it's worth.



Re: error and program_name

2010-12-23 Thread Bastien ROUCARIES
Le jeudi 23 décembre 2010 19:56:38, Paul Eggert a écrit :
> On 12/23/2010 06:13 AM, Jim Meyering wrote:

> inclined to think that going with subprocesses would be more
> trouble than it's worth.
So be simple, for each openat fork and pass fd to parent process. 

Bastien



Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9

2010-12-23 Thread Paul Eggert
On 12/22/2010 03:25 PM, Paul Eggert wrote:

> Thanks for the review and these are all good suggestions; I'll
> look into them.

Following up my own email -- I pushed this:

>From a80e645dd8bb8bc1bfdce5a2805cbfd37567 Mon Sep 17 00:00:00 2001
From: Paul Eggert 
Date: Thu, 23 Dec 2010 23:32:55 -0800
Subject: [PATCH] vsnprintf: make more consistent with snprintf; doc fixes

* doc/posix-functions/snprintf.texi (snprintf): The workaround for
the byte count return problem was promoted from the snprintf-posix
to the snprintf module.
* doc/posix-functions/vsnprintf.texi (vsnprintf): Likewise.
* m4/vsnprintf.m4 (gl_FUNC_VSNPRINTF): Also check
gl_SNPRINTF_RETVAL_C99, for consistency with gl_FUNC_SNPRINTF.
* tests/test-snprintf.c (main): Check the byte count returned.
* tests/test-vsnprintf.c (main): Likewise.
---
 ChangeLog  |   13 +
 doc/posix-functions/snprintf.texi  |6 +++---
 doc/posix-functions/vsnprintf.texi |6 +++---
 m4/vsnprintf.m4|7 ++-
 tests/test-snprintf.c  |8 
 tests/test-vsnprintf.c |8 
 6 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 128931a..f53bcb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-12-23  Paul Eggert  
+
+   vsnprintf: make more consistent with snprintf; doc fixes
+
+   * doc/posix-functions/snprintf.texi (snprintf): The workaround for
+   the byte count return problem was promoted from the snprintf-posix
+   to the snprintf module.
+   * doc/posix-functions/vsnprintf.texi (vsnprintf): Likewise.
+   * m4/vsnprintf.m4 (gl_FUNC_VSNPRINTF): Also check
+   gl_SNPRINTF_RETVAL_C99, for consistency with gl_FUNC_SNPRINTF.
+   * tests/test-snprintf.c (main): Check the byte count returned.
+   * tests/test-vsnprintf.c (main): Likewise.
+
 2010-12-23  Eric Blake  
 
sigpipe: relax to LGPLv2+, since it did not have any LGPLv3+ parts
diff --git a/doc/posix-functions/snprintf.texi 
b/doc/posix-functions/snprintf.texi
index 23fa5e7..5d19ccf 100644
--- a/doc/posix-functions/snprintf.texi
+++ b/doc/posix-functions/snprintf.texi
@@ -12,6 +12,9 @@ Portability problems fixed by either Gnulib module 
@code{snprintf} or @code{snpr
 This function is missing on some platforms:
 IRIX 5.3, OSF/1 4.0, Solaris 2.5.1.
 @item
+This function does not return a byte count as specified in C99 on some 
platforms:
+HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw.
+...@item
 This function overwrites memory even when a size argument of 1 is passed on 
some
 platforms:
 Linux libc5.
@@ -72,9 +75,6 @@ MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 This function does not truncate the result as specified in C99 on some 
platforms:
 mingw.
 @item
-This function does not return a byte count as specified in C99 on some 
platforms:
-HP-UX 11, IRIX 6.5, OSF/1 5.1, mingw.
-...@item
 This function does not fully support the @samp{n} directive on some platforms:
 HP-UX 11, mingw.
 @item
diff --git a/doc/posix-functions/vsnprintf.texi 
b/doc/posix-functions/vsnprintf.texi
index 8f6d903..38266a0 100644
--- a/doc/posix-functions/vsnprintf.texi
+++ b/doc/posix-functions/vsnprintf.texi
@@ -15,6 +15,9 @@ IRIX 5.3, OSF/1 4.0, Solaris 2.5.1.
 This function overwrites memory even when a size argument of 1 is passed on 
some
 platforms:
 Linux libc5.
+...@item
+This function does not return a byte count as specified in C99 on some 
platforms:
+HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, mingw.
 @end itemize
 
 Portability problems fixed by Gnulib module @code{vsnprintf-posix}:
@@ -72,9 +75,6 @@ MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 This function does not truncate the result as specified in C99 on some 
platforms:
 mingw.
 @item
-This function does not return a byte count as specified in C99 on some 
platforms:
-HP-UX 11, IRIX 6.5, OSF/1 5.1, mingw.
-...@item
 This function does not fully support the @samp{n} directive on some platforms:
 HP-UX 11, mingw.
 @item
diff --git a/m4/vsnprintf.m4 b/m4/vsnprintf.m4
index ed189c2..17109a7 100644
--- a/m4/vsnprintf.m4
+++ b/m4/vsnprintf.m4
@@ -13,7 +13,12 @@ AC_DEFUN([gl_FUNC_VSNPRINTF],
 gl_SNPRINTF_SIZE1
 case "$gl_cv_func_snprintf_size1" in
   *yes)
-gl_cv_func_vsnprintf_usable=yes
+gl_SNPRINTF_RETVAL_C99
+case "$gl_cv_func_snprintf_retval_c99" in
+  *yes)
+gl_cv_func_vsnprintf_usable=yes
+;;
+esac
 ;;
 esac
   fi
diff --git a/tests/test-snprintf.c b/tests/test-snprintf.c
index 62a411b..e408d48 100644
--- a/tests/test-snprintf.c
+++ b/tests/test-snprintf.c
@@ -34,15 +34,16 @@ main (int argc, char *argv[])
   int size;
   int retval;
 
+  retval = snprintf (NULL, 0, "%d", 12345);
+  ASSERT (retval == 5);
+
   for (size = 0; size <= 8; size++)
 {
   memcpy (buf, "DEADBEEF", 8);
   retval = snprintf (buf, size, "%d", 12345);
+  ASSERT (retval == 5);
   if (size < 6)
 {
-#if