pkgsrc/lang/mono/patches/patch-ak
joerg 743ff1d72a Behave when address space limits are in place:
(1) Default heap limit to 75% of available address space.
(2) Limit GC marker threads to 4MB/8MB (32bit vs 64bit) stack space.
    As Mono tries to create 16 such threads by default, the default
    stack size on AMD64 would eat 2GB VA alone.

Bump revision.
2015-06-15 09:27:29 +00:00

56 lines
1.7 KiB
Text

$NetBSD: patch-ak,v 1.12 2015/06/15 09:27:29 joerg Exp $
--- libgc/pthread_support.c.orig 2015-04-24 01:26:16.000000000 +0000
+++ libgc/pthread_support.c
@@ -71,7 +71,7 @@
defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)) || \
defined(GC_NETBSD_THREADS) && !defined(USE_PTHREAD_SPECIFIC) || \
defined(GC_FREEBSD_THREADS) && !defined(USE_PTHREAD_SPECIFIC) || \
- defined(GC_OPENBSD_THREADS)
+ !defined(USE_COMPILER_TLS) || defined(GC_OPENBSD_THREADS)
# define USE_PTHREAD_SPECIFIC
# endif
#endif
@@ -595,6 +595,20 @@ static void start_mark_threads()
}
}
# endif /* HPUX || GC_DGUX386_THREADS */
+# if defined(__NetBSD__)
+# define MAX_STACK_SIZE (1024 * 1024 *sizeof(word))
+ {
+ size_t old_size;
+ int code;
+
+ if (pthread_attr_getstacksize(&attr, &old_size) != 0)
+ ABORT("pthread_attr_getstacksize failed\n");
+ if (old_size > MAX_STACK_SIZE) {
+ if (pthread_attr_setstacksize(&attr, MAX_STACK_SIZE) != 0)
+ ABORT("pthread_attr_setstacksize failed\n");
+ }
+ }
+# endif
# ifdef CONDPRINT
if (GC_print_stats) {
GC_printf1("Starting %ld marker threads\n", GC_markers - 1);
@@ -1282,6 +1296,22 @@ void GC_end_blocking(void) {
#define __d10_sleep sleep
#endif /* GC_DGUX386_THREADS */
+#undef nanosleep
+#undef usleep
+#undef sleep
+
+/* A wrapper for the standard C nanosleep function */
+int WRAP_FUNC(nanosleep) (const struct timespec *rqtp, struct timespec *rmtp)
+{
+ int result;
+
+ GC_start_blocking();
+ result = REAL_FUNC(nanosleep)(rqtp, rmtp);
+ GC_end_blocking();
+
+ return result;
+}
+
/* A wrapper for the standard C sleep function */
int WRAP_FUNC(sleep) (unsigned int seconds)
{