1 /* 2 $License: 3 Copyright (C) 2011 InvenSense Corporation, All Rights Reserved. 4 $ 5 */ 6 /******************************************************************************* 7 * 8 * $Id: mltypes.h 3680 2010-09-04 03:13:32Z mcaramello $ 9 * 10 *******************************************************************************/ 11 12 #ifndef _MLERRORCODE_H_ 13 #define _MLERRORCODE_H_ 14 15 #include "mltypes.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /* 22 Defines 23 */ 24 #define CALL_N_CHECK(f) { \ 25 unsigned int r35uLt = f; \ 26 if(INV_SUCCESS != r35uLt) { \ 27 MPL_LOGE("Error in file %s, line %d : %s returned code %s (#%d)\n", \ 28 __FILE__, __LINE__, #f, MLErrorCode(r35uLt), r35uLt); \ 29 } \ 30 } 31 32 #define CALL_CHECK_N_RETURN_ERROR(f) { \ 33 unsigned int r35uLt = f; \ 34 if(INV_SUCCESS != r35uLt) { \ 35 MPL_LOGE("Error in file %s, line %d : %s returned code %s (#%d)\n", \ 36 __FILE__, __LINE__, #f, MLErrorCode(r35uLt), r35uLt); \ 37 return r35uLt; \ 38 } \ 39 } 40 41 // for functions returning void 42 #define CALL_CHECK_N_RETURN(f) do { \ 43 unsigned int r35uLt = f; \ 44 if(INV_SUCCESS != r35uLt) { \ 45 MPL_LOGE("Error in file %s, line %d : %s returned code %s (#%d)\n", \ 46 __FILE__, __LINE__, #f, MLErrorCode(r35uLt), r35uLt); \ 47 return; \ 48 } \ 49 } while(0) 50 51 #define CALL_CHECK_N_EXIT(f) { \ 52 unsigned int r35uLt = f; \ 53 if(INV_SUCCESS != r35uLt) { \ 54 MPL_LOGE("Error in file %s, line %d : %s returned code %s (#%d)\n", \ 55 __FILE__, __LINE__, #f, MLErrorCode(r35uLt), r35uLt); \ 56 exit (r35uLt); \ 57 } \ 58 } 59 60 61 #define CALL_CHECK_N_CALLBACK(f, cb) { \ 62 unsigned int r35uLt = f; \ 63 if(INV_SUCCESS != r35uLt) { \ 64 MPL_LOGE("Error in file %s, line %d : %s returned code %s (#%d)\n", \ 65 __FILE__, __LINE__, #f, MLErrorCode(r35uLt), r35uLt); \ 66 cb; \ 67 } \ 68 } 69 70 #define CALL_CHECK_N_GOTO(f, label) { \ 71 unsigned int r35uLt = f; \ 72 if(INV_SUCCESS != r35uLt) { \ 73 MPL_LOGE("Error in file %s, line %d : %s returned code %s (#%d)\n", \ 74 __FILE__, __LINE__, #f, MLErrorCode(r35uLt), r35uLt); \ 75 goto label; \ 76 } \ 77 } 78 79 char* MLErrorCode(inv_error_t errorcode); 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 #endif 86 87