summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Green <green@moxielogic.com>2022-09-12 08:53:06 -0400
committerAnthony Green <green@moxielogic.com>2022-09-12 08:53:06 -0400
commita1130f37712c03957c9b0adf316cd006fa92a60b (patch)
tree8569aebb6248f6c469de49776a5061f67e4e059b /src
parent26cc9a6c73c80e8459c25da3718c91cf5a36cbd8 (diff)
downloadlibffi-a1130f37712c03957c9b0adf316cd006fa92a60b.tar.gz
Add static trampoline support for Cygwin
Diffstat (limited to 'src')
-rw-r--r--src/closures.c4
-rw-r--r--src/tramp.c28
2 files changed, 18 insertions, 14 deletions
diff --git a/src/closures.c b/src/closures.c
index 6cbe2f0..e2bc651 100644
--- a/src/closures.c
+++ b/src/closures.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------
- closures.c - Copyright (c) 2019 Anthony Green
+ closures.c - Copyright (c) 2019, 2022 Anthony Green
Copyright (c) 2007, 2009, 2010 Red Hat, Inc.
Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc
Copyright (c) 2011 Plausible Labs Cooperative, Inc.
@@ -133,7 +133,7 @@ ffi_tramp_is_present (__attribute__((unused)) void *ptr)
# define FFI_MMAP_EXEC_WRIT 1
# define HAVE_MNTENT 1
# endif
-# if defined(_WIN32) || defined(__OS2__)
+# if defined(__CYGWIN__) || defined(_WIN32) || defined(__OS2__)
/* Windows systems may have Data Execution Protection (DEP) enabled,
which requires the use of VirtualMalloc/VirtualFree to alloc/free
executable memory. */
diff --git a/src/tramp.c b/src/tramp.c
index 265aeaa..19707fb 100644
--- a/src/tramp.c
+++ b/src/tramp.c
@@ -1,5 +1,6 @@
/* -----------------------------------------------------------------------
tramp.c - Copyright (c) 2020 Madhavan T. Venkataraman
+ Copyright (c) 2022 Anthony Green
API and support functions for managing statically defined closure
trampolines.
@@ -34,7 +35,7 @@
* Add support for other OSes later. For now, it is just Linux.
*/
-#if defined __linux__
+#if defined (__linux__) || defined (__CYGWIN__)
#ifdef __linux__
#define _GNU_SOURCE 1
#endif
@@ -50,7 +51,10 @@
#include <linux/limits.h>
#include <linux/types.h>
#endif
-#endif /* __linux__ */
+#ifdef __CYGWIN__
+#include <linux/limits.h>
+#endif
+#endif
/*
* Each architecture defines static code for a trampoline code table. The
@@ -191,7 +195,7 @@ static struct tramp_globals tramp_globals;
*/
static int tramp_table_alloc (void);
-#if defined __linux__
+#if defined (__linux__) || defined (__CYGWIN__)
static int
ffi_tramp_get_libffi (void)
@@ -245,9 +249,9 @@ ffi_tramp_get_libffi (void)
return 1;
}
-#endif /* __linux__ */
+#endif /* defined (__linux__) || defined (__CYGWIN__) */
-#if defined __linux__
+#if defined (__linux__) || defined (__CYGWIN__)
#if defined HAVE_MKSTEMP
@@ -294,11 +298,11 @@ ffi_tramp_get_temp_file (void)
#endif /* defined HAVE_MKSTEMP */
-#endif /* __linux__ */
+#endif /* defined (__linux__) || defined (__CYGWIN__) */
/* ------------------------ OS-specific Initialization ----------------------*/
-#if defined __linux__
+#if defined (__linux__) || defined (__CYGWIN__)
static int
ffi_tramp_init_os (void)
@@ -308,11 +312,11 @@ ffi_tramp_init_os (void)
return ffi_tramp_get_temp_file ();
}
-#endif /* __linux__ */
+#endif /* defined (__linux__) || defined (__CYGWIN__) */
/* --------------------------- OS-specific Locking -------------------------*/
-#if defined __linux__
+#if defined (__linux__) || defined (__CYGWIN__)
static pthread_mutex_t tramp_globals_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -328,7 +332,7 @@ ffi_tramp_unlock()
pthread_mutex_unlock (&tramp_globals_mutex);
}
-#endif /* __linux__ */
+#endif /* defined (__linux__) || defined (__CYGWIN__) */
/* ------------------------ OS-specific Memory Mapping ----------------------*/
@@ -347,7 +351,7 @@ ffi_tramp_unlock()
* sizeof (struct tramp_parm) cannot exceed the size of a parameter block.
*/
-#if defined __linux__
+#if defined (__linux__) || defined (__CYGWIN__)
static int
tramp_table_map (struct tramp_table *table)
@@ -384,7 +388,7 @@ tramp_table_unmap (struct tramp_table *table)
(void) munmap (table->parm_table, tramp_globals.map_size);
}
-#endif /* __linux__ */
+#endif /* defined (__linux__) || defined (__CYGWIN__) */
/* ------------------------ Trampoline Initialization ----------------------*/