[haiku-commits] r42050 - haiku/branches/developer/bonefish/signals/src/system/libroot/posix/sys

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 8 Jun 2011 15:17:00 +0200 (CEST)

Author: bonefish
Date: 2011-06-08 15:17:00 +0200 (Wed, 08 Jun 2011)
New Revision: 42050
Changeset: https://dev.haiku-os.org/changeset/42050

Modified:
   
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/sys/times.c
Log:
* Use CLOCKS_PER_SEC instead of CLK_TCK.
* Replaced local variable by a macro.


Modified: 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/sys/times.c
===================================================================
--- 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/sys/times.c  
    2011-06-08 12:24:43 UTC (rev 42049)
+++ 
haiku/branches/developer/bonefish/signals/src/system/libroot/posix/sys/times.c  
    2011-06-08 13:17:00 UTC (rev 42050)
@@ -11,29 +11,33 @@
 #include <sys/times.h>
 
 
+#define MICROSECONDS_PER_CLOCK_TICK    (1000000 / CLOCKS_PER_SEC)
+
+
 clock_t
 times(struct tms *buffer)
 {
        team_usage_info info;
        status_t err;
-       int32 clk_tck = 1000000 / CLK_TCK; /* to avoid overflow */
 
-       if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_SELF, &info)) != 
B_OK) {
+       if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_SELF, &info))
+                       != B_OK) {
                errno = err;
                return -1;
        }
 
-       buffer->tms_utime = info.user_time / clk_tck;
-       buffer->tms_stime = info.kernel_time / clk_tck;
-       
-       if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_CHILDREN, &info)) 
!= B_OK) {
+       buffer->tms_utime = info.user_time / MICROSECONDS_PER_CLOCK_TICK;
+       buffer->tms_stime = info.kernel_time / MICROSECONDS_PER_CLOCK_TICK;
+
+       if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_CHILDREN, &info))
+                       != B_OK) {
                errno = err;
                return -1;
        }
 
-       buffer->tms_cutime = info.user_time / clk_tck;
-       buffer->tms_cstime = info.kernel_time / clk_tck;
+       buffer->tms_cutime = info.user_time / MICROSECONDS_PER_CLOCK_TICK;
+       buffer->tms_cstime = info.kernel_time / MICROSECONDS_PER_CLOCK_TICK;
 
-       return system_time() / clk_tck;
+       return system_time() / MICROSECONDS_PER_CLOCK_TICK;
 }
 


Other related posts:

  • » [haiku-commits] r42050 - haiku/branches/developer/bonefish/signals/src/system/libroot/posix/sys - ingo_weinhold