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: [GLIBC][PATCH v2] Remove strdup inlines


Zack Weinberg wrote:
> On Thu, Dec 15, 2016 at 8:16 AM, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
> >
> > No I'm not talking about the C++ const inlines, I mean redirects to avoid namespace
> > issues (and to enable GCC to optimize builtins) for non-C90 functions that are used
> > inside GLIBC. Eg:
> >
> > #if (!IS_IN (libc) || !defined SHARED) \
> >   && !defined NO_MEMPCPY_STPCPY_REDIRECT
> > /* Redirect calls to __builtin_mempcpy and __builtin_stpcpy to call
> >    __mempcpy and __stpcpy if not inlined.  */
> > extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");
> > extern __typeof (stpcpy) stpcpy __asm__ ("__stpcpy");
> > #endif
> 
> I tend to think this is the best approach, since it doesn't involve
> macros and doesn't require the use of mangled names in the source
> code.  However, the NO_MEMPCPY_STPCPY_REDIRECT thing is a big mess and
> we might not want to have more of that.

Is there anything that goes wrong if you declare: 

extern __typeof (mempcpy) mempcpy __asm__ ("__mempcpy");

in string/mempcpy.c? The definition uses __mempcpy, so the only thing I can
imagine is that the weak alias/hidden def defines might get confused. If so, would this:

extern __typeof (mempcpy) mempcpy __asm__ ("mempcpy");

fix it? That would avoid NO_MEMPCPY_STPCPY_REDIRECT and make it a lot
cleaner.

> # ifndef _ISOMAC
> #  ifndef index
> #   define index(s, c)  (strchr ((s), (c)))
> #  endif
> #  ifndef rindex
> #   define rindex(s, c) (strrchr ((s), (c)))
> #  endif
> # endif

> Arguably we shouldn't be using these legacy names at all in glibc's
> source.  Maybe they should be poisoned (#pragma GCC poison).

Isn't linknamespace failures good enough? We could remove those defines and
fix resulting failures, then any new use would be flagged anyway.

> > Note there are also plenty of calls to functions with underscores, eg. __stpcpy,
> > __mempcpy, __bzero, so we ideally need to either rename these to use the base name
> > or redirect to the builtin.
>
> I'd prefer to rename to the base name, but that's just for aesthetics.

That seems best indeed.

Wilco

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