Blame manual/maint.texi

Packit 6c4009
@node Maintenance, Platform, Installation, Top
Packit 6c4009
@c %MENU% How to enhance and port the GNU C Library
Packit 6c4009
@appendix Library Maintenance
Packit 6c4009
Packit 6c4009
@menu
Packit 6c4009
* Source Layout::         How to add new functions or header files
Packit 6c4009
                             to the GNU C Library.
Packit 6c4009
* Porting::               How to port the GNU C Library to
Packit 6c4009
                             a new machine or operating system.
Packit 6c4009
@end menu
Packit 6c4009
Packit 6c4009
@node Source Layout
Packit 6c4009
@appendixsec Adding New Functions
Packit 6c4009
Packit 6c4009
The process of building the library is driven by the makefiles, which
Packit 6c4009
make heavy use of special features of GNU @code{make}.  The makefiles
Packit 6c4009
are very complex, and you probably don't want to try to understand them.
Packit 6c4009
But what they do is fairly straightforward, and only requires that you
Packit 6c4009
define a few variables in the right places.
Packit 6c4009
Packit 6c4009
The library sources are divided into subdirectories, grouped by topic.
Packit 6c4009
Packit 6c4009
The @file{string} subdirectory has all the string-manipulation
Packit 6c4009
functions, @file{math} has all the mathematical functions, etc.
Packit 6c4009
Packit 6c4009
Each subdirectory contains a simple makefile, called @file{Makefile},
Packit 6c4009
which defines a few @code{make} variables and then includes the global
Packit 6c4009
makefile @file{Rules} with a line like:
Packit 6c4009
Packit 6c4009
@smallexample
Packit 6c4009
include ../Rules
Packit 6c4009
@end smallexample
Packit 6c4009
Packit 6c4009
@noindent
Packit 6c4009
The basic variables that a subdirectory makefile defines are:
Packit 6c4009
Packit 6c4009
@table @code
Packit 6c4009
@item subdir
Packit 6c4009
The name of the subdirectory, for example @file{stdio}.
Packit 6c4009
This variable @strong{must} be defined.
Packit 6c4009
Packit 6c4009
@item headers
Packit 6c4009
The names of the header files in this section of the library,
Packit 6c4009
such as @file{stdio.h}.
Packit 6c4009
Packit 6c4009
@item routines
Packit 6c4009
@itemx aux
Packit 6c4009
The names of the modules (source files) in this section of the library.
Packit 6c4009
These should be simple names, such as @samp{strlen} (rather than
Packit 6c4009
complete file names, such as @file{strlen.c}).  Use @code{routines} for
Packit 6c4009
modules that define functions in the library, and @code{aux} for
Packit 6c4009
auxiliary modules containing things like data definitions.  But the
Packit 6c4009
values of @code{routines} and @code{aux} are just concatenated, so there
Packit 6c4009
really is no practical difference.@refill
Packit 6c4009
Packit 6c4009
@item tests
Packit 6c4009
The names of test programs for this section of the library.  These
Packit 6c4009
should be simple names, such as @samp{tester} (rather than complete file
Packit 6c4009
names, such as @file{tester.c}).  @w{@samp{make tests}} will build and
Packit 6c4009
run all the test programs.  If a test program needs input, put the test
Packit 6c4009
data in a file called @file{@var{test-program}.input}; it will be given to
Packit 6c4009
the test program on its standard input.  If a test program wants to be
Packit 6c4009
run with arguments, put the arguments (all on a single line) in a file
Packit 6c4009
called @file{@var{test-program}.args}.  Test programs should exit with
Packit 6c4009
zero status when the test passes, and nonzero status when the test
Packit 6c4009
indicates a bug in the library or error in building.
Packit 6c4009
Packit 6c4009
@item others
Packit 6c4009
The names of ``other'' programs associated with this section of the
Packit 6c4009
library.  These are programs which are not tests per se, but are other
Packit 6c4009
small programs included with the library.  They are built by
Packit 6c4009
@w{@samp{make others}}.@refill
Packit 6c4009
Packit 6c4009
@item install-lib
Packit 6c4009
@itemx install-data
Packit 6c4009
@itemx install
Packit 6c4009
Files to be installed by @w{@samp{make install}}.  Files listed in
Packit 6c4009
@samp{install-lib} are installed in the directory specified by
Packit 6c4009
@samp{libdir} in @file{configparms} or @file{Makeconfig}
Packit 6c4009
(@pxref{Installation}).  Files listed in @code{install-data} are
Packit 6c4009
installed in the directory specified by @samp{datadir} in
Packit 6c4009
@file{configparms} or @file{Makeconfig}.  Files listed in @code{install}
Packit 6c4009
are installed in the directory specified by @samp{bindir} in
Packit 6c4009
@file{configparms} or @file{Makeconfig}.@refill
Packit 6c4009
Packit 6c4009
@item distribute
Packit 6c4009
Other files from this subdirectory which should be put into a
Packit 6c4009
distribution tar file.  You need not list here the makefile itself or
Packit 6c4009
the source and header files listed in the other standard variables.
Packit 6c4009
Only define @code{distribute} if there are files used in an unusual way
Packit 6c4009
that should go into the distribution.
Packit 6c4009
Packit 6c4009
@item generated
Packit 6c4009
Files which are generated by @file{Makefile} in this subdirectory.
Packit 6c4009
These files will be removed by @w{@samp{make clean}}, and they will
Packit 6c4009
never go into a distribution.
Packit 6c4009
Packit 6c4009
@item extra-objs
Packit 6c4009
Extra object files which are built by @file{Makefile} in this
Packit 6c4009
subdirectory.  This should be a list of file names like @file{foo.o};
Packit 6c4009
the files will actually be found in whatever directory object files are
Packit 6c4009
being built in.  These files will be removed by @w{@samp{make clean}}.
Packit 6c4009
This variable is used for secondary object files needed to build
Packit 6c4009
@code{others} or @code{tests}.
Packit 6c4009
@end table
Packit 6c4009
Packit 6c4009
@menu
Packit 6c4009
* Platform: Adding Platform-specific.             Adding platform-specific
Packit 6c4009
                                         features.
Packit 6c4009
@end menu
Packit 6c4009
Packit 6c4009
@node Adding Platform-specific
Packit 6c4009
@appendixsubsec Platform-specific types, macros and functions
Packit 6c4009
Packit 6c4009
It's sometimes necessary to provide nonstandard, platform-specific
Packit 6c4009
features to developers.  The C library is traditionally the
Packit 6c4009
lowest library layer, so it makes sense for it to provide these
Packit 6c4009
low-level features.  However, including these features in the C
Packit 6c4009
library may be a disadvantage if another package provides them
Packit 6c4009
as well as there will be two conflicting versions of them.  Also,
Packit 6c4009
the features won't be available to projects that do not use
Packit 6c4009
@theglibc{} but use other GNU tools, like GCC.
Packit 6c4009
Packit 6c4009
The current guidelines are:
Packit 6c4009
@itemize @bullet
Packit 6c4009
@item
Packit 6c4009
If the header file provides features that only make sense on a particular
Packit 6c4009
machine architecture and have nothing to do with an operating system, then
Packit 6c4009
the features should ultimately be provided as GCC built-in functions.  Until
Packit 6c4009
then, @theglibc{} may provide them in the header file.  When the GCC built-in
Packit 6c4009
functions become available, those provided in the header file should be made
Packit 6c4009
conditionally available prior to the GCC version in which the built-in
Packit 6c4009
function was made available.
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
If the header file provides features that are specific to an operating system,
Packit 6c4009
both GCC and @theglibc{} could provide it, but @theglibc{} is preferred
Packit 6c4009
as it already has a lot of information about the operating system.
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
If the header file provides features that are specific to an operating system
Packit 6c4009
but used by @theglibc{}, then @theglibc{} should provide them.
Packit 6c4009
@end itemize
Packit 6c4009
Packit 6c4009
The general solution for providing low-level features is to export them as
Packit 6c4009
follows:
Packit 6c4009
Packit 6c4009
@itemize @bullet
Packit 6c4009
@item
Packit 6c4009
A nonstandard, low-level header file that defines macros and inline
Packit 6c4009
functions should be called @file{sys/platform/@var{name}.h}.
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
Each header file's name should include the platform name, to avoid
Packit 6c4009
users thinking there is anything in common between the different
Packit 6c4009
header files for different platforms.  For example, a
Packit 6c4009
@file{sys/platform/@var{arch}.h} name such as
Packit 6c4009
@file{sys/platform/ppc.h} is better than @file{sys/platform.h}.
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
A platform-specific header file provided by @theglibc{} should coordinate
Packit 6c4009
with GCC such that compiler built-in versions of the functions and macros are
Packit 6c4009
preferred if available.  This means that user programs will only ever need to
Packit 6c4009
include @file{sys/platform/@var{arch}.h}, keeping the same names of types,
Packit 6c4009
macros, and functions for convenience and portability.
Packit 6c4009
Packit 6c4009
@item
Packit 6c4009
Each included symbol must have the prefix @code{__@var{arch}_}, such as
Packit 6c4009
@code{__ppc_get_timebase}.
Packit 6c4009
@end itemize
Packit 6c4009
Packit 6c4009
Packit 6c4009
The easiest way to provide a header file is to add it to the
Packit 6c4009
@code{sysdep_headers} variable.  For example, the combination of
Packit 6c4009
Linux-specific header files on PowerPC could be provided like this:
Packit 6c4009
Packit 6c4009
@smallexample
Packit 6c4009
sysdep_headers += sys/platform/ppc.h
Packit 6c4009
@end smallexample
Packit 6c4009
Packit 6c4009
Then ensure that you have added a @file{sys/platform/ppc.h}
Packit 6c4009
header file in the machine-specific directory, e.g.,
Packit 6c4009
@file{sysdeps/powerpc/sys/platform/ppc.h}.
Packit 6c4009
Packit 6c4009
Packit 6c4009
@node Porting
Packit 6c4009
@appendixsec Porting @theglibc{}
Packit 6c4009
Packit 6c4009
@Theglibc{} is written to be easily portable to a variety of
Packit 6c4009
machines and operating systems.  Machine- and operating system-dependent
Packit 6c4009
functions are well separated to make it easy to add implementations for
Packit 6c4009
new machines or operating systems.  This section describes the layout of
Packit 6c4009
the library source tree and explains the mechanisms used to select
Packit 6c4009
machine-dependent code to use.
Packit 6c4009
Packit 6c4009
All the machine-dependent and operating system-dependent files in the
Packit 6c4009
library are in the subdirectory @file{sysdeps} under the top-level
Packit 6c4009
library source directory.  This directory contains a hierarchy of
Packit 6c4009
subdirectories (@pxref{Hierarchy Conventions}).
Packit 6c4009
Packit 6c4009
Each subdirectory of @file{sysdeps} contains source files for a
Packit 6c4009
particular machine or operating system, or for a class of machine or
Packit 6c4009
operating system (for example, systems by a particular vendor, or all
Packit 6c4009
machines that use IEEE 754 floating-point format).  A configuration
Packit 6c4009
specifies an ordered list of these subdirectories.  Each subdirectory
Packit 6c4009
implicitly appends its parent directory to the list.  For example,
Packit 6c4009
specifying the list @file{unix/bsd/vax} is equivalent to specifying the
Packit 6c4009
list @file{unix/bsd/vax unix/bsd unix}.  A subdirectory can also specify
Packit 6c4009
that it implies other subdirectories which are not directly above it in
Packit 6c4009
the directory hierarchy.  If the file @file{Implies} exists in a
Packit 6c4009
subdirectory, it lists other subdirectories of @file{sysdeps} which are
Packit 6c4009
appended to the list, appearing after the subdirectory containing the
Packit 6c4009
@file{Implies} file.  Lines in an @file{Implies} file that begin with a
Packit 6c4009
@samp{#} character are ignored as comments.  For example,
Packit 6c4009
@file{unix/bsd/Implies} contains:@refill
Packit 6c4009
@smallexample
Packit 6c4009
# BSD has Internet-related things.
Packit 6c4009
unix/inet
Packit 6c4009
@end smallexample
Packit 6c4009
@noindent
Packit 6c4009
and @file{unix/Implies} contains:
Packit 6c4009
@need 300
Packit 6c4009
@smallexample
Packit 6c4009
posix
Packit 6c4009
@end smallexample
Packit 6c4009
Packit 6c4009
@noindent
Packit 6c4009
So the final list is @file{unix/bsd/vax unix/bsd unix/inet unix posix}.
Packit 6c4009
Packit 6c4009
@file{sysdeps} has a ``special'' subdirectory called @file{generic}.  It
Packit 6c4009
is always implicitly appended to the list of subdirectories, so you
Packit 6c4009
needn't put it in an @file{Implies} file, and you should not create any
Packit 6c4009
subdirectories under it intended to be new specific categories.
Packit 6c4009
@file{generic} serves two purposes.  First, the makefiles do not bother
Packit 6c4009
to look for a system-dependent version of a file that's not in
Packit 6c4009
@file{generic}.  This means that any system-dependent source file must
Packit 6c4009
have an analogue in @file{generic}, even if the routines defined by that
Packit 6c4009
file are not implemented on other platforms.  Second, the @file{generic}
Packit 6c4009
version of a system-dependent file is used if the makefiles do not find
Packit 6c4009
a version specific to the system you're compiling for.
Packit 6c4009
Packit 6c4009
If it is possible to implement the routines in a @file{generic} file in
Packit 6c4009
machine-independent C, using only other machine-independent functions in
Packit 6c4009
the C library, then you should do so.  Otherwise, make them stubs.  A
Packit 6c4009
@dfn{stub} function is a function which cannot be implemented on a
Packit 6c4009
particular machine or operating system.  Stub functions always return an
Packit 6c4009
error, and set @code{errno} to @code{ENOSYS} (Function not implemented).
Packit 6c4009
@xref{Error Reporting}.  If you define a stub function, you must place
Packit 6c4009
the statement @code{stub_warning(@var{function})}, where @var{function}
Packit 6c4009
is the name of your function, after its definition.  This causes the
Packit 6c4009
function to be listed in the installed @code{<gnu/stubs.h>}, and
Packit 6c4009
makes GNU ld warn when the function is used.
Packit 6c4009
Packit 6c4009
Some rare functions are only useful on specific systems and aren't
Packit 6c4009
defined at all on others; these do not appear anywhere in the
Packit 6c4009
system-independent source code or makefiles (including the
Packit 6c4009
@file{generic} directory), only in the system-dependent @file{Makefile}
Packit 6c4009
in the specific system's subdirectory.
Packit 6c4009
Packit 6c4009
If you come across a file that is in one of the main source directories
Packit 6c4009
(@file{string}, @file{stdio}, etc.), and you want to write a machine- or
Packit 6c4009
operating system-dependent version of it, move the file into
Packit 6c4009
@file{sysdeps/generic} and write your new implementation in the
Packit 6c4009
appropriate system-specific subdirectory.  Note that if a file is to be
Packit 6c4009
system-dependent, it @strong{must not} appear in one of the main source
Packit 6c4009
directories.@refill
Packit 6c4009
Packit 6c4009
There are a few special files that may exist in each subdirectory of
Packit 6c4009
@file{sysdeps}:
Packit 6c4009
Packit 6c4009
@comment Blank lines after items make the table look better.
Packit 6c4009
@table @file
Packit 6c4009
@item Makefile
Packit 6c4009
Packit 6c4009
A makefile for this machine or operating system, or class of machine or
Packit 6c4009
operating system.  This file is included by the library makefile
Packit 6c4009
@file{Makerules}, which is used by the top-level makefile and the
Packit 6c4009
subdirectory makefiles.  It can change the variables set in the
Packit 6c4009
including makefile or add new rules.  It can use GNU @code{make}
Packit 6c4009
conditional directives based on the variable @samp{subdir} (see above) to
Packit 6c4009
select different sets of variables and rules for different sections of
Packit 6c4009
the library.  It can also set the @code{make} variable
Packit 6c4009
@samp{sysdep-routines}, to specify extra modules to be included in the
Packit 6c4009
library.  You should use @samp{sysdep-routines} rather than adding
Packit 6c4009
modules to @samp{routines} because the latter is used in determining
Packit 6c4009
what to distribute for each subdirectory of the main source tree.@refill
Packit 6c4009
Packit 6c4009
Each makefile in a subdirectory in the ordered list of subdirectories to
Packit 6c4009
be searched is included in order.  Since several system-dependent
Packit 6c4009
makefiles may be included, each should append to @samp{sysdep-routines}
Packit 6c4009
rather than simply setting it:
Packit 6c4009
Packit 6c4009
@smallexample
Packit 6c4009
sysdep-routines := $(sysdep-routines) foo bar
Packit 6c4009
@end smallexample
Packit 6c4009
Packit 6c4009
@need 1000
Packit 6c4009
@item Subdirs
Packit 6c4009
Packit 6c4009
This file contains the names of new whole subdirectories under the
Packit 6c4009
top-level library source tree that should be included for this system.
Packit 6c4009
These subdirectories are treated just like the system-independent
Packit 6c4009
subdirectories in the library source tree, such as @file{stdio} and
Packit 6c4009
@file{math}.
Packit 6c4009
Packit 6c4009
Use this when there are completely new sets of functions and header
Packit 6c4009
files that should go into the library for the system this subdirectory
Packit 6c4009
of @file{sysdeps} implements.  For example,
Packit 6c4009
@file{sysdeps/unix/inet/Subdirs} contains @file{inet}; the @file{inet}
Packit 6c4009
directory contains various network-oriented operations which only make
Packit 6c4009
sense to put in the library on systems that support the Internet.@refill
Packit 6c4009
Packit 6c4009
@item configure
Packit 6c4009
Packit 6c4009
This file is a shell script fragment to be run at configuration time.
Packit 6c4009
The top-level @file{configure} script uses the shell @code{.} command to
Packit 6c4009
read the @file{configure} file in each system-dependent directory
Packit 6c4009
chosen, in order.  The @file{configure} files are often generated from
Packit 6c4009
@file{configure.ac} files using Autoconf.
Packit 6c4009
Packit 6c4009
A system-dependent @file{configure} script will usually add things to
Packit 6c4009
the shell variables @samp{DEFS} and @samp{config_vars}; see the
Packit 6c4009
top-level @file{configure} script for details.  The script can check for
Packit 6c4009
@w{@samp{--with-@var{package}}} options that were passed to the
Packit 6c4009
top-level @file{configure}.  For an option
Packit 6c4009
@w{@samp{--with-@var{package}=@var{value}}} @file{configure} sets the
Packit 6c4009
shell variable @w{@samp{with_@var{package}}} (with any dashes in
Packit 6c4009
@var{package} converted to underscores) to @var{value}; if the option is
Packit 6c4009
just @w{@samp{--with-@var{package}}} (no argument), then it sets
Packit 6c4009
@w{@samp{with_@var{package}}} to @samp{yes}.
Packit 6c4009
Packit 6c4009
@item configure.ac
Packit 6c4009
Packit 6c4009
This file is an Autoconf input fragment to be processed into the file
Packit 6c4009
@file{configure} in this subdirectory.  @xref{Introduction,,,
Packit 6c4009
autoconf.info, Autoconf: Generating Automatic Configuration Scripts},
Packit 6c4009
for a description of Autoconf.  You should write either @file{configure}
Packit 6c4009
or @file{configure.ac}, but not both.  The first line of
Packit 6c4009
@file{configure.ac} should invoke the @code{m4} macro
Packit 6c4009
@samp{GLIBC_PROVIDES}.  This macro does several @code{AC_PROVIDE} calls
Packit 6c4009
for Autoconf macros which are used by the top-level @file{configure}
Packit 6c4009
script; without this, those macros might be invoked again unnecessarily
Packit 6c4009
by Autoconf.
Packit 6c4009
@end table
Packit 6c4009
Packit 6c4009
That is the general system for how system-dependencies are isolated.
Packit 6c4009
@iftex
Packit 6c4009
The next section explains how to decide what directories in
Packit 6c4009
@file{sysdeps} to use.  @ref{Porting to Unix}, has some tips on porting
Packit 6c4009
the library to Unix variants.
Packit 6c4009
@end iftex
Packit 6c4009
Packit 6c4009
@menu
Packit 6c4009
* Hierarchy Conventions::       The layout of the @file{sysdeps} hierarchy.
Packit 6c4009
* Porting to Unix::             Porting the library to an average
Packit 6c4009
                                   Unix-like system.
Packit 6c4009
@end menu
Packit 6c4009
Packit 6c4009
@node Hierarchy Conventions
Packit 6c4009
@appendixsubsec Layout of the @file{sysdeps} Directory Hierarchy
Packit 6c4009
Packit 6c4009
A GNU configuration name has three parts: the CPU type, the
Packit 6c4009
manufacturer's name, and the operating system.  @file{configure} uses
Packit 6c4009
these to pick the list of system-dependent directories to look for.  If
Packit 6c4009
the @samp{--nfp} option is @emph{not} passed to @file{configure}, the
Packit 6c4009
directory @file{@var{machine}/fpu} is also used.  The operating system
Packit 6c4009
often has a @dfn{base operating system}; for example, if the operating
Packit 6c4009
system is @samp{Linux}, the base operating system is @samp{unix/sysv}.
Packit 6c4009
The algorithm used to pick the list of directories is simple:
Packit 6c4009
@file{configure} makes a list of the base operating system,
Packit 6c4009
manufacturer, CPU type, and operating system, in that order.  It then
Packit 6c4009
concatenates all these together with slashes in between, to produce a
Packit 6c4009
directory name; for example, the configuration @w{@samp{i686-linux-gnu}}
Packit 6c4009
results in @file{unix/sysv/linux/i386/i686}.  @file{configure} then
Packit 6c4009
tries removing each element of the list in turn, so
Packit 6c4009
@file{unix/sysv/linux} and @file{unix/sysv} are also tried, among others.
Packit 6c4009
Since the precise version number of the operating system is often not
Packit 6c4009
important, and it would be very inconvenient, for example, to have
Packit 6c4009
identical @file{irix6.2} and @file{irix6.3} directories,
Packit 6c4009
@file{configure} tries successively less specific operating system names
Packit 6c4009
by removing trailing suffixes starting with a period.
Packit 6c4009
Packit 6c4009
As an example, here is the complete list of directories that would be
Packit 6c4009
tried for the configuration @w{@samp{i686-linux-gnu}}:
Packit 6c4009
Packit 6c4009
@smallexample
Packit 6c4009
sysdeps/i386/elf
Packit 6c4009
sysdeps/unix/sysv/linux/i386
Packit 6c4009
sysdeps/unix/sysv/linux
Packit 6c4009
sysdeps/gnu
Packit 6c4009
sysdeps/unix/common
Packit 6c4009
sysdeps/unix/mman
Packit 6c4009
sysdeps/unix/inet
Packit 6c4009
sysdeps/unix/sysv/i386/i686
Packit 6c4009
sysdeps/unix/sysv/i386
Packit 6c4009
sysdeps/unix/sysv
Packit 6c4009
sysdeps/unix/i386
Packit 6c4009
sysdeps/unix
Packit 6c4009
sysdeps/posix
Packit 6c4009
sysdeps/i386/i686
Packit 6c4009
sysdeps/i386/i486
Packit 6c4009
sysdeps/libm-i387/i686
Packit 6c4009
sysdeps/i386/fpu
Packit 6c4009
sysdeps/libm-i387
Packit 6c4009
sysdeps/i386
Packit 6c4009
sysdeps/wordsize-32
Packit 6c4009
sysdeps/ieee754
Packit 6c4009
sysdeps/libm-ieee754
Packit 6c4009
sysdeps/generic
Packit 6c4009
@end smallexample
Packit 6c4009
Packit 6c4009
Different machine architectures are conventionally subdirectories at the
Packit 6c4009
top level of the @file{sysdeps} directory tree.  For example,
Packit 6c4009
@w{@file{sysdeps/sparc}} and @w{@file{sysdeps/m68k}}.  These contain
Packit 6c4009
files specific to those machine architectures, but not specific to any
Packit 6c4009
particular operating system.  There might be subdirectories for
Packit 6c4009
specializations of those architectures, such as
Packit 6c4009
@w{@file{sysdeps/m68k/68020}}.  Code which is specific to the
Packit 6c4009
floating-point coprocessor used with a particular machine should go in
Packit 6c4009
@w{@file{sysdeps/@var{machine}/fpu}}.
Packit 6c4009
Packit 6c4009
There are a few directories at the top level of the @file{sysdeps}
Packit 6c4009
hierarchy that are not for particular machine architectures.
Packit 6c4009
Packit 6c4009
@table @file
Packit 6c4009
@item generic
Packit 6c4009
As described above (@pxref{Porting}), this is the subdirectory
Packit 6c4009
that every configuration implicitly uses after all others.
Packit 6c4009
Packit 6c4009
@item ieee754
Packit 6c4009
This directory is for code using the IEEE 754 floating-point format,
Packit 6c4009
where the C type @code{float} is IEEE 754 single-precision format, and
Packit 6c4009
@code{double} is IEEE 754 double-precision format.  Usually this
Packit 6c4009
directory is referred to in the @file{Implies} file in a machine
Packit 6c4009
architecture-specific directory, such as @file{m68k/Implies}.
Packit 6c4009
Packit 6c4009
@item libm-ieee754
Packit 6c4009
This directory contains an implementation of a mathematical library
Packit 6c4009
usable on platforms which use @w{IEEE 754} conformant floating-point
Packit 6c4009
arithmetic.
Packit 6c4009
Packit 6c4009
@item libm-i387
Packit 6c4009
This is a special case.  Ideally the code should be in
Packit 6c4009
@file{sysdeps/i386/fpu} but for various reasons it is kept aside.
Packit 6c4009
Packit 6c4009
@item posix
Packit 6c4009
This directory contains implementations of things in the library in
Packit 6c4009
terms of @sc{POSIX.1} functions.  This includes some of the @sc{POSIX.1}
Packit 6c4009
functions themselves.  Of course, @sc{POSIX.1} cannot be completely
Packit 6c4009
implemented in terms of itself, so a configuration using just
Packit 6c4009
@file{posix} cannot be complete.
Packit 6c4009
Packit 6c4009
@item unix
Packit 6c4009
This is the directory for Unix-like things.  @xref{Porting to Unix}.
Packit 6c4009
@file{unix} implies @file{posix}.  There are some special-purpose
Packit 6c4009
subdirectories of @file{unix}:
Packit 6c4009
Packit 6c4009
@table @file
Packit 6c4009
@item unix/common
Packit 6c4009
This directory is for things common to both BSD and System V release 4.
Packit 6c4009
Both @file{unix/bsd} and @file{unix/sysv/sysv4} imply @file{unix/common}.
Packit 6c4009
Packit 6c4009
@item unix/inet
Packit 6c4009
This directory is for @code{socket} and related functions on Unix systems.
Packit 6c4009
@file{unix/inet/Subdirs} enables the @file{inet} top-level subdirectory.
Packit 6c4009
@file{unix/common} implies @file{unix/inet}.
Packit 6c4009
@end table
Packit 6c4009
Packit 6c4009
@item mach
Packit 6c4009
This is the directory for things based on the Mach microkernel from CMU
Packit 6c4009
(including @gnuhurdsystems{}).  Other basic operating systems
Packit 6c4009
(VMS, for example) would have their own directories at the top level of
Packit 6c4009
the @file{sysdeps} hierarchy, parallel to @file{unix} and @file{mach}.
Packit 6c4009
@end table
Packit 6c4009
Packit 6c4009
@node Porting to Unix
Packit 6c4009
@appendixsubsec Porting @theglibc{} to Unix Systems
Packit 6c4009
Packit 6c4009
Most Unix systems are fundamentally very similar.  There are variations
Packit 6c4009
between different machines, and variations in what facilities are
Packit 6c4009
provided by the kernel.  But the interface to the operating system
Packit 6c4009
facilities is, for the most part, pretty uniform and simple.
Packit 6c4009
Packit 6c4009
The code for Unix systems is in the directory @file{unix}, at the top
Packit 6c4009
level of the @file{sysdeps} hierarchy.  This directory contains
Packit 6c4009
subdirectories (and subdirectory trees) for various Unix variants.
Packit 6c4009
Packit 6c4009
The functions which are system calls in most Unix systems are
Packit 6c4009
implemented in assembly code, which is generated automatically from
Packit 6c4009
specifications in files named @file{syscalls.list}.  There are several
Packit 6c4009
such files, one in @file{sysdeps/unix} and others in its subdirectories.
Packit 6c4009
Some special system calls are implemented in files that are named with a
Packit 6c4009
suffix of @samp{.S}; for example, @file{_exit.S}.  Files ending in
Packit 6c4009
@samp{.S} are run through the C preprocessor before being fed to the
Packit 6c4009
assembler.
Packit 6c4009
Packit 6c4009
These files all use a set of macros that should be defined in
Packit 6c4009
@file{sysdep.h}.  The @file{sysdep.h} file in @file{sysdeps/unix}
Packit 6c4009
partially defines them; a @file{sysdep.h} file in another directory must
Packit 6c4009
finish defining them for the particular machine and operating system
Packit 6c4009
variant.  See @file{sysdeps/unix/sysdep.h} and the machine-specific
Packit 6c4009
@file{sysdep.h} implementations to see what these macros are and what
Packit 6c4009
they should do.@refill
Packit 6c4009
Packit 6c4009
The system-specific makefile for the @file{unix} directory
Packit 6c4009
(@file{sysdeps/unix/Makefile}) gives rules to generate several files
Packit 6c4009
from the Unix system you are building the library on (which is assumed
Packit 6c4009
to be the target system you are building the library @emph{for}).  All
Packit 6c4009
the generated files are put in the directory where the object files are
Packit 6c4009
kept; they should not affect the source tree itself.  The files
Packit 6c4009
generated are @file{ioctls.h}, @file{errnos.h}, @file{sys/param.h}, and
Packit 6c4009
@file{errlist.c} (for the @file{stdio} section of the library).
Packit 6c4009
Packit 6c4009
@ignore
Packit 6c4009
@c This section might be a good idea if it is finished,
Packit 6c4009
@c but there's no point including it as it stands. --rms
Packit 6c4009
@c @appendixsec Compatibility with Traditional C
Packit 6c4009
Packit 6c4009
@c ??? This section is really short now.  Want to keep it? --roland
Packit 6c4009
Packit 6c4009
@c It's not anymore true.  glibc 2.1 cannot be used with K&R compilers.
Packit 6c4009
@c --drepper
Packit 6c4009
Packit 6c4009
Although @theglibc{} implements the @w{ISO C} library facilities, you
Packit 6c4009
@emph{can} use @theglibc{} with traditional, ``pre-ISO'' C
Packit 6c4009
compilers.  However, you need to be careful because the content and
Packit 6c4009
organization of the @glibcadj{} header files differs from that of
Packit 6c4009
traditional C implementations.  This means you may need to make changes
Packit 6c4009
to your program in order to get it to compile.
Packit 6c4009
@end ignore