summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4f79fc1)
raw | patch | inline | side by side (parent: 4f79fc1)
author | Vincent Brillault <git@lerya.net> | |
Fri, 20 Jun 2014 08:30:09 +0000 (10:30 +0200) | ||
committer | Vincent Brillault <git@lerya.net> | |
Sat, 28 Feb 2015 06:35:40 +0000 (07:35 +0100) |
- Remove horrible STATIC_MUST_CHECK macro
- Define __must_check __attribute__((warn_unused_result))
- Refactor function declaration: type only on first line
- Define __must_check __attribute__((warn_unused_result))
- Refactor function declaration: type only on first line
src/turbostat.c | patch | blob | history |
diff --git a/src/turbostat.c b/src/turbostat.c
index 755d00faee1d4a43e3402d3f91e39bde7e0e0b55..41e2219a4ea1130fc97d23f334c1c4bf5f32dbc9 100644 (file)
--- a/src/turbostat.c
+++ b/src/turbostat.c
ERR_NOT_ROOT,
};
-#define STATIC_MUST_CHECK(function) \
-function \
- __attribute__((warn_unused_result)); \
-function
+#define __must_check __attribute__((warn_unused_result))
static int setup_all_buffers(void);
-static int cpu_is_not_present(int cpu)
+static int
+cpu_is_not_present(int cpu)
{
return !CPU_ISSET_S(cpu, cpu_present_setsize, cpu_present_set);
}
* skip non-present cpus
*/
-STATIC_MUST_CHECK(static int for_all_cpus(int (func)(struct thread_data *, struct core_data *, struct pkg_data *),
- struct thread_data *thread_base, struct core_data *core_base, struct pkg_data *pkg_base))
+static int __must_check
+for_all_cpus(int (func)(struct thread_data *, struct core_data *, struct pkg_data *),
+ struct thread_data *thread_base, struct core_data *core_base, struct pkg_data *pkg_base)
{
int retval, pkg_no, core_no, thread_no;
@@ -257,7 +256,8 @@ STATIC_MUST_CHECK(static int for_all_cpus(int (func)(struct thread_data *, struc
return 0;
}
-STATIC_MUST_CHECK(static int cpu_migrate(int cpu))
+static int __must_check
+cpu_migrate(int cpu)
{
CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set);
CPU_SET_S(cpu, cpu_affinity_setsize, cpu_affinity_set);
return 0;
}
-STATIC_MUST_CHECK(static int get_msr(int cpu, off_t offset, unsigned long long *msr))
+static int __must_check
+get_msr(int cpu, off_t offset, unsigned long long *msr)
{
ssize_t retval;
char pathname[32];
/*
* old = new - old
*/
-STATIC_MUST_CHECK(static int
+static int __must_check
delta_thread(struct thread_data *new, struct thread_data *old,
- struct core_data *core_delta))
+ struct core_data *core_delta)
{
old->tsc = new->tsc - old->tsc;
return 0;
}
-STATIC_MUST_CHECK(static int delta_cpu(struct thread_data *t, struct core_data *c,
+static int __must_check
+delta_cpu(struct thread_data *t, struct core_data *c,
struct pkg_data *p, struct thread_data *t2,
- struct core_data *c2, struct pkg_data *p2))
+ struct core_data *c2, struct pkg_data *p2)
{
int ret;
@@ -411,7 +413,8 @@ STATIC_MUST_CHECK(static int delta_cpu(struct thread_data *t, struct core_data *
return 0;
}
-static unsigned long long rdtsc(void)
+static unsigned long long
+rdtsc(void)
{
unsigned int low, high;
* migrate to cpu
* acquire and record local counters for that cpu
*/
-STATIC_MUST_CHECK(static int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p))
+static int __must_check
+get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
{
int cpu = t->cpu_id;
unsigned long long msr;
@@ -538,7 +542,8 @@ STATIC_MUST_CHECK(static int get_counters(struct thread_data *t, struct core_dat
return 0;
}
-static void free_all_buffers(void)
+static void
+free_all_buffers(void)
{
allocated = false;
initialized = false;
/*
* Parse a file containing a single int.
*/
-static int parse_int_file(const char *fmt, ...)
+static int
+parse_int_file(const char *fmt, ...)
{
va_list args;
char path[PATH_MAX];
* cpu_is_first_sibling_in_core(cpu)
* return 1 if given CPU is 1st HT sibling in the core
*/
-static int cpu_is_first_sibling_in_core(int cpu)
+static int
+cpu_is_first_sibling_in_core(int cpu)
{
return cpu == parse_int_file("/sys/devices/system/cpu/cpu%d/topology/thread_siblings_list", cpu);
}
* cpu_is_first_core_in_package(cpu)
* return 1 if given CPU is 1st core in package
*/
-static int cpu_is_first_core_in_package(int cpu)
+static int
+cpu_is_first_core_in_package(int cpu)
{
return cpu == parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_siblings_list", cpu);
}
-static int get_physical_package_id(int cpu)
+static int
+get_physical_package_id(int cpu)
{
return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/physical_package_id", cpu);
}
-static int get_core_id(int cpu)
+static int
+get_core_id(int cpu)
{
return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/core_id", cpu);
}
-static int get_num_ht_siblings(int cpu)
+static int
+get_num_ht_siblings(int cpu)
{
char path[80];
FILE *filep;
* skip non-present cpus
*/
-STATIC_MUST_CHECK(
-static int for_all_cpus_2(int (func)(struct thread_data *, struct core_data *,
+
+static int __must_check
+for_all_cpus_2(int (func)(struct thread_data *, struct core_data *,
struct pkg_data *, struct thread_data *, struct core_data *,
struct pkg_data *), struct thread_data *thread_base,
struct core_data *core_base, struct pkg_data *pkg_base,
struct thread_data *thread_base2, struct core_data *core_base2,
- struct pkg_data *pkg_base2))
+ struct pkg_data *pkg_base2)
{
int retval, pkg_no, core_no, thread_no;
* run func(cpu) on every cpu in /proc/stat
* return max_cpu number
*/
-STATIC_MUST_CHECK(static int for_all_proc_cpus(int (func)(int)))
+static int __must_check
+for_all_proc_cpus(int (func)(int))
{
FILE *fp;
int cpu_num;
* count_cpus()
* remember the last one seen, it will be the max
*/
-static int count_cpus(int cpu)
+static int
+count_cpus(int cpu)
{
if (topo.max_cpu_num < cpu)
topo.max_cpu_num = cpu;
topo.num_cpus += 1;
return 0;
}
-static int mark_cpu_present(int cpu)
+static int
+mark_cpu_present(int cpu)
{
CPU_SET_S(cpu, cpu_present_setsize, cpu_present_set);
return 0;
}
-static void turbostat_submit (const char *plugin_instance,
+static void
+turbostat_submit (const char *plugin_instance,
const char *type, const char *type_instance,
gauge_t value)
{
* "CTMP" 4 columns %4d
*/
#define NAME_LEN 12
-static int submit_counters(struct thread_data *t, struct core_data *c,
+static int
+submit_counters(struct thread_data *t, struct core_data *c,
struct pkg_data *p)
{
char name[NAME_LEN];
return 0;
}
-static int turbostat_read (user_data_t * not_used)
+static int
+turbostat_read(user_data_t * not_used)
{
int ret;
return 0;
}
-STATIC_MUST_CHECK(static int check_dev_msr())
+static int __must_check
+check_dev_msr()
{
struct stat sb;
return 0;
}
-STATIC_MUST_CHECK(static int check_super_user())
+static int __must_check
+check_super_user()
{
if (getuid() != 0) {
ERROR("must be root");
#define RAPL_POWER_GRANULARITY 0x7FFF /* 15 bit power granularity */
#define RAPL_TIME_GRANULARITY 0x3F /* 6 bit time granularity */
-static double get_tdp(unsigned int model)
+static double
+get_tdp(unsigned int model)
{
unsigned long long msr;
*
* sets do_rapl, rapl_power_units, rapl_energy_units, rapl_time_units
*/
-static void rapl_probe(unsigned int family, unsigned int model)
+static void
+rapl_probe(unsigned int family, unsigned int model)
{
unsigned long long msr;
unsigned int time_unit;
return;
}
-static int is_snb(unsigned int family, unsigned int model)
+static int
+is_snb(unsigned int family, unsigned int model)
{
if (!genuine_intel)
return 0;
return 0;
}
-static int has_c8_c9_c10(unsigned int family, unsigned int model)
+static int
+has_c8_c9_c10(unsigned int family, unsigned int model)
{
if (!genuine_intel)
return 0;
}
-static int is_slm(unsigned int family, unsigned int model)
+static int
+is_slm(unsigned int family, unsigned int model)
{
if (!genuine_intel)
return 0;
* below this value, including the Digital Thermal Sensor (DTS),
* Package Thermal Management Sensor (PTM), and thermal event thresholds.
*/
-STATIC_MUST_CHECK(static int set_temperature_target(struct thread_data *t, struct core_data *c, struct pkg_data *p))
+static int __must_check
+set_temperature_target(struct thread_data *t, struct core_data *c, struct pkg_data *p)
{
unsigned long long msr;
unsigned int target_c_local;
return 0;
}
-STATIC_MUST_CHECK(static int check_cpuid())
+static int __must_check
+check_cpuid()
{
unsigned int eax, ebx, ecx, edx, max_level;
unsigned int fms, family, model;
-STATIC_MUST_CHECK(static int topology_probe())
+static int __must_check
+topology_probe()
{
int i;
int ret;
*
* increment topo.num_cores when 1st core in pkg seen
*/
-static int init_counter(struct thread_data *thread_base, struct core_data *core_base,
+static int
+init_counter(struct thread_data *thread_base, struct core_data *core_base,
struct pkg_data *pkg_base, int thread_num, int core_num,
int pkg_num, int cpu_id)
{
@@ -1394,7 +1423,8 @@ static int init_counter(struct thread_data *thread_base, struct core_data *core_
}
-static int initialize_counters(int cpu_id)
+static int
+initialize_counters(int cpu_id)
{
int my_thread_id, my_core_id, my_package_id;
int ret;
return ret;
}
-static int turbostat_init(void)
+static int
+turbostat_init(void)
{
int ret;
struct timespec ts;
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
-static int turbostat_config (const char *key, const char *value)
+static int
+turbostat_config(const char *key, const char *value)
{
if (strcasecmp("Interval", key) == 0)
interval_sec = atoi(value);
return 0;
}
-void module_register (void);
-void module_register (void)
+void module_register(void);
+void module_register(void)
{
plugin_register_init(PLUGIN_NAME, turbostat_init);
plugin_register_config(PLUGIN_NAME, turbostat_config, config_keys, config_keys_num);