fixes to?\012handle interrupts ^C in Windows.

Improvements to configure scripts for WIN32 configurations.
--with-readline= option for configure


git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@96 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2001-06-22 17:53:36 +00:00
parent c3e7f600d5
commit f22f7434c7
25 changed files with 1070 additions and 769 deletions

View File

@ -1978,9 +1978,11 @@ absmi(int inp)
*/ */
/* make sure we are here because of an awoken goal */ /* make sure we are here because of an awoken goal */
if (CFREG == Unsigned(LCL0) && !(PrologMode & AbortMode)) { if (CFREG == Unsigned(LCL0) && !(PrologMode & AbortMode)) {
Term WGs = ReadTimedVar(WokenGoals); Term WGs;
Term my_goal = AbsAppl(H); Term my_goal;
WGs = ReadTimedVar(WokenGoals);
my_goal = AbsAppl(H);
if (WGs != TermNil) { if (WGs != TermNil) {
#if SHADOW_S #if SHADOW_S
/* save S for ModuleName() */ /* save S for ModuleName() */
@ -2049,6 +2051,13 @@ absmi(int inp)
} }
else { else {
#endif #endif
if (PrologMode & AbortMode) {
PrologMode &= ~AbortMode;
CFREG = CalculateStackGap();
/* same instruction */
if (ProcessSIGINT() < 0) Abort("");
JMPNext();
}
#if SHADOW_S #if SHADOW_S
S = SREG; S = SREG;
#endif #endif
@ -2100,7 +2109,6 @@ absmi(int inp)
H += 2; H += 2;
CFREG = CalculateStackGap(); CFREG = CalculateStackGap();
SREG = (CELL *) (Unsigned(CreepCode) - sizeof(SMALLUNSGN)); SREG = (CELL *) (Unsigned(CreepCode) - sizeof(SMALLUNSGN));
#ifdef COROUTINING #ifdef COROUTINING
} }
#endif #endif

View File

@ -86,6 +86,7 @@ p_inf(E_ARGS)
#define NAN (0.0/0.0) #define NAN (0.0/0.0)
#endif #endif
static E_FUNC static E_FUNC
p_nan(E_ARGS) p_nan(E_ARGS)
{ {

View File

@ -3818,12 +3818,14 @@ p_enqueue(void)
} else } else
father_key = (db_queue *)DBRefOfTerm(Father); father_key = (db_queue *)DBRefOfTerm(Father);
x = StoreTermInDB(Deref(ARG2), 2); x = StoreTermInDB(Deref(ARG2), 2);
x->Parent = NULL;
WRITE_LOCK(father_key->QRWLock); WRITE_LOCK(father_key->QRWLock);
if (father_key->LastInQueue != NIL) if (father_key->LastInQueue != NULL)
father_key->LastInQueue->Parent = (DBProp)x; father_key->LastInQueue->Parent = (DBProp)x;
father_key->LastInQueue = x; father_key->LastInQueue = x;
if (father_key->FirstInQueue == NIL) if (father_key->FirstInQueue == NULL) {
father_key->FirstInQueue = x; father_key->FirstInQueue = x;
}
WRITE_UNLOCK(father_key->QRWLock); WRITE_UNLOCK(father_key->QRWLock);
return(TRUE); return(TRUE);
} }
@ -3873,7 +3875,7 @@ p_dequeue(void)
} else } else
father_key = (db_queue *)DBRefOfTerm(Father); father_key = (db_queue *)DBRefOfTerm(Father);
WRITE_LOCK(father_key->QRWLock); WRITE_LOCK(father_key->QRWLock);
if ((cur_instance = father_key->FirstInQueue) == NIL) { if ((cur_instance = father_key->FirstInQueue) == NULL) {
/* an empty queue automatically goes away */ /* an empty queue automatically goes away */
if (father_key == DBQueues) if (father_key == DBQueues)
DBQueues = father_key->next; DBQueues = father_key->next;

View File

@ -249,22 +249,20 @@ Abort (char *format,...)
#ifdef DEBUGX #ifdef DEBUGX
DumpActiveGoals(); DumpActiveGoals();
#endif /* DEBUG */ #endif /* DEBUG */
if (PrologMode & BootMode) if (PrologMode & BootMode) {
{ exit_yap (1, NIL);
exit_yap (1, NIL); } else {
} PutValue(AtomThrow, MkAtomTerm(AtomFalse));
else CreepFlag = CalculateStackGap();
{
CreepFlag = CalculateStackGap();
#if PUSH_REGS #if PUSH_REGS
restore_absmi_regs(&standard_regs); restore_absmi_regs(&standard_regs);
#endif #endif
#if defined(__GNUC__) && defined(hppa) #if defined(__GNUC__) && defined(hppa)
/* siglongjmp resets the TR hardware register */ /* siglongjmp resets the TR hardware register */
save_TR(); save_TR();
#endif #endif
siglongjmp (RestartEnv, 1); siglongjmp (RestartEnv, 1);
} }
} }

View File

@ -747,6 +747,12 @@ InitCodes(void)
#endif /* YAPOR */ #endif /* YAPOR */
#endif /* TABLING */ #endif /* TABLING */
heap_regs->failcode = opcode(_op_fail); heap_regs->failcode = opcode(_op_fail);
heap_regs->failcode_1 = opcode(_op_fail);
heap_regs->failcode_2 = opcode(_op_fail);
heap_regs->failcode_3 = opcode(_op_fail);
heap_regs->failcode_4 = opcode(_op_fail);
heap_regs->failcode_5 = opcode(_op_fail);
heap_regs->failcode_6 = opcode(_op_fail);
heap_regs->trustfailcode = opcode(_trust_fail); heap_regs->trustfailcode = opcode(_trust_fail);
@ -941,6 +947,8 @@ InitCodes(void)
heap_regs->functor_change_module = MkFunctor (LookupAtom("$change_module"), 1); heap_regs->functor_change_module = MkFunctor (LookupAtom("$change_module"), 1);
heap_regs->functor_current_module = MkFunctor (LookupAtom("$current_module"), 1); heap_regs->functor_current_module = MkFunctor (LookupAtom("$current_module"), 1);
heap_regs->functor_mod_switch = MkFunctor (LookupAtom("$mod_switch"), 2); heap_regs->functor_mod_switch = MkFunctor (LookupAtom("$mod_switch"), 2);
heap_regs->functor_u_minus = MkFunctor (heap_regs->atom_minus, 1);
heap_regs->functor_u_plus = MkFunctor (heap_regs->atom_plus, 1);
heap_regs->functor_v_bar = MkFunctor(LookupAtom("|"), 2); heap_regs->functor_v_bar = MkFunctor(LookupAtom("|"), 2);
heap_regs->functor_var = MkFunctor(AtomVar, 1); heap_regs->functor_var = MkFunctor(AtomVar, 1);
#ifdef EUROTRA #ifdef EUROTRA

View File

@ -51,6 +51,9 @@ static char SccsId[] = "%W% %G%";
#if HAVE_STRING_H #if HAVE_STRING_H
#include <string.h> #include <string.h>
#endif #endif
#if HAVE_SIGNAL_H
#include <signal.h>
#endif
#if HAVE_FCNTL_H #if HAVE_FCNTL_H
/* for O_BINARY and O_TEXT in WIN32 */ /* for O_BINARY and O_TEXT in WIN32 */
#include <fcntl.h> #include <fcntl.h>
@ -77,6 +80,18 @@ static char SccsId[] = "%W% %G%";
/* if we botched in a LongIO operation */ /* if we botched in a LongIO operation */
jmp_buf IOBotch; jmp_buf IOBotch;
int in_getc = FALSE;
int sigint_pending = FALSE;
#if HAVE_LIBREADLINE
jmp_buf readline_jmpbuf;
#if _MSC_VER || defined(__MINGW32__)
FILE *rl_instream, *rl_outstream;
#endif
#endif
typedef struct typedef struct
{ {
union { union {
@ -319,8 +334,8 @@ unix_upd_stream_info (StreamDesc * s)
#endif /* USE_SOCKET */ #endif /* USE_SOCKET */
#if _MSC_VER || defined(__MINGW32__) #if _MSC_VER || defined(__MINGW32__)
{ {
struct stat buf; struct _stat buf;
if (fstat(fileno(s->u.file.file), &buf) == -1) { if (_fstat(YP_fileno(s->u.file.file), &buf) == -1) {
return; return;
} }
if (buf.st_mode & S_IFCHR) { if (buf.st_mode & S_IFCHR) {
@ -768,6 +783,10 @@ static void
InitReadline(void) { InitReadline(void) {
ReadlineBuf = (char *)AllocAtomSpace(READLINE_OUT_BUF_MAX+1); ReadlineBuf = (char *)AllocAtomSpace(READLINE_OUT_BUF_MAX+1);
ReadlinePos = ReadlineBuf; ReadlinePos = ReadlineBuf;
#if _MSC_VER || defined(__MINGW32__)
rl_instream = stdin;
rl_outstream = stdout;
#endif
} }
static int static int
@ -813,6 +832,10 @@ ReadlineGetc(int sno)
register int ch; register int ch;
if (ttyptr == NIL) { if (ttyptr == NIL) {
if (setjmp(readline_jmpbuf) < 0) {
Abort("");
}
in_getc = TRUE;
/* Do it the gnu way */ /* Do it the gnu way */
YP_fflush (YP_stdout); YP_fflush (YP_stdout);
/* Only sends a newline if we are at the start of a line */ /* Only sends a newline if we are at the start of a line */
@ -845,10 +868,8 @@ ReadlineGetc(int sno)
} }
newline=FALSE; newline=FALSE;
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT); strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
in_getc = FALSE;
/* window of vulnerability closed */ /* window of vulnerability closed */
if (PrologMode & AbortMode) {
Abort ((char *) NULL);
}
if (_line == NULL || _line == (char *) EOF) if (_line == NULL || _line == (char *) EOF)
return(console_post_process_read_char(EOF, s, sno)); return(console_post_process_read_char(EOF, s, sno));
if (_line[0] != '\0' && _line[1] != '\0') if (_line[0] != '\0' && _line[1] != '\0')
@ -1156,18 +1177,15 @@ ISOGetc (int sno)
return(ch); return(ch);
} }
#ifdef _WIN32
int in_getc = FALSE;
#endif
/* send a prompt, and use the system for internal buffering. Speed is /* send a prompt, and use the system for internal buffering. Speed is
not of the essence here !!! */ not of the essence here !!! */
static int static int
ConsoleGetc(int sno) ConsoleGetc(int sno)
{ {
register StreamDesc *s = &Stream[sno]; register StreamDesc *s = &Stream[sno];
register int ch; char ch;
restart:
if (newline) { if (newline) {
char *cptr = Prompt, ch; char *cptr = Prompt, ch;
@ -1178,20 +1196,28 @@ ConsoleGetc(int sno)
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT); strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
newline = FALSE; newline = FALSE;
} }
#if defined(__MINGW32__) || _MSC_VER
next_getc:
in_getc = TRUE; in_getc = TRUE;
#if HAVE_SIGINTERRUPT
siginterrupt(SIGINT, TRUE);
#endif #endif
ch = YP_getc (s->u.file.file); ch = YP_fgetc(s->u.file.file);
#if defined(__MINGW32__) || _MSC_VER #if HAVE_SIGINTERRUPT
if (!in_getc) { siginterrupt(SIGINT, FALSE);
ProcessSIGINT();
if (PrologMode & AbortMode) {
Abort((char *)NULL);
} else
goto next_getc;
}
#endif #endif
in_getc = FALSE;
if (PrologMode & AbortMode) {
PrologMode &= ~AbortMode;
CreepFlag = CalculateStackGap();
if (ProcessSIGINT() < 0) Abort("");
newline = TRUE;
goto restart;
} else if (ch == -1 && errno == EINTR) {
errno = 0;
PrologMode &= ~AbortMode;
if (ProcessSIGINT() < 0) Abort("");
newline = TRUE;
goto restart;
}
return(console_post_process_read_char(ch, s, sno)); return(console_post_process_read_char(ch, s, sno));
} }
@ -1393,8 +1419,13 @@ static int
binary_file(char *file_name) binary_file(char *file_name)
{ {
#if HAVE_STAT #if HAVE_STAT
#if _MSC_VER || defined(__MINGW32__)
struct _stat ss;
if (_stat(file_name, &ss) != 0) {
#else
struct stat ss; struct stat ss;
if (stat(file_name, &ss) != 0) { if (stat(file_name, &ss) != 0) {
#endif
/* ignore errors while checking a file */ /* ignore errors while checking a file */
return(FALSE); return(FALSE);
} }

View File

@ -873,6 +873,12 @@ restore_codes(void)
#endif /* YAPOR */ #endif /* YAPOR */
#endif /* TABLING */ #endif /* TABLING */
heap_regs->failcode = opcode(_op_fail); heap_regs->failcode = opcode(_op_fail);
heap_regs->failcode_1 = opcode(_op_fail);
heap_regs->failcode_2 = opcode(_op_fail);
heap_regs->failcode_3 = opcode(_op_fail);
heap_regs->failcode_4 = opcode(_op_fail);
heap_regs->failcode_5 = opcode(_op_fail);
heap_regs->failcode_6 = opcode(_op_fail);
heap_regs->trustfailcode = opcode(_trust_fail); heap_regs->trustfailcode = opcode(_trust_fail);
heap_regs->yescode = opcode(_Ystop); heap_regs->yescode = opcode(_Ystop);
#ifdef YAPOR #ifdef YAPOR
@ -1089,6 +1095,8 @@ restore_codes(void)
heap_regs->functor_change_module = FuncAdjust(heap_regs->functor_change_module); heap_regs->functor_change_module = FuncAdjust(heap_regs->functor_change_module);
heap_regs->functor_current_module = FuncAdjust(heap_regs->functor_current_module); heap_regs->functor_current_module = FuncAdjust(heap_regs->functor_current_module);
heap_regs->functor_mod_switch = FuncAdjust(heap_regs->functor_mod_switch); heap_regs->functor_mod_switch = FuncAdjust(heap_regs->functor_mod_switch);
heap_regs->functor_u_minus = FuncAdjust(heap_regs->functor_u_minus);
heap_regs->functor_u_plus = FuncAdjust(heap_regs->functor_u_plus);
heap_regs->functor_v_bar = FuncAdjust(heap_regs->functor_v_bar); heap_regs->functor_v_bar = FuncAdjust(heap_regs->functor_v_bar);
heap_regs->functor_var = FuncAdjust(heap_regs->functor_var); heap_regs->functor_var = FuncAdjust(heap_regs->functor_var);
#ifdef EUROTRA #ifdef EUROTRA

View File

@ -51,14 +51,6 @@ static char SccsId[] = "@(#)scanner.c 1.2";
C <= (SU)) || (C >= 'a' && C <= (SL))) C <= (SU)) || (C >= 'a' && C <= (SL)))
#define my_isupper(C) ( C >= 'A' && C <= 'Z' ) #define my_isupper(C) ( C >= 'A' && C <= 'Z' )
#ifndef INFINITY
#define INFINITY (1.0/0.0)
#endif
#ifndef NAN
#define NAN (0.0/0.0)
#endif
STATIC_PROTO(void my_ungetch, (void)); STATIC_PROTO(void my_ungetch, (void));
STATIC_PROTO(int my_getch, (void)); STATIC_PROTO(int my_getch, (void));
STATIC_PROTO(Term float_send, (char *)); STATIC_PROTO(Term float_send, (char *));
@ -224,7 +216,7 @@ float_send(char *s)
/* we have an overflow at s */ /* we have an overflow at s */
static Term static Term
read_int_overflow(const char *s, Int base) read_int_overflow(const char *s, Int base, Int val)
{ {
#ifdef USE_GMP #ifdef USE_GMP
/* try to scan it as a bignum */ /* try to scan it as a bignum */
@ -234,7 +226,7 @@ read_int_overflow(const char *s, Int base)
return(MkBigIntTerm(new)); return(MkBigIntTerm(new));
#else #else
/* try to scan it as a float */ /* try to scan it as a float */
return(float_send((char *)s)); return(MkIntegerTerm(val));
#endif #endif
} }
@ -434,7 +426,7 @@ get_num(void)
my_ungetch(); my_ungetch();
*--sp = '\0'; *--sp = '\0';
if (has_overflow) if (has_overflow)
return(read_int_overflow(s,base)); return(read_int_overflow(s,base,val));
return (MkIntegerTerm(val)); return (MkIntegerTerm(val));
} }
do do
@ -465,12 +457,12 @@ get_num(void)
*sp = '\0'; *sp = '\0';
/* skip base */ /* skip base */
if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X'))
return(read_int_overflow(s+2,16)); return(read_int_overflow(s+2,16,val));
if (s[1] == '\'') if (s[1] == '\'')
return(read_int_overflow(s+2,base)); return(read_int_overflow(s+2,base,val));
if (s[2] == '\'') if (s[2] == '\'')
return(read_int_overflow(s+3,base)); return(read_int_overflow(s+3,base,val));
return(read_int_overflow(s,base)); return(read_int_overflow(s,base,val));
} else } else
return (MkIntegerTerm(val)); return (MkIntegerTerm(val));
} }
@ -1172,7 +1164,7 @@ fast_tokenizer(void)
*/ */
#endif #endif
if (has_overflow) if (has_overflow)
t->TokInfo = read_int_overflow(TokImage,base); t->TokInfo = read_int_overflow(TokImage,base,val);
else else
t->TokInfo = MkIntegerTerm(val); t->TokInfo = MkIntegerTerm(val);
t->TokPos = TokenPos; t->TokPos = TokenPos;
@ -1274,13 +1266,13 @@ fast_tokenizer(void)
*sp = '\0'; *sp = '\0';
/* skip base */ /* skip base */
if (TokImage[0] == '0' && (TokImage[1] == 'x' || TokImage[1] == 'X')) if (TokImage[0] == '0' && (TokImage[1] == 'x' || TokImage[1] == 'X'))
TokenInfo = read_int_overflow(TokImage+2,16); TokenInfo = read_int_overflow(TokImage+2,16,val);
else if (TokImage[1] == '\'') else if (TokImage[1] == '\'')
TokenInfo = read_int_overflow(TokImage+2,base); TokenInfo = read_int_overflow(TokImage+2,base,val);
else if (TokImage[2] == '\'') else if (TokImage[2] == '\'')
TokenInfo = read_int_overflow(TokImage+3,base); TokenInfo = read_int_overflow(TokImage+3,base,val);
else else
TokenInfo = read_int_overflow(TokImage,base); TokenInfo = read_int_overflow(TokImage,base,val);
} else } else
TokenInfo = (CELL) MkIntegerTerm(val); TokenInfo = (CELL) MkIntegerTerm(val);
} }

View File

@ -304,14 +304,6 @@ get_char_from_string(int sno)
} }
#ifndef INFINITY
#define INFINITY (1.0/0.0)
#endif
#ifndef NAN
#define NAN (0.0/0.0)
#endif
static Term static Term
get_num(char *t) get_num(char *t)
{ {
@ -1249,7 +1241,7 @@ p_abort(void)
/* make sure we won't go creeping around */ /* make sure we won't go creeping around */
CreepFlag = CalculateStackGap(); CreepFlag = CalculateStackGap();
yap_flags[SPY_CREEP_FLAG] = 0; yap_flags[SPY_CREEP_FLAG] = 0;
Error(PURE_ABORT,TermNil,""); Abort("");
return(FALSE); return(FALSE);
} }
@ -2085,6 +2077,7 @@ p_has_yap_or(void)
#endif #endif
} }
static Int static Int
p_has_tabling(void) p_has_tabling(void)
{ {

View File

@ -652,7 +652,7 @@ void walltime_interval(Int *now,Int *interval)
#include <time.h> #include <time.h>
/* since the point YAP was started */ /* since the point YAP was started */
static struct timeb StartOfWTimes; static struct _timeb StartOfWTimes;
/* since last call to walltime */ /* since last call to walltime */
#define LastWtime (*(struct timeb *)LastWtimePtr) #define LastWtime (*(struct timeb *)LastWtimePtr)
@ -661,7 +661,7 @@ static struct timeb StartOfWTimes;
static void static void
InitWTime (void) InitWTime (void)
{ {
ftime(&StartOfWTimes); _ftime(&StartOfWTimes);
} }
static void static void
@ -675,9 +675,9 @@ InitLastWtime(void) {
Int Int
walltime (void) walltime (void)
{ {
struct timeb tp; struct _timeb tp;
ftime(&tp); _ftime(&tp);
if (StartOfWTimes.millitm > tp.millitm) if (StartOfWTimes.millitm > tp.millitm)
return((tp.time - StartOfWTimes.time - 1) * 1000 + return((tp.time - StartOfWTimes.time - 1) * 1000 +
(StartOfWTimes.millitm - tp.millitm)); (StartOfWTimes.millitm - tp.millitm));
@ -688,9 +688,9 @@ walltime (void)
void walltime_interval(Int *now,Int *interval) void walltime_interval(Int *now,Int *interval)
{ {
struct timeb tp; struct _timeb tp;
ftime(&tp); _ftime(&tp);
*now = (tp.time - StartOfWTimes.time) * 1000 + *now = (tp.time - StartOfWTimes.time) * 1000 +
(tp.millitm - StartOfWTimes.millitm); (tp.millitm - StartOfWTimes.millitm);
*interval = (tp.time - LastWtime.time) * 1000 + *interval = (tp.time - LastWtime.time) * 1000 +
@ -1068,151 +1068,157 @@ void (*handler)(int);
static char *_line = NULL; static char *_line = NULL;
#endif #endif
void static int
InteractSIGINT(char ch) {
switch (ch) {
case 'a':
/* abort computation */
/* we can't do a direct abort, so ask the system to do
it for us */
p_creep();
PutValue(AtomThrow, MkAtomTerm(AtomTrue));
return(-1);
case 'c':
/* continue */
return(1);
case 'e':
/* exit */
exit_yap(0, "");
return(-1);
case 't':
/* start tracing */
PutValue (LookupAtom ("debug"), MkIntTerm (1));
PutValue (LookupAtom ("spy_sl"), MkIntTerm (0));
PutValue (LookupAtom ("spy_creep"), MkIntTerm (1));
p_creep ();
return(1);
#ifdef LOW_LEVEL_TRACER
case 'T':
toggle_low_level_trace();
return(1);
#endif
case 'd':
/* enter debug mode */
PutValue (LookupAtom ("debug"), MkIntTerm (1));
return(1);
case 's':
/* show some statistics */
#if SHORT_INTS==0
YP_fprintf(YP_stderr, "aux. stack: %d ", Unsigned (AuxTop) -
Unsigned (LCL0 + 1));
if (Unsigned (AuxSp) <= Unsigned (LCL0))
YP_fprintf(YP_stderr, "( 0 bytes used)\n");
else
YP_fprintf(YP_stderr, "( %d bytes used)\n",
Unsigned (AuxSp) - Unsigned (LCL0 + 1));
YP_fprintf(YP_stderr, "heap space: %d ", Unsigned (AuxTop) -
Unsigned (HeapBase));
YP_fprintf(YP_stderr, "( %d bytes used for heap",
Unsigned (HeapUsed));
YP_fprintf(YP_stderr, " and %d bytes used for trail)\n",
Unsigned (TR) - Unsigned (TrailBase));
YP_fprintf(YP_stderr, "stack space: %d ", Unsigned (LCL0) -
Unsigned (H0));
YP_fprintf(YP_stderr, "( %d bytes used for local",
Unsigned (LCL0) - Unsigned (ASP));
YP_fprintf(YP_stderr, " and %d bytes used for global)\n",
Unsigned (H) - Unsigned (H0));
#else
YP_fprintf(YP_stderr, "aux. stack: %ld ", Unsigned (AuxTop) -
Unsigned (LCL0 + 1));
if (Unsigned (AuxSp) <= Unsigned (LCL0))
YP_fprintf(YP_stderr, "( 0 bytes used)\n");
else
YP_fprintf(YP_stderr, "( %ld bytes used)\n",
Unsigned (AuxSp) - Unsigned (LCL0 + 1));
YP_fprintf(YP_stderr, "heap space: %ld ", Unsigned (AuxTop) -
Unsigned (HeapBase));
YP_fprintf(YP_stderr, "( %ld bytes used for heap",
Unsigned (HeapUsed));
YP_fprintf(YP_stderr, " and %ld bytes used for trail)\n",
Unsigned (TR) - Unsigned (TrailBase));
YP_fprintf(YP_stderr, "stack space: %ld ", Unsigned (LCL0) -
Unsigned (H0));
YP_fprintf(YP_stderr, "( %ld bytes used for local",
Unsigned (LCL0) - Unsigned (ASP));
YP_fprintf(YP_stderr, " and %ld bytes used for global)\n",
Unsigned (H) - Unsigned (H0));
#endif
#if SHORT_INTS
YP_fprintf(YP_stderr, "Runtime: %lds.\n", runtime ());
YP_fprintf(YP_stderr, "Cputime: %lds.\n", cputime ());
YP_fprintf(YP_stderr, "Walltime: %lds.\n", walltime ());
#else
YP_fprintf(YP_stderr, "Runtime: %ds.\n", runtime ());
YP_fprintf(YP_stderr, "Cputime: %ds.\n", cputime ());
YP_fprintf(YP_stderr, "Walltime: %ds.\n", walltime ());
#endif
return(1);
case EOF:
return(0);
break;
case 'h':
case '?':
default:
/* show an helpful message */
YP_fprintf(YP_stderr, "Please press one of:\n");
YP_fprintf(YP_stderr, " a for abort\n c for continue\n d for debug\n");
YP_fprintf(YP_stderr, " e for exit\n t for trace\n s for statistics\n");
return(0);
}
}
/*
This function talks to the user about a signal. We assume we are in
the context of the main Prolog thread (trivial in Unix, but hard in WIN32)
*/
int
ProcessSIGINT(void) ProcessSIGINT(void)
{ {
int ch, out;
while (TRUE) { #if HAVE_ISATTY
int ch; if (!isatty(0)) {
#ifdef MPW InteractSIGINT('e');
int ch0; }
#if !HAVE_LIBREADLINE
if (in_getc) {
return(0);
}
#endif #endif
#endif
do {
#if HAVE_LIBREADLINE #if HAVE_LIBREADLINE
if (_line != (char *) NULL && _line != (char *) EOF) if (_line != (char *) NULL && _line != (char *) EOF)
free (_line); free (_line);
_line = readline ("Action (h for help): "); _line = readline ("Action (h for help): ");
if (_line == (char *)NULL || _line == (char *)EOF) if (_line == (char *)NULL || _line == (char *)EOF) {
ch = EOF;
continue; continue;
}
ch = _line[0]; ch = _line[0];
#else #else
YP_fprintf(YP_stderr, "\nAction (h for help): "); /* ask for a new line */
ch = YP_getchar ( ); fprintf(stderr, "Action (h for help): ");
while ((YP_getchar()) != '\n'); ch = getc(stdin);
/* first process up to end of line */
while ((fgetc(stdin)) != '\n');
#endif #endif
switch (ch) } while (!(out = InteractSIGINT(ch)));
{ if (out < 0)
case 'a': sigint_pending = out;
/* abort computation, but take care in case we are within readline #if HAVE_LIBREADLINE
code */ if (in_getc) {
if (!(PrologMode & CritMode)) longjmp(readline_jmpbuf, (out < 0 ? -1 : 1));
{
#if HAVE_SIGPROCMASK
sigset_t sig_set;
sigemptyset(&sig_set);
sigaddset(&sig_set, SIGINT);
sigprocmask(SIG_UNBLOCK, &sig_set, NULL);
#elif HAVE_SIGGETMASK
sigsetmask (siggetmask () ^ (1 << (SIGINT - 1)));
#endif
#ifdef VAX
VaxFixFrame (CritMode);
#endif
/* we cannot abort until we finish readline :-( */
if (!(PrologMode & CritMode)) {
#if defined(__MINGW32__) || _MSC_VER
/* we can't do a direct abort, so ask the system to do it for us */
p_creep();
PutValue(AtomThrow, MkAtomTerm(AtomTrue));
#else
Abort ((char *) NULL);
#endif
#if HAVE_LIBREADLINE
}
#endif
}
PrologMode |= AbortMode;
return;
case 'c':
/* continue */
return;
case 'e':
/* exit */
exit_yap(0, "");
case 't':
/* start tracing */
PutValue (LookupAtom ("debug"), MkIntTerm (1));
PutValue (LookupAtom ("spy_sl"), MkIntTerm (0));
PutValue (LookupAtom ("spy_creep"), MkIntTerm (1));
p_creep ();
return;
#ifdef LOW_LEVEL_TRACER
case 'T':
toggle_low_level_trace();
return;
#endif
case 'd':
/* enter debug mode */
PutValue (LookupAtom ("debug"), MkIntTerm (1));
return;
case 's':
/* show some statistics */
#if SHORT_INTS==0
YP_fprintf(YP_stderr, "aux. stack: %d ", Unsigned (AuxTop) -
Unsigned (LCL0 + 1));
if (Unsigned (AuxSp) <= Unsigned (LCL0))
YP_fprintf(YP_stderr, "( 0 bytes used)\n");
else
YP_fprintf(YP_stderr, "( %d bytes used)\n",
Unsigned (AuxSp) - Unsigned (LCL0 + 1));
YP_fprintf(YP_stderr, "heap space: %d ", Unsigned (AuxTop) -
Unsigned (HeapBase));
YP_fprintf(YP_stderr, "( %d bytes used for heap",
Unsigned (HeapUsed));
YP_fprintf(YP_stderr, " and %d bytes used for trail)\n",
Unsigned (TR) - Unsigned (TrailBase));
YP_fprintf(YP_stderr, "stack space: %d ", Unsigned (LCL0) -
Unsigned (H0));
YP_fprintf(YP_stderr, "( %d bytes used for local",
Unsigned (LCL0) - Unsigned (ASP));
YP_fprintf(YP_stderr, " and %d bytes used for global)\n",
Unsigned (H) - Unsigned (H0));
#else
YP_fprintf(YP_stderr, "aux. stack: %ld ", Unsigned (AuxTop) -
Unsigned (LCL0 + 1));
if (Unsigned (AuxSp) <= Unsigned (LCL0))
YP_fprintf(YP_stderr, "( 0 bytes used)\n");
else
YP_fprintf(YP_stderr, "( %ld bytes used)\n",
Unsigned (AuxSp) - Unsigned (LCL0 + 1));
YP_fprintf(YP_stderr, "heap space: %ld ", Unsigned (AuxTop) -
Unsigned (HeapBase));
YP_fprintf(YP_stderr, "( %ld bytes used for heap",
Unsigned (HeapUsed));
YP_fprintf(YP_stderr, " and %ld bytes used for trail)\n",
Unsigned (TR) - Unsigned (TrailBase));
YP_fprintf(YP_stderr, "stack space: %ld ", Unsigned (LCL0) -
Unsigned (H0));
YP_fprintf(YP_stderr, "( %ld bytes used for local",
Unsigned (LCL0) - Unsigned (ASP));
YP_fprintf(YP_stderr, " and %ld bytes used for global)\n",
Unsigned (H) - Unsigned (H0));
#endif
#if SHORT_INTS
YP_fprintf(YP_stderr, "Runtime: %lds.\n", runtime ());
YP_fprintf(YP_stderr, "Cputime: %lds.\n", cputime ());
YP_fprintf(YP_stderr, "Walltime: %lds.\n", walltime ());
#else
YP_fprintf(YP_stderr, "Runtime: %ds.\n", runtime ());
YP_fprintf(YP_stderr, "Cputime: %ds.\n", cputime ());
YP_fprintf(YP_stderr, "Walltime: %ds.\n", walltime ());
#endif
break;
case EOF:
/* ignore end of file */
break;
case 'h':
case '?':
default:
/* show an helpful message */
YP_fprintf(YP_stderr, "Please press one of:\n");
YP_fprintf(YP_stderr, " a for abort\n c for continue\n d for debug\n");
YP_fprintf(YP_stderr, " e for exit\n t for trace\n s for statistics\n");
break;
}
} }
#endif
return(out);
} }
/* This function is called from the signal handler to process signals.
We assume we are within the context of the signal handler, whatever
that might be
*/
static RETSIGTYPE static RETSIGTYPE
#if defined(__svr4__) #if defined(__svr4__)
HandleSIGINT (int sig, siginfo_t *x, ucontext_t *y) HandleSIGINT (int sig, siginfo_t *x, ucontext_t *y)
@ -1220,21 +1226,14 @@ HandleSIGINT (int sig, siginfo_t *x, ucontext_t *y)
HandleSIGINT (int sig) HandleSIGINT (int sig)
#endif #endif
{ {
#if defined(__MINGW32__) || _MSC_VER my_signal(SIGINT, HandleSIGINT);
extern int in_getc; #if (_MSC_VER || defined(__MINGW32__))
printf("hello\n");
if (in_getc) { return;
/* YP_ungetc(YP_stdin,'\n'); #endif
PrologMode |= InterruptMode; */
in_getc = FALSE;
return;
}
#else
#ifdef HAVE_SETBUF #ifdef HAVE_SETBUF
/* make sure we are not waiting for the end of line */ /* make sure we are not waiting for the end of line */
YP_setbuf (stdin, NULL); YP_setbuf (stdin, NULL);
#endif
my_signal(SIGINT, HandleSIGINT);
#endif #endif
if (snoozing) if (snoozing)
{ {
@ -1266,6 +1265,7 @@ HandleALRM(int s)
* 6 possibilities : abort, continue, trace, debug, help, exit * 6 possibilities : abort, continue, trace, debug, help, exit
*/ */
#if !defined(LIGHT) && !_MSC_VER && !defined(__MINGW32__) && !defined(LIGHT)
static RETSIGTYPE static RETSIGTYPE
#if defined(__svr4__) #if defined(__svr4__)
ReceiveSignal (int s, siginfo_t *x, ucontext_t *y) ReceiveSignal (int s, siginfo_t *x, ucontext_t *y)
@ -1292,20 +1292,21 @@ ReceiveSignal (int s)
exit (FALSE); exit (FALSE);
} }
} }
#endif
#if _MSC_VER || defined(__MINGW32__) #if (_MSC_VER || defined(__MINGW32__))
static BOOL WINAPI MSCHandleSignal(DWORD dwCtrlType) { static BOOL WINAPI
MSCHandleSignal(DWORD dwCtrlType) {
switch(dwCtrlType) { switch(dwCtrlType) {
case CTRL_C_EVENT: case CTRL_C_EVENT:
HandleSIGINT(SIGINT);
break;
case CTRL_BREAK_EVENT: case CTRL_BREAK_EVENT:
HandleSIGINT(SIGINT); p_creep();
break; PutValue(AtomThrow, MkAtomTerm(AtomTrue));
PrologMode |= AbortMode;
return(TRUE);
default: default:
exit_yap(1, "[ SYSTEM ERROR: Received Termination Event ]\n"); return(FALSE);
} }
return(TRUE);
} }
#endif #endif
@ -1313,32 +1314,28 @@ static BOOL WINAPI MSCHandleSignal(DWORD dwCtrlType) {
static void static void
InitSignals (void) InitSignals (void)
{ {
#if !defined(LIGHT) && !_MSC_VER && !defined(__MINGW32__) && !defined(LIGHT)
my_signal (SIGQUIT, ReceiveSignal);
my_signal (SIGKILL, ReceiveSignal);
my_signal(SIGALRM, HandleALRM);
#endif
#if _MSC_VER || defined(__MINGW32__) #if _MSC_VER || defined(__MINGW32__)
signal (SIGINT, SIG_IGN);
SetConsoleCtrlHandler(MSCHandleSignal,TRUE); SetConsoleCtrlHandler(MSCHandleSignal,TRUE);
#else #else
my_signal (SIGINT, HandleSIGINT); my_signal (SIGINT, HandleSIGINT);
#endif
#ifndef MPW #ifndef MPW
my_signal (SIGFPE, HandleMatherr); my_signal (SIGFPE, HandleMatherr);
#if !defined(LIGHT) && !defined(_WIN32)
my_signal (SIGQUIT, ReceiveSignal);
#endif
#endif
#if !defined(LIGHT) && !defined(_WIN32)
my_signal (SIGKILL, ReceiveSignal);
#endif #endif
#if HAVE_SIGSEGV #if HAVE_SIGSEGV
my_signal_info (SIGSEGV, HandleSIGSEGV); my_signal_info (SIGSEGV, HandleSIGSEGV);
#endif #endif
#if !defined(LIGHT) && !defined(_WIN32)
my_signal(SIGALRM, HandleALRM);
#endif
#endif
#ifdef ACOW #ifdef ACOW
signal(SIGCHLD, SIG_IGN); /* avoid ghosts */ signal(SIGCHLD, SIG_IGN); /* avoid ghosts */
#endif #endif
} }
#endif /* HAVE_SIGNAL */ #endif /* HAVE_SIGNAL */

View File

@ -210,7 +210,6 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
send_tracer_message("RETRY: ", s, arity, mname, args); send_tracer_message("RETRY: ", s, arity, mname, args);
break; break;
} }
} }
void void

View File

@ -78,7 +78,7 @@
#include <sys/param.h> #include <sys/param.h>
#endif #endif
#endif /* HAVE_WINSOCK_H */ #endif /* HAVE_WINSOCK_H */
#if _MSC_VER #if _MSC_VER || defined(__MINGW32__)
#include <io.h> #include <io.h>
#include <winsock2.h> #include <winsock2.h>
#endif #endif
@ -177,7 +177,7 @@
#define MAXHOSTNAMELEN 256 #define MAXHOSTNAMELEN 256
#endif #endif
#if _MSC_VER #if _MSC_VER || defined(__MINGW32__)
#define socket_errno WSAGetLastError() #define socket_errno WSAGetLastError()
#define invalid_socket_fd(fd) (fd) == INVALID_SOCKET #define invalid_socket_fd(fd) (fd) == INVALID_SOCKET
#else #else
@ -468,7 +468,7 @@ CloseSocket(int fd, socket_info status, socket_domain domain)
return(FALSE); return(FALSE);
} }
} }
#if _MSC_VER #if _MSC_VER || defined(__MINGW32__)
if (closesocket(fd) != 0) { if (closesocket(fd) != 0) {
#else #else
if (close(fd) < 0) { if (close(fd) < 0) {
@ -905,7 +905,7 @@ p_socket_select(void)
fd_set readfds, writefds, exceptfds; fd_set readfds, writefds, exceptfds;
struct timeval timeout, *ptime; struct timeval timeout, *ptime;
#if _MSC_VER #if _MSC_VER || defined(__MINGW32__)
u_int fdmax=0; u_int fdmax=0;
#else #else
int fdmax=0; int fdmax=0;
@ -943,7 +943,7 @@ p_socket_select(void)
/* fetch the input streams */ /* fetch the input streams */
ti = t1; ti = t1;
while (ti != TermNil) { while (ti != TermNil) {
#if _MSC_VER #if _MSC_VER || defined(__MINGW32__)
u_int fd; u_int fd;
#else #else
int fd; int fd;
@ -1038,8 +1038,8 @@ p_current_hostname(void) {
int faq = (strrchr(sin,'.') != NULL); int faq = (strrchr(sin,'.') != NULL);
if (faq) if (faq)
#if _MSC_VER #if _MSC_VER || defined(__MINGW32__)
return(stricmp(name,sin) == 0); return(_stricmp(name,sin) == 0);
#else #else
return(strcasecmp(name,sin) == 0); return(strcasecmp(name,sin) == 0);
#endif #endif
@ -1052,8 +1052,8 @@ p_current_hostname(void) {
} }
if (name[isize] != '.') return(FALSE); if (name[isize] != '.') return(FALSE);
name[isize] = '\0'; name[isize] = '\0';
#if _MSC_VER #if _MSC_VER || defined(__MINGW32__)
return(stricmp(name,sin) == 0); return(_stricmp(name,sin) == 0);
#else #else
return(strcasecmp(name,sin) == 0); return(strcasecmp(name,sin) == 0);
#endif #endif
@ -1129,7 +1129,7 @@ InitSockets(void)
InitCPred("$socket_select", 4, p_socket_select, SafePredFlag|SyncPredFlag); InitCPred("$socket_select", 4, p_socket_select, SafePredFlag|SyncPredFlag);
InitCPred("current_hostname", 1, p_current_hostname, SafePredFlag); InitCPred("current_hostname", 1, p_current_hostname, SafePredFlag);
InitCPred("hostname_address", 2, p_hostname_address, SafePredFlag); InitCPred("hostname_address", 2, p_hostname_address, SafePredFlag);
#if _MSC_VER #if _MSC_VER || defined(__MINGW32__)
{ {
WSADATA info; WSADATA info;
if (WSAStartup(MAKEWORD(2,1), &info) != 0) if (WSAStartup(MAKEWORD(2,1), &info) != 0)

View File

@ -10,7 +10,7 @@
* File: Heap.h * * File: Heap.h *
* mods: * * mods: *
* comments: Heap Init Structure * * comments: Heap Init Structure *
* version: $Id: Heap.h,v 1.6 2001-06-11 17:40:16 vsc Exp $ * * version: $Id: Heap.h,v 1.7 2001-06-22 17:53:36 vsc Exp $ *
*************************************************************************/ *************************************************************************/
/* information that can be stored in Code Space */ /* information that can be stored in Code Space */
@ -47,6 +47,12 @@ typedef struct various_codes {
yamop tableanswerresolutioncode; yamop tableanswerresolutioncode;
#endif /* TABLING */ #endif /* TABLING */
OPCODE failcode; OPCODE failcode;
OPCODE failcode_1;
OPCODE failcode_2;
OPCODE failcode_3;
OPCODE failcode_4;
OPCODE failcode_5;
OPCODE failcode_6;
OPCODE trustfailcode; OPCODE trustfailcode;
struct { struct {
OPCODE op; OPCODE op;
@ -244,6 +250,8 @@ typedef struct various_codes {
functor_change_module, functor_change_module,
functor_current_module, functor_current_module,
functor_mod_switch, functor_mod_switch,
functor_u_minus,
functor_u_plus,
functor_v_bar, functor_v_bar,
functor_var; functor_var;
Term Term
@ -426,6 +434,8 @@ typedef struct various_codes {
#define FunctorChangeModule heap_regs->functor_change_module #define FunctorChangeModule heap_regs->functor_change_module
#define FunctorCurrentModule heap_regs->functor_current_module #define FunctorCurrentModule heap_regs->functor_current_module
#define FunctorModSwitch heap_regs->functor_mod_switch #define FunctorModSwitch heap_regs->functor_mod_switch
#define FunctorUMinus heap_regs->functor_u_minus
#define FunctorUPlus heap_regs->functor_u_plus
#define FunctorVBar heap_regs->functor_v_bar #define FunctorVBar heap_regs->functor_v_bar
#define FunctorVar heap_regs->functor_var #define FunctorVar heap_regs->functor_var
#define TermDollarU heap_regs->term_dollar_u #define TermDollarU heap_regs->term_dollar_u

View File

@ -10,7 +10,7 @@
* File: Yap.proto * * File: Yap.proto *
* mods: * * mods: *
* comments: Function declarations for YAP * * comments: Function declarations for YAP *
* version: $Id: Yapproto.h,v 1.1.1.1 2001-04-09 19:53:39 vsc Exp $ * * version: $Id: Yapproto.h,v 1.2 2001-06-22 17:53:36 vsc Exp $ *
*************************************************************************/ *************************************************************************/
/* prototype file for Yap */ /* prototype file for Yap */
@ -244,7 +244,7 @@ void STD_PROTO(walltime_interval,(Int *,Int *));
void STD_PROTO(InitSysbits,(void)); void STD_PROTO(InitSysbits,(void));
void STD_PROTO(InitSysPreds,(void)); void STD_PROTO(InitSysPreds,(void));
int STD_PROTO(TrueFileName, (char *, char *, int)); int STD_PROTO(TrueFileName, (char *, char *, int));
void STD_PROTO(ProcessSIGINT,(void)); int STD_PROTO(ProcessSIGINT,(void));
double STD_PROTO(yap_random, (void)); double STD_PROTO(yap_random, (void));
/* tracer.c */ /* tracer.c */

View File

@ -33,7 +33,11 @@
#define YP_clearerr clearerr #define YP_clearerr clearerr
#define YP_feof feof #define YP_feof feof
#define YP_ferror ferror #define YP_ferror ferror
#if _MSC_VER || defined(__MINGW32__)
#define YP_fileno _fileno
#else
#define YP_fileno fileno #define YP_fileno fileno
#endif
#define YP_fopen fopen #define YP_fopen fopen
#define YP_fclose fclose #define YP_fclose fclose
#define YP_ftell ftell #define YP_ftell ftell
@ -44,6 +48,19 @@
#define YP_fdopen fdopen #define YP_fdopen fdopen
#define init_yp_stdio() #define init_yp_stdio()
#if _MSC_VER || defined(__MINGW32__)
#define open _open
#define close _close
#define popen _popen
#define pclose _pclose
#define read _read
#define write _write
#define isatty _isatty
#define putenv(S) _putenv(S)
#define chdir(P) _chdir(P)
#define getcwd(B,S) _getcwd(B,S)
#endif
#define YP_FILE FILE #define YP_FILE FILE
extern int YP_stdin; extern int YP_stdin;
extern int YP_stdout; extern int YP_stdout;
@ -298,3 +315,10 @@ extern int Portray_delays;
#define HashFunction(CHP,OUT) { (OUT)=0; while(*(CHP) != '\0') (OUT) += *(CHP)++; (OUT) %= MaxHash; } #define HashFunction(CHP,OUT) { (OUT)=0; while(*(CHP) != '\0') (OUT) += *(CHP)++; (OUT) %= MaxHash; }
extern jmp_buf IOBotch; extern jmp_buf IOBotch;
#if HAVE_LIBREADLINE
extern jmp_buf readline_jmpbuf;
#endif
extern int in_getc, sigint_pending;

View File

@ -1,4 +1,6 @@
This directory includes programs that are distributed under the GNU This directory includes programs that are distributed under the GNU
LGPL. Please check pillow/Copyright for further information. LGPL. Please check pillow/Copyright for further information on
pillow's copyright and SWI-Prolog's win32console library directory for
more detailed info.

View File

@ -47,8 +47,9 @@ YAP_EXTRAS=@YAP_EXTRAS@
# for c_interface.c # for c_interface.c
# #
CC=@CC@ CC=@CC@
CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I. -I$(srcdir)/H -I$(srcdir)/OPTYap CPPFLAGS=@CPPFLAGS@ -I. -I$(srcdir)/H -I$(srcdir)/OPTYap
C_INTERF_FLAGS= @C_INTERF_FLAGS@ $(YAP_EXTRAS) $(DEFS) -I. -I$(srcdir)/H -I$(srcdir)/OPTYap -I$(srcdir)/include CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS)
C_INTERF_FLAGS= @C_INTERF_FLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS) -I$(srcdir)/include
# #
# #
# You shouldn't need to change what follows. # You shouldn't need to change what follows.
@ -57,7 +58,6 @@ CPP=@CPP@
DEFS=@DEFS@ DEFS=@DEFS@
LIBS=@LIBS@ LIBS=@LIBS@
LDFLAGS=@LDFLAGS@ LDFLAGS=@LDFLAGS@
CPPFLAGS=@CPPFLAGS@
LN_S=@LN_S@ LN_S=@LN_S@
M4=@M4@ M4=@M4@
GCC=@GCC@ GCC=@GCC@
@ -438,7 +438,7 @@ libYap.a: $(LIB_OBJECTS)
install: @INSTALL_COMMAND@ install: @INSTALL_COMMAND@
install_unix: install_unix: startup
-mkdir -p $(DESTDIR)$(BINDIR) -mkdir -p $(DESTDIR)$(BINDIR)
$(INSTALL_PROGRAM) -m 755 yap $(DESTDIR)$(BINDIR)/yap $(INSTALL_PROGRAM) -m 755 yap $(DESTDIR)$(BINDIR)/yap
-mkdir -p $(DESTDIR)$(YAPLIBDIR) -mkdir -p $(DESTDIR)$(YAPLIBDIR)
@ -455,13 +455,13 @@ install_unix:
-mkdir -p $(DESTDIR)$(INCLUDEDIR) -mkdir -p $(DESTDIR)$(INCLUDEDIR)
for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done
install_mingw32: install_mingw32: startup
-mkdir $(DESTDIR)$(ROOTDIR) -mkdir -p $(DESTDIR)$(ROOTDIR)
-mkdir $(DESTDIR)$(BINDIR) -mkdir -p $(DESTDIR)$(BINDIR)
-mkdir $(DESTDIR)$(ROOTDIR)/lib -mkdir -p $(DESTDIR)$(ROOTDIR)/lib
-mkdir $(DESTDIR)$(YAPLIBDIR) -mkdir -p $(DESTDIR)$(YAPLIBDIR)
-mkdir $(DESTDIR)$(ROOTDIR)/include -mkdir -p $(DESTDIR)$(ROOTDIR)/include
-mkdir $(DESTDIR)$(INCLUDEDIR) -mkdir -p $(DESTDIR)$(INCLUDEDIR)
$(INSTALL_PROGRAM) -m 755 yap.exe $(DESTDIR)$(BINDIR)/yap.exe $(INSTALL_PROGRAM) -m 755 yap.exe $(DESTDIR)$(BINDIR)/yap.exe
$(INSTALL_PROGRAM) -m 755 yap.dll $(DESTDIR)$(BINDIR)/yap.dll $(INSTALL_PROGRAM) -m 755 yap.dll $(DESTDIR)$(BINDIR)/yap.dll
$(INSTALL_PROGRAM) -m 755 startup $(DESTDIR)$(YAPLIBDIR)/startup $(INSTALL_PROGRAM) -m 755 startup $(DESTDIR)$(YAPLIBDIR)/startup
@ -479,7 +479,7 @@ install_mingw32:
install_library: libYap.a install_library: libYap.a
$(INSTALL_DATA) -m 644 libYap.a $(DESTDIR)$(LIBDIR)/libYap.a $(INSTALL_DATA) -m 644 libYap.a $(DESTDIR)$(LIBDIR)/libYap.a
-mkdir $(DESTDIR)$(INCLUDEDIR) -mkdir -p $(DESTDIR)$(INCLUDEDIR)
$(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR) $(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)
########## ##########
@ -488,7 +488,7 @@ TAGS: $(C_SOURCES) $(PL_SOURCES) $(HEADERS)
depend: $(HEADERS) $(C_SOURCES) depend: $(HEADERS) $(C_SOURCES)
-@if test "$(GCC)" = yes; then\ -@if test "$(GCC)" = yes; then\
gcc -MM $(CFLAGS) -I$(srcdir)/include $(C_SOURCES) > .depend;\ $(CC) -MM $(CFLAGS) -I$(srcdir)/include $(C_SOURCES) > .depend;\
else\ else\
makedepend -f - -- $(CFLAGS) -I$(srcdir)/include -- $(C_SOURCES) |\ makedepend -f - -- $(CFLAGS) -I$(srcdir)/include -- $(C_SOURCES) |\
sed 's|.*/\([^:]*\):|\1:|' > .depend ;\ sed 's|.*/\([^:]*\):|\1:|' > .depend ;\
@ -518,7 +518,7 @@ dist:
# #
DLLTOOL=dlltool DLLTOOL=dlltool
DLLNAME=yap.dll DLLNAME=yap.dll
DLL_LIBS=-L /usr/lib/mingw -lmoldname -lcrtdll -lkernel32 $(LIBS) DLL_LIBS=-L /usr/lib/mingw -lmoldname -lkernel32 $(LIBS)
BASE_FILE=yap.base BASE_FILE=yap.base
EXP_FILE=yap.exp EXP_FILE=yap.exp
DEF_FILE=$(srcdir)/misc/yap.def DEF_FILE=$(srcdir)/misc/yap.def

2
TO_DO
View File

@ -13,7 +13,6 @@ BEFORE 4.4:
- document system(library) - document system(library)
- document new interface functions. - document new interface functions.
- ^C can break code. - ^C can break code.
- check library(random)
- add more precision when outputting floats. - add more precision when outputting floats.
- make statistics/0 better looking. - make statistics/0 better looking.
- mask when installing. - mask when installing.
@ -78,3 +77,4 @@ DONE:
- remove pl/nfr.yap and misc/yap.spec from CVS. - remove pl/nfr.yap and misc/yap.spec from CVS.
- deterministic trail entries for multi-assignment variables. - deterministic trail entries for multi-assignment variables.
- weird going ons with prompt and readline - weird going ons with prompt and readline
- check library(random)

View File

@ -16,6 +16,13 @@
<h2>Yap-4.3.19:</h2> <h2>Yap-4.3.19:</h2>
<ul> <ul>
<li>FIXED: ^c works with Yap/MINGW32 (not in cygwin).</li>
<li>FIXED: ^c a should never core dump.</li>
<li>FIXED: comparison of variables in sub-terms.</li>
<li>FIXED: parse +inf, -inf, +nan, -nan as floats and write
them accordingly.</li>
<li>FIXED: comparison was breaking ISO.</li>
<li>FIXED: use $(CC) never gcc directly.</li>
<li>FIXED: support newer versions of readline by moving text <li>FIXED: support newer versions of readline by moving text
to prompt.</li> to prompt.</li>
<li>FIXED: upgrade to autoconf 2.5.</li> <li>FIXED: upgrade to autoconf 2.5.</li>

View File

@ -38,6 +38,7 @@
#undef HAVE_MEMORY_H #undef HAVE_MEMORY_H
#undef HAVE_NETDB_H #undef HAVE_NETDB_H
#undef HAVE_NETINET_IN_H #undef HAVE_NETINET_IN_H
#undef HAVE_READLINE_READLINE_H
#undef HAVE_REGEX_H #undef HAVE_REGEX_H
#undef HAVE_SIGINFO_H #undef HAVE_SIGINFO_H
#undef HAVE_SIGNAL_H #undef HAVE_SIGNAL_H
@ -96,22 +97,22 @@
/* Define return type for signal */ /* Define return type for signal */
#undef RETSIGTYPE #undef RETSIGTYPE
#undef HAVE_ACOSH
#undef HAVE_ALARM #undef HAVE_ALARM
#undef HAVE_ASINH #undef HAVE_ASINH
#undef HAVE_ACOSH
#undef HAVE_ATANH #undef HAVE_ATANH
#undef HAVE_CHDIR #undef HAVE_CHDIR
#undef HAVE_DUP2 #undef HAVE_DUP2
#undef HAVE_FETESTEXCEPT #undef HAVE_FETESTEXCEPT
#undef HAVE_FINITE #undef HAVE_FINITE
#undef HAVE_GETCWD
#undef HAVE_GETENV
#undef HAVE_GETHOSTBYNAME #undef HAVE_GETHOSTBYNAME
#undef HAVE_GETHOSTID #undef HAVE_GETHOSTID
#undef HAVE_GETHOSTNAME #undef HAVE_GETHOSTNAME
#undef HAVE_GETRUSAGE
#undef HAVE_GETCWD
#undef HAVE_GETENV
#undef HAVE_GETHRTIME #undef HAVE_GETHRTIME
#undef HAVE_GETPWNAM #undef HAVE_GETPWNAM
#undef HAVE_GETRUSAGE
#undef HAVE_GETTIMEOFDAY #undef HAVE_GETTIMEOFDAY
#undef HAVE_GETWD #undef HAVE_GETWD
#undef HAVE_ISATTY #undef HAVE_ISATTY
@ -121,11 +122,11 @@
#undef HAVE_LINK #undef HAVE_LINK
#undef HAVE_LOCALTIME #undef HAVE_LOCALTIME
#undef HAVE_LSTAT #undef HAVE_LSTAT
#undef HAVE_MMAP
#undef HAVE_MEMCPY #undef HAVE_MEMCPY
#undef HAVE_MEMMOVE #undef HAVE_MEMMOVE
#undef HAVE_MKSTEMP #undef HAVE_MKSTEMP
#undef HAVE_MKTEMP #undef HAVE_MKTEMP
#undef HAVE_MMAP
#undef HAVE_OPENDIR #undef HAVE_OPENDIR
#undef HAVE_POPEN #undef HAVE_POPEN
#undef HAVE_PUTENV #undef HAVE_PUTENV
@ -134,24 +135,24 @@
#undef HAVE_RENAME #undef HAVE_RENAME
#undef HAVE_RINT #undef HAVE_RINT
#undef HAVE_SBRK #undef HAVE_SBRK
#undef HAVE_STAT
#undef HAVE_SELECT #undef HAVE_SELECT
#undef HAVE_SETBUF #undef HAVE_SETBUF
#undef HAVE_SETLINEBUF #undef HAVE_SETLINEBUF
#undef HAVE_SHMAT #undef HAVE_SHMAT
#undef HAVE_SIGACTION #undef HAVE_SIGACTION
#undef HAVE_SIGGETMASK #undef HAVE_SIGGETMASK
#undef HAVE_SIGINTERRUPT
#undef HAVE_SIGNAL #undef HAVE_SIGNAL
#undef HAVE_SIGPROCMASK #undef HAVE_SIGPROCMASK
#undef HAVE_SIGSEGV
#undef HAVE_SIGSETJMP #undef HAVE_SIGSETJMP
#undef HAVE_SLEEP #undef HAVE_SLEEP
#undef HAVE_SNPRINTF #undef HAVE_SNPRINTF
#undef HAVE_SOCKET #undef HAVE_SOCKET
#undef HAVE_STAT
#undef HAVE_STRCHR
#undef HAVE_STRERROR #undef HAVE_STRERROR
#undef HAVE_STRNCAT #undef HAVE_STRNCAT
#undef HAVE_STRNCPY #undef HAVE_STRNCPY
#undef HAVE_STRCHR
#undef HAVE_STRTOD #undef HAVE_STRTOD
#undef HAVE_SYSTEM #undef HAVE_SYSTEM
#undef HAVE_TIME #undef HAVE_TIME
@ -160,9 +161,10 @@
#undef HAVE_USLEEP #undef HAVE_USLEEP
#undef HAVE_VSNPRINTF #undef HAVE_VSNPRINTF
#undef HAVE_WAITPID #undef HAVE_WAITPID
#undef HAVE_ENVIRON
#undef HAVE_MPZ_XOR #undef HAVE_MPZ_XOR
#undef HAVE_SIGSEGV
#define SELECT_TYPE_ARG1 #define SELECT_TYPE_ARG1
#define SELECT_TYPE_ARG234 #define SELECT_TYPE_ARG234
#define SELECT_TYPE_ARG5 #define SELECT_TYPE_ARG5

1088
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -11,15 +11,7 @@ AC_PROG_CC
AC_SUBST(GCC) AC_SUBST(GCC)
AC_SUBST(C_INTERF_FLAGS) AC_SUBST(C_INTERF_FLAGS)
AC_CYGWIN
if test "$ac_cv_cygwin" = "yes" -a "$CC" = "gcc"
then
CC="gcc -mno-cygwin"
fi
AC_MINGW32
dnl Checks for programs. dnl Checks for programs.
AC_PROG_CPP
AC_PROG_LN_S AC_PROG_LN_S
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_RANLIB AC_PROG_RANLIB
@ -67,17 +59,23 @@ AC_ARG_WITH(gmp,
fi fi
[yap_cv_gmp=yes]) [yap_cv_gmp=yes])
AC_ARG_WITH(readline,
[ --with-readline[=DIR] use GNU Readline Library in DIR],
if test $withval = yes; then
yap_cv_readline=yes
elif test $withval = no; then
yap_cv_readline=no
else
yap_cv_readline=$with_readline
LDFLAGS="$LDFLAGS -L${yap_cv_readline}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_readline}/include"
fi
[yap_cv_readline=yes])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
AC_DEFINE_UNQUOTED(HOST_ALIAS,"${host_alias}") AC_DEFINE_UNQUOTED(HOST_ALIAS,"${host_alias}")
if test "$cross_compiling" = "yes"
then
YAP_EXTRAS=
else
AC_SYS_RESTARTABLE_SYSCALLS
fi
dnl Compilation Flags dnl Compilation Flags
if test "$GCC" = "yes" if test "$GCC" = "yes"
then then
@ -167,22 +165,22 @@ dnl Check for libraries.
dnl mingw does not get along well with libm dnl mingw does not get along well with libm
dnl cygnus and mingw32 also need wsock32 to use sockets. dnl cygnus and mingw32 also need wsock32 to use sockets.
dnl dnl
if test "$MINGW32" = "yes" if test "$target_os" = "cygwin"
then then
AC_CHECK_LIB(wsock32,main) if test "$CC" = "gcc"
INSTALL_COMMAND=install_mingw32
else
if test "$CYGWIN" = "yes" -a "$MINGW32" = "no"
then then
CC="gcc -mno-cygwin"
AC_CHECK_LIB(wsock32,main)
INSTALL_COMMAND=install_mingw32
yap_cv_readline=no
else
AC_CHECK_LIB(wsock32,main) AC_CHECK_LIB(wsock32,main)
AC_CHECK_LIB(cygwin,main) AC_CHECK_LIB(cygwin,main)
fi fi
else
INSTALL_COMMAND="install_unix" INSTALL_COMMAND="install_unix"
AC_CHECK_LIB(m,sin) AC_CHECK_LIB(m,sin)
AC_CHECK_LIB(socket,socket) AC_CHECK_LIB(socket,socket)
AC_CHECK_LIB(termcap,tgetent)
AC_CHECK_LIB(readline,readline)
AC_CHECK_LIB(gmp,main)
AC_CHECK_LIB(nsl,main, AC_CHECK_LIB(nsl,main,
have_nsl=yes have_nsl=yes
, ,
@ -193,6 +191,24 @@ dnl Linux has both elf and a.out, in this case we found elf
, ,
have_dl=no) have_dl=no)
fi fi
if test "$yap_cv_readline" != "no"
then
AC_CHECK_LIB(termcap,tgetent)
AC_CHECK_LIB(readline,readline)
fi
if test "$yap_cv_gmp" != "no"
then
AC_CHECK_LIB(gmp,main)
fi
AC_PROG_CPP
if test "$cross_compiling" = "yes"
then
YAP_EXTRAS=
else
AC_SYS_RESTARTABLE_SYSCALLS
fi
dnl System stuff for dynamic linking. dnl System stuff for dynamic linking.
dnl dnl
@ -389,17 +405,23 @@ esac
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_HEADER_SYS_WAIT AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h sys/file.h sys/socket.h sys/types.h sys/time.h) AC_CHECK_HEADERS(arpa/inet.h ctype.h direct.h dirent.h errno.h fcntl.h)
AC_CHECK_HEADERS(sys/ucontext.h sys/un.h unistd.h sys/times.h ieeefp.h) AC_CHECK_HEADERS(fenv.h fpu_control.h ieeefp.h io.h limits.h memory.h)
AC_CHECK_HEADERS(sys/param.h errno.h netdb.h netinet/in.h arpa/inet.h) AC_CHECK_HEADERS(netdb.h netinet/in.h regex.h)
AC_CHECK_HEADERS(string.h memory.h sys/mman.h sys/stat.h stdarg.h ctype.h) AC_CHECK_HEADERS(siginfo.h signal.h stdarg.h string.h sys/file.h)
AC_CHECK_HEADERS(sys/resource.h limits.h siginfo.h time.h fenv.h) AC_CHECK_HEADERS(sys/mman.h sys/param.h sys/resource.h sys/select.h)
AC_CHECK_HEADERS(fpu_control.h sys/shm.h regex.h winsock.h winsock2.h) AC_CHECK_HEADERS(sys/shm.h sys/socket.h sys/stat.h)
AC_CHECK_HEADERS(sys/select.h direct.h dirent.h signal.h io.h) AC_CHECK_HEADERS(sys/time.h sys/times.h sys/types.h)
AC_CHECK_HEADERS(sys/ucontext.h sys/un.h)
AC_CHECK_HEADERS(time.h unistd.h winsock.h winsock2.h)
if test "$yap_cv_gmp" != "no" if test "$yap_cv_gmp" != "no"
then then
AC_CHECK_HEADERS(gmp.h) AC_CHECK_HEADERS(gmp.h)
fi fi
if test "$yap_cv_readline" != "no"
then
AC_CHECK_HEADERS( readline/readline.h)
fi
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE AC_C_INLINE
@ -561,15 +583,17 @@ fi
dnl Checks for library functions. dnl Checks for library functions.
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_CHECK_FUNCS(getcwd getwd strtod getrusage chdir signal times siggetmask) AC_CHECK_FUNCS(acosh alarm asinh atanh chdir dup2)
AC_CHECK_FUNCS(strchr memcpy isatty sbrk shmat mmap random rand sigaction) AC_CHECK_FUNCS(fetestexcept finite getcwd getenv)
AC_CHECK_FUNCS(snprintf vsnprintf setbuf system link getpwnam dup2 sigprocmask) AC_CHECK_FUNCS(gethostbyname gethostid gethostname)
AC_CHECK_FUNCS(labs strncat tmpnam getenv gettimeofday gethrtime putenv) AC_CHECK_FUNCS(gethrtime getpwnam getrusage gettimeofday getwd)
AC_CHECK_FUNCS(strerror socket memmove alarm asinh acosh atanh rint) AC_CHECK_FUNCS(isatty isnan kill labs link localtime lstat)
AC_CHECK_FUNCS(stat select fetestexcept finite strncpy mkstemp isnan) AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp mmap opendir)
AC_CHECK_FUNCS(setlinebuf lstat opendir localtime time gethostname) AC_CHECK_FUNCS(popen putenv rand random rename rint sbrk select)
AC_CHECK_FUNCS(gethostid gethostbyname kill mktemp popen rename waitpid) AC_CHECK_FUNCS(setbuf setlinebuf shmat sigaction siggetmask siginterrupt)
AC_CHECK_FUNCS(sleep usleep) AC_CHECK_FUNCS(signal sigprocmask sleep snprintf socket stat)
AC_CHECK_FUNCS(strchr strerror strncat strncpy strtod system)
AC_CHECK_FUNCS(time times tmpnam usleep vsnprintf waitpid)
dnl check for mpz_xor dnl check for mpz_xor
AC_MSG_CHECKING(for mpz_xor) AC_MSG_CHECKING(for mpz_xor)
@ -595,7 +619,7 @@ mkdir -p library/system
mkdir -p CHR mkdir -p CHR
mkdir -p CLPQR mkdir -p CLPQR
AC_OUTPUT(Makefile library/regex/Makefile library/system/Makefile library/random/Makefile .depend library/Makefile CHR/Makefile CLPQR/Makefile) AC_OUTPUT(Makefile library/regex/Makefile library/system/Makefile library/random/Makefile .depend library/Makefile CHR/Makefile CLPQR/Makefile LGPL/win32cons/Makefile)
make depend make depend

View File

@ -10,7 +10,7 @@
* File: Yap.h.m4 * * File: Yap.h.m4 *
* mods: * * mods: *
* comments: main header file for YAP * * comments: main header file for YAP *
* version: $Id: Yap.h.m4,v 1.4 2001-05-03 17:13:18 vsc Exp $ * * version: $Id: Yap.h.m4,v 1.5 2001-06-22 17:53:36 vsc Exp $ *
*************************************************************************/ *************************************************************************/
#include "config.h" #include "config.h"
@ -639,8 +639,8 @@ Inline(IsIntTerm, int, Term, t, CHKTAG((t), NumberTag))
#ifdef TAGS_FAST_OPS #ifdef TAGS_FAST_OPS
#define IntInBnd(X) (Unsigned( ( (Int)(X) >> (32-7) ) + 1) <= 1) #define IntInBnd(X) (Unsigned( ( (Int)(X) >> (32-7) ) + 1) <= 1)
#else #else
#define IntInBnd(X) ( (X) < (Int)MAX_ABS_INT && \ #define IntInBnd(X) ( (X) < (MAX_ABS_INT) && \
(X) > -(Int)MAX_ABS_INT-1 ) (X) > (-MAX_ABS_INT)-1 )
#endif #endif
#endif #endif
#ifdef C_PROLOG #ifdef C_PROLOG

View File

@ -1160,11 +1160,6 @@ catch(G,C,A) :-
'$erase_catch_elements'(I), '$erase_catch_elements'(I),
fail. fail.
'$erase_catch_elements'(catch(X, J, P), I, Catch) :-
J >= I, !,
'$erase_catch_elements'(P, I, Catch).
'$erase_catch_elements'(Catch, _, Catch).
'$catch_call'(X,G,I,NX) :- '$catch_call'(X,G,I,NX) :-
array_element('$catch_queue', 0, OldCatch), array_element('$catch_queue', 0, OldCatch),
update_array('$catch_queue', 0, catch(X,I,OldCatch)), update_array('$catch_queue', 0, catch(X,I,OldCatch)),
@ -1222,6 +1217,11 @@ catch(G,C,A) :-
'$erase_catch_elements'(OldCatch, I, Catch), '$erase_catch_elements'(OldCatch, I, Catch),
update_array('$catch_queue', 0, Catch). update_array('$catch_queue', 0, Catch).
'$erase_catch_elements'(catch(X, J, P), I, Catch) :-
J >= I, !,
'$erase_catch_elements'(P, I, Catch).
'$erase_catch_elements'(Catch, _, Catch).
'$system_catch_call'(X,G,I, NX) :- '$system_catch_call'(X,G,I, NX) :-
array_element('$catch_queue', 0, OldCatch), array_element('$catch_queue', 0, OldCatch),
update_array('$catch_queue', 0, catch(X,I,OldCatch)), update_array('$catch_queue', 0, catch(X,I,OldCatch)),

View File

@ -756,6 +756,7 @@ debugging :-
'$execute'(M:Goal). '$execute'(M:Goal).
'$creep'(G) :- '$creep'(G) :-
'$get_value'('$throw', true), !, '$get_value'('$throw', true), !,
'$set_value'('$throw', false),
abort. abort.
'$creep'([Module|'$trace'(P,G,L)]) :- !, '$creep'([Module|'$trace'(P,G,L)]) :- !,
( Module=prolog -> '$trace'(P,G,L); ( Module=prolog -> '$trace'(P,G,L);