summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix Herrmann <fherrmann@de.adit-jv.com>2019-12-10 16:29:45 +0100
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2020-07-06 10:04:07 +0900
commitf4325524cb5acdddbe26d32fab49aeed1d7f0b23 (patch)
treebfa46c9306a535472bdfb78f1c93007b896a860e /src
parent048c3d9fdfdb1a7e5ed45cc0d55b9f9389fdb6bb (diff)
downloadDLT-daemon-f4325524cb5acdddbe26d32fab49aeed1d7f0b23.tar.gz
Android: Enable Android build
Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
Diffstat (limited to 'src')
-rw-r--r--src/console/dlt-receive.c12
-rw-r--r--src/lib/dlt_user.c36
-rw-r--r--src/shared/dlt_common.c7
3 files changed, 46 insertions, 9 deletions
diff --git a/src/console/dlt-receive.c b/src/console/dlt-receive.c
index 9424711..24280ee 100644
--- a/src/console/dlt-receive.c
+++ b/src/console/dlt-receive.c
@@ -205,7 +205,11 @@ int dlt_receive_open_output_file(DltReceiveData *dltdata)
/* if (file_already_exists) */
glob_t outer;
- if (glob(dltdata->ovalue, GLOB_TILDE | GLOB_NOSORT, NULL, &outer) == 0) {
+ if (glob(dltdata->ovalue,
+#ifndef __ANDROID_API__
+ GLOB_TILDE |
+#endif
+ GLOB_NOSORT, NULL, &outer) == 0) {
if (dltdata->vflag) {
dlt_vlog(LOG_INFO, "File %s already exists, need to rename first\n", dltdata->ovalue);
}
@@ -223,7 +227,11 @@ int dlt_receive_open_output_file(DltReceiveData *dltdata)
* foo.1000.dlt
* foo.11.dlt
*/
- if (glob(pattern, GLOB_TILDE | GLOB_NOSORT, NULL, &inner) == 0) {
+ if (glob(pattern,
+#ifndef __ANDROID_API__
+ GLOB_TILDE |
+#endif
+ GLOB_NOSORT, NULL, &inner) == 0) {
/* search for the highest number used */
size_t i;
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index edb4ae0..be00a76 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -160,8 +160,10 @@ static DltReturnValue dlt_user_print_msg(DltMessage *msg, DltContextData *log);
static DltReturnValue dlt_user_log_check_user_message(void);
static void dlt_user_log_reattach_to_daemon(void);
static DltReturnValue dlt_user_log_send_overflow(void);
+#ifndef __ANDROID_API__
static void dlt_user_trace_network_segmented_thread(void *unused);
static void dlt_user_trace_network_segmented_thread_segmenter(s_segmented_data *data);
+#endif
static DltReturnValue dlt_user_log_out_error_handling(void *ptr1,
size_t len1,
void *ptr2,
@@ -400,11 +402,13 @@ DltReturnValue dlt_init(void)
#endif
+#ifndef __ANDROID_API__
/* These will be lazy initialized only when needed */
dlt_user.dlt_segmented_queue_read_handle = -1;
dlt_user.dlt_segmented_queue_write_handle = -1;
pthread_cond_init(&mq_init_condition, NULL);
+#endif
if (dlt_start_threads() < 0) {
dlt_user_initialised = false;
@@ -455,6 +459,7 @@ DltReturnValue dlt_init_file(const char *name)
return DLT_RETURN_OK;
}
+#ifndef __ANDROID_API__
DltReturnValue dlt_init_message_queue(void)
{
dlt_lock_mutex(&mq_mutex);
@@ -519,6 +524,7 @@ DltReturnValue dlt_init_message_queue(void)
dlt_unlock_mutex(&mq_mutex);
return DLT_RETURN_OK;
}
+#endif /*__ANDROID_API__*/
DltReturnValue dlt_init_common(void)
{
@@ -934,6 +940,7 @@ DltReturnValue dlt_free(void)
dlt_env_free_ll_set(&dlt_user.initial_ll_set);
DLT_SEM_FREE();
+#ifndef __ANDROID_API__
char queue_name[NAME_MAX];
snprintf(queue_name, NAME_MAX, "%s.%d", DLT_MESSAGE_QUEUE_NAME, getpid());
@@ -955,6 +962,7 @@ DltReturnValue dlt_free(void)
dlt_user.dlt_segmented_queue_read_handle = DLT_FD_INIT;
pthread_cond_destroy(&mq_init_condition);
+#endif /* ifndef __ANDROID_API__ */
sem_destroy(&dlt_mutex);
/* allow the user app to do dlt_init() again. */
@@ -1491,6 +1499,8 @@ int dlt_get_log_state()
DltReturnValue dlt_set_log_mode(DltUserLogMode mode)
{
+ DLT_UNUSED(mode);
+
/* forbid dlt usage in child after fork */
if (g_dlt_is_child)
return DLT_RETURN_ERROR;
@@ -2892,7 +2902,7 @@ DltReturnValue dlt_user_trace_network_segmented_end(uint32_t id, DltContext *han
return DLT_RETURN_OK;
}
-
+#ifndef __ANDROID_API__
void dlt_user_trace_network_segmented_thread(void *unused)
{
/* Unused on purpose. */
@@ -3192,6 +3202,7 @@ DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,
return DLT_RETURN_OK;
}
+#endif /*__ANDROID_API__*/
DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, const char *text)
{
@@ -4622,26 +4633,39 @@ int dlt_start_threads()
dlt_log(LOG_CRIT, "Can't start segmented thread!\n");
return -1;
}
-
return 0;
}
void dlt_stop_threads()
{
int dlt_housekeeperthread_result = 0;
- int dlt_segmented_nwt_result = 0;
int joined = 0;
if (dlt_housekeeperthread_handle) {
/* do not ignore return value */
+#ifndef __ANDROID_API__
dlt_housekeeperthread_result = pthread_cancel(dlt_housekeeperthread_handle);
+#else
+ dlt_lock_mutex(&mq_mutex);
+ dlt_housekeeperthread_result = pthread_kill(dlt_housekeeperthread_handle, SIGKILL);
+ dlt_user_cleanup_handler(NULL);
+#endif
+
if (dlt_housekeeperthread_result != 0)
dlt_vlog(LOG_ERR,
- "ERROR pthread_cancel(dlt_housekeeperthread_handle): %s\n",
+ "ERROR %s(dlt_housekeeperthread_handle): %s\n",
+#ifndef __ANDROID_API__
+ "pthread_cancel",
+#else
+ "pthread_kill",
+#endif
strerror(dlt_housekeeperthread_result));
}
+#ifndef __ANDROID_API__
+ int dlt_segmented_nwt_result = 0;
+
if (dlt_user.dlt_segmented_nwt_handle) {
dlt_lock_mutex(&mq_mutex);
pthread_cond_signal(&mq_init_condition);
@@ -4654,7 +4678,7 @@ void dlt_stop_threads()
"ERROR pthread_cancel(dlt_user.dlt_segmented_nwt_handle): %s\n",
strerror(dlt_segmented_nwt_result));
}
-
+#endif /* ifndef __ANDROID_API__ */
/* make sure that the threads really finished working */
if ((dlt_housekeeperthread_result == 0) && dlt_housekeeperthread_handle) {
joined = pthread_join(dlt_housekeeperthread_handle, NULL);
@@ -4667,6 +4691,7 @@ void dlt_stop_threads()
dlt_housekeeperthread_handle = 0; /* set to invalid */
}
+#ifndef __ANDROID_API__
if ((dlt_segmented_nwt_result == 0) && dlt_user.dlt_segmented_nwt_handle) {
joined = pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL);
@@ -4677,6 +4702,7 @@ void dlt_stop_threads()
dlt_user.dlt_segmented_nwt_handle = 0; /* set to invalid */
}
+#endif /* ifndef __ANDROID_API__ */
}
static void dlt_fork_child_fork_handler()
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index d2471ee..642d43d 100644
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -2064,7 +2064,7 @@ int dlt_receiver_check_and_get(DltReceiver *receiver,
unsigned int flags)
{
unsigned int min_size = to_get;
- char *src = NULL;
+ uint8_t *src = NULL;
if (flags & DLT_RCV_SKIP_HEADER)
min_size += sizeof(DltUserHeader);
@@ -2075,7 +2075,7 @@ int dlt_receiver_check_and_get(DltReceiver *receiver,
!dest)
return DLT_RETURN_WRONG_PARAMETER;
- src = receiver->buf;
+ src = (uint8_t *)receiver->buf;
if (flags & DLT_RCV_SKIP_HEADER)
src += sizeof(DltUserHeader);
@@ -3048,8 +3048,11 @@ void dlt_get_version(char *buf, size_t size)
_DLT_PACKAGE_VERSION,
_DLT_PACKAGE_VERSION_STATE,
_DLT_PACKAGE_REVISION,
+/* Clang does not like these macros, because they are not reproducable */
+#pragma clang diagnostic ignored "-Wdate-time"
__DATE__,
__TIME__,
+#pragma clang diagnostic error "-Wdate-time"
_DLT_SYSTEMD_ENABLE,
_DLT_SYSTEMD_WATCHDOG_ENABLE,
_DLT_TEST_ENABLE,