1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <stdlib.h>
6
7 #include <atomic>
8 #include <cassert>
9 #include <cstdarg>
10 #include <cstdint>
11 #include <cstdio>
12 #include <thread>
13
14 #include <lib/syslog/global.h>
15
16 #include "cutils/log.h"
17 #include "cutils/properties.h"
18 #include "cutils/threads.h"
19
20 extern "C" {
21
property_get(const char * key,char * value,const char * default_value)22 int property_get(const char* key, char* value, const char* default_value) {
23 return 0;
24 }
25
__android_log_print(int priority,const char * tag,const char * file,int line,const char * format,...)26 int __android_log_print(int priority, const char* tag, const char* file,
27 int line, const char* format, ...) {
28 const char* local_tag = tag;
29 if (!local_tag) {
30 local_tag = "<NO_TAG>";
31 }
32 va_list ap;
33 va_start(ap, format);
34 switch (priority) {
35 case ANDROID_LOG_VERBOSE:
36 case ANDROID_LOG_DEBUG:
37 FX_LOGVF(DEBUG, local_tag, file, line, format, ap);
38 break;
39 case ANDROID_LOG_WARN:
40 FX_LOGVF(WARNING, local_tag, file, line, format, ap);
41 break;
42 case ANDROID_LOG_ERROR:
43 FX_LOGVF(ERROR, local_tag, file, line, format, ap);
44 break;
45 case ANDROID_LOG_FATAL:
46 FX_LOGVF(FATAL, local_tag, file, line, format, ap);
47 break;
48 case ANDROID_LOG_INFO:
49 default:
50 FX_LOGVF(INFO, local_tag, file, line, format, ap);
51 break;
52 }
53 return 1;
54 }
55
__android_log_assert(const char * condition,const char * tag,const char * file,int line,const char * format,...)56 void __android_log_assert(const char* condition, const char* tag,
57 const char* file, int line, const char* format, ...) {
58 const char* local_tag = tag;
59 if (!local_tag) {
60 local_tag = "<NO_TAG>";
61 }
62 va_list ap;
63 va_start(ap, format);
64 FX_LOGVF(ERROR, local_tag, file, line, format, ap);
65 va_end(ap);
66
67 abort();
68 }
69
sync_wait(int fd,int timeout)70 int sync_wait(int fd, int timeout) {
71 return -1;
72 }
73
gettid()74 pid_t gettid() {
75 static thread_local pid_t id = 0;
76 if (!id) {
77 static std::atomic<pid_t> next_thread_id{1};
78 id = next_thread_id++;
79 }
80 return id;
81 }
82
83 }
84