bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] ssize_t and mingw32


From: Paul Eggert
Subject: Re: [Bug-gnulib] ssize_t and mingw32
Date: 30 Jun 2003 11:21:12 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Bruno Haible <address@hidden> writes:

> + AC_DEFUN([gt_TYPE_SSIZE_T],
> + [
> +   AC_CHECK_HEADERS_ONCE(unistd.h)
> +   AC_CACHE_CHECK([for ssize_t], gt_cv_ssize_t,
> +     [AC_TRY_COMPILE([
> + #include <sys/types.h>
> + #if HAVE_UNISTD_H
> + #include <unistd.h>
> + #endif], [int x = sizeof (ssize_t *) + sizeof (ssize_t);],
> +        gt_cv_ssize_t=yes, gt_cv_ssize_t=no)])
> +   if test $gt_cv_ssize_t = no; then
> +     AC_DEFINE(ssize_t, int,
> +               [Define as a signed type of the same size as size_t.])
> +   fi
> + ])

Is there any reason to examine both <sys/types.h> and <unistd.h>?
POSIX says that <sys/types.h> is the "home" of ssize_t, and I don't
know of any host that defines it in <unistd.h> but not <sys/types.h>.
Several other standard include files (e.g. <monetary.h>, admittedly an
XSI extension) also declare ssize_t, and some standard include files
(e.g., <sys/sockets.h>) optionally declare ssize_t, and I worry that
we're going down a slippery slope if gt_TYPE_SSIZE_T looks into
<unistd.h>.

Also, I noticed that xreadlink.c (which depends on the new
gt_TYPE_SSIZE_T) says this:

  #if HAVE_SYS_TYPES_H
  # include <sys/types.h>
  #endif

but gt_TYPE_SSIZE_T includes <sys/types.h> unconditionally.  I think
this is "over-porting", as I can't imagine any host that has readlink
but not <sys/types.h>.  The rest of gnulib includes <sys/types.h>
unconditionally, so how about the following patch?

Index: lib/xreadlink.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/xreadlink.c,v
retrieving revision 1.9
diff -p -u -r1.9 xreadlink.c
--- lib/xreadlink.c     29 May 2003 07:21:59 -0000      1.9
+++ lib/xreadlink.c     30 Jun 2003 18:09:43 -0000
@@ -30,9 +30,7 @@ extern int errno;
 #endif
 
 #include <limits.h>
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
+#include <sys/types.h>
 #if HAVE_STDLIB_H
 # include <stdlib.h>
 #endif
Index: m4/xreadlink.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/xreadlink.m4,v
retrieving revision 1.3
diff -p -u -r1.3 xreadlink.m4
--- m4/xreadlink.m4     25 Jun 2003 09:20:53 -0000      1.3
+++ m4/xreadlink.m4     30 Jun 2003 18:09:44 -0000
@@ -10,5 +10,5 @@ AC_DEFUN([gl_XREADLINK],
 [
   dnl Prerequisites of lib/xreadlink.c.
   AC_REQUIRE([gt_TYPE_SSIZE_T])
-  AC_CHECK_HEADERS_ONCE(stdlib.h sys/types.h unistd.h)
+  AC_CHECK_HEADERS_ONCE(stdlib.h unistd.h)
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]