00001 // 00002 // Copyright 2018 The Abseil Authors. 00003 // 00004 // Licensed under the Apache License, Version 2.0 (the "License"); 00005 // you may not use this file except in compliance with the License. 00006 // You may obtain a copy of the License at 00007 // 00008 // https://www.apache.org/licenses/LICENSE-2.0 00009 // 00010 // Unless required by applicable law or agreed to in writing, software 00011 // distributed under the License is distributed on an "AS IS" BASIS, 00012 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 // See the License for the specific language governing permissions and 00014 // limitations under the License. 00015 00016 // Helper function for measuring stack consumption of signal handlers. 00017 00018 #ifndef ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ 00019 #define ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_ 00020 00021 // The code in this module is not portable. 00022 // Use this feature test macro to detect its availability. 00023 #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 00024 #error ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION cannot be set directly 00025 #elif !defined(__APPLE__) && !defined(_WIN32) && \ 00026 (defined(__i386__) || defined(__x86_64__) || defined(__ppc__)) 00027 #define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1 00028 00029 namespace absl { 00030 namespace debugging_internal { 00031 00032 // Returns the stack consumption in bytes for the code exercised by 00033 // signal_handler. To measure stack consumption, signal_handler is registered 00034 // as a signal handler, so the code that it exercises must be async-signal 00035 // safe. The argument of signal_handler is an implementation detail of signal 00036 // handlers and should ignored by the code for signal_handler. Use global 00037 // variables to pass information between your test code and signal_handler. 00038 int GetSignalHandlerStackConsumption(void (*signal_handler)(int)); 00039 00040 } // namespace debugging_internal 00041 } // namespace absl 00042 00043 #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 00044 00045 #endif // ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_