summaryrefslogtreecommitdiffstats
path: root/gcc47-boehm-gc-cygwin.patch
blob: 49f9ee0c05bfc56b8378c423f12d43cbc2db604d (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
--- origsrc/gcc-4.7.2/boehm-gc/win32_threads.c	2009-05-17 21:07:18.000000000 +0100
+++ src/gcc-4.7.2/boehm-gc/win32_threads.c	2013-03-31 19:34:57.203125000 +0100
@@ -707,6 +707,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;