From e3fcef9b73ffada8fc950912a3b9643b23a89eca Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 17 Sep 2012 13:54:18 -0500 Subject: [PATCH] (PR14571 partial fix) For dyninst, rename 'stat' to 'stat_data'. * runtime/stat.h: To avoid clashing with 'stat' definition from /usr/include/sys/stat.h, rename internal 'stat' typedef to 'stat_data'. * runtime/map-gen.c: Renamed 'stat' to 'stat_data'. * runtime/map-stat.c: Ditto. * runtime/map.c: Ditto. * runtime/map.h: Ditto. * runtime/pmap-gen.c: Ditto. * runtime/stat-common.c: Ditto. * runtime/stat.c: Ditto. --- runtime/map-gen.c | 6 +++--- runtime/map-stat.c | 10 +++++----- runtime/map.c | 24 ++++++++++++------------ runtime/map.h | 10 +++++----- runtime/pmap-gen.c | 6 +++--- runtime/stat-common.c | 7 ++++--- runtime/stat.c | 38 +++++++++++++++++++------------------- runtime/stat.h | 2 +- 8 files changed, 52 insertions(+), 51 deletions(-) diff --git a/runtime/map-gen.c b/runtime/map-gen.c index 430b5531d..69993245b 100644 --- a/runtime/map-gen.c +++ b/runtime/map-gen.c @@ -58,13 +58,13 @@ #define MAP_GET_VAL(n) _stp_get_int64(n) #define NULLRET (int64_t)0 #elif VALUE_TYPE == STAT -#define VALTYPE stat* +#define VALTYPE stat_data* #define VSTYPE int64_t -#define VALNAME stat +#define VALNAME stat_data #define VALN x #define MAP_SET_VAL(a,b,c,d) _new_map_set_stat(a,b,c,d) #define MAP_GET_VAL(n) _stp_get_stat(n) -#define NULLRET (stat*)0 +#define NULLRET (stat_data*)0 #else #error Need to define VALUE_TYPE as STRING, STAT, or INT64 #endif /* VALUE_TYPE */ diff --git a/runtime/map-stat.c b/runtime/map-stat.c index 262c20b4f..2548a0015 100644 --- a/runtime/map-stat.c +++ b/runtime/map-stat.c @@ -14,7 +14,7 @@ #include "stat-common.c" -static void _stp_map_print_histogram (MAP map, stat *sd) +static void _stp_map_print_histogram (MAP map, stat_data *sd) { _stp_stat_print_histogram (&map->hist, sd); } @@ -22,7 +22,7 @@ static void _stp_map_print_histogram (MAP map, stat *sd) static MAP _stp_map_new_hstat_log (unsigned max_entries, int key_size) { /* add size for buckets */ - int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat); + int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat_data); MAP m = _stp_map_new (max_entries, STAT, key_size, size); if (m) { m->hist.type = HIST_LOG; @@ -40,7 +40,7 @@ static MAP _stp_map_new_hstat_linear (unsigned max_entries, int ksize, int start return NULL; /* add size for buckets */ - size = buckets * sizeof(int64_t) + sizeof(stat); + size = buckets * sizeof(int64_t) + sizeof(stat_data); m = _stp_map_new (max_entries, STAT, ksize, size); if (m) { @@ -62,7 +62,7 @@ static PMAP _stp_pmap_new_hstat_linear (unsigned max_entries, int ksize, int sta return NULL; /* add size for buckets */ - size = buckets * sizeof(int64_t) + sizeof(stat); + size = buckets * sizeof(int64_t) + sizeof(stat_data); pmap = _stp_pmap_new (max_entries, STAT, ksize, size); if (pmap) { @@ -90,7 +90,7 @@ static PMAP _stp_pmap_new_hstat_linear (unsigned max_entries, int ksize, int sta static PMAP _stp_pmap_new_hstat_log (unsigned max_entries, int key_size) { /* add size for buckets */ - int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat); + int size = HIST_LOG_BUCKETS * sizeof(int64_t) + sizeof(stat_data); PMAP pmap = _stp_pmap_new (max_entries, STAT, key_size, size); if (pmap) { int i; diff --git a/runtime/map.c b/runtime/map.c index 97cc6f7aa..9bf625ebd 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -21,7 +21,7 @@ static int map_sizes[] = { sizeof(int64_t), MAP_STRING_LENGTH, - sizeof(stat), + sizeof(stat_data), 0 }; @@ -109,11 +109,11 @@ static char *_stp_get_str(struct map_node *m) * @param m pointer to the map_node. * @returns A pointer to the stats. */ -static stat *_stp_get_stat(struct map_node *m) +static stat_data *_stp_get_stat(struct map_node *m) { if (!m || m->map->type != STAT) return 0; - return (stat *)((long)m + m->map->data_offset); + return (stat_data *)((long)m + m->map->data_offset); } /** Return an int64 key from a map node. @@ -459,8 +459,8 @@ static int _stp_cmp (struct list_head *a, struct list_head *b, int keynum, int d a = _stp_key_get_int64(m1, keynum); b = _stp_key_get_int64(m2, keynum); } else if (keynum < 0) { - stat *sd1 = (stat *)((long)m1 + m1->map->data_offset); - stat *sd2 = (stat *)((long)m2 + m2->map->data_offset); + stat_data *sd1 = (stat_data *)((long)m1 + m1->map->data_offset); + stat_data *sd2 = (stat_data *)((long)m2 + m2->map->data_offset); switch (keynum) { case SORT_COUNT: a = sd1->count; @@ -660,8 +660,8 @@ static struct map_node *_stp_new_agg(MAP agg, struct hlist_head *ahead, struct m 0); break; case STAT: { - stat *sd1 = (stat *)((long)aptr + agg->data_offset); - stat *sd2 = (stat *)((long)ptr + ptr->map->data_offset); + stat_data *sd1 = (stat_data *)((long)aptr + agg->data_offset); + stat_data *sd2 = (stat_data *)((long)ptr + ptr->map->data_offset); Hist st = &agg->hist; sd1->count = sd2->count; sd1->sum = sd2->sum; @@ -696,8 +696,8 @@ static void _stp_add_agg(struct map_node *aptr, struct map_node *ptr) 1); break; case STAT: { - stat *sd1 = (stat *)((long)aptr + aptr->map->data_offset); - stat *sd2 = (stat *)((long)ptr + ptr->map->data_offset); + stat_data *sd1 = (stat_data *)((long)aptr + aptr->map->data_offset); + stat_data *sd2 = (stat_data *)((long)ptr + ptr->map->data_offset); Hist st = &aptr->map->hist; if (sd1->count == 0) { sd1->count = sd2->count; @@ -808,7 +808,7 @@ static void _new_map_clear_node (struct map_node *m) break; case STAT: { - stat *sd = (stat *)((long)m + m->map->data_offset); + stat_data *sd = (stat_data *)((long)m + m->map->data_offset); Hist st = &m->map->hist; sd->count = 0; if (st->type != HIST_NONE) { @@ -884,12 +884,12 @@ static int _new_map_set_str (MAP map, struct map_node *n, char *val, int add) static int _new_map_set_stat (MAP map, struct map_node *n, int64_t val, int add) { - stat *sd; + stat_data *sd; if (map == NULL || n == NULL) return -2; - sd = (stat *)((long)n + map->data_offset); + sd = (stat_data *)((long)n + map->data_offset); if (!add) { Hist st = &map->hist; sd->count = 0; diff --git a/runtime/map.h b/runtime/map.h index 993fc5ebc..51d657f8c 100644 --- a/runtime/map.h +++ b/runtime/map.h @@ -179,9 +179,9 @@ static int int64_eq_p(int64_t key1, int64_t key2); void int64_copy(void *dest, int64_t val); void int64_add(void *dest, int64_t val); int64_t int64_get(void *ptr); -void stat_copy(void *dest, stat *src); -void stat_add(void *dest, stat *src); -stat *stat_get(void *ptr); +void stat_copy(void *dest, stat_data *src); +void stat_add(void *dest, stat_data *src); +stat_data *stat_get(void *ptr); static int64_t _stp_key_get_int64(struct map_node *mn, int n); static char * _stp_key_get_str(struct map_node *mn, int n); static unsigned int int64_hash(const int64_t v); @@ -191,14 +191,14 @@ static void str_add(void *dest, char *val); static int str_eq_p(char *key1, char *key2); static int64_t _stp_get_int64(struct map_node *m); static char * _stp_get_str(struct map_node *m); -static stat *_stp_get_stat(struct map_node *m); +static stat_data *_stp_get_stat(struct map_node *m); static unsigned int str_hash(const char *key1); static MAP _stp_map_new(unsigned max_entries, int type, int key_size, int data_size); static PMAP _stp_pmap_new(unsigned max_entries, int type, int key_size, int data_size); static int msb64(int64_t x); static MAP _stp_map_new_hstat_log(unsigned max_entries, int key_size); static MAP _stp_map_new_hstat_linear(unsigned max_entries, int ksize, int start, int stop, int interval); -static void _stp_map_print_histogram(MAP map, stat *s); +static void _stp_map_print_histogram(MAP map, stat_data *s); static struct map_node * _stp_map_start(MAP map); static struct map_node * _stp_map_iter(MAP map, struct map_node *m); static void _stp_map_del(MAP map); diff --git a/runtime/pmap-gen.c b/runtime/pmap-gen.c index 8261c89d4..c44b6339c 100644 --- a/runtime/pmap-gen.c +++ b/runtime/pmap-gen.c @@ -58,13 +58,13 @@ #define MAP_GET_VAL(n) _stp_get_int64(n) #define NULLRET (int64_t)0 #elif VALUE_TYPE == STAT -#define VALTYPE stat* +#define VALTYPE stat_data* #define VSTYPE int64_t -#define VALNAME stat +#define VALNAME stat_data #define VALN x #define MAP_SET_VAL(a,b,c,d) _new_map_set_stat(a,b,c,d) #define MAP_GET_VAL(n) _stp_get_stat(n) -#define NULLRET (stat*)0 +#define NULLRET (stat_data*)0 #else #error Need to define VALUE_TYPE as STRING, STAT, or INT64 #endif /* VALUE_TYPE */ diff --git a/runtime/stat-common.c b/runtime/stat-common.c index fabe8404d..b247757e3 100644 --- a/runtime/stat-common.c +++ b/runtime/stat-common.c @@ -132,7 +132,8 @@ static int _stp_val_to_bucket(int64_t val) #endif -static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat *sd) +static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, + stat_data *sd) { int scale, i, j, val_space, cnt_space; int low_bucket = -1, high_bucket = 0, over = 0, under = 0; @@ -279,13 +280,13 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat #undef HIST_PRINTF } -static void _stp_stat_print_histogram(Hist st, stat *sd) +static void _stp_stat_print_histogram(Hist st, stat_data *sd) { _stp_stat_print_histogram_buf(NULL, 0, st, sd); _stp_print_flush(); } -static void __stp_stat_add(Hist st, stat *sd, int64_t val) +static void __stp_stat_add(Hist st, stat_data *sd, int64_t val) { int n; if (sd->count == 0) { diff --git a/runtime/stat.c b/runtime/stat.c index 31b157dbe..58c71eb0c 100644 --- a/runtime/stat.c +++ b/runtime/stat.c @@ -42,20 +42,20 @@ /* for the paranoid. */ #if NEED_STAT_LOCKS == 1 -#define STAT_LOCK(st) spin_lock(&st->lock) -#define STAT_UNLOCK(st) spin_unlock(&st->lock) +#define STAT_LOCK(sd) spin_lock(&sd->lock) +#define STAT_UNLOCK(sd) spin_unlock(&sd->lock) #else -#define STAT_LOCK(st) ; -#define STAT_UNLOCK(st) ; +#define STAT_LOCK(sd) ; +#define STAT_UNLOCK(sd) ; #endif /** Stat struct for stat.c. Maps do not need this */ struct _Stat { struct _Hist hist; /* per-cpu data. allocated with _stp_alloc_percpu() */ - stat *sd; + stat_data *sd; /* aggregated data */ - stat *agg; + stat_data *agg; }; typedef struct _Stat *Stat; @@ -77,7 +77,7 @@ typedef struct _Stat *Stat; static Stat _stp_stat_init (int type, ...) { int size, buckets=0, start=0, stop=0, interval=0; - stat *sd, *agg; + stat_data *sd, *agg; Stat st; if (type != HIST_NONE) { @@ -102,8 +102,8 @@ static Stat _stp_stat_init (int type, ...) if (st == NULL) return NULL; - size = buckets * sizeof(int64_t) + sizeof(stat); - sd = (stat *) _stp_alloc_percpu (size); + size = buckets * sizeof(int64_t) + sizeof(stat_data); + sd = (stat_data *) _stp_alloc_percpu (size); if (sd == NULL) goto exit1; @@ -111,13 +111,13 @@ static Stat _stp_stat_init (int type, ...) { int i; for_each_possible_cpu(i) { - stat *sdp = per_cpu_ptr (sd, i); + stat_data *sdp = per_cpu_ptr (sd, i); spin_lock_init(sdp->lock); } } #endif - agg = (stat *)_stp_kmalloc_gfp(size, STP_ALLOC_SLEEP_FLAGS); + agg = (stat_data *)_stp_kmalloc_gfp(size, STP_ALLOC_SLEEP_FLAGS); if (agg == NULL) goto exit2; @@ -159,7 +159,7 @@ static void _stp_stat_del (Stat st) */ static void _stp_stat_add (Stat st, int64_t val) { - stat *sd = per_cpu_ptr (st->sd, get_cpu()); + stat_data *sd = per_cpu_ptr (st->sd, get_cpu()); STAT_LOCK(sd); __stp_stat_add (&st->hist, sd, val); STAT_UNLOCK(sd); @@ -176,14 +176,14 @@ static void _stp_stat_add (Stat st, int64_t val) * @param cpu CPU number * @returns A pointer to a stat. */ -static stat *_stp_stat_get_cpu (Stat st, int cpu) +static stat_data *_stp_stat_get_cpu (Stat st, int cpu) { - stat *sd = per_cpu_ptr (st->sd, cpu); + stat_data *sd = per_cpu_ptr (st->sd, cpu); STAT_LOCK(sd); return sd; } -static void _stp_stat_clear_data (Stat st, stat *sd) +static void _stp_stat_clear_data (Stat st, stat_data *sd) { int j; sd->count = sd->sum = sd->min = sd->max = 0; @@ -204,15 +204,15 @@ static void _stp_stat_clear_data (Stat st, stat *sd) * for polling. * @returns A pointer to a stat. */ -static stat *_stp_stat_get (Stat st, int clear) +static stat_data *_stp_stat_get (Stat st, int clear) { int i, j; - stat *agg = st->agg; + stat_data *agg = st->agg; STAT_LOCK(agg); _stp_stat_clear_data (st, agg); for_each_possible_cpu(i) { - stat *sd = per_cpu_ptr (st->sd, i); + stat_data *sd = per_cpu_ptr (st->sd, i); STAT_LOCK(sd); if (sd->count) { if (agg->count == 0) { @@ -247,7 +247,7 @@ static void _stp_stat_clear (Stat st) { int i; for_each_possible_cpu(i) { - stat *sd = per_cpu_ptr (st->sd, i); + stat_data *sd = per_cpu_ptr (st->sd, i); STAT_LOCK(sd); _stp_stat_clear_data (st, sd); STAT_UNLOCK(sd); diff --git a/runtime/stat.h b/runtime/stat.h index 4357abb41..d61bfcfd5 100644 --- a/runtime/stat.h +++ b/runtime/stat.h @@ -38,7 +38,7 @@ struct stat_data { #endif int64_t histogram[]; }; -typedef struct stat_data stat; +typedef struct stat_data stat_data; /** Information about the histogram data collected. This data is global and not duplicated per-cpu. */ -- 2.43.5