diff --git a/sysdeps/solaris/ChangeLog b/sysdeps/solaris/ChangeLog index 565303fd..6a9f8aec 100644 --- a/sysdeps/solaris/ChangeLog +++ b/sysdeps/solaris/ChangeLog @@ -1,3 +1,9 @@ +1999-06-07 Drazen Kacar + + * glibtop_machine.h, open.c, procargs.c, proclist.c, procmap.c: + Solaris 2.5 & 2.5.1 portability fixes, based on patches + from Steve Murphy . + 1999-05-30 Drazen Kacar * procargs.c: Fixed bug in calculation of process argument list. diff --git a/sysdeps/solaris/glibtop_machine.h b/sysdeps/solaris/glibtop_machine.h index b228fe13..bb14cf99 100644 --- a/sysdeps/solaris/glibtop_machine.h +++ b/sysdeps/solaris/glibtop_machine.h @@ -64,9 +64,13 @@ struct _glibtop_machine int ticks; /* clock ticks, as returned by sysconf() */ unsigned long long boot; /* boot time, although it's ui32 in kstat */ void *libproc; /* libproc handle */ +#if GLIBTOP_SOLARIS_RELEASE >= 560 void (*objname)(void *, uintptr_t, const char *, size_t); struct ps_prochandle *(*pgrab)(pid_t, int, int *); void (*pfree)(void *); +#else + void *filler[3]; +#endif }; END_LIBGTOP_DECLS diff --git a/sysdeps/solaris/open.c b/sysdeps/solaris/open.c index 7ee7cb9e..b2c8f999 100644 --- a/sysdeps/solaris/open.c +++ b/sysdeps/solaris/open.c @@ -205,6 +205,8 @@ glibtop_open_s (glibtop *server, const char *program_name, /* Now let's have a bit of magic dust... */ +#if GLIBTOP_SOLARIS_RELEASE >= 560 + dl = dlopen("/usr/lib/libproc.so", RTLD_LAZY); server->machine.libproc = dl; if(dl) @@ -226,5 +228,6 @@ glibtop_open_s (glibtop *server, const char *program_name, server->machine.pgrab = NULL; server->machine.pfree = NULL; } +#endif server->machine.me = getpid(); } diff --git a/sysdeps/solaris/procargs.c b/sysdeps/solaris/procargs.c index 2e413b29..ac2721d3 100644 --- a/sysdeps/solaris/procargs.c +++ b/sysdeps/solaris/procargs.c @@ -43,7 +43,11 @@ char * glibtop_get_proc_args_s (glibtop *server, glibtop_proc_args *buf, pid_t pid, unsigned max_len) { +#ifdef HAVE_PROCFS_H struct psinfo pinfo; +#else + struct prpsinfo pinfo; +#endif int len, i; char *ret, *p; diff --git a/sysdeps/solaris/proclist.c b/sysdeps/solaris/proclist.c index de79cf4a..192e2673 100644 --- a/sysdeps/solaris/proclist.c +++ b/sysdeps/solaris/proclist.c @@ -77,8 +77,11 @@ glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf, { if(mask) { +#ifdef HAVE_PROCFS_H struct psinfo psinfo; - +#else + struct prpsinfo psinfo; +#endif if(glibtop_get_proc_data_psinfo_s(server, &psinfo, pid)) return NULL; if(mask & GLIBTOP_EXCLUDE_IDLE && !psinfo.pr_pctcpu) diff --git a/sysdeps/solaris/procmap.c b/sysdeps/solaris/procmap.c index 27b50d04..daa2ba00 100644 --- a/sysdeps/solaris/procmap.c +++ b/sysdeps/solaris/procmap.c @@ -57,7 +57,12 @@ glibtop_map_entry * glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) { int fd, i, nmaps, pr_err, heap; +#if GLIBTOP_SOLARIS_RELEASE >= 560 prxmap_t *maps; + struct ps_prochandle *Pr; +#else + prmap_t *maps; +#endif /* A few defines, to make it shorter down there */ @@ -67,7 +72,6 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) # define OFFSET pr_off #endif - struct ps_prochandle *Pr; glibtop_map_entry *entry; struct stat inode; char buffer[BUFSIZ]; @@ -109,7 +113,7 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) s_close(fd); return NULL; } - maps = alloca((nmaps + 1) * sizeof(prxmap_t)); + maps = alloca((nmaps + 1) * sizeof(prmap_t)); if(ioctl(fd, PIOCMAP, maps) < 0) { glibtop_warn_io_r(server, "ioctl(%s, PIOCMAP)", buffer); @@ -126,21 +130,28 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) memset(entry, 0, nmaps * sizeof(glibtop_map_entry)); +#if GLIBTOP_SOLARIS_RELEASE >= 560 + if(server->machine.objname && server->machine.pgrab && server->machine.pfree) Pr = (server->machine.pgrab)(pid, 1, &pr_err); +#endif for(heap = 0,i = 0; i < nmaps; ++i) { int len; entry[i].start = maps[i].pr_vaddr; entry[i].end = maps[i].pr_vaddr + maps[i].pr_size; + +#if GLIBTOP_SOLARIS_RELEASE >= 560 + if(maps[i].pr_dev != PRNODEV) { entry[i].device = maps[i].pr_dev; entry[i].inode = maps[i].pr_ino; entry[i].flags |= _glibtop_sysdeps_map_device; } +#endif entry[i].offset = maps[i].OFFSET; if(maps[i].pr_mflags & MA_READ) entry[i].perm |= GLIBTOP_MAP_PERM_READ; @@ -153,6 +164,9 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) else entry[i].perm |= GLIBTOP_MAP_PERM_PRIVATE; entry[i].flags = _glibtop_sysdeps_map_entry; + +#if GLIBTOP_SOLARIS_RELEASE >= 560 + if(maps[i].pr_mflags & MA_ANON) { if(!heap) @@ -179,9 +193,14 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) entry[i].flags |= (1L << GLIBTOP_MAP_ENTRY_FILENAME); } } +#endif } + +#if GLIBTOP_SOLARIS_RELEASE >= 560 + if(Pr) server->machine.pfree(Pr); +#endif buf->flags = _glibtop_sysdeps_proc_map; s_close(fd); return entry;