[FIX] include paths (capi-system-runtime-info)
[platform/core/system/swap-probe.git] / custom_chart / da_chart.c
index 99e2538..801e0fc 100755 (executable)
@@ -137,7 +137,7 @@ void* _chart_timerThread(void* data)
                        PACK_COMMON_BEGIN(MSG_PROBE_CUSTOM,
                                          API_ID__chart_timerThread,
                                          "", 0);
-                       PACK_COMMON_END(0, 0, 2);
+                       PACK_COMMON_END('p', 0, 0, 2);
                        PACK_CUSTOM(cur->series_handle, 0, "", 0, value);
                        FLUSH_LOCAL_BUF();
 
@@ -196,17 +196,21 @@ static int start_callback_thread(chart_interval interval)
                return ERR_WRONG_PARAMETER;
        }
 
-       if(*timerfd != -1 || *thread_handle != -1)
+       /**
+        * FIXME: Type of pthread_t is undefined.
+        * Comparing it with -1 is *very* bad
+        */
+       if (*timerfd != -1 || *thread_handle != (pthread_t) -1)
                return 0;               // already thread exist
 
        *timerfd = timerfd_create(CLOCK_REALTIME, 0);
-       if(*timerfd == -1)
+       if (*timerfd == -1)
                return errno;
 
-       if(timerfd_settime(*timerfd, 0, &timevalue, NULL) == -1)
+       if (timerfd_settime(*timerfd, 0, &timevalue, NULL) == -1)
                return errno;
 
-       if(pthread_create(thread_handle, NULL, _chart_timerThread, pman) < 0)
+       if (pthread_create(thread_handle, NULL, _chart_timerThread, pman) < 0)
                return ERR_THREAD_CREATE_FAIL;
 
        return 0;
@@ -389,9 +393,6 @@ static void remove_from_callback_list(da_handle charthandle, da_handle series_ha
 // constructor and destructor functions
 // =====================================================================
 
-void memory_initialize_hook(void);
-void (*__malloc_initialize_hook) (void) = memory_initialize_hook;
-
 void __attribute__((constructor)) _init_lib()
 {
        probeBlockStart();
@@ -415,25 +416,19 @@ void __attribute__((destructor)) _fini_lib()
        probeBlockStart();
 
        remove_all_callback_list();
-       if(chm.interval_10ms.timerfd != -1)
+       if (chm.interval_10ms.timerfd != -1)
                close(chm.interval_10ms.timerfd);
-       if(chm.interval_100ms.timerfd != -1)
+       if (chm.interval_100ms.timerfd != -1)
                close(chm.interval_100ms.timerfd);
-       if(chm.interval_1s.timerfd != -1)
+       if (chm.interval_1s.timerfd != -1)
                close(chm.interval_1s.timerfd);
-
-       if(chm.interval_10ms.thread_handle != -1)
-       {
+       /*! Bad. Ugly. Unportable */
+       if (chm.interval_10ms.thread_handle != (pthread_t) -1)
                pthread_join(chm.interval_10ms.thread_handle, NULL);
-       }
-       if(chm.interval_100ms.thread_handle != -1)
-       {
+       if (chm.interval_100ms.thread_handle != (pthread_t) -1)
                pthread_join(chm.interval_100ms.thread_handle, NULL);
-       }
-       if(chm.interval_1s.thread_handle != -1)
-       {
+       if (chm.interval_1s.thread_handle != (pthread_t) -1)
                pthread_join(chm.interval_1s.thread_handle, NULL);
-       }
 
        probeBlockEnd();
 }
@@ -454,8 +449,8 @@ void da_mark(chart_color color, char* mark_text)
        PREPARE_LOCAL_BUF();
        PACK_COMMON_BEGIN(MSG_PROBE_CUSTOM,
                          API_ID_da_mark,
-                         "dp", color, mark_text);
-       PACK_COMMON_END(0, 0, 2);
+                         "dp", color, voidp_to_uint64(mark_text));
+       PACK_COMMON_END('v', 0, 0, 2);
        PACK_CUSTOM(0, 0, mark_text, color, 0.0f);
        FLUSH_LOCAL_BUF();
 
@@ -482,8 +477,8 @@ da_handle da_create_chart(char* chart_name)
        PREPARE_LOCAL_BUF();
        PACK_COMMON_BEGIN(MSG_PROBE_CUSTOM,
                          API_ID_da_create_chart,
-                         "p", chart_name);
-       PACK_COMMON_END(ret, 0, 2);
+                         "p", voidp_to_uint64(chart_name));
+       PACK_COMMON_END('d', ret, 0, 2);
        PACK_CUSTOM(0, 0, chart_name, 0, 0.0f);
        FLUSH_LOCAL_BUF();
 
@@ -518,8 +513,9 @@ da_handle da_create_series(da_handle charthandle, char* seriesname,
        PREPARE_LOCAL_BUF();
        PACK_COMMON_BEGIN(MSG_PROBE_CUSTOM,
                          API_ID_da_create_series,
-                         "dpdd",  charthandle, seriesname, type, color);
-       PACK_COMMON_END(ret, 0, 2);
+                         "dpdd",  charthandle, voidp_to_uint64(seriesname),
+                         type, color);
+       PACK_COMMON_END('d', ret, 0, 2);
        PACK_CUSTOM(charthandle, type, seriesname, color, 0.0f);
        FLUSH_LOCAL_BUF();
 
@@ -592,8 +588,8 @@ void da_log(da_handle series_handle, float uservalue)
        PREPARE_LOCAL_BUF();
        PACK_COMMON_BEGIN(MSG_PROBE_CUSTOM,
                          API_ID_da_log,
-                         "dw", series_handle, uservalue);
-       PACK_COMMON_END(0, 0, 2);
+                         "df", series_handle, uservalue);
+       PACK_COMMON_END('v', 0, 0, 2);
        PACK_CUSTOM(series_handle, 0, "", 0, uservalue);
        FLUSH_LOCAL_BUF();