Change all _ISxxx to _ISwxxx.
[glibc.git] / manual / maint.texi
blob2d241533f68b9a423d57b994c9e1700bd20ce61d
1 @c \input /gd/gnu/doc/texinfo
2 @c This is for making the `INSTALL' file for the distribution.
3 @c Makeinfo ignores it when processing the file from the include.
4 @setfilename INSTALL
6 @node Maintenance, Copying, Library Summary, Top
7 @appendix Library Maintenance
9 @menu
10 * Installation::          How to configure, compile and
11                              install the GNU C library.
12 * Reporting Bugs::        How to report bugs (if you want to
13                              get them fixed) and other troubles
14                              you may have with the GNU C library.
15 * Source Layout::         How to add new functions or header files
16                              to the GNU C library.
17 * Porting::               How to port the GNU C library to
18                              a new machine or operating system.
19 * Contributors::          Contributors to the GNU C Library.
20 @end menu
22 @node Installation
23 @appendixsec How to Install the GNU C Library
24 @cindex installing the library
26 Installation of the GNU C library is relatively simple, but usually
27 requires several GNU tools to be installed already.
28 @iftex
29 (@pxref{Tools for Installation}, below.)
30 @end iftex
32 @menu
33 * Tools for Installation::      We recommend using these tools to build.
34 * Supported Configurations::    What systems the GNU C library runs on.
35 @end menu
37 To configure the GNU C library for your system, run the shell script
38 @file{configure} with @code{sh}.  Use an argument which is the
39 conventional GNU name for your system configuration---for example,
40 @samp{sparc-sun-sunos4.1}, for a Sun 4 running SunOS 4.1.
41 @xref{Installation, Installation, Installing GNU CC, gcc.info, Using and
42 Porting GNU CC}, for a full description of standard GNU configuration
43 names.  If you omit the configuration name, @file{configure} will try to
44 guess one for you by inspecting the system it is running on.  It may or
45 may not be able to come up with a guess, and the its guess might be
46 wrong.  @file{configure} will tell you the canonical name of the chosen
47 configuration before proceeding.
49 Here are some options that you should specify (if appropriate) when
50 you run @code{configure}:
52 @table @samp
53 @item --with-gnu-ld
54 Use this option if you plan to use GNU @code{ld} to link programs with
55 the GNU C Library.  (We strongly recommend that you do.)  This option
56 enables use of features that exist only in GNU @code{ld}; so if you
57 configure for GNU @code{ld} you must use GNU @code{ld} @emph{every time}
58 you link with the GNU C Library, and when building it.
60 @item --with-gnu-as
61 Use this option if you plan to use the GNU assembler, @code{gas}, when
62 building the GNU C Library.  On some systems, the library may not build
63 properly if you do @emph{not} use @code{gas}.
65 @item --with-gnu-binutils
66 This option implies both @w{@samp{--with-gnu-ld}} and @w{@samp{--with-gnu-as}}.
67 On systems where GNU tools are the system tools, there is no need to
68 specify this option.  These include GNU, GNU/Linux, and free BSD systems.
70 @c extra blank line makes it look better
71 @item --without-fp
72 @itemx --nfp
74 Use this option if your computer lacks hardware floating-point support.
76 @item --prefix=@var{directory}
77 Install machine-independent data files in subdirectories of
78 @file{@var{directory}}.  (You can also set this in @file{configparms};
79 see below.)
81 @item --exec-prefix=@var{directory}
82 Install the library and other machine-dependent files in subdirectories
83 of @file{@var{directory}}.  (You can also set this in
84 @file{configparms}; see below.)
86 @item --enable-shared
87 @itemx --disable-shared
88 Enable or disable building of an ELF shared library on systems that
89 support it.  The default is to build the shared library on systems using
90 ELF when the GNU @code{binutils} are available.
92 @item --enable-profile
93 @itemx --disable-profile
94 Enable or disable building of the profiled C library, @samp{-lc_p}.  The
95 default is to build the profiled library.  You may wish to disable it if
96 you don't plan to do profiling, because it doubles the build time of
97 compiling just the unprofiled static library.
99 @item --enable-omitfp
100 Enable building a highly-optimized but possibly undebuggable static C
101 library.  This causes the normal static and shared (if enabled) C
102 libraries to be compiled with maximal optimization, including the
103 @samp{-fomit-frame-pointer} switch that makes debugging impossible on
104 many machines, and without debugging information (which makes the
105 binaries substantially smaller).  An additional static library is
106 compiled with no optimization and full debugging information, and
107 installed as @samp{-lc_g}.
108 @end table
110 The simplest way to run @code{configure} is to do it in the directory
111 that contains the library sources.  This prepares to build the library
112 in that very directory.
114 You can prepare to build the library in some other directory by going
115 to that other directory to run @code{configure}.  In order to run
116 configure, you will have to specify a directory for it, like this:
118 @smallexample
119 mkdir sun4
120 cd sun4
121 ../configure sparc-sun-sunos4.1
122 @end smallexample
124 @noindent
125 @code{configure} looks for the sources in whatever directory you
126 specified for finding @code{configure} itself.  It does not matter where
127 in the file system the source and build directories are---as long as you
128 specify the source directory when you run @code{configure}, you will get
129 the proper results.
131 This feature lets you keep sources and binaries in different
132 directories, and that makes it easy to build the library for several
133 different machines from the same set of sources.  Simply create a
134 build directory for each target machine, and run @code{configure} in
135 that directory specifying the target machine's configuration name.
137 The library has a number of special-purpose configuration parameters.
138 These are defined in the file @file{Makeconfig}; see the comments in
139 that file for the details.
141 But don't edit the file @file{Makeconfig} yourself---instead, create a
142 file @file{configparms} in the directory where you are building the
143 library, and define in that file the parameters you want to specify.
144 @file{configparms} should @strong{not} be an edited copy of
145 @file{Makeconfig}; specify only the parameters that you want to
146 override.  To see how to set these parameters, find the section of
147 @file{Makeconfig} that says ``These are the configuration variables.''
148 Then for each parameter that you want to change, copy the definition
149 from @file{Makeconfig} to your new @file{configparms} file, and change
150 the value as appropriate for your system.
152 It is easy to configure the GNU C library for cross-compilation by
153 setting a few variables in @file{configparms}.  Set @code{CC} to the
154 cross-compiler for the target you configured the library for; it is
155 important to use this same @code{CC} value when running
156 @code{configure}, like this: @samp{CC=@var{target}-gcc configure
157 @var{target}}.  Set @code{BUILD_CC} to the compiler to use for for
158 programs run on the build system as part of compiling the library.  You
159 may need to set @code{AR} and @code{RANLIB} to cross-compiling versions
160 of @code{ar} and @code{ranlib} if the native tools are not configured to
161 work with object files for the target you configured for.
163 Some of the machine-dependent code for some machines uses extensions in
164 the GNU C compiler, so you may need to compile the library with GCC.
165 (In fact, all of the existing complete ports require GCC.)
168 To build the library and related programs, type @code{make}.  This will
169 produce a lot of output, some of which may look like errors from
170 @code{make} (but isn't).  Look for error messages from @code{make}
171 containing @samp{***}.  Those indicate that something is really wrong.
173 To build and run some test programs which exercise some of the library
174 facilities, type @code{make check}.  This will produce several files
175 with names like @file{@var{program}.out}.
177 To format the @cite{GNU C Library Reference Manual} for printing, type
178 @w{@code{make dvi}}.  You need a working TeX installation to do this.
180 To install the library and its header files, and the Info files of the
181 manual, type @code{make install}.  This will build things if necessary,
182 before installing them.  If you want to install the files in a different
183 place than the one specified at configuration time you can specify a
184 value for the Makefile variable @code{install_root} on the command line.
185 This is useful to create chroot'ed environment or to prepare binary
186 releases.@refill
188 @node Tools for Installation
189 @appendixsubsec Recommended Tools to Install the GNU C Library
190 @cindex installation tools
191 @cindex tools, for installing library
193 We recommend installing the following GNU tools before attempting to
194 build the GNU C library:
196 @itemize @bullet
197 @item
198 @code{make} 3.75
200 You need the latest version of GNU @code{make}.  Modifying the GNU C
201 Library to work with other @code{make} programs would be so hard that we
202 recommend you port GNU @code{make} instead.  @strong{Really.}
203 We recommend version GNU @code{make} version 3.75.  Versions 3.76 and
204 3.76.1 are known to have bugs which only show up in big projects like
205 GNU @code{libc}.
207 @item
208 GCC 2.7.2
210 On most platforms, the GNU C library can only be compiled with the GNU C
211 compiler.  We recommend GCC version 2.7.2 or later; earlier versions may
212 have problems.
214 @item
215 @code{binutils} 2.8.1
217 Using the GNU @code{binutils} (assembler, linker, and related tools) is
218 preferable when possible, and they are required to build an ELF shared C
219 library.  We recommend @code{binutils} version 2.8 or later; earlier
220 versions are known to have problems or to not support all architectures.
222 @item
223 @code{texinfo} 3.11
225 To correctly translate and install the Texinfo documentation you need
226 this version of the @code{texinfo} package.  Former versions did not
227 understand all the tags used in the document and also the installation
228 mechanisms for the info files was not present or worked differently.
230 On some Debian Linux based systems the used @code{install-info} program
231 works differently.  Here you have to run make like this:
233 @smallexample
234 make INSTALL_INFO=/path/to/GNU/install-info install
235 @end smallexample
236 @end itemize
238 @node Supported Configurations
239 @appendixsubsec Supported Configurations
240 @cindex configurations, all supported
242 The GNU C Library currently supports configurations that match the
243 following patterns:
245 @smallexample
246 alpha-@var{anything}-linux
247 i@var{x}86-@var{anything}-gnu
248 i@var{x}86-@var{anything}-linux
249 m68k-@var{anything}-linux
250 @end smallexample
252 Former releases of this library (version 1.09.1 and perhaps earlier
253 versions) used to run on the following configurations:
255 @smallexample
256 alpha-dec-osf1
257 i@var{x}86-@var{anything}-bsd4.3
258 i@var{x}86-@var{anything}-isc2.2
259 i@var{x}86-@var{anything}-isc3.@var{n}
260 i@var{x}86-@var{anything}-sco3.2
261 i@var{x}86-@var{anything}-sco3.2v4
262 i@var{x}86-@var{anything}-sysv
263 i@var{x}86-@var{anything}-sysv4
264 i@var{x}86-force_cpu386-none
265 i@var{x}86-sequent-bsd
266 i960-nindy960-none
267 m68k-hp-bsd4.3
268 m68k-mvme135-none
269 m68k-mvme136-none
270 m68k-sony-newsos3
271 m68k-sony-newsos4
272 m68k-sun-sunos4.@var{n}
273 mips-dec-ultrix4.@var{n}
274 mips-sgi-irix4.@var{n}
275 sparc-sun-solaris2.@var{n}
276 sparc-sun-sunos4.@var{n}
277 @end smallexample
279 Since no one has volunteered to test and fix the above configurations,
280 these are not supported at the moment.  It's expected that these don't
281 work anymore.  Porting the library is not hard.  If you are interested
282 in doing a port, please contact the glibc maintainers by sending
283 electronic mail to @email{bug-glibc@@prep.ai.mit.edu}.
285 Each case of @samp{i@var{x}86} can be @samp{i386}, @samp{i486},
286 @samp{i586}, or @samp{i686}.  All of those configurations produce a
287 library that can run on any of these processors.  The library will be
288 optimized for the specified processor, but will not use instructions not
289 available on all of them.
291 While no other configurations are supported, there are handy aliases for
292 these few.  (These aliases work in other GNU software as well.)
294 @smallexample
295 decstation
296 hp320-bsd4.3 hp300bsd
297 i486-gnu
298 i586-linux
299 i386-sco
300 i386-sco3.2v4
301 i386-sequent-dynix
302 i386-svr4
303 news
304 sun3-sunos4.@var{n} sun3
305 sun4-solaris2.@var{n} sun4-sunos5.@var{n}
306 sun4-sunos4.@var{n} sun4
307 @end smallexample
309 @node Reporting Bugs
310 @appendixsec Reporting Bugs
311 @cindex reporting bugs
312 @cindex bugs, reporting
314 There are probably bugs in the GNU C library.  There are certainly
315 errors and omissions in this manual.  If you report them, they will get
316 fixed.  If you don't, no one will ever know about them and they will
317 remain unfixed for all eternity, if not longer.
319 To report a bug, first you must find it.  Hopefully, this will be the
320 hard part.  Once you've found a bug, make sure it's really a bug.  A
321 good way to do this is to see if the GNU C library behaves the same way
322 some other C library does.  If so, probably you are wrong and the
323 libraries are right (but not necessarily).  If not, one of the libraries
324 is probably wrong.
326 Once you're sure you've found a bug, try to narrow it down to the
327 smallest test case that reproduces the problem.  In the case of a C
328 library, you really only need to narrow it down to one library
329 function call, if possible.  This should not be too difficult.
331 The final step when you have a simple test case is to report the bug.
332 When reporting a bug, send your test case, the results you got, the
333 results you expected, what you think the problem might be (if you've
334 thought of anything), your system type, and the version of the GNU C
335 library which you are using.  Also include the files
336 @file{config.status} and @file{config.make} which are created by running
337 @file{configure}; they will be in whatever directory was current when
338 you ran @file{configure}.
340 If you think you have found some way in which the GNU C library does not
341 conform to the ISO and POSIX standards (@pxref{Standards and
342 Portability}), that is definitely a bug.  Report it!@refill
344 Send bug reports to the Internet address
345 @email{bug-glibc@@prep.ai.mit.edu} or the UUCP path
346 @email{mit-eddie!prep.ai.mit.edu!bug-glibc}.  If you have other problems
347 with installation or use, please report those as well.@refill
349 If you are not sure how a function should behave, and this manual
350 doesn't tell you, that's a bug in the manual.  Report that too!  If the
351 function's behavior disagrees with the manual, then either the library
352 or the manual has a bug, so report the disagreement.  If you find any
353 errors or omissions in this manual, please report them to the Internet
354 address @email{bug-glibc-manual@@prep.ai.mit.edu} or the UUCP path
355 @email{mit-eddie!prep.ai.mit.edu!bug-glibc-manual}.
357 @node Source Layout
358 @appendixsec Adding New Functions
360 The process of building the library is driven by the makefiles, which
361 make heavy use of special features of GNU @code{make}.  The makefiles
362 are very complex, and you probably don't want to try to understand them.
363 But what they do is fairly straightforward, and only requires that you
364 define a few variables in the right places.
366 The library sources are divided into subdirectories, grouped by topic.
368 The @file{string} subdirectory has all the string-manipulation
369 functions, @file{math} has all the mathematical functions, etc.
371 Each subdirectory contains a simple makefile, called @file{Makefile},
372 which defines a few @code{make} variables and then includes the global
373 makefile @file{Rules} with a line like:
375 @smallexample
376 include ../Rules
377 @end smallexample
379 @noindent
380 The basic variables that a subdirectory makefile defines are:
382 @table @code
383 @item subdir
384 The name of the subdirectory, for example @file{stdio}.
385 This variable @strong{must} be defined.
387 @item headers
388 The names of the header files in this section of the library,
389 such as @file{stdio.h}.
391 @item routines
392 @itemx aux
393 The names of the modules (source files) in this section of the library.
394 These should be simple names, such as @samp{strlen} (rather than
395 complete file names, such as @file{strlen.c}).  Use @code{routines} for
396 modules that define functions in the library, and @code{aux} for
397 auxiliary modules containing things like data definitions.  But the
398 values of @code{routines} and @code{aux} are just concatenated, so there
399 really is no practical difference.@refill
401 @item tests
402 The names of test programs for this section of the library.  These
403 should be simple names, such as @samp{tester} (rather than complete file
404 names, such as @file{tester.c}).  @w{@samp{make tests}} will build and
405 run all the test programs.  If a test program needs input, put the test
406 data in a file called @file{@var{test-program}.input}; it will be given to
407 the test program on its standard input.  If a test program wants to be
408 run with arguments, put the arguments (all on a single line) in a file
409 called @file{@var{test-program}.args}.  Test programs should exit with
410 zero status when the test passes, and nonzero status when the test
411 indicates a bug in the library or error in building.
413 @item others
414 The names of ``other'' programs associated with this section of the
415 library.  These are programs which are not tests per se, but are other
416 small programs included with the library.  They are built by
417 @w{@samp{make others}}.@refill
419 @item install-lib
420 @itemx install-data
421 @itemx install
422 Files to be installed by @w{@samp{make install}}.  Files listed in
423 @samp{install-lib} are installed in the directory specified by
424 @samp{libdir} in @file{configparms} or @file{Makeconfig}
425 (@pxref{Installation}).  Files listed in @code{install-data} are
426 installed in the directory specified by @samp{datadir} in
427 @file{configparms} or @file{Makeconfig}.  Files listed in @code{install}
428 are installed in the directory specified by @samp{bindir} in
429 @file{configparms} or @file{Makeconfig}.@refill
431 @item distribute
432 Other files from this subdirectory which should be put into a
433 distribution tar file.  You need not list here the makefile itself or
434 the source and header files listed in the other standard variables.
435 Only define @code{distribute} if there are files used in an unusual way
436 that should go into the distribution.
438 @item generated
439 Files which are generated by @file{Makefile} in this subdirectory.
440 These files will be removed by @w{@samp{make clean}}, and they will
441 never go into a distribution.
443 @item extra-objs
444 Extra object files which are built by @file{Makefile} in this
445 subdirectory.  This should be a list of file names like @file{foo.o};
446 the files will actually be found in whatever directory object files are
447 being built in.  These files will be removed by @w{@samp{make clean}}.
448 This variable is used for secondary object files needed to build
449 @code{others} or @code{tests}.
450 @end table
452 @node Porting
453 @appendixsec Porting the GNU C Library
455 The GNU C library is written to be easily portable to a variety of
456 machines and operating systems.  Machine- and operating system-dependent
457 functions are well separated to make it easy to add implementations for
458 new machines or operating systems.  This section describes the layout of
459 the library source tree and explains the mechanisms used to select
460 machine-dependent code to use.
462 All the machine-dependent and operating system-dependent files in the
463 library are in the subdirectory @file{sysdeps} under the top-level
464 library source directory.  This directory contains a hierarchy of
465 subdirectories (@pxref{Hierarchy Conventions}).
467 Each subdirectory of @file{sysdeps} contains source files for a
468 particular machine or operating system, or for a class of machine or
469 operating system (for example, systems by a particular vendor, or all
470 machines that use IEEE 754 floating-point format).  A configuration
471 specifies an ordered list of these subdirectories.  Each subdirectory
472 implicitly appends its parent directory to the list.  For example,
473 specifying the list @file{unix/bsd/vax} is equivalent to specifying the
474 list @file{unix/bsd/vax unix/bsd unix}.  A subdirectory can also specify
475 that it implies other subdirectories which are not directly above it in
476 the directory hierarchy.  If the file @file{Implies} exists in a
477 subdirectory, it lists other subdirectories of @file{sysdeps} which are
478 appended to the list, appearing after the subdirectory containing the
479 @file{Implies} file.  Lines in an @file{Implies} file that begin with a
480 @samp{#} character are ignored as comments.  For example,
481 @file{unix/bsd/Implies} contains:@refill
482 @smallexample
483 # BSD has Internet-related things.
484 unix/inet
485 @end smallexample
486 @noindent
487 and @file{unix/Implies} contains:
488 @need 300
489 @smallexample
490 posix
491 @end smallexample
493 @noindent
494 So the final list is @file{unix/bsd/vax unix/bsd unix/inet unix posix}.
496 @file{sysdeps} has two ``special'' subdirectories, called @file{generic}
497 and @file{stub}.  These two are always implicitly appended to the list
498 of subdirectories (in that order), so you needn't put them in an
499 @file{Implies} file, and you should not create any subdirectories under
500 them intended to be new specific categories.  @file{generic} is for
501 things that can be implemented in machine-independent C, using only
502 other machine-independent functions in the C library.  @file{stub} is
503 for @dfn{stub} versions of functions which cannot be implemented on a
504 particular machine or operating system.  The stub functions always
505 return an error, and set @code{errno} to @code{ENOSYS} (Function not
506 implemented).  @xref{Error Reporting}.
508 A source file is known to be system-dependent by its having a version in
509 @file{generic} or @file{stub}; every generally-available function whose
510 implementation is system-dependent in should have either a generic or
511 stub implementation (there is no point in having both).  Some rare functions
512 are only useful on specific systems and aren't defined at all on others;
513 these do not appear anywhere in the system-independent source code or makefiles
514 (including the @file{generic} and @file{stub} directories), only in the
515 system-dependent @file{Makefile} in the specific system's subdirectory.
517 If you come across a file that is in one of the main source directories
518 (@file{string}, @file{stdio}, etc.), and you want to write a machine- or
519 operating system-dependent version of it, move the file into
520 @file{sysdeps/generic} and write your new implementation in the
521 appropriate system-specific subdirectory.  Note that if a file is to be
522 system-dependent, it @strong{must not} appear in one of the main source
523 directories.@refill
525 There are a few special files that may exist in each subdirectory of
526 @file{sysdeps}:
528 @comment Blank lines after items make the table look better.
529 @table @file
530 @item Makefile
532 A makefile for this machine or operating system, or class of machine or
533 operating system.  This file is included by the library makefile
534 @file{Makerules}, which is used by the top-level makefile and the
535 subdirectory makefiles.  It can change the variables set in the
536 including makefile or add new rules.  It can use GNU @code{make}
537 conditional directives based on the variable @samp{subdir} (see above) to
538 select different sets of variables and rules for different sections of
539 the library.  It can also set the @code{make} variable
540 @samp{sysdep-routines}, to specify extra modules to be included in the
541 library.  You should use @samp{sysdep-routines} rather than adding
542 modules to @samp{routines} because the latter is used in determining
543 what to distribute for each subdirectory of the main source tree.@refill
545 Each makefile in a subdirectory in the ordered list of subdirectories to
546 be searched is included in order.  Since several system-dependent
547 makefiles may be included, each should append to @samp{sysdep-routines}
548 rather than simply setting it:
550 @smallexample
551 sysdep-routines := $(sysdep-routines) foo bar
552 @end smallexample
554 @need 1000
555 @item Subdirs
557 This file contains the names of new whole subdirectories under the
558 top-level library source tree that should be included for this system.
559 These subdirectories are treated just like the system-independent
560 subdirectories in the library source tree, such as @file{stdio} and
561 @file{math}.
563 Use this when there are completely new sets of functions and header
564 files that should go into the library for the system this subdirectory
565 of @file{sysdeps} implements.  For example,
566 @file{sysdeps/unix/inet/Subdirs} contains @file{inet}; the @file{inet}
567 directory contains various network-oriented operations which only make
568 sense to put in the library on systems that support the Internet.@refill
570 @item Dist
572 This file contains the names of files (relative to the subdirectory of
573 @file{sysdeps} in which it appears) which should be included in the
574 distribution.  List any new files used by rules in the @file{Makefile}
575 in the same directory, or header files used by the source files in that
576 directory.  You don't need to list files that are implementations
577 (either C or assembly source) of routines whose names are given in the
578 machine-independent makefiles in the main source tree.
580 @item configure
582 This file is a shell script fragment to be run at configuration time.
583 The top-level @file{configure} script uses the shell @code{.} command to
584 read the @file{configure} file in each system-dependent directory
585 chosen, in order.  The @file{configure} files are often generated from
586 @file{configure.in} files using Autoconf.
588 A system-dependent @file{configure} script will usually add things to
589 the shell variables @samp{DEFS} and @samp{config_vars}; see the
590 top-level @file{configure} script for details.  The script can check for
591 @w{@samp{--with-@var{package}}} options that were passed to the
592 top-level @file{configure}.  For an option
593 @w{@samp{--with-@var{package}=@var{value}}} @file{configure} sets the
594 shell variable @w{@samp{with_@var{package}}} (with any dashes in
595 @var{package} converted to underscores) to @var{value}; if the option is
596 just @w{@samp{--with-@var{package}}} (no argument), then it sets
597 @w{@samp{with_@var{package}}} to @samp{yes}.
599 @item configure.in
601 This file is an Autoconf input fragment to be processed into the file
602 @file{configure} in this subdirectory.  @xref{Introduction,,,
603 autoconf.info, Autoconf: Generating Automatic Configuration Scripts},
604 for a description of Autoconf.  You should write either @file{configure}
605 or @file{configure.in}, but not both.  The first line of
606 @file{configure.in} should invoke the @code{m4} macro
607 @samp{GLIBC_PROVIDES}.  This macro does several @code{AC_PROVIDE} calls
608 for Autoconf macros which are used by the top-level @file{configure}
609 script; without this, those macros might be invoked again unnecessarily
610 by Autoconf.
611 @end table
613 That is the general system for how system-dependencies are isolated.
614 @iftex
615 The next section explains how to decide what directories in
616 @file{sysdeps} to use.  @ref{Porting to Unix}, has some tips on porting
617 the library to Unix variants.
618 @end iftex
620 @menu
621 * Hierarchy Conventions::       The layout of the @file{sysdeps} hierarchy.
622 * Porting to Unix::             Porting the library to an average
623                                    Unix-like system.
624 @end menu
626 @node Hierarchy Conventions
627 @appendixsubsec Layout of the @file{sysdeps} Directory Hierarchy
629 A GNU configuration name has three parts: the CPU type, the
630 manufacturer's name, and the operating system.  @file{configure} uses
631 these to pick the list of system-dependent directories to look for.  If
632 the @samp{--nfp} option is @emph{not} passed to @file{configure}, the
633 directory @file{@var{machine}/fpu} is also used.  The operating system
634 often has a @dfn{base operating system}; for example, if the operating
635 system is @samp{sunos4.1}, the base operating system is @samp{unix/bsd}.
636 The algorithm used to pick the list of directories is simple:
637 @file{configure} makes a list of the base operating system,
638 manufacturer, CPU type, and operating system, in that order.  It then
639 concatenates all these together with slashes in between, to produce a
640 directory name; for example, the configuration @w{@samp{sparc-sun-sunos4.1}}
641 results in @file{unix/bsd/sun/sparc/sunos4.1}.  @file{configure} then
642 tries removing each element of the list in turn, so
643 @file{unix/bsd/sparc} and @file{sun/sparc} are also tried, among others.
644 Since the precise version number of the operating system is often not
645 important, and it would be very inconvenient, for example, to have
646 identical @file{sunos4.1.1} and @file{sunos4.1.2} directories,
647 @file{configure} tries successively less specific operating system names
648 by removing trailing suffixes starting with a period.
650 As an example, here is the complete list of directories that would be
651 tried for the configuration @w{@samp{sparc-sun-sunos4.1}} (without the
652 @w{@samp{--nfp}} option):
654 @smallexample
655 sparc/fpu
656 unix/bsd/sun/sunos4.1/sparc
657 unix/bsd/sun/sunos4.1
658 unix/bsd/sun/sunos4/sparc
659 unix/bsd/sun/sunos4
660 unix/bsd/sun/sunos/sparc
661 unix/bsd/sun/sunos
662 unix/bsd/sun/sparc
663 unix/bsd/sun
664 unix/bsd/sunos4.1/sparc
665 unix/bsd/sunos4.1
666 unix/bsd/sunos4/sparc
667 unix/bsd/sunos4
668 unix/bsd/sunos/sparc
669 unix/bsd/sunos
670 unix/bsd/sparc
671 unix/bsd
672 unix/sun/sunos4.1/sparc
673 unix/sun/sunos4.1
674 unix/sun/sunos4/sparc
675 unix/sun/sunos4
676 unix/sun/sunos/sparc
677 unix/sun/sunos
678 unix/sun/sparc
679 unix/sun
680 unix/sunos4.1/sparc
681 unix/sunos4.1
682 unix/sunos4/sparc
683 unix/sunos4
684 unix/sunos/sparc
685 unix/sunos
686 unix/sparc
687 unix
688 sun/sunos4.1/sparc
689 sun/sunos4.1
690 sun/sunos4/sparc
691 sun/sunos4
692 sun/sunos/sparc
693 sun/sunos
694 sun/sparc
696 sunos4.1/sparc
697 sunos4.1
698 sunos4/sparc
699 sunos4
700 sunos/sparc
701 sunos
702 sparc
703 @end smallexample
705 Different machine architectures are conventionally subdirectories at the
706 top level of the @file{sysdeps} directory tree.  For example,
707 @w{@file{sysdeps/sparc}} and @w{@file{sysdeps/m68k}}.  These contain
708 files specific to those machine architectures, but not specific to any
709 particular operating system.  There might be subdirectories for
710 specializations of those architectures, such as
711 @w{@file{sysdeps/m68k/68020}}. Code which is specific to the
712 floating-point coprocessor used with a particular machine should go in
713 @w{@file{sysdeps/@var{machine}/fpu}}.
715 There are a few directories at the top level of the @file{sysdeps}
716 hierarchy that are not for particular machine architectures.
718 @table @file
719 @item generic
720 @itemx stub
721 As described above (@pxref{Porting}), these are the two subdirectories
722 that every configuration implicitly uses after all others.
724 @item ieee754
725 This directory is for code using the IEEE 754 floating-point format,
726 where the C type @code{float} is IEEE 754 single-precision format, and
727 @code{double} is IEEE 754 double-precision format.  Usually this
728 directory is referred to in the @file{Implies} file in a machine
729 architecture-specific directory, such as @file{m68k/Implies}.
731 @item posix
732 This directory contains implementations of things in the library in
733 terms of @sc{POSIX.1} functions.  This includes some of the @sc{POSIX.1}
734 functions themselves.  Of course, @sc{POSIX.1} cannot be completely
735 implemented in terms of itself, so a configuration using just
736 @file{posix} cannot be complete.
738 @item unix
739 This is the directory for Unix-like things.  @xref{Porting to Unix}.
740 @file{unix} implies @file{posix}.  There are some special-purpose
741 subdirectories of @file{unix}:
743 @table @file
744 @item unix/common
745 This directory is for things common to both BSD and System V release 4.
746 Both @file{unix/bsd} and @file{unix/sysv/sysv4} imply @file{unix/common}.
748 @item unix/inet
749 This directory is for @code{socket} and related functions on Unix systems.
750 The @file{inet} top-level subdirectory is enabled by @file{unix/inet/Subdirs}.
751 @file{unix/common} implies @file{unix/inet}.
752 @end table
754 @item mach
755 This is the directory for things based on the Mach microkernel from CMU
756 (including the GNU operating system).  Other basic operating systems
757 (VMS, for example) would have their own directories at the top level of
758 the @file{sysdeps} hierarchy, parallel to @file{unix} and @file{mach}.
759 @end table
761 @node Porting to Unix
762 @appendixsubsec Porting the GNU C Library to Unix Systems
764 Most Unix systems are fundamentally very similar.  There are variations
765 between different machines, and variations in what facilities are
766 provided by the kernel.  But the interface to the operating system
767 facilities is, for the most part, pretty uniform and simple.
769 The code for Unix systems is in the directory @file{unix}, at the top
770 level of the @file{sysdeps} hierarchy.  This directory contains
771 subdirectories (and subdirectory trees) for various Unix variants.
773 The functions which are system calls in most Unix systems are
774 implemented in assembly code in files in @file{sysdeps/unix}.  These
775 files are named with a suffix of @samp{.S}; for example,
776 @file{__open.S}.  Files ending in @samp{.S} are run through the C
777 preprocessor before being fed to the assembler.
779 These files all use a set of macros that should be defined in
780 @file{sysdep.h}.  The @file{sysdep.h} file in @file{sysdeps/unix}
781 partially defines them; a @file{sysdep.h} file in another directory must
782 finish defining them for the particular machine and operating system
783 variant.  See @file{sysdeps/unix/sysdep.h} and the machine-specific
784 @file{sysdep.h} implementations to see what these macros are and what
785 they should do.@refill
787 The system-specific makefile for the @file{unix} directory (that is, the
788 file @file{sysdeps/unix/Makefile}) gives rules to generate several files
789 from the Unix system you are building the library on (which is assumed
790 to be the target system you are building the library @emph{for}).  All
791 the generated files are put in the directory where the object files are
792 kept; they should not affect the source tree itself.  The files
793 generated are @file{ioctls.h}, @file{errnos.h}, @file{sys/param.h}, and
794 @file{errlist.c} (for the @file{stdio} section of the library).
796 @ignore
797 @c This section might be a good idea if it is finished,
798 @c but there's no point including it as it stands. --rms
799 @c @appendixsec Compatibility with Traditional C
801 @c ??? This section is really short now.  Want to keep it? --roland
803 Although the GNU C library implements the @w{ISO C} library facilities, you
804 @emph{can} use the GNU C library with traditional, ``pre-ISO'' C
805 compilers.  However, you need to be careful because the content and
806 organization of the GNU C library header files differs from that of
807 traditional C implementations.  This means you may need to make changes
808 to your program in order to get it to compile.
809 @end ignore
811 @node Contributors
812 @appendixsec Contributors to the GNU C Library
814 The GNU C library was written originally by Roland McGrath.  Some parts
815 of the library were contributed or worked on by other people.
817 @itemize @bullet
818 @item
819 The @code{getopt} function and related code were written by
820 Richard Stallman, @w{David J. MacKenzie}, and @w{Roland McGrath}.
822 @item
823 The merge sort function @code{qsort} was written by Michael J. Haertel.
825 @item
826 The quick sort function used as a fallback by @code{qsort} was written
827 by Douglas C. Schmidt.
829 @item
830 The memory allocation functions @code{malloc}, @code{realloc} and
831 @code{free} and related code were written by Michael J. Haertel.
833 @comment tege's name has an umlaut.
834 @tex
835 \xdef\SETtege{Torbj\"orn Granlund}
836 @end tex
837 @ifinfo
838 @set tege Torbjorn Granlund
839 @end ifinfo
840 @item
841 Fast implementations of many of the string functions (@code{memcpy},
842 @code{strlen}, etc.) were written by @value{tege}.
844 @item
845 The @file{tar.h} header file was written by David J. MacKenzie.
847 @item
848 The port to the MIPS DECStation running Ultrix 4
849 (@code{mips-dec-ultrix4})
850 was contributed by Brendan Kehoe and Ian Lance Taylor.
852 @item
853 The DES encryption function @code{crypt} and related functions were
854 contributed by Michael Glad.
856 @item
857 The @code{ftw} function was contributed by Ian Lance Taylor.
859 @item
860 The startup code to support SunOS shared libraries was contributed by
861 Tom Quinn.
863 @item
864 The @code{mktime} function was contributed by Paul Eggert.
866 @item
867 The port to the Sequent Symmetry running Dynix version 3
868 (@code{i386-sequent-bsd}) was contributed by Jason Merrill.
870 @item
871 The timezone support code is derived from the public-domain timezone
872 package by Arthur David Olson and his many contributors.
874 @item
875 The port to the DEC Alpha running OSF/1 (@code{alpha-dec-osf1}) was
876 contributed by Brendan Kehoe, using some code written by Roland McGrath.
878 @item
879 The port to SGI machines running Irix 4 (@code{mips-sgi-irix4}) was
880 contributed by Tom Quinn.
882 @item
883 The port of the Mach and Hurd code to the MIPS architecture
884 (@code{mips-@var{anything}-gnu}) was contributed by Kazumoto Kojima.
886 @item
887 The floating-point printing function used by @code{printf} and friends
888 and the floating-point reading function used by @code{scanf},
889 @code{strtod} and friends were written by Ulrich Drepper.  The
890 multi-precision integer functions used in those functions are taken from
891 GNU MP, which was contributed by @value{tege}.
893 @item
894 The internationalization support in the library, and the support
895 programs @code{locale} and @code{localedef}, were written by Ulrich
896 Drepper.  Ulrich Drepper adapted the support code for message catalogs
897 (@file{libintl.h}, etc.) from the GNU @code{gettext} package, which he
898 also wrote.  He also contributed the @code{catgets} support and the
899 entire suite of multi-byte and wide-character support functions
900 (@file{wctype.h}, @file{wchar.h}, etc.).
902 @item
903 The implementations of the @file{nsswitch.conf} mechanism and the files
904 and DNS backends for it were designed and written by Ulrich Drepper and
905 Roland McGrath, based on a backend interface defined by Peter Eriksson.
907 @item
908 The port to Linux i386/ELF (@code{i386-@var{anything}-linux}) was
909 contributed by Ulrich Drepper, based in large part on work done in
910 Hongjiu Lu's Linux version of the GNU C Library.
912 @item
913 The port to Linux/m68k (@code{m68k-@var{anything}-linux}) was
914 contributed by Andreas Schwab.
916 @item
917 Richard Henderson contributed the ELF dynamic linking code and other
918 support for the Alpha processor.
920 @item
921 David Mosberger-Tang contributed the port to Linux/Alpha
922 (@code{alpha-@var{anything}-linux}).
924 @item
925 Stephen R. van den Berg contributed a highly-optimized @code{strstr} function.
927 @item
928 Ulrich Drepper contributed the @code{hsearch} and @code{drand48}
929 families of functions; reentrant @samp{@dots{}@code{_r}} versions of the
930 @code{random} family; System V shared memory and IPC support code; and
931 several highly-optimized string functions for i@var{x}86 processors.
933 @item
934 The math functions are taken from @code{fdlibm-5.1} by Sun
935 Microsystems, as modified by J.T. Conklin, Ian Lance Taylor,
936 Ulrich Drepper, Andreas Schwab, and Roland McGrath.
938 @item
939 The @code{libio} library used to implement @code{stdio} functions on
940 some platforms was written by Per Bothner and modified by Ulrich Drepper.
942 @item
943 The Internet-related code (most of the @file{inet} subdirectory) and
944 several other miscellaneous functions and header files have been
945 included from 4.4 BSD with little or no modification.
947 All code incorporated from 4.4 BSD is under the following copyright:
949 @quotation
950 @display
951 Copyright @copyright{} 1991 Regents of the University of California.
952 All rights reserved.
953 @end display
955 Redistribution and use in source and binary forms, with or without
956 modification, are permitted provided that the following conditions
957 are met:
959 @enumerate
960 @item
961 Redistributions of source code must retain the above copyright
962 notice, this list of conditions and the following disclaimer.
963 @item
964 Redistributions in binary form must reproduce the above copyright
965 notice, this list of conditions and the following disclaimer in the
966 documentation and/or other materials provided with the distribution.
967 @item
968 All advertising materials mentioning features or use of this software
969 must display the following acknowledgement:
970 @quotation
971 This product includes software developed by the University of
972 California, Berkeley and its contributors.
973 @end quotation
974 @item
975 Neither the name of the University nor the names of its contributors
976 may be used to endorse or promote products derived from this software
977 without specific prior written permission.
978 @end enumerate
980 @sc{this software is provided by the regents and contributors ``as is'' and
981 any express or implied warranties, including, but not limited to, the
982 implied warranties of merchantability and fitness for a particular purpose
983 are disclaimed.  in no event shall the regents or contributors be liable
984 for any direct, indirect, incidental, special, exemplary, or consequential
985 damages (including, but not limited to, procurement of substitute goods
986 or services; loss of use, data, or profits; or business interruption)
987 however caused and on any theory of liability, whether in contract, strict
988 liability, or tort (including negligence or otherwise) arising in any way
989 out of the use of this software, even if advised of the possibility of
990 such damage.}
991 @end quotation
993 @item
994 The random number generation functions @code{random}, @code{srandom},
995 @code{setstate} and @code{initstate}, which are also the basis for the
996 @code{rand} and @code{srand} functions, were written by Earl T. Cohen
997 for the University of California at Berkeley and are copyrighted by the
998 Regents of the University of California.  They have undergone minor
999 changes to fit into the GNU C library and to fit the @w{ISO C} standard,
1000 but the functional code is Berkeley's.@refill
1002 @item
1003 The Internet resolver code is taken directly from BIND 4.9.5, which is
1004 under both the Berkeley copyright above and also:
1006 @quotation
1007 Portions Copyright @copyright{} 1993 by Digital Equipment Corporation.
1009 Permission to use, copy, modify, and distribute this software for any
1010 purpose with or without fee is hereby granted, provided that the above
1011 copyright notice and this permission notice appear in all copies, and
1012 that the name of Digital Equipment Corporation not be used in
1013 advertising or publicity pertaining to distribution of the document or
1014 software without specific, written prior permission.
1016 @sc{the software is provided ``as is'' and digital equipment corp.
1017 disclaims all warranties with regard to this software, including all
1018 implied warranties of merchantability and fitness.  in no event shall
1019 digital equipment corporation be liable for any special, direct,
1020 indirect, or consequential damages or any damages whatsoever resulting
1021 from loss of use, data or profits, whether in an action of contract,
1022 negligence or other tortious action, arising out of or in connection
1023 with the use or performance of this software.}
1024 @end quotation
1026 @item
1027 The code to support Sun RPC is taken verbatim from Sun's
1028 @w{@sc{rpcsrc-4.0}} distribution, and is covered by this copyright:
1030 @quotation
1031 @display
1032 Copyright @copyright{} 1984, Sun Microsystems, Inc.
1033 @end display
1035 Sun RPC is a product of Sun Microsystems, Inc. and is provided for
1036 unrestricted use provided that this legend is included on all tape media
1037 and as a part of the software program in whole or part.  Users may copy
1038 or modify Sun RPC without charge, but are not authorized to license or
1039 distribute it to anyone else except as part of a product or program
1040 developed by the user.
1042 @sc{sun rpc is provided as is with no warranties of any kind including the
1043 warranties of design, merchantibility and fitness for a particular
1044 purpose, or arising from a course of dealing, usage or trade practice.}
1046 Sun RPC is provided with no support and without any obligation on the
1047 part of Sun Microsystems, Inc. to assist in its use, correction,
1048 modification or enhancement.
1050 @sc{sun microsystems, inc. shall have no liability with respect to the
1051 infringement of copyrights, trade secrets or any patents by sun rpc
1052 or any part thereof.}
1054 In no event will Sun Microsystems, Inc. be liable for any lost revenue
1055 or profits or other special, indirect and consequential damages, even if
1056 Sun has been advised of the possibility of such damages.
1058 @display
1059 Sun Microsystems, Inc.
1060 2550 Garcia Avenue
1061 Mountain View, California  94043
1062 @end display
1063 @end quotation
1065 @item
1066 Some of the support code for Mach is taken from Mach 3.0 by CMU,
1067 and is under the following copyright terms:
1069 @quotation
1070 @display
1071 Mach Operating System
1072 Copyright @copyright{} 1991,1990,1989 Carnegie Mellon University
1073 All Rights Reserved.
1074 @end display
1076 Permission to use, copy, modify and distribute this software and its
1077 documentation is hereby granted, provided that both the copyright
1078 notice and this permission notice appear in all copies of the
1079 software, derivative works or modified versions, and any portions
1080 thereof, and that both notices appear in supporting documentation.
1082 @sc{carnegie mellon allows free use of this software in its ``as is''
1083 condition.  carnegie mellon disclaims any liability of any kind for
1084 any damages whatsoever resulting from the use of this software.}
1086 Carnegie Mellon requests users of this software to return to
1088 @display
1089  Software Distribution Coordinator
1090  School of Computer Science
1091  Carnegie Mellon University
1092  Pittsburgh PA 15213-3890
1093 @end display
1095 @noindent
1096 or @email{Software.Distribution@@CS.CMU.EDU} any improvements or
1097 extensions that they make and grant Carnegie Mellon the rights to
1098 redistribute these changes.
1099 @end quotation
1101 @end itemize
1103 @c @bye