]> granicus.if.org Git - gc/commitdiff
Avoid unstructured procfs on Solaris
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 27 Aug 2015 11:26:18 +0000 (11:26 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 30 Oct 2015 07:57:54 +0000 (10:57 +0300)
(Cherry-picked commit f9711f5 from 'gcc_boehmgc' branch.)

* os_dep.c [PROC_VDB] (GC_dirty_init): Use /proc/<pid>/pagedata
instead of PIOCOPENPD; remove fd local variable; increase buf[] size.

os_dep.c

index 9f44395f80d6caf140c60af5bb344e0c4a7f06d4..838c9373fa5e0d32f95f94398206e417f2d959cf 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -3511,8 +3511,7 @@ GC_INNER GC_bool GC_page_was_dirty(struct hblk *h)
 
 GC_INNER void GC_dirty_init(void)
 {
-    int fd;
-    char buf[30];
+    char buf[40];
 
     if (GC_bytes_allocd != 0 || GC_bytes_allocd_before_gc != 0) {
       memset(GC_written_pages, 0xff, sizeof(page_hash_table));
@@ -3521,14 +3520,12 @@ GC_INNER void GC_dirty_init(void)
                 (unsigned long)(GC_bytes_allocd + GC_bytes_allocd_before_gc));
     }
 
-    (void)snprintf(buf, sizeof(buf), "/proc/%ld", (long)getpid());
+    (void)snprintf(buf, sizeof(buf), "/proc/%ld/pagedata", (long)getpid());
     buf[sizeof(buf) - 1] = '\0';
-    fd = open(buf, O_RDONLY);
-    if (fd < 0) {
+    GC_proc_fd = open(buf, O_RDONLY);
+    if (GC_proc_fd < 0) {
         ABORT("/proc open failed");
     }
-    GC_proc_fd = syscall(SYS_ioctl, fd, PIOCOPENPD, 0);
-    close(fd);
     syscall(SYS_fcntl, GC_proc_fd, F_SETFD, FD_CLOEXEC);
     if (GC_proc_fd < 0) {
         WARN("/proc ioctl(PIOCOPENPD) failed", 0);