• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HITRACE_COMMON_DEFINE_H
17 #define HITRACE_COMMON_DEFINE_H
18 
19 #include <string>
20 
21 #define EXPECTANTLY(exp) (__builtin_expect(!!(exp), true))
22 #define UNEXPECTANTLY(exp) (__builtin_expect(!!(exp), false))
23 #define UNUSED_PARAM __attribute__((__unused__))
24 
25 #ifndef PAGE_SIZE
26 constexpr size_t PAGE_SIZE = 4096;
27 #endif
28 constexpr uint64_t S_TO_NS = 1000000000;
29 constexpr uint64_t MS_TO_NS = 1000000;
30 constexpr uint64_t S_TO_MS = 1000;
31 
32 constexpr int DEFAULT_FILE_SIZE = 100 * 1024;
33 
34 static const char* TRACE_TAG_ENABLE_FLAGS = "debug.hitrace.tags.enableflags";
35 static const char* TRACE_KEY_APP_PID = "debug.hitrace.app_pid";
36 static const char* TRACE_LEVEL_THRESHOLD = "persist.hitrace.level.threshold";
37 
38 static const std::string DEBUGFS_TRACING_DIR = "/sys/kernel/debug/tracing/";
39 static const std::string TRACEFS_DIR = "/sys/kernel/tracing/";
40 static const char* TRACING_ON_NODE = "tracing_on";
41 static const char* TRACE_MARKER_NODE = "trace_marker";
42 static const char* TRACE_NODE = "trace";
43 static const char* TRACE_BUFFER_SIZE_NODE = "buffer_size_kb";
44 
45 static const std::string TRACE_FILE_DEFAULT_DIR = "/data/log/hitrace/";
46 static const char* TRACE_SAVED_EVENTS_FORMAT = "saved_events_format";
47 #endif // HITRACE_COMMON_DEFINE_H