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 <android-base/threads.h>
20 #include <cutils/trace.h>
21 #include <utils/misc.h>
22 
23 namespace android::binder {
24 namespace os {
25 
GetThreadId()26 uint64_t GetThreadId() {
27 #ifdef BINDER_RPC_SINGLE_THREADED
28     return 0;
29 #else
30     return base::GetThreadId();
31 #endif
32 }
33 
report_sysprop_change()34 bool report_sysprop_change() {
35     android::report_sysprop_change();
36     return true;
37 }
38 
trace_begin(uint64_t tag,const char * name)39 void trace_begin(uint64_t tag, const char* name) {
40     atrace_begin(tag, name);
41 }
42 
trace_end(uint64_t tag)43 void trace_end(uint64_t tag) {
44     atrace_end(tag);
45 }
46 
trace_int(uint64_t tag,const char * name,int32_t value)47 void trace_int(uint64_t tag, const char* name, int32_t value) {
48     atrace_int(tag, name, value);
49 }
50 
51 } // namespace os
52 
53 // Legacy trace symbol. To be removed once all of downstream rebuilds.
atrace_begin(uint64_t tag,const char * name)54 void atrace_begin(uint64_t tag, const char* name) {
55     os::trace_begin(tag, name);
56 }
57 
58 // Legacy trace symbol. To be removed once all of downstream rebuilds.
atrace_end(uint64_t tag)59 void atrace_end(uint64_t tag) {
60     os::trace_end(tag);
61 }
62 
63 } // namespace android::binder
64