From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13216 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: internal header proposal Date: Fri, 7 Sep 2018 23:27:36 -0400 Message-ID: <20180908032736.GP1878@brightrain.aerifal.cx> References: <20180907172312.GO1878@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1536490606 19440 195.159.176.226 (9 Sep 2018 10:56:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 9 Sep 2018 10:56:46 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-13232-gllmg-musl=m.gmane.org@lists.openwall.com Sun Sep 09 12:56:41 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1fyxOS-0004wM-Sr for gllmg-musl@m.gmane.org; Sun, 09 Sep 2018 12:56:40 +0200 Original-Received: (qmail 32685 invoked by uid 550); 9 Sep 2018 10:58:46 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 1406 invoked from network); 9 Sep 2018 00:35:14 -0000 Resent-From: Rich Felker Resent-Date: Sat, 8 Sep 2018 20:35:01 -0400 Resent-Message-ID: <20180909003501.GQ1878@brightrain.aerifal.cx> Resent-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20180907172312.GO1878@brightrain.aerifal.cx> Resent-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:13216 Archived-At: 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 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