[RFT/RFH] porting the poll module to win32

2008-08-18 Thread Paolo Bonzini

Hi,

a while ago a user of GNU Smalltalk contributed code to run the 
emulation of poll in gnulib under Win32.  The code was a little hackish, 
as it worked by emulating other POSIX system calls "as well as it was 
needed" to emulate poll; so I never contributed it to gnulib.


Now, however, I merged that code with the gnulib poll.c in order to 
obtain a native poll emulation for Win32 (MinGW).  It supports sockets, 
console handles, and disk files.  Adding named pipes would not be hard, 
and can be done later.


However, I don't have any way to test it.  It might not even compile, in 
fact.  Can anybody help?


Thanks,

Paolo
2008-08-18  Paolo Bonzini  <[EMAIL PROTECTED]>

* lib/poll.c (win32_compute_revents, win32_compute_revents_socket): New.
(compute_revents): Extract out of poll.
(poll): Add Win32 implementation for MinGW.

diff --git a/lib/poll.c b/lib/poll.c
index 4a62dc1..888757c 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -25,9 +25,18 @@
 #include "poll.h"
 #include 
 #include 
+
+#ifdef __MSVCRT__
+#include 
+#include 
+#include 
+#include 
+#include 
+#else
 #include 
 #include 
 #include 
+#endif
 
 #ifdef HAVE_SYS_IOCTL_H
 #include 
@@ -48,12 +57,144 @@
 #define MSG_PEEK 0
 #endif
 
+#ifdef __MSVCRT__
+/* Compute revents values for file handle H.  */
+
+static int
+win32_compute_revents (HANDLE h, int sought)
+{
+  int i, ret;
+  INPUT_RECORD *irbuffer;
+  DWORD nevents, nbuffer;
+
+  ret = WaitForSingleObject (h, 0);
+  if (ret != WAIT_OBJECT_0)
+return sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
+
+  if (GetFileType (h) != FILE_TYPE_CHAR)
+return sought & ~(POLLPRI | POLLRDBAND);
+
+  nbuffer = nevents = 0;
+  bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
+  if (!bRet || nbuffer == 0)
+return POLLHUP;
+
+  irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
+  bRet = PeekConsoleInput (h, irbuffer, nbuffer, &nevents);
+  if (!bRet || nevents == 0)
+return POLLHUP;
+
+  for (i = 0; i < nevents; i++)
+if (irbuffer[i].EventType == KEY_EVENT)
+  return sought & ~(POLLPRI | POLLRDBAND);
+
+  return sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
+}
+
+/* Convert fd_sets returned by select into revents values.  */
+
+static int
+win32_compute_revents_socket (SOCKET h, int sought,
+  fd_set *rfds, fd_set *wfds, fd_set *efds)
+{
+  int happened = 0;
+
+  if (FD_ISSET (h, rfds))
+{
+  int r, error;
+
+  char data[64];
+  WSASetLastError (0);
+  r = recv (h, data, sizeof (data), MSG_PEEK);
+  error = WSAGetLastError ();
+  WSASetLastError (0);
+
+  if (r == 0)
+happened |= POLLHUP;
+
+  /* If the event happened on an unconnected server socket,
+ that's fine. */
+  else if (r > 0 || ( /* (r == -1) && */ error == ENOTCONN))
+happened |= (POLLIN | POLLRDNORM) & sought;
+
+  /* Distinguish hung-up sockets from other errors.  */
+  else if (error == WSAESHUTDOWN || error == WSAECONNRESET
+   || error == WSAECONNABORTED || error == WSAENETRESET)
+happened |= POLLHUP;
+
+  else
+happened |= POLLERR;
+}
+
+  if (FD_ISSET (h, wfds))
+happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
+
+  if (FD_ISSET (h, efds))
+happened |= (POLLPRI | POLLRDBAND) & sought;
+
+  return happened;
+}
+
+#else /* !MinGW */
+
+/* Convert select(2) returned fd_sets into poll(2) revents values.  */
+static int
+compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds)
+{
+  int happened;
+  if (FD_ISSET (fd, rfds))
+{
+  int r;
+  int socket_errno;
+
+#if defined __MACH__ && defined __APPLE__
+  /* There is a bug in Mac OS X that causes it to ignore MSG_PEEK
+ for some kinds of descriptors.  Detect if this descriptor is a
+ connected socket, a server socket, or something else using a
+ 0-byte recv, and use ioctl(2) to detect POLLHUP.  */
+  r = recv (fd, NULL, 0, MSG_PEEK);
+  socket_errno = (r < 0) ? errno : 0;
+  if (r == 0 || socket_errno == ENOTSOCK)
+   ioctl (fd, FIONREAD, &r);
+#else
+  char data[64];
+  r = recv (fd, data, sizeof (data), MSG_PEEK);
+  socket_errno = (r < 0) ? errno : 0;
+#endif
+  if (r == 0)
+   happened |= POLLHUP;
+
+  /* If the event happened on an unconnected server socket,
+ that's fine. */
+  else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))
+   happened |= (POLLIN | POLLRDNORM) & sought;
+
+  /* Distinguish hung-up sockets from other errors.  */
+  else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET
+  || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
+   happened |= POLLHUP;
+
+  else
+   happened |= POLLERR;
+}
+
+  if (FD_ISSET (fd, wfds))
+happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
+
+  if (FD_ISSET (fd, efds))
+happened |= (POLLPRI | POLLRDBAND) & sought;
+
+  ret

Re: how to use module `stdlib'

2008-08-18 Thread Simon Josefsson
Thien-Thi Nguyen <[EMAIL PROTECTED]> writes:

> I just did:
>   $ gnulib-tool --import stdlib
>
> Now i see in stdlib_h.m4 the definition:
>   AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], ...)
>
> Some questions on how to properly use this module:
>
>   - What do i need to do wrt `gl_STDLIB_MODULE_INDICATOR'?

Nothing beyond what is normally required to use gnulib: i.e., invoke
gl_EARLY, gl_INIT and so on (all is explained in the last output from
gnulib-tool).

>   - Is it enough to
> - add to configure.in
> gl_STDLIB_H

No, add gl_EARLY and gl_INIT instead.  They are in gnulib-*.m4, which
should be generated by gnulib-tool.  They set up the gnulib modules
properly, and will invoke gl_STDLIB_H if necessary.

Generally, see the chapter 'Invoking gnulib-tool' in the gnulib manual.

> - convert the implementation file construct from:
> #ifdef STDC_HEADERS
> # include 
> ...
> #endif
>   to:
> #include 
> #ifdef STDC_HEADERS
> ...
> #endif
>   (that is, move the #include  to top-level,
>   without any surrounding preprocessor conditionals)?

Yes.

>   - Is it wise to remove `AC_HEADER_STDC' from configure.in?

In all of my projects, I assume standard C header files exists and never
had any reports of problems.  However, if your project is special and
needs to build on systems that doesn't have proper compilers and
libraries, you may want to use it.  My understanding is that this is
something of an autoconf antiquity.

Of course, if you remove AC_HEADER_STDC you should remove the
STDC_HEADERS checks as well.

/Simon




Re: [RFT/RFH] porting the poll module to win32

2008-08-18 Thread Simon Josefsson
Paolo Bonzini <[EMAIL PROTECTED]> writes:

> Hi,
>
> a while ago a user of GNU Smalltalk contributed code to run the
> emulation of poll in gnulib under Win32.  The code was a little
> hackish, as it worked by emulating other POSIX system calls "as well
> as it was needed" to emulate poll; so I never contributed it to
> gnulib.
>
> Now, however, I merged that code with the gnulib poll.c in order to
> obtain a native poll emulation for Win32 (MinGW).  It supports
> sockets, console handles, and disk files.  Adding named pipes would
> not be hard, and can be done later.
>
> However, I don't have any way to test it.  It might not even compile,
> in fact.  Can anybody help?

Cool!  GnuTLS's command-line tools (gnutls-cli and gnutls-serv) uses
select() which doesn't exists under Windows, and we've used a
replacement-hack as well:

http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=blob;f=src/select.c;hb=HEAD

I'd like to depend on a gnulib module instead.

GnuTLS uses select to read from one socket and to read from
fileno(stdin).  You say "console handles" above, but does that mean
stdin?  If you believe I should be able to modify the code to use poll
instead of select, and to use your module successfully for mingw32, I
could give it a try.

/Simon




Re: new module 'threadlib'

2008-08-18 Thread Bruno Haible
> 2008-08-17  Bruno Haible  <[EMAIL PROTECTED]>
> 
>   New module 'threadlib'.

Small fix:

2008-08-18  Bruno Haible  <[EMAIL PROTECTED]>

* lib/glthread/threadlib.c: Include .

*** lib/glthread/threadlib.c.orig   2008-08-18 12:35:16.0 +0200
--- lib/glthread/threadlib.c2008-08-18 11:59:48.0 +0200
***
*** 25,30 
--- 25,32 
  
  /* Use the POSIX threads library.  */
  
+ # include 
+ 
  # if PTHREAD_IN_USE_DETECTION_HARD
  
  /* The function to be executed by a dummy thread.  */





Re: checkin of glthread/glcond modules

2008-08-18 Thread Bruno Haible
One more change in the 'thread' module (fixes a link error):

2008-08-18  Bruno Haible  <[EMAIL PROTECTED]>

* lib/glthread/thread.h [USE_SOLARIS_THREADS]: Use thread_in_use(), not
pthread_in_use().

*** lib/glthread/thread.h.orig  2008-08-18 12:35:16.0 +0200
--- lib/glthread/thread.h   2008-08-18 12:25:15.0 +0200
***
*** 250,262 
  # define glthread_create(THREADP, FUNC, ARG) \
  (thread_in_use () ? thr_create (NULL, 0, FUNC, ARG, 0, THREADP) : 0)
  # define glthread_sigmask(HOW, SET, OSET) \
! (pthread_in_use () ? sigprocmask (HOW, SET, OSET) : 0)
  # define glthread_join(THREAD, RETVALP) \
! (pthread_in_use () ? thr_join (THREAD, NULL, RETVALP) : 0)
  # define gl_thread_self() \
! (pthread_in_use () ? (void *) thr_self () : 0)
  # define gl_thread_exit(RETVAL) \
! (pthread_in_use () ? thr_exit (RETVAL) : 0)
  # define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
  
  # ifdef __cplusplus
--- 250,262 
  # define glthread_create(THREADP, FUNC, ARG) \
  (thread_in_use () ? thr_create (NULL, 0, FUNC, ARG, 0, THREADP) : 0)
  # define glthread_sigmask(HOW, SET, OSET) \
! (thread_in_use () ? sigprocmask (HOW, SET, OSET) : 0)
  # define glthread_join(THREAD, RETVALP) \
! (thread_in_use () ? thr_join (THREAD, NULL, RETVALP) : 0)
  # define gl_thread_self() \
! (thread_in_use () ? (void *) thr_self () : 0)
  # define gl_thread_exit(RETVAL) \
! (thread_in_use () ? thr_exit (RETVAL) : 0)
  # define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
  
  # ifdef __cplusplus





Re: gnulib manual

2008-08-18 Thread Bruno Haible
Simon Josefsson wrote:
> Generally, see the chapter 'Invoking gnulib-tool' in the gnulib manual.

Note that a copy of the gnulib manual is online at
  http://www.gnu.org/software/gnulib/manual/

Bruno





Re: Lock module improvement

2008-08-18 Thread Bruno Haible
Another fix:

2008-08-18  Bruno Haible  <[EMAIL PROTECTED]>

* lib/glthread/lock.h [USE_SOLARIS_THREADS]: Fix
glthread_recursive_lock_* macros.
* lib/glthread/lock.c (glthread_recursive_lock_destroy_multithreaded):
Fix syntax error.

*** lib/glthread/lock.h.orig2008-08-18 12:35:16.0 +0200
--- lib/glthread/lock.h 2008-08-18 12:21:00.0 +0200
***
*** 577,609 
  # define gl_recursive_lock_initializer \
  { DEFAULTMUTEX, (thread_t) 0, 0 }
  # define glthread_recursive_lock_init(LOCK) \
! do  \
!   { \
! if (thread_in_use ())   \
!   glthread_recursive_lock_init_multithreaded (LOCK); \
!   } \
! while (0)
  # define glthread_recursive_lock_lock(LOCK) \
! do  \
!   { \
! if (thread_in_use ())   \
!   glthread_recursive_lock_lock_multithreaded (LOCK); \
!   } \
! while (0)
  # define glthread_recursive_lock_unlock(LOCK) \
! do\
!   {   \
! if (thread_in_use ()) \
!   glthread_recursive_lock_unlock_multithreaded (LOCK); \
!   }   \
! while (0)
  # define glthread_recursive_lock_destroy(LOCK) \
! do \
!   {\
! if (thread_in_use ())  \
!   glthread_recursive_lock_destroy_multithreaded (LOCK); \
!   }\
! while (0)
  extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t 
*lock);
  extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t 
*lock);
  extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t 
*lock);
--- 577,589 
  # define gl_recursive_lock_initializer \
  { DEFAULTMUTEX, (thread_t) 0, 0 }
  # define glthread_recursive_lock_init(LOCK) \
! (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
  # define glthread_recursive_lock_lock(LOCK) \
! (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
  # define glthread_recursive_lock_unlock(LOCK) \
! (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 
0)
  # define glthread_recursive_lock_destroy(LOCK) \
! (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) 
: 0)
  extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t 
*lock);
  extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t 
*lock);
  extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t 
*lock);
*** lib/glthread/lock.c.orig2008-08-18 12:35:16.0 +0200
--- lib/glthread/lock.c 2008-08-18 12:04:59.0 +0200
***
*** 445,451 
  {
if (lock->owner != (pthread_t) 0)
  return EBUSY;
!   return (pthread_mutex_destroy (&lock->mutex);
  }
  
  # endif
--- 445,451 
  {
if (lock->owner != (pthread_t) 0)
  return EBUSY;
!   return pthread_mutex_destroy (&lock->mutex);
  }
  
  # endif





Re: [RFT/RFH] porting the poll module to win32

2008-08-18 Thread Paolo Bonzini

If you believe I should be able to modify the code to use poll
instead of select,


That's for sure.  I attach an example of a bidirectional I/O loop using 
poll.



and to use your module successfully for mingw32, I
could give it a try.


Yes, stdin from the console is a console handle.

The attached patch also works for pipes (if it compiles :-), since I saw 
you needed that functionality in gnutls.


Paolo

#include 
#include 
#include 
#include 
#include 

#define BUF_SIZE8192

int
socket_loop (int sock_fd)
{
  char buf_stdin[BUF_SIZE]; /* data buffers */
  char buf_socket[BUF_SIZE];

  char *out_p = buf_stdin, *in_p = buf_socket;
  unsigned int outgoing = 0;
  unsigned int incoming = 0;

  struct pollfd pfd[3];
  int rc;

  /* Setup pollfd structs... */
  pfd[0].fd = sock_fd;
  pfd[0].events = POLLIN | POLLOUT;
  pfd[1].fd = 0;
  pfd[1].events = POLLIN;
  pfd[2].fd = 1;
  pfd[2].events = POLLOUT;

  /* Use nonblocking I/O.  */
  fcntl (0, F_SETFL, fcntl (0, F_GETFL, NULL) | O_NONBLOCK);
  fcntl (1, F_SETFL, fcntl (1, F_GETFL, NULL) | O_NONBLOCK);
  fcntl (sock_fd, F_SETFL, fcntl (sock_fd, F_GETFL, NULL) | O_NONBLOCK);

  while (1)
{
  pfd[0].revents = 0;
  pfd[1].revents = 0;

  rc = poll (pfd, 2, -1);
  if (rc < 0 && errno == EINTR)
continue;

  /* Always check for errors */
  if (rc < 0)
break;

  /* Try to read if there is no pending output... */
  if (!outgoing && (pfd[1].revents & (POLLIN | POLLERR)) == POLLIN)
outgoing = read (0, buf_stdin, BUF_SIZE);

  /* If there was an error, or if we did not read anything, shut down this
 side of the socket.  After this happens, pfd[1].revents will always
 be zero.  */
  if (!outgoing && (pfd[1].revents & (POLLIN | POLLERR | POLLHUP)))
{
  pfd[1].fd = -1;
  shutdown (sock_fd, SHUT_WR);
}

  /* Try to read if there is no pending output... */
  if (!incoming && (pfd[0].revents & (POLLIN | POLLERR)) == POLLIN)
incoming = read (sock_fd, buf_socket, BUF_SIZE);

  /* If there was an error, or if we did not read anything, quit.  */
  if (!incoming && (pfd[0].revents & (POLLIN | POLLERR | POLLHUP)))
break;

  if (incoming)
{
  rc = write (1, in_p, incoming);
  if (rc < 0)
break;

  incoming -= rc;
  in_p = incoming ? in_p + rc : buf_socket;
}

  if (outgoing)
{
  /* Write one line, or the whole buffer */
  rc = write (sock_fd, out_p, outgoing);
  if (rc < 0)
break;

  outgoing -= rc;
  out_p = outgoing ? out_p + rc : buf_stdin;
}
}

  /* Now close it.  */
  return (rc < 0) ? -1 : 0;
}
diff --git a/lib/poll.c b/lib/poll.c
index 4a62dc1..ffa6ab0 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -25,9 +25,18 @@
 #include "poll.h"
 #include 
 #include 
+
+#ifdef __MSVCRT__
+#include 
+#include 
+#include 
+#include 
+#include 
+#else
 #include 
 #include 
 #include 
+#endif
 
 #ifdef HAVE_SYS_IOCTL_H
 #include 
@@ -48,12 +57,215 @@
 #define MSG_PEEK 0
 #endif
 
+#ifdef __MSVCRT__
+
+/* Declare data structures for ntdll functions.  */
+typedef struct _FILE_PIPE_LOCAL_INFORMATION {
+  ULONG NamedPipeType;
+  ULONG NamedPipeConfiguration;
+  ULONG MaximumInstances;
+  ULONG CurrentInstances;
+  ULONG InboundQuota;
+  ULONG ReadDataAvailable;
+  ULONG OutboundQuota;
+  ULONG WriteQuotaAvailable;
+  ULONG NamedPipeState;
+  ULONG NamedPipeEnd;
+} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
+
+typedef struct _IO_STATUS_BLOCK
+{
+  union u {
+NTSTATUS Status;
+PVOID Pointer;
+  };
+  ULONG_PTR Information;
+} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
+
+#define FilePipeLocalInformation 24
+
+typedef NTSTATUS (NTAPI *PNtQueryInformationFile)
+(HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
+
+#ifndef PIPE_BUF
+#define PIPE_BUF   512
+#endif
+
+/* Compute revents values for file handle H.  */
+
+static int
+win32_compute_revents (HANDLE h, int sought)
+{
+  int i, ret, happened;
+  INPUT_RECORD *irbuffer;
+  DWORD avail, nbuffer;
+  IO_STATUS_BLOCK iosb;
+  FILE_PIPE_LOCAL_INFORMATION fpli;
+  static PNtQueryInformationFile NtQueryInformationFile;
+
+  ret = WaitForSingleObject (h, 0);
+  if (ret != WAIT_OBJECT_0)
+return sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
+
+  switch (GetFileType (h))
+{
+case FILE_TYPE_PIPE:
+  if (!NtQueryInformationFile)
+   NtQueryInformationFile = (PNtQueryInformationFile)
+ GetProcAddress (GetModuleHandle ("ntdll.dll"),
+ "NtQueryInformationFile");
+
+  happened = 0;
+  if (!PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL))
+   return POLLERR;
+
+  if (avail)
+   happened |= sought & (POLLIN | POLLRDNORM);
+
+  memset (&iosb, 0, sizeof (iosb));
+  memset (&fpli, 0, sizeof (fpli));
+
+  /* If NtQueryInformationFile fails, opt

[RFE] function to read a file descriptor

2008-08-18 Thread Debarshi Ray
I was wondering whether gnulib has a function to safely read or recv
from a file desctiptor. I could not find one, and have had to hack
them up on numerous occasions. Here is one such version I wrote while
implementing a feature for GNU Inetutils:

size_t
recvbuf (int sockfd, void **buffer, size_t *size)
{
  size_t count = 0;
  size_t nread;

  if (*buffer == NULL)
*size = BUFSIZ;

  for (;;)
{
  *buffer = realloc (*buffer, *size);
  nread = recv (sockfd, *buffer + count, BUFSIZ, 0);

  if (nread == -1)
error (EXIT_FAILURE, errno, "recv");

  count += nread;

  if (nread < BUFSIZ)
break;
  else
*size += BUFSIZ;
}

  return count;
}

Comments?

Happy hacking,
Debarshi




Re: Lock module improvement

2008-08-18 Thread Yoann Vandoorselaere
Hi Bruno,

Le lundi 18 août 2008 à 12:55 +0200, Bruno Haible a écrit :
> Another fix:

Here is another patch on top of current GnuLib HEAD:
- Make use of the thread module in lock-test
- Include missing cond unit-test.
- Isolate thread specific CPP flags into THREADCPPFLAGS (this is useful
for a library to propagate threads specific CPPFLAGS).

Regards,


-- 
Yoann Vandoorselaere <[EMAIL PROTECTED]>
diff --git a/m4/threadlib.m4 b/m4/threadlib.m4
index 3a8655e..399ac62 100644
--- a/m4/threadlib.m4
+++ b/m4/threadlib.m4
@@ -71,16 +71,18 @@ AC_HELP_STRING([--disable-threads], [build without multithread safety]),
 # 2. putting a flag into CPPFLAGS that has an effect on the linker
 # causes the AC_TRY_LINK test below to succeed unexpectedly,
 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
-CPPFLAGS="$CPPFLAGS -D_REENTRANT"
+THREADCPPFLAGS="-D_REENTRANT"
 ;;
 esac
 # Some systems optimize for single-threaded programs by default, and
 # need special flags to disable these optimizations. For example, the
 # definition of 'errno' in .
 case "$host_os" in
-  aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
-  solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
+  aix* | freebsd*) THREADCPPFLAGS="-D_THREAD_SAFE" ;;
+  solaris*) THREADCPPFLAGS="-D_REENTRANT" ;;
 esac
+CPPFLAGS="$CPPFLAGS $THREADCPPFLAGS"
+AC_SUBST(THREADCPPFLAGS)
   fi
 ])
 
diff --git a/modules/cond-tests b/modules/cond-tests
new file mode 100644
index 000..d262d9e
--- /dev/null
+++ b/modules/cond-tests
@@ -0,0 +1,11 @@
+Files:
+tests/test-cond.c
+
+Depends-on:
+thread
+yield
+
+Makefile.am:
+TESTS += test-cond
+check_PROGRAMS += test-cond
+test_cond_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
diff --git a/modules/lock-tests b/modules/lock-tests
index 7c72c94..21e2c98 100644
--- a/modules/lock-tests
+++ b/modules/lock-tests
@@ -2,20 +2,10 @@ Files:
 tests/test-lock.c
 
 Depends-on:
-
-configure.ac:
-dnl Checks for special libraries for the tests/test-lock test.
-dnl On some systems, sched_yield is in librt, rather than in libpthread.
-LIBSCHED=
-if test $gl_threads_api = posix; then
-  dnl Solaris has sched_yield in librt, not in libpthread or libc.
-  AC_CHECK_LIB(rt, sched_yield, [LIBSCHED=-lrt],
-[dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
- AC_CHECK_LIB(posix4, sched_yield, [LIBSCHED=-lposix4])])
-fi
-AC_SUBST([LIBSCHED])
+thread
+yield
 
 Makefile.am:
 TESTS += test-lock
 check_PROGRAMS += test-lock
-test_lock_LDADD = $(LDADD) @LIBMULTITHREAD@ @LIBSCHED@
+test_lock_LDADD = $(LDADD) @LIBMULTITHREAD@ @YIELD_LIB@
diff --git a/tests/test-cond.c b/tests/test-cond.c
new file mode 100644
index 000..ac77158
--- /dev/null
+++ b/tests/test-cond.c
@@ -0,0 +1,211 @@
+/* Test of locking in multithreaded situations.
+   Copyright (C) 2005 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
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see .  */
+
+#include 
+
+#if USE_POSIX_THREADS || USE_SOLARIS_THREADS || USE_PTH_THREADS || USE_WIN32_THREADS
+
+/* Whether to enable locking.
+   Uncomment this to get a test program without locking, to verify that
+   it crashes.  */
+#define ENABLE_LOCKING 1
+
+/* Which tests to perform.
+   Uncomment some of these, to verify that all tests crash if no locking
+   is enabled.  */
+#define DO_TEST_COND 1
+#define DO_TEST_TIMEDCOND 1
+
+
+/* Whether to help the scheduler through explicit yield().
+   Uncomment this to see if the operating system has a fair scheduler.  */
+#define EXPLICIT_YIELD 1
+
+/* Whether to print debugging messages.  */
+#define ENABLE_DEBUGGING 0
+
+#include 
+#include 
+#include 
+
+#if !ENABLE_LOCKING
+# undef USE_POSIX_THREADS
+# undef USE_SOLARIS_THREADS
+# undef USE_PTH_THREADS
+# undef USE_WIN32_THREADS
+#endif
+
+#include "glthread/thread.h"
+#include "glthread/cond.h"
+#include "glthread/lock.h"
+#include "glthread/yield.h"
+
+#if ENABLE_DEBUGGING
+# define dbgprintf printf
+#else
+# define dbgprintf if (0) printf
+#endif
+
+#if EXPLICIT_YIELD
+# define yield() gl_thread_yield ()
+#else
+# define yield()
+#endif
+
+
+/*
+ * Condition check
+ */
+#include 
+static int cond_value = 0;
+static gl_cond_t condtest = gl_cond_initializer;
+static gl_lock_t lockcond = gl_lock_initializer;
+
+static void *
+cond_routine(void *arg)
+{
+  gl_lock_lock(lockcond);
+  while ( ! cond_value ) {
+

autobuild.m4 time zone fix

2008-08-18 Thread Simon Josefsson
Pushed.

/Simon

>From 9fa188508ca3951b0fd6c04dfeefff5a622fe38a Mon Sep 17 00:00:00 2001
From: Simon Josefsson <[EMAIL PROTECTED]>
Date: Mon, 18 Aug 2008 19:40:11 +0200
Subject: [PATCH] autobuild.m4: Use TZ=UTC to avoid time zone complexity.

---
 ChangeLog   |4 
 m4/autobuild.m4 |6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 84978c0..57e3cfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-08-18  Simon Josefsson  <[EMAIL PROTECTED]>
+
+   * m4/autobuild.m4: Use TZ=UTC to avoid time zone complexity.
+
 2008-08-18  Bruno Haible  <[EMAIL PROTECTED]>
 
* lib/glthread/thread.h [USE_SOLARIS_THREADS]: Use thread_in_use(), not
diff --git a/m4/autobuild.m4 b/m4/autobuild.m4
index 70505c6..f0d00a0 100644
--- a/m4/autobuild.m4
+++ b/m4/autobuild.m4
@@ -1,5 +1,5 @@
-# autobuild.m4 serial 5
-dnl Copyright (C) 2004, 2006, 2007 Free Software Foundation, Inc.
+# autobuild.m4 serial 6
+dnl Copyright (C) 2004, 2006, 2007, 2008 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.
@@ -29,7 +29,7 @@ AC_DEFUN([AB_INIT],
 
   ifelse([$1],[],,[AC_MSG_NOTICE([autobuild mode... $1])])
 
-  date=`date +%Y%m%d-%H%M%S`
+  date=`TZ=UTC date +%Y%m%d-%H%M%S`
   if test "$?" != 0; then
 date=`date`
   fi
-- 
1.5.6.3





Re: autobuild.m4 time zone fix

2008-08-18 Thread Simon Josefsson
Simon Josefsson <[EMAIL PROTECTED]> writes:

> Pushed.

This one too.

/Simon

>From e8ce1f16994aebc497cb91159149ec33baeadfe8 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <[EMAIL PROTECTED]>
Date: Mon, 18 Aug 2008 19:47:23 +0200
Subject: [PATCH] Use ISO 8601 format.  Attribution.

---
 ChangeLog   |3 ++-
 m4/autobuild.m4 |4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 57e3cfb..a09e688 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-08-18  Simon Josefsson  <[EMAIL PROTECTED]>
 
-   * m4/autobuild.m4: Use TZ=UTC to avoid time zone complexity.
+   * m4/autobuild.m4: Use TZ=UTC to avoid time zone complexity.  Use
+   ISO 8601 format.  Suggested by Greg Troxel <[EMAIL PROTECTED]>.
 
 2008-08-18  Bruno Haible  <[EMAIL PROTECTED]>
 
diff --git a/m4/autobuild.m4 b/m4/autobuild.m4
index f0d00a0..ccd9b5c 100644
--- a/m4/autobuild.m4
+++ b/m4/autobuild.m4
@@ -1,4 +1,4 @@
-# autobuild.m4 serial 6
+# autobuild.m4 serial 7
 dnl Copyright (C) 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -29,7 +29,7 @@ AC_DEFUN([AB_INIT],
 
   ifelse([$1],[],,[AC_MSG_NOTICE([autobuild mode... $1])])
 
-  date=`TZ=UTC date +%Y%m%d-%H%M%S`
+  date=`TZ=UTC date +%Y%m%dT%H%M%SZ`
   if test "$?" != 0; then
 date=`date`
   fi
-- 
1.5.6.3





Re: [RFE] function to read a file descriptor

2008-08-18 Thread Bruno Haible
Debarshi Ray wrote:
> I was wondering whether gnulib has a function to safely read or recv
> from a file desctiptor.

How about using the 'read-file' module, passing it a FILE stream created with
fdopen()?

Bruno





Re: [RFT/RFH] porting the poll module to win32

2008-08-18 Thread Simon Josefsson
Hi Paolo.  I'm trying to use your poll replacement.  I have rewritten
gnutls-cli to use poll, and it works fine under debian.  However,
building under mingw32 fails.  With your original patch I get compile
errors.

What do you think about writing a gnulib self-test that tests whether
poll works correctly?  It would help to test the replacement function on
various platforms quicker, and also helps catch regression.  I suspect
writing a self test may be somewhat complicated though, you'll need to
setup at least two sockets, poll them, and read/write from/to them a
couple of times.

Alas, I have little time to develop this right now, but can test things
if you work on it.

Initial patch:

../../../src/gnutls-2.5.4/gl/poll.c: In function 'win32_compute_revents':
../../../src/gnutls-2.5.4/gl/poll.c:78: error: 'bRet' undeclared (first use in 
this function)
../../../src/gnutls-2.5.4/gl/poll.c:78: error: (Each undeclared identifier is 
reported only once
../../../src/gnutls-2.5.4/gl/poll.c:78: error: for each function it appears in.)
../../../src/gnutls-2.5.4/gl/poll.c:82: warning: implicit declaration of 
function 'alloca'
../../../src/gnutls-2.5.4/gl/poll.c:82: warning: incompatible implicit 
declaration of built-in function 'alloca'
../../../src/gnutls-2.5.4/gl/poll.c: In function 'win32_compute_revents_socket':
../../../src/gnutls-2.5.4/gl/poll.c:117: error: 'ENOTCONN' undeclared (first 
use in this function)
../../../src/gnutls-2.5.4/gl/poll.c: In function 'rpl_poll':
../../../src/gnutls-2.5.4/gl/poll.c:322: error: 'FD_SET_SIZE' undeclared (first 
use in this function)
../../../src/gnutls-2.5.4/gl/poll.c:352: error: 'h' undeclared (first use in 
this function)
../../../src/gnutls-2.5.4/gl/poll.c:353: warning: implicit declaration of 
function 'assert'
../../../src/gnutls-2.5.4/gl/poll.c:354: error: 'optlen' undeclared (first use 
in this function)
../../../src/gnutls-2.5.4/gl/poll.c:415: error: incompatible type for argument 
2 of 'select'
../../../src/gnutls-2.5.4/gl/poll.c:415: error: incompatible type for argument 
3 of 'select'
../../../src/gnutls-2.5.4/gl/poll.c:415: error: incompatible type for argument 
4 of 'select'

And with your latest patch I get this error:

../../../src/gnutls-2.5.4/gl/poll.c:79: error: expected 
specifier-qualifier-list before 'NTSTATUS'
../../../src/gnutls-2.5.4/gl/poll.c:81: warning: declaration does not declare 
anything
../../../src/gnutls-2.5.4/gl/poll.c:87: error: expected declaration specifiers 
or '...' before '*' token
../../../src/gnutls-2.5.4/gl/poll.c:88: error: expected declaration specifiers 
or '...' before 'FILE_INFORMATION_CLASS'
../../../src/gnutls-2.5.4/gl/poll.c:88: warning: type defaults to 'int' in 
declaration of 'NTSTATUS'
../../../src/gnutls-2.5.4/gl/poll.c:88: error: 'NTSTATUS' declared as function 
returning a function
../../../src/gnutls-2.5.4/gl/poll.c: In function 'win32_compute_revents':
../../../src/gnutls-2.5.4/gl/poll.c:104: error: expected '=', ',', ';', 'asm' 
or '__attribute__' before 'NtQueryInformationFile'
../../../src/gnutls-2.5.4/gl/poll.c:104: error: 'NtQueryInformationFile' 
undeclared (first use in this function)
../../../src/gnutls-2.5.4/gl/poll.c:104: error: (Each undeclared identifier is 
reported only once
../../../src/gnutls-2.5.4/gl/poll.c:104: error: for each function it appears 
in.)
../../../src/gnutls-2.5.4/gl/poll.c:114: error: 'PNtQueryInformationFile' 
undeclared (first use in this function)
../../../src/gnutls-2.5.4/gl/poll.c:115: error: expected ';' before 
'GetProcAddress'
../../../src/gnutls-2.5.4/gl/poll.c:134: warning: implicit declaration of 
function 'NtQueryInformationFile'
../../../src/gnutls-2.5.4/gl/poll.c:145: error: 'bRet' undeclared (first use in 
this function)
../../../src/gnutls-2.5.4/gl/poll.c:149: warning: implicit declaration of 
function 'alloca'
../../../src/gnutls-2.5.4/gl/poll.c:149: warning: incompatible implicit 
declaration of built-in function 'alloca'
../../../src/gnutls-2.5.4/gl/poll.c: In function 'win32_compute_revents_socket':
../../../src/gnutls-2.5.4/gl/poll.c:188: error: 'ENOTCONN' undeclared (first 
use in this function)
../../../src/gnutls-2.5.4/gl/poll.c: In function 'rpl_poll':
../../../src/gnutls-2.5.4/gl/poll.c:393: error: 'FD_SET_SIZE' undeclared (first 
use in this function)
../../../src/gnutls-2.5.4/gl/poll.c:424: error: 'h' undeclared (first use in 
this function)
../../../src/gnutls-2.5.4/gl/poll.c:425: warning: implicit declaration of 
function 'assert'
../../../src/gnutls-2.5.4/gl/poll.c:426: error: 'optlen' undeclared (first use 
in this function)
../../../src/gnutls-2.5.4/gl/poll.c:487: error: incompatible type for argument 
2 of 'select'
../../../src/gnutls-2.5.4/gl/poll.c:487: error: incompatible type for argument 
3 of 'select'
../../../src/gnutls-2.5.4/gl/poll.c:487: error: incompatible type for argument 
4 of 'select'

Thanks,
Simon




Re: [RFE] function to read a file descriptor

2008-08-18 Thread Debarshi Ray
>  *buffer = realloc (*buffer, *size);

Oops, I meant to use xrealloc there.

Happy hacking,
Debarshi




Re: [RFE] function to read a file descriptor

2008-08-18 Thread Debarshi Ray
> How about using the 'read-file' module, passing it a FILE stream created with
> fdopen()?

Yes, I saw that. However there seems to be many instances of using the
low-level system calls directly, especially in Inetutils where reading
from sockets is quite common.

Happy hacking,
Debarshi




improve error message from gitlog-to-changelog with too-old Git

2008-08-18 Thread Ben Pfaff
GNU PSPP has started using the gitlog-to-changelog script, via
the corresponding gnulib module.  One of the PSPP developers
(CC'd) reported the following error from the script:

> fatal: invalid --pretty format: format:%ct  %an  <%ae>%n%n%s%n%b%n
> gitlog-to-changelog: error closing pipe from git log --log-size
>   '--since=2008-07-27' '--pretty=format:%ct  %an
>   <%ae>%n%n%s%n%b%n'

Later, he noticed:
> It seems to work OK with git 1.5.5.3 but not with git 1.4.4.4 

Looking at Git's history, "--pretty=format:" was introduced
between Git 1.5.0 and 1.5.1, so I'd propose helping the user to
understand what went wrong with the following change.

Alternatively, one could check the Git version number before
trying "--pretty=format:", but this seems to require parsing the
output of "git --version" and I'm not too enthusiastic about
various things that can go wrong with that.

2008-08-18  Ben Pfaff  <[EMAIL PROTECTED]>

* build-aux/gitlog-to-changelog: Improve error message given when
the available version of Git is too old.

diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 3efdb6d..50b1b2f 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # Convert git log output to ChangeLog format.
 
-my $VERSION = '2008-02-10 10:03'; # UTC
+my $VERSION = '2008-08-19 05:01'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -106,7 +106,8 @@ sub quoted_cmd(@)
   my @cmd = (qw (git log --log-size), "--since=$since_date",
  '--pretty=format:%ct  %an  <%ae>%n%n%s%n%b%n');
   open PIPE, '-|', @cmd
-or die "$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n";
+or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n"
+. "(Is your Git too old?  Version 1.5.1 or later is required.)\n");
 
   my $prev_date_line = '';
   while (1)

Thanks,

Ben.
-- 
"Premature optimization is the root of all evil."
--D. E. Knuth, "Structured Programming with go to Statements"




Re: [RFT/RFH] porting the poll module to win32

2008-08-18 Thread Paolo Bonzini



What do you think about writing a gnulib self-test that tests whether
poll works correctly?  It would help to test the replacement function on
various platforms quicker, and also helps catch regression.  I suspect
writing a self test may be somewhat complicated though, you'll need to
setup at least two sockets, poll them, and read/write from/to them a
couple of times.


Yes, it can be done.  I use poll(2) extensively in GNU Smalltalk, which 
has a good deal of socket tests and does not work at all if poll(2) does 
not support console handles.



Alas, I have little time to develop this right now, but can test things
if you work on it.


Yes, here's a follow-up that should fix the syntax errors, to be applied 
on top of the last patch I sent.


Paolo
diff --git a/lib/poll.c b/lib/poll.c
index ffa6ab0..ff6f4f7 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -25,6 +25,7 @@
 #include "poll.h"
 #include 
 #include 
+#include 
 
 #ifdef __MSVCRT__
 #include 
@@ -75,16 +76,16 @@ typedef struct _FILE_PIPE_LOCAL_INFORMATION {
 
 typedef struct _IO_STATUS_BLOCK
 {
-  union u {
-NTSTATUS Status;
+  union {
+DWORD Status;
 PVOID Pointer;
-  };
+  } u;
   ULONG_PTR Information;
 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
 
 #define FilePipeLocalInformation 24
 
-typedef NTSTATUS (NTAPI *PNtQueryInformationFile)
+typedef DWORD (WINAPI *PNtQueryInformationFile)
 (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
 
 #ifndef PIPE_BUF
@@ -99,6 +100,7 @@ win32_compute_revents (HANDLE h, int sought)
   int i, ret, happened;
   INPUT_RECORD *irbuffer;
   DWORD avail, nbuffer;
+  BOOL bRet;
   IO_STATUS_BLOCK iosb;
   FILE_PIPE_LOCAL_INFORMATION fpli;
   static PNtQueryInformationFile NtQueryInformationFile;
@@ -185,7 +187,7 @@ win32_compute_revents_socket (SOCKET h, int sought,
 
   /* If the event happened on an unconnected server socket,
  that's fine. */
-  else if (r > 0 || ( /* (r == -1) && */ error == ENOTCONN))
+  else if (r > 0 || ( /* (r == -1) && */ error == WSAENOTCONN))
 happened |= (POLLIN | POLLRDNORM) & sought;
 
   /* Distinguish hung-up sockets from other errors.  */
@@ -390,7 +392,7 @@ poll (pfd, nfd, timeout)
   struct timeval tv = { 0, 0 };
   struct timeval *ptv;
   static HANDLE hEvent;
-  HANDLE handle_array[FD_SET_SIZE + 2];
+  HANDLE h, handle_array[FD_SETSIZE + 2];
   DWORD ret, wait_timeout, nhandles;
   int nsock;
   BOOL bRet;
@@ -399,7 +401,7 @@ poll (pfd, nfd, timeout)
   int rc;
   nfds_t i;
 
-  if (nfd < 0 || nfd > FD_SET_SIZE || timeout < 0)
+  if (nfd < 0 || nfd > FD_SETSIZE || timeout < 0)
 {
   errno = EINVAL;
   return -1;
@@ -418,12 +420,12 @@ poll (pfd, nfd, timeout)
   FD_ZERO (&efds);
   for (i = 0; i < nfd; i++)
 {
+  size_t optlen = sizeof(sockbuf);
   if (pfd[i].fd < 0)
 continue;
 
   h = (HANDLE) _get_osfhandle (i);
   assert (h != NULL);
-  optlen = sizeof(sockbuf);
   if ((getsockopt ((SOCKET) h, SOL_SOCKET, SO_TYPE, sockbuf, &optlen)
!= SOCKET_ERROR)
   || WSAGetLastError() != WSAENOTSOCK)
@@ -484,7 +486,7 @@ poll (pfd, nfd, timeout)
 }
 
   /* Now check if the sockets have some event set.  */
-  select (nsock + 1, rfds, wfds, efds, &tv0);
+  select (nsock + 1, &rfds, &wfds, &efds, &tv0);
 
   /* Place a sentinel at the end of the array.  */
   handle_array[nhandles] = NULL;
@@ -503,7 +505,7 @@ poll (pfd, nfd, timeout)
   if (h != handle_array[nhandles])
 {
   /* It's a socket.  */
-  WSAEventSelect (h, 0, 0);
+  WSAEventSelect ((SOCKET) h, 0, 0);
   happened = win32_compute_revents_socket ((SOCKET) h, pfd[i].events,
&rfds, &wfds, &efds);
 }


Re: improve error message from gitlog-to-changelog with too-old Git

2008-08-18 Thread Jim Meyering
Ben Pfaff <[EMAIL PROTECTED]> wrote:
> GNU PSPP has started using the gitlog-to-changelog script, via
> the corresponding gnulib module.  One of the PSPP developers
> (CC'd) reported the following error from the script:
>
>> fatal: invalid --pretty format: format:%ct  %an  <%ae>%n%n%s%n%b%n
>> gitlog-to-changelog: error closing pipe from git log --log-size
>>   '--since=2008-07-27' '--pretty=format:%ct  %an
>>   <%ae>%n%n%s%n%b%n'
>
> Later, he noticed:
>> It seems to work OK with git 1.5.5.3 but not with git 1.4.4.4
>
> Looking at Git's history, "--pretty=format:" was introduced
> between Git 1.5.0 and 1.5.1, so I'd propose helping the user to
> understand what went wrong with the following change.
>
> Alternatively, one could check the Git version number before
> trying "--pretty=format:", but this seems to require parsing the
> output of "git --version" and I'm not too enthusiastic about
> various things that can go wrong with that.
>
> 2008-08-18  Ben Pfaff  <[EMAIL PROTECTED]>
>
>   * build-aux/gitlog-to-changelog: Improve error message given when
>   the available version of Git is too old.

Thanks.  The patch looks fine.
I gave the log a summary line and pushed it:

>From 9462d43fbc0d873ee7e667ba952616d53b8585e4 Mon Sep 17 00:00:00 2001
From: Ben Pfaff <[EMAIL PROTECTED]>
Date: Tue, 19 Aug 2008 08:20:22 +0200
Subject: [PATCH] gitlog-to-changelog: give better diagnostic for failed 
pipe-open

* build-aux/gitlog-to-changelog: Improve error message: suggest
that the version of Git may be too old.
---
 ChangeLog |6 ++
 build-aux/gitlog-to-changelog |5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a09e688..5e303c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-18  Ben Pfaff  <[EMAIL PROTECTED]>
+
+   gitlog-to-changelog: give better diagnostic for failed pipe-open
+   * build-aux/gitlog-to-changelog: Improve error message: suggest
+   that the version of Git may be too old.
+
 2008-08-18  Simon Josefsson  <[EMAIL PROTECTED]>

* m4/autobuild.m4: Use TZ=UTC to avoid time zone complexity.  Use
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 3efdb6d..50b1b2f 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 # Convert git log output to ChangeLog format.

-my $VERSION = '2008-02-10 10:03'; # UTC
+my $VERSION = '2008-08-19 05:01'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -106,7 +106,8 @@ sub quoted_cmd(@)
   my @cmd = (qw (git log --log-size), "--since=$since_date",
  '--pretty=format:%ct  %an  <%ae>%n%n%s%n%b%n');
   open PIPE, '-|', @cmd
-or die "$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n";
+or die ("$ME: failed to run `". quoted_cmd (@cmd) ."': $!\n"
+. "(Is your Git too old?  Version 1.5.1 or later is required.)\n");

   my $prev_date_line = '';
   while (1)
--
1.6.0.4.g750768