*
* Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
*
* Jaewon Lim <jaewon81.lim@samsung.com>
* Woojin Jung <woojin2.jung@samsung.com>
* Juyoung Kim <j0.kim@samsung.com>
* Anastasia Lyupa <a.lyupa@samsung.com>
- *
+ *
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
- *
+ *
* This library is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* Contributors:
* - S-Core Co., Ltd
* - Samsung RnD Institute Russia
- *
+ *
*/
#include <pthread.h>
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();
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;
da_user_data_2_chart_data callback, void* user_data)
{
chart_interval_callback* newelem;
-
+
newelem = (chart_interval_callback*)malloc(sizeof(chart_interval_callback));
newelem->chart_handle = charthandle;
newelem->series_handle = series_handle;
newelem->user_data = user_data;
chm.interval_for_series[charthandle][series_handle % 10] = interval;
-
+
switch(interval)
{
case CHART_INTERVAL_10MSEC:
static void remove_all_callback_list()
{
chart_interval_callback* cur;
-
+
pthread_mutex_lock(&chm.interval_10ms.list_mutex);
while(chm.interval_10ms.callback_list != NULL)
{
// constructor and destructor functions
// =====================================================================
-void memory_initialize_hook(void);
-void (*__malloc_initialize_hook) (void) = memory_initialize_hook;
-
void __attribute__((constructor)) _init_lib()
{
probeBlockStart();
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();
}
void da_mark(chart_color color, char* mark_text)
{
DECLARE_CHART_VARIABLE;
-
+
probeBlockStart();
-
+
setProbePoint(&probeInfo);
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();
// check if there is available chart handle slot
if(chm.chart_handle_index + 1 >= MAX_CHART_HANDLE)
return ERR_MAX_CHART_NUMBER;
-
+
// check if chart_name is null
if(chart_name == NULL)
return ERR_WRONG_PARAMETER;
-
+
probeBlockStart();
ret = ++(chm.chart_handle_index);
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();
-
+
probeBlockEnd();
-
+
return ret;
}
series_type type, chart_color color)
{
DECLARE_CHART_VARIABLE;
-
+
// check if charthandle is valid handle or not
if(charthandle <= 0 || charthandle > chm.chart_handle_index)
return ERR_WRONG_HANDLE;
-
+
// chech if extra parameter is valid
if(seriesname == NULL)
return ERR_WRONG_PARAMETER;
// check if there is available series spot
if(chm.series_handle_index[(int)charthandle] + 1 >= MAX_SERIES_PER_CHART)
return ERR_MAX_CHART_NUMBER;
-
+
probeBlockStart();
ret = ++(chm.series_handle_index[charthandle]);
ret += (10 * charthandle);
-
+
setProbePoint(&probeInfo);
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();
probeBlockEnd();
-
+
return ret;
}
-
+
da_handle da_create_default_series(da_handle charthandle, char* seriesname)
{
return da_create_series(charthandle, seriesname,
int cindex, sindex;
cindex = (int)(series_handle / 10);
sindex = series_handle % 10;
-
+
// check series handle
if(cindex <= 0 || cindex > chm.chart_handle_index)
return ERR_WRONG_HANDLE;
-
+
if(sindex > chm.series_handle_index[(int)cindex])
return ERR_WRONG_HANDLE;
-
+
// check rest parameters
if(interval == CHART_NO_CYCLE && callback != NULL)
return ERR_WRONG_PARAMETER;
void da_log(da_handle series_handle, float uservalue)
{
DECLARE_CHART_VARIABLE;
-
+
// chech if series handle is valid
int cindex, sindex;
cindex = (int)(series_handle / 10);
sindex = series_handle % 10;
-
+
if(cindex <= 0 || cindex > chm.chart_handle_index)
return;
-
+
if(sindex > chm.series_handle_index[(int)cindex])
return;
-
+
probeBlockStart();
-
+
setProbePoint(&probeInfo);
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();
-
+
probeBlockEnd();
}