numatop/numatop.cpuid.patch
2014-06-30 20:58:35 +02:00

141 lines
4.4 KiB
Diff

diff --git i/common/os/os_util.c w/common/os/os_util.c
index cd73aae..535f116 100644
--- i/common/os/os_util.c
+++ w/common/os/os_util.c
@@ -231,7 +231,7 @@ calibrate_cpuinfo(double *nsofclk, uint64_t *clkofsec)
*nsofclk = (double)NS_SEC / *clkofsec;
debug_print(NULL, 2, "calibrate_cpuinfo: nsofclk = %.4f, "
- "clkofsec = %lu\n", *nsofclk, *clkofsec);
+ "clkofsec = %"PRIu64"\n", *nsofclk, *clkofsec);
return (0);
}
@@ -267,7 +267,7 @@ calibrate_cpufreq(double *nsofclk, uint64_t *clkofsec)
*nsofclk = (double)NS_SEC / *clkofsec;
debug_print(NULL, 2, "calibrate_cpufreq: nsofclk = %.4f, "
- "clkofsec = %lu\n", *nsofclk, *clkofsec);
+ "clkofsec = %"PRIu64"\n", *nsofclk, *clkofsec);
return (0);
}
@@ -321,7 +321,7 @@ calibrate_by_tsc(double *nsofclk, uint64_t *clkofsec)
processor_unbind();
debug_print(NULL, 2, "calibrate_by_tsc: nsofclk = %.4f, "
- "clkofsec = %lu\n", *nsofclk, *clkofsec);
+ "clkofsec = %"PRIu64"\n", *nsofclk, *clkofsec);
}
void
diff --git i/common/os/os_win.c w/common/os/os_win.c
index b80bcdf..1fb1781 100644
--- i/common/os/os_win.c
+++ w/common/os/os_win.c
@@ -889,11 +889,11 @@ latnode_data_show(track_proc_t *proc, dyn_latnode_t *dyn, map_entry_t *entry,
win_size2str(dyn->size, size_str, sizeof (size_str));
if (lwp != NULL) {
(void) snprintf(content, sizeof (content),
- "Memory area(%lX, %s), thread(%d)",
+ "Memory area(%"PRIX64", %s), thread(%d)",
dyn->addr, size_str, lwp->id);
} else {
(void) snprintf(content, sizeof (content),
- "Memory area(%lX, %s), process(%d)",
+ "Memory area(%"PRIX64", %s), process(%d)",
dyn->addr, size_str, proc->pid);
}
diff --git i/common/util.c w/common/util.c
index cc75188..9dc3b71 100644
--- i/common/util.c
+++ w/common/util.c
@@ -126,7 +126,7 @@ debug_print(FILE *out, int level, const char *fmt, ...)
if (s_logfile != NULL) {
(void) pthread_mutex_lock(&s_debug_ctl.mutex);
(void) fprintf(s_logfile,
- "%lu: ", current_ms() / 1000);
+ "%"PRIu64": ", current_ms() / 1000);
va_start(ap, fmt);
(void) vfprintf(s_logfile, fmt, ap);
va_end(ap);
@@ -137,7 +137,7 @@ debug_print(FILE *out, int level, const char *fmt, ...)
} else {
(void) pthread_mutex_lock(&s_debug_ctl.mutex);
(void) fprintf(out,
- "%lu: ", current_ms() / 1000);
+ "%"PRIu64": ", current_ms() / 1000);
va_start(ap, fmt);
(void) vfprintf(out, fmt, ap);
va_end(ap);
@@ -319,6 +319,7 @@ static void
cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
unsigned int *edx)
{
+#if __x86_64
__asm volatile(
"cpuid\n\t"
:"=a" (*eax),
@@ -326,6 +327,20 @@ cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx,
"=c" (*ecx),
"=d" (*edx)
:"a" (*eax));
+#else
+ __asm volatile(
+ "push %%ebx\n\t"
+ "cpuid\n\t"
+ "mov %%ebx, (%4)\n\t"
+ "pop %%ebx"
+ :"=a" (*eax),
+ "=c" (*ecx),
+ "=d" (*edx)
+ :"0" (*eax),
+ "S" (ebx)
+ :"memory");
+#endif
+
}
/*
diff --git i/common/win.c w/common/win.c
index 3321a00..cb83397 100644
--- i/common/win.c
+++ w/common/win.c
@@ -1979,17 +1979,17 @@ win_size2str(uint64_t size, char *buf, int bufsize)
* "buf" points to a big enough buffer.
*/
if ((i = (size / KB_BYTES)) < KB_BYTES) {
- (void) snprintf(buf, bufsize, "%luK", i);
+ (void) snprintf(buf, bufsize, "%"PRIu64"K", i);
} else if ((j = i / KB_BYTES) < KB_BYTES) {
if ((i % KB_BYTES) == 0) {
- (void) snprintf(buf, bufsize, "%luM", j);
+ (void) snprintf(buf, bufsize, "%"PRIu64"M", j);
} else {
(void) snprintf(buf, bufsize, "%.1fM",
(double)i / (double)KB_BYTES);
}
} else {
if ((j % KB_BYTES) == 0) {
- (void) snprintf(buf, bufsize, "%luG", j / KB_BYTES);
+ (void) snprintf(buf, bufsize, "%"PRIu64"G", j / KB_BYTES);
} else {
(void) snprintf(buf, bufsize, "%.1fG",
(double)j / (double)KB_BYTES);
@@ -2314,12 +2314,12 @@ win_lat_data_show(track_proc_t *proc, dyn_lat_t *dyn, boolean_t *note_out)
if (lwp == NULL) {
(void) snprintf(content, sizeof (content),
"Monitoring memory areas (pid: %d, "
- "AVG.LAT: %luns, interval: %s)",
+ "AVG.LAT: %"PRIu64"ns, interval: %s)",
proc->pid, cyc2ns(lat), intval_buf);
} else {
(void) snprintf(content, sizeof (content),
"Monitoring memory areas (lwpid: %d, "
- "AVG.LAT: %luns, interval: %s)",
+ "AVG.LAT: %"PRIu64"ns, interval: %s)",
lwp->id, cyc2ns(lat), intval_buf);
}