Hi, As you see in the comment, I don't know if this is something beyond cosmetics - but i always start fiddling with things like this...
I also have to admit that C++ never was my forte, so i think you're on your own for that "total_stamp" being uninitialized problem. You could treat it as a struct and do a memset with a known offsetof or so, or just handle it C++ style. --- commit b780d7fcf957d18399bae22f7681f9fe3d9efd3b Author: Ian Kumlien <[email protected]> Date: Thu Jan 6 04:27:53 2011 +0100 64 bit cleanups, using inttypes.h * Use UINT64_MAX definition instead of ~0ULL * Use PRIy64 for formating All this to better comply to C++ standards and avoid castings (I don't know if this is something you actually want, just playing with the code) diff --git a/cpu/abstract_cpu.cpp b/cpu/abstract_cpu.cpp index 2296cd8..d4f103f 100644 --- a/cpu/abstract_cpu.cpp +++ b/cpu/abstract_cpu.cpp @@ -27,6 +27,8 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> +#define __STDC_FORMAT_MACROS // Get definition of PRIu64 +#include <inttypes.h> #include "cpu.h" @@ -407,11 +409,11 @@ void abstract_cpu::validate(void) if (children[i]) { if (my_time != children[i]->total_pstate_time()) - printf("My (%i) time %llu is not the same as child (%i) time %llu\n", + printf("My (%i) time %"PRIu64" is not the same as child (%i) time %"PRIu64"\n", first_cpu, - (unsigned long long)my_time, + my_time, children[i]->number, - (unsigned long long)children[i]->total_pstate_time()); + children[i]->total_pstate_time()); children[i]->validate(); } } diff --git a/cpu/intel_cpus.cpp b/cpu/intel_cpus.cpp index 301592f..a5c60bb 100644 --- a/cpu/intel_cpus.cpp +++ b/cpu/intel_cpus.cpp @@ -35,6 +35,9 @@ #include <string.h> #include <errno.h> +#define __STDC_FORMAT_MACROS // Get the definition of PRIx64 +#include <inttypes.h> + #include "../lib.h" #include "../parameters/parameters.h" #include "../display.h" @@ -63,7 +66,7 @@ static uint64_t get_msr(int cpu, uint64_t offset) retval = pread(fd, &msr, sizeof msr, offset); if (retval != sizeof msr) { reset_display(); - fprintf(stderr, "pread cpu%d 0x%llx : ", cpu, (unsigned long long)offset); + fprintf(stderr, "pread cpu%d 0x%"PRIx64" : ", cpu, offset); fprintf(stderr, "%s\n", strerror(errno)); exit(-2); } diff --git a/lib.cpp b/lib.cpp index 9b6e04c..a26f6f3 100644 --- a/lib.cpp +++ b/lib.cpp @@ -53,7 +53,8 @@ extern "C" { #include <string.h> #include <locale.h> #include <libintl.h> - +#define __STDC_FORMAT_MACROS // Get the definition of PRIi64 +#include <inttypes.h> static int kallsyms_read = 0; @@ -69,20 +70,20 @@ double percentage(double F) char *hz_to_human(unsigned long hz, char *buffer, int digits) { - unsigned long long Hz; + uint64_t Hz; buffer[0] = 0; Hz = hz; /* default: just put the Number in */ - sprintf(buffer,_("%9lli"), Hz); + sprintf(buffer, _("%9" PRIi64), Hz); if (Hz>1000) { if (digits == 2) - sprintf(buffer, _("%4lli Mhz"), (Hz+500)/1000); + sprintf(buffer, _("%4"PRIi64" Mhz"), (Hz +500)/1000); else - sprintf(buffer, _("%6lli Mhz"), (Hz+500)/1000); + sprintf(buffer, _("%6"PRIi64" Mhz"), (Hz +500)/1000); } if (Hz>1500000) { @@ -364,4 +365,4 @@ char *pretty_print(const char *str, char *buf, int len) if (len) buf[len - 1] = 0; return buf; -} \ No newline at end of file +} diff --git a/process/do_process.cpp b/process/do_process.cpp index 798a0c5..e4fcc6f 100644 --- a/process/do_process.cpp +++ b/process/do_process.cpp @@ -22,6 +22,7 @@ * Authors: * Arjan van de Ven <[email protected]> */ +#define __STDC_LIMIT_MACROS // To get the definition of INT64_MAX from stdint.h #include "process.h" #include "interrupt.h" #include "timer.h" @@ -511,7 +512,7 @@ void start_process_measurement(void) perf_events->add_event("writeback:writeback_inode_dirty"); } - first_stamp = ~0ULL; + first_stamp = INT64_MAX; last_stamp = 0; perf_events->start(); } diff --git a/process/process.cpp b/process/process.cpp index a1fb725..a5c4e24 100644 --- a/process/process.cpp +++ b/process/process.cpp @@ -31,6 +31,9 @@ #include <unistd.h> #include <errno.h> +#define __STDC_FORMAT_MACROS // Get the definition of PRIu64 +#include <inttypes.h> + #include <iostream> #include <fstream> @@ -59,8 +62,8 @@ uint64_t process::deschedule_thread(uint64_t time, int thread_id) delta = time - running_since; if (time < running_since) - printf("%llu time %llu since \n", (unsigned long long)time, - (unsigned long long)running_since); + printf("%"PRIu64" time %"PRIu64" since \n", time, + running_since); if (thread_id == 0) /* idle thread */ delta = 0; -- Ian Kumlien -- http://demius.net || http://pomac.netswarm.net
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Power mailing list [email protected] http://www.bughost.org/mailman/listinfo/power
