From 797eb0e8666db36b75666d0b6a6d5a108c68b730 Mon Sep 17 00:00:00 2001 From: John Millaway Date: Wed, 27 Nov 2002 14:43:24 +0000 Subject: [PATCH] Changed int types to flex_intX_t. The build is now broken until typedef's are established. --- dfa.c | 16 +++---- flexint.h | 6 +++ gen.c | 90 ++++++++++++++++++++-------------------- tables.c | 108 ++++++++++++++++++++++++------------------------ tables.h | 2 +- tables_shared.c | 4 +- tables_shared.h | 30 +++++++------- 7 files changed, 131 insertions(+), 125 deletions(-) diff --git a/dfa.c b/dfa.c index 238905c..1cb038f 100644 --- a/dfa.c +++ b/dfa.c @@ -390,7 +390,7 @@ void ntod () int todo_head, todo_next; struct yytbl_data *yynxt_tbl = 0; - int32_t *yynxt_data = 0, yynxt_curr = 0; + flex_int32_t *yynxt_data = 0, yynxt_curr = 0; /* Note that the following are indexed by *equivalence classes* * and not by characters. Since equivalence classes are indexed @@ -529,14 +529,14 @@ void ntod () yynxt_tbl->td_hilen = 1; yynxt_tbl->td_lolen = num_full_table_rows; yynxt_tbl->td_data = yynxt_data = - (int32_t *) calloc (yynxt_tbl->td_lolen * + (flex_int32_t *) calloc (yynxt_tbl->td_lolen * yynxt_tbl->td_hilen, - sizeof (int32_t)); + sizeof (flex_int32_t)); yynxt_curr = 0; buf_prints (&yydmap_buf, "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", - long_align ? "int32_t" : "int16_t"); + long_align ? "flex_int32_t" : "flex_int16_t"); /* Unless -Ca, declare it "short" because it's a real * long-shot that that won't be large enough. @@ -544,12 +544,12 @@ void ntod () if (gentables) out_str_dec ("static yyconst %s yy_nxt[][%d] =\n {\n", - long_align ? "int32_t" : "int16_t", + long_align ? "flex_int32_t" : "flex_int16_t", num_full_table_rows); else { out_dec ("#undef YY_NXT_LOLEN\n#define YY_NXT_LOLEN (%d)\n", num_full_table_rows); out_str ("static yyconst %s *yy_nxt =0;\n", - long_align ? "int32_t" : "int16_t"); + long_align ? "flex_int32_t" : "flex_int16_t"); } @@ -728,10 +728,10 @@ void ntod () /* Each time we hit here, it's another td_hilen, so we realloc. */ yynxt_tbl->td_hilen++; yynxt_tbl->td_data = yynxt_data = - (int32_t *) realloc (yynxt_data, + (flex_int32_t *) realloc (yynxt_data, yynxt_tbl->td_hilen * yynxt_tbl->td_lolen * - sizeof (int32_t)); + sizeof (flex_int32_t)); if (gentables) diff --git a/flexint.h b/flexint.h index 6a4c83e..5ce1f95 100644 --- a/flexint.h +++ b/flexint.h @@ -13,6 +13,12 @@ that your header files and such are happy. */ #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L #include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; #endif #ifndef FLEX_NEED_INTEGRAL_TYPE_DEFINITIONS #include diff --git a/gen.c b/gen.c index 770e17b..796bbfc 100644 --- a/gen.c +++ b/gen.c @@ -58,16 +58,16 @@ static int indent_level = 0; /* each level is 8 spaces */ static const char *get_int16_decl (void) { return (gentables) - ? "static yyconst int16_t %s[%d] =\n { 0,\n" - : "static yyconst int16_t * %s = 0;\n"; + ? "static yyconst flex_int16_t %s[%d] =\n { 0,\n" + : "static yyconst flex_int16_t * %s = 0;\n"; } static const char *get_int32_decl (void) { return (gentables) - ? "static yyconst int32_t %s[%d] =\n { 0,\n" - : "static yyconst int32_t * %s = 0;\n"; + ? "static yyconst flex_int32_t %s[%d] =\n { 0,\n" + : "static yyconst flex_int32_t * %s = 0;\n"; } static const char *get_state_decl (void) @@ -101,7 +101,7 @@ void do_indent () static struct yytbl_data *mkeoltbl (void) { int i; - int8_t *tdata = 0; + flex_int8_t *tdata = 0; struct yytbl_data *tbl; tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data)); @@ -109,14 +109,14 @@ static struct yytbl_data *mkeoltbl (void) tbl->td_flags = YYTD_DATA8; tbl->td_lolen = num_rules + 1; tbl->td_data = tdata = - (int8_t *) calloc (tbl->td_lolen, sizeof (int8_t)); + (flex_int8_t *) calloc (tbl->td_lolen, sizeof (flex_int8_t)); for (i = 1; i <= num_rules; i++) tdata[i] = rule_has_nl[i] ? 1 : 0; buf_prints (&yydmap_buf, "\t{YYTD_ID_RULE_CAN_MATCH_EOL, (void**)&yy_rule_can_match_eol, sizeof(%s)},\n", - "int32_t"); + "flex_int32_t"); return tbl; } @@ -203,13 +203,13 @@ static struct yytbl_data *mkctbl (void) { register int i; struct yytbl_data *tbl = 0; - int32_t *tdata = 0, curr = 0; + flex_int32_t *tdata = 0, curr = 0; int end_of_buffer_action = num_rules + 1; buf_prints (&yydmap_buf, "\t{YYTD_ID_TRANSITION, (void**)&yy_transition, sizeof(%s)},\n", ((tblend + numecs + 1) >= INT16_MAX - || long_align) ? "int32_t" : "int16_t"); + || long_align) ? "flex_int32_t" : "flex_int16_t"); tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (tbl, YYTD_ID_TRANSITION); @@ -218,7 +218,7 @@ static struct yytbl_data *mkctbl (void) tbl->td_lolen = tblend + numecs + 1; /* number of structs */ tbl->td_data = tdata = - (int32_t *) calloc (tbl->td_lolen * 2, sizeof (int32_t)); + (flex_int32_t *) calloc (tbl->td_lolen * 2, sizeof (flex_int32_t)); /* We want the transition to be represented as the offset to the * next state, not the actual state number, which is what it currently @@ -304,8 +304,8 @@ static struct yytbl_data *mkctbl (void) static struct yytbl_data *mkssltbl (void) { struct yytbl_data *tbl = 0; - int32_t *tdata = 0; - int32_t i; + flex_int32_t *tdata = 0; + flex_int32_t i; tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (tbl, YYTD_ID_START_STATE_LIST); @@ -314,7 +314,7 @@ static struct yytbl_data *mkssltbl (void) tbl->td_lolen = lastsc * 2 + 1; tbl->td_data = tdata = - (int32_t *) calloc (tbl->td_lolen, sizeof (int32_t)); + (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t)); for (i = 0; i <= lastsc * 2; ++i) tdata[i] = base[i]; @@ -435,7 +435,7 @@ struct yytbl_data *mkecstbl (void) { register int i; struct yytbl_data *tbl = 0; - int32_t *tdata = 0; + flex_int32_t *tdata = 0; tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (tbl, YYTD_ID_EC); @@ -444,7 +444,7 @@ struct yytbl_data *mkecstbl (void) tbl->td_lolen = csize; tbl->td_data = tdata = - (int32_t *) calloc (tbl->td_lolen, sizeof (int32_t)); + (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t)); for (i = 1; i < csize; ++i) { if (caseins && isupper (i)) @@ -456,7 +456,7 @@ struct yytbl_data *mkecstbl (void) buf_prints (&yydmap_buf, "\t{YYTD_ID_EC, (void**)&yy_ec, sizeof(%s)},\n", - "int32_t"); + "flex_int32_t"); return tbl; } @@ -646,7 +646,7 @@ struct yytbl_data *mkftbl (void) register int i; int end_of_buffer_action = num_rules + 1; struct yytbl_data *tbl; - int32_t *tdata = 0; + flex_int32_t *tdata = 0; tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (tbl, YYTD_ID_ACCEPT); @@ -655,7 +655,7 @@ struct yytbl_data *mkftbl (void) tbl->td_lolen = lastdfa + 1; tbl->td_data = tdata = - (int32_t *) calloc (tbl->td_lolen, sizeof (int32_t)); + (flex_int32_t *) calloc (tbl->td_lolen, sizeof (flex_int32_t)); dfaacc[end_of_buffer_state].dfaacc_state = end_of_buffer_action; @@ -671,7 +671,7 @@ struct yytbl_data *mkftbl (void) buf_prints (&yydmap_buf, "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "int32_t" : "int16_t"); + long_align ? "flex_int32_t" : "flex_int16_t"); return tbl; } @@ -1057,9 +1057,9 @@ void gentabs () int end_of_buffer_action = num_rules + 1; struct yytbl_data *yyacc_tbl = 0, *yymeta_tbl = 0, *yybase_tbl = 0, *yydef_tbl = 0, *yynxt_tbl = 0, *yychk_tbl = 0, *yyacclist_tbl=0; - int32_t *yyacc_data = 0, *yybase_data = 0, *yydef_data = 0, + flex_int32_t *yyacc_data = 0, *yybase_data = 0, *yydef_data = 0, *yynxt_data = 0, *yychk_data = 0, *yyacclist_data=0; - int32_t yybase_curr = 0, yyacclist_curr=0,yyacc_curr=0; + flex_int32_t yybase_curr = 0, yyacclist_curr=0,yyacc_curr=0; acc_array = allocate_integer_array (current_max_dfas); nummt = 0; @@ -1093,13 +1093,13 @@ void gentabs () buf_prints (&yydmap_buf, "\t{YYTD_ID_ACCLIST, (void**)&yy_acclist, sizeof(%s)},\n", - long_align ? "int32_t" : "int16_t"); + long_align ? "flex_int32_t" : "flex_int16_t"); yyacclist_tbl = (struct yytbl_data*)calloc(1,sizeof(struct yytbl_data)); yytbl_data_init (yyacclist_tbl, YYTD_ID_ACCLIST); yyacclist_tbl->td_lolen = MAX(numas,1) + 1; yyacclist_tbl->td_data = yyacclist_data = - (int32_t *) calloc (yyacclist_tbl->td_lolen, sizeof (int32_t)); + (flex_int32_t *) calloc (yyacclist_tbl->td_lolen, sizeof (flex_int32_t)); yyacclist_curr = 1; j = 1; /* index into "yy_acclist" array */ @@ -1202,7 +1202,7 @@ void gentabs () buf_prints (&yydmap_buf, "\t{YYTD_ID_ACCEPT, (void**)&yy_accept, sizeof(%s)},\n", - long_align ? "int32_t" : "int16_t"); + long_align ? "flex_int32_t" : "flex_int16_t"); yyacc_tbl = (struct yytbl_data *) calloc (1, @@ -1210,7 +1210,7 @@ void gentabs () yytbl_data_init (yyacc_tbl, YYTD_ID_ACCEPT); yyacc_tbl->td_lolen = k; yyacc_tbl->td_data = yyacc_data = - (int32_t *) calloc (yyacc_tbl->td_lolen, sizeof (int32_t)); + (flex_int32_t *) calloc (yyacc_tbl->td_lolen, sizeof (flex_int32_t)); yyacc_curr=1; for (i = 1; i <= lastdfa; ++i) { @@ -1262,7 +1262,7 @@ void gentabs () /* Write out meta-equivalence classes (used to index * templates with). */ - int32_t *yymecs_data = 0; + flex_int32_t *yymecs_data = 0; yymeta_tbl = (struct yytbl_data *) calloc (1, sizeof (struct @@ -1270,8 +1270,8 @@ void gentabs () yytbl_data_init (yymeta_tbl, YYTD_ID_META); yymeta_tbl->td_lolen = numecs + 1; yymeta_tbl->td_data = yymecs_data = - (int32_t *) calloc (yymeta_tbl->td_lolen, - sizeof (int32_t)); + (flex_int32_t *) calloc (yymeta_tbl->td_lolen, + sizeof (flex_int32_t)); if (trace) fputs (_("\n\nMeta-Equivalence Classes:\n"), @@ -1280,7 +1280,7 @@ void gentabs () out_str_dec (get_int32_decl (), "yy_meta", numecs + 1); buf_prints (&yydmap_buf, "\t{YYTD_ID_META, (void**)&yy_meta, sizeof(%s)},\n", - "int32_t"); + "flex_int32_t"); for (i = 1; i <= numecs; ++i) { if (trace) @@ -1313,15 +1313,15 @@ void gentabs () buf_prints (&yydmap_buf, "\t{YYTD_ID_BASE, (void**)&yy_base, sizeof(%s)},\n", (tblend >= INT16_MAX - || long_align) ? "int32_t" : "int16_t"); + || long_align) ? "flex_int32_t" : "flex_int16_t"); yybase_tbl = (struct yytbl_data *) calloc (1, sizeof (struct yytbl_data)); yytbl_data_init (yybase_tbl, YYTD_ID_BASE); yybase_tbl->td_lolen = total_states + 1; yybase_tbl->td_data = yybase_data = - (int32_t *) calloc (yybase_tbl->td_lolen, - sizeof (int32_t)); + (flex_int32_t *) calloc (yybase_tbl->td_lolen, + sizeof (flex_int32_t)); yybase_curr = 1; for (i = 1; i <= lastdfa; ++i) { @@ -1372,7 +1372,7 @@ void gentabs () buf_prints (&yydmap_buf, "\t{YYTD_ID_DEF, (void**)&yy_def, sizeof(%s)},\n", (total_states >= INT16_MAX - || long_align) ? "int32_t" : "int16_t"); + || long_align) ? "flex_int32_t" : "flex_int16_t"); yydef_tbl = (struct yytbl_data *) calloc (1, @@ -1380,7 +1380,7 @@ void gentabs () yytbl_data_init (yydef_tbl, YYTD_ID_DEF); yydef_tbl->td_lolen = total_states + 1; yydef_tbl->td_data = yydef_data = - (int32_t *) calloc (yydef_tbl->td_lolen, sizeof (int32_t)); + (flex_int32_t *) calloc (yydef_tbl->td_lolen, sizeof (flex_int32_t)); for (i = 1; i <= total_states; ++i) { mkdata (def[i]); @@ -1406,7 +1406,7 @@ void gentabs () buf_prints (&yydmap_buf, "\t{YYTD_ID_NXT, (void**)&yy_nxt, sizeof(%s)},\n", (total_states >= INT16_MAX - || long_align) ? "int32_t" : "int16_t"); + || long_align) ? "flex_int32_t" : "flex_int16_t"); yynxt_tbl = (struct yytbl_data *) calloc (1, @@ -1414,7 +1414,7 @@ void gentabs () yytbl_data_init (yynxt_tbl, YYTD_ID_NXT); yynxt_tbl->td_lolen = tblend + 1; yynxt_tbl->td_data = yynxt_data = - (int32_t *) calloc (yynxt_tbl->td_lolen, sizeof (int32_t)); + (flex_int32_t *) calloc (yynxt_tbl->td_lolen, sizeof (flex_int32_t)); for (i = 1; i <= tblend; ++i) { /* Note, the order of the following test is important. @@ -1445,7 +1445,7 @@ void gentabs () buf_prints (&yydmap_buf, "\t{YYTD_ID_CHK, (void**)&yy_chk, sizeof(%s)},\n", (total_states >= INT16_MAX - || long_align) ? "int32_t" : "int16_t"); + || long_align) ? "flex_int32_t" : "flex_int16_t"); yychk_tbl = (struct yytbl_data *) calloc (1, @@ -1453,7 +1453,7 @@ void gentabs () yytbl_data_init (yychk_tbl, YYTD_ID_CHK); yychk_tbl->td_lolen = tblend + 1; yychk_tbl->td_data = yychk_data = - (int32_t *) calloc (yychk_tbl->td_lolen, sizeof (int32_t)); + (flex_int32_t *) calloc (yychk_tbl->td_lolen, sizeof (flex_int32_t)); for (i = 1; i <= tblend; ++i) { if (chk[i] == 0) @@ -1573,7 +1573,7 @@ void make_tables () int total_table_size = tblend + numecs + 1; char *trans_offset_type = (total_table_size >= INT16_MAX || long_align) ? - "int32_t" : "int16_t"; + "flex_int32_t" : "flex_int16_t"; set_indent (0); indent_puts ("struct yy_trans_info"); @@ -1607,8 +1607,8 @@ void make_tables () indent_puts ("struct yy_trans_info"); indent_up (); indent_puts ("{"); - indent_puts ("int32_t yy_verify;"); - indent_puts ("int32_t yy_nxt;"); + indent_puts ("flex_int32_t yy_verify;"); + indent_puts ("flex_int32_t yy_nxt;"); indent_puts ("};"); indent_down (); } @@ -1698,7 +1698,7 @@ void make_tables () } if (nultrans) { - int32_t *yynultrans_data = 0; + flex_int32_t *yynultrans_data = 0; /* Begin generating yy_NUL_trans */ out_str_dec (get_state_decl (), "yy_NUL_trans", @@ -1706,7 +1706,7 @@ void make_tables () buf_prints (&yydmap_buf, "\t{YYTD_ID_NUL_TRANS, (void**)&yy_NUL_trans, sizeof(%s)},\n", (fullspd) ? "struct yy_trans_info*" : - "int32_t"); + "flex_int32_t"); yynultrans_tbl = (struct yytbl_data *) calloc (1, @@ -1717,8 +1717,8 @@ void make_tables () yynultrans_tbl->td_flags |= YYTD_PTRANS; yynultrans_tbl->td_lolen = lastdfa + 1; yynultrans_tbl->td_data = yynultrans_data = - (int32_t *) calloc (yynultrans_tbl->td_lolen, - sizeof (int32_t)); + (flex_int32_t *) calloc (yynultrans_tbl->td_lolen, + sizeof (flex_int32_t)); for (i = 1; i <= lastdfa; ++i) { if (fullspd) { diff --git a/tables.c b/tables.c index de1480f..ddfd78e 100644 --- a/tables.c +++ b/tables.c @@ -41,9 +41,9 @@ * @return YYTD_DATA*. */ #define BYTES2TFLAG(n)\ - (((n) == sizeof(int8_t))\ + (((n) == sizeof(flex_int8_t))\ ? YYTD_DATA8\ - :(((n)== sizeof(int16_t))\ + :(((n)== sizeof(flex_int16_t))\ ? YYTD_DATA16\ : YYTD_DATA32)) @@ -52,12 +52,12 @@ */ #define TFLAGS_CLRDATA(flg) ((flg) & ~(YYTD_DATA8 | YYTD_DATA16 | YYTD_DATA32)) -int yytbl_write32 (struct yytbl_writer *wr, uint32_t v); -int yytbl_write16 (struct yytbl_writer *wr, uint16_t v); -int yytbl_write8 (struct yytbl_writer *wr, uint8_t v); -int yytbl_writen (struct yytbl_writer *wr, void *v, int32_t len); -static int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i); -static int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i, +int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v); +int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v); +int yytbl_write8 (struct yytbl_writer *wr, flex_uint8_t v); +int yytbl_writen (struct yytbl_writer *wr, void *v, flex_int32_t len); +static flex_int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i); +static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i, int j, int k); @@ -188,8 +188,8 @@ int yytbl_hdr_fwrite (struct yytbl_writer *wr, const struct yytbl_hdr *th) int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td) { size_t rv; - int32_t bwritten = 0; - int32_t i, total_len; + flex_int32_t bwritten = 0; + flex_int32_t i, total_len; fpos_t pos; if ((rv = yytbl_write16 (wr, td->td_id)) < 0) @@ -211,13 +211,13 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td) total_len = yytbl_calc_total_len (td); for (i = 0; i < total_len; i++) { switch (YYTDFLAGS2BYTES (td->td_flags)) { - case sizeof (int8_t): + case sizeof (flex_int8_t): rv = yytbl_write8 (wr, yytbl_data_geti (td, i)); break; - case sizeof (int16_t): + case sizeof (flex_int16_t): rv = yytbl_write16 (wr, yytbl_data_geti (td, i)); break; - case sizeof (int32_t): + case sizeof (flex_int32_t): rv = yytbl_write32 (wr, yytbl_data_geti (td, i)); break; default: @@ -253,7 +253,7 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td) } else /* Don't count the int we just wrote. */ - wr->total_written -= sizeof (int32_t); + wr->total_written -= sizeof (flex_int32_t); return bwritten; } @@ -263,7 +263,7 @@ int yytbl_data_fwrite (struct yytbl_writer *wr, struct yytbl_data *td) * @param len number of bytes * @return -1 on error. number of bytes written on success. */ -int yytbl_writen (struct yytbl_writer *wr, void *v, int32_t len) +int yytbl_writen (struct yytbl_writer *wr, void *v, flex_int32_t len) { size_t rv; @@ -279,13 +279,13 @@ int yytbl_writen (struct yytbl_writer *wr, void *v, int32_t len) * @param v a dword in host byte order * @return -1 on error. number of bytes written on success. */ -int yytbl_write32 (struct yytbl_writer *wr, uint32_t v) +int yytbl_write32 (struct yytbl_writer *wr, flex_uint32_t v) { - uint32_t vnet; + flex_uint32_t vnet; size_t bytes, rv; vnet = htonl (v); - bytes = sizeof (uint32_t); + bytes = sizeof (flex_uint32_t); rv = fwrite (&vnet, bytes, 1, wr->out); if (rv != 1) return -1; @@ -298,13 +298,13 @@ int yytbl_write32 (struct yytbl_writer *wr, uint32_t v) * @param v a word in host byte order * @return -1 on error. number of bytes written on success. */ -int yytbl_write16 (struct yytbl_writer *wr, uint16_t v) +int yytbl_write16 (struct yytbl_writer *wr, flex_uint16_t v) { - uint16_t vnet; + flex_uint16_t vnet; size_t bytes, rv; vnet = htons (v); - bytes = sizeof (uint16_t); + bytes = sizeof (flex_uint16_t); rv = fwrite (&vnet, bytes, 1, wr->out); if (rv != 1) return -1; @@ -317,11 +317,11 @@ int yytbl_write16 (struct yytbl_writer *wr, uint16_t v) * @param v the value to be written * @return -1 on error. number of bytes written on success. */ -int yytbl_write8 (struct yytbl_writer *wr, uint8_t v) +int yytbl_write8 (struct yytbl_writer *wr, flex_uint8_t v) { size_t bytes, rv; - bytes = sizeof (uint8_t); + bytes = sizeof (flex_uint8_t); rv = fwrite (&v, bytes, 1, wr->out); if (rv != 1) return -1; @@ -337,24 +337,24 @@ int yytbl_write8 (struct yytbl_writer *wr, uint8_t v) * @param k index into struct, must be 0 or 1. Only valid for YYTD_ID_TRANSITION table * @return data[i][j + k] */ -static int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i, +static flex_int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i, int j, int k) { - int32_t lo; + flex_int32_t lo; k %= 2; lo = tbl->td_lolen; switch (YYTDFLAGS2BYTES (tbl->td_flags)) { - case sizeof (int8_t): - return ((int8_t *) (tbl->td_data))[(i * lo + j) * (k + 1) + + case sizeof (flex_int8_t): + return ((flex_int8_t *) (tbl->td_data))[(i * lo + j) * (k + 1) + k]; - case sizeof (int16_t): - return ((int16_t *) (tbl->td_data))[(i * lo + j) * (k + + case sizeof (flex_int16_t): + return ((flex_int16_t *) (tbl->td_data))[(i * lo + j) * (k + 1) + k]; - case sizeof (int32_t): - return ((int32_t *) (tbl->td_data))[(i * lo + j) * (k + + case sizeof (flex_int32_t): + return ((flex_int32_t *) (tbl->td_data))[(i * lo + j) * (k + 1) + k]; default: @@ -372,16 +372,16 @@ static int32_t yytbl_data_getijk (const struct yytbl_data *tbl, int i, * @param i index into array. * @return data[i] */ -static int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i) +static flex_int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i) { switch (YYTDFLAGS2BYTES (tbl->td_flags)) { - case sizeof (int8_t): - return ((int8_t *) (tbl->td_data))[i]; - case sizeof (int16_t): - return ((int16_t *) (tbl->td_data))[i]; - case sizeof (int32_t): - return ((int32_t *) (tbl->td_data))[i]; + case sizeof (flex_int8_t): + return ((flex_int8_t *) (tbl->td_data))[i]; + case sizeof (flex_int16_t): + return ((flex_int16_t *) (tbl->td_data))[i]; + case sizeof (flex_int32_t): + return ((flex_int32_t *) (tbl->td_data))[i]; default: flex_die (_("invalid td_flags detected")); break; @@ -397,18 +397,18 @@ static int32_t yytbl_data_geti (const struct yytbl_data *tbl, int i) * @param newval new value for data[i] */ static void yytbl_data_seti (const struct yytbl_data *tbl, int i, - int32_t newval) + flex_int32_t newval) { switch (YYTDFLAGS2BYTES (tbl->td_flags)) { - case sizeof (int8_t): - ((int8_t *) (tbl->td_data))[i] = (int8_t) newval; + case sizeof (flex_int8_t): + ((flex_int8_t *) (tbl->td_data))[i] = (flex_int8_t) newval; break; - case sizeof (int16_t): - ((int16_t *) (tbl->td_data))[i] = (int16_t) newval; + case sizeof (flex_int16_t): + ((flex_int16_t *) (tbl->td_data))[i] = (flex_int16_t) newval; break; - case sizeof (int32_t): - ((int32_t *) (tbl->td_data))[i] = (int32_t) newval; + case sizeof (flex_int32_t): + ((flex_int32_t *) (tbl->td_data))[i] = (flex_int32_t) newval; break; default: flex_die (_("invalid td_flags detected")); @@ -419,17 +419,17 @@ static void yytbl_data_seti (const struct yytbl_data *tbl, int i, /** Calculate the number of bytes needed to hold the largest * absolute value in this data array. * @param tbl the data table - * @return sizeof(n) where n in {int8_t, int16_t, int32_t} + * @return sizeof(n) where n in {flex_int8_t, flex_int16_t, flex_int32_t} */ static size_t min_int_size (struct yytbl_data *tbl) { - uint32_t i, total_len; - int32_t max = 0; + flex_uint32_t i, total_len; + flex_int32_t max = 0; total_len = yytbl_calc_total_len (tbl); for (i = 0; i < total_len; i++) { - int32_t n; + flex_int32_t n; n = abs (yytbl_data_geti (tbl, i)); @@ -438,11 +438,11 @@ static size_t min_int_size (struct yytbl_data *tbl) } if (max <= INT8_MAX) - return sizeof (int8_t); + return sizeof (flex_int8_t); else if (max <= INT16_MAX) - return sizeof (int16_t); + return sizeof (flex_int16_t); else - return sizeof (int32_t); + return sizeof (flex_int32_t); } /** Transform data to smallest possible of (int32, int16, int8). @@ -456,7 +456,7 @@ static size_t min_int_size (struct yytbl_data *tbl) */ void yytbl_data_compress (struct yytbl_data *tbl) { - int32_t i, newsz, total_len; + flex_int32_t i, newsz, total_len; struct yytbl_data newtbl; yytbl_data_init (&newtbl, tbl->td_id); @@ -482,7 +482,7 @@ void yytbl_data_compress (struct yytbl_data *tbl) TFLAGS_CLRDATA (newtbl.td_flags) | BYTES2TFLAG (newsz); for (i = 0; i < total_len; i++) { - int32_t g; + flex_int32_t g; g = yytbl_data_geti (tbl, i); yytbl_data_seti (&newtbl, i, g); diff --git a/tables.h b/tables.h index 79f4194..2e4afe5 100644 --- a/tables.h +++ b/tables.h @@ -45,7 +45,7 @@ extern "C" { #include "tables_shared.h" struct yytbl_writer { FILE *out; - uint32_t total_written; + flex_uint32_t total_written; /**< bytes written so far */ fpos_t th_ssize_pos; /**< position of th_ssize */ diff --git a/tables_shared.c b/tables_shared.c index dcfc03b..b962666 100644 --- a/tables_shared.c +++ b/tables_shared.c @@ -55,9 +55,9 @@ dnl * @param td the table * @return the number of integers in the table */ -yyskel_static int32_t yytbl_calc_total_len (const struct yytbl_data *tbl) +yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl) { - int32_t n; + flex_int32_t n; /* total number of ints */ n = tbl->td_lolen; diff --git a/tables_shared.h b/tables_shared.h index a46c057..9676d47 100644 --- a/tables_shared.h +++ b/tables_shared.h @@ -92,9 +92,9 @@ enum yytbl_id { /** bit flags for t_flags field of struct yytbl_data */ enum yytbl_flags { /* These first three are mutually exclusive */ - YYTD_DATA8 = 0x01, /**< data is an array of type int8_t */ - YYTD_DATA16 = 0x02, /**< data is an array of type int16_t */ - YYTD_DATA32 = 0x04, /**< data is an array of type int32_t */ + YYTD_DATA8 = 0x01, /**< data is an array of type flex_int8_t */ + YYTD_DATA16 = 0x02, /**< data is an array of type flex_int16_t */ + YYTD_DATA32 = 0x04, /**< data is an array of type flex_int32_t */ /* These two are mutually exclusive. */ YYTD_PTRANS = 0x08, /**< data is a list of indexes of entries @@ -105,20 +105,20 @@ enum yytbl_flags { /* The serialized tables header. */ struct yytbl_hdr { - uint32_t th_magic; /**< Must be 0xF13C57B1 (comes from "Flex Table") */ - uint32_t th_hsize; /**< Size of this header in bytes. */ - uint32_t th_ssize; /**< Size of this dataset, in bytes, including header. */ - uint16_t th_flags; /**< Currently unused, must be 0 */ + flex_uint32_t th_magic; /**< Must be 0xF13C57B1 (comes from "Flex Table") */ + flex_uint32_t th_hsize; /**< Size of this header in bytes. */ + flex_uint32_t th_ssize; /**< Size of this dataset, in bytes, including header. */ + flex_uint16_t th_flags; /**< Currently unused, must be 0 */ char *th_version; /**< Flex version string. NUL terminated. */ char *th_name; /**< The name of this table set. NUL terminated. */ }; /** A single serialized table */ struct yytbl_data { - enum yytbl_id td_id; /**< uint16_t table identifier */ - uint16_t td_flags; /**< how to interpret this data */ - uint32_t td_hilen; /**< num elements in highest dimension array */ - uint32_t td_lolen; /**< num elements in lowest dimension array */ + enum yytbl_id td_id; /**< flex_uint16_t table identifier */ + flex_uint16_t td_flags; /**< how to interpret this data */ + flex_uint32_t td_hilen; /**< num elements in highest dimension array */ + flex_uint32_t td_lolen; /**< num elements in lowest dimension array */ void *td_data; /**< table data */ }; #endif @@ -127,16 +127,16 @@ struct yytbl_data { #ifndef YYTDFLAGS2BYTES #define YYTDFLAGS2BYTES(td_flags)\ (((td_flags) & YYTD_DATA8)\ - ? sizeof(int8_t)\ + ? sizeof(flex_int8_t)\ :(((td_flags) & YYTD_DATA16)\ - ? sizeof(int16_t)\ - :sizeof(int32_t))) + ? sizeof(flex_int16_t)\ + :sizeof(flex_int32_t))) #endif #ifdef FLEX_SCANNER %not-for-header #endif -yyskel_static int32_t yytbl_calc_total_len (const struct yytbl_data *tbl); +yyskel_static flex_int32_t yytbl_calc_total_len (const struct yytbl_data *tbl); #ifdef FLEX_SCANNER %ok-for-header #endif -- 2.40.0