1 /* 2 * Copyright (C) 2016 The Android Open Source Project 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 17 #ifndef CHRE_PLATFORM_FATAL_ERROR_H_ 18 #define CHRE_PLATFORM_FATAL_ERROR_H_ 19 20 /** 21 * @file 22 * Includes the platform-specific header that supplies a fatal error macro. The 23 * platform header must supply the following symbol as a macro or free function: 24 * 25 * FATAL_ERROR_QUIT() 26 * 27 * The error will be logged via the standard logging macros and then 28 * FATAL_ERROR_QUIT will be invoked. The FATAL_ERROR_QUIT macro will terminate 29 * the CHRE runtime. 30 */ 31 32 #include "chre/platform/log.h" 33 #include "chre/target_platform/fatal_error.h" 34 35 #ifndef FATAL_ERROR_QUIT 36 #error "FATAL_ERROR_QUIT must be defined" 37 #endif // FATAL_ERROR_QUIT 38 39 #define FATAL_ERROR(fmt, ...) \ 40 do { \ 41 LOGE(fmt, ##__VA_ARGS__); \ 42 FATAL_ERROR_QUIT(); \ 43 } while (0) 44 45 /** 46 * Fatal error on out of memory error with file and line number. 47 */ 48 #define FATAL_ERROR_OOM() FATAL_ERROR("Out of memory") 49 50 #endif // CHRE_PLATFORM_FATAL_ERROR_H_ 51