xref: /netbsd-src/external/gpl3/gcc.old/dist/libphobos/libdruntime/rt/sections.d (revision 627f7eb200a4419d89b531d55fccd2ee3ffdcde0)
1*627f7eb2Smrg /**
2*627f7eb2Smrg  *
3*627f7eb2Smrg  * Copyright: Copyright Digital Mars 2000 - 2012.
4*627f7eb2Smrg  * License: Distributed under the
5*627f7eb2Smrg  *      $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
6*627f7eb2Smrg  *    (See accompanying file LICENSE)
7*627f7eb2Smrg  * Authors:   Walter Bright, Sean Kelly, Martin Nowak
8*627f7eb2Smrg  * Source: $(DRUNTIMESRC src/rt/_sections.d)
9*627f7eb2Smrg  */
10*627f7eb2Smrg 
11*627f7eb2Smrg /* NOTE: This file has been patched from the original DMD distribution to
12*627f7eb2Smrg  * work with the GDC compiler.
13*627f7eb2Smrg  */
14*627f7eb2Smrg module rt.sections;
15*627f7eb2Smrg 
16*627f7eb2Smrg version (OSX)
17*627f7eb2Smrg     version = Darwin;
18*627f7eb2Smrg else version (iOS)
19*627f7eb2Smrg     version = Darwin;
20*627f7eb2Smrg else version (TVOS)
21*627f7eb2Smrg     version = Darwin;
22*627f7eb2Smrg else version (WatchOS)
23*627f7eb2Smrg     version = Darwin;
24*627f7eb2Smrg 
25*627f7eb2Smrg version (GNU)
26*627f7eb2Smrg     public import gcc.sections;
27*627f7eb2Smrg else version (CRuntime_Glibc)
28*627f7eb2Smrg     public import rt.sections_elf_shared;
29*627f7eb2Smrg else version (FreeBSD)
30*627f7eb2Smrg     public import rt.sections_elf_shared;
31*627f7eb2Smrg else version (NetBSD)
32*627f7eb2Smrg     public import rt.sections_elf_shared;
33*627f7eb2Smrg else version (Solaris)
34*627f7eb2Smrg     public import rt.sections_solaris;
version(Darwin)35*627f7eb2Smrg else version (Darwin)
36*627f7eb2Smrg {
37*627f7eb2Smrg     version (X86_64)
38*627f7eb2Smrg         public import rt.sections_osx_x86_64;
39*627f7eb2Smrg     else version (X86)
40*627f7eb2Smrg         public import rt.sections_osx_x86;
41*627f7eb2Smrg     else
42*627f7eb2Smrg         static assert(0, "unimplemented");
43*627f7eb2Smrg }
44*627f7eb2Smrg else version (CRuntime_DigitalMars)
45*627f7eb2Smrg     public import rt.sections_win32;
46*627f7eb2Smrg else version (CRuntime_Microsoft)
47*627f7eb2Smrg     public import rt.sections_win64;
48*627f7eb2Smrg else version (CRuntime_Bionic)
49*627f7eb2Smrg     public import rt.sections_android;
50*627f7eb2Smrg else
51*627f7eb2Smrg     static assert(0, "unimplemented");
52*627f7eb2Smrg 
53*627f7eb2Smrg import rt.deh, rt.minfo;
54*627f7eb2Smrg 
isSectionGroup(T)55*627f7eb2Smrg template isSectionGroup(T)
56*627f7eb2Smrg {
57*627f7eb2Smrg     enum isSectionGroup =
58*627f7eb2Smrg         is(typeof(T.init.modules) == immutable(ModuleInfo*)[]) &&
59*627f7eb2Smrg         is(typeof(T.init.moduleGroup) == ModuleGroup) &&
60*627f7eb2Smrg         (!is(typeof(T.init.ehTables)) || is(typeof(T.init.ehTables) == immutable(FuncTable)[])) &&
61*627f7eb2Smrg         is(typeof(T.init.gcRanges) == void[][]) &&
62*627f7eb2Smrg         is(typeof({ foreach (ref T; T) {}})) &&
63*627f7eb2Smrg         is(typeof({ foreach_reverse (ref T; T) {}}));
64*627f7eb2Smrg }
65*627f7eb2Smrg static assert(isSectionGroup!(SectionGroup));
66*627f7eb2Smrg static assert(is(typeof(&initSections) == void function() nothrow @nogc));
67*627f7eb2Smrg static assert(is(typeof(&finiSections) == void function() nothrow @nogc));
68*627f7eb2Smrg static assert(is(typeof(&initTLSRanges) RT == return) &&
69*627f7eb2Smrg               is(typeof(&initTLSRanges) == RT function() nothrow @nogc) &&
70*627f7eb2Smrg               is(typeof(&finiTLSRanges) == void function(RT) nothrow @nogc) &&
71*627f7eb2Smrg               is(typeof(&scanTLSRanges) == void function(RT, scope void delegate(void*, void*) nothrow) nothrow));
72*627f7eb2Smrg 
version(Shared)73*627f7eb2Smrg version (Shared)
74*627f7eb2Smrg {
75*627f7eb2Smrg     static assert(is(typeof(&pinLoadedLibraries) == void* function() nothrow @nogc));
76*627f7eb2Smrg     static assert(is(typeof(&unpinLoadedLibraries) == void function(void*) nothrow @nogc));
77*627f7eb2Smrg     static assert(is(typeof(&inheritLoadedLibraries) == void function(void*) nothrow @nogc));
78*627f7eb2Smrg     static assert(is(typeof(&cleanupLoadedLibraries) == void function() nothrow @nogc));
79*627f7eb2Smrg }
80*627f7eb2Smrg 
scanDataSegPrecisely()81*627f7eb2Smrg bool scanDataSegPrecisely() nothrow @nogc
82*627f7eb2Smrg {
83*627f7eb2Smrg     import rt.config;
84*627f7eb2Smrg     string opt = rt_configOption("scanDataSeg");
85*627f7eb2Smrg     switch (opt)
86*627f7eb2Smrg     {
87*627f7eb2Smrg         case "":
88*627f7eb2Smrg         case "conservative":
89*627f7eb2Smrg             return false;
90*627f7eb2Smrg         case "precise":
91*627f7eb2Smrg             return true;
92*627f7eb2Smrg         default:
93*627f7eb2Smrg             __gshared err = new Error("DRT invalid scanDataSeg option, must be 'precise' or 'conservative'");
94*627f7eb2Smrg             throw err;
95*627f7eb2Smrg     }
96*627f7eb2Smrg }
97