summaryrefslogtreecommitdiff
path: root/header_checks
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-07-26 10:15:47 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-07-26 11:43:17 +0100
commitd19e435ff9a4716e890d2653af6a1231d8961e37 (patch)
tree3ee41245f3d50a9253e50ed735e4ae3f27b04640 /header_checks
parent24a49c893886d4fa8cd81f727c465f717c3a0629 (diff)
downloadefl-d19e435ff9a4716e890d2653af6a1231d8961e37.tar.gz
reduce syscalls on opening files - roll CLOEXEC into open
on linux open supports() O_CLOEXEC. add test case for this in meson build and ifdef. this rolls 3 syscalls into 1 as we were doing open, then fnctl to get and fcntl to set flags. less syscalls is a good thing as syscalls are not cheap on some architectures or systems. I've seen a syscall on 1 system take 2-3x as long as another and another syscall in the same 2 system comparison take 10x as long. depending on the syscall you may only have a budget of something like 5000 syscalls "per frame" (60fps) before you spend all of your frame time just in syscalls not doing any processing, so we should keep these down if possible and that is what this does.
Diffstat (limited to 'header_checks')
-rw-r--r--header_checks/meson.build14
1 files changed, 14 insertions, 0 deletions
diff --git a/header_checks/meson.build b/header_checks/meson.build
index ff5b21ee0c..4cc855e218 100644
--- a/header_checks/meson.build
+++ b/header_checks/meson.build
@@ -123,6 +123,20 @@ function_checks = [
['dladdr', ['dlfcn.h'], ['dl'], '-D_GNU_SOURCE=1']
]
+open_cloexec = cc.run('''#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ int main(int argc, char **argv) {
+ int res = open(argv[0], O_RDONLY | O_CLOEXEC);
+ if (res < 0) return 1;
+ return 0;
+ }
+ ''',
+ name : 'open works with O_CLOEXEC')
+if open_cloexec.compiled() and open_cloexec.returncode() == 0
+ config_h.set10('HAVE_OPEN_CLOEXEC', true)
+endif
+
strerror_r_char_p = cc.compiles('''#define _GNU_SOURCE
#include <string.h>
int func (void)