Small changes, e.g. _MS_VER macro, added to allow compilation of tclspice with MS VC++ 2008
This commit is contained in:
parent
ee349375bd
commit
3dc3d42553
|
|
@ -1,3 +1,6 @@
|
|||
2008-10-05 Holger Vogt
|
||||
* Macros added to allow compilation of tclspice with MS Visual C++ 2008
|
||||
|
||||
2008-09-24 Holger Vogt
|
||||
* wstdio.h, scalb.c, complex.h
|
||||
Small changes to allow compilation with MS Visual C++ 2008
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
#include "vectors.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
|
||||
typedef struct measure
|
||||
{
|
||||
char *result;
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ static char * mkcname(char what, char *v1, char *v2);
|
|||
* be lost, but that's no great loss.
|
||||
*/
|
||||
|
||||
static JMP_BUF matherrbuf;
|
||||
static JMP_BUF matherrbuf;
|
||||
|
||||
static RETSIGTYPE
|
||||
sig_matherr(void)
|
||||
{
|
||||
fprintf(cp_err, "Error: argument out of range for math function\n");
|
||||
LONGJMP(matherrbuf, 1);
|
||||
LONGJMP(matherrbuf, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -221,7 +221,7 @@ doop(char what,
|
|||
/* Some of the math routines generate SIGILL if the argument is
|
||||
* out of range. Catch this here.
|
||||
*/
|
||||
if (SETJMP(matherrbuf, 1)) {
|
||||
if (SETJMP(matherrbuf, 1)) {
|
||||
return (NULL);
|
||||
}
|
||||
(void) signal(SIGILL, (SIGNAL_FUNCTION) sig_matherr);
|
||||
|
|
@ -701,7 +701,7 @@ apply_func(struct func *func, struct pnode *arg)
|
|||
/* Some of the math routines generate SIGILL if the argument is
|
||||
* out of range. Catch this here.
|
||||
*/
|
||||
if (SETJMP(matherrbuf, 1)) {
|
||||
if (SETJMP(matherrbuf, 1)) {
|
||||
(void) signal(SIGILL, SIG_DFL);
|
||||
return (NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ $Id$
|
|||
#include "variable.h"
|
||||
#include "cktdefs.h"
|
||||
|
||||
/* not apply top directory searcpath because config.h should not be used */
|
||||
#ifdef _MSC_VER
|
||||
#include "../misc/misc_time.h" /* timediff */
|
||||
#else
|
||||
|
|
@ -36,7 +37,12 @@ $Id$
|
|||
/* gtri - end - 12/12/90 */
|
||||
#endif
|
||||
|
||||
#ifdef HAS_WINDOWS
|
||||
/* We might compile for Windows, but only as a console application (e.g. tcl) */
|
||||
#if defined (HAS_WINDOWS) || defined(__MINGW32) || defined(_MSC_VER)
|
||||
#define HAVE_WIN32
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
/* At least Windows 2000 is needed
|
||||
* Undefine _WIN32_WINNT 0x0500 if you want to compile under Windows ME
|
||||
|
|
@ -65,7 +71,7 @@ $Id$
|
|||
static void printres(char *name);
|
||||
static void fprintmem(FILE* stream, unsigned long int memory);
|
||||
|
||||
#if defined(HAS_WINDOWS) || defined(HAVE__PROC_MEMINFO)
|
||||
#if defined(HAVE_WIN32) || defined(HAVE__PROC_MEMINFO)
|
||||
static size_t get_procm(struct proc_mem *memall);
|
||||
static size_t get_sysmem(struct sys_mem *memall);
|
||||
|
||||
|
|
@ -83,7 +89,7 @@ char *enddata;
|
|||
void
|
||||
init_rlimits(void)
|
||||
{
|
||||
# if defined(HAS_WINDOWS) || defined(HAVE__PROC_MEMINFO)
|
||||
# if defined(HAVE_WIN32) || defined(HAVE__PROC_MEMINFO)
|
||||
get_procm(&mem_ng);
|
||||
get_sysmem(&mem_t);
|
||||
# else
|
||||
|
|
@ -142,7 +148,7 @@ ft_ckspace(void)
|
|||
{
|
||||
unsigned long int usage, limit;
|
||||
|
||||
#if defined(HAS_WINDOWS) || defined(HAVE__PROC_MEMINFO)
|
||||
#if defined(HAVE_WIN32) || defined(HAVE__PROC_MEMINFO)
|
||||
get_procm(&mem_ng_act);
|
||||
usage = mem_ng_act.size*1024;
|
||||
limit = mem_t.free;
|
||||
|
|
@ -259,7 +265,7 @@ printres(char *name)
|
|||
lastusec -= 1000;
|
||||
lastsec += 1;
|
||||
}
|
||||
#ifndef HAS_WINDOWS
|
||||
#ifndef HAVE_WIN32
|
||||
fprintf(cp_out, "%s time since last call: %lu.%03lu seconds.\n",
|
||||
cpu_elapsed, lastsec, lastusec);
|
||||
#endif
|
||||
|
|
@ -316,7 +322,7 @@ printres(char *name)
|
|||
# endif /* HAVE_GETRLIMIT */
|
||||
#endif /* ipsc */
|
||||
|
||||
#if defined(HAS_WINDOWS) || defined(HAVE__PROC_MEMINFO)
|
||||
#if defined(HAVE_WIN32) || defined(HAVE__PROC_MEMINFO)
|
||||
|
||||
get_procm(&mem_ng_act);
|
||||
get_sysmem(&mem_t_act);
|
||||
|
|
@ -450,7 +456,7 @@ fprintmem(FILE* stream, unsigned long int memory) {
|
|||
fprintf(stream, "%lu bytes", memory);
|
||||
}
|
||||
|
||||
# if defined(HAS_WINDOWS) || defined(HAVE__PROC_MEMINFO)
|
||||
# if defined(HAVE_WIN32) || defined(HAVE__PROC_MEMINFO)
|
||||
|
||||
static size_t get_procm(struct proc_mem *memall) {
|
||||
#ifdef HAS_WINDOWS
|
||||
|
|
@ -508,7 +514,7 @@ static size_t get_procm(struct proc_mem *memall) {
|
|||
}
|
||||
|
||||
static size_t get_sysmem(struct sys_mem *memall) {
|
||||
#ifdef HAS_WINDOWS
|
||||
#ifdef HAVE_WIN32
|
||||
#if ( _WIN32_WINNT >= 0x0500)
|
||||
MEMORYSTATUSEX ms;
|
||||
ms.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
|
|
@ -601,7 +607,7 @@ fault(void)
|
|||
static void *
|
||||
baseaddr(void)
|
||||
{
|
||||
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(HAS_WINDOWS) || defined(__APPLE__)
|
||||
#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(HAVE_WIN32) || defined(__APPLE__)
|
||||
return 0;
|
||||
#else
|
||||
char *low, *high, *at;
|
||||
|
|
|
|||
|
|
@ -1,63 +1,63 @@
|
|||
/*
|
||||
variable.h
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef _VARIABLE_H
|
||||
#define _VARIABLE_H
|
||||
|
||||
/* Variables that are accessible to the parser via $varname
|
||||
* expansions. If the type is VT_LIST the value is a pointer to a
|
||||
* list of the elements. */
|
||||
struct variable {
|
||||
char va_type;
|
||||
char *va_name;
|
||||
union {
|
||||
bool vV_bool;
|
||||
int vV_num;
|
||||
double vV_real;
|
||||
char *vV_string;
|
||||
struct variable *vV_list;
|
||||
} va_V;
|
||||
struct variable *va_next; /* Link. */
|
||||
} ;
|
||||
|
||||
#define va_bool va_V.vV_bool
|
||||
#define va_num va_V.vV_num
|
||||
#define va_real va_V.vV_real
|
||||
#define va_string va_V.vV_string
|
||||
#define va_vlist va_V.vV_list
|
||||
|
||||
enum vt_types {
|
||||
VT_BOOL,
|
||||
VT_NUM,
|
||||
VT_REAL,
|
||||
VT_STRING,
|
||||
VT_LIST
|
||||
};
|
||||
|
||||
struct xxx {
|
||||
struct variable *x_v;
|
||||
char x_char;
|
||||
} ;
|
||||
|
||||
|
||||
extern struct variable *variables;
|
||||
extern bool cp_noglob;
|
||||
extern bool cp_nonomatch;
|
||||
extern bool cp_noclobber;
|
||||
extern bool cp_ignoreeof;
|
||||
extern bool cp_echo;
|
||||
|
||||
/* extern struct variable *variables; */
|
||||
wordlist * cp_varwl(struct variable *var);
|
||||
void cp_vset(char *varname, char type, char *value);
|
||||
struct variable * cp_setparse(wordlist *wl);
|
||||
void cp_remvar(char *varname);
|
||||
bool cp_getvar(char *name, int type, void *retval);
|
||||
wordlist * cp_variablesubst(wordlist *wlist);
|
||||
wordlist * vareval(char *string);
|
||||
void cp_vprint(void);
|
||||
|
||||
|
||||
#endif /* _VARIABLE_H */
|
||||
/*
|
||||
variable.h
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#ifndef _VARIABLE_H
|
||||
#define _VARIABLE_H
|
||||
|
||||
/* Variables that are accessible to the parser via $varname
|
||||
* expansions. If the type is VT_LIST the value is a pointer to a
|
||||
* list of the elements. */
|
||||
struct variable {
|
||||
char va_type;
|
||||
char *va_name;
|
||||
union {
|
||||
bool vV_bool;
|
||||
int vV_num;
|
||||
double vV_real;
|
||||
char *vV_string;
|
||||
struct variable *vV_list;
|
||||
} va_V;
|
||||
struct variable *va_next; /* Link. */
|
||||
} ;
|
||||
|
||||
#define va_bool va_V.vV_bool
|
||||
#define va_num va_V.vV_num
|
||||
#define va_real va_V.vV_real
|
||||
#define va_string va_V.vV_string
|
||||
#define va_vlist va_V.vV_list
|
||||
|
||||
enum vt_types {
|
||||
VT_BOOL,
|
||||
VT_NUM,
|
||||
VT_REAL,
|
||||
VT_STRING,
|
||||
VT_LIST
|
||||
};
|
||||
|
||||
struct xxx {
|
||||
struct variable *x_v;
|
||||
char x_char;
|
||||
} ;
|
||||
|
||||
|
||||
extern struct variable *variables;
|
||||
extern bool cp_noglob;
|
||||
extern bool cp_nonomatch;
|
||||
extern bool cp_noclobber;
|
||||
extern bool cp_ignoreeof;
|
||||
extern bool cp_echo;
|
||||
|
||||
/* extern struct variable *variables; */
|
||||
wordlist * cp_varwl(struct variable *var);
|
||||
void cp_vset(char *varname, char type, char *value);
|
||||
struct variable * cp_setparse(wordlist *wl);
|
||||
void cp_remvar(char *varname);
|
||||
bool cp_getvar(char *name, int type, void *retval);
|
||||
wordlist * cp_variablesubst(wordlist *wlist);
|
||||
wordlist * vareval(char *string);
|
||||
void cp_vprint(void);
|
||||
|
||||
|
||||
#endif /* _VARIABLE_H */
|
||||
|
|
|
|||
|
|
@ -139,6 +139,17 @@ struct timeb timebegin;
|
|||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#define strdup _strdup
|
||||
#define unlink _unlink
|
||||
#define fileno _fileno
|
||||
#define getcwd _getcwd
|
||||
#define isnan _isnan
|
||||
#define finite _finite
|
||||
#define scalb _scalb
|
||||
//#define logb _logb /* not available in spsmp.c */
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_RANDOM
|
||||
#define srandom(a) srand(a)
|
||||
#define random rand
|
||||
|
|
@ -159,10 +170,6 @@ struct timeb timebegin;
|
|||
#define HUGE HUGE_VAL
|
||||
#endif
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#define finite _finite
|
||||
#endif
|
||||
|
||||
extern char *gettok(char **s);
|
||||
extern char *gettok_noparens(char **s);
|
||||
extern char *gettok_node(char **s);
|
||||
|
|
@ -219,7 +226,9 @@ extern int tcl_printf(const char *format, ...);
|
|||
extern int tcl_fprintf(FILE *f, const char *format, ...);
|
||||
|
||||
#undef printf
|
||||
//#undef fprintf
|
||||
#define printf tcl_printf
|
||||
//#define fprintf tcl_fprintf
|
||||
|
||||
#undef perror
|
||||
#define perror(string) fprintf(stderr,"%s: %s\n",string,sys_errlist[errno])
|
||||
|
|
|
|||
|
|
@ -97,16 +97,6 @@ int fp_u_t_char(int __c);
|
|||
#define fgetchar fg_e_t_char
|
||||
#define fputchar fp_u_t_char
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#define strdup _strdup
|
||||
#define unlink _unlink
|
||||
#define fileno _fileno
|
||||
#define getcwd _getcwd
|
||||
#define isnan _isnan
|
||||
|
||||
#define scalb _scalb
|
||||
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
|||
10
src/main.c
10
src/main.c
|
|
@ -996,7 +996,7 @@ bot:
|
|||
current algorithm is uniform at the expense of a little
|
||||
startup time. */
|
||||
FILE *tempfile;
|
||||
#ifdef HAS_WINDOWS
|
||||
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||
char *tpf; /* temporary file */
|
||||
char *dname = NULL; /* directory of input file*/
|
||||
bool has_smk = FALSE;
|
||||
|
|
@ -1004,7 +1004,7 @@ bot:
|
|||
tempfile = tmpfile();
|
||||
/* tmpfile() returns NULL, if in MS Windows as non admin user
|
||||
then we add a tempfile in the local directory */
|
||||
#ifdef HAS_WINDOWS
|
||||
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||
if (tempfile == NULL) {
|
||||
tpf = smktemp("sp");
|
||||
tempfile = fopen(tpf, "w+b");
|
||||
|
|
@ -1031,7 +1031,7 @@ bot:
|
|||
err = 1;
|
||||
break;
|
||||
}
|
||||
#ifdef HAS_WINDOWS
|
||||
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||
/* Copy the input file name which otherwise will be lost due to the
|
||||
temporary file */
|
||||
dname = copy(arg);
|
||||
|
|
@ -1042,7 +1042,7 @@ bot:
|
|||
fseek(tempfile, (long) 0, 0);
|
||||
|
||||
if (tempfile && (!err || !ft_batchmode)) {
|
||||
#ifdef HAS_WINDOWS
|
||||
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||
/* Copy the input file name for adding another file search path */
|
||||
inp_spsource(tempfile, FALSE, dname);
|
||||
tfree(dname);
|
||||
|
|
@ -1051,7 +1051,7 @@ bot:
|
|||
#endif
|
||||
gotone = TRUE;
|
||||
}
|
||||
#ifdef HAS_WINDOWS
|
||||
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||
if (tempfile && has_smk) {
|
||||
if (remove(tpf))
|
||||
perror("Could not delete temp file");
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ basename(const char *name)
|
|||
return base;
|
||||
}
|
||||
|
||||
#ifdef HAS_WINDOWS
|
||||
#if defined(HAS_WINDOWS) || defined(_MSC_VER) || defined(__MINGW32__)
|
||||
/* allow back slashes \\ */
|
||||
char *
|
||||
dirname(const char *name)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
#ifdef XSPICE
|
||||
/*saj headers for xspice*/
|
||||
#include <string.h> /* for strcpy, strcat*/
|
||||
#if (!defined HAS_WINDOWS) && (!defined __MINGW32__)
|
||||
#if (!defined HAS_WINDOWS) && (!defined __MINGW32__) && (!defined _MSC_VER)
|
||||
#include <dlfcn.h> /* to load libraries*/
|
||||
#else /* ifdef HAS_WINDOWS */
|
||||
#undef BOOLEAN
|
||||
|
|
@ -485,7 +485,7 @@ int load_opus(char *name){
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__) || defined(HAS_WINDOWS)
|
||||
#if defined(__MINGW32__) || defined(HAS_WINDOWS) || defined(_MSC_VER)
|
||||
|
||||
void *dlopen(const char *name,int type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@
|
|||
#define TCLSPICE_name "spice"
|
||||
#define TCLSPICE_prefix "spice::"
|
||||
#define TCLSPICE_namespace "spice"
|
||||
#ifdef _MSC_VER
|
||||
#define TCLSPICE_version "17.1"
|
||||
#define STDIN_FILENO 0
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
#endif
|
||||
|
||||
/**********************************************************************/
|
||||
/* Header files for C functions */
|
||||
|
|
@ -22,7 +28,7 @@
|
|||
/*Use Tcl threads if on W32 without pthreads*/
|
||||
#ifndef HAVE_LIBPTHREAD
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
|
||||
#define mutex_lock(a) Tcl_MutexLock(a)
|
||||
#define mutex_unlock(a) Tcl_MutexUnlock(a)
|
||||
|
|
@ -52,7 +58,7 @@ typedef pthread_t threadId_t;
|
|||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif /* HAVE_STRING_H */
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__)
|
||||
#include <stdarg.h>
|
||||
/* remove type incompatibility with winnt.h*/
|
||||
#undef BOOLEAN
|
||||
|
|
@ -61,6 +67,14 @@ typedef pthread_t threadId_t;
|
|||
#ifndef srandom
|
||||
#define srandom(a) srand(a) /* srandom */
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#include <stdarg.h>
|
||||
/* remove type incompatibility with winnt.h*/
|
||||
#undef BOOLEAN
|
||||
#include <windows.h> /* Sleep */
|
||||
#ifndef srandom
|
||||
#define srandom(a) srand(a) /* srandom */
|
||||
#endif
|
||||
#else
|
||||
#include <unistd.h> /* usleep */
|
||||
#endif /* __MINGW32__ */
|
||||
|
|
@ -74,10 +88,14 @@ typedef pthread_t threadId_t;
|
|||
#include <spicelib/analysis/analysis.h>
|
||||
#include <misc/ivars.h>
|
||||
#include <frontend/resource.h>
|
||||
#ifndef _MSC_VER /* avoid second definition of VT_BOOL */
|
||||
#include <frontend/variable.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#include <frontend/outitf.h>
|
||||
#include <memory.h>
|
||||
|
||||
#include <frontend/com_measure2.h>
|
||||
|
||||
#ifndef HAVE_GETRUSAGE
|
||||
|
|
@ -117,6 +135,10 @@ extern JMP_BUF jbuf;
|
|||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define S_IRWXU _S_IWRITE
|
||||
#endif
|
||||
|
||||
//#include <stdarg.h> /* for va_copy() */
|
||||
|
||||
extern IFfrontEnd nutmeginfo;
|
||||
|
|
@ -155,7 +177,7 @@ do {\
|
|||
/****************************************************************************/
|
||||
|
||||
/*helper function*/
|
||||
inline static struct plot * get_plot(int plot){
|
||||
/*inline*/ static struct plot * get_plot(int plot){
|
||||
struct plot *pl;
|
||||
pl = plot_list;
|
||||
for(;0 < plot;plot--){
|
||||
|
|
@ -428,6 +450,7 @@ static int vectoblt TCL_CMDPROCARGS(clientData,interp,argc,argv) {
|
|||
char *realBlt, *imagBlt, *var;
|
||||
struct dvec *var_dvec;
|
||||
double *realData, *compData;
|
||||
int compIndex; //index to loop inside the vectors' data
|
||||
|
||||
if (argc < 3 || argc > 4){
|
||||
Tcl_SetResult(interp, "Wrong # args. spice::vectoblt spice_variable real_bltVector [imag_bltVector]",TCL_STATIC);
|
||||
|
|
@ -458,7 +481,7 @@ static int vectoblt TCL_CMDPROCARGS(clientData,interp,argc,argv) {
|
|||
}
|
||||
}
|
||||
/*If data is complex, it is harder (more complex :) to export...*/
|
||||
int compIndex; //index to loop inside the vectors' data
|
||||
// int compIndex; //index to loop inside the vectors' data
|
||||
if (var_dvec->v_realdata==NULL){
|
||||
if (var_dvec->v_compdata==NULL){
|
||||
Tcl_SetResult(interp, "The vector contains no data",TCL_STATIC);
|
||||
|
|
@ -591,7 +614,7 @@ static int _thread_stop(){
|
|||
while(!fl_exited && timeout < 100){
|
||||
ft_intrpt = TRUE;
|
||||
timeout++;
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
Sleep(10); /* va: windows native */
|
||||
#else
|
||||
usleep(10000);
|
||||
|
|
@ -2089,7 +2112,7 @@ static int tmeasure TCL_CMDPROCARGS(clientData,interp,argc,argv){
|
|||
/* Initialise spice and setup native methods */
|
||||
/*******************************************************/
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
__declspec(dllexport)
|
||||
#endif
|
||||
int Spice_Init(Tcl_Interp *interp) {
|
||||
|
|
@ -2101,7 +2124,7 @@ int Spice_Init(Tcl_Interp *interp) {
|
|||
return TCL_ERROR;
|
||||
#endif
|
||||
|
||||
Tcl_PkgProvide(interp, (char*)TCLSPICE_name, (char*)TCLSPICE_version);
|
||||
Tcl_PkgProvide(interp, (char*) TCLSPICE_name, (char*) TCLSPICE_version);
|
||||
|
||||
Tcl_Eval(interp, "namespace eval " TCLSPICE_namespace " { }");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue