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;
46 extern (C) void* rt_stackBottom()
59 version( SimpleLibcStackEnd )
61 return __libc_stack_end;
65 // See discussion: http://autopackage.org/forums/viewtopic.php?t=22
66 static void** libc_stack_end;
68 if( libc_stack_end == libc_stack_end.init )
70 void* handle = dlopen( null, RTLD_NOW );
71 libc_stack_end = cast(void**) dlsym( handle, "__libc_stack_end" );
74 return *libc_stack_end;
79 static assert( false, "Operating system not supported." );
87 extern (C) void* rt_stackTop()
89 version( D_InlineAsm_X86 )
100 static assert( false, "Architecture not supported." );
111 extern int _xi_a; // &_xi_a just happens to be start of data segment
112 extern int _edata; // &_edata is start of BSS segment
113 extern int _end; // &_end is past end of BSS
116 else version( linux )
121 extern int __data_start;
123 extern int _data_start__;
124 extern int _data_end__;
125 extern int _bss_start__;
126 extern int _bss_end__;
127 extern int __fini_array_end;
130 alias __data_start Data_Start;
134 alias void delegate( void*, void* ) scanFn;
141 extern (C) void rt_scanStaticData( scanFn scan )
145 scan( &_xi_a, &_end );
147 else version( linux )
149 scan( &__data_start, &_end );
153 static assert( false, "Operating system not supported." );