On Thu, Mar 31, 2016 at 5:23 AM, Laurent Bartholdi <laurent.bartho...@gmail.com> wrote: > Thanks for the quick reply! Yes, that would be wonderful. > > I want to interface to a library that has its own garbage collection; that > library walks the stack to find potential objects that must be kept alive. > Therefore, all calls to that library must be done in the form > library_global_StackBottomBags = __builtin_frame_address(0); > library_function(...)
OK, this is a reasonable use case if the library requires this.... It's a weird API though. You can use llvm intrinsics to do that. This is basically how `__builtin_frame_address` is implemented in clang. julia> function f() Base.llvmcall((""" declare i8 *@llvm.frameaddress(i32) """, """ %1 = call i8 *@llvm.frameaddress(i32 0) ret i8 *%1 """), Ptr{UInt8}, Tuple{}) end f (generic function with 1 method) julia> f() Ptr{UInt8} @0x00007ffecb9a3130 > > > On Thursday, 31 March 2016 00:25:13 UTC+2, Yichao Yu wrote: >> >> >> On Mar 30, 2016 6:22 PM, "Yichao Yu" <yyc...@gmail.com> wrote: >> > >> > >> > On Mar 30, 2016 6:21 PM, "Laurent Bartholdi" <laurent....@gmail.com> >> > wrote: >> > > >> > > Hi, >> > > Is there a way to obtain the address of the current stack frame (the >> > > ebp register on x86 processors)? >> > > >> > > In GCC, there's the bultin primitive __builtin_frame_address() that >> > > does precisely that. >> > >> > Why do you want this? >> > >> >> It's possible but should not be done in general. >> >> > > >> > > Many thanks in advance, Laurent