| 1 |
POSIX compatibility code |
| 2 |
------------------------ |
| 3 |
|
| 4 |
This code exists to work around some common POSIX compatibility issues. |
| 5 |
POSIX specifies that if the first line of a Makefile is ".POSIX:" then the |
| 6 |
Makefile should be processed according to POSIX rules, including with CC=c99; |
| 7 |
thus we should see behaviour consistent with a standard-compliant C99 |
| 8 |
compiler. |
| 9 |
|
| 10 |
One POSIX compatibility check requires a runtime test. This will be |
| 11 |
automatically disabled if the build system detects that you are |
| 12 |
cross-compiling for another platform, or it can be manually disabled by |
| 13 |
setting DISABLE_POSIX_RUNTIME_CHECKS to a non-zero value. |
| 14 |
|
| 15 |
- posix-cflags.sh: Detects if ${CC} supports certain POSIX features, and |
| 16 |
outputs a POSIXFAIL_ define if it is not supported so that we can work around |
| 17 |
the problem. |
| 18 |
|
| 19 |
The potential command-line flags are: |
| 20 |
- DPOSIXFAIL_MSG_NOSIGNAL: <sys/socket.h> not defining MSG_NOSIGNAL. |
| 21 |
- DPOSIXFAIL_CLOCK_REALTIME: <time.h> not defining CLOCK_REALTIME. |
| 22 |
- DPOSIXFAIL_CLOCK_GETTIME: <time.h> not declaring clock_gettime(), or |
| 23 |
clock_gettime() is not linkable. The latter test requires a runtime check. |
| 24 |
- DPOSIXFAIL_INET_ADDRSTRLEN: <netinet/in.h> not defining |
| 25 |
INET_ADDRSTRLEN. |
| 26 |
- DPOSIXFAIL_INET6_ADDRSTRLEN: <netinet/in.h> not defining |
| 27 |
INET6_ADDRSTRLEN. |
| 28 |
- DPOSIXFAIL_ABSTRACT_DECLARATOR: ${CC} does not accept |
| 29 |
qualifiers in an abstract declarator. |
| 30 |
- DPOSIXFAIL_STAT_ST_MTIM: struct stat does not contain st_mtim. |
| 31 |
- std=c99: ${CC} does not accept the `restrict` keyword by default, but |
| 32 |
accepts it when given this flag. |
| 33 |
|
| 34 |
- posix-cflags-filter.sh: Detects if ${CC} supports expected ${CFLAG} value(s). |
| 35 |
|
| 36 |
The potential ${CFLAGS} flags it checks are: |
| 37 |
- O2: some compilers only accept -O. |
| 38 |
|
| 39 |
- posix-l.sh: Detects whether the linker supports certain POSIX features. |
| 40 |
|
| 41 |
The potential command-line flags are: |
| 42 |
- lrt lxnet: c99 is required to understand these options, and ignore them if |
| 43 |
the routines for which they specify linkage are already in the standard C |
| 44 |
library |