[haiku-3rdparty-dev] Re: Getting stack Top/Bottom of running application

  • From: Tomas Wilhelmsson <tomas.wilhelmsson@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Tue, 24 Nov 2009 22:36:58 +0100

> Again, define what you need exactly. Otherwise no-one can help you.
>
> CU, Ingo
>
>
Ok The grabage collector in D needs the stack top pointer and the stack
bottom pointer of the currently running application to work.

for example in Win32 the stack bottom is taken as so:

void *rt_stackBottm() {
        void* bottom;
        asm
        {
            mov EAX, FS:4;
            mov bottom, EAX;
        }
        return bottom;
}

in linux it is:

void *rt_stackBottm() {
            static void** libc_stack_end;

            if( libc_stack_end == libc_stack_end.init )
            {
                void* handle = dlopen( null, RTLD_NOW );
                libc_stack_end = cast(void**) dlsym( handle,
"__libc_stack_end" );
                dlclose( handle );
            }
           return *libc_stack_end;
}

what would be the equalent of these two in Haiku ?

And for the data segment start/end also needed by the GC for cleanups

The Data_Start should point to the data segment in the memory where the file
was loaded i guess and
Data_End should point to where it ends.

the alias keyword is like the #define in C, just defines Data_Start/Data_End
to _data_start__ and _bss_end__


also here for example in win32 they do:

        extern (C)
        {
            extern int _data_start__;
            extern int _bss_end__;
        }

        alias _data_start__ Data_Start;
        alias _bss_end__    Data_End;

and in linux:

        extern (C)
        {
            extern int _data;
            extern int __data_start;
            extern int _end;
            extern int _data_start__;
            extern int _data_end__;
            extern int _bss_start__;
            extern int _bss_end__;
            extern int __fini_array_end;
        }

        alias __data_start  Data_Start;
        alias _end          Data_End;

and also here, what would be the equalent to do in Haiku to get where the
data segment starts/ends of the currently running application =)

Thanks alot for trying to help, i know im very bad at explaining and its
mostly due to that i dont understand this stuff fully myself :/

Other related posts: