diff options
author | Anthony Green <green@moxielogic.com> | 2022-09-19 06:42:29 -0400 |
---|---|---|
committer | Anthony Green <green@moxielogic.com> | 2022-09-19 06:42:29 -0400 |
commit | fc6b939066f211b99eed3c8111e446ec95d51ca6 (patch) | |
tree | 5e025370f32ad13d35db4e663f325737dc7381ae /src | |
parent | 4c2984c43fbb3db8e65b2b5702b27944eb0ed343 (diff) | |
download | libffi-fc6b939066f211b99eed3c8111e446ec95d51ca6.tar.gz |
Standardize temp exec file creation
Diffstat (limited to 'src')
-rw-r--r-- | src/closures.c | 2 | ||||
-rw-r--r-- | src/tramp.c | 26 |
2 files changed, 2 insertions, 26 deletions
diff --git a/src/closures.c b/src/closures.c index 3b7a0ac..9aafbec 100644 --- a/src/closures.c +++ b/src/closures.c @@ -763,7 +763,7 @@ open_temp_exec_file_opts_next (void) /* Return a file descriptor of a temporary zero-sized file in a writable and executable filesystem. */ -static int +int open_temp_exec_file (void) { int fd; diff --git a/src/tramp.c b/src/tramp.c index 9cec81e..0938c08 100644 --- a/src/tramp.c +++ b/src/tramp.c @@ -253,20 +253,14 @@ ffi_tramp_get_libffi (void) #if defined (__linux__) || defined (__CYGWIN__) -#if defined HAVE_MKSTEMP - static int ffi_tramp_get_temp_file (void) { - char template[12] = "/tmp/XXXXXX"; ssize_t count; tramp_globals.offset = 0; - tramp_globals.fd = mkstemp (template); - if (tramp_globals.fd == -1) - return 0; + tramp_globals.fd = open_temp_exec_file (); - unlink (template); /* * Write the trampoline code table into the temporary file and allocate a * trampoline table to make sure that the temporary file can be mapped. @@ -280,24 +274,6 @@ ffi_tramp_get_temp_file (void) return 0; } -#else /* !defined HAVE_MKSTEMP */ - -/* - * TODO: - * src/closures.c contains code for finding temp file that has EXEC - * permissions. May be, some of that code can be shared with static - * trampolines. - */ -static int -ffi_tramp_get_temp_file (void) -{ - tramp_globals.offset = 0; - tramp_globals.fd = -1; - return 0; -} - -#endif /* defined HAVE_MKSTEMP */ - #endif /* defined (__linux__) || defined (__CYGWIN__) */ /* ------------------------ OS-specific Initialization ----------------------*/ |