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>
5 This file is part of GCC.
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
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
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.
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/>. */
26 #include <mach-o/dyld.h>
28 /* not listed in mach-o/dyld.h for some reason. */
29 extern char * getsectdata (const char*,const char*,unsigned long*);
31 #define WEAK __attribute__((weak))
33 extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
34 extern void _ITM_deregisterTMCloneTable (void *) WEAK;
38 void __doTMRegistrations (void) __attribute__ ((constructor));
40 void __doTMRegistrations (void)
42 char * tm_clone_table_sect_data;
43 unsigned long tmct_siz;
45 tm_clone_table_sect_data = getsectdata ("__DATA",
48 tmct_siz /= (sizeof (size_t) * 2);
49 if (_ITM_registerTMCloneTable != NULL
50 && tm_clone_table_sect_data != NULL
52 _ITM_registerTMCloneTable (tm_clone_table_sect_data, (size_t)tmct_siz);
59 void __doTMdeRegistrations (void) __attribute__ ((destructor));
61 void __doTMdeRegistrations (void)
63 char * tm_clone_table_sect_data;
64 unsigned long tmct_siz;
66 tm_clone_table_sect_data = getsectdata ("__DATA",
70 if (_ITM_deregisterTMCloneTable != NULL
71 && tm_clone_table_sect_data != NULL
73 _ITM_deregisterTMCloneTable (tm_clone_table_sect_data);