[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PATH_MAX on HP-UX
From: |
Bruno Haible |
Subject: |
PATH_MAX on HP-UX |
Date: |
Sat, 18 Jun 2011 22:22:51 +0200 |
User-agent: |
KMail/1.9.9 |
Hi,
On HP-UX 11.31 I'm seeing this compilation failure:
cc -Ae -D_XOPEN_SOURCE=500 -O -DHAVE_CONFIG_H -I. -DGNULIB_STRICT_CHECKING=1
-I. -I. -I.. -I./.. -I../gllib -I./../gllib
-I/home/haible/prefix-hpux113-cc/include -g -c -o test-getcwd.o test-getcwd.c
cc: "test-getcwd.c", line 53: error 1588: "PATH_MAX" undefined.
cc: "test-getcwd.c", line 53: error 1563: Expression in if must be scalar.
gmake[4]: *** [test-getcwd.o] Error 1
PATH_MAX on HP-UX 11.31 is
1) not defined if _XOPEN_SOURCE is defined to 500 or greater,
2) otherwise defined to 1023, with a comment saying
"max number of characters in a pathname (not including terminating null)"
Apparently the reason is that POSIX specifies that PATH_MAX needs to include
the terminating NUL, but HP-UX PATH_MAX traditionally does not include it.
So they chose to remove PATH_MAX from their headers.
Here is a proposed patch. The second patch is obvious, I'm committing it
directly.
2011-06-18 Bruno Haible <address@hidden>
pathmax: Ensure correct value for PATH_MAX on HP-UX.
* lib/pathmax.h (PATH_MAX) [HP-UX]: Define to 1024.
--- lib/pathmax.h.orig Sat Jun 18 22:07:53 2011
+++ lib/pathmax.h Sat Jun 18 21:28:02 2011
@@ -19,6 +19,12 @@
#ifndef _PATHMAX_H
# define _PATHMAX_H
+/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
+ including the terminating NUL byte.
+ <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
+ PATH_MAX is not defined on systems which have no limit on filename length,
+ such as GNU/Hurd. */
+
# include <unistd.h>
# include <limits.h>
@@ -45,4 +51,13 @@
# define PATH_MAX _POSIX_PATH_MAX
# endif
+# ifdef __hpux
+/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
+ *not* including the terminating NUL byte, and is set to 1023.
+ Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
+ not defined at all any more. */
+# undef PATH_MAX
+# define PATH_MAX 1024
+# endif
+
#endif /* _PATHMAX_H */
2011-06-18 Bruno Haible <address@hidden>
getcwd tests: Avoid compilation error on HP-UX 11.31.
* modules/getcwd-tests (Depends-on): Add pathmax.
* tests/test-getcwd.c: Include pathmax.h.
--- modules/getcwd-tests.orig Sat Jun 18 22:07:54 2011
+++ modules/getcwd-tests Sat Jun 18 20:30:10 2011
@@ -5,6 +5,7 @@
errno
fcntl-h
getcwd-lgpl
+pathmax
sys_stat
configure.ac:
--- tests/test-getcwd.c.orig Sat Jun 18 22:07:54 2011
+++ tests/test-getcwd.c Sat Jun 18 20:31:03 2011
@@ -26,6 +26,7 @@
#include <string.h>
#include <sys/stat.h>
+#include "pathmax.h"
#include "macros.h"
#if ! HAVE_GETPAGESIZE
--
In memoriam Mona Mahmudnizhad <http://en.wikipedia.org/wiki/Mona_Mahmudnizhad>
- PATH_MAX on HP-UX,
Bruno Haible <=
- Re: PATH_MAX on HP-UX, Eric Blake, 2011/06/20
- Re: PATH_MAX constant expression, Bruno Haible, 2011/06/20
- Re: PATH_MAX constant expression, Eric Blake, 2011/06/20
- Re: PATH_MAX constant expression, Jim Meyering, 2011/06/21
- Re: PATH_MAX constant expression, Eric Blake, 2011/06/21
- Re: PATH_MAX constant expression, Jim Meyering, 2011/06/21
- Re: PATH_MAX constant expression, Bruno Haible, 2011/06/23