WINDOWS compatibility
This commit is contained in:
parent
53137a2502
commit
a3f79cede9
4
C/errors.c
Normal file → Executable file
4
C/errors.c
Normal file → Executable file
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 $@
|
||||
|
39
library/system/sys.c
Normal file → Executable file
39
library/system/sys.c
Normal file → Executable file
@ -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);
|
||||
|
2
packages/CLPBN/clpbn/bp/Horus.cpp
Normal file → Executable file
2
packages/CLPBN/clpbn/bp/Horus.cpp
Normal file → Executable file
@ -3,7 +3,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <Yap/YapInterface.h>
|
||||
#include <YapInterface.h>
|
||||
|
||||
#include <BayesianNetwork.h>
|
||||
#include <BayesianNode.h>
|
||||
|
2
packages/PLStream/pl-dtoa.c
Normal file → Executable file
2
packages/PLStream/pl-dtoa.c
Normal file → Executable file
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
8
packages/PLStream/pl-fmt.c
Normal file → Executable file
8
packages/PLStream/pl-fmt.c
Normal file → Executable file
@ -33,7 +33,7 @@ source should also use format() to produce error messages, etc.
|
||||
#include <ctype.h>
|
||||
|
||||
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++)
|
||||
|
@ -138,6 +138,9 @@ typedef enum
|
||||
#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h> //MAXPATHLEN
|
||||
#endif
|
||||
#ifdef __WINDOWS__
|
||||
#include <windows.h>
|
||||
#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);
|
||||
|
2
packages/PLStream/pl-rl.c
Normal file → Executable file
2
packages/PLStream/pl-rl.c
Normal file → Executable file
@ -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
|
||||
|
@ -22,13 +22,15 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#if defined(__WINDOWS__)||defined(__WIN32)
|
||||
#include <uxnt.h>
|
||||
#ifndef _YAP_NOT_INSTALLED_
|
||||
#ifdef WIN64
|
||||
#define MD "config/win64.h"
|
||||
#else
|
||||
#define MD "config/win32.h"
|
||||
#endif
|
||||
#endif
|
||||
#include <winsock2.h>
|
||||
#include "windows/mswchar.h"
|
||||
#define CRLF_MAPPING 1
|
||||
|
4
packages/PLStream/pl-string.c
Normal file → Executable file
4
packages/PLStream/pl-string.c
Normal file → Executable file
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
2
packages/PLStream/pl-string.h
Normal file → Executable file
2
packages/PLStream/pl-string.h
Normal file → Executable file
@ -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);
|
||||
|
38
packages/PLStream/windows/mswchar.h
Executable file
38
packages/PLStream/windows/mswchar.h
Executable file
@ -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 <wchar.h>
|
||||
|
||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
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
|
32
packages/PLStream/popen.c → packages/PLStream/windows/popen.c
Normal file → Executable file
32
packages/PLStream/popen.c → packages/PLStream/windows/popen.c
Normal file → Executable file
@ -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;
|
@ -1 +0,0 @@
|
||||
Subproject commit bf6525f85cfcf3c08fff8cf91fb189fe71dc34fd
|
Reference in New Issue
Block a user