]> Zhao Yanbai Git Server - minix.git/commitdiff
u64_t for human beings - the high and low parts are named hi and lo, lib/sysutil...
authorTomas Hruby <tom@minix3.org>
Thu, 13 Aug 2009 15:47:49 +0000 (15:47 +0000)
committerTomas Hruby <tom@minix3.org>
Thu, 13 Aug 2009 15:47:49 +0000 (15:47 +0000)
include/sys/types.h
lib/sysutil/profile.c

index 06b553e594e66eaa38e8064aa6b788da95e8f88b..d959e13e76fb8194f74597196ad6e77aaf9ad486 100755 (executable)
@@ -69,7 +69,10 @@ typedef char            i8_t;      /* 8 bit signed type */
 typedef short          i16_t;      /* 16 bit signed type */
 typedef long           i32_t;      /* 32 bit signed type */
 
-typedef struct { u32_t _[2]; } u64_t;
+typedef struct {
+       u32_t lo;
+       u32_t hi;
+} u64_t;
 
 /* The following types are needed because MINIX uses K&R style function
  * definitions (for maximum portability).  When a short, such as dev_t, is
index 9c6edb2cc5975f7e549bad2ffbe198564c442416..b64c038331907895f902a8fe379436ced5ca2c19 100644 (file)
@@ -19,9 +19,6 @@
 #include <minix/syslib.h>
 #include <minix/u64.h>
 
-#define U64_LO 0
-#define U64_HI 1
-
 PRIVATE char cpath[CPROF_CPATH_MAX_LEN];       /* current call path string */
 PRIVATE int cpath_len;                         /* current call path len */
 PRIVATE struct cprof_tbl_s *cprof_slot;                /* slot of current function */
@@ -64,7 +61,7 @@ char *name;
   if (cprof_locked) return; else cprof_locked = 1;
 
   /* Read CPU cycle count into local variable. */
-  read_tsc(&start._[U64_HI], &start._[U64_LO]);
+  read_tsc(&start.hi, &start.lo);
 
   /* Run init code once after system boot. */
   if (init == 0) {
@@ -108,8 +105,8 @@ char *name;
   }
 
   /* Save initial cycle count on stack. */
-  cprof_stk[cprof_stk_top].start_1._[U64_HI] = start._[U64_HI];
-  cprof_stk[cprof_stk_top].start_1._[U64_LO] = start._[U64_LO];
+  cprof_stk[cprof_stk_top].start_1.hi = start.hi;
+  cprof_stk[cprof_stk_top].start_1.lo = start.lo;
 
   /* Check available call path len. */
   if (cpath_len + strlen(name) + 1 > CPROF_CPATH_MAX_LEN) {
@@ -170,8 +167,8 @@ char *name;
   cprof_stk[cprof_stk_top].slot = cprof_slot;
 
   /* Again save CPU cycle count on stack. */
-  read_tsc(&cprof_stk[cprof_stk_top].start_2._[U64_HI],
-               &cprof_stk[cprof_stk_top].start_2._[U64_LO]);
+  read_tsc(&cprof_stk[cprof_stk_top].start_2.hi,
+               &cprof_stk[cprof_stk_top].start_2.lo);
   cprof_locked = 0;
 }
 
@@ -185,7 +182,7 @@ char *name;
   if (cprof_locked) return; else cprof_locked = 1;
 
   /* First thing: read CPU cycle count into local variable. */
-  read_tsc(&stop._[U64_HI], &stop._[U64_LO]);
+  read_tsc(&stop.hi, &stop.lo);
 
   /* Only continue if sane. */
   if (control.err) return;
@@ -204,8 +201,8 @@ char *name;
                sub64(spent, cprof_stk[cprof_stk_top].spent_deeper));
 
   /* Clear spent_deeper for call level we're leaving. */
-  cprof_stk[cprof_stk_top].spent_deeper._[U64_LO] = 0;
-  cprof_stk[cprof_stk_top].spent_deeper._[U64_HI] = 0;
+  cprof_stk[cprof_stk_top].spent_deeper.lo = 0;
+  cprof_stk[cprof_stk_top].spent_deeper.hi = 0;
 
   /* Adjust call path string and stack. */
   cpath_len = cprof_stk[cprof_stk_top].cpath_len;
@@ -221,7 +218,7 @@ char *name;
    */
 
   /* Read CPU cycle count. */
-  read_tsc(&stop._[U64_HI], &stop._[U64_LO]);
+  read_tsc(&stop.hi, &stop.lo);
 
   /* Calculate "big" difference. */
   spent = sub64(stop, cprof_stk[cprof_stk_top].start_1);
@@ -249,12 +246,12 @@ PRIVATE void cprof_init() {
   for (i=0; i<CPROF_STACK_SIZE; i++) {
        cprof_stk[i].cpath_len = 0;
        cprof_stk[i].slot = 0;
-       cprof_stk[i].start_1._[U64_LO] = 0;
-       cprof_stk[i].start_1._[U64_HI] = 0;
-       cprof_stk[i].start_2._[U64_LO] = 0;
-       cprof_stk[i].start_2._[U64_HI] = 0;
-       cprof_stk[i].spent_deeper._[U64_LO] = 0;
-       cprof_stk[i].spent_deeper._[U64_HI] = 0;
+       cprof_stk[i].start_1.lo = 0;
+       cprof_stk[i].start_1.hi = 0;
+       cprof_stk[i].start_2.lo = 0;
+       cprof_stk[i].start_2.hi = 0;
+       cprof_stk[i].spent_deeper.lo = 0;
+       cprof_stk[i].spent_deeper.hi = 0;
   }
 }
 
@@ -277,8 +274,8 @@ PRIVATE void clear_tbl()
        memset(cprof_tbl[i].cpath, '\0', CPROF_CPATH_MAX_LEN);
        cprof_tbl[i].next = 0;
        cprof_tbl[i].calls = 0;
-       cprof_tbl[i].cycles._[U64_LO] = 0;
-       cprof_tbl[i].cycles._[U64_HI] = 0;
+       cprof_tbl[i].cycles.lo = 0;
+       cprof_tbl[i].cycles.hi = 0;
   }
 }