[2/6] vfprintf: Introduce JUMP_TABLE_BASE_LABEL
diff mbox

Message ID ee12c20c28ddae424436689329d4dd79a4fdc81a.1425246936.git.fweimer@redhat.com
State New
Headers show

Commit Message

Florian Weimer March 1, 2015, 8:47 p.m. UTC
This makes the offset handling more explicit and avoids
cross-references between the jump tables.
---
 stdio-common/vfprintf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Andreas Schwab March 1, 2015, 10:36 p.m. UTC | #1
Florian Weimer <fweimer@redhat.com> writes:

> @@ -1897,7 +1898,9 @@ do_positional:
>        {
>  #undef REF
>  #ifdef SHARED
> -# define REF(Name) &&do2_##Name - &&do_form_unknown
> +# undef JUMP_TABLE_BASE_LABEL
> +# define JUMP_TABLE_BASE_LABEL do2_form_unknown

Where do you define that label?

Andreas.
Florian Weimer March 1, 2015, 10:41 p.m. UTC | #2
On 03/01/2015 11:36 PM, Andreas Schwab wrote:
> Florian Weimer <fweimer@redhat.com> writes:
> 
>> @@ -1897,7 +1898,9 @@ do_positional:
>>        {
>>  #undef REF
>>  #ifdef SHARED
>> -# define REF(Name) &&do2_##Name - &&do_form_unknown
>> +# undef JUMP_TABLE_BASE_LABEL
>> +# define JUMP_TABLE_BASE_LABEL do2_form_unknown
> 
> Where do you define that label?

Its name is generated with the LABEL macro:

#define LABEL(Name) do2_##Name

and eventually defined by the STEP4_TABLE macro.
Paul Eggert March 3, 2015, 2 a.m. UTC | #3
Florian Weimer wrote:
> +# define REF(Name) &&do_##Name - &&JUMP_TABLE_BASE_LABEL
...
> +# define REF(Name) &&do2_##Name - &&JUMP_TABLE_BASE_LABEL

The definientia should be parenthesized.
Florian Weimer March 6, 2015, 10:36 a.m. UTC | #4
On 03/03/2015 03:00 AM, Paul Eggert wrote:
> Florian Weimer wrote:
>> +# define REF(Name) &&do_##Name - &&JUMP_TABLE_BASE_LABEL
> ...
>> +# define REF(Name) &&do2_##Name - &&JUMP_TABLE_BASE_LABEL
> 
> The definientia should be parenthesized.

Committed with this change.

Patch
diff mbox

diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index d575994..16e70b8 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -304,7 +304,7 @@  vfprintf (FILE *s, const CHAR_T *format, va_list ap)
 	  spec = (ChExpr);						      \
 	  offset = NOT_IN_JUMP_RANGE (spec) ? REF (form_unknown)	      \
 	    : table[CHAR_CLASS (spec)];					      \
-	  ptr = &&do_form_unknown + offset;				      \
+	  ptr = &&JUMP_TABLE_BASE_LABEL + offset;			      \
 	  goto *ptr;							      \
 	}								      \
       while (0)
@@ -1329,7 +1329,8 @@  vfprintf (FILE *s, const CHAR_T *format, va_list ap)
   do
     {
 #ifdef SHARED
-# define REF(Name) &&do_##Name - &&do_form_unknown
+# define JUMP_TABLE_BASE_LABEL do_form_unknown
+# define REF(Name) &&do_##Name - &&JUMP_TABLE_BASE_LABEL
 #else
 # define REF(Name) &&do_##Name
 #endif
@@ -1897,7 +1898,9 @@  do_positional:
       {
 #undef REF
 #ifdef SHARED
-# define REF(Name) &&do2_##Name - &&do_form_unknown
+# undef JUMP_TABLE_BASE_LABEL
+# define JUMP_TABLE_BASE_LABEL do2_form_unknown
+# define REF(Name) &&do2_##Name - &&JUMP_TABLE_BASE_LABEL
 #else
 # define REF(Name) &&do2_##Name
 #endif