OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / libgcc / config / darwin-crt-tm.c
1 /* Provide the runtime infrastructure for the transactional memory lib.
2    Copyright (C) 2011 Free Software Foundation, Inc.
3    Contributed by Iain Sandoe <iains@gcc.gnu.org>
4
5    This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 <http://www.gnu.org/licenses/>.  */
25
26 #include <mach-o/dyld.h>
27
28 /* not listed in mach-o/dyld.h for some reason.  */
29 extern char * getsectdata (const char*,const char*,unsigned long*); 
30
31 #define WEAK __attribute__((weak))
32
33 extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
34 extern void _ITM_deregisterTMCloneTable (void *) WEAK;
35
36 #ifdef START
37
38 void __doTMRegistrations (void) __attribute__ ((constructor));
39
40 void __doTMRegistrations (void)
41 {
42   char * tm_clone_table_sect_data;
43   unsigned long tmct_siz;
44   
45   tm_clone_table_sect_data = getsectdata ("__DATA",
46                                           "__tm_clone_table",
47                                           &tmct_siz);
48   tmct_siz /= (sizeof (size_t) * 2);
49   if (_ITM_registerTMCloneTable != NULL
50       && tm_clone_table_sect_data != NULL
51       && tmct_siz > 0)
52     _ITM_registerTMCloneTable (tm_clone_table_sect_data, (size_t)tmct_siz);
53 }
54
55 #endif
56
57 #ifdef END
58
59 void __doTMdeRegistrations (void) __attribute__ ((destructor));
60
61 void __doTMdeRegistrations (void)
62 {
63   char * tm_clone_table_sect_data;
64   unsigned long tmct_siz;
65   
66   tm_clone_table_sect_data = getsectdata ("__DATA",
67                                           "__tm_clone_table",
68                                           &tmct_siz);
69   
70   if (_ITM_deregisterTMCloneTable != NULL
71       && tm_clone_table_sect_data != NULL
72       && tmct_siz > 0)
73     _ITM_deregisterTMCloneTable (tm_clone_table_sect_data);
74
75 }
76
77 #endif