Commit 5790543d authored by Paul Eggert's avatar Paul Eggert
Browse files

* sysdep.c [__FreeBSD__]: Minor cleanups.

(list_system_processes, system_process_attributes) [__FreeBSD__]:
Use Emacs indenting style more consistently.  Avoid some casts.
Use 'double' consistently rather than mixing 'float' and 'double'.
parent 9ee7d8b9
2012-04-22 Paul Eggert <eggert@cs.ucla.edu>
* sysdep.c [__FreeBSD__]: Minor cleanups.
(list_system_processes, system_process_attributes) [__FreeBSD__]:
Use Emacs indenting style more consistently. Avoid some casts.
Use 'double' consistently rather than mixing 'float' and 'double'.
2012-04-21 Eduard Wiebe <usenet@pusto.de>
* sysdep.c (list_system_processes, system_process_attributes): Add
......
......@@ -2536,10 +2536,10 @@ list_system_processes (void)
return proclist;
}
#elif defined (__FreeBSD__)
#elif defined __FreeBSD__
Lisp_Object
list_system_processes ()
list_system_processes (void)
{
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PROC};
size_t len;
......@@ -3120,13 +3120,13 @@ system_process_attributes (Lisp_Object pid)
return attrs;
}
#elif defined(__FreeBSD__)
#elif defined __FreeBSD__
Lisp_Object
system_process_attributes (Lisp_Object pid)
{
int proc_id;
int pagesize = getpagesize();
int pagesize = getpagesize ();
int npages;
int fscale;
struct passwd *pw;
......@@ -3138,7 +3138,7 @@ system_process_attributes (Lisp_Object pid)
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID};
struct kinfo_proc proc;
size_t proclen = sizeof(proc);
size_t proclen = sizeof proc;
struct gcpro gcpro1, gcpro2;
Lisp_Object attrs = Qnil;
......@@ -3153,7 +3153,7 @@ system_process_attributes (Lisp_Object pid)
GCPRO2 (attrs, decoded_comm);
attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float(proc.ki_uid)), attrs);
attrs = Fcons (Fcons (Qeuid, make_fixnum_or_float (proc.ki_uid)), attrs);
BLOCK_INPUT;
pw = getpwuid (proc.ki_uid);
......@@ -3161,7 +3161,7 @@ system_process_attributes (Lisp_Object pid)
if (pw)
attrs = Fcons (Fcons (Quser, build_string (pw->pw_name)), attrs);
attrs = Fcons (Fcons (Qegid, make_fixnum_or_float(proc.ki_svgid)), attrs);
attrs = Fcons (Fcons (Qegid, make_fixnum_or_float (proc.ki_svgid)), attrs);
BLOCK_INPUT;
gr = getgrgid (proc.ki_svgid);
......@@ -3222,50 +3222,52 @@ system_process_attributes (Lisp_Object pid)
make_number (EMACS_SECS (ts) & 0xffff), \
make_number (EMACS_USECS (ts)))
attrs = Fcons (Fcons (Qutime, TIMELIST(proc.ki_rusage.ru_utime)), attrs);
attrs = Fcons (Fcons (Qstime, TIMELIST(proc.ki_rusage.ru_stime)), attrs);
attrs = Fcons (Fcons (Qutime, TIMELIST (proc.ki_rusage.ru_utime)), attrs);
attrs = Fcons (Fcons (Qstime, TIMELIST (proc.ki_rusage.ru_stime)), attrs);
EMACS_ADD_TIME (t, proc.ki_rusage.ru_utime, proc.ki_rusage.ru_stime);
attrs = Fcons (Fcons (Qtime, TIMELIST(t)), attrs);
attrs = Fcons (Fcons (Qtime, TIMELIST (t)), attrs);
attrs = Fcons (Fcons (Qcutime, TIMELIST(proc.ki_rusage_ch.ru_utime)), attrs);
attrs = Fcons (Fcons (Qcstime, TIMELIST(proc.ki_rusage_ch.ru_utime)), attrs);
attrs = Fcons (Fcons (Qcutime, TIMELIST (proc.ki_rusage_ch.ru_utime)), attrs);
attrs = Fcons (Fcons (Qcstime, TIMELIST (proc.ki_rusage_ch.ru_utime)), attrs);
EMACS_ADD_TIME (t, proc.ki_rusage_ch.ru_utime, proc.ki_rusage_ch.ru_stime);
attrs = Fcons (Fcons (Qctime, TIMELIST(t)), attrs);
attrs = Fcons (Fcons (Qctime, TIMELIST (t)), attrs);
attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (proc.ki_numthreads)), attrs);
attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (proc.ki_numthreads)),
attrs);
attrs = Fcons (Fcons (Qpri, make_number (proc.ki_pri.pri_native)), attrs);
attrs = Fcons (Fcons (Qnice, make_number (proc.ki_nice)), attrs);
attrs = Fcons (Fcons (Qstart, TIMELIST(proc.ki_start)), attrs);
attrs = Fcons (Fcons (Qstart, TIMELIST (proc.ki_start)), attrs);
attrs = Fcons (Fcons (Qvsize, make_number (proc.ki_size >> 10)), attrs);
attrs = Fcons (Fcons (Qrss, make_number (proc.ki_rssize * pagesize >> 10)), attrs);
attrs = Fcons (Fcons (Qrss, make_number (proc.ki_rssize * pagesize >> 10)),
attrs);
EMACS_GET_TIME (now);
EMACS_SUB_TIME (t, now, proc.ki_start);
attrs = Fcons (Fcons (Qetime, TIMELIST(t)), attrs);
attrs = Fcons (Fcons (Qetime, TIMELIST (t)), attrs);
#undef TIMELIST
len = sizeof(fscale);
len = sizeof fscale;
if (sysctlbyname ("kern.fscale", &fscale, &len, NULL, 0) == 0)
{
float pcpu;
double pcpu;
fixpt_t ccpu;
len = sizeof (ccpu);
len = sizeof ccpu;
if (sysctlbyname ("kern.ccpu", &ccpu, &len, NULL, 0) == 0)
{
pcpu = 100.0 * ((double) proc.ki_pctcpu / fscale)
/ (1.0 - exp(proc.ki_swtime * log((double) ccpu / fscale)));
attrs = Fcons (Fcons (Qpcpu, make_fixnum_or_float(pcpu)), attrs);
pcpu = (100.0 * proc.ki_pctcpu / fscale
/ (1 - exp (proc.ki_swtime * log ((double) ccpu / fscale))));
attrs = Fcons (Fcons (Qpcpu, make_fixnum_or_float (pcpu)), attrs);
}
}
len = sizeof(npages);
len = sizeof npages;
if (sysctlbyname ("hw.availpages", &npages, &len, NULL, 0) == 0)
{
float pmem = proc.ki_flag & P_INMEM
? 100.0 * ((float) proc.ki_rssize / npages)
: 0.0;
attrs = Fcons (Fcons (Qpmem, make_fixnum_or_float(pmem)), attrs);
double pmem = (proc.ki_flag & P_INMEM
? 100.0 * proc.ki_rssize / npages
: 0);
attrs = Fcons (Fcons (Qpmem, make_fixnum_or_float (pmem)), attrs);
}
mib[2] = KERN_PROC_ARGS;
......@@ -3279,9 +3281,10 @@ system_process_attributes (Lisp_Object pid)
args[i] = ' ';
}
decoded_comm = code_convert_string_norecord
decoded_comm =
(code_convert_string_norecord
(make_unibyte_string (args, strlen (args)),
Vlocale_coding_system, 0);
Vlocale_coding_system, 0));
attrs = Fcons (Fcons (Qargs, decoded_comm), attrs);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment