blob: 584a4aa9364b9230ce646138b0f086a6d1884900 [file] [log] [blame]
Abseil Teambf7fc992018-02-05 05:38:45 -08001//
2// Copyright 2018 The Abseil Authors.
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// Helper function for measuring stack consumption of signal handlers.
17
18#ifndef ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_
19#define ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_
20
21// The code in this module is not portable.
22// Use this feature test macro to detect its availability.
23#ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
24#error ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION cannot be set directly
Abseil Team03c15132018-02-16 11:47:07 -080025#elif !defined(__APPLE__) && !defined(_WIN32) && \
Abseil Teambf7fc992018-02-05 05:38:45 -080026 (defined(__i386__) || defined(__x86_64__) || defined(__ppc__))
27#define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1
28
29namespace absl {
Abseil Team6c7de162018-06-20 06:25:23 -070030inline namespace lts_2018_06_20 {
Abseil Teambf7fc992018-02-05 05:38:45 -080031namespace debugging_internal {
32
33// Returns the stack consumption in bytes for the code exercised by
34// signal_handler. To measure stack consumption, signal_handler is registered
35// as a signal handler, so the code that it exercises must be async-signal
36// safe. The argument of signal_handler is an implementation detail of signal
37// handlers and should ignored by the code for signal_handler. Use global
38// variables to pass information between your test code and signal_handler.
39int GetSignalHandlerStackConsumption(void (*signal_handler)(int));
40
41} // namespace debugging_internal
Abseil Team6c7de162018-06-20 06:25:23 -070042} // inline namespace lts_2018_06_20
Abseil Teambf7fc992018-02-05 05:38:45 -080043} // namespace absl
44
45#endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
46
47#endif // ABSL_DEBUGGING_INTERNAL_STACK_CONSUMPTION_H_