Compare commits

..

16 Commits

Author SHA1 Message Date
Martin Baulig
b56c327ccc This new system call now provides all information required for libgtop. 1998-06-14 12:29:52 +00:00
Martin Baulig
8f43551d68 New file - declaration of the table () function via _syscall3 (); due to a
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* kernel.s: New file - declaration of the table () function
	via _syscall3 (); due to a bug in egcs, we cannot put this
	into a C file.
1998-06-14 12:19:18 +00:00
Martin Baulig
23cccaf87f Removed declararion of table () function again. 1998-06-14 12:18:39 +00:00
Martin Baulig
c75b77affc Removed deleted files. 1998-06-14 02:30:25 +00:00
Martin Baulig
7ffc53f45e *** empty log message *** 1998-06-14 02:26:32 +00:00
Martin Baulig
6ea7e47194 New tag.
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* acconfig.h (HAVE_LINUX_TABLE): New tag.
1998-06-14 02:23:25 +00:00
Martin Baulig
6130f0a4f9 New file. Creates lib.c' depending upon features.def'.
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* lib/lib.awk: New file.
	Creates `lib.c' depending upon `features.def'.

	* lib/<feature>.c: Removed.
1998-06-14 02:13:50 +00:00
Martin Baulig
44dcb69c41 Added missing `const'. 1998-06-14 01:01:24 +00:00
Martin Baulig
13148c632f New file. Creates gulie.c' depending upon features.def'.
1998-06-14  Martin Baulig  <martin@home-of-linux.org>

	* sysdeps/guile/guile.awk: New file.
	Creates `gulie.c' depending upon `features.def'.

	* sysdeps/guile/*.c: Removed.
1998-06-14 00:57:03 +00:00
Martin Baulig
6fd3c113ec List of features for `guile-names.awk'.
1998-06-13  Martin Baulig  <martin@home-of-linux.org>

	* features.def: List of features for `guile-names.awk'.

	* sysdeps/guile/names/guile-names.awk: New file.
	Creates `guile-names.c' depending upon `features.def'.

	* sysdeps/guile/names/*.c: Removed.
1998-06-13 22:53:55 +00:00
Martin Baulig
9661c4becc New directory. Contains some kernel code to implement a new system call
1998-06-13  Martin Baulig  <martin@home-of-linux.org>

	* kernel: New directory. Contains some kernel code to
	implement a new system call table () to fetch information
	directly from the Linux kernel.

	* sysdeps/kernel: New directory. Uses the table () function
	from the `kernel' directory to fetch things directly from
	the Linux kernel.

	* sysdeps/Makefile.am (DIST_SUBDIRS): Added `kernel'.

	* configure.in: Removed `build_CC' again.
1998-06-13 21:26:49 +00:00
Martin Baulig
c60d1d5449 The code in this directory fetches all information directly from the
1998-06-13  Martin Baulig  <martin@home-of-linux.org>

	The code in this directory fetches all information
	directly from the kernel. It uses the new table ()
	system call from the `kernel' directory.
1998-06-13 21:20:48 +00:00
Martin Baulig
eedc64096c New file.
1998-06-12  Martin Baulig  <martin@home-of-linux.org>

	* test.scm: New file.
1998-06-12 00:41:00 +00:00
Martin Baulig
cf8068049f Forgot to change declaration on Jun 6.
1998-06-12  Martin Baulig  <baulig@taurus.uni-trier.de>

	* include/glibtop/sysdeps.h (glibtop_types_sysdeps):
	Forgot to change declaration on Jun 6.

	* sysdeps/names/sysdeps.c (glibtop_types_sysdeps):
	Using numeric constants from `types.h' instead of string
	constants; forgot to change this on Jun 6. Added information
	about new `features' field of `_glibtop_sysdeps'.
1998-06-12 00:40:17 +00:00
Martin Baulig
5e3d6bdf18 Merged bug fixes from stable branch. 1998-06-11 23:56:06 +00:00
Martin Baulig
aff6786e71 Replaced call to gh_append2 ()' with gh_append ()'.
1998-06-12  Martin Baulig  <baulig@taurus.uni-trier.de>

	* sysdeps/guile/proclist.c: Replaced call to
	`gh_append2 ()' with `gh_append ()'.

	* sysdeps/guile/names/*.c: dito.
1998-06-11 23:03:07 +00:00
86 changed files with 2034 additions and 2782 deletions

View File

@@ -1,3 +1,56 @@
1998-06-14 Martin Baulig <martin@home-of-linux.org>
* acconfig.h (HAVE_LINUX_TABLE): New tag.
* lib/lib.awk: New file.
Creates `lib.c' depending upon `features.def'.
* lib/<feature>.c: Removed.
* sysdeps/guile/guile.awk: New file.
Creates `guile.c' depending upon `features.def'.
* sysdeps/guile/*.c: Removed.
1998-06-13 Martin Baulig <martin@home-of-linux.org>
* features.def: List of features for `guile-names.awk'.
* sysdeps/guile/names/guile-names.awk: New file.
Creates `guile-names.c' depending upon `features.def'.
* sysdeps/guile/names/*.c: Removed.
* kernel: New directory. Contains some kernel code to
implement a new system call table () to fetch information
directly from the Linux kernel.
* sysdeps/kernel: New directory. Uses the table () function
from the `kernel' directory to fetch things directly from
the Linux kernel.
* sysdeps/Makefile.am (DIST_SUBDIRS): Added `kernel'.
* configure.in: Removed `build_CC' again.
1998-06-12 Martin Baulig <baulig@taurus.uni-trier.de>
* include/glibtop/sysdeps.h (glibtop_types_sysdeps):
Forgot to change declaration on Jun 6.
* sysdeps/names/sysdeps.c (glibtop_types_sysdeps):
Using numeric constants from `types.h' instead of string
constants; forgot to change this on Jun 6. Added information
about new `features' field of `_glibtop_sysdeps'.
* sysdeps/guile/names/*.c (glibtop_guile_types_*):
Using `gh_ulong2scm' instead of `gh_str02scm'.
* sysdeps/guile/proclist.c: Replaced call to
`gh_append2 ()' with `gh_append ()'.
* sysdeps/guile/names/*.c: dito.
1998-06-08 Martin Baulig <martin@home-of-linux.org> 1998-06-08 Martin Baulig <martin@home-of-linux.org>
* support: Added again. * support: Added again.

View File

@@ -33,3 +33,5 @@
#undef GLIBTOP_EXAMPLES #undef GLIBTOP_EXAMPLES
#undef NEED_LIBGTOP #undef NEED_LIBGTOP
#undef HAVE_LINUX_TABLE

View File

@@ -8,23 +8,12 @@ AC_CANONICAL_SYSTEM
AM_ACLOCAL_INCLUDE(macros) AM_ACLOCAL_INCLUDE(macros)
dnl This is necessary for cross-compiling for programs
dnl that need to run on the build host.
AC_CHECK_PROG(build_CC, gcc, gcc)
if test -z "$build_CC" ; then
AC_CHECK_PROG(build_CC, cc, cc, , , /usr/ucb/cc)
test -z "$build_CC" && \
AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
AC_CHECK_TOOL(CC,gcc)
AC_ISC_POSIX AC_ISC_POSIX
AC_PROG_CC AC_PROG_CC
AC_STDC_HEADERS AC_STDC_HEADERS
AC_ARG_PROGRAM AC_ARG_PROGRAM
AC_CHECK_TOOL(CC,gcc)
AC_CHECK_TOOL(RANLIB,ranlib) AC_CHECK_TOOL(RANLIB,ranlib)
AC_CHECK_TOOL(AS,as) AC_CHECK_TOOL(AS,as)
AC_CHECK_TOOL(AR,ar) AC_CHECK_TOOL(AR,ar)
@@ -226,6 +215,7 @@ sysdeps/stub/Makefile
sysdeps/sun4/Makefile sysdeps/sun4/Makefile
sysdeps/osf1/Makefile sysdeps/osf1/Makefile
sysdeps/linux/Makefile sysdeps/linux/Makefile
sysdeps/kernel/Makefile
src/Makefile src/Makefile
src/server/Makefile src/server/Makefile
src/proxy/Makefile src/proxy/Makefile

View File

@@ -1,3 +1,7 @@
1998-06-12 Martin Baulig <martin@home-of-linux.org>
* test.scm: New file.
1998-06-07 Martin Baulig <martin@home-of-linux.org> 1998-06-07 Martin Baulig <martin@home-of-linux.org>
* Makefile.am (CFLAGS): Disable optimize. * Makefile.am (CFLAGS): Disable optimize.

80
examples/test.scm Normal file
View File

@@ -0,0 +1,80 @@
(display (glibtop-names-sysdeps)) (newline)
(display (glibtop-labels-sysdeps)) (newline)
(display (glibtop-descriptions-sysdeps)) (newline)
(display (glibtop-types-sysdeps)) (newline)
(newline)
(display (glibtop-names-cpu)) (newline)
(display (glibtop-names-mem)) (newline)
(display (glibtop-names-swap)) (newline)
(display (glibtop-names-uptime)) (newline)
(display (glibtop-names-loadavg)) (newline)
(display (glibtop-names-shm_limits)) (newline)
(display (glibtop-names-msg_limits)) (newline)
(display (glibtop-names-sem_limits)) (newline)
(display (glibtop-names-proclist)) (newline)
(display (glibtop-names-proc_state)) (newline)
(display (glibtop-names-proc_uid)) (newline)
(display (glibtop-names-proc_mem)) (newline)
(display (glibtop-names-proc_time)) (newline)
(display (glibtop-names-proc_signal)) (newline)
(display (glibtop-names-proc_kernel)) (newline)
(display (glibtop-names-proc_segment)) (newline)
(newline)
(display (glibtop-labels-cpu)) (newline)
(display (glibtop-labels-mem)) (newline)
(display (glibtop-labels-swap)) (newline)
(display (glibtop-labels-uptime)) (newline)
(display (glibtop-labels-loadavg)) (newline)
(display (glibtop-labels-shm_limits)) (newline)
(display (glibtop-labels-msg_limits)) (newline)
(display (glibtop-labels-sem_limits)) (newline)
(display (glibtop-labels-proclist)) (newline)
(display (glibtop-labels-proc_state)) (newline)
(display (glibtop-labels-proc_uid)) (newline)
(display (glibtop-labels-proc_mem)) (newline)
(display (glibtop-labels-proc_time)) (newline)
(display (glibtop-labels-proc_signal)) (newline)
(display (glibtop-labels-proc_kernel)) (newline)
(display (glibtop-labels-proc_segment)) (newline)
(newline)
(display (glibtop-descriptions-cpu)) (newline)
(display (glibtop-descriptions-mem)) (newline)
(display (glibtop-descriptions-swap)) (newline)
(display (glibtop-descriptions-uptime)) (newline)
(display (glibtop-descriptions-loadavg)) (newline)
(display (glibtop-descriptions-shm_limits)) (newline)
(display (glibtop-descriptions-msg_limits)) (newline)
(display (glibtop-descriptions-sem_limits)) (newline)
(display (glibtop-descriptions-proclist)) (newline)
(display (glibtop-descriptions-proc_state)) (newline)
(display (glibtop-descriptions-proc_uid)) (newline)
(display (glibtop-descriptions-proc_mem)) (newline)
(display (glibtop-descriptions-proc_time)) (newline)
(display (glibtop-descriptions-proc_signal)) (newline)
(display (glibtop-descriptions-proc_kernel)) (newline)
(display (glibtop-descriptions-proc_segment)) (newline)
(newline)
(display (glibtop-types-cpu)) (newline)
(display (glibtop-types-mem)) (newline)
(display (glibtop-types-swap)) (newline)
(display (glibtop-types-uptime)) (newline)
(display (glibtop-types-loadavg)) (newline)
(display (glibtop-types-shm_limits)) (newline)
(display (glibtop-types-msg_limits)) (newline)
(display (glibtop-types-sem_limits)) (newline)
(display (glibtop-types-proclist)) (newline)
(display (glibtop-types-proc_state)) (newline)
(display (glibtop-types-proc_uid)) (newline)
(display (glibtop-types-proc_mem)) (newline)
(display (glibtop-types-proc_time)) (newline)
(display (glibtop-types-proc_signal)) (newline)
(display (glibtop-types-proc_kernel)) (newline)
(display (glibtop-types-proc_segment)) (newline)

16
features.def Normal file
View File

@@ -0,0 +1,16 @@
cpu ulong(total,user,nice,sys,idle,frequency)
mem ulong(total,used,free,shared,buffer,cached,user,locked)
swap ulong(total,used,free)
uptime double(uptime,idletime)
loadavg double(loadavg[0],loadavg[1],loadavg[2])
shm_limits ulong(shmmax,shmmin,shmmni,shmseg,shmall)
msg_limits ulong(msgpool,msgmap,msgmax,msgmnb,msgmni,msgssz,msgtql)
sem_limits ulong(semmap,semmni,semmns,semmnu,semmsl,semopm,semume,semusz,semvmx,semaem)
proclist ulong(number,size,total)
proc_state str(cmd):char(state):ulong(uid,gid)
proc_uid long(uid,euid,gid,egid,pid,ppid,pgrp,session,tty,tpgid,priority,nice)
proc_mem long(size,vsize,resident,share,rss,rss_rlim)
proc_time long(start_time,utime,stime,cutime,cstime,timeout,it_real_value)
proc_signal long(signal,blocked,sigignore,sigcatch)
proc_kernel ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,wchan)
proc_segment long(trs,lrs,drs,dt):ulong(start_code,end_code,start_stack)

View File

@@ -79,7 +79,7 @@ extern SCM glibtop_guile_descriptions_loadavg __P((void));
/* You need to link with -lgtop_names to get this stuff here. */ /* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_loadavg []; extern const char *glibtop_names_loadavg [];
extern const char *glibtop_types_loadavg []; extern const unsigned glibtop_types_loadavg [];
extern const char *glibtop_labels_loadavg []; extern const char *glibtop_labels_loadavg [];
extern const char *glibtop_descriptions_loadavg []; extern const char *glibtop_descriptions_loadavg [];

View File

@@ -27,7 +27,7 @@
__BEGIN_DECLS __BEGIN_DECLS
#define GLIBTOP_SYSDEPS_DUMMY 0 #define GLIBTOP_SYSDEPS_FEATURES 0
#define GLIBTOP_SYSDEPS_CPU 1 #define GLIBTOP_SYSDEPS_CPU 1
#define GLIBTOP_SYSDEPS_MEM 2 #define GLIBTOP_SYSDEPS_MEM 2
#define GLIBTOP_SYSDEPS_SWAP 3 #define GLIBTOP_SYSDEPS_SWAP 3
@@ -101,7 +101,7 @@ extern SCM glibtop_guile_descriptions_sysdeps __P((void));
/* You need to link with -lgtop_names to get this stuff here. */ /* You need to link with -lgtop_names to get this stuff here. */
extern const char *glibtop_names_sysdeps []; extern const char *glibtop_names_sysdeps [];
extern const char *glibtop_types_sysdeps []; extern const unsigned glibtop_types_sysdeps [];
extern const char *glibtop_labels_sysdeps []; extern const char *glibtop_labels_sysdeps [];
extern const char *glibtop_descriptions_sysdeps []; extern const char *glibtop_descriptions_sysdeps [];

View File

@@ -28,11 +28,168 @@
#include "version.h" #include "version.h"
#if defined(__i386__)
# define KSTK_EIP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1019])
# define KSTK_ESP(tsk) (((unsigned long *)tsk->kernel_stack_page)[1022])
#elif defined(__alpha__)
/*
* See arch/alpha/kernel/ptrace.c for details.
*/
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
+ (long)&((struct pt_regs *)0)->reg)
# define KSTK_EIP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(pc)))
# define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->tss.usp)
#elif defined(__sparc__)
# define PT_REG(reg) (PAGE_SIZE - sizeof(struct pt_regs) \
+ (long)&((struct pt_regs *)0)->reg)
# define KSTK_EIP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(pc)))
# define KSTK_ESP(tsk) (*(unsigned long *)(tsk->kernel_stack_page + PT_REG(u_regs[UREG_FP])))
#endif
static struct task_struct *
get_task (pid_t pid)
{
struct task_struct ** p;
p = task;
while (++p < task+NR_TASKS) {
if (*p && (*p)->pid == pid)
return *p;
}
return NULL;
}
static inline void statm_pte_range(pmd_t * pmd, unsigned long address, unsigned long size,
int * pages, int * shared, int * dirty, int * total)
{
pte_t * pte;
unsigned long end;
if (pmd_none(*pmd))
return;
if (pmd_bad(*pmd)) {
printk("statm_pte_range: bad pmd (%08lx)\n", pmd_val(*pmd));
pmd_clear(pmd);
return;
}
pte = pte_offset(pmd, address);
address &= ~PMD_MASK;
end = address + size;
if (end > PMD_SIZE)
end = PMD_SIZE;
do {
pte_t page = *pte;
address += PAGE_SIZE;
pte++;
if (pte_none(page))
continue;
++*total;
if (!pte_present(page))
continue;
++*pages;
if (pte_dirty(page))
++*dirty;
if (pte_page(page) >= high_memory)
continue;
if (mem_map[MAP_NR(pte_page(page))].count > 1)
++*shared;
} while (address < end);
}
static inline void statm_pmd_range(pgd_t * pgd, unsigned long address, unsigned long size,
int * pages, int * shared, int * dirty, int * total)
{
pmd_t * pmd;
unsigned long end;
if (pgd_none(*pgd))
return;
if (pgd_bad(*pgd)) {
printk("statm_pmd_range: bad pgd (%08lx)\n", pgd_val(*pgd));
pgd_clear(pgd);
return;
}
pmd = pmd_offset(pgd, address);
address &= ~PGDIR_MASK;
end = address + size;
if (end > PGDIR_SIZE)
end = PGDIR_SIZE;
do {
statm_pte_range(pmd, address, end - address, pages, shared, dirty, total);
address = (address + PMD_SIZE) & PMD_MASK;
pmd++;
} while (address < end);
}
static void statm_pgd_range(pgd_t * pgd, unsigned long address, unsigned long end,
int * pages, int * shared, int * dirty, int * total)
{
while (address < end) {
statm_pmd_range(pgd, address, end - address, pages, shared, dirty, total);
address = (address + PGDIR_SIZE) & PGDIR_MASK;
pgd++;
}
}
static unsigned long
get_wchan (struct task_struct *p)
{
if (!p || p == current || p->state == TASK_RUNNING)
return 0;
#if defined(__i386__)
{
unsigned long ebp, eip;
unsigned long stack_page;
int count = 0;
stack_page = p->kernel_stack_page;
if (!stack_page)
return 0;
ebp = p->tss.ebp;
do {
if (ebp < stack_page || ebp >= 4092+stack_page)
return 0;
eip = *(unsigned long *) (ebp+4);
if (eip < (unsigned long) interruptible_sleep_on
|| eip >= (unsigned long) add_timer)
return eip;
ebp = *(unsigned long *) ebp;
} while (count++ < 16);
}
#elif defined(__alpha__)
/*
* This one depends on the frame size of schedule(). Do a
* "disass schedule" in gdb to find the frame size. Also, the
* code assumes that sleep_on() follows immediately after
* interruptible_sleep_on() and that add_timer() follows
* immediately after interruptible_sleep(). Ugly, isn't it?
* Maybe adding a wchan field to task_struct would be better,
* after all...
*/
{
unsigned long schedule_frame;
unsigned long pc;
pc = thread_saved_pc(&p->tss);
if (pc >= (unsigned long) interruptible_sleep_on && pc < (unsigned long) add_timer) {
schedule_frame = ((unsigned long *)p->tss.ksp)[6];
return ((unsigned long *)schedule_frame)[12];
}
return pc;
}
#endif
return 0;
}
asmlinkage int asmlinkage int
sys_table (int type, union table *buf) sys_table (int type, union table *buf, const void *param)
{ {
union table tbl; union table tbl;
struct sysinfo i; struct sysinfo i;
struct task_struct *tsk = NULL;
pid_t pid;
int err; int err;
if (type == TABLE_VERSION) if (type == TABLE_VERSION)
@@ -41,6 +198,31 @@ sys_table (int type, union table *buf)
if (!buf) if (!buf)
return -EFAULT; return -EFAULT;
memset (&tbl, 0, sizeof (union table));
/* For TABLE_PROC_*, read pid and get task_struct */
switch (type) {
case TABLE_PROC_UID:
case TABLE_PROC_MEM:
case TABLE_PROC_SEGMENT:
case TABLE_PROC_TIME:
case TABLE_PROC_STATE:
case TABLE_PROC_SIGNAL:
case TABLE_PROC_KERNEL:
err = verify_area (VERIFY_READ, param, sizeof (pid_t));
if (err)
return err;
memcpy_fromfs (&pid, param, sizeof (pid_t));
tsk = get_task (pid);
if (tsk == NULL)
return -ESRCH;
break;
}
/* Main function dispatcher */
switch (type) { switch (type) {
case TABLE_CPU: case TABLE_CPU:
tbl.cpu.total = jiffies; tbl.cpu.total = jiffies;
@@ -66,9 +248,9 @@ sys_table (int type, union table *buf)
tbl.swap.free = i.freeswap; tbl.swap.free = i.freeswap;
break; break;
case TABLE_LOADAVG: case TABLE_LOADAVG:
tbl.loadavg.loadavg [0] = avenrun [0]; tbl.loadavg.loadavg [0] = (double) avenrun [0] / (1 << FSHIFT);
tbl.loadavg.loadavg [1] = avenrun [1]; tbl.loadavg.loadavg [1] = (double) avenrun [1] / (1 << FSHIFT);
tbl.loadavg.loadavg [2] = avenrun [2]; tbl.loadavg.loadavg [2] = (double) avenrun [2] / (1 << FSHIFT);
tbl.loadavg.nr_running = nr_running; tbl.loadavg.nr_running = nr_running;
tbl.loadavg.nr_tasks = nr_tasks; tbl.loadavg.nr_tasks = nr_tasks;
tbl.loadavg.last_pid = last_pid; tbl.loadavg.last_pid = last_pid;
@@ -77,6 +259,157 @@ sys_table (int type, union table *buf)
tbl.uptime.uptime = jiffies; tbl.uptime.uptime = jiffies;
tbl.uptime.idle = task[0]->utime + task[0]->stime; tbl.uptime.idle = task[0]->utime + task[0]->stime;
break; break;
case TABLE_PROC_STATE:
tbl.proc_state.state = tsk->state;
tbl.proc_state.flags = tsk->flags;
memcpy (tbl.proc_state.comm, tsk->comm, sizeof (tbl.proc_state.comm));
break;
case TABLE_PROC_UID:
tbl.proc_uid.uid = tsk->uid;
tbl.proc_uid.euid = tsk->euid;
tbl.proc_uid.suid = tsk->suid;
tbl.proc_uid.fsuid = tsk->fsuid;
tbl.proc_uid.gid = tsk->gid;
tbl.proc_uid.egid = tsk->egid;
tbl.proc_uid.sgid = tsk->sgid;
tbl.proc_uid.fsgid = tsk->fsgid;
tbl.proc_uid.pid = tsk->pid;
tbl.proc_uid.pgrp = tsk->pgrp;
tbl.proc_uid.ppid = tsk->p_pptr->pid;
tbl.proc_uid.session = tsk->session;
tbl.proc_uid.tty = tsk->tty ? kdev_t_to_nr (tsk->tty->device) : 0;
tbl.proc_uid.tpgid = tsk->tty ? tsk->tty->pgrp : -1;
tbl.proc_uid.priority = tsk->priority;
tbl.proc_uid.counter = tsk->counter;
tbl.proc_uid.def_priority = DEF_PRIORITY;
break;
case TABLE_PROC_SIGNAL:
tbl.proc_signal.signal = tsk->signal;
tbl.proc_signal.blocked = tsk->blocked;
if (tsk->sig) {
struct sigaction * action = tsk->sig->action;
unsigned long sig_ign = 0, sig_caught = 0;
unsigned long bit = 1;
int i;
for (i = 0; i < 32; i++) {
switch((unsigned long) action->sa_handler) {
case 0:
break;
case 1:
sig_ign |= bit;
break;
default:
sig_caught |= bit;
}
bit <<= 1;
action++;
}
tbl.proc_signal.ignored = sig_ign;
tbl.proc_signal.caught = sig_caught;
} else {
tbl.proc_signal.ignored = 0;
tbl.proc_signal.caught = 0;
}
break;
case TABLE_PROC_MEM:
if (tsk->mm && tsk->mm != &init_mm) {
tbl.proc_mem.context = tsk->mm->context;
tbl.proc_mem.start_code = tsk->mm->start_code;
tbl.proc_mem.end_code = tsk->mm->end_code;
tbl.proc_mem.start_data = tsk->mm-> start_data;
tbl.proc_mem.end_data = tsk->mm->end_data;
tbl.proc_mem.start_brk = tsk->mm->start_brk;
tbl.proc_mem.brk = tsk->mm->brk;
tbl.proc_mem.start_stack = tsk->mm->start_stack;
tbl.proc_mem.start_mmap = tsk->mm->start_mmap;
tbl.proc_mem.arg_start = tsk->mm->arg_start;
tbl.proc_mem.arg_end = tsk->mm->arg_end;
tbl.proc_mem.env_start = tsk->mm->env_start;
tbl.proc_mem.env_end = tsk->mm->env_end;
tbl.proc_mem.rss = tsk->mm->rss;
tbl.proc_mem.total_vm = tsk->mm->total_vm;
tbl.proc_mem.locked_vm = tsk->mm->locked_vm;
}
tbl.proc_mem.rlim = tsk->rlim ? tsk->rlim[RLIMIT_RSS].rlim_cur : 0;
break;
case TABLE_PROC_SEGMENT:
if (tsk->mm && tsk->mm != &init_mm) {
unsigned long vsize = 0;
int size = 0, resident = 0, share = 0;
int trs = 0, lrs = 0, drs = 0, dt = 0;
struct vm_area_struct * vma = tsk->mm->mmap;
while (vma) {
pgd_t *pgd = pgd_offset(tsk->mm, vma->vm_start);
int pages = 0, shared = 0, dirty = 0, total = 0;
vsize += vma->vm_end - vma->vm_start;
statm_pgd_range (pgd, vma->vm_start, vma->vm_end,
&pages, &shared, &dirty, &total);
resident += pages;
share += shared;
dt += dirty;
size += total;
if (vma->vm_flags & VM_EXECUTABLE)
trs += pages; /* text */
else if (vma->vm_flags & VM_GROWSDOWN)
drs += pages; /* stack */
else if (vma->vm_end > 0x60000000)
lrs += pages; /* library */
else
drs += pages;
vma = vma->vm_next;
}
tbl.proc_segment.vsize = vsize;
tbl.proc_segment.size = size;
tbl.proc_segment.resident = resident;
tbl.proc_segment.shared = share;
tbl.proc_segment.trs = trs;
tbl.proc_segment.lrs = lrs;
tbl.proc_segment.dt = dt;
}
break;
case TABLE_PROC_TIME:
tbl.proc_time.utime = tsk->utime;
tbl.proc_time.stime = tsk->stime;
tbl.proc_time.cutime = tsk->cutime;
tbl.proc_time.cstime = tsk->cstime;
tbl.proc_time.start_time = tsk->start_time;
tbl.proc_time.timeout = tsk->timeout;
tbl.proc_time.policy = tsk->policy;
tbl.proc_time.rt_priority = tsk->rt_priority;
tbl.proc_time.it_real_value = tsk->it_real_value;
tbl.proc_time.it_prof_value = tsk->it_prof_value;
tbl.proc_time.it_virt_value = tsk->it_virt_value;
tbl.proc_time.it_real_incr = tsk->it_real_incr;
tbl.proc_time.it_prof_incr = tsk->it_prof_incr;
tbl.proc_time.it_virt_incr = tsk->it_virt_incr;
break;
case TABLE_PROC_KERNEL:
tbl.proc_kernel.min_flt = tsk->min_flt;
tbl.proc_kernel.cmin_flt = tsk->cmin_flt;
tbl.proc_kernel.maj_flt = tsk->maj_flt;
tbl.proc_kernel.cmaj_flt = tsk->cmaj_flt;
tbl.proc_kernel.kesp = tsk->kernel_stack_page ? KSTK_EIP(tsk) : 0;
tbl.proc_kernel.keip = tsk->kernel_stack_page ? KSTK_ESP(tsk) : 0;
tbl.proc_kernel.nswap = tsk->nswap;
tbl.proc_kernel.cnswap = tsk->cnswap;
tbl.proc_kernel.wchan = get_wchan (tsk);
break;
default: default:
return -EINVAL; return -EINVAL;
} }

View File

@@ -1,13 +1,23 @@
#ifndef _LINUX_TABLE_H #ifndef _LINUX_TABLE_H
#define _LINUX_TABLE_H #define _LINUX_TABLE_H
#include <linux/types.h>
#define TABLE_VERSION 0 #ifdef _KERNEL
#define TABLE_CPU 1 #include <linux/types.h>
#define TABLE_MEM 2 #endif
#define TABLE_SWAP 3
#define TABLE_LOADAVG 4 #define TABLE_VERSION 0
#define TABLE_UPTIME 5 #define TABLE_CPU 1
#define TABLE_MEM 2
#define TABLE_SWAP 3
#define TABLE_LOADAVG 4
#define TABLE_UPTIME 5
#define TABLE_PROC_UID 6
#define TABLE_PROC_MEM 7
#define TABLE_PROC_SEGMENT 8
#define TABLE_PROC_TIME 9
#define TABLE_PROC_STATE 10
#define TABLE_PROC_SIGNAL 11
#define TABLE_PROC_KERNEL 12
/* CPU Usage (in jiffies = 1/100th seconds) */ /* CPU Usage (in jiffies = 1/100th seconds) */
@@ -46,7 +56,7 @@ struct table_swap
struct table_loadavg struct table_loadavg
{ {
unsigned long loadavg [3]; double loadavg [3];
unsigned nr_running; unsigned nr_running;
unsigned nr_tasks; unsigned nr_tasks;
unsigned last_pid; unsigned last_pid;
@@ -60,6 +70,67 @@ struct table_uptime
unsigned long idle; unsigned long idle;
}; };
/* Information about processes. */
struct table_proc_state
{
long state;
unsigned long flags;
char comm[16];
};
struct table_proc_uid
{
int uid, euid, suid, fsuid;
int gid, egid, sgid, fsgid;
int pid, pgrp, ppid;
int session;
unsigned int tty;
int tpgid;
long priority;
long counter;
long def_priority;
};
struct table_proc_mem
{
unsigned long context;
unsigned long start_code, end_code, start_data, end_data;
unsigned long start_brk, brk, start_stack, start_mmap;
unsigned long arg_start, arg_end, env_start, env_end;
unsigned long rss, rlim, total_vm, locked_vm;
};
struct table_proc_segment
{
unsigned long vsize;
int size, resident, shared;
int trs, lrs, drs, dt;
};
struct table_proc_time
{
long utime, stime, cutime, cstime, start_time;
unsigned long timeout, policy, rt_priority;
unsigned long it_real_value, it_prof_value, it_virt_value;
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
};
struct table_proc_signal
{
unsigned long signal;
unsigned long blocked; /* bitmap of masked signals */
unsigned long ignored; /* mask of ignored signals */
unsigned long caught; /* mask of caught signals */
};
struct table_proc_kernel
{
unsigned long keip, kesp, wchan;
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
unsigned long nswap, cnswap;
};
/* Union */ /* Union */
union table union table
@@ -69,12 +140,15 @@ union table
struct table_swap swap; struct table_swap swap;
struct table_loadavg loadavg; struct table_loadavg loadavg;
struct table_uptime uptime; struct table_uptime uptime;
struct table_proc_uid proc_uid;
struct table_proc_mem proc_mem;
struct table_proc_segment proc_segment;
struct table_proc_time proc_time;
struct table_proc_state proc_state;
struct table_proc_signal proc_signal;
struct table_proc_kernel proc_kernel;
}; };
#ifdef __KERNEL__
#endif /* __KERNEL__ */
#endif /* _LINUX_IPC_H */ #endif /* _LINUX_IPC_H */

View File

@@ -7,15 +7,16 @@
#include <syscall.h> #include <syscall.h>
static inline _syscall2 (int, table, int, type, union table *, tbl); static inline _syscall3 (int, table, int, type, union table *, tbl, const void *, param);
int int
main (void) main (void)
{ {
union table tbl; union table tbl;
unsigned count;
int ret; int ret;
ret = table (TABLE_VERSION, NULL); ret = table (TABLE_VERSION, NULL, NULL);
if (ret == -1) { if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_VERSION, sys_errlist [errno]); fprintf (stderr, "table(%u): %s\n", TABLE_VERSION, sys_errlist [errno]);
@@ -24,18 +25,20 @@ main (void)
fprintf (stderr, "Table (%u) = %u\n", TABLE_VERSION, ret); fprintf (stderr, "Table (%u) = %u\n", TABLE_VERSION, ret);
ret = table (TABLE_CPU, &tbl); for (count = 0; count < 5; count++) {
ret = table (TABLE_CPU, &tbl, NULL);
if (ret == -1) { if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_CPU, sys_errlist [errno]); fprintf (stderr, "table(%u): %s\n", TABLE_CPU, sys_errlist [errno]);
exit (-errno); exit (-errno);
}
fprintf (stderr, "Table (%u) = %lu, %lu, %lu, %lu, %lu, %lu\n",
TABLE_CPU, tbl.cpu.total, tbl.cpu.user, tbl.cpu.nice,
tbl.cpu.sys, tbl.cpu.idle, tbl.cpu.frequency);
} }
fprintf (stderr, "Table (%u) = %lu, %lu, %lu, %lu, %lu, %lu\n", ret = table (TABLE_MEM, &tbl, NULL);
TABLE_CPU, tbl.cpu.total, tbl.cpu.user, tbl.cpu.nice,
tbl.cpu.sys, tbl.cpu.idle, tbl.cpu.frequency);
ret = table (TABLE_MEM, &tbl);
if (ret == -1) { if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_MEM, sys_errlist [errno]); fprintf (stderr, "table(%u): %s\n", TABLE_MEM, sys_errlist [errno]);
@@ -46,7 +49,7 @@ main (void)
TABLE_MEM, tbl.mem.total, tbl.mem.used, tbl.mem.free, TABLE_MEM, tbl.mem.total, tbl.mem.used, tbl.mem.free,
tbl.mem.shared, tbl.mem.buffer, tbl.mem.cached); tbl.mem.shared, tbl.mem.buffer, tbl.mem.cached);
ret = table (TABLE_SWAP, &tbl); ret = table (TABLE_SWAP, &tbl, NULL);
if (ret == -1) { if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_SWAP, sys_errlist [errno]); fprintf (stderr, "table(%u): %s\n", TABLE_SWAP, sys_errlist [errno]);
@@ -56,7 +59,7 @@ main (void)
fprintf (stderr, "Table (%u) = %lu, %lu, %lu\n", fprintf (stderr, "Table (%u) = %lu, %lu, %lu\n",
TABLE_SWAP, tbl.swap.total, tbl.swap.used, tbl.swap.free); TABLE_SWAP, tbl.swap.total, tbl.swap.used, tbl.swap.free);
ret = table (TABLE_LOADAVG, &tbl); ret = table (TABLE_LOADAVG, &tbl, NULL);
if (ret == -1) { if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_LOADAVG, sys_errlist [errno]); fprintf (stderr, "table(%u): %s\n", TABLE_LOADAVG, sys_errlist [errno]);
@@ -68,7 +71,7 @@ main (void)
tbl.loadavg.loadavg [2], tbl.loadavg.nr_running, tbl.loadavg.loadavg [2], tbl.loadavg.nr_running,
tbl.loadavg.nr_tasks, tbl.loadavg.last_pid); tbl.loadavg.nr_tasks, tbl.loadavg.last_pid);
ret = table (TABLE_UPTIME, &tbl); ret = table (TABLE_UPTIME, &tbl, NULL);
if (ret == -1) { if (ret == -1) {
fprintf (stderr, "table(%u): %s\n", TABLE_UPTIME, sys_errlist [errno]); fprintf (stderr, "table(%u): %s\n", TABLE_UPTIME, sys_errlist [errno]);

View File

@@ -32,3 +32,4 @@ sysinfo.lo
uptime.lo uptime.lo
write.lo write.lo
xmalloc.lo xmalloc.lo
lib.c

View File

@@ -8,10 +8,14 @@ CFLAGS = -Wall -W @CFLAGS@ -DGTOP_SERVER=\""@LIBGTOP_SERVER@"\"
lib_LTLIBRARIES = libgtop.la lib_LTLIBRARIES = libgtop.la
libgtop_la_SOURCES = init.c open.c close.c read.c read_data.c \ libgtop_la_SOURCES = init.c open.c close.c command.c read.c read_data.c write.c lib.c
write.c command.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
BUILT_SOURCES = lib.c
lib.c: lib.awk $(top_builddir)/config.h $(top_builddir)/features.def
$(AWK) -f $(srcdir)/lib.awk < $(top_builddir)/features.def > lib-t
mv lib-t lib.c
EXTRA_DIST = lib.awk
CLEANFILES = lib.c

52
lib/lib.awk Normal file
View File

@@ -0,0 +1,52 @@
BEGIN {
print "/* lib.c */";
print "/* This is a generated file. Please modify `lib.awk' */";
print "";
print "#include <glibtop.h>";
print "#include <glibtop/sysdeps.h>";
print "#include <glibtop/command.h>";
print "";
}
function output(feature) {
if (feature ~ /^proclist$/) {
print "unsigned *";
prefix = "return ";
} else {
prefix = "";
print "void";
}
if (feature ~ /^proc_/) {
param = ", pid_t pid";
} else {
param = "";
}
print "glibtop_get_"feature"_l (glibtop *server, glibtop_"feature" *buf"param")";
print "{";
print "\tglibtop_init_r (&server, GLIBTOP_SYSDEPS_"toupper(feature)", 0);";
print "";
print "\tif (server->features & GLIBTOP_SYSDEPS_"toupper(feature)") {";
if (feature ~ /^proc_/) {
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)", sizeof (pid_t),";
print "\t\t\t\t&pid, sizeof (glibtop_"feature"), buf);";
print "\t} else {";
print "\t\t"prefix"glibtop_get_"feature"_r (server, buf, pid);";
} else {
print "\t\t"prefix"glibtop_call_l (server, GLIBTOP_CMND_"toupper(feature)", 0, NULL,";
print "\t\t\t sizeof (glibtop_"feature"), buf);";
print "\t} else {";
print "\t\t"prefix"glibtop_get_"feature"_r (server, buf);";
}
print "\t}";
print "}";
print "";
}
/^(\w+)/ { output($1) }

View File

@@ -1,40 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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/command.h>
/* Provides detailed information about a process. */
void
glibtop_get_proc_kernel_l (glibtop *server, glibtop_proc_kernel *buf,
pid_t pid)
{
glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_KERNEL, 0);
if (server->features & GLIBTOP_SYSDEPS_PROC_KERNEL) {
glibtop_call_l (server, GLIBTOP_CMND_PROC_KERNEL, sizeof (pid_t),
&pid, sizeof (glibtop_proc_kernel), buf);
} else {
glibtop_get_proc_kernel_r (server, buf, pid);
}
}

View File

@@ -1,40 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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/command.h>
/* Provides detailed information about a process. */
void
glibtop_get_proc_segment_l (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_SEGMENT, 0);
if (server->features & GLIBTOP_SYSDEPS_PROC_SEGMENT) {
glibtop_call_l (server, GLIBTOP_CMND_PROC_SEGMENT, sizeof (pid_t),
&pid, sizeof (glibtop_proc_segment), buf);
} else {
glibtop_get_proc_segment_r (server, buf, pid);
}
}

View File

@@ -1,17 +1,8 @@
lib/close.c lib/close.c
lib/command.c lib/command.c
lib/cpu.c
lib/mem.c
lib/open.c lib/open.c
lib/read.c lib/read.c
lib/swap.c
lib/write.c lib/write.c
lib/uptime.c
lib/loadavg.c
lib/shm_limits.c
lib/msg_limits.c
lib/sem_limits.c
lib/proclist.c
lib/read_data.c lib/read_data.c
acconfig.h acconfig.h
glibtop.h glibtop.h

View File

@@ -12,4 +12,4 @@ endif
SUBDIRS = @sysdeps_dir@ common $(names_SUBDIRS) $(guile_SUBDIRS) SUBDIRS = @sysdeps_dir@ common $(names_SUBDIRS) $(guile_SUBDIRS)
DIST_SUBDIRS = common guile linux names osf1 stub sun4 DIST_SUBDIRS = common guile linux kernel names osf1 stub sun4

View File

@@ -23,3 +23,4 @@ so_locations
swap.lo swap.lo
sysdeps.lo sysdeps.lo
uptime.lo uptime.lo
guile.c

View File

@@ -14,8 +14,14 @@ CFLAGS = -Wall -W @CFLAGS@
lib_LTLIBRARIES = libgtop_guile.la lib_LTLIBRARIES = libgtop_guile.la
libgtop_guile_la_SOURCES = boot.c sysdeps.c cpu.c mem.c swap.c uptime.c \ libgtop_guile_la_SOURCES = guile.c
loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \ BUILT_SOURCES = guile.c
proctime.c procmem.c procsignal.c prockernel.c \
procsegment.c guile.c: guile.awk $(top_builddir)/config.h $(top_builddir)/features.def
$(AWK) -f $(srcdir)/guile.awk < $(top_builddir)/features.def > gnc-t
mv gnc-t guile.c
EXTRA_DIST = guile.awk
CLEANFILES = guile.c

View File

@@ -1,66 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/sysdeps.h>
#include <guile/gh.h>
void
glibtop_boot_guile (void)
{
gh_new_procedure0_0
("glibtop-get-cpu", glibtop_guile_get_cpu);
gh_new_procedure0_0
("glibtop-get-mem", glibtop_guile_get_mem);
gh_new_procedure0_0
("glibtop-get-swap", glibtop_guile_get_swap);
gh_new_procedure0_0
("glibtop-get-uptime", glibtop_guile_get_uptime);
gh_new_procedure0_0
("glibtop-get-loadavg", glibtop_guile_get_loadavg);
gh_new_procedure0_0
("glibtop-get-shm_limits",glibtop_guile_get_shm_limits);
gh_new_procedure0_0
("glibtop-get-msg_limits", glibtop_guile_get_msg_limits);
gh_new_procedure0_0
("glibtop-get-sem_limits", glibtop_guile_get_sem_limits);
gh_new_procedure0_0
("glibtop-get-sysdeps", glibtop_guile_get_sysdeps);
gh_new_procedure0_0
("glibtop-get-proclist", glibtop_guile_get_proclist);
gh_new_procedure1_0
("glibtop-get-proc_state", glibtop_guile_get_proc_state);
gh_new_procedure1_0
("glibtop-get-proc_uid", glibtop_guile_get_proc_uid);
gh_new_procedure1_0
("glibtop-get-proc_mem", glibtop_guile_get_proc_mem);
gh_new_procedure1_0
("glibtop-get-proc_time", glibtop_guile_get_proc_time);
gh_new_procedure1_0
("glibtop-get-proc_signal", glibtop_guile_get_proc_signal);
gh_new_procedure1_0
("glibtop-get-proc_kernel", glibtop_guile_get_proc_kernel);
gh_new_procedure1_0
("glibtop-get-proc_segment", glibtop_guile_get_proc_segment);
}

View File

@@ -1,41 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM glibtop_guile_get_cpu (void)
{
glibtop_cpu cpu;
glibtop_get_cpu (&cpu);
return gh_list (gh_ulong2scm (cpu.flags),
gh_ulong2scm (cpu.total),
gh_ulong2scm (cpu.user),
gh_ulong2scm (cpu.nice),
gh_ulong2scm (cpu.sys),
gh_ulong2scm (cpu.idle),
gh_ulong2scm (cpu.frequency),
SCM_UNDEFINED);
}

87
sysdeps/guile/guile.awk Normal file
View File

@@ -0,0 +1,87 @@
BEGIN {
print "/* guile.c */";
print "/* This is a generated file. Please modify `guile.awk' */";
print "";
print "#include <glibtop.h>";
print "#include <glibtop/xmalloc.h>";
print "#include <glibtop/sysdeps.h>";
print "";
print "#include <guile/gh.h>";
print "";
convert["long"] = "gh_long2scm ";
convert["ulong"] = "gh_ulong2scm ";
convert["double"] = "gh_double2scm";
convert["str"] = "gh_str02scm ";
convert["char"] = "gh_char2scm ";
}
/^(\w+)/ {
features[$1] = $1;
if ($1 ~ /^proclist$/) {
output = "SCM\nglibtop_guile_get_proclist (void)\n{\n";
output = output"\tglibtop_proclist proclist;\n\tunsigned i, *ptr;\n";
output = output"\tSCM list;\n\n\tptr = glibtop_get_proclist (&proclist);\n\n";
output = output"\tlist = gh_list (gh_ulong2scm ("$1".flags),\n\t\t\t";
} else {
if ($1 ~ /^proc_/) {
output = "SCM\nglibtop_guile_get_"$1" (SCM pid)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
output = output"\tglibtop_get_"$1" (&"$1", (pid_t) gh_scm2long (pid));\n\n";
} else {
output = "SCM\nglibtop_guile_get_"$1" (void)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
output = output"\tglibtop_get_"$1" (&"$1");\n\n";
}
output = output"\treturn gh_list (gh_ulong2scm ("$1".flags),\n\t\t\t";
}
nr_elements = split ($2, elements, /:/);
for (element = 1; element <= nr_elements; element++) {
list = elements[element];
type = elements[element];
sub(/\(.*/, "", type);
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
count = split (list, fields, /,/);
for (field = 1; field <= count; field++) {
output = output""convert[type]" ("$1"."fields[field]"),\n\t\t\t";
}
}
output = output"SCM_UNDEFINED);";
print output;
if ($1 ~ /^proclist$/) {
print "";
print "\tif (ptr) {";
print "\t\tfor (i = 0; i < proclist.number; i++)";
print "\t\t\tlist = gh_append";
print "\t\t\t\t(gh_list (list,";
print "\t\t\t\t\t gh_list (gh_ulong2scm ((unsigned long) ptr [i])),";
print "\t\t\t\t\t SCM_UNDEFINED));";
print "\t}";
print "";
print "\tglibtop_free (ptr);";
print "";
print "\treturn list;";
}
print "}";
print "";
}
END {
print "void";
print "glibtop_boot_guile (void)";
print "{";
for (feature in features) {
if (feature ~ /^proc_/) {
print "\tgh_new_procedure1_0";
} else {
print "\tgh_new_procedure0_0";
}
print "\t\t(\"glibtop-get-"feature"\", glibtop_guile_get_"feature");";
}
print "}";
}

View File

@@ -1,38 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM glibtop_guile_get_loadavg (void)
{
glibtop_loadavg loadavg;
glibtop_get_loadavg (&loadavg);
return gh_list (gh_ulong2scm (loadavg.flags),
gh_double2scm (loadavg.loadavg [0]),
gh_double2scm (loadavg.loadavg [1]),
gh_double2scm (loadavg.loadavg [2]),
SCM_UNDEFINED);
}

View File

@@ -1,43 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM glibtop_guile_get_mem (void)
{
glibtop_mem mem;
glibtop_get_mem (&mem);
return gh_list (gh_ulong2scm (mem.flags),
gh_ulong2scm (mem.total),
gh_ulong2scm (mem.used),
gh_ulong2scm (mem.free),
gh_ulong2scm (mem.shared),
gh_ulong2scm (mem.buffer),
gh_ulong2scm (mem.cached),
gh_ulong2scm (mem.user),
gh_ulong2scm (mem.locked),
SCM_UNDEFINED);
}

View File

@@ -1,42 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM glibtop_guile_get_msg_limits (void)
{
glibtop_msg_limits msg_limits;
glibtop_get_msg_limits (&msg_limits);
return gh_list (gh_ulong2scm (msg_limits.flags),
gh_ulong2scm (msg_limits.msgpool),
gh_ulong2scm (msg_limits.msgmap),
gh_ulong2scm (msg_limits.msgmax),
gh_ulong2scm (msg_limits.msgmnb),
gh_ulong2scm (msg_limits.msgmni),
gh_ulong2scm (msg_limits.msgssz),
gh_ulong2scm (msg_limits.msgtql),
SCM_UNDEFINED);
}

View File

@@ -24,3 +24,4 @@ so_locations
swap.lo swap.lo
sysdeps.lo sysdeps.lo
uptime.lo uptime.lo
guile-names.c

View File

@@ -8,9 +8,15 @@ CFLAGS = -Wall -W @CFLAGS@
lib_LTLIBRARIES = libgtop_guile_names.la lib_LTLIBRARIES = libgtop_guile_names.la
libgtop_guile_names_la_SOURCES = boot.c sysdeps.c cpu.c mem.c swap.c uptime.c \ libgtop_guile_names_la_SOURCES = guile-names.c
loadavg.c shm_limits.c msg_limits.c \
sem_limits.c proclist.c procstate.c procuid.c \ BUILT_SOURCES = guile-names.c
proctime.c procmem.c procsignal.c prockernel.c \
procsegment.c guile-names.c: guile-names.awk $(top_builddir)/config.h $(top_builddir)/features.def
$(AWK) -f $(srcdir)/guile-names.awk < $(top_builddir)/features.def > gnc-t
mv gnc-t guile-names.c
EXTRA_DIST = guile-names.awk
CLEANFILES = guile-names.c

View File

@@ -1,174 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/sysdeps.h>
#include <guile/gh.h>
void
glibtop_boot_guile_names (void)
{
gh_new_procedure0_0
("glibtop-names-cpu", glibtop_guile_names_cpu);
gh_new_procedure0_0
("glibtop-names-mem", glibtop_guile_names_mem);
gh_new_procedure0_0
("glibtop-names-swap", glibtop_guile_names_swap);
gh_new_procedure0_0
("glibtop-names-uptime", glibtop_guile_names_uptime);
gh_new_procedure0_0
("glibtop-names-loadavg", glibtop_guile_names_loadavg);
gh_new_procedure0_0
("glibtop-names-shm_limits", glibtop_guile_names_shm_limits);
gh_new_procedure0_0
("glibtop-names-msg_limits", glibtop_guile_names_msg_limits);
gh_new_procedure0_0
("glibtop-names-sem_limits", glibtop_guile_names_sem_limits);
gh_new_procedure0_0
("glibtop-names-sysdeps", glibtop_guile_names_sysdeps);
gh_new_procedure0_0
("glibtop-names-proclist", glibtop_guile_names_proclist);
gh_new_procedure0_0
("glibtop-names-proc_state", glibtop_guile_names_proc_state);
gh_new_procedure0_0
("glibtop-names-proc_uid", glibtop_guile_names_proc_uid);
gh_new_procedure0_0
("glibtop-names-proc_mem", glibtop_guile_names_proc_mem);
gh_new_procedure0_0
("glibtop-names-proc_time", glibtop_guile_names_proc_time);
gh_new_procedure0_0
("glibtop-names-proc_signal", glibtop_guile_names_proc_signal);
gh_new_procedure0_0
("glibtop-names-proc_kernel", glibtop_guile_names_proc_kernel);
gh_new_procedure0_0
("glibtop-names-proc_segment", glibtop_guile_names_proc_segment);
gh_new_procedure0_0
("glibtop-types-cpu", glibtop_guile_types_cpu);
gh_new_procedure0_0
("glibtop-types-mem", glibtop_guile_types_mem);
gh_new_procedure0_0
("glibtop-types-swap", glibtop_guile_types_swap);
gh_new_procedure0_0
("glibtop-types-uptime", glibtop_guile_types_uptime);
gh_new_procedure0_0
("glibtop-types-loadavg", glibtop_guile_types_loadavg);
gh_new_procedure0_0
("glibtop-types-shm_limits", glibtop_guile_types_shm_limits);
gh_new_procedure0_0
("glibtop-types-msg_limits", glibtop_guile_types_msg_limits);
gh_new_procedure0_0
("glibtop-types-sem_limits", glibtop_guile_types_sem_limits);
gh_new_procedure0_0
("glibtop-types-sysdeps", glibtop_guile_types_sysdeps);
gh_new_procedure0_0
("glibtop-types-proclist", glibtop_guile_types_proclist);
gh_new_procedure0_0
("glibtop-types-proc_state", glibtop_guile_types_proc_state);
gh_new_procedure0_0
("glibtop-types-proc_uid", glibtop_guile_types_proc_uid);
gh_new_procedure0_0
("glibtop-types-proc_mem", glibtop_guile_types_proc_mem);
gh_new_procedure0_0
("glibtop-types-proc_time", glibtop_guile_types_proc_time);
gh_new_procedure0_0
("glibtop-types-proc_signal", glibtop_guile_types_proc_signal);
gh_new_procedure0_0
("glibtop-types-proc_kernel", glibtop_guile_types_proc_kernel);
gh_new_procedure0_0
("glibtop-types-proc_segment", glibtop_guile_types_proc_segment);
gh_new_procedure0_0
("glibtop-labels-cpu", glibtop_guile_labels_cpu);
gh_new_procedure0_0
("glibtop-labels-mem", glibtop_guile_labels_mem);
gh_new_procedure0_0
("glibtop-labels-swap", glibtop_guile_labels_swap);
gh_new_procedure0_0
("glibtop-labels-uptime", glibtop_guile_labels_uptime);
gh_new_procedure0_0
("glibtop-labels-loadavg", glibtop_guile_labels_loadavg);
gh_new_procedure0_0
("glibtop-labels-shm_limits", glibtop_guile_labels_shm_limits);
gh_new_procedure0_0
("glibtop-labels-msg_limits", glibtop_guile_labels_msg_limits);
gh_new_procedure0_0
("glibtop-labels-sem_limits", glibtop_guile_labels_sem_limits);
gh_new_procedure0_0
("glibtop-labels-sysdeps", glibtop_guile_labels_sysdeps);
gh_new_procedure0_0
("glibtop-labels-proclist", glibtop_guile_labels_proclist);
gh_new_procedure0_0
("glibtop-labels-proc_state", glibtop_guile_labels_proc_state);
gh_new_procedure0_0
("glibtop-labels-proc_uid", glibtop_guile_labels_proc_uid);
gh_new_procedure0_0
("glibtop-labels-proc_mem", glibtop_guile_labels_proc_mem);
gh_new_procedure0_0
("glibtop-labels-proc_time", glibtop_guile_labels_proc_time);
gh_new_procedure0_0
("glibtop-labels-proc_signal", glibtop_guile_labels_proc_signal);
gh_new_procedure0_0
("glibtop-labels-proc_kernel", glibtop_guile_labels_proc_kernel);
gh_new_procedure0_0
("glibtop-labels-proc_segment", glibtop_guile_labels_proc_segment);
gh_new_procedure0_0
("glibtop-descriptions-cpu", glibtop_guile_descriptions_cpu);
gh_new_procedure0_0
("glibtop-descriptions-mem", glibtop_guile_descriptions_mem);
gh_new_procedure0_0
("glibtop-descriptions-swap", glibtop_guile_descriptions_swap);
gh_new_procedure0_0
("glibtop-descriptions-uptime", glibtop_guile_descriptions_uptime);
gh_new_procedure0_0
("glibtop-descriptions-loadavg", glibtop_guile_descriptions_loadavg);
gh_new_procedure0_0
("glibtop-descriptions-shm_limits", glibtop_guile_descriptions_shm_limits);
gh_new_procedure0_0
("glibtop-descriptions-msg_limits", glibtop_guile_descriptions_msg_limits);
gh_new_procedure0_0
("glibtop-descriptions-sem_limits", glibtop_guile_descriptions_sem_limits);
gh_new_procedure0_0
("glibtop-descriptions-sysdeps", glibtop_guile_descriptions_sysdeps);
gh_new_procedure0_0
("glibtop-descriptions-proclist", glibtop_guile_descriptions_proclist);
gh_new_procedure0_0
("glibtop-descriptions-proc_state", glibtop_guile_descriptions_proc_state);
gh_new_procedure0_0
("glibtop-descriptions-proc_uid", glibtop_guile_descriptions_proc_uid);
gh_new_procedure0_0
("glibtop-descriptions-proc_mem", glibtop_guile_descriptions_proc_mem);
gh_new_procedure0_0
("glibtop-descriptions-proc_time", glibtop_guile_descriptions_proc_time);
gh_new_procedure0_0
("glibtop-descriptions-proc_signal", glibtop_guile_descriptions_proc_signal);
gh_new_procedure0_0
("glibtop-descriptions-proc_kernel", glibtop_guile_descriptions_proc_kernel);
gh_new_procedure0_0
("glibtop-descriptions-proc_segment", glibtop_guile_descriptions_proc_segment);
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_cpu (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_CPU; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_cpu [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_cpu (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_CPU; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_cpu [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_cpu (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_CPU; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_cpu [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_cpu (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_CPU; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_cpu [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -0,0 +1,121 @@
BEGIN {
print "/* guile_names.c */";
print "/* This is a generated file. Please modify `guile-names.awk' */";
print "";
print "#include <glibtop.h>";
print "#include <glibtop/sysdeps.h>";
print "";
print "#include <guile/gh.h>";
print "";
}
function output(feature) {
print "SCM";
print "glibtop_guile_names_"feature" (void)";
print "{";
print "\tint i;";
print "\tSCM list;";
print "";
print "\tlist = gh_list (SCM_UNDEFINED);";
print "";
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
print "\t\tlist = gh_append";
print "\t\t\t(gh_list (list,";
print "\t\t\t\t gh_list (gh_str02scm ((char *) glibtop_names_"feature" [i])),";
print "\t\t\t\t SCM_UNDEFINED));";
print "";
print "\treturn list;";
print "}";
print "";
print "SCM";
print "glibtop_guile_types_"feature" (void)";
print "{";
print "\tint i;";
print "\tSCM list;";
print "";
print "\tlist = gh_list (SCM_UNDEFINED);";
print "";
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
print "\t\tlist = gh_append";
print "\t\t\t(gh_list (list,";
print "\t\t\t\t gh_list (gh_ulong2scm (glibtop_types_"feature" [i])),";
print "\t\t\t\t SCM_UNDEFINED));";
print "";
print "\treturn list;";
print "}";
print "";
print "SCM";
print "glibtop_guile_labels_"feature" (void)";
print "{";
print "\tint i;";
print "\tSCM list;";
print "";
print "\tlist = gh_list (SCM_UNDEFINED);";
print "";
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
print "\t\tlist = gh_append";
print "\t\t\t(gh_list (list,";
print "\t\t\t\t gh_list (gh_str02scm (gettext";
print "\t\t\t\t\t\t\t(glibtop_labels_"feature" [i]))),";
print "\t\t\t\t SCM_UNDEFINED));";
print "";
print "\treturn list;";
print "}";
print "";
print "SCM";
print "glibtop_guile_descriptions_"feature" (void)";
print "{";
print "\tint i;";
print "\tSCM list;";
print "";
print "\tlist = gh_list (SCM_UNDEFINED);";
print "";
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
print "\t\tlist = gh_append";
print "\t\t\t(gh_list (list,";
print "\t\t\t\t gh_list (gh_str02scm (gettext";
print "\t\t\t\t\t\t\t(glibtop_descriptions_"feature" [i]))),";
print "\t\t\t\t SCM_UNDEFINED));";
print "";
print "\treturn list;";
print "}";
print "";
}
/^(\w+)/ { features[$1] = $1 }
END {
for (feature in features) {
output(feature);
}
print "void";
print "glibtop_boot_guile_names (void)";
print "{";
for (feature in features) {
print "\tgh_new_procedure0_0";
print "\t\t(\"glibtop-names-"feature"\", glibtop_guile_names_"feature");";
print "";
print "\tgh_new_procedure0_0";
print "\t\t(\"glibtop-types-"feature"\", glibtop_guile_types_"feature");";
print "";
print "\tgh_new_procedure0_0";
print "\t\t(\"glibtop-labels-"feature"\", glibtop_guile_labels_"feature");";
print "";
print "\tgh_new_procedure0_0";
print "\t\t(\"glibtop-descriptions-"feature"\", glibtop_guile_descriptions_"feature");";
}
print "}";
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_loadavg (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_loadavg [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_loadavg (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_loadavg [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_loadavg (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_loadavg [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_loadavg (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_LOADAVG; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_loadavg [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_mem [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_mem [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_mem [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_mem [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_msg_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_msg_limits [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_msg_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_msg_limits [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_msg_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_msg_limits [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_msg_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_MSG_LIMITS; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_msg_limits [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_proc_kernel (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_proc_kernel [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_proc_kernel (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_proc_kernel [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_proc_kernel (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_proc_kernel [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_proc_kernel (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_KERNEL; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_proc_kernel [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,96 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_proclist (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_proclist [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_proclist (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_proclist [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_proclist (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_proclist [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_proclist (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROCLIST; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_proclist [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/procmem.h>
#include <guile/gh.h>
SCM
glibtop_guile_names_proc_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_proc_mem [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_proc_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_proc_mem [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_proc_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_proc_mem [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_proc_mem (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_MEM; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_proc_mem [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_proc_segment (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_proc_segment [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_proc_segment (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_proc_segment [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_proc_segment (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_proc_segment [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_proc_segment (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_SEGMENT; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_proc_segment [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_proc_signal (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_proc_signal [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_proc_signal (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_proc_signal [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_proc_signal (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_proc_signal [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_proc_signal (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_SIGNAL; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_proc_signal [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_proc_state (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_proc_state [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_proc_state (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_proc_state [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_proc_state (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_proc_state [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_proc_state (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_STATE; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_proc_state [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_proc_time (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_proc_time [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_proc_time (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_proc_time [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_proc_time (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_proc_time [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_proc_time (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_TIME; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_proc_time [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,95 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_proc_uid (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_names_proc_uid [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_proc_uid (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (glibtop_types_proc_uid [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_proc_uid (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_labels_proc_uid [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_proc_uid (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_PROC_UID; i++)
list = gh_append2
(list, gh_list
(gh_str02scm (gettext
(glibtop_descriptions_proc_uid [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,85 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_sem_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_sem_limits [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_sem_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_sem_limits [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_sem_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_sem_limits [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_sem_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SEM_LIMITS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_sem_limits [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,85 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_shm_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_shm_limits [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_shm_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_shm_limits [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_shm_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_shm_limits [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_shm_limits (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SHM_LIMITS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_shm_limits [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,84 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_names_swap (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SWAP; i++)
list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_swap [i]), SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_swap (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SWAP; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_swap [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_swap (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SWAP; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_swap [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_swap (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SWAP; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_swap [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,85 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/sysdeps.h>
#include <guile/gh.h>
SCM
glibtop_guile_names_sysdeps (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_sysdeps [i]),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_sysdeps (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_sysdeps [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_sysdeps (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_sysdeps [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_sysdeps (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_SYSDEPS; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_sysdeps [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,84 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/uptime.h>
#include <guile/gh.h>
SCM
glibtop_guile_names_uptime (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_UPTIME; i++)
list = gh_append2 (list, gh_list (gh_str02scm (glibtop_names_uptime [i]), SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_types_uptime (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_UPTIME; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_types_uptime [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_labels_uptime (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_UPTIME; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_labels_uptime [i])),
SCM_UNDEFINED));
return list;
}
SCM
glibtop_guile_descriptions_uptime (void)
{
int i;
SCM list;
list = gh_list (SCM_UNDEFINED);
for (i = 0; i < GLIBTOP_MAX_UPTIME; i++)
list = gh_append2 (list, gh_list (gh_str02scm (gettext (glibtop_descriptions_uptime [i])),
SCM_UNDEFINED));
return list;
}

View File

@@ -1,44 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_get_proc_kernel (SCM pid)
{
glibtop_proc_kernel p;
glibtop_get_proc_kernel (&p, (pid_t) gh_scm2long (pid));
return gh_list (gh_ulong2scm (p.flags),
gh_ulong2scm (p.k_flags),
gh_ulong2scm (p.min_flt),
gh_ulong2scm (p.maj_flt),
gh_ulong2scm (p.cmin_flt),
gh_ulong2scm (p.cmaj_flt),
gh_ulong2scm (p.kstk_esp),
gh_ulong2scm (p.kstk_eip),
gh_ulong2scm (p.wchan),
SCM_UNDEFINED);
}

View File

@@ -1,52 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_get_proclist (void)
{
glibtop_proclist proclist;
unsigned *ptr;
unsigned i;
SCM list;
ptr = glibtop_get_proclist (&proclist);
list = gh_list (gh_ulong2scm (proclist.flags),
gh_ulong2scm (proclist.number),
gh_ulong2scm (proclist.size),
gh_ulong2scm (proclist.total),
SCM_UNDEFINED);
if (ptr) {
for (i = 0; i < proclist.number; i++)
list = gh_append2 (list, gh_list (gh_ulong2scm ((unsigned long) ptr [i]), SCM_UNDEFINED));
}
glibtop_free (ptr);
return list;
}

View File

@@ -1,42 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/procmem.h>
#include <guile/gh.h>
SCM
glibtop_guile_get_proc_mem (SCM pid)
{
glibtop_proc_mem p;
glibtop_get_proc_mem (&p, (pid_t) gh_scm2long (pid));
return gh_list (gh_ulong2scm (p.flags),
gh_long2scm (p.size),
gh_long2scm (p.vsize),
gh_long2scm (p.resident),
gh_long2scm (p.share),
gh_long2scm (p.rss),
gh_long2scm (p.rss_rlim),
SCM_UNDEFINED);
}

View File

@@ -1,43 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_get_proc_segment (SCM pid)
{
glibtop_proc_segment p;
glibtop_get_proc_segment (&p, (pid_t) gh_scm2long (pid));
return gh_list (gh_ulong2scm (p.flags),
gh_long2scm (p.trs),
gh_long2scm (p.lrs),
gh_long2scm (p.drs),
gh_long2scm (p.dt),
gh_ulong2scm (p.start_code),
gh_ulong2scm (p.end_code),
gh_ulong2scm (p.start_stack),
SCM_UNDEFINED);
}

View File

@@ -1,40 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_get_proc_signal (SCM pid)
{
glibtop_proc_signal p;
glibtop_get_proc_signal (&p, (pid_t) gh_scm2long (pid));
return gh_list (gh_ulong2scm (p.flags),
gh_long2scm (p.signal),
gh_long2scm (p.blocked),
gh_long2scm (p.sigignore),
gh_long2scm (p.sigcatch),
SCM_UNDEFINED);
}

View File

@@ -1,40 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_get_proc_state (SCM pid)
{
glibtop_proc_state p;
glibtop_get_proc_state (&p, (pid_t) gh_scm2long (pid));
return gh_list (gh_ulong2scm (p.flags),
gh_str02scm (p.cmd),
gh_char2scm (p.state),
gh_ulong2scm (p.uid),
gh_ulong2scm (p.gid),
SCM_UNDEFINED);
}

View File

@@ -1,43 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_get_proc_time (SCM pid)
{
glibtop_proc_time p;
glibtop_get_proc_time (&p, (pid_t) gh_scm2long (pid));
return gh_list (gh_ulong2scm (p.flags),
gh_long2scm (p.start_time),
gh_long2scm (p.utime),
gh_long2scm (p.stime),
gh_long2scm (p.cutime),
gh_long2scm (p.cstime),
gh_long2scm (p.timeout),
gh_long2scm (p.it_real_value),
SCM_UNDEFINED);
}

View File

@@ -1,48 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM
glibtop_guile_get_proc_uid (SCM pid)
{
glibtop_proc_uid p;
glibtop_get_proc_uid (&p, (pid_t) gh_scm2long (pid));
return gh_list (gh_ulong2scm (p.flags),
gh_long2scm (p.uid),
gh_long2scm (p.euid),
gh_long2scm (p.gid),
gh_long2scm (p.egid),
gh_long2scm (p.pid),
gh_long2scm (p.ppid),
gh_long2scm (p.pgrp),
gh_long2scm (p.session),
gh_long2scm (p.tty),
gh_long2scm (p.tpgid),
gh_long2scm (p.priority),
gh_long2scm (p.nice),
SCM_UNDEFINED);
}

View File

@@ -1,45 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM glibtop_guile_get_sem_limits (void)
{
glibtop_sem_limits sem_limits;
glibtop_get_sem_limits (&sem_limits);
return gh_list (gh_ulong2scm (sem_limits.flags),
gh_ulong2scm (sem_limits.semmap),
gh_ulong2scm (sem_limits.semmni),
gh_ulong2scm (sem_limits.semmns),
gh_ulong2scm (sem_limits.semmnu),
gh_ulong2scm (sem_limits.semmsl),
gh_ulong2scm (sem_limits.semopm),
gh_ulong2scm (sem_limits.semume),
gh_ulong2scm (sem_limits.semusz),
gh_ulong2scm (sem_limits.semvmx),
gh_ulong2scm (sem_limits.semaem),
SCM_UNDEFINED);
}

View File

@@ -1,40 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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 <guile/gh.h>
SCM glibtop_guile_get_shm_limits (void)
{
glibtop_shm_limits shm_limits;
glibtop_get_shm_limits (&shm_limits);
return gh_list (gh_ulong2scm (shm_limits.flags),
gh_ulong2scm (shm_limits.shmmax),
gh_ulong2scm (shm_limits.shmmin),
gh_ulong2scm (shm_limits.shmmni),
gh_ulong2scm (shm_limits.shmseg),
gh_ulong2scm (shm_limits.shmall),
SCM_UNDEFINED);
}

View File

@@ -1,51 +0,0 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop.h>
#include <glibtop/sysdeps.h>
#include <guile/gh.h>
SCM glibtop_guile_get_sysdeps (void)
{
glibtop_sysdeps sysdeps;
glibtop_get_sysdeps (&sysdeps);
return gh_list (gh_ulong2scm (sysdeps.flags),
gh_ulong2scm (sysdeps.cpu),
gh_ulong2scm (sysdeps.mem),
gh_ulong2scm (sysdeps.swap),
gh_ulong2scm (sysdeps.uptime),
gh_ulong2scm (sysdeps.loadavg),
gh_ulong2scm (sysdeps.shm_limits),
gh_ulong2scm (sysdeps.msg_limits),
gh_ulong2scm (sysdeps.sem_limits),
gh_ulong2scm (sysdeps.proclist),
gh_ulong2scm (sysdeps.proc_state),
gh_ulong2scm (sysdeps.proc_uid),
gh_ulong2scm (sysdeps.proc_mem),
gh_ulong2scm (sysdeps.proc_time),
gh_ulong2scm (sysdeps.proc_signal),
gh_ulong2scm (sysdeps.proc_kernel),
gh_ulong2scm (sysdeps.proc_segment),
SCM_UNDEFINED);
}

28
sysdeps/kernel/.cvsignore Normal file
View File

@@ -0,0 +1,28 @@
.deps
.libs
Makefile
Makefile.in
close.lo
cpu.lo
init.lo
ipc_limits.lo
libgtop_sysdeps.la
loadavg.lo
mem.lo
msg_limits.lo
open.lo
procdata.lo
prockernel.lo
proclist.lo
procmem.lo
procsegment.lo
procsignal.lo
procstate.lo
proctime.lo
procuid.lo
sem_limits.lo
shm_limits.lo
swap.lo
sysdeps.lo
sysinfo.lo
uptime.lo

11
sysdeps/kernel/ChangeLog Normal file
View File

@@ -0,0 +1,11 @@
1998-06-14 Martin Baulig <martin@home-of-linux.org>
* kernel.s: New file - declaration of the table () function
via _syscall3 (); due to a bug in egcs, we cannot put this
into a C file.
1998-06-13 Martin Baulig <martin@home-of-linux.org>
The code in this directory fetches all information
directly from the kernel. It uses the new table ()
system call from the `kernel' directory.

View File

@@ -0,0 +1,23 @@
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
INCLUDES = -I$(top_builddir) -I$(top_srcdir) @machine_incs@ \
-I$(top_srcdir)/include -I$(top_srcdir)/intl @GUILE_INCS@ \
-DGTOPLOCALEDIR=\"$(datadir)/locale\" -D_GNU_SOURCE
CFLAGS = -Wall -W @CFLAGS@
lib_LTLIBRARIES = libgtop_sysdeps.la
libgtop_sysdeps_la_SOURCES = init.c open.c close.c kernel.s 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
include_HEADERS = glibtop_server.h
kernel.o kernel.lo: kernel.s
rm -f kernel.o kernel.lo
$(AS) -o kernel.o kernel.s
cp kernel.o kernel.lo

View File

@@ -19,20 +19,10 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h> #include <glibtop/close.h>
#include <glibtop/swap.h>
#include <guile/gh.h> /* Closes pipe to gtop server. */
SCM glibtop_guile_get_swap (void) void
{ glibtop_close_l (glibtop *server)
glibtop_swap swap; { }
glibtop_get_swap (&swap);
return gh_list (gh_ulong2scm (swap.flags),
gh_ulong2scm (swap.total),
gh_ulong2scm (swap.used),
gh_ulong2scm (swap.free),
SCM_UNDEFINED);
}

View File

@@ -19,21 +19,37 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h> #include <config.h>
#include <glibtop/error.h>
#include <glibtop/cpu.h> #include <glibtop/cpu.h>
#include <glibtop/command.h>
#include "kernel.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. */ /* Provides information about cpu usage. */
void void
glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf) glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_CPU, 0); union table tbl;
if (server->features & GLIBTOP_SYSDEPS_CPU) { glibtop_init_r (&server, 0, 0);
glibtop_call_l (server, GLIBTOP_CMND_CPU, 0, NULL,
sizeof (glibtop_cpu), buf); memset (buf, 0, sizeof (glibtop_cpu));
} else {
glibtop_get_cpu_r (server, buf); if (table (TABLE_CPU, &tbl, NULL))
} glibtop_error_r (server, "table(TABLE_CPU): %s\n", strerror (errno));
buf->flags = _glibtop_sysdeps_cpu;
buf->total = tbl.cpu.total;
buf->user = tbl.cpu.user;
buf->nice = tbl.cpu.nice;
buf->sys = tbl.cpu.sys;
buf->idle = tbl.cpu.idle;
buf->frequency = tbl.cpu.frequency;
} }

View File

@@ -19,20 +19,28 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop/proclist.h> #ifndef __GLIBTOP_SERVER_H__
#include <glibtop/command.h> #define __GLIBTOP_SERVER_H__
/* Fetch list of currently running processes. */ __BEGIN_DECLS
unsigned * #define GLIBTOP_SUID_CPU 0
glibtop_get_proclist_l (glibtop *server, glibtop_proclist *buf) #define GLIBTOP_SUID_MEM 0
{ #define GLIBTOP_SUID_SWAP 0
glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROCLIST, 0); #define GLIBTOP_SUID_UPTIME 0
#define GLIBTOP_SUID_LOADAVG 0
#define GLIBTOP_SUID_SHM_LIMITS 0
#define GLIBTOP_SUID_MSG_LIMITS 0
#define GLIBTOP_SUID_SEM_LIMITS 0
#define GLIBTOP_SUID_PROCLIST 0
#define GLIBTOP_SUID_PROC_STATE 0
#define GLIBTOP_SUID_PROC_UID 0
#define GLIBTOP_SUID_PROC_MEM 0
#define GLIBTOP_SUID_PROC_TIME 0
#define GLIBTOP_SUID_PROC_SIGNAL 0
#define GLIBTOP_SUID_PROC_KERNEL 0
#define GLIBTOP_SUID_PROC_SEGMENT 0
if (server->features & GLIBTOP_SYSDEPS_PROCLIST) { __END_DECLS
return glibtop_call_l (server, GLIBTOP_CMND_PROCLIST, 0, NULL,
sizeof (glibtop_proclist), buf); #endif
} else {
return glibtop_get_proclist_r (server, buf);
}
}

View File

@@ -20,21 +20,25 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/procuid.h> #include <glibtop/open.h>
#include <glibtop/command.h>
/* Provides detailed information about a process. */ static glibtop _glibtop_global_server;
glibtop *glibtop_global_server = NULL;
void glibtop *
glibtop_get_proc_uid_l (glibtop *server, glibtop_proc_uid *buf, glibtop_init_r (glibtop **server, const unsigned long features,
pid_t pid) const unsigned flags)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_UID, 0); if (*server != NULL)
return *server;
if (server->features & GLIBTOP_SYSDEPS_PROC_UID) { fprintf (stderr, "DEBUG: %s (%d)\n", __FILE__, __LINE__);
glibtop_call_l (server, GLIBTOP_CMND_PROC_UID, sizeof (pid_t),
&pid, sizeof (glibtop_proc_uid), buf); if (glibtop_global_server == NULL) {
} else { glibtop_global_server = &_glibtop_global_server;
glibtop_get_proc_uid_r (server, buf, pid); glibtop_open_r (glibtop_global_server, "glibtop",
features, flags);
} }
return *server = glibtop_global_server;
} }

View File

@@ -19,19 +19,20 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h> #ifndef __GLIBTOP_KERNEL_KERNEL_H__
#include <glibtop/uptime.h> #define __GLIBTOP_KERNEL_KERNEL_H__
#include <guile/gh.h> #include <linux/unistd.h>
#include <linux/table.h>
SCM glibtop_guile_get_uptime (void) #include <sys/param.h>
{
glibtop_uptime uptime;
glibtop_get_uptime (&uptime); #include <syscall.h>
return gh_list (gh_ulong2scm (uptime.flags), __BEGIN_DECLS
gh_double2scm (uptime.uptime),
gh_double2scm (uptime.idletime), extern int table (int, union table *, const void *);
SCM_UNDEFINED);
} __END_DECLS
#endif

42
sysdeps/kernel/kernel.s Normal file
View File

@@ -0,0 +1,42 @@
.file "test.c"
.version "01.01"
/ GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release) (i686-pc-linux-gnu) compiled by GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release).
/ options passed: -O2 -Wall -W
/ options enabled: -fdefer-pop -fcse-follow-jumps -fcse-skip-blocks
/ -fexpensive-optimizations -fthread-jumps -fstrength-reduce -fpeephole
/ -fforce-mem -ffunction-cse -finline -fkeep-static-consts -fcaller-saves
/ -fpcc-struct-return -frerun-cse-after-loop -frerun-loop-opt
/ -fschedule-insns2 -fcommon -fverbose-asm -fgnu-linker -fregmove
/ -falias-check -fargument-alias -m80387 -mhard-float -mno-soft-float
/ -mieee-fp -mfp-ret-in-387 -mschedule-prologue -mcpu=pentiumpro
/ -march=pentium
gcc2_compiled.:
.text
.align 4
.globl table
.type table,@function
table:
pushl %ebp
movl %esp,%ebp
movl $168,%eax
pushl %ebx
movl 8(%ebp),%ebx
movl 12(%ebp),%ecx
movl 16(%ebp),%edx
#APP
int $0x80
#NO_APP
testl %eax,%eax
jge .L3
negl %eax
movl %eax,errno
movl $-1,%eax
.L3:
movl -4(%ebp),%ebx
movl %ebp,%esp
popl %ebp
ret
.Lfe1:
.size table,.Lfe1-table
.ident "GCC: (GNU) egcs-2.90.29 980515 (egcs-1.0.3 release)"

View File

@@ -20,20 +20,38 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <config.h> #include <config.h>
#include <glibtop/error.h>
#include <glibtop/loadavg.h> #include <glibtop/loadavg.h>
#include <glibtop/command.h>
/* Provides load averange. */ #include "kernel.h"
static const unsigned long _glibtop_sysdeps_loadavg =
(1 << GLIBTOP_LOADAVG_LOADAVG);
/* Provides load load averange. */
void void
glibtop_get_loadavg_l (glibtop *server, glibtop_loadavg *buf) glibtop_get_loadavg_s (glibtop *server, glibtop_loadavg *buf)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_LOADAVG, 0); union table tbl;
glibtop_init_r (&server, 0, 0);
if (server->features & GLIBTOP_SYSDEPS_LOADAVG) { memset (buf, 0, sizeof (glibtop_loadavg));
glibtop_call_l (server, GLIBTOP_CMND_LOADAVG, 0, NULL,
sizeof (glibtop_loadavg), buf); if (table (TABLE_LOADAVG, &tbl, NULL))
} else { glibtop_error_r (server, "table(TABLE_LOADAVG): %s\n", strerror (errno));
glibtop_get_loadavg_r (server, buf);
} buf->flags = _glibtop_sysdeps_loadavg;
#if 0
fprintf (stderr, "Table (%u) = (%lu, %lu, %lu) - %u, %u, %u\n",
TABLE_LOADAVG, tbl.loadavg.loadavg [0], tbl.loadavg.loadavg [1],
tbl.loadavg.loadavg [2], tbl.loadavg.nr_running,
tbl.loadavg.nr_tasks, tbl.loadavg.last_pid);
#endif
buf->loadavg [0] = tbl.loadavg.loadavg [0];
buf->loadavg [1] = tbl.loadavg.loadavg [1];
buf->loadavg [2] = tbl.loadavg.loadavg [2];
} }

View File

@@ -19,20 +19,40 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <config.h>
#include <glibtop/error.h>
#include <glibtop/mem.h> #include <glibtop/mem.h>
#include <glibtop/command.h>
#include "kernel.h"
static const unsigned long _glibtop_sysdeps_mem =
(1 << GLIBTOP_MEM_TOTAL) + (1 << GLIBTOP_MEM_USED) +
(1 << GLIBTOP_MEM_FREE) + (1 << GLIBTOP_MEM_SHARED) +
(1 << GLIBTOP_MEM_BUFFER) + (1 << GLIBTOP_MEM_CACHED) +
(1 << GLIBTOP_MEM_USER);
/* Provides information about memory usage. */ /* Provides information about memory usage. */
void void
glibtop_get_mem_l (glibtop *server, glibtop_mem *buf) glibtop_get_mem_s (glibtop *server, glibtop_mem *buf)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_MEM, 0); union table tbl;
glibtop_init_r (&server, 0, 0);
if (server->features & GLIBTOP_SYSDEPS_MEM) { memset (buf, 0, sizeof (glibtop_mem));
glibtop_call_l (server, GLIBTOP_CMND_MEM, 0, NULL,
sizeof (glibtop_mem), buf); if (table (TABLE_MEM, &tbl, NULL))
} else { glibtop_error_r (server, "table(TABLE_MEM): %s\n", strerror (errno));
glibtop_get_mem_r (server, buf);
} buf->flags = _glibtop_sysdeps_mem;
buf->total = tbl.mem.total;
buf->used = tbl.mem.used;
buf->free = tbl.mem.free;
buf->shared = tbl.mem.shared;
buf->buffer = tbl.mem.buffer;
buf->cached = tbl.mem.cached;
buf->user = buf->total - buf->free - buf->shared - buf->buffer;
} }

View File

@@ -20,19 +20,36 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop/msg_limits.h> #include <glibtop/msg_limits.h>
#include <glibtop/command.h>
#include <sys/ipc.h>
#include <sys/msg.h>
static const unsigned long _glibtop_sysdeps_msg_limits =
(1 << GLIBTOP_IPC_MSGPOOL) + (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. */ /* Provides information about sysv ipc limits. */
void void
glibtop_get_msg_limits_l (glibtop *server, glibtop_msg_limits *buf) glibtop_get_msg_limits_s (glibtop *server, glibtop_msg_limits *buf)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_MSG_LIMITS, 0); struct msginfo msginfo;
glibtop_init_r (&server, 0, 0);
if (server->features & GLIBTOP_SYSDEPS_MSG_LIMITS) { memset (buf, 0, sizeof (glibtop_msg_limits));
glibtop_call_l (server, GLIBTOP_CMND_MSG_LIMITS, 0, NULL,
sizeof (glibtop_msg_limits), buf); buf->flags = _glibtop_sysdeps_msg_limits;
} else {
glibtop_get_msg_limits_r (server, buf); msgctl (0, IPC_INFO, (struct msqid_ds *) &msginfo);
}
buf->msgpool = msginfo.msgpool;
buf->msgmap = msginfo.msgmap;
buf->msgmax = msginfo.msgmax;
buf->msgmnb = msginfo.msgmnb;
buf->msgmni = msginfo.msgmni;
buf->msgssz = msginfo.msgssz;
buf->msgtql = msginfo.msgtql;
} }

62
sysdeps/kernel/open.c Normal file
View File

@@ -0,0 +1,62 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <glibtop/open.h>
/* =====================================================
* Linux kernel version information for procps utilities
* Copyright (c) 1996 Charles Blake <cblake@bbn.com>
*/
#include <sys/utsname.h>
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
static int linux_version_code = 0;
static void set_linux_version(void) {
static struct utsname uts;
int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
if (linux_version_code) return;
if (uname(&uts) == -1) /* failure most likely implies impending death */
exit(1);
if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
fprintf(stderr, /* *very* unlikely to happen by accident */
"Non-standard uts for running kernel:\n"
"release %s=%d.%d.%d gives version code %d\n",
uts.release, x, y, z, LINUX_VERSION(x,y,z));
linux_version_code = LINUX_VERSION(x, y, z);
}
/* ======================================================= */
/* Opens pipe to gtop server. Returns 0 on success and -1 on error. */
void
glibtop_open_r (glibtop *server, const char *program_name,
const unsigned long features, const unsigned flags)
{
memset (server, 0, sizeof (glibtop));
server->name = program_name;
set_linux_version ();
server->os_version_code = (unsigned long) linux_version_code;
}

178
sysdeps/kernel/procdata.c Normal file
View File

@@ -0,0 +1,178 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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>
#include <sys/stat.h>
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
#define BIT_SHIFT(x) (1 << (x % 32))
static const unsigned long _glibtop_sysdeps_procdata_0 =
BIT_SHIFT(GLIBTOP_PROCDATA_CMD) +
BIT_SHIFT(GLIBTOP_PROCDATA_STATE) +
BIT_SHIFT(GLIBTOP_PROCDATA_UID) +
BIT_SHIFT(GLIBTOP_PROCDATA_PID) +
BIT_SHIFT(GLIBTOP_PROCDATA_PPID) +
BIT_SHIFT(GLIBTOP_PROCDATA_PGRP) +
BIT_SHIFT(GLIBTOP_PROCDATA_SESSION) +
BIT_SHIFT(GLIBTOP_PROCDATA_TTY) +
BIT_SHIFT(GLIBTOP_PROCDATA_TPGID) +
BIT_SHIFT(GLIBTOP_PROCDATA_PRIORITY) +
BIT_SHIFT(GLIBTOP_PROCDATA_NICE) +
BIT_SHIFT(GLIBTOP_PROCDATA_SIGNAL) +
BIT_SHIFT(GLIBTOP_PROCDATA_BLOCKED) +
BIT_SHIFT(GLIBTOP_PROCDATA_SIGIGNORE) +
BIT_SHIFT(GLIBTOP_PROCDATA_SIGCATCH) +
BIT_SHIFT(GLIBTOP_PROCDATA_START_TIME) +
BIT_SHIFT(GLIBTOP_PROCDATA_UTIME) +
BIT_SHIFT(GLIBTOP_PROCDATA_STIME) +
BIT_SHIFT(GLIBTOP_PROCDATA_CUTIME) +
BIT_SHIFT(GLIBTOP_PROCDATA_CSTIME) +
BIT_SHIFT(GLIBTOP_PROCDATA_SIZE) +
BIT_SHIFT(GLIBTOP_PROCDATA_RESIDENT) +
BIT_SHIFT(GLIBTOP_PROCDATA_SHARE) +
BIT_SHIFT(GLIBTOP_PROCDATA_TRS) +
BIT_SHIFT(GLIBTOP_PROCDATA_LRS) +
BIT_SHIFT(GLIBTOP_PROCDATA_DRS) +
BIT_SHIFT(GLIBTOP_PROCDATA_DT) +
BIT_SHIFT(GLIBTOP_PROCDATA_VSIZE) +
BIT_SHIFT(GLIBTOP_PROCDATA_RSS) +
BIT_SHIFT(GLIBTOP_PROCDATA_RSS_RLIM) +
BIT_SHIFT(GLIBTOP_PROCDATA_TIMEOUT) +
BIT_SHIFT(GLIBTOP_PROCDATA_IT_REAL_VALUE);
static const unsigned long _glibtop_sysdeps_procdata_1 =
BIT_SHIFT(GLIBTOP_PROCDATA_K_FLAGS) +
BIT_SHIFT(GLIBTOP_PROCDATA_MIN_FLT) +
BIT_SHIFT(GLIBTOP_PROCDATA_MAJ_FLT) +
BIT_SHIFT(GLIBTOP_PROCDATA_CMIN_FLT) +
BIT_SHIFT(GLIBTOP_PROCDATA_CMAJ_FLT) +
BIT_SHIFT(GLIBTOP_PROCDATA_START_CODE) +
BIT_SHIFT(GLIBTOP_PROCDATA_END_CODE) +
BIT_SHIFT(GLIBTOP_PROCDATA_START_STACK) +
BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_ESP) +
BIT_SHIFT(GLIBTOP_PROCDATA_KSTK_EIP) +
BIT_SHIFT(GLIBTOP_PROCDATA_WCHAN);
/* Provides detailed information about a process. */
void
glibtop_get_procdata_s (glibtop *server, glibtop_procdata *buf, pid_t pid)
{
char input [BUFSIZ], *tmp;
struct stat statb;
int nread;
FILE *f;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_procdata));
if (pid == 0) {
/* Client is only interested in the flags. */
buf->flags [0] = _glibtop_sysdeps_procdata_0;
buf->flags [1] = _glibtop_sysdeps_procdata_1;
return;
}
sprintf (input, "/proc/%d/stat", pid);
if (stat (input, &statb)) return;
buf->uid = statb.st_uid;
f = fopen (input, "r");
if (!f) return;
nread = fread (input, 1, BUFSIZ, f);
if (nread < 0) {
fclose (f);
return;
}
input [nread] = 0;
/* This is from guile-utils/gtop/proc/readproc.c */
/* split into "PID (cmd" and "<rest>" */
tmp = strrchr (input, ')');
*tmp = '\0'; /* replace trailing ')' with NUL */
/* parse these two strings separately, skipping the leading "(". */
memset (buf->cmd, 0, sizeof (buf->cmd));
sscanf (input, "%d (%39c", &buf->pid, buf->cmd);
sscanf(tmp + 2, /* skip space after ')' too */
"%c %d %d %d %d %d %lu %lu %lu %lu %lu "
"%ld %ld %ld %ld %d %d %lu %lu %ld %lu "
"%lu %lu %lu %lu %lu %lu %lu %d %d %d %d %lu",
&buf->state, &buf->ppid, &buf->pgrp, &buf->session,
&buf->tty, &buf->tpgid, &buf->k_flags, &buf->min_flt,
&buf->cmin_flt, &buf->maj_flt, &buf->cmaj_flt,
&buf->utime, &buf->stime, &buf->cutime, &buf->cstime,
&buf->priority, &buf->nice, &buf->timeout,
&buf->it_real_value, &buf->start_time, &buf->vsize,
&buf->rss, &buf->rss_rlim, &buf->start_code,
&buf->end_code, &buf->start_stack, &buf->kstk_esp,
&buf->kstk_eip, &buf->signal, &buf->blocked,
&buf->sigignore, &buf->sigcatch, &buf->wchan);
if (buf->tty == 0)
/* the old notty val, update elsewhere bef. moving to 0 */
buf->tty = -1;
if (server->os_version_code < LINUX_VERSION(1,3,39)) {
/* map old meanings to new */
buf->priority = 2*15 - buf->priority;
buf->nice = 15 - buf->nice;
}
if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
/* when tty wasn't full devno */
buf->tty = 4*0x100 + buf->tty;
fclose (f);
sprintf (input, "/proc/%d/statm", pid);
f = fopen (input, "r");
if (!f) return;
nread = fread (input, 1, BUFSIZ, f);
if (nread < 0) {
fclose (f);
return;
}
input [nread] = 0;
sscanf (input, "%ld %ld %ld %ld %ld %ld %ld",
&buf->size, &buf->resident, &buf->share,
&buf->trs, &buf->lrs, &buf->drs, &buf->dt);
fclose (f);
buf->flags [0] = _glibtop_sysdeps_procdata_0;
buf->flags [1] = _glibtop_sysdeps_procdata_1;
}

View File

@@ -0,0 +1,63 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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/prockernel.h>
#include "kernel.h"
static const unsigned long _glibtop_sysdeps_proc_kernel =
(1 << GLIBTOP_PROC_KERNEL_K_FLAGS) + (1 << GLIBTOP_PROC_KERNEL_MIN_FLT) +
(1 << GLIBTOP_PROC_KERNEL_MAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_CMIN_FLT) +
(1 << GLIBTOP_PROC_KERNEL_CMAJ_FLT) + (1 << GLIBTOP_PROC_KERNEL_KSTK_ESP) +
(1 << GLIBTOP_PROC_KERNEL_KSTK_EIP) + (1 << GLIBTOP_PROC_KERNEL_WCHAN);
/* Provides detailed information about a process. */
void
glibtop_get_proc_kernel_s (glibtop *server, glibtop_proc_kernel *buf, pid_t pid)
{
union table tbl;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_proc_kernel));
if (pid == 0) {
/* Client is only interested in the flags. */
buf->flags = _glibtop_sysdeps_proc_kernel;
return;
}
if (table (TABLE_PROC_KERNEL, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_KERNEL): %s\n", strerror (errno));
buf->flags = _glibtop_sysdeps_proc_kernel;
buf->min_flt = tbl.proc_kernel.min_flt;
buf->cmin_flt = tbl.proc_kernel.cmin_flt;
buf->maj_flt = tbl.proc_kernel.maj_flt;
buf->cmaj_flt = tbl.proc_kernel.cmaj_flt;
buf->kstk_esp = tbl.proc_kernel.kesp;
buf->kstk_eip = tbl.proc_kernel.keip;
buf->wchan = tbl.proc_kernel.wchan;
}

155
sysdeps/kernel/proclist.c Normal file
View File

@@ -0,0 +1,155 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <config.h>
#include <glibtop/xmalloc.h>
#include <glibtop/proclist.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <ctype.h>
static const unsigned long _glibtop_sysdeps_proclist =
(1 << GLIBTOP_PROCLIST_TOTAL) + (1 << GLIBTOP_PROCLIST_NUMBER) +
(1 << GLIBTOP_PROCLIST_SIZE);
#define BLOCK_COUNT 256
#define BLOCK_SIZE (BLOCK_COUNT * sizeof (unsigned))
/* Fetch list of currently running processes.
*
* The interface of this function is a little bit different from the others:
* buf->flags is only set if the call succeeded, in this case pids_chain,
* a list of the pids of all currently running processes is returned,
* buf->number is the number of elements of this list and buf->size is
* the size of one single element (sizeof (unsigned)). The total size is
* stored in buf->total.
*
* The calling function has to free the memory to which a pointer is returned.
*
* On error, NULL is returned and buf->flags is zero. */
unsigned *
glibtop_get_proclist_s (glibtop *server, glibtop_proclist *buf)
{
DIR *proc;
struct dirent *entry;
char buffer [BUFSIZ];
unsigned count, total, pid;
unsigned pids [BLOCK_COUNT], *pids_chain = NULL;
unsigned pids_size = 0, pids_offset = 0, new_size;
struct stat statb;
int len, i, ok;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_proclist));
proc = opendir ("/proc");
if (!proc) return NULL;
/* read every every entry in /proc */
for (count = total = 0, entry = readdir (proc); entry; entry = readdir (proc)) {
ok = 1; len = strlen (entry->d_name);
/* does it consist entirely of digits? */
for (i = 0; i < len; i++)
if (!isdigit (entry->d_name [i])) ok = 0;
if (!ok) continue;
/* convert it in a number */
if (sscanf (entry->d_name, "%u", &pid) != 1) continue;
/* is it really a directory? */
sprintf (buffer, "/proc/%d", pid);
if (stat (buffer, &statb)) continue;
if (!S_ISDIR (statb.st_mode)) continue;
/* Fine. Now we first try to store it in pids. If this buffer is
* full, we copy it to the pids_chain. */
if (count >= BLOCK_COUNT) {
/* The following call to glibtop_realloc will be equivalent to
* glibtop_malloc if pids_chain is NULL. We just calculate the
* new size and copy pids to the beginning of the newly allocated
* block. */
new_size = pids_size + BLOCK_SIZE;
pids_chain = glibtop_realloc_r (server, pids_chain, new_size);
memcpy (pids_chain + pids_offset, pids, BLOCK_SIZE);
pids_size = new_size;
pids_offset += BLOCK_COUNT;
count = 0;
}
/* pids is now big enough to hold at least one single pid. */
pids [count++] = pid;
total++;
}
closedir (proc);
/* count is only zero if an error occured (one a running Linux system, we
* only have at least one single process). */
if (!count) return NULL;
/* The following call to glibtop_realloc will be equivalent to
* glibtop_malloc if pids_chain is NULL. We just calculate the
* new size and copy pids to the beginning of the newly allocated
* block. */
new_size = pids_size + count * sizeof (unsigned);
pids_chain = glibtop_realloc_r (server, pids_chain, new_size);
memcpy (pids_chain + pids_offset, pids, count * sizeof (unsigned));
pids_size = new_size;
pids_offset += BLOCK_COUNT;
/* Since everything is ok now, we can set buf->flags, fill in the remaining fields
and return pids_chain. */
buf->flags = _glibtop_sysdeps_proclist;
buf->size = sizeof (unsigned);
buf->number = total;
buf->total = total * sizeof (unsigned);
return pids_chain;
}

View File

@@ -20,21 +20,46 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/procmem.h> #include <glibtop/procmem.h>
#include <glibtop/command.h>
#include "kernel.h"
static const unsigned long _glibtop_sysdeps_proc_mem =
(1 << GLIBTOP_PROC_MEM_SIZE) + (1 << GLIBTOP_PROC_MEM_VSIZE) +
(1 << GLIBTOP_PROC_MEM_RESIDENT) + (1 << GLIBTOP_PROC_MEM_SHARE) +
(1 << GLIBTOP_PROC_MEM_RSS) + (1 << GLIBTOP_PROC_MEM_RSS_RLIM);
/* Provides detailed information about a process. */ /* Provides detailed information about a process. */
void void
glibtop_get_proc_mem_l (glibtop *server, glibtop_proc_mem *buf, glibtop_get_proc_mem_s (glibtop *server, glibtop_proc_mem *buf, pid_t pid)
pid_t pid)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_MEM, 0); union table tbl;
if (server->features & GLIBTOP_SYSDEPS_PROC_MEM) { glibtop_init_r (&server, 0, 0);
glibtop_call_l (server, GLIBTOP_CMND_PROC_MEM, sizeof (pid_t),
&pid, sizeof (glibtop_proc_mem), buf); memset (buf, 0, sizeof (glibtop_proc_mem));
} else {
glibtop_get_proc_mem_r (server, buf, pid); if (pid == 0) {
/* Client is only interested in the flags. */
buf->flags = _glibtop_sysdeps_proc_mem;
return;
} }
if (table (TABLE_PROC_MEM, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_MEM): %s\n", strerror (errno));
buf->rss = tbl.proc_mem.rss;
buf->rss_rlim = tbl.proc_mem.rlim;
if (table (TABLE_PROC_SEGMENT, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_SEGMENT): %s\n", strerror (errno));
buf->flags = _glibtop_sysdeps_proc_mem;
buf->vsize = tbl.proc_segment.vsize;
buf->size = tbl.proc_segment.size;
buf->resident = tbl.proc_segment.resident;
buf->share = tbl.proc_segment.shared;
} }

View File

@@ -0,0 +1,68 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <config.h>
#include <glibtop/error.h>
#include <glibtop/procsegment.h>
#include "kernel.h"
static const unsigned long _glibtop_sysdeps_proc_segment =
(1 << GLIBTOP_PROC_SEGMENT_TRS) + (1 << GLIBTOP_PROC_SEGMENT_LRS) +
(1 << GLIBTOP_PROC_SEGMENT_DRS) + (1 << GLIBTOP_PROC_SEGMENT_DT) +
(1 << GLIBTOP_PROC_SEGMENT_START_CODE) + (1 << GLIBTOP_PROC_SEGMENT_END_CODE) +
(1 << GLIBTOP_PROC_SEGMENT_START_STACK);
/* Provides detailed information about a process. */
void
glibtop_get_proc_segment_s (glibtop *server, glibtop_proc_segment *buf,
pid_t pid)
{
union table tbl;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_proc_segment));
if (pid == 0) {
/* Client is only interested in the flags. */
buf->flags = _glibtop_sysdeps_proc_segment;
return;
}
if (table (TABLE_PROC_MEM, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_MEM): %s\n", strerror (errno));
buf->start_code = tbl.proc_mem.start_code;
buf->end_code = tbl.proc_mem.end_code;
buf->start_stack = tbl.proc_mem.start_stack;
if (table (TABLE_PROC_SEGMENT, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_SEGMENT): %s\n", strerror (errno));
buf->flags = _glibtop_sysdeps_proc_segment;
buf->trs = tbl.proc_segment.trs;
buf->lrs = tbl.proc_segment.lrs;
buf->drs = tbl.proc_segment.drs;
buf->dt = tbl.proc_segment.dt;
}

View File

@@ -20,21 +20,40 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/procsignal.h> #include <glibtop/procsignal.h>
#include <glibtop/command.h>
#include "kernel.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. */ /* Provides detailed information about a process. */
void void
glibtop_get_proc_signal_l (glibtop *server, glibtop_proc_signal *buf, glibtop_get_proc_signal_s (glibtop *server, glibtop_proc_signal *buf, pid_t pid)
pid_t pid)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_SIGNAL, 0); union table tbl;
if (server->features & GLIBTOP_SYSDEPS_PROC_SIGNAL) { glibtop_init_r (&server, 0, 0);
glibtop_call_l (server, GLIBTOP_CMND_PROC_SIGNAL, sizeof (pid_t),
&pid, sizeof (glibtop_proc_signal), buf); memset (buf, 0, sizeof (glibtop_proc_signal));
} else {
glibtop_get_proc_signal_r (server, buf, pid); if (pid == 0) {
/* Client is only interested in the flags. */
buf->flags = _glibtop_sysdeps_proc_signal;
return;
} }
if (table (TABLE_PROC_SIGNAL, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_SIGNAL): %s\n", strerror (errno));
buf->flags = _glibtop_sysdeps_proc_signal;
buf->signal = tbl.proc_signal.signal;
buf->blocked = tbl.proc_signal.blocked;
buf->sigignore = tbl.proc_signal.ignored;
buf->sigcatch = tbl.proc_signal.caught;
} }

View File

@@ -20,21 +20,46 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/procstate.h> #include <glibtop/procstate.h>
#include <glibtop/command.h>
#include "kernel.h"
static const unsigned long _glibtop_sysdeps_proc_state =
(1 << GLIBTOP_PROC_STATE_CMD) + (1 << GLIBTOP_PROC_STATE_STATE);
/* Provides detailed information about a process. */ /* Provides detailed information about a process. */
void #define NR_STATES 7
glibtop_get_proc_state_l (glibtop *server, glibtop_proc_state *buf,
pid_t pid)
{
glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_STATE, 0);
if (server->features & GLIBTOP_SYSDEPS_PROC_STATE) { void
glibtop_call_l (server, GLIBTOP_CMND_PROC_STATE, sizeof (pid_t), glibtop_get_proc_state_s (glibtop *server, glibtop_proc_state *buf, pid_t pid)
&pid, sizeof (glibtop_proc_state), buf); {
} else { union table tbl;
glibtop_get_proc_state_r (server, buf, pid); static const char states [NR_STATES] = { 'R', 'S', 'D', 'Z', 'T', 'W', '.' };
unsigned state;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_proc_state));
if (pid == 0) {
/* Client is only interested in the flags. */
buf->flags = _glibtop_sysdeps_proc_state;
return;
} }
if (table (TABLE_PROC_STATE, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_STATE): %s\n", strerror (errno));
buf->flags = _glibtop_sysdeps_proc_state;
memcpy (buf->cmd, tbl.proc_state.comm, sizeof (tbl.proc_state.comm));
state = (unsigned) tbl.proc_state.state;
if (state >= NR_STATES)
state = NR_STATES;
buf->state = states [state];
} }

View File

@@ -20,21 +20,42 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/error.h>
#include <glibtop/proctime.h> #include <glibtop/proctime.h>
#include <glibtop/command.h>
#include "kernel.h"
static const unsigned long _glibtop_sysdeps_proc_time =
(1 << GLIBTOP_PROC_TIME_UTIME) + (1 << GLIBTOP_PROC_TIME_CUTIME) +
(1 << GLIBTOP_PROC_TIME_STIME) + (1 << GLIBTOP_PROC_TIME_CSTIME) +
(1 << GLIBTOP_PROC_TIME_TIMEOUT) + (1 << GLIBTOP_PROC_TIME_IT_REAL_VALUE) +
(1 << GLIBTOP_PROC_TIME_START_TIME);
/* Provides detailed information about a process. */ /* Provides detailed information about a process. */
void void
glibtop_get_proc_time_l (glibtop *server, glibtop_proc_time *buf, glibtop_get_proc_time_s (glibtop *server, glibtop_proc_time *buf, pid_t pid)
pid_t pid)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_PROC_TIME, 0); union table tbl;
if (server->features & GLIBTOP_SYSDEPS_PROC_TIME) { glibtop_init_r (&server, 0, 0);
glibtop_call_l (server, GLIBTOP_CMND_PROC_TIME, sizeof (pid_t),
&pid, sizeof (glibtop_proc_time), buf); memset (buf, 0, sizeof (glibtop_proc_time));
} else {
glibtop_get_proc_time_r (server, buf, pid); if (pid == 0) {
/* Client is only interested in the flags. */
buf->flags = _glibtop_sysdeps_proc_time;
return;
} }
if (table (TABLE_PROC_TIME, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_TIME): %s\n", strerror (errno));
buf->utime = tbl.proc_time.utime;
buf->stime = tbl.proc_time.stime;
buf->cutime = tbl.proc_time.cutime;
buf->cstime = tbl.proc_time.cstime;
buf->timeout = tbl.proc_time.timeout;
buf->it_real_value = tbl.proc_time.it_real_value;
buf->start_time = tbl.proc_time.start_time;
} }

100
sysdeps/kernel/procuid.c Normal file
View File

@@ -0,0 +1,100 @@
/* $Id$ */
/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the Gnome Top Library.
Contributed by Martin Baulig <martin@home-of-linux.org>, April 1998.
The Gnome Top Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Gnome Top Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. 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/procuid.h>
#include "kernel.h"
static const unsigned long _glibtop_sysdeps_proc_uid =
(1 << GLIBTOP_PROC_UID_UID) + (1 << GLIBTOP_PROC_UID_EUID) +
(1 << GLIBTOP_PROC_UID_GID) + (1 << GLIBTOP_PROC_UID_EGID) +
(1 << GLIBTOP_PROC_UID_PID) + (1 << GLIBTOP_PROC_UID_PPID) +
(1 << GLIBTOP_PROC_UID_PGRP) + (1 << GLIBTOP_PROC_UID_SESSION) +
(1 << GLIBTOP_PROC_UID_TTY) + (1 << GLIBTOP_PROC_UID_TPGID) +
(1 << GLIBTOP_PROC_UID_PRIORITY) + (1 << GLIBTOP_PROC_UID_NICE);
#define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
/* Provides detailed information about a process. */
void
glibtop_get_proc_uid_s (glibtop *server, glibtop_proc_uid *buf, pid_t pid)
{
union table tbl;
long def_priority, priority, nice;
glibtop_init_r (&server, 0, 0);
memset (buf, 0, sizeof (glibtop_proc_uid));
if (pid == 0) {
/* Client is only interested in the flags. */
buf->flags = _glibtop_sysdeps_proc_uid;
return;
}
if (table (TABLE_PROC_UID, &tbl, &pid))
glibtop_error_r (server, "table(TABLE_PROC_UID): %s\n", strerror (errno));
buf->flags = _glibtop_sysdeps_proc_uid;
buf->uid = tbl.proc_uid.uid;
buf->euid = tbl.proc_uid.euid;
buf->gid = tbl.proc_uid.gid;
buf->egid = tbl.proc_uid.egid;
buf->pid = tbl.proc_uid.pid;
buf->ppid = tbl.proc_uid.ppid;
buf->pgrp = tbl.proc_uid.pgrp;
buf->session = tbl.proc_uid.session;
buf->tty = tbl.proc_uid.tty;
buf->tpgid = tbl.proc_uid.tpgid;
/* scale priority and nice values from timeslices to -20..20 */
/* to make it look like a "normal" unix priority/nice value */
def_priority = tbl.proc_uid.def_priority;
priority = tbl.proc_uid.counter;
priority = 20 - (priority * 10 + def_priority / 2) / def_priority;
nice = tbl.proc_uid.priority;
nice = 20 - (nice * 20 + def_priority / 2) / def_priority;
buf->priority = (int) priority;
buf->nice = (int) nice;
if (buf->tty == 0)
/* the old notty val, update elsewhere bef. moving to 0 */
buf->tty = -1;
if (server->os_version_code < LINUX_VERSION(1,3,39)) {
/* map old meanings to new */
buf->priority = 2*15 - buf->priority;
buf->nice = 15 - buf->nice;
}
if (server->os_version_code < LINUX_VERSION(1,1,30) && buf->tty != -1)
/* when tty wasn't full devno */
buf->tty = 4*0x100 + buf->tty;
buf->flags = _glibtop_sysdeps_proc_uid;
}

View File

@@ -20,19 +20,42 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop/sem_limits.h> #include <glibtop/sem_limits.h>
#include <glibtop/command.h>
#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 ipc limits. */ /* Provides information about sysv ipc limits. */
void void
glibtop_get_sem_limits_l (glibtop *server, glibtop_sem_limits *buf) glibtop_get_sem_limits_s (glibtop *server, glibtop_sem_limits *buf)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_SEM_LIMITS, 0); struct seminfo seminfo;
union semun arg;
glibtop_init_r (&server, 0, 0);
if (server->features & GLIBTOP_SYSDEPS_SEM_LIMITS) { memset (buf, 0, sizeof (glibtop_sem_limits));
glibtop_call_l (server, GLIBTOP_CMND_SEM_LIMITS, 0, NULL,
sizeof (glibtop_sem_limits), buf); buf->flags = _glibtop_sysdeps_sem_limits;
} else {
glibtop_get_sem_limits_r (server, buf); arg.array = (ushort *) &seminfo;
} semctl (0, 0, IPC_INFO, arg);
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;
} }

View File

@@ -20,19 +20,33 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <glibtop/shm_limits.h> #include <glibtop/shm_limits.h>
#include <glibtop/command.h>
#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. */ /* Provides information about sysv ipc limits. */
void void
glibtop_get_shm_limits_l (glibtop *server, glibtop_shm_limits *buf) glibtop_get_shm_limits_s (glibtop *server, glibtop_shm_limits *buf)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_SHM_LIMITS, 0); struct shminfo shminfo;
glibtop_init_r (&server, 0, 0);
if (server->features & GLIBTOP_SYSDEPS_SHM_LIMITS) { memset (buf, 0, sizeof (glibtop_shm_limits));
glibtop_call_l (server, GLIBTOP_CMND_SHM_LIMITS, 0, NULL,
sizeof (glibtop_shm_limits), buf); buf->flags = _glibtop_sysdeps_shm_limits;
} else {
glibtop_get_shm_limits_r (server, buf); shmctl (0, IPC_INFO, (struct shmid_ds *) &shminfo);
}
buf->shmmax = shminfo.shmmax;
buf->shmmin = shminfo.shmmin;
buf->shmmni = shminfo.shmmni;
buf->shmseg = shminfo.shmseg;
buf->shmall = shminfo.shmall;
} }

View File

@@ -19,20 +19,33 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <config.h>
#include <glibtop/error.h>
#include <glibtop/swap.h> #include <glibtop/swap.h>
#include <glibtop/command.h>
#include "kernel.h"
static unsigned long _glibtop_sysdeps_swap =
(1 << GLIBTOP_SWAP_TOTAL) + (1 << GLIBTOP_SWAP_USED) +
(1 << GLIBTOP_SWAP_FREE);
/* Provides information about swap usage. */ /* Provides information about swap usage. */
void void
glibtop_get_swap_l (glibtop *server, glibtop_swap *buf) glibtop_get_swap_s (glibtop *server, glibtop_swap *buf)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_SWAP, 0); union table tbl;
glibtop_init_r (&server, 0, 0);
if (server->features & GLIBTOP_SYSDEPS_SWAP) { memset (buf, 0, sizeof (glibtop_swap));
glibtop_call_l (server, GLIBTOP_CMND_SWAP, 0, NULL,
sizeof (glibtop_swap), buf); if (table (TABLE_SWAP, &tbl, NULL))
} else { glibtop_error_r (server, "table(TABLE_SWAP): %s\n", strerror (errno));
glibtop_get_swap_r (server, buf);
} buf->flags = _glibtop_sysdeps_swap;
buf->total = tbl.swap.total;
buf->used = tbl.swap.used;
buf->free = tbl.swap.free;
} }

View File

@@ -20,20 +20,35 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <config.h> #include <config.h>
#include <glibtop/error.h>
#include <glibtop/uptime.h> #include <glibtop/uptime.h>
#include <glibtop/command.h>
#include "kernel.h"
static unsigned long _glibtop_sysdeps_uptime =
(1 << GLIBTOP_UPTIME_UPTIME) + (1 << GLIBTOP_UPTIME_IDLETIME);
/* Provides uptime and idle time. */ /* Provides uptime and idle time. */
void void
glibtop_get_uptime_l (glibtop *server, glibtop_uptime *buf) glibtop_get_uptime_s (glibtop *server, glibtop_uptime *buf)
{ {
glibtop_init_r (&server, GLIBTOP_SYSDEPS_UPTIME, 0); union table tbl;
glibtop_init_r (&server, 0, 0);
if (server->features & GLIBTOP_SYSDEPS_UPTIME) { memset (buf, 0, sizeof (glibtop_uptime));
glibtop_call_l (server, GLIBTOP_CMND_UPTIME, 0, NULL,
sizeof (glibtop_uptime), buf); if (table (TABLE_UPTIME, &tbl, NULL))
} else { glibtop_error_r (server, "table(TABLE_UPTIME): %s\n", strerror (errno));
glibtop_get_uptime_r (server, buf);
} buf->flags = _glibtop_sysdeps_uptime;
#if 0
fprintf (stderr, "Table (%u) = %lu, %lu\n",
TABLE_UPTIME, tbl.uptime.uptime, tbl.uptime.idle);
#endif
buf->uptime = (double) tbl.uptime.uptime / HZ;
buf->idletime = (double) tbl.uptime.idle / HZ;
} }

View File

@@ -26,7 +26,7 @@ const char *glibtop_names_loadavg [GLIBTOP_MAX_LOADAVG] =
"loadavg" "loadavg"
}; };
const char *glibtop_types_loadavg [GLIBTOP_MAX_LOADAVG] = const unsigned glibtop_types_loadavg [GLIBTOP_MAX_LOADAVG] =
{ {
GLIBTOP_TYPE_DOUBLE GLIBTOP_TYPE_DOUBLE
}; };

View File

@@ -23,22 +23,25 @@
const char *glibtop_names_sysdeps [GLIBTOP_MAX_SYSDEPS] = const char *glibtop_names_sysdeps [GLIBTOP_MAX_SYSDEPS] =
{ {
"cpu", "mem", "swap", "uptime", "loadavg", "shm_limits", "features", "cpu", "mem", "swap", "uptime", "loadavg",
"msg_limits", "sem_limits", "proclist", "proc_state", "shm_limits", "msg_limits", "sem_limits", "proclist",
"proc_uid", "proc_mem", "proc_time", "proc_signal", "proc_state", "proc_uid", "proc_mem", "proc_time",
"proc_kernel", "proc_segment" "proc_signal", "proc_kernel", "proc_segment"
}; };
const char *glibtop_types_sysdeps [GLIBTOP_MAX_SYSDEPS] = const unsigned glibtop_types_sysdeps [GLIBTOP_MAX_SYSDEPS] =
{ {
"unsigned long", "unsigned long", "unsigned long", "unsigned long", GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
"unsigned long", "unsigned long", "unsigned long", "unsigned long", GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
"unsigned long", "unsigned long", "unsigned long", "unsigned long", GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
"unsigned long", "unsigned long", "unsigned long", "unsigned long" GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG,
GLIBTOP_TYPE_ULONG, GLIBTOP_TYPE_ULONG
}; };
const char *glibtop_labels_sysdeps [GLIBTOP_MAX_SYSDEPS] = const char *glibtop_labels_sysdeps [GLIBTOP_MAX_SYSDEPS] =
{ {
N_("Server Features"),
N_("CPU Usage"), N_("CPU Usage"),
N_("Memory Usage"), N_("Memory Usage"),
N_("Swap Usage"), N_("Swap Usage"),
@@ -59,6 +62,7 @@ const char *glibtop_labels_sysdeps [GLIBTOP_MAX_SYSDEPS] =
const char *glibtop_descriptions_sysdeps [GLIBTOP_MAX_SYSDEPS] = const char *glibtop_descriptions_sysdeps [GLIBTOP_MAX_SYSDEPS] =
{ {
N_("Server Features"),
N_("CPU Usage"), N_("CPU Usage"),
N_("Memory Usage"), N_("Memory Usage"),
N_("Swap Usage"), N_("Swap Usage"),