Discussion:
vma-iter: support Solaris
Bruno Haible
2017-03-19 15:38:24 UTC
Permalink
I'm adding support for Solaris to the 'vma-iter' module.
It's useful for GNU clisp.
Tom G. Christensen
2017-04-18 19:48:34 UTC
Permalink
Post by Bruno Haible
I'm adding support for Solaris to the 'vma-iter' module.
It's useful for GNU clisp.
This is causing my daily gnulib builds to fail on Solaris.

On Solaris 8 and 9 I'm seeing this error:

In file included from vma-iter.c:41:0:
/usr/include/sys/procfs.h:44:2: error: #error "Cannot use procfs in the
large file compilation environment"
#error "Cannot use procfs in the large file compilation environment"
^
make[4]: *** [vma-iter.o] Error 1

On Solaris 2.6 and 7 there is the additional issue of missing MAP_ANONYMOUS:

In file included from vma-iter.c:41:0:
/usr/include/sys/procfs.h:44:2: error: #error "Cannot use procfs in the
large file compilation environment"
vma-iter.c: In function 'vma_iterate':
vma-iter.c:545:27: error: 'MAP_ANONYMOUS' undeclared (first use in this
function)
vma-iter.c:545:27: note: each undeclared identifier is reported only
once for each function it appears in
make[4]: *** [vma-iter.o] Error 1

-tgc
Bruno Haible
2017-04-18 23:05:27 UTC
Permalink
Post by Tom G. Christensen
This is causing my daily gnulib builds to fail on Solaris.
/usr/include/sys/procfs.h:44:2: error: #error "Cannot use procfs in the
large file compilation environment"
#error "Cannot use procfs in the large file compilation environment"
^
make[4]: *** [vma-iter.o] Error 1
Fixed as follows. Thanks for the report!


2017-04-18 Bruno Haible <***@clisp.org>

vma-iter: Fix conflict with module 'largefile' on 32-bit Solaris 9.
* modules/vma-iter (configure.ac): Test whether <sys/procfs.h> can be
included.
* lib/vma-iter.c: On Solaris, test HAVE_SYS_PROCFS_H before including
<sys/procfs.h>.
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Don't define on Solaris when
<sys/procfs.h> cannot be included.
Reported by Tom G. Christensen <***@jupiterrise.com>.

diff --git a/modules/vma-iter b/modules/vma-iter
index df9e7b8..40e5605 100644
--- a/modules/vma-iter
+++ b/modules/vma-iter
@@ -15,6 +15,8 @@ getpagesize
configure.ac:
gl_FUNC_MMAP_ANON
AC_CHECK_FUNCS_ONCE([mquery pstat_getprocvm])
+dnl On Solaris <= 9, <sys/procfs.h> is unusable when AC_SYS_LARGEFILE is in use.
+AC_CHECK_HEADERS([sys/procfs.h])

Makefile.am:
lib_SOURCES += vma-iter.c
diff --git a/lib/vma-iter.c b/lib/vma-iter.c
index 7356188..d4bae13 100644
--- a/lib/vma-iter.c
+++ b/lib/vma-iter.c
@@ -32,7 +32,7 @@
# include <sys/procfs.h> /* PIOC*, prmap_t */
#endif

-#if defined __sun /* Solaris */
+#if defined __sun && HAVE_SYS_PROCFS_H /* Solaris */
# include <string.h> /* memcpy */
# include <sys/types.h>
# include <sys/mman.h> /* mmap, munmap */
@@ -378,7 +378,7 @@ vma_iterate (vma_iterate_callback_fn callback, void *data)
close (fd);
return -1;

-#elif defined __sun /* Solaris */
+#elif defined __sun && HAVE_SYS_PROCFS_H /* Solaris */

/* Note: Solaris <sys/procfs.h> defines a different type prmap_t with
_STRUCTURED_PROC than without! Here's a table of sizeof(prmap_t):
diff --git a/lib/vma-iter.h b/lib/vma-iter.h
index bb1f3c1..95374ef 100644
--- a/lib/vma-iter.h
+++ b/lib/vma-iter.h
@@ -52,7 +52,7 @@ extern int vma_iterate (vma_iterate_callback_fn callback, void *data);
this platform.
Note that even when this macro is defined, vma_iterate() may still fail to
find any virtual memory area, for example if /proc is not mounted. */
-#if defined __linux__ || defined __FreeBSD__ || defined __NetBSD__ || defined __sgi || defined __osf__ || defined __sun || HAVE_PSTAT_GETPROCVM || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __WIN32__) || defined __CYGWIN__ || defined __BEOS__ || defined __HAIKU__ || HAVE_MQUERY
+#if defined __linux__ || defined __FreeBSD__ || defined __NetBSD__ || defined __sgi || defined __osf__ || (defined __sun && HAVE_SYS_PROCFS_H) || HAVE_PSTAT_GETPROCVM || (defined __APPLE__ && defined __MACH__) || (defined _WIN32 || defined __WIN32__) || defined __CYGWIN__ || defined __BEOS__ || defined __HAIKU__ || HAVE_MQUERY
# define VMA_ITERATE_SUPPORTED 1
#endif
Tom G. Christensen
2017-04-19 16:11:54 UTC
Permalink
Post by Bruno Haible
Post by Tom G. Christensen
This is causing my daily gnulib builds to fail on Solaris.
/usr/include/sys/procfs.h:44:2: error: #error "Cannot use procfs in the
large file compilation environment"
#error "Cannot use procfs in the large file compilation environment"
^
make[4]: *** [vma-iter.o] Error 1
Fixed as follows. Thanks for the report!
Thank you, builds have completed on Solaris 8 and 9 with no issues.

I should note that Solaris 10 has the same guard in <sys/procfs.h> so it
would presumably have been affected as well.
I don't have a Solaris 11 system to check.

-tgc
Bruno Haible
2017-09-30 17:56:19 UTC
Permalink
Post by Bruno Haible
vma-iter: Fix conflict with module 'largefile' on 32-bit Solaris 9.
* modules/vma-iter (configure.ac): Test whether <sys/procfs.h> can be
included.
* lib/vma-iter.c: On Solaris, test HAVE_SYS_PROCFS_H before including
<sys/procfs.h>.
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Don't define on Solaris when
<sys/procfs.h> cannot be included.
Well, that fixed the compilation error, but at the price of not having a working
vma_iterate function in this configuration. The attached patch does it better.

2017-09-30 Bruno Haible <***@clisp.org>

vma-iter: Make it work on 32-bit Solaris with module 'largefile'.
* modules/vma-iter: Don't test for sys/procfs.h, as this test would
fail when module 'largefile' is in use.
* lib/vma-iter.h (VMA_ITERATE_SUPPORTED): Don't test HAVE_SYS_PROCFS_H.
* lib/vma-iter.c: Undefine _FILE_OFFSET_BITS early.
Don't test HAVE_SYS_PROCFS_H.

Bruno Haible
2017-04-18 23:28:44 UTC
Permalink
Post by Tom G. Christensen
/usr/include/sys/procfs.h:44:2: error: #error "Cannot use procfs in the
large file compilation environment"
vma-iter.c:545:27: error: 'MAP_ANONYMOUS' undeclared (first use in this
function)
vma-iter.c:545:27: note: each undeclared identifier is reported only
once for each function it appears in
make[4]: *** [vma-iter.o] Error 1
Fixed as follows. Thanks for the report!


2017-04-18 Bruno Haible <***@clisp.org>

vma-iter: Fix compilation error on Solaris 7.
* lib/vma-iter.c (vma_iterate): Treat missing MAP_ANONYMOUS on Solaris
like on IRIX, OSF/1.
Reported by Tom G. Christensen <***@jupiterrise.com>.

diff --git a/lib/vma-iter.c b/lib/vma-iter.c
index d4bae13..e81b8ea 100644
--- a/lib/vma-iter.c
+++ b/lib/vma-iter.c
@@ -399,6 +399,13 @@ vma_iterate (vma_iterate_callback_fn callback, void *data)
int fd;
int nmaps;
size_t memneed;
+# if HAVE_MAP_ANONYMOUS
+# define zero_fd -1
+# define map_flags MAP_ANONYMOUS
+# else /* Solaris <= 7 */
+ int zero_fd;
+# define map_flags 0
+# endif
void *auxmap;
unsigned long auxmap_start;
unsigned long auxmap_end;
@@ -433,8 +440,16 @@ vma_iterate (vma_iterate_callback_fn callback, void *data)
and thus pre-allocate available memory.
So use mmap(), and ignore the resulting VMA. */
memneed = ((memneed - 1) / pagesize + 1) * pagesize;
+# if !HAVE_MAP_ANONYMOUS
+ zero_fd = open ("/dev/zero", O_RDONLY, 0644);
+ if (zero_fd < 0)
+ goto fail2;
+# endif
auxmap = (void *) mmap ((void *) 0, memneed, PROT_READ | PROT_WRITE,
- MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+ map_flags | MAP_PRIVATE, zero_fd, 0);
+# if !HAVE_MAP_ANONYMOUS
+ close (zero_fd);
+# endif
if (auxmap == (void *) -1)
goto fail2;
auxmap_start = (unsigned long) auxmap;
@@ -502,6 +517,13 @@ vma_iterate (vma_iterate_callback_fn callback, void *data)
int fd;
int nmaps;
size_t memneed;
+# if HAVE_MAP_ANONYMOUS
+# define zero_fd -1
+# define map_flags MAP_ANONYMOUS
+# else /* Solaris <= 7 */
+ int zero_fd;
+# define map_flags 0
+# endif
void *auxmap;
unsigned long auxmap_start;
unsigned long auxmap_end;
@@ -541,8 +563,16 @@ vma_iterate (vma_iterate_callback_fn callback, void *data)
and thus pre-allocate available memory.
So use mmap(), and ignore the resulting VMA. */
memneed = ((memneed - 1) / pagesize + 1) * pagesize;
+# if !HAVE_MAP_ANONYMOUS
+ zero_fd = open ("/dev/zero", O_RDONLY, 0644);
+ if (zero_fd < 0)
+ goto fail2;
+# endif
auxmap = (void *) mmap ((void *) 0, memneed, PROT_READ | PROT_WRITE,
- MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+ map_flags | MAP_PRIVATE, zero_fd, 0);
+# if !HAVE_MAP_ANONYMOUS
+ close (zero_fd);
+# endif
if (auxmap == (void *) -1)
goto fail2;
auxmap_start = (unsigned long) auxmap;
Tom G. Christensen
2017-04-19 16:12:38 UTC
Permalink
Post by Bruno Haible
Post by Tom G. Christensen
/usr/include/sys/procfs.h:44:2: error: #error "Cannot use procfs in the
large file compilation environment"
vma-iter.c:545:27: error: 'MAP_ANONYMOUS' undeclared (first use in this
function)
vma-iter.c:545:27: note: each undeclared identifier is reported only
once for each function it appears in
make[4]: *** [vma-iter.o] Error 1
Fixed as follows. Thanks for the report!
Thank you, builds have now completed on Solaris 2.6 and 7.

-tgc
Paul Eggert
2017-04-20 00:31:00 UTC
Permalink
Post by Tom G. Christensen
builds have now completed on Solaris 2.6 and 7
Out of curiosity, what are these old builds used for? Sun stopped
supporting Solaris 2.6 in 2006, for example.
Tom G. Christensen
2017-04-20 20:59:49 UTC
Permalink
Post by Paul Eggert
Post by Tom G. Christensen
builds have now completed on Solaris 2.6 and 7
Out of curiosity, what are these old builds used for? Sun stopped
supporting Solaris 2.6 in 2006, for example.
I build various opensource packages for my own amusement and make them
available for public consumption for anyone interested as part of my
tgcware project(1).
To support this it's important to know what state gnulib is in so I run
daily builds on those platforms (among others).
The build logs are also publicly available(2).
Should you choose to look into them you will see that there are several
testsuite errors that I have not reported. I know those platforms are
not that interesting to gnulib and I have no wish to impose any undue
demands on already scarce resources.

-tgc

1) http://jupiterrise.com/tgcware/
2) http://jupiterrise.com/autobuild/gnulib/
Loading...