00001 /* --------------------------------------------------------------------------- 00002 00003 00004 This file is part of the ``utils'' package of NuSMV version 2. 00005 Copyright (C) 1998-2001 by CMU and FBK-irst. 00006 00007 NuSMV version 2 is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 NuSMV version 2 is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00020 00021 For more information on NuSMV see <http://nusmv.fbk.eu> 00022 or email to <nusmv-users@fbk.eu>. 00023 Please report bugs to <nusmv-users@fbk.eu>. 00024 00025 To contact the NuSMV development board, email to <nusmv@fbk.eu>. 00026 00027 -----------------------------------------------------------------------------*/ 00028 00038 #ifndef __NUSMV_CORE_UTILS_ERROR_H__ 00039 #define __NUSMV_CORE_UTILS_ERROR_H__ 00040 00041 #if HAVE_CONFIG_H 00042 # include "nusmv-config.h" 00043 #endif 00044 00045 #include <stdio.h> 00046 #include "nusmv/core/utils/utils.h" 00047 #include "nusmv/core/utils/portability.h" 00048 #include "nusmv/core/node/node.h" 00049 #include "nusmv/core/utils/NodeList.h" 00050 00051 /* warning [MD] Why Prop.h is included here? */ 00052 #include "nusmv/core/prop/Prop.h" 00053 00054 00055 /*---------------------------------------------------------------------------*/ 00056 /* Macro declarations */ 00057 /*---------------------------------------------------------------------------*/ 00058 00059 /* Define the alternative for nusmv_assert(0) */ 00060 00066 #define error_unreachable_code() \ 00067 do { \ 00068 fprintf(stderr, "%s:%d:%s: reached invalid code\n", \ 00069 __FILE__, __LINE__, __func__); \ 00070 exit(4); \ 00071 } while (0) 00072 00073 /* Define the alternative for nusmv_assert(0 && "message") */ 00074 00080 #define error_unreachable_code_msg(...) \ 00081 do { \ 00082 printf(__VA_ARGS__); \ 00083 fprintf(stderr, "%s:%d:%s: reached invalid code\n", \ 00084 __FILE__, __LINE__, __func__); \ 00085 exit(4); \ 00086 } while (0) 00087 00112 #define SNPRINTF_CHECK(chars, buffsize) \ 00113 do { \ 00114 if (chars < 0) { \ 00115 fprintf(stderr, "%s:%d:%s: Error in buffer writing", \ 00116 __FILE__, __LINE__, __func__); \ 00117 exit(5); \ 00118 } \ 00119 else if ((unsigned int)chars >= buffsize) { \ 00120 fprintf(stderr, "%s:%d:%s: String buffer overflow", \ 00121 __FILE__, __LINE__, __func__); \ 00122 exit(5); \ 00123 } \ 00124 else {}; \ 00125 } while (0) 00126 00127 00128 /*---------------------------------------------------------------------------*/ 00129 /* Type declarations */ 00130 /*---------------------------------------------------------------------------*/ 00131 00132 00133 /*---------------------------------------------------------------------------*/ 00134 /* Function prototypes */ 00135 /*---------------------------------------------------------------------------*/ 00136 00146 void Error_init(NuSMVEnv_ptr env); 00147 00155 void Error_quit(NuSMVEnv_ptr env); 00156 00167 void init_memory(void); 00168 00169 00170 #endif /* __NUSMV_CORE_UTILS_ERROR_H__ */