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.6 2005/07/31 15:26:58 recht Exp $
--- libgc/pthread_support.c.orig 2005-06-19 11:59:53.000000000 +0200
+++ 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>
@@ -956,7 +959,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);
@@ -1093,8 +1096,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;
@@ -1104,6 +1123,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;
|