1 // Copyright 2020 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 #pragma once 15 16 #include "pw_preprocessor/compiler.h" 17 #include "pw_preprocessor/util.h" 18 19 // This is needed for testing the basic crash handler. 20 // TODO(pwbug/17): Replace when Pigweed config system is added. 21 #define PW_ASSERT_BASIC_DISABLE_NORETURN 0 22 #if PW_ASSERT_BASIC_DISABLE_NORETURN 23 #define PW_ASSERT_NORETURN 24 #else 25 #define PW_ASSERT_NORETURN PW_NO_RETURN 26 #endif 27 28 PW_EXTERN_C_START 29 30 // Application-defined assert failure handler for pw_assert_basic. 31 // file_name - may be nullptr if not available 32 // line_number - may be -1 if not available 33 // function_name - may be nullptr if not available 34 // format & varags - The assert reason can be built using the format string and 35 // the varargs. 36 // 37 // Applications must define this function; it is not defined by pw_assert_basic. 38 void pw_assert_basic_HandleFailure(const char* file_name, 39 int line_number, 40 const char* function_name, 41 const char* format, 42 ...) 43 PW_PRINTF_FORMAT(4, 5) PW_ASSERT_NORETURN; 44 45 PW_EXTERN_C_END 46