Before this commit, the following will trigger a complete rebuild: - create another git name (git checkout -b test) - run cmake again manually (cmake ..) - run ninja again The top-level CMakeLists.txt uses add_definitions() to add git information to all targets; if some git information changes, this will mark all command lines as dirty, triggering the build. There is an easy solution: instead of passing this information on the command line, pass it in a header. This commit uses configure_file() to generate a file oai_version.h in the build directory with the same information. Various sources files, e.g., main executables, use this to output the same information as before. It is then also not necessary to use header guards, as cmake takes care to create this file. If cmake is re-run, it will update the header, and trigger only files including this header will be rebuilt (which can be shown with the above stpes). The information passed is the same as before, and updates the information when the old method would have updated it.
25 lines
2.9 KiB
Markdown
25 lines
2.9 KiB
Markdown
Loader API is defined in the [common/utils/load_module_shlib.h](https://gitlab.eurecom.fr/oai/openairinterface5g/blob/develop/common/utils/load_module_shlib.h) include file.
|
|
```c
|
|
int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf)
|
|
```
|
|
* possibly initializes the loader, if it has not been already initialized
|
|
* Formats the full shared library path, using the `modname` argument and the loader `shlibpath` and `shlibversion`configuration parameters.
|
|
* loads the shared library, using the dlopen system call
|
|
* looks for `< modname >_autoinit` symbol, using the `dlsym` system call and possibly call the corresponding function.
|
|
* looks for `< modname >_checkbuildver` symbol, using the `dlsym` system call and possibly calls the corresponding function. If the return value of this call is `-1`, program execution is stopped. It is the responsibility of the shared library developer to implement or not a `< modname >_checkbuildver` function and to decide if a version mismatch is a fatal condition. The `< modname >_checkbuildver` function must match the `checkverfunc_t` function type. The first argument is the main executable version, as set in the `OAI_PACKAGE_VERSION` macro defined in the [`common/CMakeLists`](../../../CMakeLists). The second argument points to the shared library version which should be set by the `< modname >_checkbuildver` function.
|
|
* If the farray pointer is null, looks for `< modname >_getfarray` symbol, calls the corresponding function when the symbol is found. `< modname >_getfarray` takes one argument, a pointer to a `loader_shlibfunc_t` array, and returns the number of items in this array, as defined by the `getfarrayfunc_t` type. The `loader_shlibfunc_t` array returned by the shared library must be fully filled (both `fname` and `fptr` fields).
|
|
* looks for the `numf` function symbols listed in the `farray[i].fname` arguments and set the corresponding `farray[i].fptr`function pointers
|
|
|
|
```c
|
|
int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *farray, int numf)
|
|
```
|
|
Allows loading a specific library version, as specified by the `version` parameter. When version is not NULL the version that is possibly specified as a config module parameter is ignored. This call has been introduced for phy simulators executables which do not use the config module. It is used, for example, by the ldcp initialization (`load_nrLDPClib` function in [nrLDPC_load.c](../../../../../openair1/PHY/CODING/nrLDPC_load.c) to allow the `ldpctest` simulator to select the cuda accelerated ldcp implementation. `load_module_shlib` is just a define macro to switch to a `load_module_version_shlib` call, adding a NULL pointer for the version parameter.
|
|
|
|
```c
|
|
void * get_shlibmodule_fptr(char *modname, char *fname)
|
|
```
|
|
Returns a pointer to the symbol `fname`, defined in module `modname`, or `NULL` if the symbol is not found.
|
|
|
|
[loader home page](../../loader.md)
|
|
[loader developer home page](../devusage.md)
|