[09/26] stdio-common: Add printf specifier registry to <printf.h>

Message ID ee994f649cc7ae110a0d4b97ec80e3cc1d880c3f.1647544751.git.fweimer@redhat.com
State Superseded
Headers
Series vfprintf rework to remove vtables |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Florian Weimer March 17, 2022, 7:29 p.m. UTC
  Add  __printf_function_table, __register_printf_specifier to
include/printf.h, where they belong.
---
 include/printf.h                 | 6 ++++++
 stdio-common/reg-printf.c        | 7 -------
 stdio-common/vfprintf-internal.c | 1 -
 3 files changed, 6 insertions(+), 8 deletions(-)
  

Comments

Adhemerval Zanella May 20, 2022, 5:49 p.m. UTC | #1
On 17/03/2022 16:29, Florian Weimer via Libc-alpha wrote:
> Add  __printf_function_table, __register_printf_specifier to
> include/printf.h, where they belong.
> ---
>  include/printf.h                 | 6 ++++++
>  stdio-common/reg-printf.c        | 7 -------
>  stdio-common/vfprintf-internal.c | 1 -
>  3 files changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/include/printf.h b/include/printf.h
> index 0ed6e87387..e1ac20807b 100644
> --- a/include/printf.h
> +++ b/include/printf.h
> @@ -12,6 +12,12 @@
>  
>  # ifndef _ISOMAC
>  
> +/* Internal interfaces for registered specifiers.  */
> +extern printf_function **__printf_function_table attribute_hidden;
> +int __register_printf_specifier (int, printf_function,
> +				 printf_arginfo_size_function);
> +libc_hidden_proto (__register_printf_specifier)
> +
>  #include <bits/types/locale_t.h>
>  
>  /* Now define the internal interfaces.  */

The __printf_function_table prototype is still present at 
stdio-common/printf-parse.h.  Maybe either move __printf_arginfo_table and
__printf_va_arg_table, or remove __printf_function_table from printf.h.


> diff --git a/stdio-common/reg-printf.c b/stdio-common/reg-printf.c
> index 400b99d2f6..5f4c6a24c2 100644
> --- a/stdio-common/reg-printf.c
> +++ b/stdio-common/reg-printf.c
> @@ -30,13 +30,6 @@ printf_function **__printf_function_table attribute_hidden;
>  
>  __libc_lock_define_initialized (static, lock)
>  
> -int __register_printf_specifier (int, printf_function,
> -				 printf_arginfo_size_function);
> -libc_hidden_proto (__register_printf_specifier)
> -int __register_printf_function (int, printf_function,
> -				printf_arginfo_function);
> -
> -
>  /* Register FUNC to be called to format SPEC specifiers.  */
>  int
>  __register_printf_specifier (int spec, printf_function converter,

Ok.

> diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
> index 1986c4bdb5..f8aa2fdafb 100644
> --- a/stdio-common/vfprintf-internal.c
> +++ b/stdio-common/vfprintf-internal.c
> @@ -1379,7 +1379,6 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
>        /* Process format specifiers.  */
>        while (1)
>  	{
> -	  extern printf_function **__printf_function_table;
>  	  int function_done;
>  
>  	  if (spec <= UCHAR_MAX

Ok.
  

Patch

diff --git a/include/printf.h b/include/printf.h
index 0ed6e87387..e1ac20807b 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -12,6 +12,12 @@ 
 
 # ifndef _ISOMAC
 
+/* Internal interfaces for registered specifiers.  */
+extern printf_function **__printf_function_table attribute_hidden;
+int __register_printf_specifier (int, printf_function,
+				 printf_arginfo_size_function);
+libc_hidden_proto (__register_printf_specifier)
+
 #include <bits/types/locale_t.h>
 
 /* Now define the internal interfaces.  */
diff --git a/stdio-common/reg-printf.c b/stdio-common/reg-printf.c
index 400b99d2f6..5f4c6a24c2 100644
--- a/stdio-common/reg-printf.c
+++ b/stdio-common/reg-printf.c
@@ -30,13 +30,6 @@  printf_function **__printf_function_table attribute_hidden;
 
 __libc_lock_define_initialized (static, lock)
 
-int __register_printf_specifier (int, printf_function,
-				 printf_arginfo_size_function);
-libc_hidden_proto (__register_printf_specifier)
-int __register_printf_function (int, printf_function,
-				printf_arginfo_function);
-
-
 /* Register FUNC to be called to format SPEC specifiers.  */
 int
 __register_printf_specifier (int spec, printf_function converter,
diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
index 1986c4bdb5..f8aa2fdafb 100644
--- a/stdio-common/vfprintf-internal.c
+++ b/stdio-common/vfprintf-internal.c
@@ -1379,7 +1379,6 @@  printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
       /* Process format specifiers.  */
       while (1)
 	{
-	  extern printf_function **__printf_function_table;
 	  int function_done;
 
 	  if (spec <= UCHAR_MAX