2 * This module exposes functionality for inspecting and manipulating memory.
4 * Copyright: Copyright (C) 2005-2006 Digital Mars, www.digitalmars.com.
7 * This software is provided 'as-is', without any express or implied
8 * warranty. In no event will the authors be held liable for any damages
9 * arising from the use of this software.
11 * Permission is granted to anyone to use this software for any purpose,
12 * including commercial applications, and to alter it and redistribute it
13 * freely, in both source and binary form, subject to the following
16 * o The origin of this software must not be misrepresented; you must not
17 * claim that you wrote the original software. If you use this software
18 * in a product, an acknowledgment in the product documentation would be
19 * appreciated but is not required.
20 * o Altered source versions must be plainly marked as such, and must not
21 * be misrepresented as being the original software.
22 * o This notice may not be removed or altered from any source
24 * Authors: Walter Bright, Sean Kelly
33 version = SimpleLibcStackEnd;
35 version( SimpleLibcStackEnd )
37 extern (C) extern void* __libc_stack_end;
40 extern (C) void gc_addRange( void* p, size_t sz );
41 extern (C) void gc_removeRange( void *p );
48 extern (C) void* rt_stackBottom()
61 version( SimpleLibcStackEnd )
63 return __libc_stack_end;
67 // See discussion: http://autopackage.org/forums/viewtopic.php?t=22
68 static void** libc_stack_end;
70 if( libc_stack_end == libc_stack_end.init )
72 void* handle = dlopen( null, RTLD_NOW );
73 libc_stack_end = cast(void**) dlsym( handle, "__libc_stack_end" );
76 return *libc_stack_end;
81 static assert( false, "Operating system not supported." );
89 extern (C) void* rt_stackTop()
91 version( D_InlineAsm_X86 )
102 static assert( false, "Architecture not supported." );
113 extern int _xi_a; // &_xi_a just happens to be start of data segment
114 extern int _edata; // &_edata is start of BSS segment
115 extern int _end; // &_end is past end of BSS
118 else version( linux )
123 extern int __data_start;
125 extern int _data_start__;
126 extern int _data_end__;
127 extern int _bss_start__;
128 extern int _bss_end__;
129 extern int __fini_array_end;
132 alias __data_start Data_Start;
138 void initStaticDataGC()
142 gc_addRange( &_xi_a, cast(size_t) &_end - cast(size_t) &_xi_a );
144 else version( linux )
146 gc_addRange( &__data_start, cast(size_t) &_end - cast(size_t) &__data_start );
150 static assert( false, "Operating system not supported." );