diff --git a/common/main.cc b/common/main.cc index a5fa0db..e1bd9ba 100644 --- a/common/main.cc +++ b/common/main.cc @@ -73,7 +73,7 @@ std::string cpu_string( unsigned int cpu_usage_delay, unsigned int graph_lines, if( graph_lines > 0) { - oss << "["; + oss << " ["; oss << get_graph_by_percentage( unsigned( percentage ), graph_lines ); oss << "]"; } @@ -173,7 +173,7 @@ int main( int argc, char** argv ) return EXIT_FAILURE; } - std::cout << mem_string( use_colors ) << ' ' + std::cout << mem_string( use_colors ) << cpu_string( cpu_usage_delay, graph_lines, use_colors ) << ' ' << load_string( use_colors ); diff --git a/openbsd/cpu.cc b/openbsd/cpu.cc index 9af4eb5..fefc215 100644 --- a/openbsd/cpu.cc +++ b/openbsd/cpu.cc @@ -42,8 +42,18 @@ float cpu_percentage( unsigned int cpu_usage_delay ) { int cpu_ctl[] = { CTL_KERN, KERN_CPTIME }; + // on 64bit systems KERN_CPTIME gets reported as 64bit + // uint. Detect 64bit system and define array to hold the + // stats accordingly. + // NOTE: the following test may need to be extended to cover + // more 64bit platforms. +#if __x86_64__ || __ppc64__ + u_int64_t load1[CPUSTATES]; + u_int64_t load2[CPUSTATES]; +#else u_int32_t load1[CPUSTATES]; u_int32_t load2[CPUSTATES]; +#endif size_t size = sizeof( load1 );