/*$Id: md.h,v 26.18 2007/03/03 06:08:43 al Exp $ -*- C++ -*- * Copyright (C) 2001 Albert Davis * Author: Albert Davis * * This file is part of "Gnucap", the Gnu Circuit Analysis Package * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. *------------------------------------------------------------------ * Machine dependent, configuration, and standard includes */ //testing=trivial 2006.07.17 #ifndef MD_H_INCLUDED #define MD_H_INCLUDED /*--------------------------------------------------------------------------*/ /* autoconf stuff */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /*--------------------------------------------------------------------------*/ /* std collection of includes */ // system #include #include #include #include #include #include #include #include #include #include #include #include // types #include #include // containers #include #include #include #include // algorithms #include #include /* usual but non-standard (POSIX??) collection of includes */ #include /* chdir, access, getcwd */ #include /* old style unix files */ /*--------------------------------------------------------------------------*/ /* constants related to memory size, word size, etc */ enum { BUFLEN = 256, BIGBUFLEN = 4096 }; /*--------------------------------------------------------------------------*/ /* user interface preferences */ #define I_PROMPT "gnucap> " #define CKT_PROMPT ">" #define ANTI_COMMENT "*>" /*--------------------------------------------------------------------------*/ #if defined(__WIN32__) #define ENDDIR "/\\" #define PATHSEP ';' #define SYSTEMSTARTFILE "gnucap.rc" #define SYSTEMSTARTPATH OS::getenv("PATH") #define USERSTARTFILE "gnucap.rc" #define USERSTARTPATH OS::getenv("HOME") #define STEPFILE "/tmp/SXXXXXX" #define SHELL OS::getenv("COMSPEC") /*--------------------------------------------------------------------------*/ #else #define ENDDIR "/" #define PATHSEP ':' #define SYSTEMSTARTFILE "gnucap.rc" #define SYSTEMSTARTPATH OS::getenv("PATH") #define USERSTARTFILE ".gnucaprc" #define USERSTARTPATH OS::getenv("HOME") #define STEPFILE "/tmp/SXXXXXX" #define SHELL OS::getenv("SHELL") #endif /*--------------------------------------------------------------------------*/ /* machine and compiler patches */ #if defined(__MINGW32__) #define SIGSETJMP_IS_BROKEN #define MS_DLL #endif /*--------------------------------------------------------------------------*/ /* my standard collection of includes */ #include "io_error.h" #include "io_trace.h" /*--------------------------------------------------------------------------*/ /* some convenient names */ typedef std::complex COMPLEX; typedef std::pair DPAIR; // dynamic cast kluge. // Strictly, this should always be dynamic_cast, but if it has already // been checked, don't bother checking again, hence static_cast. // It works and is faster. #if defined(NDEBUG) #define prechecked_cast static_cast #else #define prechecked_cast dynamic_cast #endif /*--------------------------------------------------------------------------*/ /* portability hacks */ #if !defined(MS_DLL) // The usual way for POSIX compliant systems #include #else // Microsoft DLL hacks -- thanks to Holger Vogt for the info // Make the MS DLL functions look like the posix ones. #include #undef min #undef max inline void* dlopen(const char* f, int) { return LoadLibrary(f); } inline void dlclose(void* h) { FreeLibrary((HINSTANCE)h); } inline char* dlerror() { static LPVOID lpMsgBuf = NULL; // free the error message buffer if (lpMsgBuf) { LocalFree(lpMsgBuf); } // get the error code DWORD dw = GetLastError(); // get the corresponding error message FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL); return (char*)lpMsgBuf; } #define RTLD_LAZY 0x00001 /* Lazy function call binding. */ #define RTLD_NOW 0x00002 /* Immediate function call binding. */ #define RTLD_BINDING_MASK 0x3 /* Mask of binding time value. */ #define RTLD_NOLOAD 0x00004 /* Do not load the object. */ #define RTLD_DEEPBIND 0x00008 /* Use deep binding. */ #define RTLD_GLOBAL 0x00100 #define RTLD_LOCAL 0 #define RTLD_NODELETE 0x01000 #endif #if defined(SIGSETJMP_IS_BROKEN) #undef sigjmp_buf #undef siglongjmp #undef sigsetjmp #define sigjmp_buf jmp_buf #define siglongjmp(a,b) longjmp(a,b) #define sigsetjmp(a,b) setjmp(a) #endif #if !defined(SIGNALARGS) #define SIGNALARGS int #endif /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ #endif