RFC: first stab at getting rid of libc_hidden_proto() forest
Denys Vlasenko
vda.linux at googlemail.com
Sat Apr 12 13:38:03 UTC 2008
On Saturday 12 April 2008 07:35, Carmelo Amoroso wrote:
> > I find the need of having libc_hidden_proto(fprintf)
> > anywhere you want to use fprintf efficiently (i.e.
> > to call it directly, not thru GOT/PLT) to be unmaintainable.
> >
> Hi,
> sounds reasonable...
> > First, it clogs up the source.
> >
> agree
> > Second, it's too easy to forget to do it, and you get
> > suboptimal code, silently.
> >
> agree
> > Third, sometimes it gets even more ugly: you need to know
> > _implementation details_ and dance with #defines like this:
> >
> > #ifdef __UCLIBC_HAS_XLOCALE__
> > libc_hidden_proto(__ctype_b_loc)
> > #elif __UCLIBC_HAS_CTYPE_TABLES__
> > libc_hidden_proto(__ctype_b)
> > #endif
> >
> well, this case could not be a major issue,
> it can rewritten like this
>
> #ifdef __UCLIBC_HAS_XLOCALE__
> #define __CTYPE_B __ctype_b_loc
> #elif __UCLIBC_HAS_CTYPE_TABLES__
> #define __CTYPE_B __ctype_b
> #endif
This adds more unwanted stuff to public headers.
>
> libc_hidden_proto(__CTYPE_B)
>
> > Fifth: it needs to be repeated in every .c file where you want
> > to use e.g. ctype.h functions!
> >
> agree
>
> > Obvious solution of adding libc_hidden_proto's to .h files
> > does not work so well since we'd like to not pollute them with
> > machinery which doesn't belong to public interface.
> >
> but we could scrub public *h at install time by removing
> all occurences of libc_hidden_proto producing a sort of
> sanitized libc headers, in the same way kernel does.
>
> > In the attached patch, I chose to create a "master include file"
> > which includes almost all other headers; and then marks
> > all exported functions(variables) with libc_hidden_proto.
> > The file is called uClibc_libc.h.
>
> I don't like this approach since I usually prefer explicitely
> including all specific headers are areally need, no less, no more,
> instead of a master include header.
>
> This is my opinion. I agree with you about the needs of consistently
> using libc_hidden_proto, but I'd try to find another solution.
How about having one "internal" header for each public one?
internal/stdio.h would look like this:
#include <stdio.h>
libc_hidden_proto(printf)
libc_hidden_proto(sprintf)
libc_hidden_proto(vfprintf)
...
with #ifdefs etc if some functions are not always present.
uclibc .c files would #include <internal/stdio.h> instead of <stdio.h>
> Anyway, being this a big change, I'd like to hear other opinions
> and comment.
> Mike, Jocke, Bernds, Peter others... what do you think ?
--
vda
More information about the uClibc
mailing list