version 1.14, 1999/08/07 21:40:36
|
version 1.23, 2000/09/23 15:47:07
|
Line 1
|
Line 1
|
/* Gforth virtual machine (aka inner interpreter) |
/* Gforth virtual machine (aka inner interpreter) |
|
|
Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. |
Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc. |
|
|
This file is part of Gforth. |
This file is part of Gforth. |
|
|
Line 16
|
Line 16
|
|
|
You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. |
*/ |
*/ |
|
|
#include "config.h" |
#include "config.h" |
Line 38
|
Line 38
|
#include <sys/time.h> |
#include <sys/time.h> |
#include <unistd.h> |
#include <unistd.h> |
#include <pwd.h> |
#include <pwd.h> |
|
#include <dirent.h> |
|
#include <sys/resource.h> |
|
#ifdef HAVE_FNMATCH_H |
|
#include <fnmatch.h> |
|
#else |
|
#include "fnmatch.h" |
|
#endif |
#else |
#else |
#include "systypes.h" |
#include "systypes.h" |
#endif |
#endif |
Line 82 int emitcounter;
|
Line 89 int emitcounter;
|
|
|
#ifdef MEMCMP_AS_SUBROUTINE |
#ifdef MEMCMP_AS_SUBROUTINE |
extern int gforth_memcmp(const char * s1, const char * s2, size_t n); |
extern int gforth_memcmp(const char * s1, const char * s2, size_t n); |
|
#define memcmp(s1,s2,n) gforth_memcmp(s1,s2,n) |
#endif |
#endif |
|
|
#ifdef HAS_FILE |
#ifdef HAS_FILE |
Line 162 char *tilde_cstr(Char *from, UCell size,
|
Line 170 char *tilde_cstr(Char *from, UCell size,
|
} |
} |
#endif |
#endif |
|
|
|
DCell timeval2us(struct timeval *tvp) |
|
{ |
|
#ifndef BUGGY_LONG_LONG |
|
return (tvp->tv_sec*(DCell)1000000)+tvp->tv_usec; |
|
#else |
|
DCell d2; |
|
DCell d1=mmul(tvp->tv_sec,1000000); |
|
d2.lo = d1.lo+tvp->tv_usec; |
|
d2.hi = d1.hi + (d2.lo<d1.lo); |
|
return d2; |
|
#endif |
|
} |
|
|
#define NEWLINE '\n' |
#define NEWLINE '\n' |
|
|
#ifndef HAVE_RINT |
#ifndef HAVE_RINT |
Line 169 char *tilde_cstr(Char *from, UCell size,
|
Line 190 char *tilde_cstr(Char *from, UCell size,
|
#endif |
#endif |
|
|
#ifdef HAS_FILE |
#ifdef HAS_FILE |
static char* fileattr[6]={"r","rb","r+","r+b","w","wb"}; |
static char* fileattr[6]={"rb","rb","r+b","r+b","wb","wb"}; |
|
|
#ifndef O_BINARY |
#ifndef O_BINARY |
#define O_BINARY 0 |
#define O_BINARY 0 |
Line 179 static char* fileattr[6]={"r","rb","r+",
|
Line 200 static char* fileattr[6]={"r","rb","r+",
|
#endif |
#endif |
|
|
static int ufileattr[6]= { |
static int ufileattr[6]= { |
O_RDONLY|O_TEXT, O_RDONLY|O_BINARY, |
O_RDONLY|O_BINARY, O_RDONLY|O_BINARY, |
O_RDWR |O_TEXT, O_RDWR |O_BINARY, |
O_RDWR |O_BINARY, O_RDWR |O_BINARY, |
O_WRONLY|O_TEXT, O_WRONLY|O_BINARY }; |
O_WRONLY|O_BINARY, O_WRONLY|O_BINARY }; |
#endif |
#endif |
|
|
/* if machine.h has not defined explicit registers, define them as implicit */ |
/* if machine.h has not defined explicit registers, define them as implicit */ |
Line 299 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
Line 320 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
if (i>=MAX_SYMBOLS) { |
if (i>=MAX_SYMBOLS) { |
fprintf(stderr,"gforth-ditc: more than %d primitives\n",MAX_SYMBOLS); |
fprintf(stderr,"gforth-ditc: more than %d primitives\n",MAX_SYMBOLS); |
exit(1); |
exit(1); |
|
} |
|
symbols[i] = &routines[i]; |
} |
} |
symbols[i] = &routines[i]; |
|
} |
|
#endif /* defined(DOUBLY_INDIRECT) */ |
#endif /* defined(DOUBLY_INDIRECT) */ |
return symbols; |
return symbols; |
} |
} |
|
|
IF_TOS(TOS = sp[0]); |
IF_TOS(TOS = sp[0]); |
IF_FTOS(FTOS = fp[0]); |
IF_FTOS(FTOS = fp[0]); |