#define CPU_BOOSTING_PLUGIN_PATH PLUGIN_PATH"/libcapi-system-resource-plugin.so"
-static void open_cpu_boosting_plugin(void)
+static int open_cpu_boosting_plugin(void)
{
- if (access(CPU_BOOSTING_PLUGIN_PATH, F_OK) != 0) {
+ 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)
+ if (!plugin_handle) {
_E("[CPU-BOOSTING] Failed to load %s", CPU_BOOSTING_PLUGIN_PATH);
+ return RESOURCE_ERROR_NOT_SUPPORTED;
+ }
+
+ return RESOURCE_ERROR_NONE;
}
}
int ret;
int (*func)(resource_pid_t pid, cpu_boosting_level_e level, int timeout_msec) = NULL;
- if (!plugin_handle)
- return RESOURCE_ERROR_NO_SUCH_FILE;
+ ret = open_cpu_boosting_plugin();
+ if (ret != RESOURCE_ERROR_NONE)
+ return ret;
func = dlsym(plugin_handle, "resource_set_cpu_boosting");
if (!func) {
int ret;
int (*func)(resource_pid_t pid) = NULL;
- if (!plugin_handle)
- return RESOURCE_ERROR_NO_SUCH_FILE;
+ ret = open_cpu_boosting_plugin();
+ if (ret != RESOURCE_ERROR_NONE)
+ return ret;
func = dlsym(plugin_handle, "resource_clear_cpu_boosting");
if (!func) {
int ret;
int (*func)(resource_pid_t pid, cpu_boosting_level_info_t *level) = NULL;
- if (!plugin_handle)
- return RESOURCE_ERROR_NO_SUCH_FILE;
+ ret = open_cpu_boosting_plugin();
+ if (ret != RESOURCE_ERROR_NONE)
+ return ret;
func = dlsym(plugin_handle, "resource_get_cpu_boosting_level");
if (!func) {
int ret;
int (*func)(int source_tid, char *dest_process, int timeout_msec) = NULL;
- if (!plugin_handle)
- return RESOURCE_ERROR_NO_SUCH_FILE;
+ ret = open_cpu_boosting_plugin();
+ if (ret != RESOURCE_ERROR_NONE)
+ return ret;
func = dlsym(plugin_handle, "resource_set_cpu_inheritance");
if (!func) {
int ret;
int (*func)(int source_tid, char *dest_process) = NULL;
- if (!plugin_handle)
- return RESOURCE_ERROR_NO_SUCH_FILE;
+ ret = open_cpu_boosting_plugin();
+ if (ret != RESOURCE_ERROR_NONE)
+ return ret;
func = dlsym(plugin_handle, "resource_clear_cpu_inheritance");
if (!func) {
int ret;
int (*func)(char *dest_process, resource_pid_t pid) = NULL;
- if (!plugin_handle)
- return RESOURCE_ERROR_NO_SUCH_FILE;
+ ret = open_cpu_boosting_plugin();
+ if (ret != RESOURCE_ERROR_NONE)
+ return ret;
func = dlsym(plugin_handle, "resource_register_cpu_inheritance_destination");
if (!func) {
int ret;
int (*func)(char *dest_process) = NULL;
- if (!plugin_handle)
- return RESOURCE_ERROR_NO_SUCH_FILE;
+ ret = open_cpu_boosting_plugin();
+ if (ret != RESOURCE_ERROR_NONE)
+ return ret;
func = dlsym(plugin_handle, "resource_unregister_cpu_inheritance_destination");
if (!func) {
static void __CONSTRUCTOR__ cpu_boosting_init(void)
{
- open_cpu_boosting_plugin();
- if (!plugin_handle)
- _E("[CPU-BOOSTING] Failed to open CPU boosting plugin");
- else
- _D("[CPU-BOOSTING] plugin handle (open) = %p", plugin_handle);
}
static void __DESTRUCTOR__ cpu_boosting_exit(void)
{
- _D("[CPU-BOOSTING] plugin handle (close) = %p", plugin_handle);
- if (plugin_handle)
- dlclose(plugin_handle);
}
cpu_boosting_level_e level, int timeout_msec)
{
_D("[CPU-BOOSTING-PLUGIN] %s called", __func__);
- for (int i = 0; i < pid.tid_count; i++) {
- _D("[CPU-BOOSTING-PLUGIN] pid = %d, tid = %d", pid.pid, pid.tid[i]);
- }
return 0;
}
API int resource_clear_cpu_boosting (resource_pid_t pid)
{
_D("[CPU-BOOSTING-PLUGIN] %s called", __func__);
- for (int i = 0; i < pid.tid_count; i++) {
- _D("[CPU-BOOSTING-PLUGIN] pid = %d, tid = %d", pid.pid, pid.tid[i]);
- }
return 0;
}
cpu_boosting_level_info_t *level)
{
_D("[CPU-BOOSTING-PLUGIN] %s called", __func__);
- for (int i = 0; i < pid.tid_count; i++) {
- _D("[CPU-BOOSTING-PLUGIN] pid = %d, tid = %d", pid.pid, pid.tid[i]);
- }
return 0;
}