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, ...) do { \ 40 LOGE(fmt, ##__VA_ARGS__); \ 41 FATAL_ERROR_QUIT(); \ 42 } while (0) 43 44 /** 45 * Fatal error on out of memory error with file and line number. 46 */ 47 #define FATAL_ERROR_OOM() \ 48 FATAL_ERROR("Out of memory") 49 50 #endif // CHRE_PLATFORM_FATAL_ERROR_H_ 51