Subject: compat code restructuring status
To: None <,>
From: Christos Zoulas <>
List: tech-userlevel
Date: 09/13/2005 16:17:02

Last night I committed the bulk of the changes to the compat infrastructure.
Here's what's changed...



In the past, we added compatibility glue to the src/sys/sys/*.h
headers protected by #if defined(_KERNEL) && defined(COMPAT_XXX)
or #if defined(__LIBC12_VERSION__). All such compat glue code has
now been migrated to src/sys/compat/sys/*.h headers. The only
mentions of compat code in the standard system headers should be:

    #ifndef __LIBC12_SOURCE__
    ... current declarations with __RENAME()

Currently only sparc64 and i386 compile. The rest of the kernel
archs can be easily fixed by including one or more of:

    ... etc...

where appropriate.


Similarly to the kernel headers, the compatibility portion of system
headers in src/include/*.h has moved to src/lib/libc/compat/include.

In the past, when a function became obsolete we created new files
called __functionXX.c and included __functionXX.c from function.c
or __functionYY.c. This made the source move around losing CVS
history and created ugly filenames.

In the new scheme, all compat code has been moved to
src/lib/libc/compat/<dir>/compat_<func>.c. For example, since we
had 2 fts(3) revisions so far (fts(), __fts13(), and __fts30()),
we have:

	    [contains fts which is renamed to __fts30() -- current]
	    [includes src/lib/libc/gen/fts.c to build __fts13() -- previous]
	    [includes src/lib/libc/gen/fts.c to build fts() -- original]

With regards to indirect references [these should eventually go
away and unless you understand what these are for, you can skip
this paragraph], we keep the source in foo.c, and the reference in
_foo.c [which is backwards with reality, but more convenient]. We
also don't include the original file as we did before, but define
an external declaration of the function to call, and use the function

The same holds for assembly source files, which should be moved to
the compat arch-specific subdirectories (this is work in progress).

Currently i386 and sparc64 compile, but only the i386 arch specific
code has been moved to the src/lib/libc/compat/arch/i386 directories.
Even some of the i386 arch-specific files will be renamed eventually.
It is better to fix the sources by moving the compat .S files in
src/lib/libc/compat/arch rather than just adding <compat/sys/...>
includes to make them compile.