Subject: upcoming compat kernel and libc changes
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 09/09/2005 12:46:42
Hello,

Our compatibility code has gotten quite messy through the years and I decided
it was time to attempt to fix some of the major problems:

	1. header clutter
	2. no consistent file/syscall naming.
	3. cvs history lost as files move around.
	4. ugly filenames __fooXX.c
	5. no easy way to avoid compiling the compatibility code in libc.

Here's what I did:
	1. Created sys/compat/sys/*.h and lib/libc/compat/include/*.h
	   for headers that have compat definitions. Moved all the compat
	   definitions there. These headers are not installed.
	   The only ugliness that remains in the installed headers, is
	   #ifndef __LIBC12_SOURCE__ in a few places and the __RENAME()
	   macros. This is fairly non-intrusive.
	2. moved some more code from kern that belonged in compat.
	3. created a subtree lib/libc/compat that mirrors the struct
	   of lib/libc and populated it with the compat files that were
	   needed. All files in that subtree are prefixed with compat_
	   so they have their own namespace. In the future, we can even
	   separate the build to build a libc_compat.so. I have moved
	   the arch specific bits for i386 there too; I have not done
	   so for the rest of the archs. I did it just as a proof of
	   concept.
	4. Fixed the __indirect_reference mess (specially the _*{err,warn}*.c
	   files).
	5. Moved all current function implementations in their proper
	   filenames i.e. the current glob(3) was in __glob13.c, now
	   it is back in glob.c (I did not do this for arch yet).
	   The naming convention now is that the original function
	   (eg. stat) goes to compat/sys/compat_stat.c,
	   the next stat function (eg. __stat13) goes to
	   compat/sys/compat___stat13.c, and the current stat function
	   is always in sys/stat.c [if needed, and is not a syscall].

The patch is quite large and can be found on:

    ftp://ftp.netbsd.org/pub/NetBSD/misc/christos/compat.tar.gz

In that tar file:

 14982 include.diff
151578 lib.libc.diff
204800 lib.libc.tar
 24654 sys.compat.diff
 40960 sys.compat.tar
  2882 sys.kern.diff
 17163 sys.sys.diff

Please let me know ASAP what you think, because I intend to commit this
RSN.

christos