Skip to content

Commit

Permalink
fixup! loader: Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jul 10, 2018
1 parent 582c7ff commit 21086a3
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions include/evmc/loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,30 @@ enum evmc_loader_error_code
};

/**
* Dynamically loads the shared object and with an EVM implementation.
* Dynamically loads the shared object (DLL) with an EVM implementation.
*
* This function tries to open a DLL at the given `filename`. On UNIX-like systems dlopen() function
* is used. On Windows LoadLibrary() function is used.
*
* If the file does not exists or is not a valid shared library the ::EVMC_ERRC_CANNOT_OPEN error
* If the file does not exist or is not a valid shared library the ::EVMC_ERRC_CANNOT_OPEN error
* code is signaled and NULL is returned.
*
* After the DLL is successfully loaded the function tries to find the EVM create function in the
* library. The `filename` is used to guess the EVM name and the name of the create function.
* The create function name is constructed as following:
* - the filename is taken from the path,
* - the "lib" prefix and file extension are stripped from the name,
* - all "-" are replaced with "_" to construct _full name_,
* - the last stem from the _full name_ separated with "_" is taken to construct the _short name_,
* - the name "evmc_create_" + _full name_ is checked in the library,
* - the name "evmc_create_" + _short name_ is checked in the library.
* The create function name is constructed by the following rules. Consider example path:
* "/ethereum/libexample-interpreter.so".
* - the filename is taken from the path:
* "libexample-interpreter.so",
* - the "lib" prefix and file extension are stripped from the name:
* "example-interpreter"
* - all "-" are replaced with "_" to construct _full name_:
* "example_interpreter",
* - the _full name_ is split by "_" char and the last item is taken to form the _short name_:
* "interpreter",
* - the name "evmc_create_" + _full name_ is checked in the library:
* "evmc_create_example_interpreter",
* - the name "evmc_create_" + _short name_ is checked in the library:
* "evmc_create_interpreter".
*
* If the create function is found in the library, the pointer to the function is returned.
* Otherwise, the ::EVMC_ERRC_SYMBOL_NOT_FOUND error code is signaled and NULL is returned.
Expand Down

0 comments on commit 21086a3

Please sign in to comment.