Section 2.2. UNIX Standardization

team bbl


2.2. UNIX Standardization

2.2.1. ISO C

In late 1989, ANSI Standard X3.1591989 for the C programming language was approved. This standard has also been adopted as international standard ISO/IEC 9899:1990. ANSI is the American National Standards Institute, the U.S. member in the International Organization for Standardization (ISO). IEC stands for the International Electrotechnical Commission.

The C standard is now maintained and developed by the ISO/IEC international standardization working group for the C programming language, known as ISO/IEC JTC1/SC22/WG14, or WG14 for short. The intent of the ISO C standard is to provide portability of conforming C programs to a wide variety of operating systems, not only the UNIX System. This standard defines not only the syntax and semantics of the programming language but also a standard library [Chapter 7 of ISO 1999; Plauger 1992; Appendix B of Kernighan and Ritchie 1988]. This library is important because all contemporary UNIX systems, such as the ones described in this book, provide the library routines that are specified in the C standard.

In 1999, the ISO C standard was updated and approved as ISO/IEC 9899:1999, largely to improve support for applications that perform numerical processing. The changes don't affect the POSIX standards described in this book, except for the addition of the restrict keyword to some of the function prototypes. This keyword is used to tell the compiler which pointer references can be optimized, by indicating that the object to which the pointer refers is accessed in the function only via that pointer.

As with most standards, there is a delay between the standard's approval and the modification of software to conform to it. As each vendor's compilation systems evolve, they add more support for the latest version of the ISO C standard.

A summary of the current level of conformance of gcc to the 1999 version of the ISO C standard is available at http://www.gnu.org/software/gcc/c99status.html.

The ISO C library can be divided into 24 areas, based on the headers defined by the standard. Figure 2.1 lists the headers defined by the C standard. The POSIX.1 standard includes these headers, as well as others. We also list which of these headers are supported by the four implementations (FreeBSD 5.2.1, Linux 2.4.22, Mac OS X 10.3, and Solaris 9) that are described later in this chapter.

Figure 2.1. Headers defined by the ISO C standard

Header

FreeBSD 5.2.1

Linux 2.4.22

Mac OS X 10.3

Solaris 9

Description

<assert.h>

verify program assertion

<complex.h>

 

complex arithmetic support

<ctype.h>

character types

<errno.h>

error codes (Section 1.7)

<fenv.h>

 

 

floating-point environment

<float.h>

floating-point constants

<inttypes.h>

integer type format conversion

<iso646.h>

alternate relational operator macros

<limits.h>

implementation constants (Section 2.5)

<locale.h>

locale categories

<math.h>

mathematical constants

<setjmp.h>

nonlocal goto (Section 7.10)

<signal.h>

signals (Chapter 10)

<stdarg.h>

variable argument lists

<stdbool.h>

boolean type and values

<stddef.h>

standard definitions

<stdint.h>

 

integer types

<stdio.h>

standard I/O library (Chapter 5)

<stdlib.h>

utility functions

<string.h>

string operations

<tgmath.h>

 

  

type-generic math macros

<time.h>

time and date (Section 6.10)

<wchar.h>

extended multibyte and wide character support

<wctype.h>

wide character classification and mapping support


The ISO C headers depend on which version of the C compiler is used with the operating system. When considering Figure 2.1, note that FreeBSD 5.2.1 ships with version 3.3.3 of gcc, Solaris 9 ships with both version 2.95.3 and version 3.2 of gcc, Mandrake 9.2 (Linux 2.4.22) ships with version 3.3.1 of gcc, and Mac OS X 10.3 ships with version 3.3 of gcc. Mac OS X also includes older versions of gcc.

2.2.2. IEEE POSIX

POSIX is a family of standards developed by the IEEE (Institute of Electrical and Electronics Engineers). POSIX stands for Portable Operating System Interface. It originally referred only to the IEEE Standard 1003.11988the operating system interfacebut was later extended to include many of the standards and draft standards with the 1003 designation, including the shell and utilities (1003.2).

Of specific interest to this book is the 1003.1 operating system interface standard, whose goal is to promote the portability of applications among various UNIX System environments. This standard defines the services that must be provided by an operating system if it is to be "POSIX compliant," and has been adopted by most computer vendors. Although the 1003.1 standard is based on the UNIX operating system, the standard is not restricted to UNIX and UNIX-like systems. Indeed, some vendors supplying proprietary operating systems claim that these systems have been made POSIX compliant, while still leaving all their proprietary features in place.

Because the 1003.1 standard specifies an interface and not an implementation, no distinction is made between system calls and library functions. All the routines in the standard are called functions.

Standards are continually evolving, and the 1003.1 standard is no exception. The 1988 version of this standard, IEEE Standard 1003.11988, was modified and submitted to the International Organization for Standardization. No new interfaces or features were added, but the text was revised. The resulting document was published as IEEE Std 1003.11990 [IEEE 1990]. This is also the international standard ISO/IEC 99451:1990. This standard is commonly referred to as POSIX.1, which we'll use in this text.

The IEEE 1003.1 working group continued to make changes to the standard. In 1993, a revised version of the IEEE 1003.1 standard was published. It included 1003.1-1990 standard and the 1003.1b-1993 real-time extensions standard. In 1996, the standard was again updated as international standard ISO/IEC 99451:1996. It included interfaces for multithreaded programming, called pthreads for POSIX threads. More real-time interfaces were added in 1999 with the publication of IEEE Standard 1003.1d-1999. A year later, IEEE Standard 1003.1j-2000 was published, including even more real-time interfaces, and IEEE Standard 1003.1q-2000 was published, adding event-tracing extensions to the standard.

The 2001 version of 1003.1 departed from the prior versions in that it combined several 1003.1 amendments, the 1003.2 standard, and portions of the Single UNIX Specification (SUS), Version 2 (more on this later). The resulting standard, IEEE Standard 1003.1-2001, includes the following other standards:

  • ISO/IEC 9945-1 (IEEE Standard 1003.1-1996), which includes

    • IEEE Standard 1003.1-1990

    • IEEE Standard 1003.1b-1993 (real-time extensions)

    • IEEE Standard 1003.1c-1995 (pthreads)

    • IEEE Standard 1003.1i-1995 (real-time technical corrigenda)

  • IEEE P1003.1a draft standard (system interface revision)

  • IEEE Standard 1003.1d-1999 (advanced real-time extensions)

  • IEEE Standard 1003.1j-2000 (more advanced real-time extensions)

  • IEEE Standard 1003.1q-2000 (tracing)

  • IEEE Standard 1003.2d-1994 (batch extensions)

  • IEEE P1003.2b draft standard (additional utilities)

  • Parts of IEEE Standard 1003.1g-2000 (protocol-independent interfaces)

  • ISO/IEC 9945-2 (IEEE Standard 1003.2-1993)

  • The Base Specifications of the Single UNIX Specification, version 2, which include

    • System Interface Definitions, Issue 5

    • Commands and Utilities, Issue 5

    • System Interfaces and Headers, Issue 5

  • Open Group Technical Standard, Networking Services, Issue 5.2

  • ISO/IEC 9899:1999, Programming Languages - C

Figure 2.2, Figure 2.3, and Figure 2.4 summarize the required and optional headers as specified by POSIX.1. Because POSIX.1 includes the ISO C standard library functions, it also requires the headers listed in Figure 2.1. All four figures summarize which headers are included in the implementations discussed in this book.

Figure 2.2. Required headers defined by the POSIX standard

Header

FreeBSD 5.2.1

Linux 2.4.22

Mac OS X 10.3

Solaris 9

Description

<dirent.h>

directory entries (Section 4.21)

<fcntl.h>

file control (Section 3.14)

<fnmatch.h>

filename-matching types

<glob.h>

pathname pattern-matching types

<grp.h>

group file (Section 6.4)

<netdb.h>

network database operations

<pwd.h>

password file (Section 6.2)

<regex.h>

regular expressions

<tar.h>

tar archive values

<termios.h>

terminal I/O (Chapter 18)

<unistd.h>

symbolic constants

<utime.h>

file times (Section 4.19)

<wordexp.h>

 

word-expansion types

<arpa/inet.h>

Internet definitions (Chapter 16)

<net/if.h>

socket local interfaces (Chapter 16)

<netinet/in.h>

Internet address family (Section 16.3)

<netinet/tcp.h>

Transmission Control Protocol definitions

<sys/mman.h>

memory management declarations

<sys/select.h>

select function (Section 14.5.1)

<sys/socket.h>

sockets interface (Chapter 16)

<sys/stat.h>

file status (Chapter 4)

<sys/times.h>

process times (Section 8.16)

<sys/types.h>

primitive system data types (Section 2.8)

<sys/un.h>

UNIX domain socket definitions (Section 17.3)

<sys/utsname.h>

system name (Section 6.9)

<sys/wait.h>

process control (Section 8.6)


Figure 2.3. XSI extension headers defined by the POSIX standard

Header

FreeBSD 5.2.1

Linux 2.4.22

Mac OS X 10.3

Solaris 9

Description

<cpio.h>

 

cpio archive values

<dlfcn.h>

dynamic linking

<fmtmsg.h>

 

message display structures

<ftw.h>

 

 

file tree walking (Section 4.21)

<iconv.h>

 

codeset conversion utility

<langinfo.h>

language information constants

<libgen.h>

definitions for pattern-matching function

<monetary.h>

monetary types

<ndbm.h>

 

database operations

<nl_types.h>

message catalogs

<poll.h>

poll function (Section 14.5.2)

<search.h>

search tables

<strings.h>

string operations

<syslog.h>

system error logging (Section 13.4)

<ucontext.h>

user context

<ulimit.h>

user limits

<utmpx.h>

 

 

user accounting database

<sys/ipc.h>

IPC (Section 15.6)

<sys/msg.h>

 

message queues (Section 15.7)

<sys/resource.h>

resource operations (Section 7.11)

<sys/sem.h>

semaphores (Section 15.8)

<sys/shm.h>

shared memory (Section 15.9)

<sys/statvfs.h>

 

file system information

<sys/time.h>

time types

<sys/timeb.h>

additional date and time definitions

<sys/uio.h>

vector I/O operations (Section 14.7)


Figure 2.4. Optional headers defined by the POSIX standard

Header

FreeBSD 5.2.1

Linux 2.4.22

Mac OS X 10.3

Solaris 9

Description

<aio.h>

asynchronous I/O

<mqueue.h>

  

message queues

<pthread.h>

threads (Chapters 11 and 12)

<sched.h>

execution scheduling

<semaphore.h>

semaphores

<spawn.h>

 

  

real-time spawn interface

<stropts.h>

 

 

XSI STREAMS interface (Section 14.4)

<trace.h>

    

event tracing


In this text we describe the 2001 version of POSIX.1, which includes the functions specified in the ISO C standard. Its interfaces are divided into required ones and optional ones. The optional interfaces are further divided into 50 sections, based on functionality. The sections containing nonobsolete programming interfaces are summarized in Figure 2.5 with their respective option codes. Option codes are two- to three-character abbreviations that help identify the interfaces that belong to each functional area. The option codes highlight text on manual pages where interfaces depend on the support of a particular option. Many of the options deal with real-time extensions.

Figure 2.5. POSIX.1 optional interface groups and codes

Code

SUS mandatory

Symbolic constant

Description

ADV

 

_POSIX_ADVISORY_INFO

advisory information (real-time)

AIO

 

_POSIX_ASYNCHRONOUS_IO

asynchronous input and output (real-time)

BAR

 

_POSIX_BARRIERS

barriers (real-time)

CPT

 

_POSIX_CPUTIME

process CPU time clocks (real-time)

CS

 

_POSIX_CLOCK_SELECTION

clock selection (real-time)

CX

 

extension to ISO C standard

FSC

_POSIX_FSYNC

file synchronization

IP6

 

_POSIX_IPV6

IPv6 interfaces

MF

_POSIX_MAPPED_FILES

memory-mapped files

ML

 

_POSIX_MEMLOCK

process memory locking (real-time)

MLR

 

_POSIX_MEMLOCK_RANGE

memory range locking (real-time)

MON

 

_POSIX_MONOTONIC_CLOCK

monotonic clock (real-time)

MPR

_POSIX_MEMORY_PROTECTION

memory protection

MSG

 

_POSIX_MESSAGE_PASSING

message passing (real-time)

MX

  

IEC 60559 floating-point option

PIO

 

_POSIX_PRIORITIZED_IO

prioritized input and output

PS

 

_POSIX_PRIORITIZED_SCHEDULING

process scheduling (real-time)

RS

 

_POSIX_RAW_SOCKETS

raw sockets

RTS

 

_POSIX_REALTIME_SIGNALS

real-time signals extension

SEM

 

_POSIX_SEMAPHORES

semaphores (real-time)

SHM

 

_POSIX_SHARED_MEMORY_OBJECTS

shared memory objects (real-time)

SIO

 

_POSIX_SYNCHRONIZED_IO

synchronized input and output (real-time)

SPI

 

_POSIX_SPIN_LOCKS

spin locks (real-time)

SPN

 

_POSIX_SPAWN

spawn (real-time)

SS

 

_POSIX_SPORADIC_SERVER

process sporadic server (real-time)

TCT

 

_POSIX_THREAD_CPUTIME

thread CPU time clocks (real-time)

TEF

 

_POSIX_TRACE_EVENT_FILTER

trace event filter

THR

_POSIX_THREADS

threads

TMO

 

_POSIX_TIMEOUTS

timeouts (real-time)

TMR

 

_POSIX_TIMERS

timers (real-time)

TPI

 

_POSIX_THREAD_PRIO_INHERIT

thread priority inheritance (real-time)

TPP

 

_POSIX_THREAD_PRIO_PROTECT

thread priority protection (real-time)

TPS

 

_POSIX_THREAD_PRIORITY_SCHEDULING

thread execution scheduling (real-time)

TRC

 

_POSIX_TRACE

trace

TRI

 

_POSIX_TRACE_INHERIT

trace inherit

TRL

 

_POSIX_TRACE_LOG

trace log

TSA

_POSIX_THREAD_ATTR_STACKADDR

thread stack address attribute

TSF

_POSIX_THREAD_SAFE_FUNCTIONS

thread-safe functions

TSH

_POSIX_THREAD_PROCESS_SHARED

thread process-shared synchronization

TSP

 

_POSIX_THREAD_SPORADIC_SERVER

thread sporadic server (real-time)

TSS

_POSIX_THREAD_ATTR_STACKSIZE

thread stack address size

TYM

 

_POSIX_TYPED_MEMORY_OBJECTS

typed memory objects (real-time)

XSI

_XOPEN_UNIX

X/Open extended interfaces

XSR

 

_XOPEN_STREAMS

XSI STREAMS


POSIX.1 does not include the notion of a superuser. Instead, certain operations require "appropriate privileges," although POSIX.1 leaves the definition of this term up to the implementation. UNIX systems that conform to the Department of Defense security guidelines have many levels of security. In this text, however, we use the traditional terminology and refer to operations that require superuser privilege.

After almost twenty years of work, the standards are mature and stable. The POSIX.1 standard is maintained by an open working group known as the Austin Group (http://www.opengroup.org/austin). To ensure that they are still relevant, the standards need to be either updated or reaffirmed every so often.

2.2.3. The Single UNIX Specification

The Single UNIX Specification, a superset of the POSIX.1 standard, specifies additional interfaces that extend the functionality provided by the basic POSIX.1 specification. The complete set of system interfaces is called the X/Open System Interface (XSI). The _XOPEN_UNIX symbolic constant identifies interfaces that are part of the XSI extensions to the base POSIX.1 interfaces.

The XSI also defines which optional portions of POSIX.1 must be supported for an implementation to be deemed XSI conforming. These include file synchronization, memory-mapped files, memory protection, and thread interfaces, and are marked in Figure 2.5 as "SUS mandatory." Only XSI-conforming implementations can be called UNIX systems.

The Open Group owns the UNIX trademark and uses the Single UNIX Specification to define the interfaces an implementation must support to call itself a UNIX system. Implementations must file conformance statements, pass test suites that verify conformance, and license the right to use the UNIX trademark.

Some of the additional interfaces defined in the XSI are required, whereas others are optional. The interfaces are divided into option groups based on common functionality, as follows:

  • Encryption: denoted by the _XOPEN_CRYPT symbolic constant

  • Real-time: denoted by the _XOPEN_REALTIME symbolic constant

  • Advanced real-time

  • Real-time threads: denoted by the _XOPEN_REALTIME_THREADS symbolic constant

  • Advanced real-time threads

  • Tracing

  • XSI STREAMS: denoted by the _XOPEN_STREAMS symbolic constant

  • Legacy: denoted by the _XOPEN_LEGACY symbolic constant

The Single UNIX Specification (SUS) is a publication of The Open Group, which was formed in 1996 as a merger of X/Open and the Open Software Foundation (OSF), both industry consortia. X/Open used to publish the X/Open Portability Guide, which adopted specific standards and filled in the gaps where functionality was missing. The goal of these guides was to improve application portability past what was possible by merely conforming to published standards.

The first version of the Single UNIX Specification was published by X/Open in 1994. It was also known as "Spec 1170," because it contained roughly 1,170 interfaces. It grew out of the Common Open Software Environment (COSE) initiative, whose goal was to further improve application portability across all implementations of the UNIX operating system. The COSE groupSun, IBM, HP, Novell/USL, and OSFwent further than endorsing standards. In addition, they investigated interfaces used by common commercial applications. The resulting 1,170 interfaces were selected from these applications, and also included the X/Open Common Application Environment (CAE), Issue 4 (known as "XPG4" as a historical reference to its predecessor, the X/Open Portability Guide), the System V Interface Definition (SVID), Edition 3, Level 1 interfaces, and the OSF Application Environment Specification (AES) Full Use interfaces.

The second version of the Single UNIX Specification was published by The Open Group in 1997. The new version added support for threads, real-time interfaces, 64-bit processing, large files, and enhanced multibyte character processing.

The third version of the Single UNIX Specification (SUSv3, for short) was published by The Open Group in 2001. The Base Specifications of SUSv3 are the same as the IEEE Standard 1003.1-2001 and are divided into four sections: Base Definitions, System Interfaces, Shell and Utilities, and Rationale. SUSv3 also includes X/Open Curses Issue 4, Version 2, but this specification is not part of POSIX.1.

In 2002, ISO approved this version as International Standard ISO/IEC 9945:2002. The Open Group updated the 1003.1 standard again in 2003 to include technical corrections, and ISO approved this as International Standard ISO/IEC 9945:2003. In April 2004, The Open Group published the Single UNIX Specification, Version 3, 2004 Edition. It included more technical corrections edited in with the main text of the standard.

2.2.4. FIPS

FIPS stands for Federal Information Processing Standard. It was published by the U.S. government, which used it for the procurement of computer systems. FIPS 1511 (April 1989) was based on the IEEE Std. 1003.11988 and a draft of the ANSI C standard. This was followed by FIPS 1512 (May 1993), which was based on the IEEE Standard 1003.11990. FIPS 1512 required some features that POSIX.1 listed as optional. All these options have been included as mandatory in POSIX.1-2001.

The effect of the POSIX.1 FIPS was to require any vendor that wished to sell POSIX.1-compliant computer systems to the U.S. government to support some of the optional features of POSIX.1. The POSIX.1 FIPS has since been withdrawn, so we won't consider it further in this text.

    team bbl



    Advanced Programming in the UNIX Environment
    Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series)
    ISBN: 0321525949
    EAN: 2147483647
    Year: 2005
    Pages: 370

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net