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:
parent
c3e7f600d5
commit
f22f7434c7
14
C/absmi.c
14
C/absmi.c
@ -1978,9 +1978,11 @@ absmi(int inp)
|
||||
*/
|
||||
/* make sure we are here because of an awoken goal */
|
||||
if (CFREG == Unsigned(LCL0) && !(PrologMode & AbortMode)) {
|
||||
Term WGs = ReadTimedVar(WokenGoals);
|
||||
Term my_goal = AbsAppl(H);
|
||||
Term WGs;
|
||||
Term my_goal;
|
||||
|
||||
WGs = ReadTimedVar(WokenGoals);
|
||||
my_goal = AbsAppl(H);
|
||||
if (WGs != TermNil) {
|
||||
#if SHADOW_S
|
||||
/* save S for ModuleName() */
|
||||
@ -2049,6 +2051,13 @@ absmi(int inp)
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
if (PrologMode & AbortMode) {
|
||||
PrologMode &= ~AbortMode;
|
||||
CFREG = CalculateStackGap();
|
||||
/* same instruction */
|
||||
if (ProcessSIGINT() < 0) Abort("");
|
||||
JMPNext();
|
||||
}
|
||||
#if SHADOW_S
|
||||
S = SREG;
|
||||
#endif
|
||||
@ -2100,7 +2109,6 @@ absmi(int inp)
|
||||
H += 2;
|
||||
CFREG = CalculateStackGap();
|
||||
SREG = (CELL *) (Unsigned(CreepCode) - sizeof(SMALLUNSGN));
|
||||
|
||||
#ifdef COROUTINING
|
||||
}
|
||||
#endif
|
||||
|
@ -86,6 +86,7 @@ p_inf(E_ARGS)
|
||||
#define NAN (0.0/0.0)
|
||||
#endif
|
||||
|
||||
|
||||
static E_FUNC
|
||||
p_nan(E_ARGS)
|
||||
{
|
||||
|
@ -3818,12 +3818,14 @@ p_enqueue(void)
|
||||
} else
|
||||
father_key = (db_queue *)DBRefOfTerm(Father);
|
||||
x = StoreTermInDB(Deref(ARG2), 2);
|
||||
x->Parent = NULL;
|
||||
WRITE_LOCK(father_key->QRWLock);
|
||||
if (father_key->LastInQueue != NIL)
|
||||
if (father_key->LastInQueue != NULL)
|
||||
father_key->LastInQueue->Parent = (DBProp)x;
|
||||
father_key->LastInQueue = x;
|
||||
if (father_key->FirstInQueue == NIL)
|
||||
if (father_key->FirstInQueue == NULL) {
|
||||
father_key->FirstInQueue = x;
|
||||
}
|
||||
WRITE_UNLOCK(father_key->QRWLock);
|
||||
return(TRUE);
|
||||
}
|
||||
@ -3873,7 +3875,7 @@ p_dequeue(void)
|
||||
} else
|
||||
father_key = (db_queue *)DBRefOfTerm(Father);
|
||||
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 */
|
||||
if (father_key == DBQueues)
|
||||
DBQueues = father_key->next;
|
||||
|
22
C/errors.c
22
C/errors.c
@ -249,22 +249,20 @@ Abort (char *format,...)
|
||||
#ifdef DEBUGX
|
||||
DumpActiveGoals();
|
||||
#endif /* DEBUG */
|
||||
if (PrologMode & BootMode)
|
||||
{
|
||||
exit_yap (1, NIL);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreepFlag = CalculateStackGap();
|
||||
if (PrologMode & BootMode) {
|
||||
exit_yap (1, NIL);
|
||||
} else {
|
||||
PutValue(AtomThrow, MkAtomTerm(AtomFalse));
|
||||
CreepFlag = CalculateStackGap();
|
||||
#if PUSH_REGS
|
||||
restore_absmi_regs(&standard_regs);
|
||||
restore_absmi_regs(&standard_regs);
|
||||
#endif
|
||||
#if defined(__GNUC__) && defined(hppa)
|
||||
/* siglongjmp resets the TR hardware register */
|
||||
save_TR();
|
||||
/* siglongjmp resets the TR hardware register */
|
||||
save_TR();
|
||||
#endif
|
||||
siglongjmp (RestartEnv, 1);
|
||||
}
|
||||
siglongjmp (RestartEnv, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
8
C/init.c
8
C/init.c
@ -747,6 +747,12 @@ InitCodes(void)
|
||||
#endif /* YAPOR */
|
||||
#endif /* TABLING */
|
||||
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);
|
||||
|
||||
@ -941,6 +947,8 @@ InitCodes(void)
|
||||
heap_regs->functor_change_module = MkFunctor (LookupAtom("$change_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_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_var = MkFunctor(AtomVar, 1);
|
||||
#ifdef EUROTRA
|
||||
|
73
C/iopreds.c
73
C/iopreds.c
@ -51,6 +51,9 @@ static char SccsId[] = "%W% %G%";
|
||||
#if HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#if HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#if HAVE_FCNTL_H
|
||||
/* for O_BINARY and O_TEXT in WIN32 */
|
||||
#include <fcntl.h>
|
||||
@ -77,6 +80,18 @@ static char SccsId[] = "%W% %G%";
|
||||
/* if we botched in a LongIO operation */
|
||||
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
|
||||
{
|
||||
union {
|
||||
@ -319,8 +334,8 @@ unix_upd_stream_info (StreamDesc * s)
|
||||
#endif /* USE_SOCKET */
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
{
|
||||
struct stat buf;
|
||||
if (fstat(fileno(s->u.file.file), &buf) == -1) {
|
||||
struct _stat buf;
|
||||
if (_fstat(YP_fileno(s->u.file.file), &buf) == -1) {
|
||||
return;
|
||||
}
|
||||
if (buf.st_mode & S_IFCHR) {
|
||||
@ -768,6 +783,10 @@ static void
|
||||
InitReadline(void) {
|
||||
ReadlineBuf = (char *)AllocAtomSpace(READLINE_OUT_BUF_MAX+1);
|
||||
ReadlinePos = ReadlineBuf;
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
rl_instream = stdin;
|
||||
rl_outstream = stdout;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
@ -813,6 +832,10 @@ ReadlineGetc(int sno)
|
||||
register int ch;
|
||||
|
||||
if (ttyptr == NIL) {
|
||||
if (setjmp(readline_jmpbuf) < 0) {
|
||||
Abort("");
|
||||
}
|
||||
in_getc = TRUE;
|
||||
/* Do it the gnu way */
|
||||
YP_fflush (YP_stdout);
|
||||
/* Only sends a newline if we are at the start of a line */
|
||||
@ -845,10 +868,8 @@ ReadlineGetc(int sno)
|
||||
}
|
||||
newline=FALSE;
|
||||
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
|
||||
in_getc = FALSE;
|
||||
/* window of vulnerability closed */
|
||||
if (PrologMode & AbortMode) {
|
||||
Abort ((char *) NULL);
|
||||
}
|
||||
if (_line == NULL || _line == (char *) EOF)
|
||||
return(console_post_process_read_char(EOF, s, sno));
|
||||
if (_line[0] != '\0' && _line[1] != '\0')
|
||||
@ -1156,18 +1177,15 @@ ISOGetc (int sno)
|
||||
return(ch);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
int in_getc = FALSE;
|
||||
#endif
|
||||
|
||||
/* send a prompt, and use the system for internal buffering. Speed is
|
||||
not of the essence here !!! */
|
||||
static int
|
||||
ConsoleGetc(int sno)
|
||||
{
|
||||
register StreamDesc *s = &Stream[sno];
|
||||
register int ch;
|
||||
char ch;
|
||||
|
||||
restart:
|
||||
if (newline) {
|
||||
char *cptr = Prompt, ch;
|
||||
|
||||
@ -1178,20 +1196,28 @@ ConsoleGetc(int sno)
|
||||
strncpy (Prompt, RepAtom (*AtPrompt)->StrOfAE, MAX_PROMPT);
|
||||
newline = FALSE;
|
||||
}
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
next_getc:
|
||||
in_getc = TRUE;
|
||||
#if HAVE_SIGINTERRUPT
|
||||
siginterrupt(SIGINT, TRUE);
|
||||
#endif
|
||||
ch = YP_getc (s->u.file.file);
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
if (!in_getc) {
|
||||
ProcessSIGINT();
|
||||
if (PrologMode & AbortMode) {
|
||||
Abort((char *)NULL);
|
||||
} else
|
||||
goto next_getc;
|
||||
}
|
||||
ch = YP_fgetc(s->u.file.file);
|
||||
#if HAVE_SIGINTERRUPT
|
||||
siginterrupt(SIGINT, FALSE);
|
||||
#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));
|
||||
}
|
||||
|
||||
@ -1393,8 +1419,13 @@ static int
|
||||
binary_file(char *file_name)
|
||||
{
|
||||
#if HAVE_STAT
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
struct _stat ss;
|
||||
if (_stat(file_name, &ss) != 0) {
|
||||
#else
|
||||
struct stat ss;
|
||||
if (stat(file_name, &ss) != 0) {
|
||||
#endif
|
||||
/* ignore errors while checking a file */
|
||||
return(FALSE);
|
||||
}
|
||||
|
8
C/save.c
8
C/save.c
@ -873,6 +873,12 @@ restore_codes(void)
|
||||
#endif /* YAPOR */
|
||||
#endif /* TABLING */
|
||||
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->yescode = opcode(_Ystop);
|
||||
#ifdef YAPOR
|
||||
@ -1089,6 +1095,8 @@ restore_codes(void)
|
||||
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_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_var = FuncAdjust(heap_regs->functor_var);
|
||||
#ifdef EUROTRA
|
||||
|
32
C/scanner.c
32
C/scanner.c
@ -51,14 +51,6 @@ static char SccsId[] = "@(#)scanner.c 1.2";
|
||||
C <= (SU)) || (C >= 'a' && C <= (SL)))
|
||||
#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(int my_getch, (void));
|
||||
STATIC_PROTO(Term float_send, (char *));
|
||||
@ -224,7 +216,7 @@ float_send(char *s)
|
||||
|
||||
/* we have an overflow at s */
|
||||
static Term
|
||||
read_int_overflow(const char *s, Int base)
|
||||
read_int_overflow(const char *s, Int base, Int val)
|
||||
{
|
||||
#ifdef USE_GMP
|
||||
/* try to scan it as a bignum */
|
||||
@ -234,7 +226,7 @@ read_int_overflow(const char *s, Int base)
|
||||
return(MkBigIntTerm(new));
|
||||
#else
|
||||
/* try to scan it as a float */
|
||||
return(float_send((char *)s));
|
||||
return(MkIntegerTerm(val));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -434,7 +426,7 @@ get_num(void)
|
||||
my_ungetch();
|
||||
*--sp = '\0';
|
||||
if (has_overflow)
|
||||
return(read_int_overflow(s,base));
|
||||
return(read_int_overflow(s,base,val));
|
||||
return (MkIntegerTerm(val));
|
||||
}
|
||||
do
|
||||
@ -465,12 +457,12 @@ get_num(void)
|
||||
*sp = '\0';
|
||||
/* skip base */
|
||||
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] == '\'')
|
||||
return(read_int_overflow(s+2,base));
|
||||
return(read_int_overflow(s+2,base,val));
|
||||
if (s[2] == '\'')
|
||||
return(read_int_overflow(s+3,base));
|
||||
return(read_int_overflow(s,base));
|
||||
return(read_int_overflow(s+3,base,val));
|
||||
return(read_int_overflow(s,base,val));
|
||||
} else
|
||||
return (MkIntegerTerm(val));
|
||||
}
|
||||
@ -1172,7 +1164,7 @@ fast_tokenizer(void)
|
||||
*/
|
||||
#endif
|
||||
if (has_overflow)
|
||||
t->TokInfo = read_int_overflow(TokImage,base);
|
||||
t->TokInfo = read_int_overflow(TokImage,base,val);
|
||||
else
|
||||
t->TokInfo = MkIntegerTerm(val);
|
||||
t->TokPos = TokenPos;
|
||||
@ -1274,13 +1266,13 @@ fast_tokenizer(void)
|
||||
*sp = '\0';
|
||||
/* skip base */
|
||||
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] == '\'')
|
||||
TokenInfo = read_int_overflow(TokImage+2,base);
|
||||
TokenInfo = read_int_overflow(TokImage+2,base,val);
|
||||
else if (TokImage[2] == '\'')
|
||||
TokenInfo = read_int_overflow(TokImage+3,base);
|
||||
TokenInfo = read_int_overflow(TokImage+3,base,val);
|
||||
else
|
||||
TokenInfo = read_int_overflow(TokImage,base);
|
||||
TokenInfo = read_int_overflow(TokImage,base,val);
|
||||
} else
|
||||
TokenInfo = (CELL) MkIntegerTerm(val);
|
||||
}
|
||||
|
11
C/stdpreds.c
11
C/stdpreds.c
@ -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
|
||||
get_num(char *t)
|
||||
{
|
||||
@ -1249,7 +1241,7 @@ p_abort(void)
|
||||
/* make sure we won't go creeping around */
|
||||
CreepFlag = CalculateStackGap();
|
||||
yap_flags[SPY_CREEP_FLAG] = 0;
|
||||
Error(PURE_ABORT,TermNil,"");
|
||||
Abort("");
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
@ -2085,6 +2077,7 @@ p_has_yap_or(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static Int
|
||||
p_has_tabling(void)
|
||||
{
|
||||
|
331
C/sysbits.c
331
C/sysbits.c
@ -652,7 +652,7 @@ void walltime_interval(Int *now,Int *interval)
|
||||
#include <time.h>
|
||||
|
||||
/* since the point YAP was started */
|
||||
static struct timeb StartOfWTimes;
|
||||
static struct _timeb StartOfWTimes;
|
||||
|
||||
/* since last call to walltime */
|
||||
#define LastWtime (*(struct timeb *)LastWtimePtr)
|
||||
@ -661,7 +661,7 @@ static struct timeb StartOfWTimes;
|
||||
static void
|
||||
InitWTime (void)
|
||||
{
|
||||
ftime(&StartOfWTimes);
|
||||
_ftime(&StartOfWTimes);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -675,9 +675,9 @@ InitLastWtime(void) {
|
||||
Int
|
||||
walltime (void)
|
||||
{
|
||||
struct timeb tp;
|
||||
struct _timeb tp;
|
||||
|
||||
ftime(&tp);
|
||||
_ftime(&tp);
|
||||
if (StartOfWTimes.millitm > tp.millitm)
|
||||
return((tp.time - StartOfWTimes.time - 1) * 1000 +
|
||||
(StartOfWTimes.millitm - tp.millitm));
|
||||
@ -688,9 +688,9 @@ walltime (void)
|
||||
|
||||
void walltime_interval(Int *now,Int *interval)
|
||||
{
|
||||
struct timeb tp;
|
||||
struct _timeb tp;
|
||||
|
||||
ftime(&tp);
|
||||
_ftime(&tp);
|
||||
*now = (tp.time - StartOfWTimes.time) * 1000 +
|
||||
(tp.millitm - StartOfWTimes.millitm);
|
||||
*interval = (tp.time - LastWtime.time) * 1000 +
|
||||
@ -1068,151 +1068,157 @@ void (*handler)(int);
|
||||
static char *_line = NULL;
|
||||
#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)
|
||||
{
|
||||
int ch, out;
|
||||
|
||||
while (TRUE) {
|
||||
int ch;
|
||||
#ifdef MPW
|
||||
int ch0;
|
||||
#if HAVE_ISATTY
|
||||
if (!isatty(0)) {
|
||||
InteractSIGINT('e');
|
||||
}
|
||||
#if !HAVE_LIBREADLINE
|
||||
if (in_getc) {
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
do {
|
||||
#if HAVE_LIBREADLINE
|
||||
if (_line != (char *) NULL && _line != (char *) EOF)
|
||||
free (_line);
|
||||
_line = readline ("Action (h for help): ");
|
||||
if (_line == (char *)NULL || _line == (char *)EOF)
|
||||
if (_line == (char *)NULL || _line == (char *)EOF) {
|
||||
ch = EOF;
|
||||
continue;
|
||||
}
|
||||
ch = _line[0];
|
||||
#else
|
||||
YP_fprintf(YP_stderr, "\nAction (h for help): ");
|
||||
ch = YP_getchar ( );
|
||||
while ((YP_getchar()) != '\n');
|
||||
/* ask for a new line */
|
||||
fprintf(stderr, "Action (h for help): ");
|
||||
ch = getc(stdin);
|
||||
/* first process up to end of line */
|
||||
while ((fgetc(stdin)) != '\n');
|
||||
#endif
|
||||
switch (ch)
|
||||
{
|
||||
case 'a':
|
||||
/* abort computation, but take care in case we are within readline
|
||||
code */
|
||||
if (!(PrologMode & CritMode))
|
||||
{
|
||||
#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;
|
||||
}
|
||||
} while (!(out = InteractSIGINT(ch)));
|
||||
if (out < 0)
|
||||
sigint_pending = out;
|
||||
#if HAVE_LIBREADLINE
|
||||
if (in_getc) {
|
||||
longjmp(readline_jmpbuf, (out < 0 ? -1 : 1));
|
||||
}
|
||||
#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
|
||||
#if defined(__svr4__)
|
||||
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)
|
||||
#endif
|
||||
{
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
extern int in_getc;
|
||||
|
||||
if (in_getc) {
|
||||
/* YP_ungetc(YP_stdin,'\n');
|
||||
PrologMode |= InterruptMode; */
|
||||
in_getc = FALSE;
|
||||
return;
|
||||
}
|
||||
#else
|
||||
my_signal(SIGINT, HandleSIGINT);
|
||||
#if (_MSC_VER || defined(__MINGW32__))
|
||||
printf("hello\n");
|
||||
return;
|
||||
#endif
|
||||
#ifdef HAVE_SETBUF
|
||||
/* make sure we are not waiting for the end of line */
|
||||
YP_setbuf (stdin, NULL);
|
||||
#endif
|
||||
my_signal(SIGINT, HandleSIGINT);
|
||||
#endif
|
||||
if (snoozing)
|
||||
{
|
||||
@ -1266,6 +1265,7 @@ HandleALRM(int s)
|
||||
* 6 possibilities : abort, continue, trace, debug, help, exit
|
||||
*/
|
||||
|
||||
#if !defined(LIGHT) && !_MSC_VER && !defined(__MINGW32__) && !defined(LIGHT)
|
||||
static RETSIGTYPE
|
||||
#if defined(__svr4__)
|
||||
ReceiveSignal (int s, siginfo_t *x, ucontext_t *y)
|
||||
@ -1292,20 +1292,21 @@ ReceiveSignal (int s)
|
||||
exit (FALSE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
static BOOL WINAPI MSCHandleSignal(DWORD dwCtrlType) {
|
||||
#if (_MSC_VER || defined(__MINGW32__))
|
||||
static BOOL WINAPI
|
||||
MSCHandleSignal(DWORD dwCtrlType) {
|
||||
switch(dwCtrlType) {
|
||||
case CTRL_C_EVENT:
|
||||
HandleSIGINT(SIGINT);
|
||||
break;
|
||||
case CTRL_BREAK_EVENT:
|
||||
HandleSIGINT(SIGINT);
|
||||
break;
|
||||
p_creep();
|
||||
PutValue(AtomThrow, MkAtomTerm(AtomTrue));
|
||||
PrologMode |= AbortMode;
|
||||
return(TRUE);
|
||||
default:
|
||||
exit_yap(1, "[ SYSTEM ERROR: Received Termination Event ]\n");
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1313,32 +1314,28 @@ static BOOL WINAPI MSCHandleSignal(DWORD dwCtrlType) {
|
||||
static 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__)
|
||||
signal (SIGINT, SIG_IGN);
|
||||
SetConsoleCtrlHandler(MSCHandleSignal,TRUE);
|
||||
#else
|
||||
my_signal (SIGINT, HandleSIGINT);
|
||||
#endif
|
||||
#ifndef MPW
|
||||
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
|
||||
#if HAVE_SIGSEGV
|
||||
my_signal_info (SIGSEGV, HandleSIGSEGV);
|
||||
#endif
|
||||
#if !defined(LIGHT) && !defined(_WIN32)
|
||||
my_signal(SIGALRM, HandleALRM);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ACOW
|
||||
signal(SIGCHLD, SIG_IGN); /* avoid ghosts */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif /* HAVE_SIGNAL */
|
||||
|
||||
|
||||
|
@ -210,7 +210,6 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
send_tracer_message("RETRY: ", s, arity, mname, args);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
20
C/ypsocks.c
20
C/ypsocks.c
@ -78,7 +78,7 @@
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
#endif /* HAVE_WINSOCK_H */
|
||||
#if _MSC_VER
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
#include <io.h>
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
@ -177,7 +177,7 @@
|
||||
#define MAXHOSTNAMELEN 256
|
||||
#endif
|
||||
|
||||
#if _MSC_VER
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
#define socket_errno WSAGetLastError()
|
||||
#define invalid_socket_fd(fd) (fd) == INVALID_SOCKET
|
||||
#else
|
||||
@ -468,7 +468,7 @@ CloseSocket(int fd, socket_info status, socket_domain domain)
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
#if _MSC_VER
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
if (closesocket(fd) != 0) {
|
||||
#else
|
||||
if (close(fd) < 0) {
|
||||
@ -905,7 +905,7 @@ p_socket_select(void)
|
||||
fd_set readfds, writefds, exceptfds;
|
||||
struct timeval timeout, *ptime;
|
||||
|
||||
#if _MSC_VER
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
u_int fdmax=0;
|
||||
#else
|
||||
int fdmax=0;
|
||||
@ -943,7 +943,7 @@ p_socket_select(void)
|
||||
/* fetch the input streams */
|
||||
ti = t1;
|
||||
while (ti != TermNil) {
|
||||
#if _MSC_VER
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
u_int fd;
|
||||
#else
|
||||
int fd;
|
||||
@ -1038,8 +1038,8 @@ p_current_hostname(void) {
|
||||
int faq = (strrchr(sin,'.') != NULL);
|
||||
|
||||
if (faq)
|
||||
#if _MSC_VER
|
||||
return(stricmp(name,sin) == 0);
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
return(_stricmp(name,sin) == 0);
|
||||
#else
|
||||
return(strcasecmp(name,sin) == 0);
|
||||
#endif
|
||||
@ -1052,8 +1052,8 @@ p_current_hostname(void) {
|
||||
}
|
||||
if (name[isize] != '.') return(FALSE);
|
||||
name[isize] = '\0';
|
||||
#if _MSC_VER
|
||||
return(stricmp(name,sin) == 0);
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
return(_stricmp(name,sin) == 0);
|
||||
#else
|
||||
return(strcasecmp(name,sin) == 0);
|
||||
#endif
|
||||
@ -1129,7 +1129,7 @@ InitSockets(void)
|
||||
InitCPred("$socket_select", 4, p_socket_select, SafePredFlag|SyncPredFlag);
|
||||
InitCPred("current_hostname", 1, p_current_hostname, SafePredFlag);
|
||||
InitCPred("hostname_address", 2, p_hostname_address, SafePredFlag);
|
||||
#if _MSC_VER
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
{
|
||||
WSADATA info;
|
||||
if (WSAStartup(MAKEWORD(2,1), &info) != 0)
|
||||
|
12
H/Heap.h
12
H/Heap.h
@ -10,7 +10,7 @@
|
||||
* File: Heap.h *
|
||||
* mods: *
|
||||
* 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 */
|
||||
@ -47,6 +47,12 @@ typedef struct various_codes {
|
||||
yamop tableanswerresolutioncode;
|
||||
#endif /* TABLING */
|
||||
OPCODE failcode;
|
||||
OPCODE failcode_1;
|
||||
OPCODE failcode_2;
|
||||
OPCODE failcode_3;
|
||||
OPCODE failcode_4;
|
||||
OPCODE failcode_5;
|
||||
OPCODE failcode_6;
|
||||
OPCODE trustfailcode;
|
||||
struct {
|
||||
OPCODE op;
|
||||
@ -244,6 +250,8 @@ typedef struct various_codes {
|
||||
functor_change_module,
|
||||
functor_current_module,
|
||||
functor_mod_switch,
|
||||
functor_u_minus,
|
||||
functor_u_plus,
|
||||
functor_v_bar,
|
||||
functor_var;
|
||||
Term
|
||||
@ -426,6 +434,8 @@ typedef struct various_codes {
|
||||
#define FunctorChangeModule heap_regs->functor_change_module
|
||||
#define FunctorCurrentModule heap_regs->functor_current_module
|
||||
#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 FunctorVar heap_regs->functor_var
|
||||
#define TermDollarU heap_regs->term_dollar_u
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: Yap.proto *
|
||||
* mods: *
|
||||
* 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 */
|
||||
@ -244,7 +244,7 @@ void STD_PROTO(walltime_interval,(Int *,Int *));
|
||||
void STD_PROTO(InitSysbits,(void));
|
||||
void STD_PROTO(InitSysPreds,(void));
|
||||
int STD_PROTO(TrueFileName, (char *, char *, int));
|
||||
void STD_PROTO(ProcessSIGINT,(void));
|
||||
int STD_PROTO(ProcessSIGINT,(void));
|
||||
double STD_PROTO(yap_random, (void));
|
||||
|
||||
/* tracer.c */
|
||||
|
24
H/yapio.h
24
H/yapio.h
@ -33,7 +33,11 @@
|
||||
#define YP_clearerr clearerr
|
||||
#define YP_feof feof
|
||||
#define YP_ferror ferror
|
||||
#if _MSC_VER || defined(__MINGW32__)
|
||||
#define YP_fileno _fileno
|
||||
#else
|
||||
#define YP_fileno fileno
|
||||
#endif
|
||||
#define YP_fopen fopen
|
||||
#define YP_fclose fclose
|
||||
#define YP_ftell ftell
|
||||
@ -44,6 +48,19 @@
|
||||
#define YP_fdopen fdopen
|
||||
#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
|
||||
extern int YP_stdin;
|
||||
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; }
|
||||
|
||||
extern jmp_buf IOBotch;
|
||||
|
||||
#if HAVE_LIBREADLINE
|
||||
extern jmp_buf readline_jmpbuf;
|
||||
#endif
|
||||
|
||||
extern int in_getc, sigint_pending;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
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.
|
||||
|
||||
|
28
Makefile.in
28
Makefile.in
@ -47,8 +47,9 @@ YAP_EXTRAS=@YAP_EXTRAS@
|
||||
# for c_interface.c
|
||||
#
|
||||
CC=@CC@
|
||||
CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -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
|
||||
CPPFLAGS=@CPPFLAGS@ -I. -I$(srcdir)/H -I$(srcdir)/OPTYap
|
||||
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.
|
||||
@ -57,7 +58,6 @@ CPP=@CPP@
|
||||
DEFS=@DEFS@
|
||||
LIBS=@LIBS@
|
||||
LDFLAGS=@LDFLAGS@
|
||||
CPPFLAGS=@CPPFLAGS@
|
||||
LN_S=@LN_S@
|
||||
M4=@M4@
|
||||
GCC=@GCC@
|
||||
@ -438,7 +438,7 @@ libYap.a: $(LIB_OBJECTS)
|
||||
|
||||
install: @INSTALL_COMMAND@
|
||||
|
||||
install_unix:
|
||||
install_unix: startup
|
||||
-mkdir -p $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL_PROGRAM) -m 755 yap $(DESTDIR)$(BINDIR)/yap
|
||||
-mkdir -p $(DESTDIR)$(YAPLIBDIR)
|
||||
@ -455,13 +455,13 @@ install_unix:
|
||||
-mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
||||
for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done
|
||||
|
||||
install_mingw32:
|
||||
-mkdir $(DESTDIR)$(ROOTDIR)
|
||||
-mkdir $(DESTDIR)$(BINDIR)
|
||||
-mkdir $(DESTDIR)$(ROOTDIR)/lib
|
||||
-mkdir $(DESTDIR)$(YAPLIBDIR)
|
||||
-mkdir $(DESTDIR)$(ROOTDIR)/include
|
||||
-mkdir $(DESTDIR)$(INCLUDEDIR)
|
||||
install_mingw32: startup
|
||||
-mkdir -p $(DESTDIR)$(ROOTDIR)
|
||||
-mkdir -p $(DESTDIR)$(BINDIR)
|
||||
-mkdir -p $(DESTDIR)$(ROOTDIR)/lib
|
||||
-mkdir -p $(DESTDIR)$(YAPLIBDIR)
|
||||
-mkdir -p $(DESTDIR)$(ROOTDIR)/include
|
||||
-mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
||||
$(INSTALL_PROGRAM) -m 755 yap.exe $(DESTDIR)$(BINDIR)/yap.exe
|
||||
$(INSTALL_PROGRAM) -m 755 yap.dll $(DESTDIR)$(BINDIR)/yap.dll
|
||||
$(INSTALL_PROGRAM) -m 755 startup $(DESTDIR)$(YAPLIBDIR)/startup
|
||||
@ -479,7 +479,7 @@ install_mingw32:
|
||||
|
||||
install_library: libYap.a
|
||||
$(INSTALL_DATA) -m 644 libYap.a $(DESTDIR)$(LIBDIR)/libYap.a
|
||||
-mkdir $(DESTDIR)$(INCLUDEDIR)
|
||||
-mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
||||
$(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)
|
||||
|
||||
##########
|
||||
@ -488,7 +488,7 @@ TAGS: $(C_SOURCES) $(PL_SOURCES) $(HEADERS)
|
||||
|
||||
depend: $(HEADERS) $(C_SOURCES)
|
||||
-@if test "$(GCC)" = yes; then\
|
||||
gcc -MM $(CFLAGS) -I$(srcdir)/include $(C_SOURCES) > .depend;\
|
||||
$(CC) -MM $(CFLAGS) -I$(srcdir)/include $(C_SOURCES) > .depend;\
|
||||
else\
|
||||
makedepend -f - -- $(CFLAGS) -I$(srcdir)/include -- $(C_SOURCES) |\
|
||||
sed 's|.*/\([^:]*\):|\1:|' > .depend ;\
|
||||
@ -518,7 +518,7 @@ dist:
|
||||
#
|
||||
DLLTOOL=dlltool
|
||||
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
|
||||
EXP_FILE=yap.exp
|
||||
DEF_FILE=$(srcdir)/misc/yap.def
|
||||
|
2
TO_DO
2
TO_DO
@ -13,7 +13,6 @@ BEFORE 4.4:
|
||||
- document system(library)
|
||||
- document new interface functions.
|
||||
- ^C can break code.
|
||||
- check library(random)
|
||||
- add more precision when outputting floats.
|
||||
- make statistics/0 better looking.
|
||||
- mask when installing.
|
||||
@ -78,3 +77,4 @@ DONE:
|
||||
- remove pl/nfr.yap and misc/yap.spec from CVS.
|
||||
- deterministic trail entries for multi-assignment variables.
|
||||
- weird going ons with prompt and readline
|
||||
- check library(random)
|
||||
|
@ -16,6 +16,13 @@
|
||||
|
||||
<h2>Yap-4.3.19:</h2>
|
||||
<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
|
||||
to prompt.</li>
|
||||
<li>FIXED: upgrade to autoconf 2.5.</li>
|
||||
|
20
config.h.in
20
config.h.in
@ -38,6 +38,7 @@
|
||||
#undef HAVE_MEMORY_H
|
||||
#undef HAVE_NETDB_H
|
||||
#undef HAVE_NETINET_IN_H
|
||||
#undef HAVE_READLINE_READLINE_H
|
||||
#undef HAVE_REGEX_H
|
||||
#undef HAVE_SIGINFO_H
|
||||
#undef HAVE_SIGNAL_H
|
||||
@ -96,22 +97,22 @@
|
||||
/* Define return type for signal */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
#undef HAVE_ACOSH
|
||||
#undef HAVE_ALARM
|
||||
#undef HAVE_ASINH
|
||||
#undef HAVE_ACOSH
|
||||
#undef HAVE_ATANH
|
||||
#undef HAVE_CHDIR
|
||||
#undef HAVE_DUP2
|
||||
#undef HAVE_FETESTEXCEPT
|
||||
#undef HAVE_FINITE
|
||||
#undef HAVE_GETCWD
|
||||
#undef HAVE_GETENV
|
||||
#undef HAVE_GETHOSTBYNAME
|
||||
#undef HAVE_GETHOSTID
|
||||
#undef HAVE_GETHOSTNAME
|
||||
#undef HAVE_GETRUSAGE
|
||||
#undef HAVE_GETCWD
|
||||
#undef HAVE_GETENV
|
||||
#undef HAVE_GETHRTIME
|
||||
#undef HAVE_GETPWNAM
|
||||
#undef HAVE_GETRUSAGE
|
||||
#undef HAVE_GETTIMEOFDAY
|
||||
#undef HAVE_GETWD
|
||||
#undef HAVE_ISATTY
|
||||
@ -121,11 +122,11 @@
|
||||
#undef HAVE_LINK
|
||||
#undef HAVE_LOCALTIME
|
||||
#undef HAVE_LSTAT
|
||||
#undef HAVE_MMAP
|
||||
#undef HAVE_MEMCPY
|
||||
#undef HAVE_MEMMOVE
|
||||
#undef HAVE_MKSTEMP
|
||||
#undef HAVE_MKTEMP
|
||||
#undef HAVE_MMAP
|
||||
#undef HAVE_OPENDIR
|
||||
#undef HAVE_POPEN
|
||||
#undef HAVE_PUTENV
|
||||
@ -134,24 +135,24 @@
|
||||
#undef HAVE_RENAME
|
||||
#undef HAVE_RINT
|
||||
#undef HAVE_SBRK
|
||||
#undef HAVE_STAT
|
||||
#undef HAVE_SELECT
|
||||
#undef HAVE_SETBUF
|
||||
#undef HAVE_SETLINEBUF
|
||||
#undef HAVE_SHMAT
|
||||
#undef HAVE_SIGACTION
|
||||
#undef HAVE_SIGGETMASK
|
||||
#undef HAVE_SIGINTERRUPT
|
||||
#undef HAVE_SIGNAL
|
||||
#undef HAVE_SIGPROCMASK
|
||||
#undef HAVE_SIGSEGV
|
||||
#undef HAVE_SIGSETJMP
|
||||
#undef HAVE_SLEEP
|
||||
#undef HAVE_SNPRINTF
|
||||
#undef HAVE_SOCKET
|
||||
#undef HAVE_STAT
|
||||
#undef HAVE_STRCHR
|
||||
#undef HAVE_STRERROR
|
||||
#undef HAVE_STRNCAT
|
||||
#undef HAVE_STRNCPY
|
||||
#undef HAVE_STRCHR
|
||||
#undef HAVE_STRTOD
|
||||
#undef HAVE_SYSTEM
|
||||
#undef HAVE_TIME
|
||||
@ -160,9 +161,10 @@
|
||||
#undef HAVE_USLEEP
|
||||
#undef HAVE_VSNPRINTF
|
||||
#undef HAVE_WAITPID
|
||||
#undef HAVE_ENVIRON
|
||||
#undef HAVE_MPZ_XOR
|
||||
|
||||
#undef HAVE_SIGSEGV
|
||||
|
||||
#define SELECT_TYPE_ARG1
|
||||
#define SELECT_TYPE_ARG234
|
||||
#define SELECT_TYPE_ARG5
|
||||
|
104
configure.in
104
configure.in
@ -11,15 +11,7 @@ AC_PROG_CC
|
||||
AC_SUBST(GCC)
|
||||
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.
|
||||
AC_PROG_CPP
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_RANLIB
|
||||
@ -67,17 +59,23 @@ AC_ARG_WITH(gmp,
|
||||
fi
|
||||
[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_DEFINE_UNQUOTED(HOST_ALIAS,"${host_alias}")
|
||||
|
||||
if test "$cross_compiling" = "yes"
|
||||
then
|
||||
YAP_EXTRAS=
|
||||
else
|
||||
AC_SYS_RESTARTABLE_SYSCALLS
|
||||
fi
|
||||
|
||||
dnl Compilation Flags
|
||||
if test "$GCC" = "yes"
|
||||
then
|
||||
@ -167,22 +165,22 @@ dnl Check for libraries.
|
||||
dnl mingw does not get along well with libm
|
||||
dnl cygnus and mingw32 also need wsock32 to use sockets.
|
||||
dnl
|
||||
if test "$MINGW32" = "yes"
|
||||
if test "$target_os" = "cygwin"
|
||||
then
|
||||
AC_CHECK_LIB(wsock32,main)
|
||||
INSTALL_COMMAND=install_mingw32
|
||||
else
|
||||
if test "$CYGWIN" = "yes" -a "$MINGW32" = "no"
|
||||
if test "$CC" = "gcc"
|
||||
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(cygwin,main)
|
||||
fi
|
||||
else
|
||||
INSTALL_COMMAND="install_unix"
|
||||
AC_CHECK_LIB(m,sin)
|
||||
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,
|
||||
have_nsl=yes
|
||||
,
|
||||
@ -193,6 +191,24 @@ dnl Linux has both elf and a.out, in this case we found elf
|
||||
,
|
||||
have_dl=no)
|
||||
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
|
||||
@ -389,17 +405,23 @@ esac
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS(fcntl.h sys/file.h sys/socket.h sys/types.h sys/time.h)
|
||||
AC_CHECK_HEADERS(sys/ucontext.h sys/un.h unistd.h sys/times.h ieeefp.h)
|
||||
AC_CHECK_HEADERS(sys/param.h errno.h netdb.h netinet/in.h arpa/inet.h)
|
||||
AC_CHECK_HEADERS(string.h memory.h sys/mman.h sys/stat.h stdarg.h ctype.h)
|
||||
AC_CHECK_HEADERS(sys/resource.h limits.h siginfo.h time.h fenv.h)
|
||||
AC_CHECK_HEADERS(fpu_control.h sys/shm.h regex.h winsock.h winsock2.h)
|
||||
AC_CHECK_HEADERS(sys/select.h direct.h dirent.h signal.h io.h)
|
||||
AC_CHECK_HEADERS(arpa/inet.h ctype.h direct.h dirent.h errno.h fcntl.h)
|
||||
AC_CHECK_HEADERS(fenv.h fpu_control.h ieeefp.h io.h limits.h memory.h)
|
||||
AC_CHECK_HEADERS(netdb.h netinet/in.h regex.h)
|
||||
AC_CHECK_HEADERS(siginfo.h signal.h stdarg.h string.h sys/file.h)
|
||||
AC_CHECK_HEADERS(sys/mman.h sys/param.h sys/resource.h sys/select.h)
|
||||
AC_CHECK_HEADERS(sys/shm.h sys/socket.h sys/stat.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"
|
||||
then
|
||||
AC_CHECK_HEADERS(gmp.h)
|
||||
fi
|
||||
if test "$yap_cv_readline" != "no"
|
||||
then
|
||||
AC_CHECK_HEADERS( readline/readline.h)
|
||||
fi
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_INLINE
|
||||
@ -561,15 +583,17 @@ fi
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
AC_CHECK_FUNCS(getcwd getwd strtod getrusage chdir signal times siggetmask)
|
||||
AC_CHECK_FUNCS(strchr memcpy isatty sbrk shmat mmap random rand sigaction)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf setbuf system link getpwnam dup2 sigprocmask)
|
||||
AC_CHECK_FUNCS(labs strncat tmpnam getenv gettimeofday gethrtime putenv)
|
||||
AC_CHECK_FUNCS(strerror socket memmove alarm asinh acosh atanh rint)
|
||||
AC_CHECK_FUNCS(stat select fetestexcept finite strncpy mkstemp isnan)
|
||||
AC_CHECK_FUNCS(setlinebuf lstat opendir localtime time gethostname)
|
||||
AC_CHECK_FUNCS(gethostid gethostbyname kill mktemp popen rename waitpid)
|
||||
AC_CHECK_FUNCS(sleep usleep)
|
||||
AC_CHECK_FUNCS(acosh alarm asinh atanh chdir dup2)
|
||||
AC_CHECK_FUNCS(fetestexcept finite getcwd getenv)
|
||||
AC_CHECK_FUNCS(gethostbyname gethostid gethostname)
|
||||
AC_CHECK_FUNCS(gethrtime getpwnam getrusage gettimeofday getwd)
|
||||
AC_CHECK_FUNCS(isatty isnan kill labs link localtime lstat)
|
||||
AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp mmap opendir)
|
||||
AC_CHECK_FUNCS(popen putenv rand random rename rint sbrk select)
|
||||
AC_CHECK_FUNCS(setbuf setlinebuf shmat sigaction siggetmask siginterrupt)
|
||||
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
|
||||
AC_MSG_CHECKING(for mpz_xor)
|
||||
@ -595,7 +619,7 @@ mkdir -p library/system
|
||||
mkdir -p CHR
|
||||
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
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* 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"
|
||||
@ -639,8 +639,8 @@ Inline(IsIntTerm, int, Term, t, CHKTAG((t), NumberTag))
|
||||
#ifdef TAGS_FAST_OPS
|
||||
#define IntInBnd(X) (Unsigned( ( (Int)(X) >> (32-7) ) + 1) <= 1)
|
||||
#else
|
||||
#define IntInBnd(X) ( (X) < (Int)MAX_ABS_INT && \
|
||||
(X) > -(Int)MAX_ABS_INT-1 )
|
||||
#define IntInBnd(X) ( (X) < (MAX_ABS_INT) && \
|
||||
(X) > (-MAX_ABS_INT)-1 )
|
||||
#endif
|
||||
#endif
|
||||
#ifdef C_PROLOG
|
||||
|
10
pl/boot.yap
10
pl/boot.yap
@ -1160,11 +1160,6 @@ catch(G,C,A) :-
|
||||
'$erase_catch_elements'(I),
|
||||
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) :-
|
||||
array_element('$catch_queue', 0, OldCatch),
|
||||
update_array('$catch_queue', 0, catch(X,I,OldCatch)),
|
||||
@ -1222,6 +1217,11 @@ catch(G,C,A) :-
|
||||
'$erase_catch_elements'(OldCatch, I, 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) :-
|
||||
array_element('$catch_queue', 0, OldCatch),
|
||||
update_array('$catch_queue', 0, catch(X,I,OldCatch)),
|
||||
|
@ -756,6 +756,7 @@ debugging :-
|
||||
'$execute'(M:Goal).
|
||||
'$creep'(G) :-
|
||||
'$get_value'('$throw', true), !,
|
||||
'$set_value'('$throw', false),
|
||||
abort.
|
||||
'$creep'([Module|'$trace'(P,G,L)]) :- !,
|
||||
( Module=prolog -> '$trace'(P,G,L);
|
||||
|
Reference in New Issue
Block a user