Holger Vogt Windows port for Ngspice.

This commit is contained in:
pnenzi 2002-01-03 22:44:21 +00:00
parent 6696aac9e6
commit 937e3db647
35 changed files with 573 additions and 54 deletions

View File

@ -1,3 +1,19 @@
2002-01-03 Paolo Nenzi <p.nenzi@ieee.org>
* acconfig.h: added define needed for Windows and some aesthetic
rework (from Holger Vogt patch).
* configure.in: added macros to handle windows related
issues (Holger patch and me).
* INSTALL: added documentation on ngspice compilation under
Windows (Holger Vogt patch).
* Makefile.am: added Windows compilation code (Holger Vogt patch and
me).
2001-12-05 Emmanuel Rouat <emmanuel.rouat@wanadoo.fr>
* configure.in: removed (unnecessary) macros to handle GNU getopt

49
INSTALL
View File

@ -151,3 +151,52 @@ operates.
script, and exit.
`configure' also accepts some other, not widely useful, options.
NGSPICE COMPILATION UNDER WINDOWS OS
====================================
make ngspice with CYGWIN and external MINGW32
according to http://www.geocrawler.com/lists/3/SourceForge/6013/0/7321042/
$ cd ng-spice-rework-14
$ export PATH="/cygdrive/g/gcc_mingw/bin:$PATH"
$ autoconf
$ rm config.cache
$ ./configure --with-windows --prefix="/cygdrive/g/gcc_mingw/bin"
$ make clean
$ make 2> make.err
$ cp config.h config_ming.h
ngspice.exe is o.k.,but make tests does not work (cannot direct console
output into file). Needs to add .save "what" "where.test" to every input
(*.cir) file. Also all given output files have to be adapted to WINDOWS (CR/LF
instead of only LF at each line ending) for allowing proper comparison.
make ngspice with CYGWIN and internal MINGW32 (use config.h made above)
$ cd ng-spice-rework-14
$ rm config.cache
$ export CFLAGS="-mno-cygwin -g -O2"
$ export LDFLAGS="-L/lib/mingw"
$ export CPPFLAGS="-I/usr/include/mingw"
$ ./configure --with-windows
$ cp config_ming.h config.h
$ make clean
$ make 2> make.err
./configure does not work correctly: It finds headers and libs which are not
really available in the -mno-cygwin port of MINGW32. Therefore config.h is
not o.k.
ToDo: find appropriate presets for variables ?
rewrite tests for headers and libs (search exclusively in mingw
directories)

View File

@ -32,8 +32,14 @@
/* Undefine HAVE_EKV since it is not included in the standard distribution */
#undef HAVE_EKV
/* Define if we have GNU readline */
/* Undefine HAVE_GNUREADLINE */
#undef HAVE_GNUREADLINE
/* We do not want spurios debug info into non-developer code */
#undef FTEDEBUG
/* Generate MS WINDOWS executable */
#undef HAS_WINDOWS
/* get system memory and time */
#undef HAVE__MEMAVL

View File

@ -1,6 +1,9 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/main.c)
dnl Keep old autoconf version, procedure is not compatible to new 2.5.2
AC_PREREQ(2.13)
dnl Create a configuration header
AM_CONFIG_HEADER(config.h)
@ -57,6 +60,7 @@ AM_MAINTAINER_MODE
dnl Work on compiler options according to system:
dnl Set default CFLAG - only use -Wall if we have gcc
AC_PROG_CC
if test "x$GCC" = "xyes"; then
@ -106,6 +110,22 @@ AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
dnl --with-windows : the user wants to use generate the MS WINDOWS executable
AC_ARG_WITH(windows,
[ --with-windows MS WINDOWS executable],
dnl set HAS_WINDOWS flag:
AC_DEFINE(HAS_WINDOWS)
)
case $with_windows in
yes )
AC_DEFINE(X_DISPLAY_MISSING)
AC_MSG_RESULT(No X display!)
CFLAGS="$CFLAGS -mwindows";;
*)
dnl Checks for X11 header files and libraries - X11 support can be disabled
dnl by passing the '--without-x' option to configure:
@ -117,16 +137,18 @@ AC_PATH_XTRA
dnl Checks for X libraries - if X11 wasn't found then don't make following
dnl tests and compile without X11 support - otherwise, check if the following
dnl libraries are present (error if they are not)
dnl In CYGWIN library ordering has to be changed. Is this compatible to LINUX?
dnl XShmAttach is a struct in CYGWIN, not a function
if test ! "$no_x" = "yes" ; then
X_LIBS="$X_LIBS -lX11 -lXt"
AC_CHECK_LIB(Xext, XShmAttach,X_LIBS="$X_LIBS -lXext",AC_MSG_ERROR(Couldn't find Xext librairies), $X_LIBS $X_EXTRA_LIBS)
AC_CHECK_LIB(Xmu,main,X_LIBS="$X_LIBS -lXmu",AC_MSG_ERROR(Couldn't find Xmu librairies), $X_LIBS $X_EXTRA_LIBS)
AC_CHECK_LIB(Xaw,main,X_LIBS="$X_LIBS -lXaw",AC_MSG_ERROR(Couldn't find Xaw librairies),$X_LIBS $X_EXTRA_LIBS)
X_LIBS="$X_LIBS -lXt"
AC_CHECK_LIB(Xmu,main,X_LIBS="$X_LIBS -lXmu",AC_MSG_ERROR(Couldn't find Xmu librairies), $X_LIBS $X_EXTRA_LIBS)
AC_CHECK_LIB(Xext,main,X_LIBS="$X_LIBS -lXext",AC_MSG_ERROR(Couldn't find Xext librairies), $X_LIBS $X_EXTRA_LIBS)
X_LIBS="$X_LIBS -lX11 -lXpm"
fi ;;
fi
esac
dnl Check for a few typdefs:
AC_TYPE_PID_T
@ -135,8 +157,8 @@ AC_TYPE_SIGNAL
dnl Check for a few libraries and headers:
dnl Look for ncurses first, then termcap
AC_SEARCH_LIBS(tputs,ncurses termcap,AC_DEFINE(HAVE_TERMCAP),
AC_MSG_ERROR(Found neither ncurses or termcap))
#AC_SEARCH_LIBS(tputs,ncurses termcap,AC_DEFINE(HAVE_TERMCAP),
# AC_MSG_ERROR(Found neither ncurses or termcap))
AC_HEADER_DIRENT
@ -149,13 +171,20 @@ AC_HEADER_TIME
AC_STRUCT_TM
AC_STRUCT_TIMEZONE
AC_CHECK_FUNCS(localtime)
AC_CHECK_FUNCS(gettimeofday time ftime , break)
AC_CHECK_FUNCS(getrusage utimes, break)
AC_CHECK_FUNCS(getrlimit ulimit, break)
case $host_os in
*cygwin* )
AC_CHECK_FUNCS(ftime)
AC_DEFINE(HAVE__MEMAVL) ;;
* )
AC_CHECK_FUNCS(gettimeofday time ftime , break)
AC_CHECK_FUNCS(getrusage utimes, break)
AC_CHECK_FUNCS(getrlimit ulimit, break) ;;
esac
dnl Look for termios first (posix)
AC_CHECK_HEADERS(termios.h termio.h sgtty.h , break)
AC_CHECK_FUNCS(isatty)
AC_CHECK_FUNCS(isatty tcgetattr tcsetattr)
dnl Check for a few functions:
AC_FUNC_VFORK
@ -177,9 +206,12 @@ dnl Check for the garbage collector:
AC_CHECK_LIB(gc,GC_malloc,AC_DEFINE(HAVE_LIBGC) LIBS="$LIBS -lgc")
dnl Check for the asprintf function:
AC_CHECK_FUNCS(asprintf)
AC_CHECK_FUNCS(asprintf,,AC_CHECK_LIB(iberty,asprintf,AC_DEFINE(HAVE_ASPRINTF) LIBS="$LIBS -liberty"))
# AC_CHECK_FUNC(getopt_long, getopt_long=true)
# AM_CONDITIONAL(HAVE_GETOPT_LONG, test "$getopt_long" = "true")
# Expand the prefix variable (this is really annoying!)
if eval "test x$prefix = xNONE"; then
dprefix=$ac_default_prefix
@ -187,10 +219,22 @@ else
dprefix=$prefix
fi
AC_DEFINE_UNQUOTED(NGSPICEBINDIR, "`echo $dprefix/bin`" )
AC_DEFINE_UNQUOTED(NGSPICEDATADIR, "`echo $dprefix/share/ng-spice-rework`" )
AC_DEFINE_UNQUOTED(NGSPICEBUILDDATE, "`date`" )
dnl with the MS WINDOWS executable we suggest /spice_win/bin as *.exe-path
if test "$with_windows" = "yes"; then
dnl redefine the path for WINDOWS:
AC_MSG_RESULT(WINDOWS cide enabled)
AC_DEFINE_UNQUOTED(NGSPICEBINDIR, "`echo /spice_win/bin`" )
AC_DEFINE_UNQUOTED(NGSPICEDATADIR, "`echo /spice_win/lib`" )
WINMAIN = "winmain.o"
else
WINMAIN =""
fi
AC_SUBST(WINMAIN)
# Recapitulate settings:
AC_MSG_RESULT(Settings which were chosen:)
@ -297,6 +341,7 @@ src/frontend/Makefile \
src/frontend/help/Makefile \
src/frontend/parser/Makefile \
src/frontend/plotting/Makefile \
src/frontend/wdisp/Makefile \
src/include/Makefile \
src/maths/Makefile \
src/maths/cmaths/Makefile \
@ -312,6 +357,6 @@ tests/resistance/Makefile \
tests/bsim3soipd/Makefile \
tests/bsim3soifd/Makefile \
tests/bsim3soidd/Makefile \
tests/bsim4/Makefile \
tests/bsim4/Makefile \
tests/mesa/Makefile
)

View File

@ -1,3 +1,16 @@
2002-01-03 Paolo Nenzi <p.nenzi@ieee.org>
* main.c: Some code additions for Windows support (Holger Vogt patch).
* maths/cmaths/Makefile.am: reintegrated test code removed from
Holger Vogt patch (this may cause trouble under Windows).
* maths/cmaths/cmath1.c, maths/cmaths/test_cx_ph.c: small changes to
support Windows (Holger Vogt patch).
* winmain.c: added file for Windows port (Holger Vogt).
2001-12-04 Emmanuel Rouat <emmanuel.rouat@wanadoo.fr>
* maths/cmaths/Makefile.am (noinst_PROGRAMS): test programs

View File

@ -63,12 +63,15 @@ DYNAMIC_DEVICELIBS = \
ngspice_SOURCES = \
conf.c \
conf.h \
ngspice.c
ngspice.c
ngspice_LDADD = \
@WINMAIN@ \
spice.o \
frontend/libfte.a \
frontend/wdisp/libwindisp.a \
frontend/plotting/libplotting.a \
spicelib/devices/dev.o \
$(DYNAMIC_DEVICELIBS) \
spicelib/analysis/libckt.a \
spicelib/devices/libdev.a \
@ -83,7 +86,10 @@ ngspice_LDADD = \
misc/libmisc.a
spice.o: main.c
winmain.o: winmain.c
$(COMPILE) -DSIMULATOR -o winmain.o -c $(srcdir)/winmain.c
spice.o: main.c
$(COMPILE) -DSIMULATOR -o spice.o -c $(srcdir)/main.c
## nutmeg:
@ -95,7 +101,9 @@ ngnutmeg_SOURCES = \
ngnutmeg.c
ngnutmeg_LDADD = \
@WINMAIN@ \
frontend/libfte.a \
frontend/wdisp/libwindisp.a \
frontend/plotting/libplotting.a \
frontend/parser/libparser.a \
frontend/help/libhlp.a \

View File

@ -7,10 +7,21 @@
char Spice_Version[ ] = VERSION;
char Spice_Notice[ ] = "Please submit bug-reports to: ng-spice-bugs@ieee.ing.uniroma1.it";
char Spice_Build_Date[ ] = NGSPICEBUILDDATE;
/*
char *Spice_Exec_Dir = "/spice_win/bin";
char *Spice_Lib_Dir = "/spice_win/lib";
*/
char *Spice_Exec_Dir = NGSPICEBINDIR;
char *Spice_Lib_Dir = NGSPICEDATADIR;
#ifdef __MINGW32__
char *Def_Editor = "notepad.exe";
int AsciiRawFile = 1;
#else
char *Def_Editor = "vi";
int AsciiRawFile = 0;
#endif
char *Bug_Addr = "ng-spice-bugs@ieee.ing.uniroma1.it";
char *Spice_Host = "";

View File

@ -1,4 +1,16 @@
2001-12-14 Paolo Nenzi <p.nenzi@iee.org>
2002-01-03 Paolo Nenzi <p.nenzi@ieee.org>
* wdisp: added an entire directory containing windows frontend code
(Holger Vogt patch). Files in wdsip: ftegraf.h, makedefs, Makefile.am,
windisp.c and winprint.c.
* Makefile.am: Windows code compilation rules added to makefile.
* display.c, outitf.c, rawfile.c, resource.c, runcoms.c: added
defines for Windows (Holger Vogt patch).
2001-12-14 Paolo Nenzi <p.nenzi@ieee.org>
* control.c, control.h, com_cdump.c, com_cdump.h, variable.c, variable.h:
Patched the code with the one contributed by Charles Williams. The patches
@ -6,7 +18,7 @@
2001-11-25 Emmanuel Rouat <emmanuel.rouat@wanadoo.fr>
* circuits.h: transfered definition of sstructire 'circ' to ftedefs.h
* circuits.h: transfered definition of structure 'circ' to ftedefs.h
2001-02-07 Paolo Nenzi <p.nenzi@ieee.org>

View File

@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = plotting help parser
SUBDIRS = plotting help parser wdisp
noinst_LIBRARIES = libfte.a

View File

@ -31,6 +31,17 @@ extern int X11_Init(void), X11_NewViewport(GRAPH *graph), X11_Close(void), X11_
#endif
#ifdef HAS_WINDOWS /* Grafik-IO über MS Windows */
extern int WIN_Init(), WIN_NewViewport(), WIN_Close(), WIN_Clear(),
WIN_DrawLine(), WIN_Arc(), WIN_Text(), WIN_DefineColor(),
WIN_DefineLinestyle(), WIN_SetLinestyle(), WIN_SetColor(),
WIN_Update(), WIN_DiagramReady();
extern int WPRINT_Init(), WPRINT_NewViewport(), WPRINT_Close(), WPRINT_Clear(),
WPRINT_DrawLine(), WPRINT_Arc(), WPRINT_Text(), WPRINT_DefineColor(),
WPRINT_DefineLinestyle(), WPRINT_SetLinestyle(), WPRINT_SetColor(),
WPRINT_Update(), WPRINT_DiagramReady();
#endif
@ -62,6 +73,24 @@ DISPDEVICE device[] = {
gen_DatatoScreen,},
#endif
#ifdef HAS_WINDOWS /* Grafik-IO über MS Windows */
{"Windows", 0, 0, 1000, 1000, 0, 0, WIN_Init, WIN_NewViewport,
WIN_Close, WIN_Clear,
WIN_DrawLine, WIN_Arc, WIN_Text, WIN_DefineColor, WIN_DefineLinestyle,
WIN_SetLinestyle, WIN_SetColor, WIN_Update,
nodev, nodev, nodev, gen_Input,
gen_DatatoScreen, WIN_DiagramReady},
// Achtung: Namen "WinPrint" nicht ändern!
{"WinPrint", 0, 0, 1000, 1000, 0, 0, WPRINT_Init, WPRINT_NewViewport,
WPRINT_Close, WPRINT_Clear,
WPRINT_DrawLine, WPRINT_Arc, WPRINT_Text, WPRINT_DefineColor, WPRINT_DefineLinestyle,
WPRINT_SetLinestyle, WPRINT_SetColor, WPRINT_Update,
nodev, nodev, nodev, nodev,
gen_DatatoScreen, WPRINT_DiagramReady},
#endif
{"plot5", 0, 0, 1000, 1000, 0, 0, Plt5_Init, Plt5_NewViewport,
Plt5_Close, Plt5_Clear,
@ -87,6 +116,7 @@ DISPDEVICE device[] = {
};
DISPDEVICE *dispdev = device + NUMELEMS(device) - 1;
// DISPDEVICE *dispdev = device ; /* GCC257 stuertzt hier ab */
#define XtNumber(arr) (sizeof(arr) / sizeof(arr[0]))
@ -135,6 +165,11 @@ DevInit(void)
#endif
#ifdef HAS_WINDOWS
if (!dispdev) {
dispdev = FindDev("Windows");
}
#endif
if (!dispdev) {
externalerror(

View File

@ -524,6 +524,7 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
variable just the same */
currclock = clock();
#ifndef HAS_WINDOWS
if ((currclock-lastclock)>(0.25*CLOCKS_PER_SEC)) {
if (run->isComplex) {
fprintf(stderr, " Reference value : % 12.5e\r",
@ -534,7 +535,7 @@ OUTpData(void *plotPtr, IFvalue *refValue, IFvalue *valuePtr)
}
lastclock = currclock;
}
#endif
for (i = 0; i < run->numData; i++) {
if (run->data[i].outIndex == -1) {
if (run->data[i].type == IF_REAL)

View File

@ -1,3 +1,10 @@
2002-01-03 Paolo Nenzi <p.nenzi@ieee.org>
* complete.c: Double patch applied, code for Windows support (Holger
Vogt) and rework of netBSD support (AMAKAWA Shuhei).
* input.c, lexical.c: Windows support (Holger Vogt patch).
2001-12-14 Paolo Nenzi <p.nenzi@ieee.org>
* lexical.c, complete.c, complete.h:

View File

@ -35,8 +35,10 @@ Modified: 1999 Paolo Nenzi
#include <pwd.h>
#endif
#ifndef __MINGW32__
/* MW. We also need ioctl.h here I think */
#include <sys/ioctl.h>
#endif
/* Be sure the ioctls get included in the following */
#ifdef HAVE_SGTTY_H
@ -413,10 +415,6 @@ cp_ccon(bool on)
# else
# ifdef HAVE_TERMIOS_H
# ifdef __NetBSD__
# define TCGETS
# define TCSETS
# endif
# define TERM_GET TCGETS
# define TERM_SET TCSETS
@ -426,7 +424,7 @@ cp_ccon(bool on)
# endif
# endif
# if defined(TERM_GET) || defined(__NetBSD__)
#ifdef TERM_GET
static bool ison = FALSE;
if (cp_nocc || !cp_interactive || (ison == on))
@ -434,7 +432,7 @@ cp_ccon(bool on)
ison = on;
if (ison == TRUE) {
#ifdef __NetBSD__
#if HAVE_TCGETATTR
tcgetattr(fileno(cp_in),&OS_Buf);
#else
(void) ioctl(fileno(cp_in), TERM_GET, (char *) &OS_Buf);
@ -443,13 +441,13 @@ cp_ccon(bool on)
sbuf.c_cc[VEOF] = 0;
sbuf.c_cc[VEOL] = ESCAPE;
sbuf.c_cc[VEOL2] = CNTRL_D;
#ifdef __NetBSD__
#if HAVE_TCSETATTR
tcsetattr(fileno(cp_in),TCSANOW,&sbuf);
#else
(void) ioctl(fileno(cp_in), TERM_SET, (char *) &sbuf);
#endif
} else {
#ifdef __NetBSD__
#ifdef HAVE_TCSETATTR
tcsetattr(fileno(cp_in),TCSANOW,&OS_Buf);
#else
(void) ioctl(fileno(cp_in), TERM_SET, (char *) &OS_Buf);

View File

@ -24,6 +24,7 @@ inchar(FILE *fp)
{
char c;
#ifndef HAS_WINDOWS
int i;
if (cp_interactive && !cp_nocc) {
@ -38,6 +39,7 @@ inchar(FILE *fp)
} else
return ((int) c);
} else
#endif
c = getc(fp);
return ((int) c);
}

View File

@ -22,8 +22,10 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include <pwd.h>
#endif
#ifndef __MINGW32__
/* MW. Linux has TIOCSTI, so we include all headers here */
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SGTTY_H
#include <sys/types.h>

View File

@ -1,3 +1,7 @@
2002-01-03 Paolo Nenzi <p.nenzi@ieee.org>
* graf.c: Added code to support Windows (Holger Vogt patch).
2000-10-10 Arno W. Peters <A.W.Peters@ieee.org>
* graf.c: Removed need to press return after resizing the plot

View File

@ -153,6 +153,16 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */
graph->data.xmax = xlims[1];
graph->data.ymin = ylims[0];
graph->data.ymax = ylims[1];
/* get title into plot window */
#ifdef HAS_WINDOWS
if (!pname)
pname = "(unknown)";
if (!plotname)
plotname = "(unknown)";
comb_title = tmalloc(strlen(plotname) + strlen(pname) + 3);
sprintf(comb_title, "%s: %s", pname, plotname);
graph->plotname = comb_title;
#endif
/* note: have enum here or some better convention */
if (NewViewport(graph) == 1) {
@ -199,7 +209,7 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */
graph->grid.ylabel = "imag";
}
}
#ifndef HAS_WINDOWS
if (!pname)
pname = "(unknown)";
if (!plotname)
@ -207,7 +217,7 @@ gr_init(double *xlims, double *ylims, /* The size of the screen. */
comb_title = tmalloc(strlen(plotname) + strlen(pname) + 3);
sprintf(comb_title, "%s: %s", pname, plotname);
graph->plotname = comb_title;
#endif
gr_resize_internal(graph);
gr_redrawgrid(graph);

View File

@ -24,6 +24,12 @@ int raw_prec = -1; /* How many sigfigs to use, default 15 (max). */
#define DEFPREC 15
#ifdef HAS_WINDOWS
#undef fscanf /* redo I/O from WINMAIN.C here
otherwise reading ASCII will not work */
#endif
/* Write a raw file. We write everything in the plot pointed to. */
void
@ -56,11 +62,34 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
else
prec = DEFPREC;
#ifdef __MINGW32__
// -Binärdatei binär schreiben- hvogt 15.03.2000 ---------------------
if (binary) {
if (!(fp = fopen(name, app ? "ab" : "wb"))) {
perror(name);
return;
}
fprintf(cp_out,"binary raw file\n");
}
else {
if (!(fp = fopen(name, app ? "a" : "w"))) {
perror(name);
return;
}
fprintf(cp_out,"ASCII raw file\n");
}
// --------------------------------------------------------------------
#else
if (!(fp = fopen(name, app ? "a" : "w"))) {
perror(name);
return;
}
#endif
numdims = nvars = length = 0;
for (v = pl->pl_dvecs; v; v = v->v_next) {
if (iscomplex(v))
@ -138,7 +167,7 @@ raw_write(char *name, struct plot *pl, bool app, bool binary)
if (v->v_gridtype)
fprintf(fp, " grid=%d", v->v_gridtype);
if (v->v_plottype)
fprintf(fp, " plot=%d", v->v_gridtype);
fprintf(fp, " plot=%d", v->v_plottype);
/* Only write dims if they are different from default. */
writedims = FALSE;
if (v->v_numdims != numdims) {
@ -253,12 +282,35 @@ raw_read(char *name)
struct variable *vv;
wordlist *wl, *nwl;
FILE *fp, *lastin, *lastout, *lasterr;
bool binary = TRUE;
if (!(fp = fopen(name, "r"))) {
perror(name);
return (NULL);
}
#ifdef __MINGW32__
// Test, ob Datei wirklich ASCII, sonst binär annehmen hvogt 15.3.2000
while (fgets(buf, BSIZE_SP, fp)) {
if (ciprefix("values:", buf)) {
binary = FALSE;
rewind(fp); // zurückspulen
fprintf(cp_err, "\nASCII raw file\n");
break;
}
}
if (binary) {
(void) fclose(fp);
if (!(fp = fopen(name, "rb"))) {
perror(name);
return (NULL);
}
fprintf(cp_err, "\nbinary raw file\n");
}
//--------------------------------------------------------
#endif
/* Since we call cp_evloop() from here, we have to do this junk. */
lastin = cp_curin;
lastout = cp_curout;

View File

@ -17,24 +17,47 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "resource.h"
#include "variable.h"
#ifdef HAVE__MEMAVL
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
/* static declarations */
static void printres(char *name);
static RETSIGTYPE fault(void);
static void * baseaddr(void);
#ifdef HAVE__MEMAVL
size_t mem_avail;
size_t _memavl(void)
{
MEMORYSTATUS ms;
DWORD sum;
ms.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus( &ms);
sum = ms.dwAvailPhys + ms.dwAvailPageFile;
return (size_t) sum;
}
#else
char *startdata;
char *enddata;
#endif
void
init_rlimits(void)
{
# ifdef HAVE__MEMAVL // hvogt
mem_avail = _memavl( );
# else
startdata = (char *) baseaddr( );
enddata = sbrk(0);
# endif
// startdata = (char *) baseaddr( );
// enddata = sbrk(0);
}
@ -88,10 +111,19 @@ void
ft_ckspace(void)
{
long usage, limit;
#ifdef HAVE__MEMAVL
size_t mem_avail_now;
mem_avail_now = _memavl( );
usage = mem_avail - mem_avail_now;
limit = mem_avail;
#else
static long old_usage = 0;
char *hi;
# ifdef HAVE_GETRLIMIT
struct rlimit rld;
@ -102,6 +134,8 @@ ft_ckspace(void)
# else
/* SYSVRLIMIT */
limit = ulimit(3, 0L) - (enddata - startdata);
@ -110,6 +144,7 @@ ft_ckspace(void)
usage = (long) (hi - enddata);
if (limit < 0)
return; /* what else do you do? */
@ -118,6 +153,8 @@ ft_ckspace(void)
old_usage = usage;
#endif
if (usage > limit * 0.9) {
fprintf(cp_err, "Warning - approaching max data size: ");
fprintf(cp_err, "current size = %ld, limit = %ld.\n", usage, limit);
@ -162,7 +199,7 @@ printres(char *name)
int sec, msec;
ftime(&timenow);
timediff(&timenow, &timebegin, &total, &totalu);
totalu /= 1000;
// totalu /= 1000; hvogt
cpu_elapsed = "elapsed";
# else
# define NO_RUDATA
@ -191,10 +228,10 @@ printres(char *name)
lastusec -= 1000;
lastsec += 1;
}
#ifndef HAVE__MEMAVL
fprintf(cp_out, "%s time since last call: %lu.%03lu seconds.\n",
cpu_elapsed, lastsec, lastusec);
#endif
lastsec = total;
lastusec = totalu;
}
@ -212,6 +249,17 @@ printres(char *name)
if (!name || eq(name, "space")) {
long usage = 0, limit = 0;
#ifdef HAVE__MEMAVL
size_t mem_avail_now;
mem_avail_now = _memavl( );
usage = mem_avail - mem_avail_now;
limit = mem_avail;
#else
#ifdef ipsc
NXINFO cur = nxinfo, start = nxinfo_snap;
@ -236,8 +284,18 @@ printres(char *name)
# endif
# endif
#endif
#endif
#ifdef HAVE__MEMAVL
if (usage > 1000000)
fprintf(cp_out, "Current dynamic memory usage = %8.6f MB,\n", usage/1000000.);
else
fprintf(cp_out, "Current dynamic memory usage = %5.3f kB,\n", usage/1000.);
fprintf(cp_out, "Dynamic memory limit = %8.6f MB.\n", limit/1000000.);
#else
fprintf(cp_out, "Current dynamic memory usage = %ld,\n", usage);
fprintf(cp_out, "Dynamic memory limit = %ld.\n", limit);
#endif
yy = TRUE;
}
@ -321,6 +379,10 @@ baseaddr(void)
if (getenv("SPICE_NO_DATASEG_CHECK"))
return 0;
#if defined(__CYGWIN__) || defined(HAS_WINDOWS)
return 0;
#endif
low = 0;
high = (char *) ((unsigned long) sbrk(0) & ~((1 << LOG2_PAGESIZE) - 1));

View File

@ -214,12 +214,33 @@ dosim(char *what, wordlist *wl)
#endif /* PARALLEL_ARCH */
if (!*wl->wl_word)
rawfileFp = stdout;
#ifdef __MINGW32__
// ask if binary or ASCII, open file with w or wb hvogt 15.3.2000
else if (ascii) {
if(!(rawfileFp = fopen(wl->wl_word, "w"))) {
perror(wl->wl_word);
ft_setflag = FALSE;
return 1;
}
fprintf(cp_out,"ASCII raw file\n");
}
else if (!ascii) {
if(!(rawfileFp = fopen(wl->wl_word, "wb"))) {
perror(wl->wl_word);
ft_setflag = FALSE;
return 1;
}
fprintf(cp_out,"binary raw file\n");
}
//-------------------------------------------------------------------------
#else
else if (!(rawfileFp = fopen(wl->wl_word, "w"))) {
setvbuf(rawfileFp, rawfileBuf, _IOFBF, RAWBUF_SIZE);
perror(wl->wl_word);
ft_setflag = FALSE;
return 1;
}
#endif /* __MINGW32__ */
rawfileBinary = !ascii;
#ifdef PARALLEL_ARCH
} else {

View File

@ -1,3 +1,15 @@
2002-01-03 Paolo Nenzi <p.nenzi@ieee.org>
* wstdio.h: Standard input/output for Windows (Holger Vogt patch).
* complex.h: _complex redefined as _complex1 to avoid conflict with
MINGW32 Paolo Nenzi <p.nenzi@ieee.org>
* defines.h: added defines for Windows (Holger Vogt patch).
* ngspice.h: added wstdio.h inclusion if compiling for Windows
(Holger Vogt patch).
2001-12-14 Paolo Nenzi <p.nenzi@ieee.org>
* cpextern.h: Modification needed for patches sent by

View File

@ -7,15 +7,15 @@
/* Complex numbers. */
struct _complex { /* IBM portability... */
struct _complex1 { /* IBM portability... renamed due to double definition in MINGW32*/
double cx_real;
double cx_imag;
} ;
typedef struct _complex complex;
typedef struct _complex1 complex;
#define realpart(cval) ((struct _complex *) (cval))->cx_real
#define imagpart(cval) ((struct _complex *) (cval))->cx_imag
#define realpart(cval) ((struct _complex1 *) (cval))->cx_real
#define imagpart(cval) ((struct _complex1 *) (cval))->cx_imag
/*

View File

@ -65,6 +65,18 @@
#define REFTEMP 300.15 /* 27 degrees C */
#ifdef __MINGW32__
#define DIR_PATHSEP "\\"
#define DIR_TERM '\\'
#define DIR_CWD "."
#define TEMPFORMAT "%s%d.tmp"
/*
#define SYSTEM_PLOT5LPR "lpr -P%s -g %s"
#define SYSTEM_PSLPR "lpr -P%s %s"
#define SYSTEM_MAIL "Mail -s \"%s (%s) Bug Report\" %s"
*/
#else
#define DIR_PATHSEP "/"
#define DIR_TERM '/'
@ -75,6 +87,7 @@
#define SYSTEM_PSLPR "lpr -P%s %s"
#define SYSTEM_MAIL "Mail -s \"%s (%s) Bug Report\" %s"
#endif
/*
* #define-s that are always on
@ -102,7 +115,7 @@
#define TRUE 1
#define FALSE 0
/*
#define DIR_PATHSEP "/"
#define DIR_TERM '/'
@ -113,7 +126,7 @@
#define SYSTEM_PSLPR "lpr -P%s %s"
#define SYSTEM_MAIL "Mail -s \"%s (%s) Bug Report\" %s"
*/

View File

@ -103,6 +103,14 @@ struct timeb timebegin;
#include <time.h>
#endif
// added for CYGWIN
#ifndef HUGE
#define HUGE HUGE_VAL
#endif
#ifdef HAS_WINDOWS
#include "wstdio.h"
#endif
extern char *gettok(char **s);
extern void appendc(char *s, char c);

View File

@ -23,7 +23,9 @@
#include <spicelib/devices/dev.h>
#include <spicelib/analysis/analysis.h>
#include <misc/ivars.h>
#if !defined(__CYGWIN__)
#include <misc/getopt.h>
#endif
#include <frontend/resource.h>
#include <frontend/variable.h>
@ -46,6 +48,9 @@ bool ft_intrpt = FALSE; /* Set by the (void) signal handlers. */
bool ft_setflag = FALSE; /* Don't abort after an interrupt. */
char *ft_rawfile = "rawspice.raw";
bool oflag = FALSE; /* Output über redefinierte Funktionen */
FILE *flogp; // hvogt 15.12.2001
/* Frontend and circuit options */
IFsimulator *ft_sim = NULL;
@ -240,7 +245,11 @@ append_to_stream(FILE *dest, FILE *source)
}
int
#ifdef HAS_WINDOWS
xmain(int argc, char **argv)
#else
main(int argc, char **argv)
#endif
{
int c;
int err;
@ -318,7 +327,8 @@ main(int argc, char **argv)
#ifdef MALLOCTRACE
mallocTraceInit("malloc.out");
#endif
#ifdef HAVE_ISATTY
#if defined (HAVE_ISATTY) && !defined(HAS_WINDOWS)
istty = (bool) isatty(fileno(stdin));
#endif
@ -398,10 +408,22 @@ main(int argc, char **argv)
#else
sprintf (buf, "%s", optarg);
#endif
if (!(freopen (buf, "w", stdout))) {
/* if (!(freopen (buf, "w", stdout))) {
perror (buf);
shutdown (EXIT_BAD);
}
*/
// *** Log-File öffnen *******
if (!(flogp = fopen(buf, "w"))) {
perror(buf);
shutdown(EXIT_BAD);
}
// ***************************
com_version(NULL); // hvogt 11.11.2001
fprintf(stdout, "\nBatch mode\n\n");
fprintf(stdout, "Simulation output goes to rawfile: %s\n\n", ft_rawfile);
fprintf(stdout, "Comments and warnigs go to log-file: %s\n", buf);
oflag = TRUE;
}
break;
@ -473,7 +495,7 @@ main(int argc, char **argv)
if (!ft_batchmode) {
signal(SIGINT, ft_sigintr);
signal(SIGFPE, sigfloat);
#ifdef SIGTSTP
#if defined(SIGTSTP) // && !defined(__MINGW32__)
signal(SIGTSTP, sigstop);
#endif
}

View File

@ -14,7 +14,7 @@ libcmaths_a_SOURCES = \
cmath4.h
noinst_PROGRAMS = test_cx_mag test_cx_j test_cx_ph
test_cx_ph_SOURCES = \
test_cx_ph.c
@ -38,6 +38,7 @@ test_cx_j_LDADD = \
TESTS = test_cx_mag test_cx_j test_cx_ph
INCLUDES = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/maths/poly
MAINTAINERCLEANFILES = Makefile.in

View File

@ -24,6 +24,9 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "cmath.h"
#include "cmath1.h"
#ifdef HAS_WINDOWS
#define fp_r_i_n_t_f fprintf
#endif
/* This flag determines whether degrees or radians are used. The radtodeg
* and degtorad macros are no-ops if this is FALSE.

View File

@ -6,6 +6,7 @@
#include <memory.h>
#include <dvec.h>
#include <complex.h>
#include <defines.h>
#include "cmath.h"
#include "cmath1.h"

View File

@ -1,3 +1,10 @@
2002-01-03 Paolo Nenzi <p.nenzi@ieee.org>
* Added some code that adds new functionalities if
ngspice is compiled for Windows (Holger Vogt patch)
I think that the new code interactively displays the
percent done of the analysis.
2001-01-23 Paolo Nenzi <p.nenzi@ieee.org>
* noisean.c: patched the code with the new one

View File

@ -11,6 +11,10 @@ Modified 2001: AlansFixes
#include "devdefs.h"
#include "sperror.h"
#ifdef HAS_WINDOWS
void SetAnalyse( char * Analyse, int Percent);
#endif
int
ACan(CKTcircuit *ckt, int restart)
@ -196,10 +200,36 @@ ACan(CKTcircuit *ckt, int restart)
switch(((ACAN*)ckt->CKTcurJob)->ACstepType) {
case DECADE:
case OCTAVE:
// neu eingefügt 14.12.2001
#ifdef HAS_WINDOWS
{
double endfreq = ((ACAN*)ckt->CKTcurJob)->ACstopFreq;
double startfreq = ((ACAN*)ckt->CKTcurJob)->ACstartFreq;
double step = ((ACAN*)ckt->CKTcurJob)->ACfreqDelta;
endfreq = log(endfreq);
if (startfreq == 0.0)
startfreq = 1e-12;
startfreq = log(startfreq);
if (freq > 0.0)
SetAnalyse( "ac", (log(freq)-startfreq) * 100.0 / (endfreq-startfreq));
}
#endif
freq *= ((ACAN*)ckt->CKTcurJob)->ACfreqDelta;
if(((ACAN*)ckt->CKTcurJob)->ACfreqDelta==1) goto endsweep;
break;
case LINEAR:
#ifdef HAS_WINDOWS
{
double endfreq = ((ACAN*)ckt->CKTcurJob)->ACstopFreq;
double startfreq = ((ACAN*)ckt->CKTcurJob)->ACstartFreq;
SetAnalyse( "ac", (freq - startfreq)* 100.0 / (endfreq-startfreq));
}
#endif
freq += ((ACAN*)ckt->CKTcurJob)->ACfreqDelta;
if(((ACAN*)ckt->CKTcurJob)->ACfreqDelta==0) goto endsweep;
break;

View File

@ -13,6 +13,12 @@ Modified: 2000 AlansFixes
#include <trandefs.h>
#include <sperror.h>
#ifdef HAS_WINDOWS /* hvogt 10.03.99, nach W. Mues */
void SetAnalyse( char * Analyse, int Percent);
#endif
int
DCtran(CKTcircuit *ckt,
int restart) /* forced restart flag */
@ -328,6 +334,9 @@ resume:
(void)printf("limited by Tmax\n");
}
}
#endif
#ifdef HAS_WINDOWS
SetAnalyse( "tran", (int)((ckt->CKTtime * 100) / ckt->CKTfinalTime));
#endif
ckt->CKTdelta =
MIN(ckt->CKTdelta,ckt->CKTmaxStep);

View File

@ -1,3 +1,12 @@
2002-01-03 Paolo Nenzi <p.nenzi@ieee.org>
* bsim3v1/b3v1noi.c, bsim3v2/b3v2noi.c: Both models had a
function called StrongInversionNoiseEval(). They were renamed
BSIM3V1StrongInversionNoiseEval() and
BSIM3V2StrongInversionNoiseEval(). (Holger Vogt)
* dev.c: support for ieee754 floating point. (Holger Vogt patch)
2000-08-28 Arno W. Peters <A.W.Peters@ieee.org>
* asrc/asrcset.c, bjt/bjtsetup.c, bsim1/b1set.c, bsim2/b2set.c,

View File

@ -44,7 +44,7 @@ extern void NevalSrc();
extern double Nintegrate();
double
StrongInversionNoiseEval(vgs, vds, model, here, freq, temp)
BSIM3V1StrongInversionNoiseEval(vgs, vds, model, here, freq, temp)
double vgs, vds, freq, temp;
BSIM3V1model *model;
BSIM3V1instance *here;
@ -253,7 +253,7 @@ int i;
vgs = vgs + vds;
}
if (vgs >= here->BSIM3V1von + 0.1)
{ Ssi = StrongInversionNoiseEval(vgs,
{ Ssi = BSIM3V1StrongInversionNoiseEval(vgs,
vds, model, here, data->freq,
ckt->CKTtemp);
noizDens[BSIM3V1FLNOIZ] *= Ssi;
@ -268,7 +268,7 @@ int i;
* 4.0e36;
Swi = T10 / T11 * here->BSIM3V1cd
* here->BSIM3V1cd;
Slimit = StrongInversionNoiseEval(
Slimit = BSIM3V1StrongInversionNoiseEval(
here->BSIM3V1von + 0.1, vds, model,
here, data->freq, ckt->CKTtemp);
T1 = Swi + Slimit;

View File

@ -44,7 +44,7 @@ extern void NevalSrc();
extern double Nintegrate();
double
StrongInversionNoiseEval(vgs, vds, model, here, freq, temp)
BSIM3V2StrongInversionNoiseEval(vgs, vds, model, here, freq, temp)
double vgs, vds, freq, temp;
BSIM3V2model *model;
BSIM3V2instance *here;
@ -253,7 +253,7 @@ int error, i;
vgs = vgs + vds;
}
if (vgs >= here->BSIM3V2von + 0.1)
{ Ssi = StrongInversionNoiseEval(vgs,
{ Ssi = BSIM3V2StrongInversionNoiseEval(vgs,
vds, model, here, data->freq,
ckt->CKTtemp);
noizDens[BSIM3V2FLNOIZ] *= Ssi;
@ -268,7 +268,7 @@ int error, i;
* 4.0e36;
Swi = T10 / T11 * here->BSIM3V2cd
* here->BSIM3V2cd;
Slimit = StrongInversionNoiseEval(
Slimit = BSIM3V2StrongInversionNoiseEval(
here->BSIM3V2von + 0.1, vds, model,
here, data->freq, ckt->CKTtemp);
T1 = Swi + Slimit;

View File

@ -182,3 +182,53 @@ devices(void)
{
return DEVices;
}
#ifdef __MINGW32__
// isnan for SOI devices in MINGW32 hvogt
union ieee754_double
{
double d;
/* This is the IEEE 754 double-precision format. */
struct
{
/* Together these comprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:20;
unsigned int exponent:11;
unsigned int negative:1;
} ieee;
struct
{
/* Together these conprise the mantissa. */
unsigned int mantissa1:32;
unsigned int mantissa0:19;
unsigned int quiet_nan:1;
unsigned int exponent:11;
unsigned int negative:1;
} ieee_nan;
};
int
isnan(double value)
{
union ieee754_double u;
u.d = value;
/* IEEE 754 NaN's have the maximum possible
exponent and a nonzero mantissa. */
return ((u.ieee.exponent & 0x7ff) == 0x7ff &&
(u.ieee.mantissa0 != 0 || u.ieee.mantissa1 != 0));
}
/*
* end isnan.c
*/
#endif