POSIX Wrapper Functions

The libzk library has been enhanced with a number of functions that aim to bridge the gap between the POSIX functionality that much of the ZK core libraries expect, and the reality of having to support platforms that are not in any way POSIX-compliant, for example Mac OS and to a lesser extent Win32.

The enhancements can be grouped into a number of overlapping categories:

  • Functions that exist in both the Standard C library and POSIX. In many cases, POSIX specifies additional semantics upon which the core libraries depend. For example, Standard C defines only a handful of functions as setting errno, whereas in POSIX most functions set errno. The wrapper functions in this case set errno when an error occurs on non-POSIX platforms.
     
  • Functions that do no exist in the Standard C library. Examples include socket calls and unbuffered I/O calls (eg, open(), read(), write(), close()).
     
  • Functions that exist on all supported platforms, but whose entire POSIX-defined functionality has not been implemented on every platform for one reason or another. For example, in POSIX one can call read() on a socket; however, the matching POSIX wrapper function can only be called portably on file descriptors. In this case, the documentation for the function will describe any applicable restrictions on usage.
     
  • Functions that require a different implementation in kernel space. In this case, the POSIX wrapper function will call through to a kernel-specific function when ZK_KERNEL is defined.
  • Below is a list of headers whose contents have been "wrapped" by functions in libzk. There is a link to a page for each header, which will in turn take you to a page for each function declared in that header.

    Deprecated Headers
    Don't Include This Instead, Include This Reason
    <arpa/inet.h> "zkArpaInet.h" Not in Standard C.
    <ctype.h> "zkCtype.h" Includes kernel header when ZK_KERNEL is defined.
    <errno.h> "zkErrno.h" Includes kernel header when ZK_KERNEL is defined.
    <fcntl.h> "zkFcntl.h" Not in Standard C.
    <netdb.h> "zkNetdb.h" Not in Standard C.
    <netinet/in.h> "zkNetinetIn.h" Not in Standard C.
    <stdio.h> "zkStdio.h" Defines wrapper functions; includes kernel header when ZK_KERNEL is defined.
    <stdlib.h> "zkStdlib.h" Defines wrapper functions; includes kernel header when ZK_KERNEL is defined.
    <string.h> "zkString.h" Defines wrapper functions; includes kernel header when ZK_KERNEL is defined.
    <sys/select.h> "zkSysSelect.h" Not in Standard C.
    <sys/socket.h> "zkSysSocket.h" Not in Standard C.
    <sys/stat.h> "zkSysStat.h> Not in Standard C.
    <sys/time.h> "zkSysTime.h" Not in Standard C.
    <sys/types.h> "zkSysTypes.h" Not in Standard C.
    <time.h> "zkTime.h" Defines wrapper functions; includes kernel header when ZK_KERNEL is defined.
    <unistd.h> "zkUnistd.h" Not in Standard C.

    Below is a list of headers whose contents have not been "wrapped" by functions in libzk. The notes describe any restrictions that apply to the header as a whole, as well as any caveats in its use.

    Supported Headers
    Header
    Notes
    <assert.h>
    Only available in user space, i.e., when ZK_KERNEL is undefined.
    <float.h>
     
    <limits.h>
     
    <locale.h>
    Only available in user space, i.e., when ZK_KERNEL is undefined. Quality of implementation varies a lot, so use of the declarations in this header is not recommended in cross-platform code.
    <math.h>
    Only available in user space, i.e., when ZK_KERNEL is undefined.
    <setjmp.h>
    Available in user space, i.e., when ZK_KERNEL is undefined. The portability of this header to kernel space is unknown at the moment; use at your own risk.
    <signal.h>
    Only available in user space, i.e., when ZK_KERNEL is undefined. Support for signals on non-UNIX platforms is spotty at best, so use of the declarations in this header is not recommended in cross-platform code.
    <stdarg.h>
     
    <stddef.h>