• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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_TRACING_CORE_BASIC_TYPES_H_
18 #define INCLUDE_PERFETTO_TRACING_CORE_BASIC_TYPES_H_
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <sys/types.h>
23 
24 namespace perfetto {
25 
26 // Unique within the scope of the tracing service.
27 using TracingSessionID = uint64_t;
28 
29 // Unique within the scope of the tracing service.
30 using ProducerID = uint16_t;
31 
32 // Unique within the scope of the tracing service.
33 using DataSourceInstanceID = uint64_t;
34 
35 // Unique within the scope of a Producer.
36 using WriterID = uint16_t;
37 
38 // Unique within the scope of the tracing service.
39 using FlushRequestID = uint64_t;
40 
41 // We need one FD per producer and we are not going to be able to keep > 64k FDs
42 // open in the service.
43 static constexpr ProducerID kMaxProducerID = static_cast<ProducerID>(-1);
44 
45 // 1024 Writers per producer seems a resonable bound. This reduces the ability
46 // to memory-DoS the service by having to keep track of too many writer IDs.
47 static constexpr WriterID kMaxWriterID = static_cast<WriterID>((1 << 10) - 1);
48 
49 // Unique within the scope of a {ProducerID, WriterID} tuple.
50 using ChunkID = uint32_t;
51 static constexpr ChunkID kMaxChunkID = static_cast<ChunkID>(-1);
52 
53 // Unique within the scope of the tracing service.
54 using BufferID = uint16_t;
55 
56 // Keep this in sync with SharedMemoryABI::PageHeader::target_buffer.
57 static constexpr BufferID kMaxTraceBufferID = static_cast<BufferID>(-1);
58 
59 // TODO(primiano): temporary. The buffer page size should be configurable by
60 // consumers.
61 static constexpr size_t kBufferPageSize = 8192;
62 
63 constexpr uid_t kInvalidUid = static_cast<uid_t>(-1);
64 
65 }  // namespace perfetto
66 
67 #endif  // INCLUDE_PERFETTO_TRACING_CORE_BASIC_TYPES_H_
68