Module Gccjit.Result

val code : result -> string -> ('a -> 'b) Ctypes.fn -> 'a -> 'b

Locate a given function within the built machine code.

  • Functions are looked up by name. For this to succeed, a function with a name matching funcname must have been created on result's context (or a parent context) via a call to Function.create with kind Exported.
  • If such a function is not found, an error will be raised.
  • If the function is found, the result is cast to the given Ctypes signature. Care must be taken to pass a signature compatible with that of function being extracted.
  • The resulting machine code becomes invalid after release is called on the result; attempting to call it after that may lead to a segmentation fault.
val global : result -> string -> 'a Ctypes.typ -> 'a Ctypes.ptr

Locate a given global within the built machine code.

  • Globals are looked up by name. For this to succeed, a global with a name matching name must have been created on result's context (or a parent context) via a call to LValue.global with kind Exported.
  • If the global is found, the result is cast to the Given Ctypes type.
  • This is a pointer to the global, so e.g. for an int this is an int *.
  • If such a global is not found, an error will be raised.
  • The resulting address becomes invalid after release is called on the result; attempting to use it after that may lead to a segmentation fault.
val release : result -> unit

Once we're done with the code, this unloads the built .so file. This cleans up the result; after calling this, it's no longer valid to use the result, or any code or globals that were obtained by calling code or global on it.