[llvm-commits] [PATCH] Look up symbols in a specific library with DynamicLibrary

Jordy Rose jediknil at belkadan.com
Thu Aug 11 13:20:13 PDT 2011


On Aug 11, 2011, at 11:53, David Blaikie wrote:

> It'd be a pity if we couldn't make something more RAII-esque, though I
> agree it's hard without movement support. I haven't looked closely -
> but is there any (portable) way to duplicate a dynamic library handle?
> In which case the copy ctor could just use that & the dtor could
> dlclose & then we could return by value, etc, with relatively low
> cost. (the only alternative, while preserving RAII-esque semantics, is
> for the DynamicLibrary to remember what file/options it used & dlopen
> on every copy (knowing it'll hit the OS's cache) which is probably
> still pretty costly even for a cache hit)

dlopen does its own caching (otherwise it wouldn't be guaranteed to return the same handle each time), but remembering the file/options in each DynamicLibrary instance is probably a waste of space. Ah, well. And no handle-copying in dlfcn.h.

I will leave the semantics the way they are now, only allowing permanent loads and ignoring ref-counting. Thanks for the review.

Jordy



More information about the llvm-commits mailing list