f78 Definitions for OS interface Contents|Index|Previous|Next

Definitions for OS interface 

The following discussions describe the complete set of system definitions (primarily subroutines) required.

The examples shown implement the minimal functionality required to allow libc to link, failing gracefully where OS services are not available. Graceful failure is permitted by returning an error code. A minor complication arises here: the C library must be compatible with development environments that supply fully functional versions of these subroutines. Such environments usually return error codes in a global errno.

However, the GNUPro C library provides a macro definition for errno in the header file, errno.h, serving to support reentrant routines (see “Reentrancy” for more discussion). The bridge between these two interpretations of errno is straightforward: the C library routines with OS interface calls capture the errno values returned globally, recording them in the appropriate field of the reentrancy structure (so that you can query them using the errno macro from ‘errno.h).This mechanism becomes visible when you write stub routines for OS interfaces. You must include errno.h, then disable the macro, as in the following example.

#include <errno.h>
#undef errno
extern int errno;

The examples in the following documentation include the following treatment of errno.
 

0