summaryrefslogtreecommitdiff
path: root/lang/mono/patches/patch-ak
blob: b09c15eafe3c10f1976b332cbcb5e09eb8223f90 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
$NetBSD: patch-ak,v 1.7 2006/01/03 08:03:53 recht Exp $

--- libgc/pthread_support.c.orig	2005-12-07 06:42:46.000000000 +0100
+++ libgc/pthread_support.c
@@ -68,7 +68,7 @@
 # endif
 
 # if (defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) || \
-      defined(GC_DARWIN_THREADS)) && !defined(USE_PTHREAD_SPECIFIC)
+      defined(GC_DARWIN_THREADS) || defined(GC_NETBSD_THREADS)) && !defined(USE_PTHREAD_SPECIFIC)
 #   define USE_PTHREAD_SPECIFIC
 # endif
 
@@ -120,7 +120,10 @@
 # include <sys/sysctl.h>
 #endif /* GC_DARWIN_THREADS */
 
-
+#if defined(GC_NETBSD_THREADS)
+# include <sys/param.h>
+# include <sys/sysctl.h>
+#endif
 
 #if defined(GC_DGUX386_THREADS)
 # include <sys/dg_sys_info.h>
@@ -978,7 +981,7 @@ void GC_thr_init()
 #       if defined(GC_FREEBSD_THREADS)
           GC_nprocs = 1;
 #       endif
-#       if defined(GC_DARWIN_THREADS)
+#       if defined(GC_DARWIN_THREADS) || defined(GC_NETBSD_THREADS)
 	  int ncpus = 1;
 	  size_t len = sizeof(ncpus);
 	  sysctl((int[2]) {CTL_HW, HW_NCPU}, 2, &ncpus, &len, NULL, 0);
@@ -1115,8 +1118,24 @@ 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)
+unsigned int WRAP_FUNC(sleep) (unsigned int seconds)
 {
     int result;
 
@@ -1126,6 +1145,19 @@ int WRAP_FUNC(sleep) (unsigned int secon
     return result;
 }
 
+/* A wrapper for the standard C usleep function	*/
+int WRAP_FUNC(usleep) (useconds_t microseconds)
+{
+    int result;
+
+    GC_start_blocking();
+    result = REAL_FUNC(usleep)(microseconds);
+    GC_end_blocking();
+
+    return result;
+}
+
+
 struct start_info {
     void *(*start_routine)(void *);
     void *arg;