summaryrefslogtreecommitdiff
path: root/doc/README.Porting
blob: 9c13a9987c6c7d8d9894d4d635d96be18bd281bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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.