This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2] Mark internal argz functions with attribute_hidden [BZ #18822]


On Fri, Aug 18, 2017 at 7:01 AM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Fri, 18 Aug 2017, H.J. Lu wrote:
>
>> diff --git a/include/argz.h b/include/argz.h
>> index 0388c23277..bddebfa221 100644
>> --- a/include/argz.h
>> +++ b/include/argz.h
>> @@ -4,6 +4,11 @@
>>
>>  # ifndef _ISOMAC
>>
>> +extern __typeof (__argz_add) __argz_add attribute_hidden;
>> +extern __typeof (__argz_add_sep) __argz_add_sep attribute_hidden;
>> +extern __typeof (__argz_append) __argz_append attribute_hidden;
>> +extern __typeof (__argz_create_sep) __argz_create_sep attribute_hidden;
>
> This sort of use of typeof is suspect for an internal function.  For
> declaring an internal alias to a public function, sure, but why redeclare
> an internal function using typeof rather than just getting the original
> declaration of the internal function right?
>
> In this case, the problem presumably is that the internal declarations are
> in the installed argz.h header.  So move them from the installed header to
> the include/ one.  At that point, using typeof *does* make sense to copy
> the type from the public function, e.g.
>
> extern __typeof (argz_add) __argz_add __THROW attribute_hidden;
>
> (argz.h is shared with gnulib, but in gnulib it doesn't have those
> internal declarations anyway.  So moving them to the include/ header helps
> bring the public one closer to the gnulib version.)
>

Done.

Here is the updated patch.  OK for master?

Thanks.


-- 
H.J.
From 4dec43c4a1cb7be8a746a2d65548705274041865 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 18 Aug 2017 05:19:36 -0700
Subject: [PATCH] Mark internal argz functions with attribute_hidden [BZ
 #18822]

Move internal argz function prototypes to include/argz.h and mark them
with attribute_hidden to allow direct access within libc.so and libc.a
without using GOT nor PLT.  This also brings string/argz.h closer to the
gnulib version.

	[BZ #18822]
	* include/argz.h (__argz_create_sep): New function prototype.
	(__argz_append): Likewise.
	(__argz_add): Likewise.
	(__argz_add_sep): Likewise.
	(__argz_delete): Likewise.
	(__argz_insert): Likewise.
	(__argz_replace): Likewise.
	* string/argz.h (__argz_create_sep): Removed.
	(__argz_append): Likewise.
	(__argz_add): Likewise.
	(__argz_add_sep): Likewise.
	(__argz_delete): Likewise.
	(__argz_insert): Likewise.
	(__argz_replace): Likewise.
---
 include/argz.h | 32 ++++++++++++++++++++++++++++++++
 string/argz.h  | 26 --------------------------
 2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/include/argz.h b/include/argz.h
index 0388c23277..c265d9d76a 100644
--- a/include/argz.h
+++ b/include/argz.h
@@ -4,6 +4,38 @@
 
 # ifndef _ISOMAC
 
+extern error_t __argz_create_sep (const char *__restrict __string,
+				  int __sep, char **__restrict __argz,
+				  size_t *__restrict __len)
+     __THROW attribute_hidden;
+extern error_t __argz_append (char **__restrict __argz,
+			      size_t *__restrict __argz_len,
+			      const char *__restrict __buf, size_t __buf_len)
+     __THROW attribute_hidden;
+extern error_t __argz_add (char **__restrict __argz,
+			   size_t *__restrict __argz_len,
+			   const char *__restrict __str)
+     __THROW attribute_hidden;
+extern error_t __argz_add_sep (char **__restrict __argz,
+			       size_t *__restrict __argz_len,
+			       const char *__restrict __string, int __delim)
+     __THROW attribute_hidden;
+extern void __argz_delete (char **__restrict __argz,
+			   size_t *__restrict __argz_len,
+			   char *__restrict __entry)
+     __THROW attribute_hidden;
+extern error_t __argz_insert (char **__restrict __argz,
+			      size_t *__restrict __argz_len,
+			      char *__restrict __before,
+			      const char *__restrict __entry)
+     __THROW attribute_hidden;
+extern error_t __argz_replace (char **__restrict __argz,
+			       size_t *__restrict __argz_len,
+			       const char *__restrict __str,
+			       const char *__restrict __with,
+			       unsigned int *__restrict __replace_count)
+     __THROW attribute_hidden;
+
 libc_hidden_proto (argz_delete)
 libc_hidden_proto (__argz_count)
 libc_hidden_proto (__argz_stringify)
diff --git a/string/argz.h b/string/argz.h
index e07d74208a..269016d7ff 100644
--- a/string/argz.h
+++ b/string/argz.h
@@ -44,9 +44,6 @@ extern error_t argz_create (char *const __argv[], char **__restrict __argz,
    STRING, returning it in ARGZ, and the total length in LEN.  If a
    memory allocation error occurs, ENOMEM is returned, otherwise 0.
    The result can be destroyed using free.  */
-extern error_t __argz_create_sep (const char *__restrict __string,
-				  int __sep, char **__restrict __argz,
-				  size_t *__restrict __len) __THROW;
 extern error_t argz_create_sep (const char *__restrict __string,
 				int __sep, char **__restrict __argz,
 				size_t *__restrict __len) __THROW;
@@ -70,38 +67,24 @@ extern void __argz_stringify (char *__argz, size_t __len, int __sep) __THROW;
 extern void argz_stringify (char *__argz, size_t __len, int __sep) __THROW;
 
 /* Append BUF, of length BUF_LEN to the argz vector in ARGZ & ARGZ_LEN.  */
-extern error_t __argz_append (char **__restrict __argz,
-			      size_t *__restrict __argz_len,
-			      const char *__restrict __buf, size_t __buf_len)
-     __THROW;
 extern error_t argz_append (char **__restrict __argz,
 			    size_t *__restrict __argz_len,
 			    const char *__restrict __buf, size_t __buf_len)
      __THROW;
 
 /* Append STR to the argz vector in ARGZ & ARGZ_LEN.  */
-extern error_t __argz_add (char **__restrict __argz,
-			   size_t *__restrict __argz_len,
-			   const char *__restrict __str) __THROW;
 extern error_t argz_add (char **__restrict __argz,
 			 size_t *__restrict __argz_len,
 			 const char *__restrict __str) __THROW;
 
 /* Append SEP separated list in STRING to the argz vector in ARGZ &
    ARGZ_LEN.  */
-extern error_t __argz_add_sep (char **__restrict __argz,
-			       size_t *__restrict __argz_len,
-			       const char *__restrict __string, int __delim)
-     __THROW;
 extern error_t argz_add_sep (char **__restrict __argz,
 			     size_t *__restrict __argz_len,
 			     const char *__restrict __string, int __delim)
      __THROW;
 
 /* Delete ENTRY from ARGZ & ARGZ_LEN, if it appears there.  */
-extern void __argz_delete (char **__restrict __argz,
-			   size_t *__restrict __argz_len,
-			   char *__restrict __entry) __THROW;
 extern void argz_delete (char **__restrict __argz,
 			 size_t *__restrict __argz_len,
 			 char *__restrict __entry) __THROW;
@@ -112,10 +95,6 @@ extern void argz_delete (char **__restrict __argz,
    ARGZ, ENTRY) will insert ENTRY at the beginning of ARGZ.  If BEFORE is not
    in ARGZ, EINVAL is returned, else if memory can't be allocated for the new
    ARGZ, ENOMEM is returned, else 0.  */
-extern error_t __argz_insert (char **__restrict __argz,
-			      size_t *__restrict __argz_len,
-			      char *__restrict __before,
-			      const char *__restrict __entry) __THROW;
 extern error_t argz_insert (char **__restrict __argz,
 			    size_t *__restrict __argz_len,
 			    char *__restrict __before,
@@ -124,11 +103,6 @@ extern error_t argz_insert (char **__restrict __argz,
 /* Replace any occurrences of the string STR in ARGZ with WITH, reallocating
    ARGZ as necessary.  If REPLACE_COUNT is non-zero, *REPLACE_COUNT will be
    incremented by number of replacements performed.  */
-extern error_t __argz_replace (char **__restrict __argz,
-			       size_t *__restrict __argz_len,
-			       const char *__restrict __str,
-			       const char *__restrict __with,
-			       unsigned int *__restrict __replace_count);
 extern error_t argz_replace (char **__restrict __argz,
 			     size_t *__restrict __argz_len,
 			     const char *__restrict __str,
-- 
2.13.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]