xref: /aosp_15_r20/frameworks/native/libs/binder/OS_non_android_linux.cpp (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "OS.h"
18 
19 #include <log/log.h>
20 
21 #include <syscall.h>
22 #include <cstdarg>
23 
24 #include <binder/Common.h>
25 
26 #ifdef __ANDROID__
27 #error "This module is not intended for Android, just bare Linux"
28 #endif
29 #ifdef __APPLE__
30 #error "This module is not intended for MacOS"
31 #endif
32 #ifdef _WIN32
33 #error "This module is not intended for Windows"
34 #endif
35 
36 namespace android::binder::os {
37 
trace_begin(uint64_t,const char *)38 void trace_begin(uint64_t, const char*) {}
39 
trace_end(uint64_t)40 void trace_end(uint64_t) {}
41 
trace_int(uint64_t,const char *,int32_t)42 void trace_int(uint64_t, const char*, int32_t) {}
43 
get_trace_enabled_tags()44 uint64_t get_trace_enabled_tags() {
45     return 0;
46 }
47 
GetThreadId()48 uint64_t GetThreadId() {
49     return syscall(__NR_gettid);
50 }
51 
report_sysprop_change()52 bool report_sysprop_change() {
53     return false;
54 }
55 
56 } // namespace android::binder::os
57 
__android_log_print(int,const char *,const char * fmt,...)58 LIBBINDER_EXPORTED int __android_log_print(int /*prio*/, const char* /*tag*/, const char* fmt,
59                                            ...) {
60     va_list args;
61     va_start(args, fmt);
62     vfprintf(stderr, fmt, args);
63     va_end(args);
64 
65     return 1;
66 }
67