Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

36 UNIX Standardization and Implementations Chapter 2


2.4 Relationship of Standards and Implementations


The standards that we’ve mentioned define a subset of any actual system. The focus of
this book is on four real systems: FreeBSD 8.0, Linux 3.2.0, Mac OS X 10.6.8, and Solaris


  1. Although only Mac OS X and Solaris can call themselves UNIX systems, all four
    provide a similar programming environment. Because all four arePOSIX compliant to
    varying degrees, we will also concentrate on the features required by the POSIX.1
    standard, noting any differences between POSIX and the actual implementations of
    these four systems. Those features and routines that arespecific to only a particular
    implementation areclearly marked. We’ll also note any features that arerequired on
    UNIX systems but areoptional on other POSIX-conforming systems.
    Be awarethat the implementations provide backwardcompatibility for features in
    earlier releases, such as SVR3.2 and 4.3BSD. For example, Solaris supports both the
    POSIX.1 specification for nonblocking I/O (O_NONBLOCK)and the traditional System V
    method (O_NDELAY). In this text, we’ll use only the POSIX.1 feature, although we’ll
    mention the nonstandardfeaturethat it replaces. Similarly,both SVR3.2 and 4.3BSD
    provided reliable signals in a way that differs from the POSIX.1 standard. In Chapter 10
    we describe only the POSIX.1 signal mechanism.


2.5 Limits


The implementations define many magic numbers and constants. Many of these have
been hardcoded into programs or weredetermined using ad hoc techniques.With the
various standardization efforts that we’ve described, moreportable methods arenow
provided to determine these magic numbers and implementation-defined limits, greatly
improving the portability of softwarewritten for the UNIX environment.
Twotypes of limits areneeded:


  1. Compile-time limits (e.g., what’s the largest value of a short integer?)

  2. Runtime limits (e.g., how many bytes in a filename?)
    Compile-time limits can be defined in headers that any program can include at compile
    time. Butruntime limits requirethe process to call a function to obtain the limit’s value.
    Additionally,some limits can be fixed on a given implementation—and could
    therefore be defined statically in a header—yet vary on another implementation and
    would requirearuntime function call. An example of this type of limit is the maximum
    number of bytes in a filename. BeforeSVR4, System V historically allowed only 14
    bytes in a filename, whereas BSD-derived systems increased this number to 255. Most
    UNIX System implementations these days support multiple file system types, and each
    type has its own limit. This is the case of a runtime limit that depends on where in the
    file system the file in question is located.Afilename in the root file system, for example,
    could have a 14-byte limit, whereas a filename in another file system could have a
    255 - byte limit.
    To solve these problems, three types of limits areprovided:

  3. Compile-time limits (headers)


http://www.allitebooks.com^

Free download pdf