pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mono-git: Simulate Linux's mremap(2) on NetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Apr 17 03:09:36 2016 +0200
Changeset:	5229271257d9492a50d76710f2944bd9f10e9c66

Modified Files:
	mono-git/distinfo
Added Files:
	mono-git/patches/patch-mono_utils_dlmalloc.c
	mono-git/patches/patch-support_map.c
	mono-git/patches/patch-support_sys-mman.c

Log Message:
mono-git: Simulate Linux's mremap(2) on NetBSD

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=5229271257d9492a50d76710f2944bd9f10e9c66

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 mono-git/distinfo                            |  3 ++
 mono-git/patches/patch-mono_utils_dlmalloc.c | 42 ++++++++++++++++++++++++++
 mono-git/patches/patch-support_map.c         | 45 ++++++++++++++++++++++++++++
 mono-git/patches/patch-support_sys-mman.c    | 20 +++++++++++++
 4 files changed, 110 insertions(+)

diffs:
diff --git a/mono-git/distinfo b/mono-git/distinfo
index a91cd49..52d42c3 100644
--- a/mono-git/distinfo
+++ b/mono-git/distinfo
@@ -30,3 +30,6 @@ SHA1 (patch-mono_tests_verifier_make__switch__test.sh) = 1f967fa68b3e889846ce8f6
 SHA1 (patch-mono_tests_verifier_make__tail__call__test.sh) = e7ea47858bf45a2ab492933e397afab209fa4a7e
 SHA1 (patch-mono_tests_verifier_make__tests.sh) = eb090981fb75d68566fb1d8accbdc5e2ead8703d
 SHA1 (patch-mono_tests_verifier_make__unbox__test.sh) = 28c885c5ae3da474598c1ff092760a806a2559e6
+SHA1 (patch-mono_utils_dlmalloc.c) = a1fcd65964e1e18418c97e1726058f1864a49de1
+SHA1 (patch-support_map.c) = 39a26cca54503d465fe89042433b7bfdb52104ab
+SHA1 (patch-support_sys-mman.c) = 9d22f579a3f826faf5092b1c3ba0409bde419970
diff --git a/mono-git/patches/patch-mono_utils_dlmalloc.c b/mono-git/patches/patch-mono_utils_dlmalloc.c
new file mode 100644
index 0000000..52065e2
--- /dev/null
+++ b/mono-git/patches/patch-mono_utils_dlmalloc.c
@@ -0,0 +1,42 @@
+$NetBSD$
+
+--- mono/utils/dlmalloc.c.orig	2016-04-16 14:26:45.000000000 +0000
++++ mono/utils/dlmalloc.c
+@@ -342,7 +342,7 @@ HAVE_MMAP                 default: 1 (tr
+   able to unmap memory that may have be allocated using multiple calls
+   to MMAP, so long as they are adjacent.
+ 
+-HAVE_MREMAP               default: 1 on linux, else 0
++HAVE_MREMAP               default: 1 on linux and NetBSD, else 0
+   If true realloc() uses mremap() to re-allocate large blocks and
+   extend or shrink allocation spaces.
+ 
+@@ -536,11 +536,11 @@ DEFAULT_MMAP_THRESHOLD       default: 25
+ #define MMAP_CLEARS 1
+ #endif  /* MMAP_CLEARS */
+ #ifndef HAVE_MREMAP
+-#ifdef linux
++#if defined(linux) || defined(__NetBSD__)
+ #define HAVE_MREMAP 1
+-#else   /* linux */
++#else   /* linux || __NetBSD__ */
+ #define HAVE_MREMAP 0
+-#endif  /* linux */
++#endif  /* linux || __NetBSD__ */
+ #endif  /* HAVE_MREMAP */
+ #ifndef MALLOC_FAILURE_ACTION
+ #define MALLOC_FAILURE_ACTION  errno = ENOMEM;
+@@ -1375,7 +1375,13 @@ static int win32munmap(void* ptr, size_t
+ #endif /* HAVE_MMAP */
+ 
+ #if HAVE_MMAP && HAVE_MREMAP
++#if defined(linux)
+ #define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
++#elif defined(__NetBSD__)
++#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (addr), (nsz), (mv))
++#else
++#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL
++#endif
+ #else  /* HAVE_MMAP && HAVE_MREMAP */
+ #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL
+ #endif /* HAVE_MMAP && HAVE_MREMAP */
diff --git a/mono-git/patches/patch-support_map.c b/mono-git/patches/patch-support_map.c
new file mode 100644
index 0000000..423c19d
--- /dev/null
+++ b/mono-git/patches/patch-support_map.c
@@ -0,0 +1,45 @@
+$NetBSD$
+
+--- support/map.c.orig	2016-04-16 14:26:45.000000000 +0000
++++ support/map.c
+@@ -3922,12 +3922,17 @@ int Mono_Posix_ToMountFlags (guint64 x, 
+ int Mono_Posix_FromMremapFlags (guint64 x, guint64 *r)
+ {
+ 	*r = 0;
++#ifndef __NetBSD__
+ 	if ((x & Mono_Posix_MremapFlags_MREMAP_MAYMOVE) == Mono_Posix_MremapFlags_MREMAP_MAYMOVE)
+ #ifdef MREMAP_MAYMOVE
+ 		*r |= MREMAP_MAYMOVE;
+ #else /* def MREMAP_MAYMOVE */
+ 		{errno = EINVAL; return -1;}
+ #endif /* ndef MREMAP_MAYMOVE */
++#else /* def __NetBSD__ */
++	if ((x & Mono_Posix_MremapFlags_MREMAP_MAYMOVE) != Mono_Posix_MremapFlags_MREMAP_MAYMOVE)
++		*r = MAP_FIXED;
++#endif /* def __NetBSD__ */
+ 	if (x == 0)
+ 		return 0;
+ 	return 0;
+@@ -3936,12 +3941,17 @@ int Mono_Posix_FromMremapFlags (guint64 
+ int Mono_Posix_ToMremapFlags (guint64 x, guint64 *r)
+ {
+ 	*r = 0;
++#ifndef __NetBSD__
+ 	if (x == 0)
+ 		return 0;
+ #ifdef MREMAP_MAYMOVE
+ 	if ((x & MREMAP_MAYMOVE) == MREMAP_MAYMOVE)
+ 		*r |= Mono_Posix_MremapFlags_MREMAP_MAYMOVE;
+ #endif /* ndef MREMAP_MAYMOVE */
++#else /* def __NetBSD__ */
++	if ((x & MAP_FIXED) != MAP_FIXED)
++		*r |= Mono_Posix_MremapFlags_MREMAP_MAYMOVE;
++#endif
+ 	return 0;
+ }
+ 
+@@ -9314,4 +9324,3 @@ int Mono_Posix_ToXattrFlags (int x, int 
+ #endif /* ndef XATTR_REPLACE */
+ 	return 0;
+ }
+-
diff --git a/mono-git/patches/patch-support_sys-mman.c b/mono-git/patches/patch-support_sys-mman.c
new file mode 100644
index 0000000..f030784
--- /dev/null
+++ b/mono-git/patches/patch-support_sys-mman.c
@@ -0,0 +1,20 @@
+$NetBSD$
+
+--- support/sys-mman.c.orig	2016-04-16 14:26:45.000000000 +0000
++++ support/sys-mman.c
+@@ -109,8 +109,15 @@ Mono_Posix_Syscall_mremap (void *old_add
+ 	if (Mono_Posix_FromMremapFlags (flags, &_flags) == -1)
+ 		return MAP_FAILED;
+ 
++#if defined(linux)
+ 	return mremap (old_address, (size_t) old_size, (size_t) new_size,
+ 			(unsigned long) _flags);
++#elif defined(__NetBSD__)
++	return mremap (old_address, (size_t) old_size, old_address,
++			(size_t) new_size, (unsigned long) _flags);
++#else
++#error Port me
++#endif
+ }
+ #endif /* def HAVE_MREMAP */
+ 


Home | Main Index | Thread Index | Old Index