diff --git a/src/os/shared/inc/os-shared-module.h b/src/os/shared/inc/os-shared-module.h index 3c93c2345..f65d03cc5 100644 --- a/src/os/shared/inc/os-shared-module.h +++ b/src/os/shared/inc/os-shared-module.h @@ -30,6 +30,8 @@ #include +#define OS_MODULE_FLAG_IS_STATIC 0x1 + typedef struct { char module_name[OS_MAX_API_NAME]; diff --git a/src/os/shared/src/osapi-module.c b/src/os/shared/src/osapi-module.c index 8b690e7d4..689ea996b 100644 --- a/src/os/shared/src/osapi-module.c +++ b/src/os/shared/src/osapi-module.c @@ -232,7 +232,12 @@ int32 OS_ModuleLoad(osal_id_t *module_id, const char *module_name, const char *f * returns OS_ERR_NAME_NOT_FOUND. */ return_code = OS_ModuleLoad_Static(module_name); - if (return_code != OS_SUCCESS) + if (return_code == OS_SUCCESS) + { + /* mark this as a statically loaded module */ + OS_module_table[local_id].flags |= OS_MODULE_FLAG_IS_STATIC; + } + else { /* * If this is NOT a static module, then the module file must be loaded by normal @@ -280,9 +285,14 @@ int32 OS_ModuleUnload(osal_id_t module_id) if (return_code == OS_SUCCESS) { /* - * Only call the implementation if the loader is enabled + * Only call the implementation if the file was actually loaded. + * If this is a static module, then this is just a placeholder and + * it means there was no file actually loaded. */ - return_code = OS_ModuleUnload_Impl(local_id); + if ((OS_module_table[local_id].flags & OS_MODULE_FLAG_IS_STATIC) == 0) + { + return_code = OS_ModuleUnload_Impl(local_id); + } /* Complete the operation via the common routine */ return_code = OS_ObjectIdFinalizeDelete(return_code, record);