How to support a new operating system, platform or version thereof? ------------------------------------------------------------------- Make sure 'port/guess_env' reliably detects the version of your new operating system. If you have a new operating system choose a new label for the platform like 'SUNOS'. Never port for the future with 'OS_MINOR_VERSION >= 5', make sure you check the new version first. We try to follow the X-Open group if possible (and POSIX). Try to avoid BSD emulations of functions on SysV systems and vice versa. Defines in 'port/sys.h' ----------------------- Don't port using '#ifdef LINUX'! Instead use the platform flags only in 'port/sys.h' and define descriptive macros for features of the system like 'HAVE_VSNPRINTF'. Currently there are the following definitions which must be set: - HAVE_STDBOOL_H and HAVE_ENUM_BOOL: HAVE_STDBOOL_H whether the platform has a C99 bool type in stdbool.h HAVE_ENUM_BOOL for platforms which define an internal _Bool somewhere but not the official bool data type - HAVE_VSNPRINTF, HAVE_SNPRINTF: vsnprintf and snprintf, there is a stub implementation if this function doesn't exist or is buggy (see http://www.jhweiss.de/software/snprintf.html) - HAVE_STRDUP: a string duplication function (there is a stub for really old platforms) - HAVE_STRERROR_R: whether we have a reentrant strerror function - HAVE_LOCKF: whether we have a POSIX lockf interface. A stub implemented with fcntl is available for platform which don't have a lockf function. Currently tested on: -------------------- - x86 Linux 2.6.x - x86 FreeBSD 6.2 - x86 OpenBSD 4.2 - x86 Solaris 10 - SPARC Solaris 8 How to use the porting layer in your code ----------------------------------------- Don't include system header files if there is a similar file in the 'ports' subdir: #include "port/limits.h" #include "port/stdbool.h" #include "port/stdio.h" #include "port/string.h" #include "port/unistd.h" You also may to have new such stubs when porting to new platforms or when you start to use new features.