Enable use of sendfile on FreeBSD
[exim.git] / src / OS / os.h-Linux
index 285e8d28f84ef2d341f2bfce993a66ca09ee243d..57034649c6909e7422f724caad23caf8031c5704 100644 (file)
@@ -1,7 +1,13 @@
-/* $Cambridge: exim/src/OS/os.h-Linux,v 1.3 2005/02/17 10:04:41 ph10 Exp $ */
-
 /* Exim: OS-specific C header file for Linux */
 
+/* Some old systems we've received bug-reports for have a <limits.h> which
+does not pull in <features.h>.  Best to just pull it in now and have done
+with the issue. */
+
+#include <features.h>
+#include <sys/types.h>
+
+
 #define CRYPT_H
 #define GLIBC_IP_OPTIONS
 #define HAVE_MMAP
 #define NO_IP_VAR_H
 #define SIG_IGN_WORKS
 
+/* When using DKIM, setting OS_SENDFILE can increase
+performance on outgoing mail a bit. Note: With older glibc versions
+this setting will conflict with the _FILE_OFFSET_BITS=64 setting
+defined as part of the Linux CFLAGS.  As of 2017 those are declared
+to be too old to build by default. */
+
+#define OS_SENDFILE
+extern ssize_t os_sendfile(int, int, off_t *, size_t);
+
 #define F_FREESP     O_TRUNC
 typedef struct flock flock_t;
 
@@ -17,8 +32,8 @@ typedef struct flock flock_t;
 #define OS_STRSIGNAL
 
 #if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD_kernel__)
-#define SIOCGIFCONF_GIVES_ADDR
-#define HAVE_SYS_MOUNT_H
+# define SIOCGIFCONF_GIVES_ADDR
+# define HAVE_SYS_MOUNT_H
 #endif
 
 #if defined(__linux__)
@@ -32,9 +47,6 @@ storage" as quickly as Exim thinks they are. */
 
 #define NEED_SYNC_DIRECTORY
 
-/* Other OS have "const" in here */
-#define ICONV_ARG2_TYPE char **
-
 #define os_find_running_interfaces os_find_running_interfaces_linux
 
 /* Need a prototype for the Linux-specific function. The structure hasn't
@@ -45,4 +57,26 @@ extern struct ip_address_item *os_find_running_interfaces_linux(void);
 
 #endif /* __linux__ */
 
+/* Some folks running "unusual" setups with very old libc environments have
+found that _GNU_SOURCE=1 before <features.h> is not sufficient to define some
+constants needed for 64-bit arithmetic.  If you encounter build errors based
+on LLONG_MIN being undefined and various other escape hatches have not helped,
+then change the 0 to 1 in the next block. */
+
+#if 0
+# define LLONG_MIN LONG_LONG_MIN
+# define LLONG_MAX LONG_LONG_MAX
+#endif
+
+#if _POSIX_C_SOURCE >= 200809L || _ATFILE_SOUCE
+# define EXIM_HAVE_OPENAT
+#endif
+
+#include <netinet/tcp.h>       /* for TCP_FASTOPEN */
+#include <sys/socket.h>                /* for MSG_FASTOPEN */
+#if defined(TCP_FASTOPEN) && !defined(MSG_FASTOPEN)
+# define MSG_FASTOPEN 0x20000000
+#endif
+
+
 /* End */