]>
Commit | Line | Data |
---|---|---|
03385ed3 | 1 | /** |
2 | * Written in the D programming language. | |
3 | * This module provides Solaris-specific support for sections. | |
4 | * | |
5 | * Copyright: Copyright Martin Nowak 2012-2013. | |
6 | * License: $(WEB www.boost.org/LICENSE_1_0.txt, Boost License 1.0). | |
7 | * Authors: Martin Nowak | |
8 | * Source: $(DRUNTIMESRC src/rt/_sections_solaris.d) | |
9 | */ | |
10 | ||
11 | module rt.sections_solaris; | |
12 | ||
13 | version (Solaris): | |
14 | ||
15 | // debug = PRINTF; | |
16 | debug(PRINTF) import core.stdc.stdio; | |
17 | import core.stdc.stdlib : malloc, free; | |
18 | import rt.deh, rt.minfo; | |
19 | ||
20 | struct SectionGroup | |
21 | { | |
22 | static int opApply(scope int delegate(ref SectionGroup) dg) | |
23 | { | |
24 | return dg(_sections); | |
25 | } | |
26 | ||
27 | static int opApplyReverse(scope int delegate(ref SectionGroup) dg) | |
28 | { | |
29 | return dg(_sections); | |
30 | } | |
31 | ||
22163f0d | 32 | @property immutable(ModuleInfo*)[] modules() const nothrow @nogc |
03385ed3 | 33 | { |
34 | return _moduleGroup.modules; | |
35 | } | |
36 | ||
22163f0d | 37 | @property ref inout(ModuleGroup) moduleGroup() inout nothrow @nogc |
03385ed3 | 38 | { |
39 | return _moduleGroup; | |
40 | } | |
41 | ||
22163f0d | 42 | @property immutable(FuncTable)[] ehTables() const nothrow @nogc |
03385ed3 | 43 | { |
44 | auto pbeg = cast(immutable(FuncTable)*)&__start_deh; | |
45 | auto pend = cast(immutable(FuncTable)*)&__stop_deh; | |
46 | return pbeg[0 .. pend - pbeg]; | |
47 | } | |
48 | ||
22163f0d | 49 | @property inout(void[])[] gcRanges() inout nothrow @nogc |
03385ed3 | 50 | { |
51 | return _gcRanges[]; | |
52 | } | |
53 | ||
54 | private: | |
55 | ModuleGroup _moduleGroup; | |
56 | void[][1] _gcRanges; | |
57 | } | |
58 | ||
59 | void initSections() nothrow @nogc | |
60 | { | |
61 | auto mbeg = cast(immutable ModuleInfo**)&__start_minfo; | |
62 | auto mend = cast(immutable ModuleInfo**)&__stop_minfo; | |
63 | _sections.moduleGroup = ModuleGroup(mbeg[0 .. mend - mbeg]); | |
64 | ||
65 | auto pbeg = cast(void*)&__dso_handle; | |
66 | auto pend = cast(void*)&_end; | |
67 | _sections._gcRanges[0] = pbeg[0 .. pend - pbeg]; | |
68 | } | |
69 | ||
70 | void finiSections() nothrow @nogc | |
71 | { | |
72 | } | |
73 | ||
74 | void[] initTLSRanges() nothrow @nogc | |
75 | { | |
76 | auto pbeg = cast(void*)&_tlsstart; | |
77 | auto pend = cast(void*)&_tlsend; | |
78 | return pbeg[0 .. pend - pbeg]; | |
79 | } | |
80 | ||
81 | void finiTLSRanges(void[] rng) nothrow @nogc | |
82 | { | |
83 | } | |
84 | ||
85 | void scanTLSRanges(void[] rng, scope void delegate(void* pbeg, void* pend) nothrow dg) nothrow | |
86 | { | |
87 | dg(rng.ptr, rng.ptr + rng.length); | |
88 | } | |
89 | ||
90 | private: | |
91 | ||
92 | __gshared SectionGroup _sections; | |
93 | ||
94 | extern(C) | |
95 | { | |
96 | /* Symbols created by the compiler/linker and inserted into the | |
97 | * object file that 'bracket' sections. | |
98 | */ | |
99 | extern __gshared | |
100 | { | |
101 | void* __start_deh; | |
102 | void* __stop_deh; | |
103 | void* __start_minfo; | |
104 | void* __stop_minfo; | |
105 | int __dso_handle; | |
106 | int _end; | |
107 | } | |
108 | ||
109 | extern | |
110 | { | |
111 | void* _tlsstart; | |
112 | void* _tlsend; | |
113 | } | |
114 | } |