summaryrefslogtreecommitdiff
path: root/sysdeps/sun4
diff options
context:
space:
mode:
authorCarlos Perelló Marín <carlos@gnome.org>2003-10-19 16:55:56 +0000
committerCarlos Perelló Marín <carlos@src.gnome.org>2003-10-19 16:55:56 +0000
commit4c8ae9e25c1940d8876ca3f2330426863cae4737 (patch)
treec43f97bc0647546b0ed87022db0749c137f24edc /sysdeps/sun4
parentbae16b467f90df94d80feae41dceb7e816f16c61 (diff)
downloadlibgtop-4c8ae9e25c1940d8876ca3f2330426863cae4737.tar.gz
Reverted libgtop changes. It's a common module and I should not modify it.
2003-10-19 Carlos Perelló Marín <carlos@gnome.org> * support/*: Reverted libgtop changes. It's a common module and I should not modify it. * Added/removed files. Now the move should be done.
Diffstat (limited to 'sysdeps/sun4')
-rw-r--r--sysdeps/sun4/.cvsignore17
-rw-r--r--sysdeps/sun4/ChangeLog17
-rw-r--r--sysdeps/sun4/Makefile.am22
-rw-r--r--sysdeps/sun4/close.c30
-rw-r--r--sysdeps/sun4/cpu.c107
-rw-r--r--sysdeps/sun4/glibtop_machine.h117
-rw-r--r--sysdeps/sun4/glibtop_server.h49
-rw-r--r--sysdeps/sun4/glibtop_suid.h48
-rw-r--r--sysdeps/sun4/loadavg.c67
-rw-r--r--sysdeps/sun4/loadavg.h57
-rw-r--r--sysdeps/sun4/mem.c91
-rw-r--r--sysdeps/sun4/msg_limits.c75
-rw-r--r--sysdeps/sun4/nosuid.c35
-rw-r--r--sysdeps/sun4/open.c308
-rw-r--r--sysdeps/sun4/ppp.c44
-rw-r--r--sysdeps/sun4/procdata.c33
-rw-r--r--sysdeps/sun4/prockernel.c60
-rw-r--r--sysdeps/sun4/proclist.c97
-rw-r--r--sysdeps/sun4/procmem.c63
-rw-r--r--sysdeps/sun4/procsegment.c61
-rw-r--r--sysdeps/sun4/procsignal.c63
-rw-r--r--sysdeps/sun4/procstate.c60
-rw-r--r--sysdeps/sun4/proctime.c60
-rw-r--r--sysdeps/sun4/procuid.c71
-rw-r--r--sysdeps/sun4/sem_limits.c81
-rw-r--r--sysdeps/sun4/shm_limits.c74
-rw-r--r--sysdeps/sun4/siglist.c60
-rw-r--r--sysdeps/sun4/swap.c37
-rw-r--r--sysdeps/sun4/uptime.c61
29 files changed, 1965 insertions, 0 deletions
diff --git a/sysdeps/sun4/.cvsignore b/sysdeps/sun4/.cvsignore
new file mode 100644
index 00000000..dd420e7f
--- /dev/null
+++ b/sysdeps/sun4/.cvsignore
@@ -0,0 +1,17 @@
+.deps
+.libs
+Makefile
+Makefile.in
+close.lo
+cpu.lo
+libgtop_sysdeps.la
+loadavg.lo
+mem.lo
+msg_limits.lo
+open.lo
+proclist.lo
+sem_limits.lo
+shm_limits.lo
+swap.lo
+sysdeps.lo
+uptime.lo
diff --git a/sysdeps/sun4/ChangeLog b/sysdeps/sun4/ChangeLog
new file mode 100644
index 00000000..f05eac85
--- /dev/null
+++ b/sysdeps/sun4/ChangeLog
@@ -0,0 +1,17 @@
+2001-10-17 Abel Cheung <maddog@linux.org.hk>
+
+ * Makefile.am: move header to $(includedir)/libgtop-1.0/glibtop.
+
+1998-10-25 Martin Baulig <martin@home-of-linux.org>
+
+ * ppp.c: New file.
+
+1998-08-25 Martin Baulig <martin@home-of-linux.org>
+
+ * *.c (glibtop_init_p): Using correct `(1 << GLIBTOP_SYSDPES_*)'.
+ (<glibtop_suid.h>): Include.
+
+ * glibtop_suid.h: New file.
+
+ * ChangeLog: New file.
+
diff --git a/sysdeps/sun4/Makefile.am b/sysdeps/sun4/Makefile.am
new file mode 100644
index 00000000..87ac8c74
--- /dev/null
+++ b/sysdeps/sun4/Makefile.am
@@ -0,0 +1,22 @@
+LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
+
+INCLUDES = @INCLUDES@
+
+lib_LTLIBRARIES = libgtop_sysdeps-2.0.la libgtop_sysdeps_suid-2.0.la
+
+libgtop_sysdeps_2_0_la_SOURCES = nosuid.c siglist.c
+libgtop_sysdeps_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
+libgtop_sysdeps_2_0_la_LIBADD = -lkvm
+
+libgtop_sysdeps_suid_2_0_la_SOURCES = open.c close.c cpu.c mem.c swap.c \
+ uptime.c loadavg.c shm_limits.c msg_limits.c \
+ sem_limits.c proclist.c procstate.c procuid.c \
+ proctime.c procmem.c procsignal.c prockernel.c \
+ procsegment.c ppp.c
+libgtop_sysdeps_suid_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
+libgtop_sysdeps_suid_2_0_la_LIBADD = -lkvm
+
+libgtopinclude_HEADERS = glibtop_server.h glibtop_machine.h
+libgtopincludedir = $(includedir)/libgtop-2.0
+
+noinst_HEADERS = glibtop_suid.h
diff --git a/sysdeps/sun4/close.c b/sysdeps/sun4/close.c
new file mode 100644
index 00000000..a8733f0f
--- /dev/null
+++ b/sysdeps/sun4/close.c
@@ -0,0 +1,30 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop/close.h>
+
+/* Closes pipe to gtop server. */
+
+void
+glibtop_close_p (glibtop *server)
+{ }
diff --git a/sysdeps/sun4/cpu.c b/sysdeps/sun4/cpu.c
new file mode 100644
index 00000000..9c27e538
--- /dev/null
+++ b/sysdeps/sun4/cpu.c
@@ -0,0 +1,107 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/cpu.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_cpu =
+(1 << GLIBTOP_CPU_TOTAL) + (1 << GLIBTOP_CPU_USER) +
+(1 << GLIBTOP_CPU_NICE) + (1 << GLIBTOP_CPU_SYS) +
+(1 << GLIBTOP_CPU_IDLE) + (1 << GLIBTOP_CPU_FREQUENCY);
+
+/* Provides information about cpu usage. */
+
+void
+glibtop_get_cpu_p (glibtop *server, glibtop_cpu *buf)
+{
+ long cp_time [CPUSTATES], mp_time [NCPU][CPUSTATES];
+ int i;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_CPU), 0);
+
+ memset (buf, 0, sizeof (glibtop_cpu));
+
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+
+ glibtop_suid_enter (server);
+
+ /* get the cp_time array */
+
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_CP_TIME].n_value,
+ (int *) cp_time, sizeof (cp_time),
+ _glibtop_nlist [X_CP_TIME].n_name);
+
+#ifdef MULTIPROCESSOR
+ /* get the mp_time array as well */
+
+ if (server->machine.ncpu > 1) {
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_MP_TIME].n_value,
+ (int *) mp_time, sizeof (mp_time),
+ _glibtop_nlist [X_MP_TIME].n_name);
+ }
+#endif
+
+ glibtop_suid_leave (server);
+
+ /* !!! END OF SUID ROOT PART !!! */
+
+#ifdef MULTIPROCESSOR
+ /* If we have multiple processors, we add the times for each of them
+ * and set frequency to 100 times the number of the processors. */
+
+ /* [FIXME]: I had no machine with more than one processor to test
+ * this code !!! */
+
+ if (server->machine.ncpu > 1) {
+ for (i = 0; i < server->machine.ncpu; i++) {
+ buf->user += mp_time [i][CP_USER];
+ buf->nice += mp_time [i][CP_NICE];
+ buf->sys += mp_time [i][CP_SYS];
+ buf->idle += mp_time [i][CP_IDLE];
+ buf->frequency += 100;
+ }
+ } else {
+ buf->user = cp_time [CP_USER];
+ buf->nice = cp_time [CP_NICE];
+ buf->sys = cp_time [CP_SYS];
+ buf->idle = cp_time [CP_IDLE];
+ buf->frequency = 100;
+ }
+#else
+ buf->user = cp_time [CP_USER];
+ buf->nice = cp_time [CP_NICE];
+ buf->sys = cp_time [CP_SYS];
+ buf->idle = cp_time [CP_IDLE];
+ buf->frequency = 100;
+#endif
+
+ /* Calculate total time. */
+
+ buf->total = buf->user + buf->nice + buf->sys + buf->idle;
+
+ /* Now we can set the flags. */
+
+ buf->flags = _glibtop_sysdeps_cpu;
+}
diff --git a/sysdeps/sun4/glibtop_machine.h b/sysdeps/sun4/glibtop_machine.h
new file mode 100644
index 00000000..8ab56840
--- /dev/null
+++ b/sysdeps/sun4/glibtop_machine.h
@@ -0,0 +1,117 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __GLIBTOP_MACHINE_H__
+#define __GLIBTOP_MACHINE_H__
+
+/* make sure param.h gets loaded with KERNEL defined to get PZERO & NZERO */
+#define KERNEL
+#include <sys/param.h>
+#undef KERNEL
+
+#include <stdio.h>
+#include <kvm.h>
+#include <nlist.h>
+#include <math.h>
+#include <sys/dir.h>
+#include <sys/user.h>
+#include <sys/proc.h>
+#include <sys/dk.h>
+#include <sys/vm.h>
+#include <sys/file.h>
+#include <sys/time.h>
+#include <vm/page.h>
+
+#ifdef solbourne
+#include <sys/syscall.h>
+#endif
+
+#include "loadavg.h"
+
+BEGIN_LIBGTOP_DECLS
+
+/* Older versions of SunOS don't have a typedef for pid_t.
+ Hopefully this will catch all those cases without causing other problems.
+ */
+#ifndef __sys_stdtypes_h
+typedef int pid_t;
+#endif
+
+/* definitions for indices in the nlist array */
+#define X_AVENRUN 0
+#define X_CCPU 1
+#define X_MPID 2
+#define X_NPROC 3
+#define X_PROC 4
+#define X_TOTAL 5
+#define X_CP_TIME 6
+#define X_PAGES 7
+#define X_EPAGES 8
+#define X_SHMINFO 9
+#define X_MSGINFO 10
+#define X_SEMINFO 11
+
+#ifdef MULTIPROCESSOR
+#define X_NCPU 12
+#define X_MP_TIME 13
+#endif
+
+/* Log base 2 of 1024 is 10 (2^10 == 1024) */
+#define LOG1024 10
+
+typedef struct _glibtop_machine glibtop_machine;
+
+struct _glibtop_machine
+{
+ uid_t uid, euid; /* Real and effective user id */
+ gid_t gid, egid; /* Real and effective group id */
+ int nlist_count; /* Number of symbols in the nlist */
+ int ncpu; /* Number of CPUs we have */
+ int nproc; /* Number of entries in the process array */
+ size_t ptable_size; /* Size of process array. */
+ unsigned long ptable_offset; /* Offset of process array in kernel. */
+ struct proc *proc_table; /* Process array. */
+ unsigned long pages, epages;
+ struct page *physpage;
+ int bytesize, count;
+ int pageshift; /* log base 2 of the pagesize */
+ kvm_t *kd;
+};
+
+/* Those functions are used internally in libgtop */
+
+#ifdef _IN_LIBGTOP
+
+extern struct nlist _glibtop_nlist[];
+
+int _glibtop_check_nlist (void *server, register struct nlist *nlst);
+int _glibtop_getkval (void *void_server, unsigned long offset, int *ptr,
+ int size, char *refstr);
+void _glibtop_read_proc_table (void *void_server);
+struct proc *_glibtop_find_pid (void *void_server, pid_t pid);
+
+#endif
+
+END_LIBGTOP_DECLS
+
+#endif
diff --git a/sysdeps/sun4/glibtop_server.h b/sysdeps/sun4/glibtop_server.h
new file mode 100644
index 00000000..e631e43e
--- /dev/null
+++ b/sysdeps/sun4/glibtop_server.h
@@ -0,0 +1,49 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __GLIBTOP_SERVER_H__
+#define __GLIBTOP_SERVER_H__
+
+BEGIN_LIBGTOP_DECLS
+
+#define GLIBTOP_SUID_CPU (1 << GLIBTOP_SYSDEPS_CPU)
+#define GLIBTOP_SUID_MEM (1 << GLIBTOP_SYSDEPS_MEM)
+#define GLIBTOP_SUID_SWAP (1 << GLIBTOP_SYSDEPS_SWAP)
+#define GLIBTOP_SUID_UPTIME (1 << GLIBTOP_SYSDEPS_UPTIME)
+#define GLIBTOP_SUID_LOADAVG (1 << GLIBTOP_SYSDEPS_LOADAVG)
+#define GLIBTOP_SUID_SHM_LIMITS (1 << GLIBTOP_SYSDEPS_SHM_LIMITS)
+#define GLIBTOP_SUID_MSG_LIMITS (1 << GLIBTOP_SYSDEPS_MSG_LIMITS)
+#define GLIBTOP_SUID_SEM_LIMITS (1 << GLIBTOP_SYSDEPS_SEM_LIMITS)
+#define GLIBTOP_SUID_PROCLIST (1 << GLIBTOP_SYSDEPS_PROCLIST)
+#define GLIBTOP_SUID_PROC_STATE (1 << GLIBTOP_SYSDEPS_PROC_STATE)
+#define GLIBTOP_SUID_PROC_UID (1 << GLIBTOP_SYSDEPS_PROC_UID)
+#define GLIBTOP_SUID_PROC_MEM (1 << GLIBTOP_SYSDEPS_PROC_MEM)
+#define GLIBTOP_SUID_PROC_TIME (1 << GLIBTOP_SYSDEPS_PROC_TIME)
+#define GLIBTOP_SUID_PROC_SIGNAL (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL)
+#define GLIBTOP_SUID_PROC_KERNEL (1 << GLIBTOP_SYSDEPS_PROC_KERNEL)
+#define GLIBTOP_SUID_PROC_SEGMENT (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT)
+#define GLIBTOP_SUID_PROC_MAP (1 << GLIBTOP_SYSDEPS_PROC_MAP)
+
+END_LIBGTOP_DECLS
+
+#endif
diff --git a/sysdeps/sun4/glibtop_suid.h b/sysdeps/sun4/glibtop_suid.h
new file mode 100644
index 00000000..18d3b1d3
--- /dev/null
+++ b/sysdeps/sun4/glibtop_suid.h
@@ -0,0 +1,48 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __GLIBTOP_SUID_H__
+#define __GLIBTOP_SUID_H__
+
+BEGIN_LIBGTOP_DECLS
+
+static inline void glibtop_suid_enter (glibtop *server) {
+ setregid (server->machine.gid, server->machine.egid);
+};
+
+static inline void glibtop_suid_leave (glibtop *server) {
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
+};
+
+void
+glibtop_init_p (glibtop *server, const unsigned long features,
+ const unsigned flags);
+void
+glibtop_open_p (glibtop *server, const char *program_name,
+ const unsigned long features,
+ const unsigned flags);
+
+END_LIBGTOP_DECLS
+
+#endif
diff --git a/sysdeps/sun4/loadavg.c b/sysdeps/sun4/loadavg.c
new file mode 100644
index 00000000..530efb9a
--- /dev/null
+++ b/sysdeps/sun4/loadavg.c
@@ -0,0 +1,67 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/loadavg.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_loadavg =
+(1 << GLIBTOP_LOADAVG_LOADAVG);
+
+/* Provides load averange. */
+
+void
+glibtop_get_loadavg_p (glibtop *server, glibtop_loadavg *buf)
+{
+ load_avg avenrun [3];
+ int i;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_LOADAVG), 0);
+
+ memset (buf, 0, sizeof (glibtop_loadavg));
+
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+
+ setregid (server->machine.gid, server->machine.egid);
+
+ /* get the load average array */
+
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_AVENRUN].n_value,
+ (int *) avenrun, sizeof (avenrun),
+ _glibtop_nlist [X_AVENRUN].n_name);
+
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
+
+ /* !!! END OF SGID KMEM PART !!! */
+
+ for (i = 0; i < 3; i++) {
+ /* Calculate loadavg values from avenrun. */
+ buf->loadavg [i] = loaddouble (avenrun [i]);
+ }
+
+ /* Now we can set the flags. */
+
+ buf->flags = _glibtop_sysdeps_loadavg;
+}
diff --git a/sysdeps/sun4/loadavg.h b/sysdeps/sun4/loadavg.h
new file mode 100644
index 00000000..f49541e7
--- /dev/null
+++ b/sysdeps/sun4/loadavg.h
@@ -0,0 +1,57 @@
+/*
+ * Top - a top users display for Berkeley Unix
+ *
+ * Defines required to access load average figures.
+ *
+ * This include file sets up everything we need to access the load average
+ * values in the kernel in a machine independent way. First, it sets the
+ * typedef "load_avg" to be either double or long (depending on what is
+ * needed), then it defines these macros appropriately:
+ *
+ * loaddouble(la) - convert load_avg to double.
+ * intload(i) - convert integer to load_avg.
+ */
+
+/*
+ * We assume that if FSCALE is defined, then avenrun and ccpu are type long.
+ * If your machine is an exception (mips, perhaps?) then make adjustments
+ * here.
+ *
+ * Defined types: load_avg for load averages, pctcpu for cpu percentages.
+ */
+#if defined(mips) && !defined(NetBSD)
+# include <sys/fixpoint.h>
+# if defined(FBITS) && !defined(FSCALE)
+# define FSCALE (1 << FBITS) /* mips */
+# endif
+#endif
+
+#ifdef FSCALE
+# define FIXED_LOADAVG FSCALE
+# define FIXED_PCTCPU FSCALE
+#endif
+
+#ifdef ibm032
+# undef FIXED_LOADAVG
+# undef FIXED_PCTCPU
+# define FIXED_PCTCPU PCT_SCALE
+#endif
+
+
+#ifdef FIXED_PCTCPU
+ typedef long pctcpu;
+# define pctdouble(p) ((double)(p) / FIXED_PCTCPU)
+#else
+typedef double pctcpu;
+# define pctdouble(p) (p)
+#endif
+
+#ifdef FIXED_LOADAVG
+ typedef long load_avg;
+# define loaddouble(la) ((double)(la) / FIXED_LOADAVG)
+# define intload(i) ((int)((i) * FIXED_LOADAVG))
+#else
+ typedef double load_avg;
+# define loaddouble(la) (la)
+# define intload(i) ((double)(i))
+#endif
diff --git a/sysdeps/sun4/mem.c b/sysdeps/sun4/mem.c
new file mode 100644
index 00000000..6bbac96b
--- /dev/null
+++ b/sysdeps/sun4/mem.c
@@ -0,0 +1,91 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/mem.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_mem =
+(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
+(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_LOCKED);
+
+/* define pagetok in terms of pageshift */
+
+#define pagetok(size) ((size) << server->machine.pageshift)
+
+/* Provides information about memory usage. */
+
+void
+glibtop_get_mem_p (glibtop *server, glibtop_mem *buf)
+{
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MEM), 0);
+
+ memset (buf, 0, sizeof (glibtop_mem));
+
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+
+ glibtop_suid_enter (server);
+
+ /* get the array of physpage descriptors */
+
+ (void) _glibtop_getkval (server, server->machine.pages,
+ (int *) server->machine.physpage,
+ server->machine.bytesize,
+ "array _page");
+
+ glibtop_suid_leave (server);
+
+ /* !!! END OF SGID KMEM PART !!! */
+
+
+ { /* sum memory statistics */
+ register struct page *pp;
+ register int cnt;
+ register int inuse;
+ register int free;
+ register int locked;
+
+ /* bop thru the array counting page types */
+
+ pp = server->machine.physpage;
+ inuse = free = locked = 0;
+ for (cnt = server->machine.count; --cnt >= 0; pp++) {
+ if (pp->p_free)
+ free++;
+ else if (pp->p_lock || pp->p_keepcnt > 0)
+ locked++;
+ else
+ inuse++;
+ }
+
+ /* convert memory stats to Kbytes */
+
+ buf->total = pagetok (inuse + free);
+ buf->used = pagetok (inuse);
+ buf->free = pagetok (free);
+ buf->locked = pagetok (locked);
+
+ buf->flags = _glibtop_sysdeps_mem;
+ }
+}
diff --git a/sysdeps/sun4/msg_limits.c b/sysdeps/sun4/msg_limits.c
new file mode 100644
index 00000000..7a01740c
--- /dev/null
+++ b/sysdeps/sun4/msg_limits.c
@@ -0,0 +1,75 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/msg_limits.h>
+
+#include <glibtop_suid.h>
+
+/* #define KERNEL to get declaration of `struct msginfo'. */
+
+#define KERNEL
+
+#include <sys/ipc.h>
+#include <sys/msg.h>
+
+static const unsigned long _glibtop_sysdeps_msg_limits =
+(1 << GLIBTOP_IPC_MSGMAP) + (1 << GLIBTOP_IPC_MSGMAX) +
+(1 << GLIBTOP_IPC_MSGMNB) + (1 << GLIBTOP_IPC_MSGMNI) +
+(1 << GLIBTOP_IPC_MSGSSZ) + (1 << GLIBTOP_IPC_MSGTQL);
+
+/* Provides information about sysv ipc limits. */
+
+void
+glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
+{
+ struct msginfo msginfo;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_MSG_LIMITS), 0);
+
+ memset (buf, 0, sizeof (glibtop_msg_limits));
+
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+
+ setregid (server->machine.gid, server->machine.egid);
+
+ /* get the load average array */
+
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_MSGINFO].n_value,
+ (int *) &msginfo, sizeof (msginfo),
+ _glibtop_nlist [X_MSGINFO].n_name);
+
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
+
+ /* !!! END OF SGID KMEM PART !!! */
+
+ buf->msgmap = msginfo.msgmap;
+ buf->msgmax = msginfo.msgmax;
+ buf->msgmnb = msginfo.msgmnb;
+ buf->msgmni = msginfo.msgmni;
+ buf->msgssz = msginfo.msgssz;
+ buf->msgtql = msginfo.msgtql;
+
+ buf->flags = _glibtop_sysdeps_msg_limits;
+}
diff --git a/sysdeps/sun4/nosuid.c b/sysdeps/sun4/nosuid.c
new file mode 100644
index 00000000..cd52852c
--- /dev/null
+++ b/sysdeps/sun4/nosuid.c
@@ -0,0 +1,35 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/open.h>
+#include <glibtop/close.h>
+
+void
+glibtop_open_s (glibtop *server, const char *program_name,
+ const unsigned long features, const unsigned flags)
+{ }
+
+void
+glibtop_close_s (glibtop *server)
+{ }
diff --git a/sysdeps/sun4/open.c b/sysdeps/sun4/open.c
new file mode 100644
index 00000000..30fd3e1e
--- /dev/null
+++ b/sysdeps/sun4/open.c
@@ -0,0 +1,308 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/open.h>
+#include <glibtop/xmalloc.h>
+
+struct nlist _glibtop_nlist[] = {
+#ifdef i386
+ { "avenrun" }, /* 0 */
+ { "ccpu" }, /* 1 */
+ { "mpid" }, /* 2 */
+ { "nproc" }, /* 3 */
+ { "proc" }, /* 4 */
+ { "total" }, /* 5 */
+ { "cp_time" }, /* 6 */
+ { "pages" }, /* 7 */
+ { "epages" }, /* 8 */
+ { "shminfo" }, /* 9 */
+ { "msginfo" }, /* 10 */
+ { "seminfo" }, /* 11 */
+#else
+ { "_avenrun" }, /* 0 */
+ { "_ccpu" }, /* 1 */
+ { "_mpid" }, /* 2 */
+ { "_nproc" }, /* 3 */
+ { "_proc" }, /* 4 */
+ { "_total" }, /* 5 */
+ { "_cp_time" }, /* 6 */
+ { "_pages" }, /* 7 */
+ { "_epages" }, /* 8 */
+ { "_shminfo" }, /* 9 */
+ { "_msginfo" }, /* 10 */
+ { "_seminfo" }, /* 11 */
+#ifdef MULTIPROCESSOR
+ { "_ncpu" },
+ { "_mp_time" },
+#endif
+#endif
+ { 0 }
+};
+
+/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
+
+/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+
+void
+glibtop_init_p (glibtop *server, const unsigned long features,
+ const unsigned flags)
+{
+ if (server == NULL)
+ glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
+
+ glibtop_open_p (server, "glibtop", features, flags);
+}
+
+void
+glibtop_open_p (glibtop *server, const char *program_name,
+ const unsigned long features, const unsigned flags)
+{
+ register int pagesize;
+
+ /* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
+
+ server->name = program_name;
+
+ server->machine.uid = getuid ();
+ server->machine.euid = geteuid ();
+ server->machine.gid = getgid ();
+ server->machine.egid = getegid ();
+
+ /* initialize the kernel interface */
+
+ server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "libgtop");
+
+ if (server->machine.kd == NULL)
+ glibtop_error_io_r (server, "kvm_open");
+
+ /* get the list of symbols we want to access in the kernel */
+
+ server->machine.nlist_count = kvm_nlist
+ (server->machine.kd, _glibtop_nlist);
+
+ if (server->machine.nlist_count < 0)
+ glibtop_error_io_r (server, "nlist");
+
+#ifdef MULTIPROCESSOR
+ /* were ncpu and xp_time not found in the nlist? */
+
+ if ((server->machine.nlist_count > 0) &&
+ (_glibtop_nlist[X_NCPU].n_type == 0) &&
+ (_glibtop_nlist[X_MP_TIME].n_type == 0)) {
+ /* we were compiled on an MP system but we are not running
+ * on one, so we will pretend this didn't happen and set
+ * ncpu = 1 */
+ server->machine.nlist_count -= 2;
+ server->machine.ncpu = 1;
+ }
+#endif
+
+#ifdef solbourne
+ {
+ unsigned int status, type;
+
+ /* Get the number of CPUs on this system. */
+ syscall(SYS_getcpustatus, &status,
+ &server->machine.ncpu, &type);
+ }
+#endif
+
+ /* Make sure all of the symbols were found. */
+
+ if ((server->machine.nlist_count > 0) &&
+ (_glibtop_check_nlist (server, _glibtop_nlist) > 0))
+ _exit (1);
+
+ /* Get process array stuff. */
+
+ (void) _glibtop_getkval (server, _glibtop_nlist[X_NPROC].n_value,
+ (int *)(&server->machine.nproc),
+ sizeof (server->machine.nproc),
+ _glibtop_nlist[X_NPROC].n_name);
+
+ (void) _glibtop_getkval (server, _glibtop_nlist[X_PROC].n_value,
+ (int *)(&server->machine.ptable_offset),
+ sizeof (server->machine.ptable_offset),
+ _glibtop_nlist[X_PROC].n_name);
+
+ server->machine.ptable_size = (unsigned long) server->machine.nproc *
+ (unsigned long) sizeof (struct proc);
+
+ server->machine.proc_table = glibtop_malloc_r
+ (server, server->machine.ptable_size);
+
+ /* This are for the memory statistics. */
+
+ (void) _glibtop_getkval (server, _glibtop_nlist[X_PAGES].n_value,
+ (int *)(&server->machine.pages),
+ sizeof (server->machine.pages),
+ _glibtop_nlist[X_PAGES].n_name);
+
+ (void) _glibtop_getkval (server, _glibtop_nlist[X_EPAGES].n_value,
+ (int *)(&server->machine.epages),
+ sizeof (server->machine.epages),
+ _glibtop_nlist[X_EPAGES].n_name);
+
+ server->machine.bytesize = server->machine.epages -
+ server->machine.pages;
+ server->machine.count = server->machine.bytesize /
+ sizeof (struct page);
+
+ server->machine.physpage = (struct page *)
+ glibtop_malloc_r (server, server->machine.bytesize);
+
+ /* get the page size with "getpagesize" and
+ * calculate pageshift from it */
+
+ pagesize = getpagesize();
+
+ server->machine.pageshift = 0;
+
+ while (pagesize > 1) {
+ server->machine.pageshift++;
+ pagesize >>= 1;
+ }
+
+ /* we only need the amount of log(2)1024 for our conversion */
+
+ server->machine.pageshift -= LOG1024;
+
+ /* Drop priviledges. */
+
+ if (setreuid (server->machine.euid, server->machine.uid))
+ _exit (1);
+
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
+
+ /* !!! END OF SUID ROOT PART !!! */
+
+ /* Our effective uid is now those of the user invoking the server,
+ * so we do no longer have any priviledges. */
+
+ /* NOTE: On SunOS, we do not need to be suid root, we just need to
+ * be sgid kmem.
+ *
+ * The server will only use setegid() to get back it's priviledges,
+ * so it will fail if it is suid root and not sgid kmem. */
+}
+
+/* Used internally. Returns number of symbols that cannot be found in
+ * the nlist. */
+
+int
+_glibtop_check_nlist (void *server, register struct nlist *nlst)
+{
+ register int not_found;
+
+ /* check to see if we got ALL the symbols we requested */
+ /* this will write one line to stderr for every symbol not found */
+
+ not_found = 0;
+
+ while (nlst->n_name != NULL) {
+
+#ifdef i386
+ if (nlst->n_value == 0) {
+ glibtop_error_r (server,
+ "kernel: no symbol named `%s'",
+ nlst->n_name);
+ not_found++;
+ }
+#else
+ if (nlst->n_type == 0) {
+ glibtop_error_r (server,
+ "kernel: no symbol named `%s'",
+ nlst->n_name);
+ not_found++;
+ }
+#endif
+
+ nlst++;
+ }
+
+ return not_found;
+}
+
+/* Used internally. Fetches value from kernel. */
+
+int
+_glibtop_getkval (void *void_server, unsigned long offset, int *ptr,
+ int size, char *refstr)
+{
+ glibtop *server = (glibtop *) void_server;
+
+ if (kvm_read (server->machine.kd, offset, ptr, size) != size)
+ {
+ if (*refstr == '!') return 0;
+
+ glibtop_error_r (server, "kvm_read(%s): %s",
+ refstr, strerror (errno));
+ }
+
+ return 1;
+}
+
+/* Used internally. Reads process table from kernel. */
+
+void
+_glibtop_read_proc_table (void *void_server)
+{
+ glibtop *server = (glibtop *) void_server;
+
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+
+ setregid (server->machine.gid, server->machine.egid);
+
+ /* Read process table from kernel. */
+
+ (void) _glibtop_getkval (server, server->machine.ptable_offset,
+ (int *) server->machine.proc_table,
+ (size_t) server->machine.ptable_size,
+ _glibtop_nlist[X_PROC].n_name);
+
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
+
+ /* !!! END OF SGID KMEM PART !!! */
+}
+
+/* Used internally. Finds pid in process table. */
+
+struct proc *
+_glibtop_find_pid (void *void_server, pid_t pid)
+{
+ register struct proc *pp;
+ register int i;
+
+ glibtop *server = (glibtop *) void_server;
+
+ for (pp = server->machine.proc_table, i = 0;
+ i < server->machine.nproc; pp++, i++) {
+ if ((pp->p_stat != 0) && (pp->p_pid == pid))
+ return pp;
+ }
+
+ return NULL;
+}
diff --git a/sysdeps/sun4/ppp.c b/sysdeps/sun4/ppp.c
new file mode 100644
index 00000000..6d0905d5
--- /dev/null
+++ b/sysdeps/sun4/ppp.c
@@ -0,0 +1,44 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, October 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/error.h>
+#include <glibtop/ppp.h>
+
+static const unsigned long _glibtop_sysdeps_ppp = 0;
+
+/* Init function. */
+
+void
+glibtop_init_ppp_s (glibtop *server)
+{
+ server->sysdeps.ppp = _glibtop_sysdeps_ppp;
+}
+
+/* Provides PPP/ISDN information. */
+
+void
+glibtop_get_ppp_s (glibtop *server, glibtop_ppp *buf, unsigned short device)
+{
+ memset (buf, 0, sizeof (glibtop_ppp));
+}
diff --git a/sysdeps/sun4/procdata.c b/sysdeps/sun4/procdata.c
new file mode 100644
index 00000000..50756730
--- /dev/null
+++ b/sysdeps/sun4/procdata.c
@@ -0,0 +1,33 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+#include <glibtop/procdata.h>
+
+/* Provides detailed information about a process. */
+
+void
+glibtop_get_procdata_p (glibtop *server, glibtop_procdata *buf, pid_t pid)
+{
+ memset (buf, 0, sizeof (glibtop_procdata));
+}
diff --git a/sysdeps/sun4/prockernel.c b/sysdeps/sun4/prockernel.c
new file mode 100644
index 00000000..603e881b
--- /dev/null
+++ b/sysdeps/sun4/prockernel.c
@@ -0,0 +1,60 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/prockernel.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_proc_kernel =
+(1 << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1 << GLIBTOP_PROC_KERNEL_WCHAN);
+
+/* Provides detailed information about a process. */
+
+void
+glibtop_get_proc_kernel_p (glibtop *server, glibtop_proc_kernel *buf,
+ pid_t pid)
+{
+ struct proc *pp;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_KERNEL), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_kernel));
+
+ /* Read process table from kernel. */
+
+ _glibtop_read_proc_table (server);
+
+ /* Find the pid in the process table. */
+
+ pp = _glibtop_find_pid (server, pid);
+
+ if (pp == NULL) return;
+
+ /* Fill in data fields. */
+
+ buf->k_flags = pp->p_flag;
+ buf->nwchan = (unsigned long) pp->p_wchan;
+
+ buf->flags = _glibtop_sysdeps_proc_kernel;
+}
diff --git a/sysdeps/sun4/proclist.c b/sysdeps/sun4/proclist.c
new file mode 100644
index 00000000..4b6fc42e
--- /dev/null
+++ b/sysdeps/sun4/proclist.c
@@ -0,0 +1,97 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/xmalloc.h>
+#include <glibtop/proclist.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_proclist =
+(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) +
+(1 << GLIBTOP_PROCLIST_SIZE);
+
+/* Fetch list of currently running processes.
+ *
+ * IMPORTANT NOTE:
+ * On error, this function MUST return NULL and set buf->flags to zero !
+ * On success, it returnes a pointer to a list of buf->number elements
+ * each buf->size big. The total size is stored in buf->total. */
+
+unsigned *
+glibtop_get_proclist_p (glibtop *server, glibtop_proclist *buf,
+ int64_t which, int64_t arg)
+{
+ register struct proc *pp;
+ register int i, nproc = 0;
+ unsigned *proc_list = NULL;
+ size_t proc_size;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROCLIST), 0);
+
+ memset (buf, 0, sizeof (glibtop_proclist));
+
+ /* Read process table from kernel. */
+
+ _glibtop_read_proc_table (server);
+
+ /* Count number of processes. */
+
+ for (pp = server->machine.proc_table, i = 0;
+ i < server->machine.nproc; pp++, i++) {
+ if (pp->p_stat == 0)
+ continue;
+ else
+ nproc++;
+ }
+
+ if (nproc == 0) /* Should never happen. */
+ return NULL;
+
+ /* Allocate space for process list. */
+
+ proc_size = nproc * sizeof (unsigned);
+
+ proc_list = glibtop_malloc_r (server, proc_size);
+
+ /* Write process list. */
+
+ for (pp = server->machine.proc_table, i = 0, nproc = 0;
+ i < server->machine.nproc; pp++, i++) {
+ if (pp->p_stat == 0)
+ continue;
+ proc_list [nproc++] = pp->p_pid;
+ }
+
+ /* Since everything is ok now, we can set buf->flags, fill in the remaining fields
+ and return proc_list. */
+
+ buf->flags = _glibtop_sysdeps_proclist;
+
+ buf->size = sizeof (unsigned);
+ buf->number = nproc;
+
+ buf->total = nproc * sizeof (unsigned);
+
+ return proc_list;
+}
diff --git a/sysdeps/sun4/procmem.c b/sysdeps/sun4/procmem.c
new file mode 100644
index 00000000..979fc7af
--- /dev/null
+++ b/sysdeps/sun4/procmem.c
@@ -0,0 +1,63 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <config.h>
+#include <glibtop/procmem.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_proc_mem =
+(1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_RSS) +
+(1 << GLIBTOP_PROC_MEM_RSS_RLIM);
+
+/* Provides detailed information about a process. */
+
+void
+glibtop_get_proc_mem_p (glibtop *server, glibtop_proc_mem *buf,
+ pid_t pid)
+{
+ struct proc *pp;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_MEM), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_mem));
+
+ /* Read process table from kernel. */
+
+ _glibtop_read_proc_table (server);
+
+ /* Find the pid in the process table. */
+
+ pp = _glibtop_find_pid (server, pid);
+
+ if (pp == NULL) return;
+
+ /* Fill in data fields. */
+
+ buf->size = (pp)->p_tsize + (pp)->p_dsize + (pp)->p_ssize;
+
+ buf->rss = pp->p_rssize;
+ buf->rss_rlim = pp->p_maxrss;
+
+ buf->flags = _glibtop_sysdeps_proc_mem;
+}
diff --git a/sysdeps/sun4/procsegment.c b/sysdeps/sun4/procsegment.c
new file mode 100644
index 00000000..8dd64bea
--- /dev/null
+++ b/sysdeps/sun4/procsegment.c
@@ -0,0 +1,61 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/procsegment.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_proc_segment =
+(1 << GLIBTOP_PROC_SEGMENT_TEXT_RSS) +
+(1 << GLIBTOP_PROC_SEGMENT_DATA_RSS);
+
+/* Provides detailed information about a process. */
+
+void
+glibtop_get_proc_segment_p (glibtop *server, glibtop_proc_segment *buf,
+ pid_t pid)
+{
+ struct proc *pp;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_SEGMENT), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_segment));
+
+ /* Read process table from kernel. */
+
+ _glibtop_read_proc_table (server);
+
+ /* Find the pid in the process table. */
+
+ pp = _glibtop_find_pid (server, pid);
+
+ if (pp == NULL) return;
+
+ /* Fill in data fields. */
+
+ buf->text_rss = pp->p_tsize;
+ buf->data_rss = pp->p_dsize;
+
+ buf->flags = _glibtop_sysdeps_proc_segment;
+}
diff --git a/sysdeps/sun4/procsignal.c b/sysdeps/sun4/procsignal.c
new file mode 100644
index 00000000..66a5a2bc
--- /dev/null
+++ b/sysdeps/sun4/procsignal.c
@@ -0,0 +1,63 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/procsignal.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_proc_signal =
+(1 << GLIBTOP_PROC_SIGNAL_SIGNAL) + (1 << GLIBTOP_PROC_SIGNAL_BLOCKED) +
+(1 << GLIBTOP_PROC_SIGNAL_SIGIGNORE) + (1 << GLIBTOP_PROC_SIGNAL_SIGCATCH);
+
+/* Provides detailed information about a process. */
+
+void
+glibtop_get_proc_signal_p (glibtop *server, glibtop_proc_signal *buf,
+ pid_t pid)
+{
+ struct proc *pp;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_SIGNAL), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_signal));
+
+ /* Read process table from kernel. */
+
+ _glibtop_read_proc_table (server);
+
+ /* Find the pid in the process table. */
+
+ pp = _glibtop_find_pid (server, pid);
+
+ if (pp == NULL) return;
+
+ /* Fill in data fields. */
+
+ buf->signal [0] = pp->p_sig;
+ buf->blocked [0] = pp->p_sigmask;
+ buf->sigignore [0] = pp->p_sigignore;
+ buf->sigcatch [0] = pp->p_sigcatch;
+
+ buf->flags = _glibtop_sysdeps_proc_signal;
+}
diff --git a/sysdeps/sun4/procstate.c b/sysdeps/sun4/procstate.c
new file mode 100644
index 00000000..4ce3734d
--- /dev/null
+++ b/sysdeps/sun4/procstate.c
@@ -0,0 +1,60 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/procstate.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_proc_state =
+(1 << GLIBTOP_PROC_STATE_STATE) + (1 << GLIBTOP_PROC_STATE_UID);
+
+/* Provides detailed information about a process. */
+
+void
+glibtop_get_proc_state_p (glibtop *server, glibtop_proc_state *buf,
+ pid_t pid)
+{
+ struct proc *pp;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_STATE), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_state));
+
+ /* Read process table from kernel. */
+
+ _glibtop_read_proc_table (server);
+
+ /* Find the pid in the process table. */
+
+ pp = _glibtop_find_pid (server, pid);
+
+ if (pp == NULL) return;
+
+ /* Fill in data fields. */
+
+ buf->state = pp->p_stat;
+ buf->uid = pp->p_uid;
+
+ buf->flags = _glibtop_sysdeps_proc_state;
+}
diff --git a/sysdeps/sun4/proctime.c b/sysdeps/sun4/proctime.c
new file mode 100644
index 00000000..9541f948
--- /dev/null
+++ b/sysdeps/sun4/proctime.c
@@ -0,0 +1,60 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/proctime.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_proc_time =
+(1 << GLIBTOP_PROC_TIME_START_TIME) + (1 << GLIBTOP_PROC_TIME_UTIME);
+
+/* Provides detailed information about a process. */
+
+void
+glibtop_get_proc_time_p (glibtop *server, glibtop_proc_time *buf,
+ pid_t pid)
+{
+ struct proc *pp;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_TIME), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_time));
+
+ /* Read process table from kernel. */
+
+ _glibtop_read_proc_table (server);
+
+ /* Find the pid in the process table. */
+
+ pp = _glibtop_find_pid (server, pid);
+
+ if (pp == NULL) return;
+
+ /* Fill in data fields. */
+
+ buf->start_time = pp->p_time;
+ buf->utime = pp->p_cpticks;
+
+ buf->flags = _glibtop_sysdeps_proc_time;
+}
diff --git a/sysdeps/sun4/procuid.c b/sysdeps/sun4/procuid.c
new file mode 100644
index 00000000..5ff0e5bf
--- /dev/null
+++ b/sysdeps/sun4/procuid.c
@@ -0,0 +1,71 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/procuid.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_proc_uid =
+(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) +
+(1 << GLIBTOP_PROC_UID_EGID) + (1 << GLIBTOP_PROC_UID_PID) +
+(1 << GLIBTOP_PROC_UID_PPID) + (1 << GLIBTOP_PROC_UID_PGRP) +
+(1 << GLIBTOP_PROC_UID_TPGID) + (1 << GLIBTOP_PROC_UID_PRIORITY) +
+(1 << GLIBTOP_PROC_UID_NICE);
+
+/* Provides detailed information about a process. */
+
+void
+glibtop_get_proc_uid_p (glibtop *server, glibtop_proc_uid *buf,
+ pid_t pid)
+{
+ struct proc *pp;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_PROC_UID), 0);
+
+ memset (buf, 0, sizeof (glibtop_proc_uid));
+
+ /* Read process table from kernel. */
+
+ _glibtop_read_proc_table (server);
+
+ /* Find the pid in the process table. */
+
+ pp = _glibtop_find_pid (server, pid);
+
+ if (pp == NULL) return;
+
+ /* Fill in data fields. */
+
+ buf->uid = pp->p_uid;
+ buf->euid = pp->p_suid;
+ buf->egid = pp->p_sgid;
+ buf->pid = pp->p_pid;
+ buf->ppid = pp->p_ppid;
+ buf->pgrp = pp->p_pgrp;
+ buf->tpgid = pp->p_pgrp;
+ buf->priority = pp->p_pri;
+ buf->nice = pp->p_nice;
+
+ buf->flags = _glibtop_sysdeps_proc_uid;
+}
diff --git a/sysdeps/sun4/sem_limits.c b/sysdeps/sun4/sem_limits.c
new file mode 100644
index 00000000..e6f07c6c
--- /dev/null
+++ b/sysdeps/sun4/sem_limits.c
@@ -0,0 +1,81 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/sem_limits.h>
+
+#include <glibtop_suid.h>
+
+/* #define KERNEL to get declaration of `struct seminfo'. */
+
+#define KERNEL
+
+#include <sys/ipc.h>
+#include <sys/sem.h>
+
+static unsigned long _glibtop_sysdeps_sem_limits =
+(1 << GLIBTOP_IPC_SEMMAP) + (1 << GLIBTOP_IPC_SEMMNI) +
+(1 << GLIBTOP_IPC_SEMMNS) + (1 << GLIBTOP_IPC_SEMMNU) +
+(1 << GLIBTOP_IPC_SEMMSL) + (1 << GLIBTOP_IPC_SEMOPM) +
+(1 << GLIBTOP_IPC_SEMUME) + (1 << GLIBTOP_IPC_SEMUSZ) +
+(1 << GLIBTOP_IPC_SEMVMX) + (1 << GLIBTOP_IPC_SEMAEM);
+
+/* Provides information about sysv sem limits. */
+
+void
+glibtop_get_sem_limits_p (glibtop *server, glibtop_sem_limits *buf)
+{
+ struct seminfo seminfo;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SEM_LIMITS), 0);
+
+ memset (buf, 0, sizeof (glibtop_sem_limits));
+
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+
+ setregid (server->machine.gid, server->machine.egid);
+
+ /* get the load average array */
+
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_SEMINFO].n_value,
+ (int *) &seminfo, sizeof (seminfo),
+ _glibtop_nlist [X_SEMINFO].n_name);
+
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
+
+ /* !!! END OF SGID KMEM PART !!! */
+
+ buf->semmap = seminfo.semmap;
+ buf->semmni = seminfo.semmni;
+ buf->semmns = seminfo.semmns;
+ buf->semmnu = seminfo.semmnu;
+ buf->semmsl = seminfo.semmsl;
+ buf->semopm = seminfo.semopm;
+ buf->semume = seminfo.semume;
+ buf->semusz = seminfo.semusz;
+ buf->semvmx = seminfo.semvmx;
+ buf->semaem = seminfo.semaem;
+
+ buf->flags = _glibtop_sysdeps_sem_limits;
+}
diff --git a/sysdeps/sun4/shm_limits.c b/sysdeps/sun4/shm_limits.c
new file mode 100644
index 00000000..a5f638f2
--- /dev/null
+++ b/sysdeps/sun4/shm_limits.c
@@ -0,0 +1,74 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/shm_limits.h>
+
+#include <glibtop_suid.h>
+
+/* #define KERNEL to get declaration of `struct shminfo'. */
+
+#define KERNEL
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
+static unsigned long _glibtop_sysdeps_shm_limits =
+(1 << GLIBTOP_IPC_SHMMAX) + (1 << GLIBTOP_IPC_SHMMIN) +
+(1 << GLIBTOP_IPC_SHMMNI) + (1 << GLIBTOP_IPC_SHMSEG) +
+(1 << GLIBTOP_IPC_SHMALL);
+
+/* Provides information about sysv ipc limits. */
+
+void
+glibtop_get_shm_limits_p (glibtop *server, glibtop_shm_limits *buf)
+{
+ struct shminfo shminfo;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SHM_LIMITS), 0);
+
+ memset (buf, 0, sizeof (glibtop_shm_limits));
+
+ /* !!! THE FOLLOWING CODE RUNS SGID KMEM - CHANGE WITH CAUTION !!! */
+
+ setregid (server->machine.gid, server->machine.egid);
+
+ /* get the load average array */
+
+ (void) _glibtop_getkval (server, _glibtop_nlist [X_SHMINFO].n_value,
+ (int *) &shminfo, sizeof (shminfo),
+ _glibtop_nlist [X_SHMINFO].n_name);
+
+ if (setregid (server->machine.egid, server->machine.gid))
+ _exit (1);
+
+ /* !!! END OF SGID KMEM PART !!! */
+
+ buf->shmmax = shminfo.shmmax;
+ buf->shmmin = shminfo.shmmin;
+ buf->shmmni = shminfo.shmmni;
+ buf->shmseg = shminfo.shmseg;
+ buf->shmall = shminfo.shmall;
+
+ buf->flags = _glibtop_sysdeps_shm_limits;
+}
diff --git a/sysdeps/sun4/siglist.c b/sysdeps/sun4/siglist.c
new file mode 100644
index 00000000..c5bd59c0
--- /dev/null
+++ b/sysdeps/sun4/siglist.c
@@ -0,0 +1,60 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/signal.h>
+
+const glibtop_signame glibtop_sys_siglist [] =
+{ { 1, "SIGHUP", N_("Hangup") },
+ { 2, "SIGINT", N_("Interrupt") },
+ { 3, "SIGQUIT", N_("Quit") },
+ { 4, "SIGILL", N_("Illegal instruction") },
+ { 5, "SIGTRAP", N_("Trace trap") },
+ { 6, "SIGABRT", N_("Abort") },
+ { 7, "SIGEMT", N_("EMT error") },
+ { 8, "SIGFPE", N_("Floating-point exception") },
+ { 9, "SIGKILL", N_("Kill") },
+ { 10, "SIGBUS", N_("Bus error") },
+ { 11, "SIGSEGV", N_("Segmentation violation") },
+ { 12, "SIGSYS", N_("Bad argument to system call") },
+ { 13, "SIGPIPE", N_("Broken pipe") },
+ { 14, "SIGALRM", N_("Alarm clock") },
+ { 15, "SIGTERM", N_("Termination") },
+ { 16, "SIGURG", N_("Urgent condition on socket") },
+ { 17, "SIGSTOP", N_("Stop") },
+ { 18, "SIGTSTP", N_("Keyboard stop") },
+ { 19, "SIGCONT", N_("Continue") },
+ { 20, "SIGCHLD", N_("Child status has changed") },
+ { 21, "SIGTTIN", N_("Background read from tty") },
+ { 22, "SIGTTOU", N_("Background write to tty") },
+ { 23, "SIGIO", N_("I/O now possible") },
+ { 24, "SIGXCPU", N_("CPU limit exceeded") },
+ { 25, "SIGXFSZ", N_("File size limit exceeded") },
+ { 26, "SIGVTALRM", N_("Virtual alarm clock") },
+ { 27, "SIGPROF", N_("Profiling alarm clock") },
+ { 28, "SIGWINCH", N_("Window size change") },
+ { 29, "SIGINFO", N_("Information request") },
+ { 30, "SIGUSR1", N_("User defined signal 1") },
+ { 31, "SIGUSR2", N_("User defined signal 2") },
+ { 0, NULL, NULL },
+};
diff --git a/sysdeps/sun4/swap.c b/sysdeps/sun4/swap.c
new file mode 100644
index 00000000..3c93e3a7
--- /dev/null
+++ b/sysdeps/sun4/swap.c
@@ -0,0 +1,37 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/swap.h>
+
+#include <glibtop_suid.h>
+
+/* Provides information about swap usage. */
+
+void
+glibtop_get_swap_p (glibtop *server, glibtop_swap *buf)
+{
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_SWAP), 0);
+
+ memset (buf, 0, sizeof (glibtop_swap));
+}
diff --git a/sysdeps/sun4/uptime.c b/sysdeps/sun4/uptime.c
new file mode 100644
index 00000000..023cf3f3
--- /dev/null
+++ b/sysdeps/sun4/uptime.c
@@ -0,0 +1,61 @@
+/* $Id$ */
+
+/* Copyright (C) 1998-99 Martin Baulig
+ This file is part of LibGTop 1.0.
+
+ Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
+
+ LibGTop is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ LibGTop is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with LibGTop; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <glibtop.h>
+#include <glibtop/cpu.h>
+#include <glibtop/uptime.h>
+
+#include <glibtop_suid.h>
+
+static const unsigned long _glibtop_sysdeps_uptime =
+(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME);
+
+/* Provides uptime and idle time. */
+
+void
+glibtop_get_uptime_p (glibtop *server, glibtop_uptime *buf)
+{
+ glibtop_cpu cpu;
+
+ glibtop_init_p (server, (1 << GLIBTOP_SYSDEPS_UPTIME), 0);
+
+ /* Get currect cpu usage. */
+
+ glibtop_get_cpu_p (server, &cpu);
+
+ /* Make sure all required fields are present. */
+
+ if (((cpu.flags & (1 << GLIBTOP_CPU_TOTAL)) == 0) ||
+ ((cpu.flags & (1 << GLIBTOP_CPU_IDLE)) == 0) ||
+ ((cpu.flags & (1 << GLIBTOP_CPU_FREQUENCY)) == 0) ||
+ (cpu.frequency == 0))
+ return;
+
+ /* Simply calculate uptime and idle time from
+ * cpu usage. */
+
+ buf->uptime = (double) cpu.total / (double) cpu.frequency;
+ buf->idletime = (double) cpu.idle / (double) cpu.frequency;
+
+ buf->flags = _glibtop_sysdeps_uptime;
+}