diff --git a/C/errors.c b/C/errors.c old mode 100644 new mode 100755 index a7d00c897..b4b688bf1 --- a/C/errors.c +++ b/C/errors.c @@ -299,7 +299,11 @@ dump_stack( USES_REGS1 ) extern long long vsc_count; if (vsc_count) { +#if _WIN32 + fprintf(stderr,"Trace Counter at %I64d\n",vsc_count); +#else fprintf(stderr,"Trace Counter at %lld\n",vsc_count); +#endif } } #endif diff --git a/H/rheap.h b/H/rheap.h index b35719d3a..adbfc44c1 100755 --- a/H/rheap.h +++ b/H/rheap.h @@ -249,6 +249,8 @@ static char SccsId[] = "@(#)rheap.c 1.3 3/15/90"; #define RestoreForeignCode() RestoreForeignCode__( PASS_REGS1 ) #define RestoreAtoms() RestoreAtoms__( PASS_REGS1 ) #define RestoreWideAtoms() RestoreWideAtoms__( PASS_REGS1 ) +#define RestoreSWIBlobs() RestoreSWIBlobs__( PASS_REGS1 ) +#define RestoreSWIBlobTypes() RestoreSWIBlobTypes__( PASS_REGS1 ) #define RestoreInvisibleAtoms() RestoreInvisibleAtoms__( PASS_REGS1 ) #define RestorePredHash() RestorePredHash__( PASS_REGS1 ) #define RestoreDBTermsList() RestoreDBTermsList__( PASS_REGS1 ) @@ -701,13 +703,15 @@ RestoreSWIAtoms__( USES_REGS1 ) } static void -RestoreSWIBlobTypes(void) +RestoreSWIBlobTypes__( USES_REGS1 ) { } static void -RestoreSWIBlobs(void) +RestoreSWIBlobs__( USES_REGS1 ) { + SWI_Blobs = AtomAdjust(SWI_Blobs); + RestoreAtomList(SWI_Blobs PASS_REGS); } static void diff --git a/Makefile.in b/Makefile.in index 71d691c1c..f36ebaa98 100755 --- a/Makefile.in +++ b/Makefile.in @@ -131,7 +131,7 @@ IOLIB_HEADERS=$(srcdir)/packages/PLStream/atoms.h $(srcdir)/packages/PLStream/pl $(srcdir)/packages/PLStream/pl-stream.h \ $(srcdir)/packages/PLStream/pl-table.h \ $(srcdir)/packages/PLStream/pl-text.h $(srcdir)/pl-utf8.h \ - $(srcdir)/packages/PLStream/pl-yap.h @ENABLE_WINCONSOLE@ $(srcdir)/packages/PLStream/uxnt/dirent.h $(srcdir)/packages/PLStream/uxnt/utf8.h $(srcdir)/packages/PLStream/pl-utf8.c $(srcdir)/packages/PLStream/uxnt/uxnt.h + $(srcdir)/packages/PLStream/pl-yap.h @ENABLE_WINCONSOLE@ $(srcdir)/packages/PLStream/windows/dirent.h $(srcdir)/packages/PLStream/windows/utf8.h $(srcdir)/packages/PLStream/pl-utf8.c $(srcdir)/packages/PLStream/windows/windows.h HEADERS = \ $(srcdir)/H/TermExt.h \ @@ -212,7 +212,7 @@ IOLIB_SOURCES=$(srcdir)/packages/PLStream/pl-buffer.c $(srcdir)/packages/PLStrea $(srcdir)/packages/PLStream/pl-table.c \ $(srcdir)/packages/PLStream/pl-text.c \ $(srcdir)/packages/PLStream/pl-write.c \ - $(srcdir)/packages/PLStream/pl-yap.c @ENABLE_WINCONSOLE@ $(srcdir)/packages/PLStream/popen.c $(srcdir)/packages/PLStream/uxnt/uxnt.c + $(srcdir)/packages/PLStream/pl-yap.c @ENABLE_WINCONSOLE@ $(srcdir)/packages/PLStream/popen.c $(srcdir)/packages/PLStream/windows/windows.c C_SOURCES= \ $(IOLIB_SOURCES) \ @@ -596,7 +596,7 @@ pl-read.o: $(srcdir)/packages/PLStream/pl-read.c $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream $(srcdir)/packages/PLStream/pl-read.c -o $@ pl-stream.o: $(srcdir)/packages/PLStream/pl-stream.c - $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream $(srcdir)/packages/PLStream/pl-stream.c -o $@ + $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream -I$(srcdir)/packages/PLStream/windows $(srcdir)/packages/PLStream/pl-stream.c -o $@ pl-string.o: $(srcdir)/packages/PLStream/pl-string.c $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream $(srcdir)/packages/PLStream/pl-string.c -o $@ @@ -616,6 +616,9 @@ pl-write.o: $(srcdir)/packages/PLStream/pl-write.c pl-yap.o: $(srcdir)/packages/PLStream/pl-yap.c $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream $(srcdir)/packages/PLStream/pl-yap.c -o $@ +uxnt.o: $(srcdir)/packages/PLStream/windows/uxnt.c + $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir) -I$(srcdir)/packages/PLStream $(srcdir)/packages/PLStream/windows/uxnt.c -o $@ + # default rule %.o : $(srcdir)/C/%.c config.h $(CC) -c $(CFLAGS) $< -o $@ diff --git a/library/system/sys.c b/library/system/sys.c old mode 100644 new mode 100755 index 3bbfb98ad..768527770 --- a/library/system/sys.c +++ b/library/system/sys.c @@ -867,44 +867,6 @@ p_wait(void) #endif } -/* execute a command as a detached process */ -static int -p_popen(void) -{ - char *command = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); - long int mode = YAP_IntOfTerm(YAP_ARG2); - FILE *pfd; - YAP_Term tsno; - int flags; - -#if HAVE_POPEN -#if defined(__MINGW32__) || _MSC_VER - /* This will only work for console applications. FIX */ - if (mode == 0) - pfd = _popen(command, "r"); - else - pfd = _popen(command, "w"); -#else - if (mode == 0) - pfd = popen(command, "r"); - else - pfd = popen(command, "w"); -#endif - if (pfd == NULL) { - return(YAP_Unify(YAP_ARG4, YAP_MkIntTerm(errno))); - } - if (mode == 0) - flags = YAP_INPUT_STREAM | YAP_POPEN_STREAM; - else - flags = YAP_OUTPUT_STREAM | YAP_POPEN_STREAM; - tsno = YAP_OpenStream((void *)pfd, - "pipe", - YAP_MkAtomTerm(YAP_LookupAtom("pipe")), - flags); -#endif - return(YAP_Unify(YAP_ARG3, tsno)); -} - static int p_sleep(void) { @@ -1058,7 +1020,6 @@ init_sys(void) YAP_UserCPredicate("exec_command", execute_command, 6); YAP_UserCPredicate("do_shell", do_shell, 5); YAP_UserCPredicate("do_system", do_system, 3); - YAP_UserCPredicate("popen", p_popen, 4); YAP_UserCPredicate("wait", p_wait, 3); YAP_UserCPredicate("host_name", host_name, 2); YAP_UserCPredicate("host_id", host_id, 2); diff --git a/packages/CLPBN/clpbn/bp/Horus.cpp b/packages/CLPBN/clpbn/bp/Horus.cpp old mode 100644 new mode 100755 index 3e8058d36..43770b689 --- a/packages/CLPBN/clpbn/bp/Horus.cpp +++ b/packages/CLPBN/clpbn/bp/Horus.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include diff --git a/packages/PLStream/pl-dtoa.c b/packages/PLStream/pl-dtoa.c old mode 100644 new mode 100755 index c455d8d63..e05a5c549 --- a/packages/PLStream/pl-dtoa.c +++ b/packages/PLStream/pl-dtoa.c @@ -30,7 +30,7 @@ #define MALLOC PL_malloc #define FREE PL_free -#if defined(_REENTRANT)||defined(__YAP_PROLOG__) +#if defined(_REENTRANT)||( defined(__YAP_PROLOG__) && defined(THREADS)) #define Long int /* 32-bits */ #define MULTIPLE_THREADS diff --git a/packages/PLStream/pl-file.c b/packages/PLStream/pl-file.c index 12211dc32..5dff861f1 100755 --- a/packages/PLStream/pl-file.c +++ b/packages/PLStream/pl-file.c @@ -1796,7 +1796,7 @@ error: return FALSE; } -#ifdef __WINDOWS__ /* defined in pl-nt.c */ +#if defined(__WINDOWS__) && !defined(__MINGW32__) /* defined in pl-nt.c */ extern int ftruncate(int fileno, int64_t length); #define HAVE_FTRUNCATE #endif @@ -4696,7 +4696,7 @@ static const PL_extension foreigns[] = { struct PL_local_data *Yap_InitThreadIO(int wid) { - struct PL_local_data *p = (struct PL_local_data *)malloc(sizeof(struct PL_local_data)); + struct PL_local_data *p = (struct PL_local_data *)calloc(sizeof(struct PL_local_data), 1); if (!p) { Yap_Error(OUT_OF_HEAP_ERROR, 0L, "Creating thread %d\n", wid); } diff --git a/packages/PLStream/pl-files.c b/packages/PLStream/pl-files.c index 949cead1b..97a84cb27 100755 --- a/packages/PLStream/pl-files.c +++ b/packages/PLStream/pl-files.c @@ -808,6 +808,9 @@ PRED_IMPL("make_directory", 1, make_directory, 0) if ( !PL_get_file_name(A1, &n, 0) ) return FALSE; +#if __MINGW32__ +#define mkdir(A, B) mkdir(A) +#endif if ( mkdir(n, 0777) == 0 ) return TRUE; else diff --git a/packages/PLStream/pl-fmt.c b/packages/PLStream/pl-fmt.c old mode 100644 new mode 100755 index 45d376ba0..a4484d040 --- a/packages/PLStream/pl-fmt.c +++ b/packages/PLStream/pl-fmt.c @@ -33,7 +33,7 @@ source should also use format() to produce error messages, etc. #include static char * formatNumber(bool split, int div, int radix, - bool small, Number n, Buffer out); + bool smll, Number n, Buffer out); static char * formatFloat(int how, int arg, Number f, Buffer out); #define MAXRUBBER 100 @@ -877,7 +877,7 @@ emit_rubber(format_state *state) ** Fri Aug 19 22:26:41 1988 jan@swivax.UUCP (Jan Wielemaker) */ static char * -formatNumber(bool split, int div, int radix, bool small, Number i, +formatNumber(bool split, int div, int radix, bool smll, Number i, Buffer out) { switch(i->type) { case V_INTEGER: @@ -912,7 +912,7 @@ formatNumber(bool split, int div, int radix, bool small, Number i, } if ( split && before && (digits++ % 3) == 0 && digits != 1 ) *--s = ','; - *--s = digitName((int)(n % radix), small); + *--s = digitName((int)(n % radix), smll); n /= radix; } if ( negative ) @@ -937,7 +937,7 @@ formatNumber(bool split, int div, int radix, bool small, Number i, buf = tmp; mpz_get_str(buf, radix, i->value.mpz); - if ( !small && radix > 10 ) + if ( !smll && radix > 10 ) { char *s; for(s=buf; *s; s++) diff --git a/packages/PLStream/pl-incl.h b/packages/PLStream/pl-incl.h index d352b0a47..ba62a5958 100755 --- a/packages/PLStream/pl-incl.h +++ b/packages/PLStream/pl-incl.h @@ -138,6 +138,9 @@ typedef enum #if HAVE_SYS_PARAM_H #include //MAXPATHLEN #endif +#ifdef __WINDOWS__ +#include +#endif #if __YAP_PROLOG__ #include "pl-yap.h" #if _WIN32 @@ -590,6 +593,8 @@ typedef double real; #define XOS_DOWNCASE 0x01 /* _xos_canonical_filename() */ +#define statfunc stat + #ifndef __WINDOWS__ #define __WINDOWS__ 1 #endif @@ -728,17 +733,17 @@ extern void RemoveTemporaryFiles(void); extern int Pause(real t); char *findExecutable(const char *av0, char *buffer); -void setOSPrologFlags(void); -void setRandom(unsigned int *seedp); -char *canoniseFileName(char *path); -char *canonisePath(char *path); -void PL_changed_cwd(void); -struct tm *LocalTime(long *t, struct tm *r); -size_t getenv3(const char *name, char *buf, size_t len); -int Setenv(char *name, char *value); -int Unsetenv(char *name); -int System(char *cmd); -bool expandVars(const char *pattern, char *expanded, int maxlen); +extern void setOSPrologFlags(void); +extern void setRandom(unsigned int *seedp); +extern char *canoniseFileName(char *path); +extern char *canonisePath(char *path); +extern void PL_changed_cwd(void); +extern struct tm *LocalTime(long *t, struct tm *r); +extern size_t getenv3(const char *name, char *buf, size_t len); +extern int Setenv(char *name, char *value); +extern int Unsetenv(char *name); +extern int System(char *cmd); +extern bool expandVars(const char *pattern, char *expanded, int maxlen); /**** SWI stuff (emulated in pl-yap.c) ****/ extern int writeAtomToStream(IOSTREAM *so, atom_t at); @@ -757,7 +762,7 @@ PL_EXPORT(int) PL_get_file_nameW(term_t n, wchar_t **name, int flags); COMMON(int) unifyTime(term_t t, time_t time); -COMMON(char) digitName(int n, int small); +COMMON(char) digitName(int n, int sm); /**** stuff from pl-utf8.c ****/ size_t utf8_strlen(const char *s, size_t len); diff --git a/packages/PLStream/pl-rl.c b/packages/PLStream/pl-rl.c old mode 100644 new mode 100755 index ed5fdc55f..67e76a627 --- a/packages/PLStream/pl-rl.c +++ b/packages/PLStream/pl-rl.c @@ -40,7 +40,7 @@ SWI-Prolog.h and SWI-Stream.h #include "SWI-Stream.h" #include "SWI-Prolog.h" -#ifdef __WINDOWS__ +#if defined(__WINDOWS__) && !defined(__YAP_PROLOG__) #ifdef WIN64 #include "config/win64.h" #else diff --git a/packages/PLStream/pl-stream.c b/packages/PLStream/pl-stream.c index 30298229f..7d5f31451 100755 --- a/packages/PLStream/pl-stream.c +++ b/packages/PLStream/pl-stream.c @@ -22,13 +22,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifdef __WINDOWS__ +#if defined(__WINDOWS__)||defined(__WIN32) #include +#ifndef _YAP_NOT_INSTALLED_ #ifdef WIN64 #define MD "config/win64.h" #else #define MD "config/win32.h" #endif +#endif #include #include "windows/mswchar.h" #define CRLF_MAPPING 1 diff --git a/packages/PLStream/pl-string.c b/packages/PLStream/pl-string.c old mode 100644 new mode 100755 index e5744726b..39a2d83ee --- a/packages/PLStream/pl-string.c +++ b/packages/PLStream/pl-string.c @@ -102,10 +102,10 @@ remove_string(char *s) ** Fri Jun 10 10:45:40 1988 jan@swivax.UUCP (Jan Wielemaker) */ char -digitName(int n, int small) +digitName(int n, int smll) { if (n <= 9) return n + '0'; - return n + (small ? 'a' : 'A') - 10; + return n + (smll ? 'a' : 'A') - 10; } diff --git a/packages/PLStream/pl-string.h b/packages/PLStream/pl-string.h old mode 100644 new mode 100755 index d6df1828f..f102045e9 --- a/packages/PLStream/pl-string.h +++ b/packages/PLStream/pl-string.h @@ -27,7 +27,7 @@ COMMON(char *) store_string(const char *s); COMMON(void) remove_string(char *s); -COMMON(char) digitName(int n, int small); +COMMON(char) digitName(int n, int smll); COMMON(int) digitValue(int b, int c); COMMON(bool) strprefix(const char *string, const char *prefix); COMMON(bool) strpostfix(const char *string, const char *postfix); diff --git a/packages/PLStream/uxnt/README b/packages/PLStream/windows/README similarity index 100% rename from packages/PLStream/uxnt/README rename to packages/PLStream/windows/README diff --git a/packages/PLStream/uxnt/dirent.h b/packages/PLStream/windows/dirent.h similarity index 100% rename from packages/PLStream/uxnt/dirent.h rename to packages/PLStream/windows/dirent.h diff --git a/packages/PLStream/windows/mswchar.h b/packages/PLStream/windows/mswchar.h new file mode 100755 index 000000000..f43d230a3 --- /dev/null +++ b/packages/PLStream/windows/mswchar.h @@ -0,0 +1,38 @@ +/* $Id$ + + Part of SWI-Prolog + + Author: Jan Wielemaker + E-mail: wielemak@science.uva.nl + WWW: http://www.swi-prolog.org + Copyright (C): 1985-2005, University of Amsterdam + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +See pl-mswchar.cpp for the motivation for this nonsense. Used in +pl-fli.c and pl-text.c. +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +#ifdef __WINDOWS__ +#define wcrtomb(s, wc, ps) ms_wcrtomb(s, wc, ps) +#define mbrtowc(pwc, s, n, ps) ms_mbrtowc(pwc, s, n, ps) + +extern size_t ms_wcrtomb(char *s, wchar_t wc, mbstate_t *ps); +extern size_t ms_mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); +#endif diff --git a/packages/PLStream/popen.c b/packages/PLStream/windows/popen.c old mode 100644 new mode 100755 similarity index 94% rename from packages/PLStream/popen.c rename to packages/PLStream/windows/popen.c index e18b67956..d1a253e86 --- a/packages/PLStream/popen.c +++ b/packages/PLStream/windows/popen.c @@ -61,7 +61,7 @@ DWORD RunSilent(const char* strCommand) char *pEnvCMD = NULL; char *pDefaultCMD = "CMD.EXE"; ULONG rc; - + memset(&StartupInfo, 0, sizeof(StartupInfo)); StartupInfo.cb = sizeof(STARTUPINFO); StartupInfo.dwFlags = STARTF_USESHOWWINDOW; @@ -71,25 +71,25 @@ DWORD RunSilent(const char* strCommand) pEnvCMD = getenv("COMSPEC"); - if(pEnvCMD){ + if(pEnvCMD){ strcpy(Args, pEnvCMD); } else{ strcpy(Args, pDefaultCMD); } /* "/c" option - Do the command then terminate the command window */ - strcat(Args, " /c "); + strcat(Args, " /c "); /*the application you would like to run from the command window */ - strcat(Args, strCommand); + strcat(Args, strCommand); if (!CreateProcess( NULL, Args, NULL, NULL, FALSE, - CREATE_NEW_CONSOLE, - NULL, + CREATE_NEW_CONSOLE, + NULL, NULL, &StartupInfo, &ProcessInfo)) { - return GetLastError(); + return GetLastError(); } WaitForSingleObject(ProcessInfo.hProcess, INFINITE); @@ -100,7 +100,7 @@ DWORD RunSilent(const char* strCommand) CloseHandle(ProcessInfo.hProcess); return rc; - + } /*------------------------------------------------------------------------------ @@ -271,15 +271,15 @@ pt_popen(const char *cmd, const char *mode) siStartInfo.dwFlags = STARTF_USESTDHANDLES; success = CreateProcessW(NULL, - wcmd, // command line - NULL, // process security attributes - NULL, // primary thread security attributes - TRUE, // handles are inherited + wcmd, // command line + NULL, // process security attributes + NULL, // primary thread security attributes + TRUE, // handles are inherited CREATE_NO_WINDOW, // creation flags: without window (?) - NULL, // use parent's environment - NULL, // use parent's current directory - &siStartInfo, // STARTUPINFO pointer - &piProcInfo); // receives PROCESS_INFORMATION + NULL, // use parent's environment + NULL, // use parent's current directory + &siStartInfo, // STARTUPINFO pointer + &piProcInfo); // receives PROCESS_INFORMATION if ( !success ) goto finito; diff --git a/packages/PLStream/uxnt/utf8.c b/packages/PLStream/windows/utf8.c similarity index 100% rename from packages/PLStream/uxnt/utf8.c rename to packages/PLStream/windows/utf8.c diff --git a/packages/PLStream/uxnt/utf8.h b/packages/PLStream/windows/utf8.h similarity index 100% rename from packages/PLStream/uxnt/utf8.h rename to packages/PLStream/windows/utf8.h diff --git a/packages/PLStream/uxnt/uxnt.c b/packages/PLStream/windows/uxnt.c similarity index 100% rename from packages/PLStream/uxnt/uxnt.c rename to packages/PLStream/windows/uxnt.c diff --git a/packages/PLStream/uxnt/uxnt.h b/packages/PLStream/windows/uxnt.h similarity index 100% rename from packages/PLStream/uxnt/uxnt.h rename to packages/PLStream/windows/uxnt.h diff --git a/packages/chr b/packages/chr deleted file mode 160000 index bf6525f85..000000000 --- a/packages/chr +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bf6525f85cfcf3c08fff8cf91fb189fe71dc34fd