[OPTIM] linux: add support for bypassing libc to force using vsyscalls
Some distros' libc are built for CPUs earlier than i686 and as such do
not offer support for Linux kernel's faster vsyscalls. This code adds
a new build option USE_VSYSCALLS to bypass libc for most commonly used
system calls. A net gain of about 10% can be observed with this change
alone.
It only works when /proc/sys/abi/vsyscall32 equals exactly 2. When it's
set to 1, the VDSO is randomized and cannot be used.
diff --git a/Makefile b/Makefile
index 1480faf..51bbefc 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,7 @@
# USE_LINUX_SPLICE : enable kernel 2.6 splicing (broken on old kernels)
# USE_LIBCRYPT : enable crypted passwords using -lcrypt
# USE_CRYPT_H : set it if your system requires including crypt.h
+# USE_VSYSCALL : enable vsyscall on Linux x86, bypassing libc
#
# Options can be forced by specifying "USE_xxx=1" or can be disabled by using
# "USE_xxx=" (empty string).
@@ -374,6 +375,12 @@
BUILD_OPTIONS += $(call ignore_implicit,USE_KQUEUE)
endif
+ifneq ($(USE_VSYSCALL),)
+OPTIONS_OBJS += src/i386-linux-vsys.o
+OPTIONS_CFLAGS += -DCONFIG_HAP_LINUX_VSYSCALL
+BUILD_OPTIONS += $(call ignore_implicit,USE_VSYSCALL)
+endif
+
ifneq ($(USE_NETFILTER),)
OPTIONS_CFLAGS += -DNETFILTER
BUILD_OPTIONS += $(call ignore_implicit,USE_NETFILTER)