Standardize temp exec file creation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
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 ----------------------*/