1 /* Glibc support needed only by D front-end.
2    Copyright (C) 2017-2019 Free Software Foundation, Inc.
3 
4 GCC is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
7 version.
8 
9 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3.  If not see
16 <http://www.gnu.org/licenses/>.  */
17 
18 #include "config.h"
19 #include "system.h"
20 #include "coretypes.h"
21 #include "tm.h"
22 #include "memmodel.h"
23 #include "tm_p.h"
24 #include "d/d-target.h"
25 #include "d/d-target-def.h"
26 
27 /* Implement TARGET_D_OS_VERSIONS for Glibc targets.  */
28 
29 static void
glibc_d_os_builtins(void)30 glibc_d_os_builtins (void)
31 {
32   d_add_builtin_version ("Posix");
33 
34 #define builtin_version(TXT) d_add_builtin_version (TXT)
35 
36 #ifdef GNU_USER_TARGET_D_OS_VERSIONS
37   GNU_USER_TARGET_D_OS_VERSIONS ();
38 #endif
39 
40 #ifdef EXTRA_TARGET_D_OS_VERSIONS
41   EXTRA_TARGET_D_OS_VERSIONS ();
42 #endif
43 }
44 
45 /* Implement TARGET_D_CRITSEC_SIZE for Glibc targets.  */
46 
47 static unsigned
glibc_d_critsec_size(void)48 glibc_d_critsec_size (void)
49 {
50   /* This is the sizeof pthread_mutex_t.  */
51 #ifdef GNU_USER_TARGET_D_CRITSEC_SIZE
52   return GNU_USER_TARGET_D_CRITSEC_SIZE;
53 #else
54   return (POINTER_SIZE == 64) ? 40 : 24;
55 #endif
56 }
57 
58 #undef TARGET_D_OS_VERSIONS
59 #define TARGET_D_OS_VERSIONS glibc_d_os_builtins
60 
61 #undef TARGET_D_CRITSEC_SIZE
62 #define TARGET_D_CRITSEC_SIZE glibc_d_critsec_size
63 
64 struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
65