xref: /netbsd-src/external/gpl3/gcc/dist/gcc/config/glibc-d.cc (revision b1e838363e3c6fc78a55519254d99869742dd33c)
1 /* Glibc support needed only by D front-end.
2    Copyright (C) 2017-2022 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 "tm_d.h"
23 #include "d/d-target.h"
24 #include "d/d-target-def.h"
25 
26 /* Implement TARGET_D_OS_VERSIONS for Glibc targets.  */
27 
28 static void
glibc_d_os_builtins(void)29 glibc_d_os_builtins (void)
30 {
31   d_add_builtin_version ("Posix");
32 
33 #define builtin_version(TXT) d_add_builtin_version (TXT)
34 
35 #ifdef GNU_USER_TARGET_D_OS_VERSIONS
36   GNU_USER_TARGET_D_OS_VERSIONS ();
37 #endif
38 
39 #ifdef EXTRA_TARGET_D_OS_VERSIONS
40   EXTRA_TARGET_D_OS_VERSIONS ();
41 #endif
42 }
43 
44 /* Handle a call to `__traits(getTargetInfo, "objectFormat")'.  */
45 
46 static tree
glibc_d_handle_target_object_format(void)47 glibc_d_handle_target_object_format (void)
48 {
49   const char *objfmt = "elf";
50 
51   return build_string_literal (strlen (objfmt) + 1, objfmt);
52 }
53 
54 /* Implement TARGET_D_REGISTER_OS_TARGET_INFO for Glibc targets.  */
55 
56 static void
glibc_d_register_target_info(void)57 glibc_d_register_target_info (void)
58 {
59   const struct d_target_info_spec handlers[] = {
60     { "objectFormat", glibc_d_handle_target_object_format },
61     { NULL, NULL },
62   };
63 
64   d_add_target_info_handlers (handlers);
65 }
66 
67 #undef TARGET_D_OS_VERSIONS
68 #define TARGET_D_OS_VERSIONS glibc_d_os_builtins
69 
70 #undef TARGET_D_REGISTER_OS_TARGET_INFO
71 #define TARGET_D_REGISTER_OS_TARGET_INFO glibc_d_register_target_info
72 
73 struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
74