Modify tid and pid from int to pid_t 66/277266/1 accepted/tizen/6.5/unified/20220704.213120 submit/tizen_6.5/20220704.075646
authorUnsung Lee <unsung.lee@samsung.com>
Mon, 4 Jul 2022 05:45:19 +0000 (14:45 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 4 Jul 2022 07:50:55 +0000 (07:50 +0000)
Change-Id: I6bf4914fb1dc7f0c75c73e0292264b48625249bf
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
(cherry picked from commit 56d356846f6ddea53d60107268e65ed899516528)

include/cpu-boosting-type.h
include/cpu-boosting.h
src/cpu-boosting.c
src/plugin/plugin.c
tests/main.c

index be23729..79084ee 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef __TIZEN_SYSTEM_CPU_BOOSTING_TYPE_H__
 #define __TIZEN_SYSTEM_CPU_BOOSTING_TYPE_H__
 
+#include <sys/types.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -36,8 +38,8 @@ typedef enum resource_cpu_boosting_level {
 } cpu_boosting_level_e;
 
 typedef struct resource_pid_info {
-       int pid;
-       int *tid;
+       pid_t pid;
+       pid_t *tid;
        int tid_count;
 } resource_pid_t;
 
index e705d76..c62a20c 100644 (file)
@@ -99,7 +99,7 @@ int resource_get_cpu_boosting_level (resource_pid_t pid, cpu_boosting_level_info
  *
  * @return 0 on success, otherwise a negative error value.
  */
-int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec);
+int resource_set_cpu_inheritance (pid_t source_tid, const char *dest_process, int timeout_msec);
 
 /**
  * @brief Clear cpu resource inheritance from the source tid to the destination process (pid/tids).
@@ -112,7 +112,7 @@ int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int
  *
  * @return 0 on success, otherwise a negative error value.
  */
-int resource_clear_cpu_inheritance (int source_tid, const char *dest_process);
+int resource_clear_cpu_inheritance (pid_t source_tid, const char *dest_process);
 
 /**
  * @brief Register a destination process (pid/tids) for cpu resource inheritance.
index 884b4f5..3841978 100644 (file)
@@ -124,10 +124,10 @@ API int resource_get_cpu_boosting_level (resource_pid_t pid,
        return ret;
 }
 
-API int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec)
+API int resource_set_cpu_inheritance (pid_t source_tid, const char *dest_process, int timeout_msec)
 {
        int ret;
-       int (*func)(int source_tid, const char *dest_process, int timeout_msec) = NULL;
+       int (*func)(pid_t source_tid, const char *dest_process, int timeout_msec) = NULL;
 
        ret = open_cpu_boosting_plugin();
        if (ret != RESOURCE_ERROR_NONE)
@@ -148,10 +148,10 @@ API int resource_set_cpu_inheritance (int source_tid, const char *dest_process,
        return ret;
 }
 
-API int resource_clear_cpu_inheritance (int source_tid, const char *dest_process)
+API int resource_clear_cpu_inheritance (pid_t source_tid, const char *dest_process)
 {
        int ret;
-       int (*func)(int source_tid, const char *dest_process) = NULL;
+       int (*func)(pid_t source_tid, const char *dest_process) = NULL;
 
        ret = open_cpu_boosting_plugin();
        if (ret != RESOURCE_ERROR_NONE)
index a3588fa..598c1b3 100644 (file)
@@ -96,7 +96,7 @@ static inline bool resource_cpu_boosting_level_input_is_valid(cpu_boosting_level
 API int resource_set_cpu_boosting (resource_pid_t pid,
                cpu_boosting_level_e level, int timeout_msec)
 {
-       int tid;
+       pid_t tid;
        int byte;
        int ret = 0;
        int sock;
@@ -126,7 +126,7 @@ API int resource_set_cpu_boosting (resource_pid_t pid,
                        input.pid.tid_count = 1;
                }
 
-               input.body_size = input.pid.tid_count * sizeof(int);
+               input.body_size = input.pid.tid_count * sizeof(pid_t);
        }
 
        byte = send(sock, (const void *)&input, sizeof(input), 0);
@@ -186,14 +186,14 @@ API int resource_get_cpu_boosting_level (resource_pid_t pid,
        return 0;
 }
 
-API int resource_set_cpu_inheritance (int source_tid, const char *dest_process, int timeout_msec)
+API int resource_set_cpu_inheritance (pid_t source_tid, const char *dest_process, int timeout_msec)
 {
        _D("[CPU-BOOSTING-PLUGIN] %s called", __func__);
 
        return 0;
 }
 
-API int resource_clear_cpu_inheritance (int source_tid, const char *dest_process)
+API int resource_clear_cpu_inheritance (pid_t source_tid, const char *dest_process)
 {
        _D("[CPU-BOOSTING-PLUGIN] %s called", __func__);
 
index 1e7f0a4..fd4d8e0 100644 (file)
@@ -46,7 +46,7 @@
 
 static void *thread_worker(void *arg)
 {
-       int *tid = (int *)arg;
+       pid_t *tid = (pid_t *)arg;
        if (tid)
                *tid = gettid();
 
@@ -145,7 +145,7 @@ static void one_process_multi_thread_test(int tid_count)
        if (tid_count < 1)
                return;
 
-       pid.tid = (int *)calloc(tid_count, sizeof(int));
+       pid.tid = (pid_t *)calloc(tid_count, sizeof(pid_t));
        if (pid.tid == NULL) {
                _E("[CPU-BOOSTING-TEST] Failed to allocate memory for tids");
                return;