#include "common.h"
static void *plugin_handle = NULL;
+int (*plugin_resource_set_cpu_boosting)(resource_pid_t pid, cpu_boosting_level_e level, cpu_boosting_flag_e flags, int timeout_msec) = NULL;
+int (*plugin_resource_clear_cpu_boosting)(resource_pid_t pid) = NULL;
+int (*plugin_resource_get_cpu_boosting_level)(resource_pid_t pid, cpu_boosting_level_info_t *level) = NULL;
+int (*plugin_resource_set_cpu_inheritance)(pid_t source_tid, const char *dest_process, int timeout_msec) = NULL;
+int (*plugin_resource_clear_cpu_inheritance)(pid_t source_tid, const char *dest_process) = NULL;
+int (*plugin_resource_register_cpu_inheritance_destination)(const char *dest_process, resource_pid_t pid) = NULL;
+int (*plugin_resource_unregister_cpu_inheritance_destination)(const char *dest_process) = NULL;
#define CPU_BOOSTING_PLUGIN_PATH PLUGIN_PATH"/libcapi-system-resource-plugin.so"
static int open_cpu_boosting_plugin(void)
{
- if (plugin_handle)
- return RESOURCE_ERROR_NONE;
-
if (access(CPU_BOOSTING_PLUGIN_PATH, F_OK) != 0) {
_E("[CPU-BOOSTING] Cannot find a plugin file");
return RESOURCE_ERROR_NO_SUCH_FILE;
}
- else {
- plugin_handle = dlopen(CPU_BOOSTING_PLUGIN_PATH, RTLD_NOW);
- if (!plugin_handle) {
- _E("[CPU-BOOSTING] Failed to load %s", CPU_BOOSTING_PLUGIN_PATH);
- return RESOURCE_ERROR_NOT_SUPPORTED;
- }
-
- return RESOURCE_ERROR_NONE;
+
+ plugin_handle = dlopen(CPU_BOOSTING_PLUGIN_PATH, RTLD_NOW);
+ if (!plugin_handle) {
+ _E("[CPU-BOOSTING] Failed to load %s", CPU_BOOSTING_PLUGIN_PATH);
+ return RESOURCE_ERROR_NOT_SUPPORTED;
}
+
+ plugin_resource_set_cpu_boosting =
+ dlsym(plugin_handle, "resource_set_cpu_boosting");
+ plugin_resource_clear_cpu_boosting =
+ dlsym(plugin_handle, "resource_clear_cpu_boosting");
+ plugin_resource_get_cpu_boosting_level =
+ dlsym(plugin_handle, "resource_get_cpu_boosting_level");
+ plugin_resource_set_cpu_inheritance =
+ dlsym(plugin_handle, "resource_set_cpu_inheritance");
+ plugin_resource_clear_cpu_inheritance =
+ dlsym(plugin_handle, "resource_clear_cpu_inheritance");
+ plugin_resource_register_cpu_inheritance_destination =
+ dlsym(plugin_handle, "resource_register_cpu_inheritance_destination");
+ plugin_resource_unregister_cpu_inheritance_destination =
+ dlsym(plugin_handle, "resource_unregister_cpu_inheritance_destination");
+
+ return RESOURCE_ERROR_NONE;
}
API int resource_set_cpu_boosting (resource_pid_t pid,
int ret;
int (*func)(resource_pid_t pid, cpu_boosting_level_e level, cpu_boosting_flag_e flags, int timeout_msec) = NULL;
- ret = open_cpu_boosting_plugin();
- if (ret != RESOURCE_ERROR_NONE)
- return ret;
-
- func = dlsym(plugin_handle, "resource_set_cpu_boosting");
+ func = plugin_resource_set_cpu_boosting;
if (!func) {
- _E("[CPU-BOOSTING] dlsym failed: %s", dlerror());
return RESOURCE_ERROR_NOT_SUPPORTED;
}
int ret;
int (*func)(resource_pid_t pid) = NULL;
- ret = open_cpu_boosting_plugin();
- if (ret != RESOURCE_ERROR_NONE)
- return ret;
-
- func = dlsym(plugin_handle, "resource_clear_cpu_boosting");
+ func = plugin_resource_clear_cpu_boosting;
if (!func) {
- _E("[CPU-BOOSTING] dlsym failed: %s", dlerror());
return RESOURCE_ERROR_NOT_SUPPORTED;
}
int ret;
int (*func)(resource_pid_t pid, cpu_boosting_level_info_t *level) = NULL;
- ret = open_cpu_boosting_plugin();
- if (ret != RESOURCE_ERROR_NONE)
- return ret;
-
- func = dlsym(plugin_handle, "resource_get_cpu_boosting_level");
+ func = plugin_resource_get_cpu_boosting_level;
if (!func) {
- _E("[CPU-BOOSTING] dlsym failed: %s", dlerror());
return RESOURCE_ERROR_NOT_SUPPORTED;
}
int ret;
int (*func)(pid_t source_tid, const char *dest_process, int timeout_msec) = NULL;
- ret = open_cpu_boosting_plugin();
- if (ret != RESOURCE_ERROR_NONE)
- return ret;
-
- func = dlsym(plugin_handle, "resource_set_cpu_inheritance");
+ func = plugin_resource_set_cpu_inheritance;
if (!func) {
- _E("[CPU-BOOSTING] dlsym failed: %s", dlerror());
return RESOURCE_ERROR_NOT_SUPPORTED;
}
int ret;
int (*func)(pid_t source_tid, const char *dest_process) = NULL;
- ret = open_cpu_boosting_plugin();
- if (ret != RESOURCE_ERROR_NONE)
- return ret;
-
- func = dlsym(plugin_handle, "resource_clear_cpu_inheritance");
+ func = plugin_resource_clear_cpu_inheritance;
if (!func) {
- _E("[CPU-BOOSTING] dlsym failed: %s", dlerror());
return RESOURCE_ERROR_NOT_SUPPORTED;
}
int ret;
int (*func)(const char *dest_process, resource_pid_t pid) = NULL;
- ret = open_cpu_boosting_plugin();
- if (ret != RESOURCE_ERROR_NONE)
- return ret;
-
- func = dlsym(plugin_handle, "resource_register_cpu_inheritance_destination");
+ func = plugin_resource_register_cpu_inheritance_destination;
if (!func) {
- _E("[CPU-BOOSTING] dlsym failed: %s", dlerror());
return RESOURCE_ERROR_NOT_SUPPORTED;
}
int ret;
int (*func)(const char *dest_process) = NULL;
- ret = open_cpu_boosting_plugin();
- if (ret != RESOURCE_ERROR_NONE)
- return ret;
-
- func = dlsym(plugin_handle, "resource_unregister_cpu_inheritance_destination");
+ func = plugin_resource_unregister_cpu_inheritance_destination;
if (!func) {
- _E("[CPU-BOOSTING] dlsym failed: %s", dlerror());
return RESOURCE_ERROR_NOT_SUPPORTED;
}
static void __CONSTRUCTOR__ cpu_boosting_init(void)
{
+ open_cpu_boosting_plugin();
}
static void __DESTRUCTOR__ cpu_boosting_exit(void)