]> granicus.if.org Git - flex/commitdiff
Obsolete yypad64() macro.
authorExplorer09 <explorer09@gmail.com>
Mon, 30 Oct 2017 05:29:26 +0000 (13:29 +0800)
committerWill Estes <westes575@gmail.com>
Tue, 28 Nov 2017 20:06:10 +0000 (15:06 -0500)
Slightly rewrite the logic in yytbl_data_load() and yytbl_write_pad64()
so they simply check if the bytes read/written are in 8-byte boundary.
No need to calculate how many bytes we need to pad. (Incidentally this
makes smaller code in x86_64.)

For yytbl_hdr_init(), just expand the calculation from the macro.

src/flex.skl
src/tables.c
src/tables_shared.h

index 332d3c038bc3f5e7bdc05a5ea4aae9d4d79956d6..f2da3a3048329473c1dcf67cf67861b11b495af0 100644 (file)
@@ -3300,9 +3300,7 @@ static int yytbl_data_load YYFARGS2(struct yytbl_dmap *, dmap, struct yytbl_read
 
     /* Now eat padding. */
     {
-        int pad;
-        pad = yypad64(rd->bread);
-        while(--pad >= 0){
+        while (rd->bread % (8 * sizeof(flex_uint8_t)) > 0) {
             flex_int8_t t8;
             if(yytbl_read8(&t8,rd) != 0)
                 return -1;
index 980d2e96f86e8a1a11018a832b0fa8fe50032dc0..182ab637917beeb1cec0c0e31da526b7e854cde9 100644 (file)
@@ -87,7 +87,7 @@ int yytbl_hdr_init (struct yytbl_hdr *th, const char *version_str,
 
        th->th_magic = YYTBL_MAGIC;
        th->th_hsize = (flex_uint32_t) (14 + strlen (version_str) + 1 + strlen (name) + 1);
-       th->th_hsize += yypad64 (th->th_hsize);
+       th->th_hsize += (8 - (th->th_hsize % 8)) % 8; // Pad to 64-bit boundary
        th->th_ssize = 0;       // Not known at this point.
        th->th_flags = 0;
        th->th_version = xstrdup(version_str);
@@ -124,14 +124,14 @@ int yytbl_data_destroy (struct yytbl_data *td)
 /** Write enough padding to bring the file pointer to a 64-bit boundary. */
 static int yytbl_write_pad64 (struct yytbl_writer *wr)
 {
-       int     pad, bwritten = 0;
+       int bwritten = 0;
 
-       pad = yypad64 (wr->total_written);
-       while (pad-- > 0)
+       while (wr->total_written % (8 * sizeof(flex_uint8_t)) > 0) {
                if (yytbl_write8 (wr, 0) < 0)
                        return -1;
                else
                        bwritten++;
+       }
        return bwritten;
 }
 
index bbf9910a96aa059b586a3f78d0faff499cd8ccc0..feca2518e33e808d25ad94bc024d47edf0b58ae4 100644 (file)
@@ -63,12 +63,6 @@ dnl  flex code (hence the name "_shared").
 #define YYTBL_MAGIC 0xF13C57B1
 #endif
 
-/** Calculate (0-7) = number bytes needed to pad n to next 64-bit boundary. */
-#ifndef yypad64
-#define yypad64(n) ((8-((n)%8))%8)
-#endif
-
-
 #ifndef YYTABLES_TYPES
 #define YYTABLES_TYPES
 /** Possible values for td_id field. Each one corresponds to a