lkml.org 
[lkml]   [2015]   [Apr]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/7] perf tools: Move TUI-specific fields to struct hist_entry_tui
Em Mon, Apr 20, 2015 at 10:00:46PM +0900, Namhyung Kim escreveu:
> +++ b/tools/perf/ui/browsers/hists.c
> @@ -61,7 +61,7 @@ static int hist_browser__get_folding(struct hist_browser *browser)
> rb_entry(nd, struct hist_entry, rb_node);

> if (he->ms.unfolded)
> - unfolded_rows += he->nr_rows;
> + unfolded_rows += he->tui.nr_rows;

To avoid all these changes, I wonder if we can't use unamed structs in
addition to the unnamed union?

Like this what is done in include/net/sock.h, struct sock_common, and
here:

[root@zoo ~]# cat unnamed_struct_union.c
#include <stdbool.h>
#include <stdio.h>

struct hist_entry {
union {
struct /* tui */ {
int nr_rows;
int row_offset;
/* other fields */
};
struct /* diff */ {
bool computed;
/* other fields */
};
};
};

int main(int argc, char *argv[])
{
struct hist_entry he = { .nr_rows = 11, .row_offset = 19, };

printf("he.nr_rows=%d, he.row_offset=%d\n", he.nr_rows,
he.row_offset);
}
[root@zoo ~]# make unnamed_struct_union
cc unnamed_struct_union.c -o unnamed_struct_union
[root@zoo ~]# ./unnamed_struct_union
he.nr_rows=11, he.row_offset=19
[root@zoo ~]#

- Arnaldo


\
 
 \ /
  Last update: 2015-04-20 22:01    [W:0.093 / U:2.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site