From d054f3fb9af7399ee67be94e1602b45d21fc555f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 23 Jun 2012 01:21:48 -0700 Subject: [PATCH] * sysdep.c [__FreeBSD__]: Fix recently-introduced typos. Privately reported by Herbert J. Skuhra. [__FreeBSD__]: Remove "*/" typo after "#include". (timeval_to_EMACS_TIME) [__FreeBSD__]: New static function. (TIMEVAL) [__FreeBSD__]: Now a static function rather than a macro. (TIMEVAL, system_process_attributes) [__FreeBSD__]: Don't assume EMACS_TIME and struct timeval are the same type. --- src/ChangeLog | 10 ++++++++++ src/sysdep.c | 33 ++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 65424205f34..e5d77d66b0c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2012-06-23 Paul Eggert + + * sysdep.c [__FreeBSD__]: Fix recently-introduced typos. + Privately reported by Herbert J. Skuhra. + [__FreeBSD__]: Remove "*/" typo after "#include". + (timeval_to_EMACS_TIME) [__FreeBSD__]: New static function. + (TIMEVAL) [__FreeBSD__]: Now a static function rather than a macro. + (TIMEVAL, system_process_attributes) [__FreeBSD__]: + Don't assume EMACS_TIME and struct timeval are the same type. + 2012-06-22 Paul Eggert Support higher-resolution time stamps (Bug#9000). diff --git a/src/sysdep.c b/src/sysdep.c index 8d1c3d0ca3c..875f343135e 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -41,7 +41,7 @@ along with GNU Emacs. If not, see . */ #ifdef __FreeBSD__ #include #include -#include */ +#include #include #endif @@ -3107,6 +3107,20 @@ system_process_attributes (Lisp_Object pid) #elif defined __FreeBSD__ +static EMACS_TIME +timeval_to_EMACS_TIME (struct timeval t) +{ + EMACS_TIME e; + EMACS_SET_SECS_NSECS (e, t.tv_sec, t.tv_usec * 1000); + return e; +} + +static Lisp_Object +TIMELIST (struct timeval t) +{ + return make_lisp_time (timeval_to_EMACS_TIME (t)); +} + Lisp_Object system_process_attributes (Lisp_Object pid) { @@ -3202,19 +3216,18 @@ system_process_attributes (Lisp_Object pid) attrs = Fcons (Fcons (Qcminflt, make_number (proc.ki_rusage_ch.ru_minflt)), attrs); attrs = Fcons (Fcons (Qcmajflt, make_number (proc.ki_rusage_ch.ru_majflt)), attrs); -#define TIMELIST(ts) \ - list3 (make_number (EMACS_SECS (ts) >> 16 & 0xffff), \ - 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); - EMACS_ADD_TIME (t, proc.ki_rusage.ru_utime, proc.ki_rusage.ru_stime); + EMACS_ADD_TIME (t, + timeval_to_EMACS_TIME (proc.ki_rusage.ru_utime), + timeval_to_EMACS_TIME (proc.ki_rusage.ru_stime)); 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); - EMACS_ADD_TIME (t, proc.ki_rusage_ch.ru_utime, proc.ki_rusage_ch.ru_stime); + EMACS_ADD_TIME (t, + timeval_to_EMACS_TIME (proc.ki_rusage_ch.ru_utime), + timeval_to_EMACS_TIME (proc.ki_rusage_ch.ru_stime)); attrs = Fcons (Fcons (Qctime, TIMELIST (t)), attrs); attrs = Fcons (Fcons (Qthcount, make_fixnum_or_float (proc.ki_numthreads)), @@ -3227,11 +3240,9 @@ system_process_attributes (Lisp_Object pid) attrs); EMACS_GET_TIME (now); - EMACS_SUB_TIME (t, now, proc.ki_start); + EMACS_SUB_TIME (t, now, timeval_to_EMACS_TIME (proc.ki_start)); attrs = Fcons (Fcons (Qetime, TIMELIST (t)), attrs); -#undef TIMELIST - len = sizeof fscale; if (sysctlbyname ("kern.fscale", &fscale, &len, NULL, 0) == 0) { -- 2.39.2