Skip to content

Instantly share code, notes, and snippets.

@gerdr

gerdr/dll.md Secret

Last active December 24, 2015 09:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerdr/aabd97a9637e0720ccf4 to your computer and use it in GitHub Desktop.
Save gerdr/aabd97a9637e0720ccf4 to your computer and use it in GitHub Desktop.

MoarVM DLL handling

I propose the following additions to the codebase:

structs

  • MVMDLLibRegistry

Wraps dyncall's DLLib* together with a string id in a per-instance hash.

Keeps track of a refcount to prevent the user from prematurely freeing a library.

reprs

  • DLSym

Wraps the pointer returned by dlFindSymbol() together with a MVMDLLibRegistry*.

Conjecture: This will be the argument to the (yet to be implemented) loadextop (or whatever we end up calling it) and could be used as input to my ptrcast op from the ctypes branch. (adding exptops by symbol is probably not a good idea)

ops

  • loadlib(str id, str path)
  • freelib(str id)
  • findsym(str id, str name) -> obj sym
  • dropsym(obj sym)

dropsym sets a symbol to NULL, decreasing the refcount of the containing library.

Open question: How should loadlib handle libraries that (according to their id) have already been loaded? Silently ignore, throw or via return value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment