WIN32 support

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1790 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2007-01-28 14:26:37 +00:00
parent 1583990b8f
commit 47765f7739
14 changed files with 89 additions and 68 deletions

View File

@ -196,9 +196,9 @@ p_uminus(Term t E_ARGS)
switch (BlobOfFunctor(f)) {
case long_int_e:
{
#ifdef USE_GMP
Int i = IntegerOfTerm(t);
#ifdef USE_GMP
if (i == Int_MIN) {
MP_INT *new = TMP_BIG();

View File

@ -10,8 +10,12 @@
* File: c_interface.c *
* comments: c_interface primitives definition *
* *
* Last rev: $Date: 2007-01-08 08:27:19 $,$Author: vsc $ *
* Last rev: $Date: 2007-01-28 14:26:36 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.88 2007/01/08 08:27:19 vsc
* fix restore (Trevor)
* make indexing a bit faster on IDB
*
* Revision 1.87 2006/12/13 16:10:14 vsc
* several debugger and CLP(BN) improvements.
*
@ -304,7 +308,7 @@ X_API void STD_PROTO(YAP_PruneGoal,(void));
X_API void STD_PROTO(YAP_InitConsult,(int, char *));
X_API void STD_PROTO(YAP_EndConsult,(void));
X_API Term STD_PROTO(YAP_Read, (int (*)(void)));
X_API void STD_PROTO(YAP_Write, (Term, wchar_t (*)(wchar_t), int));
X_API void STD_PROTO(YAP_Write, (Term, int (*)(wchar_t), int));
X_API Term STD_PROTO(YAP_WriteBuffer, (Term, char *, unsigned int, int));
X_API char *STD_PROTO(YAP_CompileClause, (Term));
X_API void STD_PROTO(YAP_PutValue, (Atom,Term));
@ -354,9 +358,9 @@ static int do_yap_getc(int streamno) {
return(do_getf());
}
static wchar_t (*do_putcf)(wchar_t);
static int (*do_putcf)(wchar_t);
static wchar_t do_yap_putc(int streamno,wchar_t ch) {
static int do_yap_putc(int streamno,wchar_t ch) {
do_putcf(ch);
return(ch);
}
@ -1046,7 +1050,7 @@ YAP_Error(int myerrno, Term t, char *buf,...)
Yap_Error(myerrno,t,tmpbuf);
}
static wchar_t myputc (wchar_t ch)
static int myputc (wchar_t ch)
{
putc(ch,stderr);
return ch;
@ -1197,11 +1201,11 @@ YAP_Read(int (*mygetc)(void))
}
X_API void
YAP_Write(Term t, wchar_t (*myputc)(wchar_t), int flags)
YAP_Write(Term t, int (*myputc)(wchar_t), int flags)
{
BACKUP_MACHINE_REGS();
do_putcf = myputc;
do_putcf = myputc; /* */
Yap_plwrite (t, do_yap_putc, flags);
RECOVER_MACHINE_REGS();

View File

@ -176,14 +176,14 @@ GrowDelayArena(Term *arenap, UInt old_size, UInt size, UInt arity)
if (size < 64) {
size = 64;
}
XREGS[arity+1] = (CELL)arenap;
/* just make sure we are shifted up when we expand stacks */
XREGS[arity+1] = arena;
if ((howmuch = Yap_InsertInGlobal((CELL *)arena, (size-old_size)*sizeof(attvar_record)))==0) {
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
return TermNil;
}
size = howmuch/sizeof(attvar_record)+old_size;
arenap = (CELL *)XREGS[arity+1];
arena = *arenap;
arena = XREGS[arity+1];
CreateDelayArena(DelayArenaPt(arena), DelayArenaPt(arena)-size);
return arena;
}

View File

@ -599,7 +599,7 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
return FALSE;
else if (hsplit == (CELL *)omax)
hsplit = NULL;
if (size+H < ASP+4096 &&
if (size+H < ASP-4096 &&
hsplit > H0) {
/* don't need to expand stacks */
do_grow = FALSE;
@ -620,7 +620,8 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
if (!Yap_ExtendWorkSpace(size)) {
/* always fails when using malloc */
Yap_ErrorMessage = NULL;
size += AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap); minimal_request = size;
size += AdjustPageSize(((CELL)Yap_TrailTop-(CELL)Yap_GlobalBase)+MinHeapGap);
minimal_request = size;
size = Yap_ExtendWorkSpaceThroughHole(size);
if (size < 0) {
Yap_ErrorMessage = "Global Stack crashed against Local Stack";
@ -717,7 +718,10 @@ static_growglobal(long size, CELL **ptr, CELL *hsplit)
fprintf(Yap_stderr, "%% %cO Total of %g sec expanding stacks \n", vb_msg1, (double)total_delay_overflow_time/1000);
}
Yap_PrologMode &= ~GrowStackMode;
return size;
if (hsplit)
return GDiff-GDiff0;
else
return GDiff-DelayDiff;
}
static void

View File

@ -11,8 +11,12 @@
* File: index.c *
* comments: Indexing a Prolog predicate *
* *
* Last rev: $Date: 2007-01-08 08:27:19 $,$Author: vsc $ *
* Last rev: $Date: 2007-01-28 14:26:36 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.181 2007/01/08 08:27:19 vsc
* fix restore (Trevor)
* make indexing a bit faster on IDB
*
* Revision 1.180 2006/12/27 01:32:37 vsc
* diverse fixes
*
@ -6269,7 +6273,7 @@ remove_clause_from_index(yamop *header, LogUpdClause *cl)
newp->opc = curp->opc;
*prevp = newp;
} else {
yamop *ocurp, *ocurp0 = curp;
yamop *ocurp = NULL, *ocurp0 = curp;
while (curp->u.lld.d != cl) {
ocurp = curp;

View File

@ -83,7 +83,7 @@ static char SccsId[] = "%W% %G%";
STATIC_PROTO (Int PlIOError, (yap_error_number, Term, char *));
STATIC_PROTO (int FilePutc, (int, int));
STATIC_PROTO (int MemPutc, (int, int));
STATIC_PROTO (int console_post_process_read_char, (wchar_t, StreamDesc *));
STATIC_PROTO (int console_post_process_read_char, (int, StreamDesc *));
STATIC_PROTO (int console_post_process_eof, (StreamDesc *));
STATIC_PROTO (int post_process_read_char, (int, StreamDesc *));
STATIC_PROTO (int post_process_eof, (StreamDesc *));
@ -101,7 +101,7 @@ STATIC_PROTO (int PlGetc, (int));
STATIC_PROTO (int DefaultGets, (int,UInt,char*));
STATIC_PROTO (int PlGets, (int,UInt,char*));
STATIC_PROTO (int MemGetc, (int));
STATIC_PROTO (wchar_t ISOWGetc, (int));
STATIC_PROTO (int ISOWGetc, (int));
STATIC_PROTO (int ConsoleGetc, (int));
STATIC_PROTO (int PipeGetc, (int));
STATIC_PROTO (int ConsolePipeGetc, (int));
@ -168,8 +168,8 @@ STATIC_PROTO (Int p_startline, (void));
STATIC_PROTO (Int p_change_type_of_char, (void));
STATIC_PROTO (Int p_type_of_char, (void));
STATIC_PROTO (void CloseStream, (int));
STATIC_PROTO (wchar_t get_wchar, (int));
STATIC_PROTO (wchar_t put_wchar, (int,wchar_t));
STATIC_PROTO (int get_wchar, (int));
STATIC_PROTO (int put_wchar, (int,wchar_t));
static encoding_t
DefaultEncoding(void)
@ -669,7 +669,7 @@ Yap_DebugGetc()
}
int
Yap_DebugPutc(int sno, int ch)
Yap_DebugPutc(int sno, wchar_t ch)
{
if (Yap_Option['l' - 96])
(void) putc(ch, Yap_logfile);
@ -1075,7 +1075,7 @@ ReadlineGetc(int sno)
int
Yap_GetCharForSIGINT(void)
{
wchar_t ch;
int ch;
#if HAVE_LIBREADLINE
if ((Yap_PrologMode & ConsoleGetcMode) && myrl_line != (char *) NULL) {
ch = myrl_line[0];
@ -1205,7 +1205,7 @@ post_process_eof(StreamDesc *s)
/* check if we read a newline or an EOF */
static int
console_post_process_read_char(wchar_t ch, StreamDesc *s)
console_post_process_read_char(int ch, StreamDesc *s)
{
if (ch == '\n') {
++s->linecount;
@ -1279,7 +1279,7 @@ static int
ConsoleSocketGetc(int sno)
{
register StreamDesc *s = &Stream[sno];
register wchar_t ch;
register int ch;
Int c;
int count;
@ -1349,8 +1349,8 @@ PipeGetc(int sno)
static int
ConsolePipeGetc(int sno)
{
register StreamDesc *s = &Stream[sno];
register wchar_t ch;
StreamDesc *s = &Stream[sno];
int ch;
char c;
#if _MSC_VER || defined(__MINGW32__)
DWORD count;
@ -1463,10 +1463,10 @@ MemGetc (int sno)
}
/* I dispise this code!!!!! */
static wchar_t
static int
ISOWGetc (int sno)
{
Int ch = Stream[sno].stream_wgetc(sno);
int ch = Stream[sno].stream_wgetc(sno);
if (ch != EOF && CharConversionTable != NULL) {
if (ch < NUMBER_OF_CHARS) {
@ -1572,11 +1572,11 @@ utf8_nof(char ch)
return 5;
}
static wchar_t
static int
get_wchar(int sno)
{
wchar_t wch;
int ch;
wchar_t wch;
int how_many = 0;
while (TRUE) {
@ -1671,7 +1671,7 @@ get_wchar(int sno)
#define MB_LEN_MAX 6
#endif
static wchar_t
static int
put_wchar(int sno, wchar_t ch)
{
@ -1714,7 +1714,8 @@ put_wchar(int sno, wchar_t ch)
if (ch < 0x800) {
Stream[sno].stream_putc(sno, 0xC0 | ch>>6);
return Stream[sno].stream_putc(sno, 0x80 | (ch & 0x3F));
} else if (ch < 0x10000) {
}
else if (ch < 0x10000) {
Stream[sno].stream_putc(sno, 0xE0 | ch>>12);
Stream[sno].stream_putc(sno, 0x80 | (ch>>6 & 0x3F));
return Stream[sno].stream_putc(sno, 0x80 | (ch & 0x3F));
@ -1723,7 +1724,8 @@ put_wchar(int sno, wchar_t ch)
Stream[sno].stream_putc(sno, 0x80 | (ch>>12 & 0x3F));
Stream[sno].stream_putc(sno, 0x80 | (ch>>6 & 0x3F));
return Stream[sno].stream_putc(sno, 0x80 | (ch & 0x3F));
} else {
}
else {
/* should never happen */
return -1;
}
@ -1747,7 +1749,7 @@ Yap_PlGetchar (void)
return(Stream[Yap_c_input_stream].stream_getc(Yap_c_input_stream));
}
wchar_t
int
Yap_PlGetWchar (void)
{
return get_wchar(Yap_c_input_stream);
@ -3926,7 +3928,7 @@ static Int
p_get (void)
{ /* '$get'(Stream,-N) */
int sno = CheckStream (ARG1, Input_Stream_f, "get/2");
wchar_t ch;
int ch;
Int status;
if (sno < 0)
@ -4094,7 +4096,7 @@ typedef struct format_status {
pads pad_entries[16], *pad_max;
} format_info;
static wchar_t
static int
format_putc(int sno, wchar_t ch) {
if (FormatInfo->format_buf_size == -1)
return EOF;
@ -4200,7 +4202,7 @@ static void fill_pads(int nchars)
}
static int
format_print_str (Int sno, Int size, Int has_size, Term args, wchar_t (* f_putc)(int, wchar_t))
format_print_str (Int sno, Int size, Int has_size, Term args, int (* f_putc)(int, wchar_t))
{
Term arghd;
while (!has_size || size > 0) {
@ -4377,7 +4379,7 @@ format(volatile Term otail, volatile Term oargs, int sno)
char *fstr = NULL, *fptr;
Term args;
Term tail;
wchar_t (* f_putc)(int, wchar_t);
int (* f_putc)(int, wchar_t);
int has_tabs;
jmp_buf format_botch;
volatile void *old_handler;
@ -4979,7 +4981,7 @@ p_skip (void)
{ /* '$skip'(Stream,N) */
int sno = CheckStream (ARG1, Input_Stream_f, "skip/2");
Int n = IntOfTerm (Deref (ARG2));
wchar_t ch;
int ch;
if (sno < 0)
return (FALSE);

View File

@ -57,7 +57,7 @@
STATIC_PROTO(int my_getch, (int (*) (int)));
STATIC_PROTO(Term float_send, (char *));
STATIC_PROTO(Term get_num, (wchar_t *, wchar_t *, int, wchar_t (*) (int), wchar_t (*) (int),char *,UInt));
STATIC_PROTO(Term get_num, (int *, int *, int, int (*) (int), int (*) (int),char *,UInt));
/* token table with some help from Richard O'Keefe's PD scanner */
static char chtype0[NUMBER_OF_CHARS+1] =
@ -232,7 +232,7 @@ read_int_overflow(const char *s, Int base, Int val)
}
static wchar_t
read_quoted_char(int *scan_nextp, int inp_stream, wchar_t (*QuotedNxtch)(int))
read_quoted_char(int *scan_nextp, int inp_stream, int (*QuotedNxtch)(int))
{
int ch;
@ -455,7 +455,7 @@ read_quoted_char(int *scan_nextp, int inp_stream, wchar_t (*QuotedNxtch)(int))
/* reads a number, either integer or float */
static Term
get_num(wchar_t *chp, wchar_t *chbuffp, int inp_stream, wchar_t (*Nxtch) (int), wchar_t (*QuotedNxtch) (int), char *s, UInt max_size)
get_num(int *chp, int *chbuffp, int inp_stream, int (*Nxtch) (int), int (*QuotedNxtch) (int), char *s, UInt max_size)
{
char *sp = s;
int ch = *chp;
@ -669,11 +669,11 @@ get_num(wchar_t *chp, wchar_t *chbuffp, int inp_stream, wchar_t (*Nxtch) (int),
/* given a function Nxtch scan until we either find the number
or end of file */
Term
Yap_scan_num(wchar_t (*Nxtch) (int))
Yap_scan_num(int (*Nxtch) (int))
{
Term out;
int sign = 1;
wchar_t ch, cherr;
int ch, cherr;
char *ptr;
Yap_ErrorMessage = NULL;
@ -698,7 +698,7 @@ Yap_scan_num(wchar_t (*Nxtch) (int))
cherr = '\0';
if (ASP-H < 1024)
return TermNil;
out = get_num(&ch, &cherr, -1, Nxtch, Nxtch, ptr, 4096);
out = get_num(&ch, &cherr, -1, Nxtch, Nxtch, ptr, 4096); /* */
PopScannerMemory(ptr, 4096);
if (sign == -1) {
if (IsIntegerTerm(out))
@ -709,7 +709,7 @@ Yap_scan_num(wchar_t (*Nxtch) (int))
Yap_clean_tokenizer(NULL, NULL, NULL);
if (Yap_ErrorMessage != NULL || ch != -1 || cherr)
return TermNil;
return(out);
return out;
}
@ -736,9 +736,10 @@ Yap_tokenizer(int inp_stream)
TokEntry *t, *l, *p;
enum TokenKinds kind;
int solo_flag = TRUE;
wchar_t ch, *wcharp;
wchar_t (*Nxtch) (int) = Stream[inp_stream].stream_wgetc_for_read;
wchar_t (*QuotedNxtch) (int) = Stream[inp_stream].stream_wgetc;
int ch;
wchar_t *wcharp;
int (*Nxtch) (int) = Stream[inp_stream].stream_wgetc_for_read;
int (*QuotedNxtch) (int) = Stream[inp_stream].stream_wgetc;
Yap_ErrorMessage = NULL;
Yap_Error_Size = 0;
@ -844,8 +845,8 @@ Yap_tokenizer(int inp_stream)
case NU:
{
wchar_t cherr;
wchar_t cha = ch;
int cherr;
int cha = ch;
char *ptr;
cherr = 0;

View File

@ -11,8 +11,11 @@
* File: stdpreds.c *
* comments: General-purpose C implemented system predicates *
* *
* Last rev: $Date: 2006-12-13 16:10:23 $,$Author: vsc $ *
* Last rev: $Date: 2007-01-28 14:26:37 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.116 2006/12/13 16:10:23 vsc
* several debugger and CLP(BN) improvements.
*
* Revision 1.115 2006/11/28 13:46:41 vsc
* fix wide_char support for name/2.
*
@ -638,13 +641,13 @@ strtod(s, pe)
static char *cur_char_ptr;
static wchar_t
static int
get_char_from_string(int s)
{
if (cur_char_ptr[0] == '\0')
return(-1);
return -1;
cur_char_ptr++;
return((wchar_t)(cur_char_ptr[-1]));
return cur_char_ptr[-1];
}

View File

@ -42,7 +42,7 @@ typedef enum {
static wtype lastw;
typedef wchar_t (*wrf) (int, wchar_t);
typedef int (*wrf) (int, wchar_t);
typedef struct write_globs {
wrf writewch;
@ -798,7 +798,7 @@ writeTerm(Term t, int p, int depth, int rinfixarg, struct write_globs *wglb)
}
void
Yap_plwrite(Term t, wchar_t (*mywrite) (int, wchar_t), int flags)
Yap_plwrite(Term t, int (*mywrite) (int, wchar_t), int flags)
/* term to be written */
/* consumer */
/* write options */

View File

@ -10,7 +10,7 @@
* File: Yap.proto *
* mods: *
* comments: Function declarations for YAP *
* version: $Id: Yapproto.h,v 1.77 2006-12-13 16:10:25 vsc Exp $ *
* version: $Id: Yapproto.h,v 1.78 2007-01-28 14:26:37 vsc Exp $ *
*************************************************************************/
/* prototype file for Yap */
@ -188,7 +188,7 @@ int STD_PROTO(Yap_gcl, (UInt, Int, CELL *, yamop *));
/* init.c */
#ifdef DEBUG
int STD_PROTO(Yap_DebugPutc,(int,int));
int STD_PROTO(Yap_DebugPutc,(int,wchar_t));
void STD_PROTO(Yap_DebugSetIFile,(char *));
void STD_PROTO(Yap_DebugEndline,(void));
int STD_PROTO(Yap_DebugGetc,(void));

View File

@ -87,9 +87,9 @@ typedef struct stream_desc
GetsFunc stream_gets; /* function the stream uses for reading a sequence of characters */
/* function the stream uses for parser. It may be different if the ISO
character conversion is on */
wchar_t (* stream_wgetc_for_read)(int);
wchar_t (* stream_wgetc)(int);
wchar_t (* stream_wputc)(int,wchar_t);
int (* stream_wgetc_for_read)(int);
int (* stream_wgetc)(int);
int (* stream_wputc)(int,wchar_t);
encoding_t encoding;
int use_bom;
mbstate_t mbstate;

View File

@ -273,7 +273,7 @@ Term STD_PROTO(Yap_VarNames,(VarEntry *,Term));
/* routines in scanner.c */
TokEntry STD_PROTO(*Yap_tokenizer,(int));
void STD_PROTO(Yap_clean_tokenizer,(TokEntry *, VarEntry *, VarEntry *));
Term STD_PROTO(Yap_scan_num,(wchar_t (*)(int)));
Term STD_PROTO(Yap_scan_num,(int (*)(int)));
char STD_PROTO(*Yap_AllocScannerMemory,(unsigned int));
/* routines in iopreds.c */
@ -283,7 +283,7 @@ int STD_PROTO(Yap_GetStreamFd,(int));
void STD_PROTO(Yap_CloseStreams,(int));
void STD_PROTO(Yap_CloseStream,(int));
int STD_PROTO(Yap_PlGetchar,(void));
wchar_t STD_PROTO(Yap_PlGetWchar,(void));
int STD_PROTO(Yap_PlGetWchar,(void));
int STD_PROTO(Yap_PlFGetchar,(void));
int STD_PROTO(Yap_GetCharForSIGINT,(void));
int STD_PROTO(Yap_StreamToFileNo,(Term));
@ -319,7 +319,7 @@ extern int
#define To_heap_f 16
/* write.c */
void STD_PROTO(Yap_plwrite,(Term,wchar_t (*)(int, wchar_t),int));
void STD_PROTO(Yap_plwrite,(Term,int (*)(int, wchar_t),int));
/* grow.c */
int STD_PROTO(Yap_growstack_in_parser, (tr_fr_ptr *, TokEntry **, VarEntry **));

View File

@ -16,6 +16,8 @@
<h2>Yap-5.1.2:</h2>
<ul>
<li> FIXED: wchar_t in the WIN32 is unsigned and 16 bits.</li>
<li> FIXED: stack overflow when growing the delay stack.</li>
<li> FIXED: overflows with MIN_INT (obs from Marius Filip).</li>
<li> NEW: make debugger more like standard debuggers (obs from Miguel Filgueiras).</li>
<li> NEW: glist_void_varx was broken (obs from Marius Filip).</li>

View File

@ -155,8 +155,9 @@ true :- true.
'$system_catch'('$query'(once(G), []),Module,Error,user:'$Error'(Error)),
fail.
'$startup_goals' :-
get_value('$init_goal',GA), GA \= [],
set_value('$init_goal',[]),
get_value('$init_goal',GA),
GA \= [],
set_value('$init_goal',[]),
'$run_atom_goal'(GA),
fail.
'$startup_goals' :-