00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00038 #ifndef __NUSMV_CORE_UTILS_DEFS_H__
00039 #define __NUSMV_CORE_UTILS_DEFS_H__
00040
00041 #if HAVE_CONFIG_H
00042 # include "nusmv-config.h"
00043 #endif
00044
00045 #if NUSMV_HAVE_STDLIB_H
00046 # include <stdlib.h>
00047 #endif
00048
00049 #include <assert.h>
00050 #include "cudd/util.h"
00051
00052 # ifndef NUSMV_GCC_WARN_UNUSED_RESULT
00053 # define NUSMV_GCC_WARN_UNUSED_RESULT
00054 # endif
00055
00056
00057 #ifdef EXTERN
00058 # ifndef HAVE_EXTERN_ARGS_MACROS
00059
00060 # undef EXTERN
00061 # endif
00062 #endif
00063
00064
00065 #ifdef ARGS
00066 # ifndef HAVE_EXTERN_ARGS_MACROS
00067
00068 # undef ARGS
00069 # endif
00070 #endif
00071
00072
00073
00074 #if HAVE_EXTERN_ARGS_MACROS
00075 # ifndef EXTERN
00076 # ifdef __cplusplus
00077 # define EXTERN extern "C"
00078 # else
00079 # define EXTERN extern
00080 # endif
00081 # endif
00082 # ifndef ARGS
00083 # if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER)
00084 # define ARGS(protos) protos
00085 # else
00086 # define ARGS(protos) ()
00087 # endif
00088 # endif
00089 #endif
00090
00091 #ifndef NORETURN
00092 # if defined __GNUC__
00093 # define NORETURN __attribute__ ((__noreturn__))
00094 # else
00095 # define NORETURN
00096 # endif
00097 #endif
00098
00104 #define nusmv_assert(expr) \
00105 assert(expr)
00106
00112 #define NIL_PTR(ptr_type) \
00113 ((ptr_type) NULL)
00114
00115
00116
00117
00123 typedef util_ptrint nusmv_ptrint;
00124
00130 typedef util_ptruint nusmv_ptruint;
00131
00132
00133
00134
00135
00136
00137
00138 #ifndef max
00139
00145 #define max(_a_, _b_) ((_a_ < _b_) ? _b_ : _a_)
00146 #endif
00147
00148 #ifndef min
00149
00155 #define min(_a_, _b_) ((_a_ < _b_) ? _a_ : _b_)
00156 #endif
00157
00163 #define PTR_TO_INT(x) \
00164 ((int) (nusmv_ptrint) (x))
00165
00171 #define PTR_FROM_INT(ptr, x) \
00172 ((ptr) (nusmv_ptrint) (x))
00173
00179 #define VOIDPTR_FROM_INT(x) \
00180 ((void *) (nusmv_ptrint) (x))
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00196 #define MACRO_STRINGIZE_2nd_LEVEL(x) \
00197 #x
00198
00204 #define MACRO_STRINGIZE(x) \
00205 MACRO_STRINGIZE_2nd_LEVEL(x)
00206
00214 #if !NUSMV_HAVE_INTTYPES_H
00215 # if (defined __MINGW32__) || (defined __CYGWIN__)
00216 # ifdef _WIN64
00217 # define PRIuPTR "I64u"
00218 # define PRIdPTR "I64d"
00219 # else
00220 # define PRIuPTR "u"
00221 # define PRIdPTR "d"
00222 # endif
00223 # else
00224 # if __WORDSIZE == 64
00225 # define PRIuPTR "lu"
00226 # define PRIdPTR "ld"
00227 # else
00228 # define PRIuPTR "u"
00229 # define PRIdPTR "d"
00230 # endif
00231 # endif
00232 #else
00233 # include <inttypes.h>
00234 # endif
00235
00246 #if !NUSMV_HAVE_INTTYPES_H
00247 # if (defined __MINGW32__) || (defined __CYGWIN__)
00248 # ifdef _WIN64
00249 # define PRIuMAX "I64u"
00250 # define PRIdMAX "I64d"
00251 # define PRIoMAX "I64o"
00252 # define PRIXMAX "I64X"
00253 # else
00254 # define PRIuMAX "lu"
00255 # define PRIdMAX "ld"
00256 # define PRIoMAX "lo"
00257 # define PRIXMAX "lX"
00258 # endif
00259 # else
00260 # if __WORDSIZE == 64
00261 # define PRIuMAX "llu"
00262 # define PRIdMAX "lld"
00263 # define PRIoMAX "llo"
00264 # define PRIXMAX "llX"
00265 # else
00266 # define PRIuMAX "lu"
00267 # define PRIdMAX "ld"
00268 # define PRIoMAX "lo"
00269 # define PRIXMAX "lX"
00270 # endif
00271 # endif
00272 #else
00273 # include <inttypes.h>
00274 # endif
00275
00276
00277 #if NUSMV_HAVE_SRANDOM
00278 # if NUSMV_HAVE_GETPID
00279 # define utils_random_set_seed() \
00280 srandom((unsigned int)getpid())
00281 # else
00282 #include <time.h>
00283 # define utils_random_set_seed() \
00284 srandom((unsigned int)time(NULL))
00285 # endif
00286 #else
00287 # if NUSMV_HAVE_GETPID
00288 # define utils_random_set_seed() \
00289 srand((unsigned int)getpid())
00290 # else
00291 #include <time.h>
00292 # define utils_random_set_seed() \
00293 srand((unsigned int)time(NULL))
00294 # endif
00295 #endif
00296
00297 #if NUSMV_HAVE_RANDOM
00298 # define utils_random() \
00299 random()
00300 #else
00301 # define utils_random() \
00302 rand()
00303 #endif
00304
00305
00306 #if NUSMV_HAVE_STDBOOL_H
00307 #include <stdbool.h>
00308
00314 typedef bool boolean;
00315 #else
00316 #ifdef __cplusplus
00317 typedef bool boolean;
00318 #else
00319 typedef enum {false=0, true=1} boolean;
00320 #endif
00321 #endif
00322
00323
00324
00325 typedef enum Outcome_TAG
00326 {
00327 OUTCOME_GENERIC_ERROR,
00328 OUTCOME_PARSER_ERROR,
00329 OUTCOME_SYNTAX_ERROR,
00330 OUTCOME_FILE_ERROR,
00331 OUTCOME_SUCCESS_REQUIRED_HELP,
00332 OUTCOME_SUCCESS
00333 } Outcome;
00334
00335
00336
00342 #define UNUSED_PARAM(x) (void)(x)
00343
00349 #define UNUSED_VAR(x) (void)(x)
00350
00356 #define ENUM_CHECK(value, first, last) \
00357 nusmv_assert(first < value && value < last)
00358
00359
00363 #define FALLTHROUGH
00364
00365
00366
00367
00373 #define THROWS_EXCEPTION
00374
00375
00376
00382 #define COMMA_OPERATOR ,
00383
00384
00385
00391 typedef int (*PFIVPVP)(const void*, const void*);
00392
00393
00394
00400 typedef void* (*PFVPVPVP)(void*, void*);
00401
00402 #endif