1 : // Copyright 2014 Google Inc. All Rights Reserved.
2 : //
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 : // Declares some constants that are used across Asan.
16 :
17 : #ifndef SYZYGY_AGENT_ASAN_CONSTANTS_H_
18 : #define SYZYGY_AGENT_ASAN_CONSTANTS_H_
19 :
20 m : namespace agent {
21 m : namespace asan {
22 :
23 : // The ratio of shadow memory to actual memory. This governs the behaviour, size
24 : // and alignment requirements of many Asan structures.
25 m : static const size_t kShadowRatioLog = 3;
26 m : static const size_t kShadowRatio = (1 << kShadowRatioLog);
27 :
28 : // Expected page sizes and allocation granularities. Some usages of these are
29 : // at compile time, thus we need accessible constants.
30 m : static const size_t kUsualPageSize = 4096;
31 m : static const size_t kUsualAllocationGranularity = 64 * 1024;
32 :
33 : // The default sharding factor of the quarantine. This is used to give us linear
34 : // access for random removal and insertion of elements into the quarantine.
35 m : static const size_t kQuarantineDefaultShardingFactor = 128;
36 :
37 : // @returns the size of a page on the OS (usually 4KB).
38 : // @note Declaring this as a constant might result in an initialization order
39 : // fiasco.
40 m : size_t GetPageSize();
41 :
42 : // @returns the allocation granularity of the OS (usually 64KB).
43 : // @note Declaring this as a constant might result in an initialization order
44 : // fiasco.
45 m : size_t GetAllocationGranularity();
46 :
47 m : } // namespace asan
48 m : } // namespace agent
49 :
50 : #endif // SYZYGY_AGENT_ASAN_CONSTANTS_H_
|