• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #ifndef INCLUDE_PERFETTO_EXT_BASE_SYS_TYPES_H_
18 #define INCLUDE_PERFETTO_EXT_BASE_SYS_TYPES_H_
19 
20 // This headers deals with sys types commonly used in the codebase that are
21 // missing on Windows.
22 
23 #include <sys/types.h>  // IWYU pragma: export
24 #include <cstdint>
25 
26 #include "perfetto/base/build_config.h"
27 
28 #if PERFETTO_BUILDFLAG(PERFETTO_OS_WIN)
29 
30 #if !PERFETTO_BUILDFLAG(PERFETTO_COMPILER_GCC)
31 // MinGW has these. clang-cl and MSVC, which use just the Windows SDK, don't.
32 using uid_t = int;
33 using pid_t = int;
34 #endif  // !GCC
35 
36 #if defined(_WIN64)
37 using ssize_t = int64_t;
38 #else
39 using ssize_t = long;
40 #endif  // _WIN64
41 
42 #endif  // OS_WIN
43 
44 #if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) && !defined(AID_SHELL)
45 // From libcutils' android_filesystem_config.h .
46 #define AID_SHELL 2000
47 #endif
48 
49 namespace perfetto {
50 namespace base {
51 
52 // The machine ID used in the tracing core.
53 using MachineID = uint32_t;
54 // The default value reserved for the host trace.
55 constexpr MachineID kDefaultMachineID = 0;
56 
57 constexpr uid_t kInvalidUid = static_cast<uid_t>(-1);
58 constexpr pid_t kInvalidPid = static_cast<pid_t>(-1);
59 
60 }  // namespace base
61 }  // namespace perfetto
62 
63 #endif  // INCLUDE_PERFETTO_EXT_BASE_SYS_TYPES_H_
64