aboutsummaryrefslogtreecommitdiffstats
path: root/ghw
diff options
context:
space:
mode:
authorumarcor <unai.martinezcorral@ehu.eus>2021-04-23 15:37:37 +0200
committertgingold <tgingold@users.noreply.github.com>2021-04-23 20:40:50 +0200
commit1d527b1353cd51d5c763b58382746be6b3531e08 (patch)
tree9cc91de635d9a67f77137da96d7ad570f19673a3 /ghw
parentb9f5b9b28994d05a56ff4cc2721c0c3efe6a27c2 (diff)
downloadghdl-1d527b1353cd51d5c763b58382746be6b3531e08.tar.gz
ghdl-1d527b1353cd51d5c763b58382746be6b3531e08.tar.bz2
ghdl-1d527b1353cd51d5c763b58382746be6b3531e08.zip
ghw: run GNU indent
Diffstat (limited to 'ghw')
-rw-r--r--ghw/ghwdump.c43
-rw-r--r--ghw/ghwlib.c252
-rw-r--r--ghw/ghwlib.h106
3 files changed, 197 insertions, 204 deletions
diff --git a/ghw/ghwdump.c b/ghw/ghwdump.c
index ac237c64a..2acb0cab5 100644
--- a/ghw/ghwdump.c
+++ b/ghw/ghwdump.c
@@ -15,11 +15,11 @@
along with this program. If not, see <gnu.org/licenses>.
*/
-#include <stdio.h>
#include <assert.h>
#include <stdint.h>
-#include <string.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include "ghwlib.h"
@@ -36,9 +36,9 @@ usage (void)
" -T display time\n"
" -s display signals (and time)\n"
" -S display strings\n"
- " -f <lst> list of signals to display (default: all, example: -f 1,3,5-7,21-33)\n"
- " -l display list of sections\n"
- " -v verbose\n");
+ " -f <lst> list of signals to display (default: all, example: -f "
+ "1,3,5-7,21-33)\n"
+ " -l display list of sections\n" " -v verbose\n");
}
static void
@@ -57,8 +57,8 @@ add_single_signal (int **signalSet, int *nbSignals, int signal)
}
static void
-add_signal_range (int **signalSet,
- int *nbSignals, const char *s, const char *e)
+add_signal_range (int **signalSet, int *nbSignals, const char *s,
+ const char *e)
{
int i;
@@ -67,11 +67,8 @@ add_signal_range (int **signalSet,
int rangeStart = -1;
int bytesMatched = -1;
int expected = ((e - s) - 1);
- int itemsMatched = sscanf (s,
- "%d-%d%n",
- &rangeStart,
- &rangeEnd,
- &bytesMatched);
+ int itemsMatched =
+ sscanf (s, "%d-%d%n", &rangeStart, &rangeEnd, &bytesMatched);
if (2 == itemsMatched && expected == bytesMatched)
{
if (rangeEnd < rangeStart)
@@ -97,8 +94,8 @@ add_signal_range (int **signalSet,
if (rangeEnd < 0 || rangeStart < 0 || rangeSize < 0)
{
fprintf (stderr,
- "incorrect signal range specification\"%s\" found in command line, aborting\n",
- s);
+ "incorrect signal range specification\"%s\" found in "
+ "command line, aborting\n", s);
exit (1);
}
@@ -253,7 +250,7 @@ main (int argc, char **argv)
}
section_name = ghw_sections[section].name;
printf ("Section %s\n", section_name);
- if ((*ghw_sections[section].handler)(hp) < 0)
+ if ((*ghw_sections[section].handler) (hp) < 0)
break;
if (flag_disp_strings && strcmp (section_name, "STR") == 0)
@@ -289,14 +286,14 @@ main (int argc, char **argv)
if (flag_disp_time)
printf ("Time is %lld fs\n", hp->snap_time);
if (flag_disp_signals)
- {
- if (!filter_done)
- {
- ghw_filter_signals (hp, signal_set, nb_signals);
- filter_done = 1;
- }
- ghw_disp_values (hp);
- }
+ {
+ if (!filter_done)
+ {
+ ghw_filter_signals (hp, signal_set, nb_signals);
+ filter_done = 1;
+ }
+ ghw_disp_values (hp);
+ }
break;
case ghw_res_eof:
eof = 1;
diff --git a/ghw/ghwlib.c b/ghw/ghwlib.c
index 358d40736..0d320ff07 100644
--- a/ghw/ghwlib.c
+++ b/ghw/ghwlib.c
@@ -15,11 +15,11 @@
along with this program. If not, see <gnu.org/licenses>.
*/
+#include <assert.h>
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-#include <assert.h>
#include "ghwlib.h"
@@ -28,12 +28,12 @@
static int
ghw_openz (struct ghw_handler *h, const char *decomp, const char *filename)
{
- int plen = strlen (decomp) + 1 + strlen(filename) + 1;
+ int plen = strlen (decomp) + 1 + strlen (filename) + 1;
char *p = malloc (plen);
snprintf (p, plen, "%s %s", decomp, filename);
fclose (h->stream);
- h->stream = popen(p, "r");
+ h->stream = popen (p, "r");
free (p);
if (h->stream == NULL)
@@ -80,8 +80,7 @@ ghw_open (struct ghw_handler *h, const char *filename)
if (memcmp (hdr, "GHDLwave\n", 9) != 0)
return -2;
/* Check version. */
- if (hdr[9] != 16
- || hdr[10] != 0)
+ if (hdr[9] != 16 || hdr[10] != 0)
return -2;
h->version = hdr[11];
if (h->version > 1)
@@ -96,7 +95,11 @@ ghw_open (struct ghw_handler *h, const char *filename)
/* Endianness. */
{
int endian;
- union { unsigned char b[4]; uint32_t i;} v;
+ union
+ {
+ unsigned char b[4];
+ uint32_t i;
+ } v;
v.i = 0x11223344;
if (v.b[0] == 0x11)
endian = 2;
@@ -147,7 +150,7 @@ ghw_get_i64 (struct ghw_handler *ghw_h, unsigned char *b)
l = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | (b[0] << 0);
h = (b[7] << 24) | (b[6] << 16) | (b[5] << 8) | (b[4] << 0);
}
- return (((int64_t)h) << 32) | l;
+ return (((int64_t) h) << 32) | l;
}
int
@@ -163,7 +166,7 @@ ghw_read_byte (struct ghw_handler *h, unsigned char *res)
}
int
-ghw_read_uleb128 (struct ghw_handler *h, uint32_t *res)
+ghw_read_uleb128 (struct ghw_handler *h, uint32_t * res)
{
uint32_t r = 0;
unsigned int off = 0;
@@ -183,7 +186,7 @@ ghw_read_uleb128 (struct ghw_handler *h, uint32_t *res)
}
int
-ghw_read_sleb128 (struct ghw_handler *h, int32_t *res)
+ghw_read_sleb128 (struct ghw_handler *h, int32_t * res)
{
int32_t r = 0;
unsigned int off = 0;
@@ -193,7 +196,7 @@ ghw_read_sleb128 (struct ghw_handler *h, int32_t *res)
int v = fgetc (h->stream);
if (v == EOF)
return -1;
- r |= ((int32_t)(v & 0x7f)) << off;
+ r |= ((int32_t) (v & 0x7f)) << off;
off += 7;
if ((v & 0x80) == 0)
{
@@ -207,7 +210,7 @@ ghw_read_sleb128 (struct ghw_handler *h, int32_t *res)
}
int
-ghw_read_lsleb128 (struct ghw_handler *h, int64_t *res)
+ghw_read_lsleb128 (struct ghw_handler *h, int64_t * res)
{
static const int64_t r_mask = -1;
int64_t r = 0;
@@ -218,7 +221,7 @@ ghw_read_lsleb128 (struct ghw_handler *h, int64_t *res)
int v = fgetc (h->stream);
if (v == EOF)
return -1;
- r |= ((int64_t)(v & 0x7f)) << off;
+ r |= ((int64_t) (v & 0x7f)) << off;
off += 7;
if ((v & 0x80) == 0)
{
@@ -278,7 +281,7 @@ ghw_read_range (struct ghw_handler *h)
goto err_b2;
if (ghw_read_byte (h, &r->right) != 0)
goto err_b2;
- return (union ghw_range *)r;
+ return (union ghw_range *) r;
err_b2:
free (r);
return NULL;
@@ -293,7 +296,7 @@ ghw_read_range (struct ghw_handler *h)
goto err_e8;
if (ghw_read_byte (h, &r->right) != 0)
goto err_e8;
- return (union ghw_range *)r;
+ return (union ghw_range *) r;
err_e8:
free (r);
return NULL;
@@ -309,7 +312,7 @@ ghw_read_range (struct ghw_handler *h)
goto err_i32;
if (ghw_read_sleb128 (h, &r->right) != 0)
goto err_i32;
- return (union ghw_range *)r;
+ return (union ghw_range *) r;
err_i32:
free (r);
return NULL;
@@ -325,7 +328,7 @@ ghw_read_range (struct ghw_handler *h)
goto err_i64;
if (ghw_read_lsleb128 (h, &r->right) != 0)
goto err_i64;
- return (union ghw_range *)r;
+ return (union ghw_range *) r;
err_i64:
free (r);
return NULL;
@@ -340,7 +343,7 @@ ghw_read_range (struct ghw_handler *h)
goto err_f64;
if (ghw_read_f64 (h, &r->right) != 0)
goto err_f64;
- return (union ghw_range *)r;
+ return (union ghw_range *) r;
err_f64:
free (r);
return NULL;
@@ -367,8 +370,8 @@ ghw_read_str (struct ghw_handler *h)
h->nbr_str = ghw_get_i32 (h, &hdr[4]);
h->nbr_str++;
h->str_size = ghw_get_i32 (h, &hdr[8]);
- h->str_table = (char **)malloc ((h->nbr_str + 1) * sizeof (char *));
- h->str_content = (char *)malloc (h->str_size + h->nbr_str + 1);
+ h->str_table = (char **) malloc ((h->nbr_str + 1) * sizeof (char *));
+ h->str_content = (char *) malloc (h->str_size + h->nbr_str + 1);
if (h->flag_verbose)
{
@@ -396,8 +399,7 @@ ghw_read_str (struct ghw_handler *h)
c = fgetc (h->stream);
if (c == EOF)
return -1;
- if ((c >= 0 && c <= 31)
- || (c >= 128 && c <= 159))
+ if ((c >= 0 && c <= 31) || (c >= 128 && c <= 159))
break;
*p++ = c;
}
@@ -519,8 +521,8 @@ ghw_get_range_length (union ghw_range *rng)
return (res <= 0) ? 0 : res;
}
-static union ghw_type *
-ghw_read_type_bounds (struct ghw_handler *h, union ghw_type *base);
+static union ghw_type *ghw_read_type_bounds (struct ghw_handler *h,
+ union ghw_type *base);
/* Create an array subtype using BASE and ranges read from H. */
@@ -528,7 +530,7 @@ struct ghw_subtype_array *
ghw_read_array_subtype (struct ghw_handler *h, union ghw_type *base)
{
struct ghw_type_array *arr =
- (struct ghw_type_array *)ghw_get_base_type (base);
+ (struct ghw_type_array *) ghw_get_base_type (base);
struct ghw_subtype_array *sa;
unsigned j;
int nbr_scalars;
@@ -554,10 +556,10 @@ ghw_read_array_subtype (struct ghw_handler *h, union ghw_type *base)
else
{
/* Read bounds for the elements. */
- sa->el = ghw_read_type_bounds(h, arr->el);
+ sa->el = ghw_read_type_bounds (h, arr->el);
nbr_els = get_nbr_elements (sa->el);
}
- sa->nbr_scalars = nbr_scalars * nbr_els;
+ sa->nbr_scalars = nbr_scalars * nbr_els;
return sa;
}
@@ -582,7 +584,8 @@ ghw_read_record_subtype (struct ghw_handler *h, struct ghw_type_record *base)
unsigned j;
int nbr_scalars;
- sr->els = malloc (base->nbr_fields * sizeof (struct ghw_record_element));
+ sr->els =
+ malloc (base->nbr_fields * sizeof (struct ghw_record_element));
nbr_scalars = 0;
for (j = 0; j < base->nbr_fields; j++)
{
@@ -597,7 +600,7 @@ ghw_read_record_subtype (struct ghw_handler *h, struct ghw_type_record *base)
}
else
{
- sr->els[j].type = ghw_read_type_bounds(h, btype);
+ sr->els[j].type = ghw_read_type_bounds (h, btype);
el_nbr_scalars = get_nbr_elements (sr->els[j].type);
}
nbr_scalars += el_nbr_scalars;
@@ -616,15 +619,15 @@ ghw_read_type_bounds (struct ghw_handler *h, union ghw_type *base)
{
case ghdl_rtik_type_array:
case ghdl_rtik_subtype_unbounded_array:
- return (union ghw_type *)ghw_read_array_subtype (h, base);
+ return (union ghw_type *) ghw_read_array_subtype (h, base);
break;
case ghdl_rtik_type_record:
case ghdl_rtik_subtype_unbounded_record:
- return (union ghw_type *)ghw_read_record_subtype (h, &base->rec);
+ return (union ghw_type *) ghw_read_record_subtype (h, &base->rec);
break;
default:
fprintf (stderr, "ghw_read_type_bounds: unhandled kind %d\n",
- base->kind);
+ base->kind);
return NULL;
}
}
@@ -641,8 +644,8 @@ ghw_read_type (struct ghw_handler *h)
if (hdr[0] != 0 || hdr[1] != 0 || hdr[2] != 0 || hdr[3] != 0)
return -1;
h->nbr_types = ghw_get_i32 (h, &hdr[4]);
- h->types = (union ghw_type **)
- malloc (h->nbr_types * sizeof (union ghw_type *));
+ h->types =
+ (union ghw_type **) malloc (h->nbr_types * sizeof (union ghw_type *));
for (i = 0; i < h->nbr_types; i++)
{
@@ -652,7 +655,7 @@ ghw_read_type (struct ghw_handler *h)
if (t == EOF)
return -1;
if (h->flag_verbose > 1)
- printf ("type[%d]= %d\n", i, t);
+ printf ("type[%d]= %d\n", i, t);
switch (t)
{
case ghdl_rtik_type_b2:
@@ -678,7 +681,7 @@ ghw_read_type (struct ghw_handler *h)
}
if (h->flag_verbose > 1)
printf ("\n");
- h->types[i] = (union ghw_type *)e;
+ h->types[i] = (union ghw_type *) e;
break;
err_b2:
free (e);
@@ -696,9 +699,8 @@ ghw_read_type (struct ghw_handler *h)
sc->name = ghw_read_strid (h);
if (h->flag_verbose > 1)
printf ("scalar: %s\n", sc->name);
- h->types[i] = (union ghw_type *)sc;
- }
- break;
+ h->types[i] = (union ghw_type *) sc;
+ } break;
case ghdl_rtik_type_p32:
case ghdl_rtik_type_p64:
{
@@ -726,7 +728,7 @@ ghw_read_type (struct ghw_handler *h)
}
if (h->flag_verbose > 1)
printf ("physical: %s\n", ph->name);
- h->types[i] = (union ghw_type *)ph;
+ h->types[i] = (union ghw_type *) ph;
break;
err_p32:
free (ph->units);
@@ -745,9 +747,8 @@ ghw_read_type (struct ghw_handler *h)
ss->rng = ghw_read_range (h);
if (h->flag_verbose > 1)
printf ("subtype scalar: %s\n", ss->name);
- h->types[i] = (union ghw_type *)ss;
- }
- break;
+ h->types[i] = (union ghw_type *) ss;
+ } break;
case ghdl_rtik_type_array:
{
struct ghw_type_array *arr;
@@ -759,14 +760,15 @@ ghw_read_type (struct ghw_handler *h)
arr->el = ghw_read_typeid (h);
if (ghw_read_uleb128 (h, &arr->nbr_dim) != 0)
goto err_array;
- arr->dims = (union ghw_type **)
- malloc (arr->nbr_dim * sizeof (union ghw_type *));
+ arr->dims =
+ (union ghw_type **) malloc (arr->nbr_dim *
+ sizeof (union ghw_type *));
for (j = 0; j < arr->nbr_dim; j++)
arr->dims[j] = ghw_read_typeid (h);
if (h->flag_verbose > 1)
- printf ("array: %s (ndim=%u) of %s\n",
- arr->name, arr->nbr_dim, arr->el->common.name);
- h->types[i] = (union ghw_type *)arr;
+ printf ("array: %s (ndim=%u) of %s\n", arr->name, arr->nbr_dim,
+ arr->el->common.name);
+ h->types[i] = (union ghw_type *) arr;
break;
err_array:
free (arr);
@@ -784,21 +786,21 @@ ghw_read_type (struct ghw_handler *h)
sa = ghw_read_array_subtype (h, base);
sa->name = name;
- h->types[i] = (union ghw_type *)sa;
+ h->types[i] = (union ghw_type *) sa;
if (h->flag_verbose > 1)
- printf ("subtype array: %s (nbr_scalars=%d)\n",
- sa->name, sa->nbr_scalars);
+ printf ("subtype array: %s (nbr_scalars=%d)\n", sa->name,
+ sa->nbr_scalars);
}
break;
case ghdl_rtik_subtype_unbounded_array:
{
struct ghw_subtype_unbounded_array *sua;
- sua = malloc (sizeof (struct ghw_subtype_unbounded_array));
- sua->kind = t;
+ sua = malloc (sizeof (struct ghw_subtype_unbounded_array));
+ sua->kind = t;
sua->name = ghw_read_strid (h);
sua->base = ghw_read_typeid (h);
- h->types[i] = (union ghw_type *)sua;
+ h->types[i] = (union ghw_type *) sua;
if (h->flag_verbose > 1)
printf ("subtype unbounded array: %s\n", sua->name);
}
@@ -815,8 +817,8 @@ ghw_read_type (struct ghw_handler *h)
rec->els = NULL;
if (ghw_read_uleb128 (h, &rec->nbr_fields) != 0)
goto err_record;
- rec->els = malloc
- (rec->nbr_fields * sizeof (struct ghw_record_element));
+ rec->els =
+ malloc (rec->nbr_fields * sizeof (struct ghw_record_element));
nbr_scalars = 0;
for (j = 0; j < rec->nbr_fields; j++)
{
@@ -824,7 +826,8 @@ ghw_read_type (struct ghw_handler *h)
rec->els[j].type = ghw_read_typeid (h);
if (nbr_scalars != -1)
{
- int field_nbr_scalars = get_nbr_elements (rec->els[j].type);
+ int field_nbr_scalars =
+ get_nbr_elements (rec->els[j].type);
if (field_nbr_scalars == -1)
nbr_scalars = -1;
else
@@ -833,9 +836,9 @@ ghw_read_type (struct ghw_handler *h)
}
rec->nbr_scalars = nbr_scalars;
if (h->flag_verbose > 1)
- printf ("record type: %s (nbr_scalars=%d)\n",
- rec->name, rec->nbr_scalars);
- h->types[i] = (union ghw_type *)rec;
+ printf ("record type: %s (nbr_scalars=%d)\n", rec->name,
+ rec->nbr_scalars);
+ h->types[i] = (union ghw_type *) rec;
break;
err_record:
free (rec->els);
@@ -850,14 +853,14 @@ ghw_read_type (struct ghw_handler *h)
struct ghw_type_record *base;
name = ghw_read_strid (h);
- base = (struct ghw_type_record *)ghw_read_typeid (h);
+ base = (struct ghw_type_record *) ghw_read_typeid (h);
sr = ghw_read_record_subtype (h, base);
sr->name = name;
- h->types[i] = (union ghw_type *)sr;
+ h->types[i] = (union ghw_type *) sr;
if (h->flag_verbose > 1)
- printf ("subtype record: %s (nbr_scalars=%d)\n",
- sr->name, sr->nbr_scalars);
+ printf ("subtype record: %s (nbr_scalars=%d)\n", sr->name,
+ sr->nbr_scalars);
}
break;
default:
@@ -893,8 +896,7 @@ ghw_read_wk_types (struct ghw_handler *h)
break;
tid = ghw_read_typeid (h);
- if (tid->kind == ghdl_rtik_type_b2
- || tid->kind == ghdl_rtik_type_e8)
+ if (tid->kind == ghdl_rtik_type_b2 || tid->kind == ghdl_rtik_type_e8)
{
if (h->flag_verbose > 0)
printf ("%s: wkt=%d\n", tid->en.name, t);
@@ -907,7 +909,7 @@ ghw_read_wk_types (struct ghw_handler *h)
void
ghw_disp_typename (struct ghw_handler *h, union ghw_type *t)
{
- (void)h;
+ (void) h;
printf ("%s", t->common.name);
}
@@ -986,10 +988,9 @@ ghw_read_signal (struct ghw_handler *h, unsigned int *sigs, union ghw_type *t)
}
}
-
int
-ghw_read_value (struct ghw_handler *h,
- union ghw_val *val, union ghw_type *type)
+ghw_read_value (struct ghw_handler *h, union ghw_val *val,
+ union ghw_type *type)
{
switch (ghw_get_base_type (type)->kind)
{
@@ -1065,10 +1066,10 @@ ghw_read_hie (struct ghw_handler *h)
h->nbr_sigs = ghw_get_i32 (h, &hdr[12]);
if (h->flag_verbose)
- printf ("%u scopes, %u signals, %u signal elements\n",
- nbr_scopes, nbr_sigs, h->nbr_sigs);
+ printf ("%u scopes, %u signals, %u signal elements\n", nbr_scopes,
+ nbr_sigs, h->nbr_sigs);
- blk = (struct ghw_hie *)malloc (sizeof (struct ghw_hie));
+ blk = (struct ghw_hie *) malloc (sizeof (struct ghw_hie));
blk->kind = ghw_hie_design;
blk->name = NULL;
blk->parent = NULL;
@@ -1149,8 +1150,8 @@ ghw_read_hie (struct ghw_handler *h)
{
el->u.blk.iter_type = ghw_read_typeid (h);
el->u.blk.iter_value = malloc (sizeof (union ghw_val));
- if (ghw_read_value (h, el->u.blk.iter_value,
- el->u.blk.iter_type) < 0)
+ if (ghw_read_value
+ (h, el->u.blk.iter_value, el->u.blk.iter_type) < 0)
return -1;
}
blk = el;
@@ -1171,8 +1172,8 @@ ghw_read_hie (struct ghw_handler *h)
nbr_el = get_nbr_elements (el->u.sig.type);
if (nbr_el < 0)
return -1;
- sigs = (unsigned int *) malloc
- ((nbr_el + 1) * sizeof (unsigned int));
+ sigs =
+ (unsigned int *) malloc ((nbr_el + 1) * sizeof (unsigned int));
el->u.sig.sigs = sigs;
/* Last element is NULL. */
sigs[nbr_el] = 0;
@@ -1245,8 +1246,7 @@ ghw_get_hie_name (struct ghw_hie *h)
}
}
-void
-ghw_disp_value (union ghw_val *val, union ghw_type *type);
+void ghw_disp_value (union ghw_val *val, union ghw_type *type);
static void
print_name (struct ghw_hie *hie, int full_names)
@@ -1393,7 +1393,7 @@ ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top)
int
ghw_read_eoh (struct ghw_handler *h)
{
- (void)h;
+ (void) h;
return 0;
}
@@ -1540,7 +1540,6 @@ ghw_read_cycle_next (struct ghw_handler *h)
return 1;
}
-
int
ghw_read_cycle_end (struct ghw_handler *h)
{
@@ -1590,8 +1589,7 @@ ghw_disp_value (union ghw_val *val, union ghw_type *type)
printf ("%g", val->f64);
break;
default:
- fprintf (stderr, "ghw_disp_value: cannot handle type %d\n",
- type->kind);
+ fprintf (stderr, "ghw_disp_value: cannot handle type %d\n", type->kind);
abort ();
}
}
@@ -1657,8 +1655,8 @@ is_skip_signal (int *signals_to_keep, int nb_signals_to_keep, int signal)
}
void
-ghw_filter_signals (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)
{
unsigned i;
@@ -1670,8 +1668,8 @@ ghw_filter_signals (struct ghw_handler *h,
}
for (i = 0; i < h->nbr_sigs; ++i)
{
- h->skip_sigs[i] = is_skip_signal (signals_to_keep,
- nb_signals_to_keep, i);
+ h->skip_sigs[i] =
+ is_skip_signal (signals_to_keep, nb_signals_to_keep, i);
}
}
else
@@ -1700,6 +1698,7 @@ ghw_disp_values (struct ghw_handler *h)
}
}
}
+
int
ghw_read_directory (struct ghw_handler *h)
{
@@ -1792,8 +1791,8 @@ ghw_read_sm_hdr (struct ghw_handler *h, int *list)
}
else
{
- fprintf (stderr, "unknown GHW section %c%c%c%c\n",
- hdr[0], hdr[1], hdr[2], hdr[3]);
+ fprintf (stderr, "unknown GHW section %c%c%c%c\n", hdr[0], hdr[1],
+ hdr[2], hdr[3]);
return -1;
}
if (res != 0)
@@ -1872,7 +1871,6 @@ ghw_read_cycle (struct ghw_handler *h)
if (0)
ghw_disp_values (h);
-
res = ghw_read_cycle_next (h);
if (res < 0)
return res;
@@ -1918,8 +1916,8 @@ ghw_read_dump (struct ghw_handler *h)
}
else
{
- fprintf (stderr, "unknown GHW section %c%c%c%c\n",
- hdr[0], hdr[1], hdr[2], hdr[3]);
+ fprintf (stderr, "unknown GHW section %c%c%c%c\n", hdr[0], hdr[1],
+ hdr[2], hdr[3]);
return -1;
}
if (res != 0)
@@ -1927,17 +1925,16 @@ ghw_read_dump (struct ghw_handler *h)
}
}
-struct ghw_section ghw_sections[] = {
- { "\0\0\0", NULL },
- { "STR", ghw_read_str },
- { "HIE", ghw_read_hie },
- { "TYP", ghw_read_type },
- { "WKT", ghw_read_wk_types },
- { "EOH", ghw_read_eoh },
- { "SNP", ghw_read_snapshot },
- { "CYC", ghw_read_cycle },
- { "DIR", ghw_read_directory },
- { "TAI", ghw_read_tailer }
+struct ghw_section ghw_sections[] = { {"\0\0\0", NULL},
+{"STR", ghw_read_str},
+{"HIE", ghw_read_hie},
+{"TYP", ghw_read_type},
+{"WKT", ghw_read_wk_types},
+{"EOH", ghw_read_eoh},
+{"SNP", ghw_read_snapshot},
+{"CYC", ghw_read_cycle},
+{"DIR", ghw_read_directory},
+{"TAI", ghw_read_tailer}
};
int
@@ -1958,8 +1955,8 @@ ghw_read_section (struct ghw_handler *h)
if (memcmp (hdr, ghw_sections[i].name, 4) == 0)
return i;
- fprintf (stderr, "ghw_read_section: unknown GHW section %c%c%c%c\n",
- hdr[0], hdr[1], hdr[2], hdr[3]);
+ fprintf (stderr, "ghw_read_section: unknown GHW section %c%c%c%c\n", hdr[0],
+ hdr[1], hdr[2], hdr[3]);
return 0;
}
@@ -1998,17 +1995,17 @@ ghw_disp_range (union ghw_type *type, union ghw_range *rng)
break;
case ghdl_rtik_type_i32:
case ghdl_rtik_type_p32:
- printf (GHWPRI32 " %s " GHWPRI32,
- rng->i32.left, ghw_get_dir (rng->i32.dir), rng->i32.right);
+ printf (GHWPRI32 " %s " GHWPRI32, rng->i32.left,
+ ghw_get_dir (rng->i32.dir), rng->i32.right);
break;
case ghdl_rtik_type_i64:
case ghdl_rtik_type_p64:
- printf (GHWPRI64 " %s " GHWPRI64,
- rng->i64.left, ghw_get_dir (rng->i64.dir), rng->i64.right);
+ printf (GHWPRI64 " %s " GHWPRI64, rng->i64.left,
+ ghw_get_dir (rng->i64.dir), rng->i64.right);
break;
case ghdl_rtik_type_f64:
- printf ("%g %s %g",
- rng->f64.left, ghw_get_dir (rng->f64.dir), rng->f64.right);
+ printf ("%g %s %g", rng->f64.left, ghw_get_dir (rng->f64.dir),
+ rng->f64.right);
break;
default:
printf ("?(%d)", rng->kind);
@@ -2020,7 +2017,7 @@ ghw_disp_array_subtype_bounds (struct ghw_subtype_array *a)
{
unsigned i;
struct ghw_type_array *base =
- (struct ghw_type_array *)ghw_get_base_type (a->base);
+ (struct ghw_type_array *) ghw_get_base_type (a->base);
printf (" (");
for (i = 0; i < base->nbr_dim; i++)
@@ -2079,31 +2076,27 @@ ghw_disp_subtype_definition (struct ghw_handler *h, union ghw_type *t)
ghw_disp_typename (h, s->base);
printf (" range ");
ghw_disp_range (s->base, s->rng);
- }
- break;
+ } break;
case ghdl_rtik_subtype_array:
{
struct ghw_subtype_array *a = &t->sa;
- ghw_disp_typename (h, (union ghw_type *)a->base);
+ ghw_disp_typename (h, (union ghw_type *) a->base);
ghw_disp_array_subtype_bounds (a);
- }
- break;
+ } break;
case ghdl_rtik_subtype_record:
{
struct ghw_subtype_record *sr = &t->sr;
- ghw_disp_typename (h, (union ghw_type *)sr->base);
+ ghw_disp_typename (h, (union ghw_type *) sr->base);
ghw_disp_record_subtype_bounds (sr);
- }
- break;
+ } break;
case ghdl_rtik_subtype_unbounded_array:
{
struct ghw_subtype_unbounded_record *sur = &t->sur;
- ghw_disp_typename (h, (union ghw_type *)sur->base);
- }
- break;
+ ghw_disp_typename (h, (union ghw_type *) sur->base);
+ } break;
default:
printf ("ghw_disp_subtype_definition: unhandled type kind %d\n",
t->kind);
@@ -2157,8 +2150,7 @@ ghw_disp_type (struct ghw_handler *h, union ghw_type *t)
{
struct ghw_type_scalar *s = &t->sc;
printf ("type %s is range <>;\n", s->name);
- }
- break;
+ } break;
case ghdl_rtik_type_p32:
case ghdl_rtik_type_p64:
{
@@ -2169,12 +2161,11 @@ ghw_disp_type (struct ghw_handler *h, union ghw_type *t)
for (i = 0; i < p->nbr_units; i++)
{
struct ghw_unit *u = &p->units[i];
- printf (" %s = " GHWPRI64 " %s;\n",
- u->name, u->val, p->units[0].name);
+ printf (" %s = " GHWPRI64 " %s;\n", u->name, u->val,
+ p->units[0].name);
}
printf ("end units\n");
- }
- break;
+ } break;
case ghdl_rtik_type_array:
{
struct ghw_type_array *a = &t->ar;
@@ -2217,8 +2208,7 @@ ghw_disp_type (struct ghw_handler *h, union ghw_type *t)
printf ("subtype %s is ", c->name);
ghw_disp_subtype_definition (h, t);
printf (";\n");
- }
- break;
+ } break;
default:
printf ("ghw_disp_type: unhandled type kind %d\n", t->kind);
}
diff --git a/ghw/ghwlib.h b/ghw/ghwlib.h
index a51b0c797..3efa65721 100644
--- a/ghw/ghwlib.h
+++ b/ghw/ghwlib.h
@@ -15,7 +15,6 @@
along with this program. If not, see <gnu.org/licenses>.
*/
-
#ifndef _GHWLIB_H_
#define _GHWLIB_H_
@@ -31,20 +30,21 @@
in stdint.h. Header inttypes.h includes stdint.h and provides macro for
printf and co specifiers. Use it if known to be available. */
-#if defined(__cplusplus) \
- || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \
- || defined(HAVE_INTTYPES_H)
+#if defined(__cplusplus) || \
+ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
+ defined(HAVE_INTTYPES_H)
/* Use C99 standard header. */
-# include <inttypes.h>
-# define GHWPRI64 "%"PRId64
-# define GHWPRI32 "%"PRId32
+#include <inttypes.h>
+#define GHWPRI64 "%" PRId64
+#define GHWPRI32 "%" PRId32
#else
-# include <stdint.h>
-# define GHWPRI64 "%lld"
-# define GHWPRI32 "%d"
+#include <stdint.h>
+#define GHWPRI64 "%lld"
+#define GHWPRI32 "%d"
#endif
-enum ghdl_rtik {
+enum ghdl_rtik
+{
ghdl_rtik_top, /* 0 */
ghdl_rtik_library,
ghdl_rtik_package,
@@ -81,12 +81,12 @@ enum ghdl_rtik {
ghdl_rtik_type_file,
ghdl_rtik_subtype_scalar,
ghdl_rtik_subtype_array, /* 35 */
- ghdl_rtik_subtype_array_ptr, /* Obsolete. */
+ ghdl_rtik_subtype_array_ptr, /* Obsolete. */
ghdl_rtik_subtype_unbounded_array,
ghdl_rtik_subtype_record,
ghdl_rtik_subtype_unbounded_record,
#if 0
- ghdl_rtik_subtype_access, /* 40 */
+ ghdl_rtik_subtype_access, /* 40 */
ghdl_rtik_type_protected,
ghdl_rtik_element,
ghdl_rtik_unit,
@@ -98,7 +98,8 @@ enum ghdl_rtik {
};
/* Well-known types. */
-enum ghw_wkt_type {
+enum ghw_wkt_type
+{
ghw_wkt_unknown,
ghw_wkt_boolean,
ghw_wkt_bit,
@@ -107,47 +108,47 @@ enum ghw_wkt_type {
struct ghw_range_b2
{
- enum ghdl_rtik kind : 8;
- int dir : 8; /* 0: to, !0: downto. */
+ enum ghdl_rtik kind:8;
+ int dir:8; /* 0: to, !0: downto. */
unsigned char left;
unsigned char right;
};
struct ghw_range_e8
{
- enum ghdl_rtik kind : 8;
- int dir : 8; /* 0: to, !0: downto. */
+ enum ghdl_rtik kind:8;
+ int dir:8; /* 0: to, !0: downto. */
unsigned char left;
unsigned char right;
};
struct ghw_range_i32
{
- enum ghdl_rtik kind : 8;
- int dir : 8; /* 0: to, !0: downto. */
+ enum ghdl_rtik kind:8;
+ int dir:8; /* 0: to, !0: downto. */
int32_t left;
int32_t right;
};
struct ghw_range_i64
{
- enum ghdl_rtik kind : 8;
- int dir : 8;
+ enum ghdl_rtik kind:8;
+ int dir:8;
int64_t left;
int64_t right;
};
struct ghw_range_f64
{
- enum ghdl_rtik kind : 8;
- int dir : 8;
+ enum ghdl_rtik kind:8;
+ int dir:8;
double left;
double right;
};
union ghw_range
{
- enum ghdl_rtik kind : 8;
+ enum ghdl_rtik kind:8;
struct ghw_range_b2 b2;
struct ghw_range_e8 e8;
struct ghw_range_i32 i32;
@@ -244,7 +245,7 @@ struct ghw_type_record
const char *name;
unsigned int nbr_fields;
- int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */
+ int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */
struct ghw_record_element *els;
};
@@ -254,7 +255,7 @@ struct ghw_subtype_record
const char *name;
struct ghw_type_record *base;
- int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */
+ int nbr_scalars; /* Number of scalar elements (ie nbr of signals). */
struct ghw_record_element *els;
};
@@ -298,22 +299,23 @@ struct ghw_sig
union ghw_val *val;
};
-enum ghw_hie_kind {
- ghw_hie_eoh = 0,
- ghw_hie_design = 1,
- ghw_hie_block = 3,
- ghw_hie_generate_if = 4,
+enum ghw_hie_kind
+{
+ ghw_hie_eoh = 0,
+ ghw_hie_design = 1,
+ ghw_hie_block = 3,
+ ghw_hie_generate_if = 4,
ghw_hie_generate_for = 5,
- ghw_hie_instance = 6,
- ghw_hie_package = 7,
- ghw_hie_process = 13,
- ghw_hie_generic = 14,
- ghw_hie_eos = 15,
- ghw_hie_signal = 16,
- ghw_hie_port_in = 17,
- ghw_hie_port_out = 18,
- ghw_hie_port_inout = 19,
- ghw_hie_port_buffer = 20,
+ ghw_hie_instance = 6,
+ ghw_hie_package = 7,
+ ghw_hie_process = 13,
+ ghw_hie_generic = 14,
+ ghw_hie_eos = 15,
+ ghw_hie_signal = 16,
+ ghw_hie_port_in = 17,
+ ghw_hie_port_out = 18,
+ ghw_hie_port_inout = 19,
+ ghw_hie_port_buffer = 20,
ghw_hie_port_linkage = 21
};
@@ -337,7 +339,7 @@ struct ghw_hie
{
union ghw_type *type;
/* Array of signal elements.
- Last element is GHW_NO_SIG (0). */
+ Last element is GHW_NO_SIG (0). */
unsigned int *sigs;
} sig;
} u;
@@ -397,8 +399,8 @@ int ghw_get_range_length (union ghw_range *rng);
/* Put the ASCII representation of VAL into BUF, whose size if LEN.
A NUL is always written to BUF. */
-void ghw_get_value (char *buf, int len,
- union ghw_val *val, union ghw_type *type);
+void ghw_get_value (char *buf, int len, union ghw_val *val,
+ union ghw_type *type);
const char *ghw_get_hie_name (struct ghw_hie *h);
@@ -406,7 +408,8 @@ void ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top);
int ghw_read_base (struct ghw_handler *h);
-void ghw_filter_signals (struct ghw_handler *h, int *signals_to_keep, int nb_signals_to_keep);
+void ghw_filter_signals (struct ghw_handler *h, int *signals_to_keep,
+ int nb_signals_to_keep);
void ghw_disp_values (struct ghw_handler *h);
@@ -418,7 +421,8 @@ int ghw_read_cycle_next (struct ghw_handler *h);
int ghw_read_cycle_end (struct ghw_handler *h);
-enum ghw_sm_type {
+enum ghw_sm_type
+{
/* At init;
Read section name. */
ghw_sm_init = 0,
@@ -426,7 +430,8 @@ enum ghw_sm_type {
ghw_sm_cycle = 2
};
-enum ghw_res {
+enum ghw_res
+{
ghw_res_error = -1,
ghw_res_eof = -2,
ghw_res_ok = 0,
@@ -441,9 +446,10 @@ int ghw_read_sm (struct ghw_handler *h, enum ghw_sm_type *sm);
int ghw_read_dump (struct ghw_handler *h);
-struct ghw_section {
+struct ghw_section
+{
const char name[4];
- int (*handler)(struct ghw_handler *h);
+ int (*handler) (struct ghw_handler * h);
};
extern struct ghw_section ghw_sections[];