1*9356374aSAndroid Build Coastguard Worker // 2*9356374aSAndroid Build Coastguard Worker // Copyright 2018 The Abseil Authors. 3*9356374aSAndroid Build Coastguard Worker // 4*9356374aSAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License"); 5*9356374aSAndroid Build Coastguard Worker // you may not use this file except in compliance with the License. 6*9356374aSAndroid Build Coastguard Worker // You may obtain a copy of the License at 7*9356374aSAndroid Build Coastguard Worker // 8*9356374aSAndroid Build Coastguard Worker // https://www.apache.org/licenses/LICENSE-2.0 9*9356374aSAndroid Build Coastguard Worker // 10*9356374aSAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software 11*9356374aSAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS, 12*9356374aSAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*9356374aSAndroid Build Coastguard Worker // See the License for the specific language governing permissions and 14*9356374aSAndroid Build Coastguard Worker // limitations under the License. 15*9356374aSAndroid Build Coastguard Worker 16*9356374aSAndroid Build Coastguard Worker // Helper function for measuring stack consumption of signal handlers. 17*9356374aSAndroid Build Coastguard Worker 18*9356374aSAndroid Build Coastguard Worker #ifndef ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ 19*9356374aSAndroid Build Coastguard Worker #define ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ 20*9356374aSAndroid Build Coastguard Worker 21*9356374aSAndroid Build Coastguard Worker #include "absl/base/config.h" 22*9356374aSAndroid Build Coastguard Worker 23*9356374aSAndroid Build Coastguard Worker // The code in this module is not portable. 24*9356374aSAndroid Build Coastguard Worker // Use this feature test macro to detect its availability. 25*9356374aSAndroid Build Coastguard Worker #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 26*9356374aSAndroid Build Coastguard Worker #error ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION cannot be set directly 27*9356374aSAndroid Build Coastguard Worker #elif !defined(__APPLE__) && !defined(_WIN32) && \ 28*9356374aSAndroid Build Coastguard Worker (defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || \ 29*9356374aSAndroid Build Coastguard Worker defined(__aarch64__) || defined(__riscv)) 30*9356374aSAndroid Build Coastguard Worker #define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1 31*9356374aSAndroid Build Coastguard Worker 32*9356374aSAndroid Build Coastguard Worker namespace absl { 33*9356374aSAndroid Build Coastguard Worker ABSL_NAMESPACE_BEGIN 34*9356374aSAndroid Build Coastguard Worker namespace debugging_internal { 35*9356374aSAndroid Build Coastguard Worker 36*9356374aSAndroid Build Coastguard Worker // Returns the stack consumption in bytes for the code exercised by 37*9356374aSAndroid Build Coastguard Worker // signal_handler. To measure stack consumption, signal_handler is registered 38*9356374aSAndroid Build Coastguard Worker // as a signal handler, so the code that it exercises must be async-signal 39*9356374aSAndroid Build Coastguard Worker // safe. The argument of signal_handler is an implementation detail of signal 40*9356374aSAndroid Build Coastguard Worker // handlers and should ignored by the code for signal_handler. Use global 41*9356374aSAndroid Build Coastguard Worker // variables to pass information between your test code and signal_handler. 42*9356374aSAndroid Build Coastguard Worker int GetSignalHandlerStackConsumption(void (*signal_handler)(int)); 43*9356374aSAndroid Build Coastguard Worker 44*9356374aSAndroid Build Coastguard Worker } // namespace debugging_internal 45*9356374aSAndroid Build Coastguard Worker ABSL_NAMESPACE_END 46*9356374aSAndroid Build Coastguard Worker } // namespace absl 47*9356374aSAndroid Build Coastguard Worker 48*9356374aSAndroid Build Coastguard Worker #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 49*9356374aSAndroid Build Coastguard Worker 50*9356374aSAndroid Build Coastguard Worker #endif // ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ 51