Linux and the BSDs have getifaddrs(). Use it and save a bunch of complex coding.
[exim.git] / src / OS / os.h-Linux
1 /* Exim: OS-specific C header file for Linux */
2 /* Copyright (c) University of Cambridge 1995 - 2020 */
3 /* See the file NOTICE for conditions of use and distribution. */
4
5
6 /* Some old systems we've received bug-reports for have a <limits.h> which
7 does not pull in <features.h>.  Best to just pull it in now and have done
8 with the issue. */
9
10 #include <features.h>
11 #include <sys/types.h>
12
13
14 #define CRYPT_H
15 #define GLIBC_IP_OPTIONS
16 #define HAVE_MMAP
17 #define HAVE_BSD_GETLOADAVG
18 #define HAVE_SYS_STATVFS_H
19 #define HAVE_GETIFADDRS
20 #define NO_IP_VAR_H
21 #define SIG_IGN_WORKS
22
23 /* When using DKIM, setting OS_SENDFILE can increase
24 performance on outgoing mail a bit. Note: With older glibc versions
25 this setting will conflict with the _FILE_OFFSET_BITS=64 setting
26 defined as part of the Linux CFLAGS.  As of 2017 those are declared
27 to be too old to build by default. */
28
29 #define OS_SENDFILE
30 extern ssize_t os_sendfile(int, int, off_t *, size_t);
31
32 #define F_FREESP     O_TRUNC
33 typedef struct flock flock_t;
34
35 #define os_strsignal strsignal
36 #define OS_STRSIGNAL
37
38 #if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD_kernel__)
39 # define SIOCGIFCONF_GIVES_ADDR
40 # define HAVE_SYS_MOUNT_H
41 #endif
42
43 #if defined(__linux__)
44
45 /* Some versions of Linux need explicit sync-ing of directories as well as
46 files. This setting requests that. If the directory is on NFS, it may not
47 be possible to sync it - in that case, Exim now should ignore the error. But
48 if you have problems in that area, try undefining this. But be aware that you
49 may be in a situation where files are not being properly "committed to stable
50 storage" as quickly as Exim thinks they are. */
51
52 #define NEED_SYNC_DIRECTORY
53
54 #define os_find_running_interfaces os_find_running_interfaces_linux
55
56 /* Need a prototype for the Linux-specific function. The structure hasn't
57 been defined yet, so we need to pre-declare it. */
58
59 struct ip_address_item;
60 extern struct ip_address_item *os_find_running_interfaces_linux(void);
61
62 #endif /* __linux__ */
63
64 /* Some folks running "unusual" setups with very old libc environments have
65 found that _GNU_SOURCE=1 before <features.h> is not sufficient to define some
66 constants needed for 64-bit arithmetic.  If you encounter build errors based
67 on LLONG_MIN being undefined and various other escape hatches have not helped,
68 then change the 0 to 1 in the next block. */
69
70 #if 0
71 # define LLONG_MIN LONG_LONG_MIN
72 # define LLONG_MAX LONG_LONG_MAX
73 #endif
74
75 #if _POSIX_C_SOURCE >= 200809L || _ATFILE_SOURCE
76 # define EXIM_HAVE_OPENAT
77 # define EXIM_HAVE_FUTIMENS
78 #endif
79
80 /* TCP Fast Open support */
81
82 #include <netinet/tcp.h>        /* for TCP_FASTOPEN */
83 #include <sys/socket.h>         /* for MSG_FASTOPEN */
84 #if defined(TCP_FASTOPEN) && !defined(MSG_FASTOPEN)
85 # define MSG_FASTOPEN 0x20000000
86 #endif
87 #define EXIM_HAVE_TCPI_UNACKED
88 #ifndef TCPI_OPT_SYN_DATA
89 # define TCPI_OPT_SYN_DATA 32
90 #endif
91
92 /* "Abstract" Unix-socket names */
93 #define EXIM_HAVE_ABSTRACT_UNIX_SOCKETS
94
95 /* inotify(7) etc syscalls */
96 #define EXIM_HAVE_INOTIFY
97
98 /* Needed for uClibc */
99 #ifndef NS_MAXMSG
100 # define NS_MAXMSG 65535
101 #endif
102
103 /* End */