/usr/share/doc/glibc-doc/html/libc_37.html is in glibc-doc 2.15-0ubuntu10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- This file documents the GNU C library.
This is Edition 0.13, last updated 2011-07-19,
of The GNU C Library Reference Manual, for version
2.14 (Ubuntu EGLIBC 2.15-0ubuntu10) .
Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
2003, 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software Needs Free Documentation"
and "GNU Lesser General Public License", the Front-Cover texts being
"A GNU Manual", and with the Back-Cover Texts as in (a) below. A
copy of the license is included in the section entitled "GNU Free
Documentation License".
(a) The FSF's Back-Cover Text is: "You have the freedom to
copy and modify this GNU manual. Buying copies from the FSF
supports it in developing GNU and promoting software freedom."
-->
<!-- Created on April 20, 2012 by texi2html 1.82
texi2html was written by:
Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>The GNU C Library: D. Library Maintenance</title>
<meta name="description" content="The GNU C Library: D. Library Maintenance">
<meta name="keywords" content="The GNU C Library: D. Library Maintenance">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.82">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Maintenance"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="libc_36.html#Reporting-Bugs" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Source-Layout" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="libc_36.html#Installation" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="libc.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="libc_38.html#Contributors" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="libc.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="libc_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="libc_42.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="libc_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Library-Maintenance"></a>
<h1 class="appendix">D. Library Maintenance</h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Source-Layout">D.1 Adding New Functions</a></td><td> </td><td align="left" valign="top"> How to add new functions or header files
to the GNU C library.
</td></tr>
<tr><td align="left" valign="top"><a href="#Porting">D.2 Porting the GNU C Library</a></td><td> </td><td align="left" valign="top"> How to port the GNU C library to
a new machine or operating system.
</td></tr>
</table>
<hr size="6">
<a name="Source-Layout"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Maintenance" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Porting" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Maintenance" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Maintenance" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="libc_38.html#Contributors" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="libc.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="libc_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="libc_42.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="libc_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Adding-New-Functions"></a>
<h2 class="appendixsec">D.1 Adding New Functions</h2>
<p>The process of building the library is driven by the makefiles, which
make heavy use of special features of GNU <code>make</code>. The makefiles
are very complex, and you probably don’t want to try to understand them.
But what they do is fairly straightforward, and only requires that you
define a few variables in the right places.
</p>
<p>The library sources are divided into subdirectories, grouped by topic.
</p>
<p>The ‘<tt>string</tt>’ subdirectory has all the string-manipulation
functions, ‘<tt>math</tt>’ has all the mathematical functions, etc.
</p>
<p>Each subdirectory contains a simple makefile, called ‘<tt>Makefile</tt>’,
which defines a few <code>make</code> variables and then includes the global
makefile ‘<tt>Rules</tt>’ with a line like:
</p>
<table><tr><td> </td><td><pre class="smallexample">include ../Rules
</pre></td></tr></table>
<p>The basic variables that a subdirectory makefile defines are:
</p>
<dl compact="compact">
<dt> <code>subdir</code></dt>
<dd><p>The name of the subdirectory, for example ‘<tt>stdio</tt>’.
This variable <strong>must</strong> be defined.
</p>
</dd>
<dt> <code>headers</code></dt>
<dd><p>The names of the header files in this section of the library,
such as ‘<tt>stdio.h</tt>’.
</p>
</dd>
<dt> <code>routines</code></dt>
<dt> <code>aux</code></dt>
<dd><p>The names of the modules (source files) in this section of the library.
These should be simple names, such as ‘<samp>strlen</samp>’ (rather than
complete file names, such as ‘<tt>strlen.c</tt>’). Use <code>routines</code> for
modules that define functions in the library, and <code>aux</code> for
auxiliary modules containing things like data definitions. But the
values of <code>routines</code> and <code>aux</code> are just concatenated, so there
really is no practical difference.
</p>
</dd>
<dt> <code>tests</code></dt>
<dd><p>The names of test programs for this section of the library. These
should be simple names, such as ‘<samp>tester</samp>’ (rather than complete file
names, such as ‘<tt>tester.c</tt>’). ‘<samp>make tests</samp>’ will build and
run all the test programs. If a test program needs input, put the test
data in a file called ‘<tt><var>test-program</var>.input</tt>’; it will be given to
the test program on its standard input. If a test program wants to be
run with arguments, put the arguments (all on a single line) in a file
called ‘<tt><var>test-program</var>.args</tt>’. Test programs should exit with
zero status when the test passes, and nonzero status when the test
indicates a bug in the library or error in building.
</p>
</dd>
<dt> <code>others</code></dt>
<dd><p>The names of “other” programs associated with this section of the
library. These are programs which are not tests per se, but are other
small programs included with the library. They are built by
‘<samp>make others</samp>’.
</p>
</dd>
<dt> <code>install-lib</code></dt>
<dt> <code>install-data</code></dt>
<dt> <code>install</code></dt>
<dd><p>Files to be installed by ‘<samp>make install</samp>’. Files listed in
‘<samp>install-lib</samp>’ are installed in the directory specified by
‘<samp>libdir</samp>’ in ‘<tt>configparms</tt>’ or ‘<tt>Makeconfig</tt>’
(see section <a href="libc_36.html#Installation">Installing the GNU C Library</a>). Files listed in <code>install-data</code> are
installed in the directory specified by ‘<samp>datadir</samp>’ in
‘<tt>configparms</tt>’ or ‘<tt>Makeconfig</tt>’. Files listed in <code>install</code>
are installed in the directory specified by ‘<samp>bindir</samp>’ in
‘<tt>configparms</tt>’ or ‘<tt>Makeconfig</tt>’.
</p>
</dd>
<dt> <code>distribute</code></dt>
<dd><p>Other files from this subdirectory which should be put into a
distribution tar file. You need not list here the makefile itself or
the source and header files listed in the other standard variables.
Only define <code>distribute</code> if there are files used in an unusual way
that should go into the distribution.
</p>
</dd>
<dt> <code>generated</code></dt>
<dd><p>Files which are generated by ‘<tt>Makefile</tt>’ in this subdirectory.
These files will be removed by ‘<samp>make clean</samp>’, and they will
never go into a distribution.
</p>
</dd>
<dt> <code>extra-objs</code></dt>
<dd><p>Extra object files which are built by ‘<tt>Makefile</tt>’ in this
subdirectory. This should be a list of file names like ‘<tt>foo.o</tt>’;
the files will actually be found in whatever directory object files are
being built in. These files will be removed by ‘<samp>make clean</samp>’.
This variable is used for secondary object files needed to build
<code>others</code> or <code>tests</code>.
</p></dd>
</dl>
<hr size="6">
<a name="Porting"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Source-Layout" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Hierarchy-Conventions" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Maintenance" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Maintenance" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="libc_38.html#Contributors" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="libc.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="libc_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="libc_42.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="libc_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Porting-the-GNU-C-Library"></a>
<h2 class="appendixsec">D.2 Porting the GNU C Library</h2>
<p>The GNU C library is written to be easily portable to a variety of
machines and operating systems. Machine- and operating system-dependent
functions are well separated to make it easy to add implementations for
new machines or operating systems. This section describes the layout of
the library source tree and explains the mechanisms used to select
machine-dependent code to use.
</p>
<p>All the machine-dependent and operating system-dependent files in the
library are in the subdirectory ‘<tt>sysdeps</tt>’ under the top-level
library source directory. This directory contains a hierarchy of
subdirectories (see section <a href="#Hierarchy-Conventions">Layout of the ‘<tt>sysdeps</tt>’ Directory Hierarchy</a>).
</p>
<p>Each subdirectory of ‘<tt>sysdeps</tt>’ contains source files for a
particular machine or operating system, or for a class of machine or
operating system (for example, systems by a particular vendor, or all
machines that use IEEE 754 floating-point format). A configuration
specifies an ordered list of these subdirectories. Each subdirectory
implicitly appends its parent directory to the list. For example,
specifying the list ‘<tt>unix/bsd/vax</tt>’ is equivalent to specifying the
list ‘<tt>unix/bsd/vax unix/bsd unix</tt>’. A subdirectory can also specify
that it implies other subdirectories which are not directly above it in
the directory hierarchy. If the file ‘<tt>Implies</tt>’ exists in a
subdirectory, it lists other subdirectories of ‘<tt>sysdeps</tt>’ which are
appended to the list, appearing after the subdirectory containing the
‘<tt>Implies</tt>’ file. Lines in an ‘<tt>Implies</tt>’ file that begin with a
‘<samp>#</samp>’ character are ignored as comments. For example,
‘<tt>unix/bsd/Implies</tt>’ contains:
</p><table><tr><td> </td><td><pre class="smallexample"># BSD has Internet-related things.
unix/inet
</pre></td></tr></table>
<p>and ‘<tt>unix/Implies</tt>’ contains:
</p><table><tr><td> </td><td><pre class="smallexample">posix
</pre></td></tr></table>
<p>So the final list is ‘<tt>unix/bsd/vax unix/bsd unix/inet unix posix</tt>’.
</p>
<p>‘<tt>sysdeps</tt>’ has a “special” subdirectory called ‘<tt>generic</tt>’. It
is always implicitly appended to the list of subdirectories, so you
needn’t put it in an ‘<tt>Implies</tt>’ file, and you should not create any
subdirectories under it intended to be new specific categories.
‘<tt>generic</tt>’ serves two purposes. First, the makefiles do not bother
to look for a system-dependent version of a file that’s not in
‘<tt>generic</tt>’. This means that any system-dependent source file must
have an analogue in ‘<tt>generic</tt>’, even if the routines defined by that
file are not implemented on other platforms. Second, the ‘<tt>generic</tt>’
version of a system-dependent file is used if the makefiles do not find
a version specific to the system you’re compiling for.
</p>
<p>If it is possible to implement the routines in a ‘<tt>generic</tt>’ file in
machine-independent C, using only other machine-independent functions in
the C library, then you should do so. Otherwise, make them stubs. A
<em>stub</em> function is a function which cannot be implemented on a
particular machine or operating system. Stub functions always return an
error, and set <code>errno</code> to <code>ENOSYS</code> (Function not implemented).
See section <a href="libc_2.html#Error-Reporting">Error Reporting</a>. If you define a stub function, you must place
the statement <code>stub_warning(<var>function</var>)</code>, where <var>function</var>
is the name of your function, after its definition; also, you must
include the file <code><stub-tag.h></code> into your file. This causes the
function to be listed in the installed <code><gnu/stubs.h></code>, and
makes GNU ld warn when the function is used.
</p>
<p>Some rare functions are only useful on specific systems and aren’t
defined at all on others; these do not appear anywhere in the
system-independent source code or makefiles (including the
‘<tt>generic</tt>’ directory), only in the system-dependent ‘<tt>Makefile</tt>’
in the specific system’s subdirectory.
</p>
<p>If you come across a file that is in one of the main source directories
(‘<tt>string</tt>’, ‘<tt>stdio</tt>’, etc.), and you want to write a machine- or
operating system-dependent version of it, move the file into
‘<tt>sysdeps/generic</tt>’ and write your new implementation in the
appropriate system-specific subdirectory. Note that if a file is to be
system-dependent, it <strong>must not</strong> appear in one of the main source
directories.
</p>
<p>There are a few special files that may exist in each subdirectory of
‘<tt>sysdeps</tt>’:
</p>
<dl compact="compact">
<dt> ‘<tt>Makefile</tt>’</dt>
<dd>
<p>A makefile for this machine or operating system, or class of machine or
operating system. This file is included by the library makefile
‘<tt>Makerules</tt>’, which is used by the top-level makefile and the
subdirectory makefiles. It can change the variables set in the
including makefile or add new rules. It can use GNU <code>make</code>
conditional directives based on the variable ‘<samp>subdir</samp>’ (see above) to
select different sets of variables and rules for different sections of
the library. It can also set the <code>make</code> variable
‘<samp>sysdep-routines</samp>’, to specify extra modules to be included in the
library. You should use ‘<samp>sysdep-routines</samp>’ rather than adding
modules to ‘<samp>routines</samp>’ because the latter is used in determining
what to distribute for each subdirectory of the main source tree.
</p>
<p>Each makefile in a subdirectory in the ordered list of subdirectories to
be searched is included in order. Since several system-dependent
makefiles may be included, each should append to ‘<samp>sysdep-routines</samp>’
rather than simply setting it:
</p>
<table><tr><td> </td><td><pre class="smallexample">sysdep-routines := $(sysdep-routines) foo bar
</pre></td></tr></table>
</dd>
<dt> ‘<tt>Subdirs</tt>’</dt>
<dd>
<p>This file contains the names of new whole subdirectories under the
top-level library source tree that should be included for this system.
These subdirectories are treated just like the system-independent
subdirectories in the library source tree, such as ‘<tt>stdio</tt>’ and
‘<tt>math</tt>’.
</p>
<p>Use this when there are completely new sets of functions and header
files that should go into the library for the system this subdirectory
of ‘<tt>sysdeps</tt>’ implements. For example,
‘<tt>sysdeps/unix/inet/Subdirs</tt>’ contains ‘<tt>inet</tt>’; the ‘<tt>inet</tt>’
directory contains various network-oriented operations which only make
sense to put in the library on systems that support the Internet.
</p>
</dd>
<dt> ‘<tt>configure</tt>’</dt>
<dd>
<p>This file is a shell script fragment to be run at configuration time.
The top-level ‘<tt>configure</tt>’ script uses the shell <code>.</code> command to
read the ‘<tt>configure</tt>’ file in each system-dependent directory
chosen, in order. The ‘<tt>configure</tt>’ files are often generated from
‘<tt>configure.in</tt>’ files using Autoconf.
</p>
<p>A system-dependent ‘<tt>configure</tt>’ script will usually add things to
the shell variables ‘<samp>DEFS</samp>’ and ‘<samp>config_vars</samp>’; see the
top-level ‘<tt>configure</tt>’ script for details. The script can check for
‘<samp>--with-<var>package</var></samp>’ options that were passed to the
top-level ‘<tt>configure</tt>’. For an option
‘<samp>--with-<var>package</var>=<var>value</var></samp>’ ‘<tt>configure</tt>’ sets the
shell variable ‘<samp>with_<var>package</var></samp>’ (with any dashes in
<var>package</var> converted to underscores) to <var>value</var>; if the option is
just ‘<samp>--with-<var>package</var></samp>’ (no argument), then it sets
‘<samp>with_<var>package</var></samp>’ to ‘<samp>yes</samp>’.
</p>
</dd>
<dt> ‘<tt>configure.in</tt>’</dt>
<dd>
<p>This file is an Autoconf input fragment to be processed into the file
‘<tt>configure</tt>’ in this subdirectory. See <a href="../autoconf/Introduction.html#Introduction">(autoconf.info)Introduction</a> section ‘Introduction’ in <cite>Autoconf: Generating Automatic Configuration Scripts</cite>,
for a description of Autoconf. You should write either ‘<tt>configure</tt>’
or ‘<tt>configure.in</tt>’, but not both. The first line of
‘<tt>configure.in</tt>’ should invoke the <code>m4</code> macro
‘<samp>GLIBC_PROVIDES</samp>’. This macro does several <code>AC_PROVIDE</code> calls
for Autoconf macros which are used by the top-level ‘<tt>configure</tt>’
script; without this, those macros might be invoked again unnecessarily
by Autoconf.
</p></dd>
</dl>
<p>That is the general system for how system-dependencies are isolated.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Hierarchy-Conventions">D.2.1 Layout of the ‘<tt>sysdeps</tt>’ Directory Hierarchy</a></td><td> </td><td align="left" valign="top"> The layout of the ‘<tt>sysdeps</tt>’ hierarchy.
</td></tr>
<tr><td align="left" valign="top"><a href="#Porting-to-Unix">D.2.2 Porting the GNU C Library to Unix Systems</a></td><td> </td><td align="left" valign="top"> Porting the library to an average
Unix-like system.
</td></tr>
</table>
<hr size="6">
<a name="Hierarchy-Conventions"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Porting" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#Porting-to-Unix" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Maintenance" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Porting" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="libc_38.html#Contributors" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="libc.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="libc_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="libc_42.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="libc_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Layout-of-the-sysdeps-Directory-Hierarchy"></a>
<h3 class="appendixsubsec">D.2.1 Layout of the ‘<tt>sysdeps</tt>’ Directory Hierarchy</h3>
<p>A GNU configuration name has three parts: the CPU type, the
manufacturer’s name, and the operating system. ‘<tt>configure</tt>’ uses
these to pick the list of system-dependent directories to look for. If
the ‘<samp>--nfp</samp>’ option is <em>not</em> passed to ‘<tt>configure</tt>’, the
directory ‘<tt><var>machine</var>/fpu</tt>’ is also used. The operating system
often has a <em>base operating system</em>; for example, if the operating
system is ‘<samp>Linux</samp>’, the base operating system is ‘<samp>unix/sysv</samp>’.
The algorithm used to pick the list of directories is simple:
‘<tt>configure</tt>’ makes a list of the base operating system,
manufacturer, CPU type, and operating system, in that order. It then
concatenates all these together with slashes in between, to produce a
directory name; for example, the configuration ‘<samp>i686-linux-gnu</samp>’
results in ‘<tt>unix/sysv/linux/i386/i686</tt>’. ‘<tt>configure</tt>’ then
tries removing each element of the list in turn, so
‘<tt>unix/sysv/linux</tt>’ and ‘<tt>unix/sysv</tt>’ are also tried, among others.
Since the precise version number of the operating system is often not
important, and it would be very inconvenient, for example, to have
identical ‘<tt>irix6.2</tt>’ and ‘<tt>irix6.3</tt>’ directories,
‘<tt>configure</tt>’ tries successively less specific operating system names
by removing trailing suffixes starting with a period.
</p>
<p>As an example, here is the complete list of directories that would be
tried for the configuration ‘<samp>i686-linux-gnu</samp>’ (with the
‘<tt>crypt</tt>’ and ‘<tt>linuxthreads</tt>’ add-on):
</p>
<table><tr><td> </td><td><pre class="smallexample">sysdeps/i386/elf
crypt/sysdeps/unix
linuxthreads/sysdeps/unix/sysv/linux
linuxthreads/sysdeps/pthread
linuxthreads/sysdeps/unix/sysv
linuxthreads/sysdeps/unix
linuxthreads/sysdeps/i386/i686
linuxthreads/sysdeps/i386
linuxthreads/sysdeps/pthread/no-cmpxchg
sysdeps/unix/sysv/linux/i386
sysdeps/unix/sysv/linux
sysdeps/gnu
sysdeps/unix/common
sysdeps/unix/mman
sysdeps/unix/inet
sysdeps/unix/sysv/i386/i686
sysdeps/unix/sysv/i386
sysdeps/unix/sysv
sysdeps/unix/i386
sysdeps/unix
sysdeps/posix
sysdeps/i386/i686
sysdeps/i386/i486
sysdeps/libm-i387/i686
sysdeps/i386/fpu
sysdeps/libm-i387
sysdeps/i386
sysdeps/wordsize-32
sysdeps/ieee754
sysdeps/libm-ieee754
sysdeps/generic
</pre></td></tr></table>
<p>Different machine architectures are conventionally subdirectories at the
top level of the ‘<tt>sysdeps</tt>’ directory tree. For example,
‘<tt>sysdeps/sparc</tt>’ and ‘<tt>sysdeps/m68k</tt>’. These contain
files specific to those machine architectures, but not specific to any
particular operating system. There might be subdirectories for
specializations of those architectures, such as
‘<tt>sysdeps/m68k/68020</tt>’. Code which is specific to the
floating-point coprocessor used with a particular machine should go in
‘<tt>sysdeps/<var>machine</var>/fpu</tt>’.
</p>
<p>There are a few directories at the top level of the ‘<tt>sysdeps</tt>’
hierarchy that are not for particular machine architectures.
</p>
<dl compact="compact">
<dt> ‘<tt>generic</tt>’</dt>
<dd><p>As described above (see section <a href="#Porting">Porting the GNU C Library</a>), this is the subdirectory
that every configuration implicitly uses after all others.
</p>
</dd>
<dt> ‘<tt>ieee754</tt>’</dt>
<dd><p>This directory is for code using the IEEE 754 floating-point format,
where the C type <code>float</code> is IEEE 754 single-precision format, and
<code>double</code> is IEEE 754 double-precision format. Usually this
directory is referred to in the ‘<tt>Implies</tt>’ file in a machine
architecture-specific directory, such as ‘<tt>m68k/Implies</tt>’.
</p>
</dd>
<dt> ‘<tt>libm-ieee754</tt>’</dt>
<dd><p>This directory contains an implementation of a mathematical library
usable on platforms which use IEEE 754 conformant floating-point
arithmetic.
</p>
</dd>
<dt> ‘<tt>libm-i387</tt>’</dt>
<dd><p>This is a special case. Ideally the code should be in
‘<tt>sysdeps/i386/fpu</tt>’ but for various reasons it is kept aside.
</p>
</dd>
<dt> ‘<tt>posix</tt>’</dt>
<dd><p>This directory contains implementations of things in the library in
terms of <small>POSIX.1</small> functions. This includes some of the <small>POSIX.1</small>
functions themselves. Of course, <small>POSIX.1</small> cannot be completely
implemented in terms of itself, so a configuration using just
‘<tt>posix</tt>’ cannot be complete.
</p>
</dd>
<dt> ‘<tt>unix</tt>’</dt>
<dd><p>This is the directory for Unix-like things. See section <a href="#Porting-to-Unix">Porting the GNU C Library to Unix Systems</a>.
‘<tt>unix</tt>’ implies ‘<tt>posix</tt>’. There are some special-purpose
subdirectories of ‘<tt>unix</tt>’:
</p>
<dl compact="compact">
<dt> ‘<tt>unix/common</tt>’</dt>
<dd><p>This directory is for things common to both BSD and System V release 4.
Both ‘<tt>unix/bsd</tt>’ and ‘<tt>unix/sysv/sysv4</tt>’ imply ‘<tt>unix/common</tt>’.
</p>
</dd>
<dt> ‘<tt>unix/inet</tt>’</dt>
<dd><p>This directory is for <code>socket</code> and related functions on Unix systems.
‘<tt>unix/inet/Subdirs</tt>’ enables the ‘<tt>inet</tt>’ top-level subdirectory.
‘<tt>unix/common</tt>’ implies ‘<tt>unix/inet</tt>’.
</p></dd>
</dl>
</dd>
<dt> ‘<tt>mach</tt>’</dt>
<dd><p>This is the directory for things based on the Mach microkernel from CMU
(including the GNU operating system). Other basic operating systems
(VMS, for example) would have their own directories at the top level of
the ‘<tt>sysdeps</tt>’ hierarchy, parallel to ‘<tt>unix</tt>’ and ‘<tt>mach</tt>’.
</p></dd>
</dl>
<hr size="6">
<a name="Porting-to-Unix"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Hierarchy-Conventions" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="libc_38.html#Contributors" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#Maintenance" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#Porting" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="libc_38.html#Contributors" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="libc.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="libc_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="libc_42.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="libc_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Porting-the-GNU-C-Library-to-Unix-Systems"></a>
<h3 class="appendixsubsec">D.2.2 Porting the GNU C Library to Unix Systems</h3>
<p>Most Unix systems are fundamentally very similar. There are variations
between different machines, and variations in what facilities are
provided by the kernel. But the interface to the operating system
facilities is, for the most part, pretty uniform and simple.
</p>
<p>The code for Unix systems is in the directory ‘<tt>unix</tt>’, at the top
level of the ‘<tt>sysdeps</tt>’ hierarchy. This directory contains
subdirectories (and subdirectory trees) for various Unix variants.
</p>
<p>The functions which are system calls in most Unix systems are
implemented in assembly code, which is generated automatically from
specifications in files named ‘<tt>syscalls.list</tt>’. There are several
such files, one in ‘<tt>sysdeps/unix</tt>’ and others in its subdirectories.
Some special system calls are implemented in files that are named with a
suffix of ‘<samp>.S</samp>’; for example, ‘<tt>_exit.S</tt>’. Files ending in
‘<samp>.S</samp>’ are run through the C preprocessor before being fed to the
assembler.
</p>
<p>These files all use a set of macros that should be defined in
‘<tt>sysdep.h</tt>’. The ‘<tt>sysdep.h</tt>’ file in ‘<tt>sysdeps/unix</tt>’
partially defines them; a ‘<tt>sysdep.h</tt>’ file in another directory must
finish defining them for the particular machine and operating system
variant. See ‘<tt>sysdeps/unix/sysdep.h</tt>’ and the machine-specific
‘<tt>sysdep.h</tt>’ implementations to see what these macros are and what
they should do.
</p>
<p>The system-specific makefile for the ‘<tt>unix</tt>’ directory
(‘<tt>sysdeps/unix/Makefile</tt>’) gives rules to generate several files
from the Unix system you are building the library on (which is assumed
to be the target system you are building the library <em>for</em>). All
the generated files are put in the directory where the object files are
kept; they should not affect the source tree itself. The files
generated are ‘<tt>ioctls.h</tt>’, ‘<tt>errnos.h</tt>’, ‘<tt>sys/param.h</tt>’, and
‘<tt>errlist.c</tt>’ (for the ‘<tt>stdio</tt>’ section of the library).
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Maintenance" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="libc_38.html#Contributors" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="libc.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="libc_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="libc_42.html#Concept-Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="libc_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>root</em> on <em>April 20, 2012</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
</font>
<br>
</p>
</body>
</html>
|