1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_NOTREACHED_H_
6 #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_NOTREACHED_H_
7 
8 #include "partition_alloc/partition_alloc_base/check.h"
9 
10 // PA_NOTREACHED() annotates paths that are supposed to be unreachable. They
11 // crash if they are ever hit.
12 #if PA_BASE_CHECK_WILL_STREAM()
13 // PartitionAlloc uses async-signal-safe RawCheckFailure() for error reporting.
14 // Async-signal-safe functions are guaranteed to not allocate as otherwise they
15 // could operate with inconsistent allocator state.
16 #define PA_NOTREACHED()                                  \
17   ::partition_alloc::internal::logging::RawCheckFailure( \
18       __FILE__ "(" PA_STRINGIFY(__LINE__) ") PA_NOTREACHED() hit.")
19 #else
20 #define PA_NOTREACHED() PA_IMMEDIATE_CRASH()
21 #endif  // CHECK_WILL_STREAM()
22 
23 #endif  // PARTITION_ALLOC_PARTITION_ALLOC_BASE_NOTREACHED_H_
24