[GLIBC][PATCH v2] Remove strdup inlines

Joseph Myers joseph@codesourcery.com
Mon Dec 12 23:13:00 GMT 2016


On Mon, 12 Dec 2016, Mike Frysinger wrote:

> On 12 Dec 2016 13:02, Wilco Dijkstra wrote:
> > --- a/string/string.h
> > +++ b/string/string.h
> >  
> > +#if (defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8     \
> > +     || __GLIBC_USE (LIB_EXT2))
> > +# define strdup(s) __builtin_strdup (s)
> > +#endif
> > +
> > +#if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
> > +#define strndup(s,n) __builtin_strndup (s, n)
> > +#endif
> 
> why do we need these at all ?  these seem like the sort of thing that
> gcc should do automatically for us ?

GCC can only do that in general for C90 functions.  Consider someone 
selecting strict POSIX with -std=c99 -D_POSIX_C_SOURCE=200809L; glibc 
knows these names are reserved in that context, GCC doesn't.  (Well, for 
str* there's strictly a general C reservation, but glibc doesn't take 
advantage of it.)

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Libc-alpha mailing list