00001 /* --------------------------------------------------------------------------- 00002 00003 This file is part of the ``utils'' package of NuSMV version 2. 00004 Copyright (C) 2005 FBK-irst. 00005 00006 NuSMV version 2 is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 NuSMV version 2 is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00019 00020 For more information of NuSMV see <http://nusmv.fbk.eu> 00021 or email to <nusmv-users@fbk.eu>. 00022 Please report bugs to <nusmv-users@fbk.eu>. 00023 00024 To contact the NuSMV development board, email to <nusmv@fbk.eu>. 00025 00026 -----------------------------------------------------------------------------*/ 00027 00038 #ifndef __NUSMV_CORE_UTILS_PORTABILITY_H__ 00039 #define __NUSMV_CORE_UTILS_PORTABILITY_H__ 00040 00041 #include <limits.h> /* for ULLONG_MAX and LLONG_MAX */ 00042 00043 #if HAVE_CONFIG_H 00044 #include "nusmv-config.h" 00045 #endif 00046 00047 /*---------------------------------------------------------------------------*/ 00048 /* Macro declarations */ 00049 /*---------------------------------------------------------------------------*/ 00050 00051 #if !NUSMV_HAVE_MALLOC 00052 # undef malloc 00053 # undef realloc 00054 # if NUSMV_HAVE_MALLOC_H 00055 # include <malloc.h> 00056 # elif NUSMV_HAVE_STDLIB_H 00057 # include <stdlib.h> 00058 # endif 00059 00060 # ifndef malloc 00061 void* malloc(size_t); 00062 # endif /* ifndef malloc */ 00063 00064 # ifndef realloc 00065 void* realloc(void*, size_t); 00066 # endif /* ifndef realloc */ 00067 #endif /* if not NUSMV_HAVE_MALLOC */ 00068 00069 #if NUSMV_HAVE_ERRNO_H 00070 #include <errno.h> 00071 #else 00072 /* extern definition for the errno variable */ 00073 #ifndef errno 00074 extern int errno; 00075 #endif 00076 00077 #ifndef ERANGE 00078 /* Result too large */ 00079 00085 #define ERANGE 34 00086 #endif 00087 00088 #ifndef EINVAL 00089 /* Result invalid */ 00090 00096 #define EINVAL 22 00097 #endif 00098 00099 #endif 00100 00101 /* some specific macros for Visual Studio */ 00102 #if defined(_MSC_VER) 00103 #define strncasecmp _strnicmp 00104 #define strcasecmp _stricmp 00105 #endif 00106 00107 #if defined(_MSC_VER) 00108 #define __func__ __FUNCTION__ 00109 #endif 00110 00111 /* strtoull not available within MSVC */ 00112 #if ! NUSMV_HAVE_STRTOULL && defined(_MSC_VER) 00113 # define strtoull \ 00114 _strtoui64 00115 #endif 00116 00117 /* for compilers which are not compliant with C99 but have "long long" 00118 ULLONG_MAX/LLONG_MAX/LLONG_MIN may be not defined. Note that "long 00119 long" has to be supported as it is used, e.g., in WordNumber class. 00120 */ 00121 #ifndef ULLONG_MAX 00122 /* this solution should be safe as unsigned cast is done 00123 "by repeatedly adding or subtracting one more than the maximum value 00124 that can be represented in the new type until the value is in the 00125 range of the new type". I.e. the max value of unsigned long long. 00126 Another possibility is (~0ULL) */ 00127 00133 #define ULLONG_MAX ((unsigned long long) -1) 00134 #endif 00135 00136 #ifndef LLONG_MAX 00137 00143 #define LLONG_MAX ((long long)(ULLONG_MAX >> 1)) 00144 #endif 00145 00146 #ifndef LLONG_MIN 00147 /* probably this is not a portable definition. Expert opinion required. */ 00148 00154 #define LLONG_MIN (- LLONG_MAX - 1) 00155 #endif 00156 00157 /*---------------------------------------------------------------------------*/ 00158 /* Structure definitions */ 00159 /*---------------------------------------------------------------------------*/ 00160 00161 /*---------------------------------------------------------------------------*/ 00162 /* Variable declarations */ 00163 /*---------------------------------------------------------------------------*/ 00164 00165 /*---------------------------------------------------------------------------*/ 00166 /* Functions declarations */ 00167 /*---------------------------------------------------------------------------*/ 00168 00169 00170 00171 #endif /* ifndef __NUSMV_CORE_UTILS_PORTABILITY_H__ */