svn commit: trunk/uClibc: extra/Configs libc/misc/glob

Bernhard Fischer rep.nop at aon.at
Fri Jul 7 13:00:09 UTC 2006


On Thu, Jul 06, 2006 at 09:34:00AM +0200, Peter S. Mazinger wrote:
>On Wed, 5 Jul 2006, Erik Andersen wrote:
>
>> On Thu Jul 06, 2006 at 12:34:25AM +0200, Peter S. Mazinger wrote:
>> > please check the produced objects: `readelf -s glob[64].os` for non __GI_ 
>> > prefixed functions, you introduced some jump relocations
>> 
>> My bad.  Better now?
>> 
>>  -Erik
>
>Attached a fix against it (probably needs some testing for !LFS):
>- malloc/realloc/free are not prepared to be hidable in trunk, you can't 
>  use libc_hidden_proto(x) for them

Confirmed.

>- using libc_hidden_proto(x64) LFS unguarded will fail because the header 
>  does not provide the prototype
>- if you are using libc_hidden_proto(collated_compare|prefix_array), you 
>  also need libc_hidden_def|_weak(x) after the function itself, the result 
>  being to provide a hidden __GI_collated_compare and a visible 
>  collated_compare, for this case I do not consider this necessary, 
>  especially that collated_compare is hidden already (I have chosen to 
>  prefix them with __ to know that they are intended to be internal only, 
>  against the practice in glibc, you could go without prefix as well)
>
>Another possible size win:
>- collated_compare and prefix_array (next_brace_sub as well) are compiled 
>  only into glob.c and used only by glob64.c (if LFS enabled), for !LFS 
>  they could even be made static

These above look ok to me. Please apply.
>
>Haven't provided change to glob.h, but it needs adapting for the planned 
>config options.
>
>Peter
>
>-- 
>Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
>Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2

>--- /mnt/ftp/svn/uClibc.orig/libc/misc/glob/glob.c	2006-07-06 08:31:02 +0200
>+++ glob.c	2006-07-06 09:02:52 +0200
>@@ -33,17 +33,11 @@
> 
> libc_hidden_proto(closedir)
> libc_hidden_proto(fnmatch)
>-libc_hidden_proto(free)
>-libc_hidden_proto(malloc)
> libc_hidden_proto(memcpy)
> libc_hidden_proto(mempcpy)
> libc_hidden_proto(opendir)
> libc_hidden_proto(qsort)
> libc_hidden_proto(readdir)
>-libc_hidden_proto(readdir64)
>-libc_hidden_proto(realloc)
>-libc_hidden_proto(stat)
>-libc_hidden_proto(stat64)
> libc_hidden_proto(strchr)
> libc_hidden_proto(strcoll)
> libc_hidden_proto(strcpy)
>@@ -68,11 +62,19 @@
> #define glob_t glob64_t
> #define glob(pattern, flags, errfunc, pglob) glob64 (pattern, flags, errfunc, pglob)
> #define globfree(pglob) globfree64 (pglob)
>+libc_hidden_proto(stat64)
>+libc_hidden_proto(readdir64)
> #else
> #define __readdir readdir
>+#ifdef __UCLIBC_HAS_LFS__
> #define __readdir64 readdir64
>+libc_hidden_proto(readdir64)
>+#else
>+#define __readdir64 readdir
>+#endif
> #define struct_stat64          struct stat
> #define __stat64(fname, buf)   stat (fname, buf)
>+libc_hidden_proto(stat)
> #endif
> 
> 
>@@ -124,19 +126,13 @@
>   CONVERT_D_INO (d64, d32)						      \
>   CONVERT_D_TYPE (d64, d32)
> 
>-extern __ptr_t (*__glob_opendir_hook) (const char *directory) attribute_hidden;
>-extern void (*__glob_closedir_hook) (__ptr_t stream) attribute_hidden;
>-extern const char *(*__glob_readdir_hook) (__ptr_t stream) attribute_hidden;
>-
>-extern int collated_compare (const void *a, const void *b) attribute_hidden;
>-extern int prefix_array (const char *dirname, char **array, size_t n) attribute_hidden;
>+extern int __collated_compare (const void *a, const void *b) attribute_hidden;
>+extern int __prefix_array (const char *dirname, char **array, size_t n) attribute_hidden;
> #if defined ENABLE_GLOB_BRACE_EXPANSION
> extern const char *__next_brace_sub (const char *cp, int flags) attribute_hidden;
> #endif
> 
> libc_hidden_proto(glob_pattern_p)
>-libc_hidden_proto(collated_compare)
>-libc_hidden_proto(prefix_array)
> #ifndef COMPILE_GLOB64
> /* Return nonzero if PATTERN contains any metacharacters.
>    Metacharacters can be quoted with backslashes if QUOTE is nonzero.  */
>@@ -173,7 +169,7 @@
> 
> 
> /* Do a collated comparison of A and B.  */
>-int collated_compare (const void *a, const void *b)
>+int __collated_compare (const void *a, const void *b)
> {
>   const char *const s1 = *(const char *const * const) a;
>   const char *const s2 = *(const char *const * const) b;
>@@ -194,7 +190,7 @@
>    unless DIRNAME is just "/".  Each old element of ARRAY is freed.
>    If ADD_SLASH is non-zero, allocate one character more than
>    necessary, so that a slash can be appended later.  */
>-int prefix_array (const char *dirname, char **array, size_t n)
>+int __prefix_array (const char *dirname, char **array, size_t n)
> {
>   register size_t i;
>   size_t dirlen = strlen (dirname);
>@@ -953,7 +949,7 @@
> 	    }
> 
> 	  /* Stick the directory on the front of each name.  */
>-	  if (prefix_array (dirs.gl_pathv[i],
>+	  if (__prefix_array (dirs.gl_pathv[i],
> 			    &pglob->gl_pathv[old_pathc + pglob->gl_offs],
> 			    pglob->gl_pathc - old_pathc))
> 	    {
>@@ -1022,7 +1018,7 @@
>       if (dirlen > 0)
> 	{
> 	  /* Stick the directory on the front of each name.  */
>-	  if (prefix_array (dirname,
>+	  if (__prefix_array (dirname,
> 			    &pglob->gl_pathv[old_pathc + pglob->gl_offs],
> 			    pglob->gl_pathc - old_pathc))
> 	    {
>@@ -1065,7 +1061,7 @@
>       /* Sort the vector.  */
>       qsort (&pglob->gl_pathv[oldcount],
> 	     pglob->gl_pathc + pglob->gl_offs - oldcount,
>-	     sizeof (char *), collated_compare);
>+	     sizeof (char *), __collated_compare);
>     }
> 
>   return 0;

>_______________________________________________
>uClibc mailing list
>uClibc at uclibc.org
>http://busybox.net/cgi-bin/mailman/listinfo/uclibc



More information about the uClibc mailing list