Enhance loader to allow library version selection for executables, as ldcptest which do not use the config module.
This commit is contained in:
@@ -10,6 +10,10 @@ int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf)
|
||||
* 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)
|
||||
|
||||
@@ -63,7 +63,7 @@ void loader_init(void) {
|
||||
}
|
||||
|
||||
/* build the full shared lib name from the module name */
|
||||
char *loader_format_shlibpath(char *modname)
|
||||
char *loader_format_shlibpath(char *modname, char *version)
|
||||
{
|
||||
|
||||
char *tmpstr;
|
||||
@@ -97,7 +97,10 @@ int ret;
|
||||
shlibpath = loader_data.shlibpath ;
|
||||
}
|
||||
/* no specific shared lib version */
|
||||
if (shlibversion == NULL) {
|
||||
if (version != NULL) { // version specified as a function parameter
|
||||
shlibversion=version;
|
||||
}
|
||||
if (shlibversion == NULL) { // no specific version specified, neither as a config param or as a function param
|
||||
shlibversion = "" ;
|
||||
}
|
||||
/* alloc memory for full module shared lib file name */
|
||||
@@ -118,7 +121,7 @@ int ret;
|
||||
return tmpstr;
|
||||
}
|
||||
|
||||
int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf, void *autoinit_arg)
|
||||
int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *farray, int numf, void *autoinit_arg)
|
||||
{
|
||||
void *lib_handle = NULL;
|
||||
initfunc_t fpi;
|
||||
@@ -138,7 +141,7 @@ int load_module_shlib(char *modname,loader_shlibfunc_t *farray, int numf, void *
|
||||
loader_init();
|
||||
}
|
||||
|
||||
shlib_path = loader_format_shlibpath(modname);
|
||||
shlib_path = loader_format_shlibpath(modname, version);
|
||||
|
||||
for (int i = 0; i < loader_data.numshlibs; i++) {
|
||||
if (strcmp(loader_data.shlibs[i].name, modname) == 0) {
|
||||
|
||||
@@ -84,10 +84,11 @@ loader_data_t loader_data;
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------*/
|
||||
#else /* LOAD_MODULE_SHLIB_MAIN */
|
||||
extern int load_module_shlib(char *modname, loader_shlibfunc_t *farray, int numf, void *initfunc_arg);
|
||||
|
||||
extern int load_module_version_shlib(char *modname, char *version, loader_shlibfunc_t *farray, int numf, void *initfunc_arg);
|
||||
extern void * get_shlibmodule_fptr(char *modname, char *fname);
|
||||
extern loader_data_t loader_data;
|
||||
#endif /* LOAD_MODULE_SHLIB_MAIN */
|
||||
|
||||
#define load_module_shlib(M, F, N, I) load_module_version_shlib(M, NULL, F, N, I)
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user