1*8d67ca89SAndroid Build Coastguard Worker /* 2*8d67ca89SAndroid Build Coastguard Worker * Copyright (C) 2014 The Android Open Source Project 3*8d67ca89SAndroid Build Coastguard Worker * 4*8d67ca89SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*8d67ca89SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*8d67ca89SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*8d67ca89SAndroid Build Coastguard Worker * 8*8d67ca89SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*8d67ca89SAndroid Build Coastguard Worker * 10*8d67ca89SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*8d67ca89SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*8d67ca89SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*8d67ca89SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*8d67ca89SAndroid Build Coastguard Worker * limitations under the License. 15*8d67ca89SAndroid Build Coastguard Worker */ 16*8d67ca89SAndroid Build Coastguard Worker 17*8d67ca89SAndroid Build Coastguard Worker #pragma once 18*8d67ca89SAndroid Build Coastguard Worker 19*8d67ca89SAndroid Build Coastguard Worker #define US_PER_S 1'000'000LL 20*8d67ca89SAndroid Build Coastguard Worker #define NS_PER_S 1'000'000'000LL 21*8d67ca89SAndroid Build Coastguard Worker 22*8d67ca89SAndroid Build Coastguard Worker // Size of the shadow call stack. This can be small because these stacks only 23*8d67ca89SAndroid Build Coastguard Worker // contain return addresses. This must be a power of 2 so the mask trick works. 24*8d67ca89SAndroid Build Coastguard Worker // See the SCS commentary in pthread_internal.h for more detail. 25*8d67ca89SAndroid Build Coastguard Worker // SCS_SIZE must be a multiple of page size. 26*8d67ca89SAndroid Build Coastguard Worker // We used 8KiB until V but switched to 16KiB in V to experiment with 16KiB pages. 27*8d67ca89SAndroid Build Coastguard Worker #define SCS_SIZE (16 * 1024) 28*8d67ca89SAndroid Build Coastguard Worker #define SCS_MASK (SCS_SIZE - 1) 29*8d67ca89SAndroid Build Coastguard Worker 30*8d67ca89SAndroid Build Coastguard Worker // The shadow call stack is allocated at an aligned address within a guard region of this size. The 31*8d67ca89SAndroid Build Coastguard Worker // guard region must be large enough that we can allocate an SCS_SIZE-aligned SCS while ensuring 32*8d67ca89SAndroid Build Coastguard Worker // that there is at least one guard page after the SCS so that a stack overflow results in a SIGSEGV 33*8d67ca89SAndroid Build Coastguard Worker // instead of corrupting the allocation that comes after it. 34*8d67ca89SAndroid Build Coastguard Worker #define SCS_GUARD_REGION_SIZE (16 * 1024 * 1024) 35