mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: internal header proposal
Date: Fri, 7 Sep 2018 23:27:36 -0400	[thread overview]
Message-ID: <20180908032736.GP1878@brightrain.aerifal.cx> (raw)
In-Reply-To: <20180907172312.GO1878@brightrain.aerifal.cx>

On Fri, Sep 07, 2018 at 01:23:12PM -0400, Rich Felker wrote:
> Option 1: The big fancy header wrapping
> 
> Add a new tree of "wrapper headers" for public headers (let's call it
> $(srcdir)/src/include), and -I it before the real public ones
> ($(srcdir)/include). These new headers include their corresponding
> public header (../../include/[self].h) then add anything else that's
> supposed to be "public within musl". For example sys/mman.h would have
> stuff like:
> 
> hidden void __vm_wait(void);
> hidden void __vm_lock(void);
> hidden void __vm_unlock(void);
> 
> hidden void *__mmap(void *, size_t, int, int, int, off_t);
> hidden int __munmap(void *, size_t);
> hidden void *__mremap(void *, size_t, size_t, int, ...);
> hidden int __madvise(void *, size_t, int);
> hidden int __mprotect(void *, size_t, int);
> 
> hidden const unsigned char *__map_file(const char *, size_t *);
> 
> Now, every file that needs to use mman.h functions without violating
> namespace can just #include <sys/mman.h> and use the above. If we
> wanted, at some point we could even #define the unprefixed names to
> remap to the prefixed ones, and only #undef them in the files that
> define them, so that everything automatically gets the namespace-safe,
> low-call-overhead names. This idea is a lot like how
> syscall()/__syscall() work now -- the musl source files get programmed
> with familiar interfaces, and a small amount of header magic makes
> them do the right thing rather than depending on a public namespace
> violation.
> 
> If this all seems too radical, or like it has potential pitfalls we
> need to think about before committing to it, I have a less invasive
> proposal too:

I have this option implemented and it's working out really well, with
just the following headers:

src/include/arpa/inet.h
src/include/langinfo.h
src/include/pthread.h
src/include/resolv.h
src/include/signal.h
src/include/stdlib.h
src/include/string.h
src/include/sys/mman.h
src/include/time.h
src/include/unistd.h

This list tells a lot about what parts (how little) of libc are
useful/necessary for implementing other parts.

So far I've dropped the number of inline-in-source declarations down
from over 160 to 41, and most of the ones left are either ABI/linking
glue stuff, or internal interfaces with a single consumer. Nothing
left is purely a namespace-protected version of a public function.

I'll wrap up the rest soon and get all this ready to push. Already
found and fixed a few small bugs in the process. :)

Rich


  reply	other threads:[~2018-09-08  3:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-07 17:23 Rich Felker
2018-09-08  3:27 ` Rich Felker [this message]
2018-09-09 22:27 ` Alexander Monakov
2018-09-10  0:47   ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180908032736.GP1878@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).