diff options
author | tgingold <tgingold@users.noreply.github.com> | 2017-04-18 06:48:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-18 06:48:02 +0200 |
commit | 4ba1e81209431b98723dc85d0a5a37c52982e874 (patch) | |
tree | bccfe8cb64e5ea6e9c29f94e9cca8072eec8b66b /src/grt/ghwlib.c | |
parent | 2f29858cd3a29921b28a5e699b848f0ec16fb7cc (diff) | |
parent | ba52acf5442bfdc69bd8ef3f8aee88b6af4a73c5 (diff) | |
download | ghdl-4ba1e81209431b98723dc85d0a5a37c52982e874.tar.gz ghdl-4ba1e81209431b98723dc85d0a5a37c52982e874.tar.bz2 ghdl-4ba1e81209431b98723dc85d0a5a37c52982e874.zip |
Merge pull request #336 from emogenet/master
Move skip flags to own arry in ghwlib + indent new code to indigenous style
Diffstat (limited to 'src/grt/ghwlib.c')
-rw-r--r-- | src/grt/ghwlib.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/grt/ghwlib.c b/src/grt/ghwlib.c index 4ac721ee0..bee84687c 100644 --- a/src/grt/ghwlib.c +++ b/src/grt/ghwlib.c @@ -839,6 +839,7 @@ ghw_read_hie (struct ghw_handler *h) h->hie = blk; h->nbr_sigs++; + h->skip_sigs = NULL; h->sigs = (struct ghw_sig *) malloc (h->nbr_sigs * sizeof (struct ghw_sig)); memset (h->sigs, 0, h->nbr_sigs * sizeof (struct ghw_sig)); @@ -1345,28 +1346,44 @@ ghw_get_value (char *buf, int len, union ghw_val *val, union ghw_type *type) } } -static int +static char is_skip_signal (int *signals_to_keep, int nb_signals_to_keep, int signal) { int i; - for (i = 0; i < nb_signals_to_keep; ++i) { - if (signal==signals_to_keep[i]) - return 0; + if (signal == signals_to_keep[i]) + { + return 0; + } } return 1; } void -ghw_filter_values (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep) +ghw_filter_signals (struct ghw_handler *h, + int *signals_to_keep, int nb_signals_to_keep) { int i; - - for (i = 0; i < h->nbr_sigs; ++i) + if (0 < nb_signals_to_keep && 0 != signals_to_keep) + { + if (0 == h->skip_sigs) + { + h->skip_sigs = (char *) malloc (sizeof (char) * h->nbr_sigs); + } + for (i = 0; i < h->nbr_sigs; ++i) + { + h->skip_sigs[i] = is_skip_signal (signals_to_keep, + nb_signals_to_keep, i); + } + } + else { - struct ghw_sig *s = &(h->sigs[i]); - s->skip = is_skip_signal (signals_to_keep, nb_signals_to_keep, i); + if (0 != h->skip_sigs) + { + free (h->skip_sigs); + h->skip_sigs = 0; + } } } @@ -1374,11 +1391,11 @@ void ghw_disp_values (struct ghw_handler *h) { int i; - for (i = 0; i < h->nbr_sigs; i++) { struct ghw_sig *s = &h->sigs[i]; - if (s->type != NULL && !(s->skip)) + int skip = (0 != h->skip_sigs && (0 != h->skip_sigs[i])); + if (s->type != NULL && !skip) { printf ("#%d: ", i); ghw_disp_value (s->val, s->type); @@ -1386,7 +1403,6 @@ ghw_disp_values (struct ghw_handler *h) } } } - int ghw_read_directory (struct ghw_handler *h) { |