summaryrefslogtreecommitdiffstats
path: root/0002-boehm-gc-for-cygwin.patch
blob: 8614803d34b8165610fe77ed184e3f7e0bbf2551 (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
From 350df6c8caa021f3237486ea6b5145ee559f4d00 Mon Sep 17 00:00:00 2001
From: Jonathan Yong <10walls@gmail.com>
Date: Wed, 28 May 2014 22:11:01 +0800
Subject: [PATCH 02/21] boehm-gc for cygwin

---
 boehm-gc/win32_threads.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/boehm-gc/win32_threads.c b/boehm-gc/win32_threads.c
index 2de1c69..07ecde0 100644
--- a/boehm-gc/win32_threads.c
+++ b/boehm-gc/win32_threads.c
@@ -711,6 +711,54 @@ void * GC_start_routine(void * arg)
     return(result);
 }
 
+void GC_register_my_thread()
+{
+  GC_thread me;
+  pthread_t my_pthread;
+
+  my_pthread = pthread_self();
+#   if DEBUG_CYGWIN_THREADS
+      GC_printf1("Attaching thread 0x%lx\n", my_pthread);
+      GC_printf1("pid = %ld\n", (long) getpid());
+#   endif
+  
+  /* Check to ensure this thread isn't attached already. */
+  LOCK();
+  me = GC_lookup_thread (my_pthread);
+  UNLOCK();
+  if (me != 0)
+    {
+#   if DEBUG_CYGWIN_THREADS
+      GC_printf1("Attempt to re-attach known thread 0x%lx\n", my_pthread);
+#   endif
+      return;
+    }
+
+  LOCK();
+  me = GC_new_thread();
+  me -> flags |= DETACHED;  
+  me -> pthread_id = pthread_self();
+  UNLOCK();
+}
+
+void GC_unregister_my_thread()
+{
+  pthread_t my_pthread;
+  GC_thread me;
+
+  my_pthread = pthread_self();
+
+#   if DEBUG_CYGWIN_THREADS
+      GC_printf1("Detaching thread 0x%lx\n", my_pthread);
+#   endif
+
+  LOCK();
+  me = GC_lookup_thread(my_pthread);
+  UNLOCK();
+  GC_thread_exit_proc ((void *)me);
+}
+
+
 void GC_thread_exit_proc(void *arg)
 {
     GC_thread me = (GC_thread)arg;
-- 
2.4.5