Use `retval' for the default retval.
1999-10-24 Martin Baulig <martin@home-of-linux.org> * features.def: Use `retval' for the default retval. * include/glibtop/command.h (glibtop_command_h): Added `int *retval_ptr' parameter to return the retval from the sysdeps functions.
This commit is contained in:
committed by
Martin Baulig
parent
1dadfb6d15
commit
507f171b63
@@ -1,5 +1,11 @@
|
||||
1999-10-24 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* features.def: Use `retval' for the default retval.
|
||||
|
||||
* include/glibtop/command.h (glibtop_command_h): Added
|
||||
`int *retval_ptr' parameter to return the retval from the
|
||||
sysdeps functions.
|
||||
|
||||
* include/glibtop/*.h (glibtop_get_*, glibtop_init*): Changed
|
||||
the return value of all `glibtop_get_<feature>_* ()' and all
|
||||
`glibtop_init_<feature>_* ()' functions from void to int.
|
||||
|
36
features.def
36
features.def
@@ -1,22 +1,22 @@
|
||||
int|cpu|ulong(total,user,nice,sys,idle,frequency,xcpu_total[GLIBTOP_NCPU],xcpu_user[GLIBTOP_NCPU],xcpu_nice[GLIBTOP_NCPU],xcpu_sys[GLIBTOP_NCPU],xcpu_idle[GLIBTOP_NCPU],xcpu_flags)
|
||||
int|mem|ulong(total,used,free,shared,buffer,cached,user,locked)
|
||||
int|swap|ulong(total,used,free,pagein,pageout)
|
||||
int|uptime|double(uptime,idletime):ulong(boot_time)
|
||||
int|loadavg|double(loadavg[3]):ulong(nr_running,nr_tasks,last_pid)
|
||||
int|shm_limits|ulong(shmmax,shmmin,shmmni,shmseg,shmall)
|
||||
int|msg_limits|ulong(msgpool,msgmap,msgmax,msgmnb,msgmni,msgssz,msgtql)
|
||||
int|sem_limits|ulong(semmap,semmni,semmns,semmnu,semmsl,semopm,semume,semusz,semvmx,semaem)
|
||||
retval|cpu|ulong(total,user,nice,sys,idle,frequency,xcpu_total[GLIBTOP_NCPU],xcpu_user[GLIBTOP_NCPU],xcpu_nice[GLIBTOP_NCPU],xcpu_sys[GLIBTOP_NCPU],xcpu_idle[GLIBTOP_NCPU],xcpu_flags)
|
||||
retval|mem|ulong(total,used,free,shared,buffer,cached,user,locked)
|
||||
retval|swap|ulong(total,used,free,pagein,pageout)
|
||||
retval|uptime|double(uptime,idletime):ulong(boot_time)
|
||||
retval|loadavg|double(loadavg[3]):ulong(nr_running,nr_tasks,last_pid)
|
||||
retval|shm_limits|ulong(shmmax,shmmin,shmmni,shmseg,shmall)
|
||||
retval|msg_limits|ulong(msgpool,msgmap,msgmax,msgmnb,msgmni,msgssz,msgtql)
|
||||
retval|sem_limits|ulong(semmap,semmni,semmns,semmnu,semmsl,semopm,semume,semusz,semvmx,semaem)
|
||||
unsigned *|proclist|ulong(number,size,total)|long(which,arg)
|
||||
int|proc_state|str(cmd):unsigned(state):ulong(uid,gid,ruid,rgid,has_cpu,processor,last_processor)|pid_t(pid)
|
||||
int|proc_uid|long(uid,euid,gid,egid,suid,sgid,fsuid,fsgid,pid,ppid,pgrp,session,tty,tpgid,priority,nice,ngroups,groups[GLIBTOP_MAX_GROUPS])|pid_t(pid)
|
||||
int|proc_mem|long(size,vsize,resident,share,rss,rss_rlim)|pid_t(pid)
|
||||
int|proc_time|long(start_time,rtime,utime,stime,cutime,cstime,timeout,it_real_value,frequency,xcpu_utime[GLIBTOP_NCPU],xcpu_stime[GLIBTOP_NCPU],xcpu_flags)|pid_t(pid)
|
||||
int|proc_signal|ulong(signal[2],blocked[2],sigignore[2],sigcatch[2])|pid_t(pid)
|
||||
int|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,nwchan):str(wchan)|pid_t(pid)
|
||||
int|proc_segment|ulong(text_rss,shlib_rss,data_rss,stack_rss,dirty_size,start_code,end_code,start_data,end_data,start_brk,end_brk,start_stack,start_mmap,arg_start,arg_end,env_start,env_end)|pid_t(pid)
|
||||
retval|proc_state|str(cmd):unsigned(state):ulong(uid,gid,ruid,rgid,has_cpu,processor,last_processor)|pid_t(pid)
|
||||
retval|proc_uid|long(uid,euid,gid,egid,suid,sgid,fsuid,fsgid,pid,ppid,pgrp,session,tty,tpgid,priority,nice,ngroups,groups[GLIBTOP_MAX_GROUPS])|pid_t(pid)
|
||||
retval|proc_mem|long(size,vsize,resident,share,rss,rss_rlim)|pid_t(pid)
|
||||
retval|proc_time|long(start_time,rtime,utime,stime,cutime,cstime,timeout,it_real_value,frequency,xcpu_utime[GLIBTOP_NCPU],xcpu_stime[GLIBTOP_NCPU],xcpu_flags)|pid_t(pid)
|
||||
retval|proc_signal|ulong(signal[2],blocked[2],sigignore[2],sigcatch[2])|pid_t(pid)
|
||||
retval|proc_kernel|ulong(k_flags,min_flt,maj_flt,cmin_flt,cmaj_flt,kstk_esp,kstk_eip,nwchan):str(wchan)|pid_t(pid)
|
||||
retval|proc_segment|ulong(text_rss,shlib_rss,data_rss,stack_rss,dirty_size,start_code,end_code,start_data,end_data,start_brk,end_brk,start_stack,start_mmap,arg_start,arg_end,env_start,env_end)|pid_t(pid)
|
||||
char *|proc_args|ulong(size)|pid_t(pid):unsigned(max_len)
|
||||
glibtop_map_entry *|proc_map|ulong(number,size,total)|pid_t(pid)
|
||||
glibtop_mountentry *|@mountlist|ulong(number,size,total)|int(all_fs)
|
||||
int|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir
|
||||
int|netload|ulong(if_flags,mtu,subnet,address,packets_in,packets_out,packets_total,bytes_in,bytes_out,bytes_total,errors_in,errors_out,errors_total,collisions)|string|interface
|
||||
int|ppp|ulong(state,bytes_in,bytes_out)|ushort(device)
|
||||
retval|@fsusage|ulong(blocks,bfree,bavail,files,ffree)|string|mount_dir
|
||||
retval|netload|ulong(if_flags,mtu,subnet,address,packets_in,packets_out,packets_total,bytes_in,bytes_out,bytes_total,errors_in,errors_out,errors_total,collisions)|string|interface
|
||||
retval|ppp|ulong(state,bytes_in,bytes_out)|ushort(device)
|
||||
|
@@ -93,7 +93,8 @@ struct _glibtop_response
|
||||
|
||||
void *
|
||||
glibtop_call_l (glibtop *server, unsigned command, size_t send_size,
|
||||
const void *send_buf, size_t recv_size, void *recv_buf);
|
||||
const void *send_buf, size_t recv_size, void *recv_buf,
|
||||
int *retval_ptr);
|
||||
|
||||
void *
|
||||
glibtop_call_s (glibtop *server, unsigned command, size_t send_size,
|
||||
|
@@ -35,7 +35,7 @@ glibtop_close_r (glibtop *server)
|
||||
case GLIBTOP_METHOD_UNIX:
|
||||
case GLIBTOP_METHOD_INET:
|
||||
glibtop_call_l (server, GLIBTOP_CMND_QUIT,
|
||||
0, NULL, 0, NULL);
|
||||
0, NULL, 0, NULL, NULL);
|
||||
|
||||
if (close (server->socket))
|
||||
glibtop_warn_io ("close");
|
||||
|
@@ -30,10 +30,12 @@
|
||||
|
||||
void *
|
||||
glibtop_call_l (glibtop *server, unsigned command, size_t send_size,
|
||||
const void *send_buf, size_t recv_size, void *recv_buf)
|
||||
const void *send_buf, size_t recv_size, void *recv_buf,
|
||||
int *retval_ptr)
|
||||
{
|
||||
glibtop_command cmnd;
|
||||
glibtop_response response;
|
||||
int retval;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
@@ -61,6 +63,10 @@ glibtop_call_l (glibtop *server, unsigned command, size_t send_size,
|
||||
response.offset, response.data_size);
|
||||
#endif
|
||||
|
||||
glibtop_read_l (server, sizeof (int), &retval);
|
||||
if (retval_ptr)
|
||||
*retval_ptr = retval;
|
||||
|
||||
if (recv_buf)
|
||||
memcpy (recv_buf, ((char *) &response) + response.offset,
|
||||
recv_size);
|
||||
|
37
lib/lib.pl
37
lib/lib.pl
@@ -68,6 +68,7 @@ $convert{'long'} = 'int64_t';
|
||||
$convert{'ulong'} = 'u_int64_t';
|
||||
$convert{'pid_t'} = 'pid_t';
|
||||
$convert{'int'} = 'int';
|
||||
$convert{'retval'} = 'int';
|
||||
$convert{'ushort'} = 'unsigned short';
|
||||
$convert{'unsigned'} = 'unsigned';
|
||||
|
||||
@@ -91,16 +92,31 @@ sub output {
|
||||
$space = $feature;
|
||||
$space =~ s/./ /g;
|
||||
|
||||
print $retval;
|
||||
if ($retval !~ /^void$/) {
|
||||
$prefix = 'retval = ';
|
||||
$prefix_space = ' ';
|
||||
if ($retval eq 'retval') {
|
||||
$retval_param = '&retval';
|
||||
$call_prefix = '';
|
||||
$call_prefix_space = '';
|
||||
$prefix = 'retval = ';
|
||||
$prefix_space = ' ';
|
||||
$retval = 'int';
|
||||
}
|
||||
elsif ($retval !~ /^void$/) {
|
||||
$retval_param = 'NULL';
|
||||
$prefix = 'retval = ';
|
||||
$prefix_space = ' ';
|
||||
$call_prefix = 'retval = ';
|
||||
$call_prefix_space = ' ';
|
||||
}
|
||||
else {
|
||||
$prefix = '';
|
||||
$prefix_space = '';
|
||||
$retval_param = 'NULL';
|
||||
$call_prefix = '';
|
||||
$call_prefix_space = '';
|
||||
$prefix = '';
|
||||
$prefix_space = '';
|
||||
}
|
||||
|
||||
print $retval;
|
||||
|
||||
if ($param_def eq 'string') {
|
||||
$call_param = ', ' . $line_fields[5];
|
||||
$param_decl = ",\n " . $space . ' const char *' .
|
||||
@@ -185,13 +201,14 @@ sub output {
|
||||
&toupper($feature) . ')))';
|
||||
print "\t{";
|
||||
|
||||
print "\t\t" . $prefix . 'glibtop_call_l (server, GLIBTOP_CMND_' .
|
||||
print "\t\t" . $call_prefix . 'glibtop_call_l (server, GLIBTOP_CMND_' .
|
||||
|
||||
&toupper($feature) . ',';
|
||||
print "\t\t\t\t" . $prefix_space . 'send_size, send_ptr,';
|
||||
print "\t\t\t\t" . $prefix_space . 'sizeof (glibtop_' . $feature .
|
||||
print "\t\t\t\t" . $call_prefix_space . 'send_size, send_ptr,';
|
||||
print "\t\t\t\t" . $call_prefix_space . 'sizeof (glibtop_' . $feature .
|
||||
|
||||
'), buf);';
|
||||
'), buf,';
|
||||
print "\t\t\t\t" . $call_prefix_space . $retval_param . ');';
|
||||
|
||||
print "\t} else {";
|
||||
|
||||
|
@@ -159,7 +159,8 @@ glibtop_open_l (glibtop *server, const char *program_name,
|
||||
/* Now ask it for its features. */
|
||||
|
||||
glibtop_call_l (server, GLIBTOP_CMND_SYSDEPS, 0, NULL,
|
||||
sizeof (glibtop_sysdeps), &sysdeps);
|
||||
sizeof (glibtop_sysdeps), &sysdeps,
|
||||
NULL);
|
||||
|
||||
server->features = sysdeps.features;
|
||||
|
||||
|
@@ -81,6 +81,10 @@ sub make_output {
|
||||
|
||||
$total_nr_params = 0;
|
||||
|
||||
if ($retval eq 'retval') {
|
||||
$retval = 'int';
|
||||
}
|
||||
|
||||
if ($param_def eq 'string') {
|
||||
$call_param = ', gh_scm2newstr( ' . $line_fields[5] . ', NULL)';
|
||||
$param_decl = 'SCM ' . $line_fields[5];
|
||||
|
Reference in New Issue
Block a user