1#ifndef IVL_config_H 2#define IVL_config_H 3/* 4 * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com) 5 * 6 * This source code is free software; you can redistribute it 7 * and/or modify it in source code form under the terms of the GNU 8 * General Public License as published by the Free Software 9 * Foundation; either version 2 of the License, or (at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 */ 21 22#if defined(__cplusplus) 23# if !defined(__GNUC__) 24 using namespace std; 25# elif (__GNUC__ == 3) 26 using namespace std; 27# endif 28#endif 29 30# define SIZEOF_UNSIGNED_LONG_LONG 0 31#ifndef SIZEOF_UNSIGNED_LONG 32# define SIZEOF_UNSIGNED_LONG 0 33#endif 34# define SIZEOF_UNSIGNED 0 35 36# undef NEED_LU 37# undef NEED_TU 38# undef WLU 39# undef WTU 40# undef HAVE_IOSFWD 41# undef HAVE_DLFCN_H 42# undef HAVE_DL_H 43# undef HAVE_GETOPT_H 44# undef HAVE_LIBREADLINE 45# undef HAVE_READLINE_READLINE_H 46# undef HAVE_LIBHISTORY 47# undef HAVE_READLINE_HISTORY_H 48# undef HAVE_INTTYPES_H 49# undef HAVE_LROUND 50# undef HAVE_LLROUND 51# undef HAVE_NAN 52# undef UINT64_T_AND_ULONG_SAME 53 54/* 55 * Define this if you want to compile vvp with memory freeing and 56 * special valgrind hooks for the memory pools. 57 */ 58# undef CHECK_WITH_VALGRIND 59 60/* Figure if I can use readline. */ 61#undef USE_READLINE 62#ifdef HAVE_LIBREADLINE 63#ifdef HAVE_READLINE_READLINE_H 64# define USE_READLINE 65#endif 66#endif 67 68/* Figure if I can use history. */ 69#undef USE_HISTORY 70#ifdef HAVE_LIBHISTORY 71#ifdef HAVE_READLINE_HISTORY_H 72# define USE_HISTORY 73#endif 74#endif 75 76#ifndef MODULE_DIR 77# define MODULE_DIR "." 78#endif 79 80#ifdef HAVE_INTTYPES_H 81/* This is needed in C++ to get the PRI?64 formats. */ 82# ifndef __STDC_FORMAT_MACROS 83# define __STDC_FORMAT_MACROS 84# endif 85# include <inttypes.h> 86 87typedef uint64_t vvp_time64_t; 88 89# define TIME_FMT_O PRIo64 90# define TIME_FMT_U PRIu64 91# define TIME_FMT_X PRIx64 92 93# ifdef UINT64_T_AND_ULONG_SAME 94# define UL_AND_TIME64_SAME 95# endif 96 97#else /* HAVE_INTTYPES_H */ 98 99 100#if SIZEOF_UNSIGNED >= 8 101typedef unsigned vvp_time64_t; 102# define TIME_FMT_O "o" 103# define TIME_FMT_U "u" 104# define TIME_FMT_X "x" 105#else 106# if SIZEOF_UNSIGNED_LONG >= 8 107typedef unsigned long vvp_time64_t; 108# define UL_AND_TIME64_SAME 109# define TIME_FMT_O "lo" 110# define TIME_FMT_U "lu" 111# define TIME_FMT_X "lx" 112# else 113# if SIZEOF_UNSIGNED_LONG_LONG > SIZEOF_UNSIGNED_LONG 114typedef unsigned long long vvp_time64_t; 115# define TIME_FMT_O "llo" 116# define TIME_FMT_U "llu" 117# define TIME_FMT_X "llx" 118# else 119typedef unsigned long vvp_time64_t; 120# define UL_AND_TIME64_SAME 121# define TIME_FMT_O "lo" 122# define TIME_FMT_U "lu" 123# define TIME_FMT_X "lx" 124# endif 125# endif 126#endif 127 128#endif /* HAVE_INTTYPES_H */ 129 130# include <cmath> 131 132/* getrusage, /proc/self/statm */ 133 134# undef HAVE_SYS_RESOURCE_H 135# undef LINUX 136 137#if !defined(HAVE_LROUND) 138/* 139 * If the system doesn't provide the lround function, then we provide 140 * it ourselves here. It is simply the nearest integer, rounded away 141 * from zero. 142 */ 143inline long int lround(double x) 144{ 145 if (x >= 0.0) 146 return (long)floor(x+0.5); 147 else 148 return (long)ceil(x-0.5); 149} 150#endif /* HAVE_LROUND */ 151 152#if ((SIZEOF_UNSIGNED_LONG < 8) && (SIZEOF_UNSIGNED_LONG_LONG >= 8)) 153#if !defined(HAVE_LLROUND) 154/* 155 * We also need an equivalent function with a 64-bit return value if 156 * it is not available. 157 */ 158inline int64_t i64round(double x) 159{ 160 if (x >= 0.0) 161 return (int64_t)floor(x+0.5); 162 else 163 return (int64_t)ceil(x-0.5); 164} 165#else /* HAVE_LLROUND */ 166# define i64round llround 167#endif /* HAVE_LLROUND */ 168#else 169# define i64round lround 170#endif 171 172#if !defined(HAVE_NAN) 173# define nan(x) (NAN) 174#endif 175 176#if !defined(INFINITY) 177# define INFINITY HUGE_VAL 178#endif 179 180/* 181 * When doing dynamic linking, we need a uniform way to identify the 182 * symbol. Some compilers put leading _, some trailing _. The 183 * configure script figures out which is the local convention and 184 * defines NEED_LU and NEED_TU as required. 185 */ 186#ifdef NEED_LU 187#define LU "_" 188#else 189#define LU "" 190#endif 191 192#ifdef NEED_TU 193#define TU "_" 194#else 195#define TU "" 196#endif 197 198#ifdef __MINGW32__ 199# include <cstdlib> 200# include <string.h> 201static inline char*strndup(const char*s, size_t n) 202{ 203 if (strlen(s) < n) return strdup(s); 204 char*tmp = (char*)malloc(n); 205 strncpy(tmp, s, n); 206 tmp[n-1] = 0; 207 return tmp; 208} 209#endif 210 211#endif /* IVL_config_H */ 212