WIN32 fixes: work in progress.

This commit is contained in:
Vitor Santos Costa 2009-04-20 16:22:47 -05:00
parent 2c00c4a00b
commit 50207cb52a
7 changed files with 73 additions and 25 deletions

View File

@ -17,7 +17,7 @@ LIBDIR=$(EROOTDIR)/lib/Yap
# #
# #
CC=@CC@ CC=@CC@
CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/uxnt
# #
# #
# You shouldn't need to change what follows. # You shouldn't need to change what follows.
@ -35,23 +35,25 @@ CWD=$(PWD)
# #
HEADERS=$(srcdir)/atoms.h $(srcdir)/pl-buffer.h $(srcdir)/pl-ctype.h \ HEADERS=$(srcdir)/atoms.h $(srcdir)/pl-buffer.h $(srcdir)/pl-ctype.h \
$(srcdir)/pl-incl.h $(srcdir)/pl-opts.h \ $(srcdir)/pl-incl.h \
$(srcdir)/pl-mswchar.h \
$(srcdir)/pl-opts.h \
$(srcdir)/pl-os.h \ $(srcdir)/pl-os.h \
$(srcdir)/pl-stream.h \ $(srcdir)/pl-stream.h \
$(srcdir)/pl-table.h \ $(srcdir)/pl-table.h \
$(srcdir)/pl-text.h $(srcdir)/pl-utf8.h \ $(srcdir)/pl-text.h $(srcdir)/pl-utf8.h \
$(srcdir)/pl-yap.h $(srcdir)/pl-yap.h @ENABLE_WINCONSOLE@ $(srcdir)/uxnt/dirent.h $(srcdir)/uxnt/utf8.h $(srcdir)/uxnt/uxnt.h
C_SOURCES=$(srcdir)/pl-buffer.c $(srcdir)/pl-ctype.c \ C_SOURCES=$(srcdir)/pl-buffer.c $(srcdir)/pl-ctype.c \
$(srcdir)/pl-error.c $(srcdir)/pl-feature.c \ $(srcdir)/pl-error.c $(srcdir)/pl-feature.c \
$(srcdir)/pl-file.c $(srcdir)/pl-os.c \ $(srcdir)/pl-file.c $(srcdir)/pl-os.c \
$(srcdir)/pl-stream.c $(srcdir)/pl-string.c \ $(srcdir)/pl-stream.c $(srcdir)/pl-string.c \
$(srcdir)/pl-table.c \ $(srcdir)/pl-table.c \
$(srcdir)/pl-text.c $(srcdir)/pl-utf8.c \ $(srcdir)/pl-text.c $(srcdir)/pl-utf8.c \
$(srcdir)/pl-yap.c $(srcdir)/pl-yap.c @ENABLE_WINCONSOLE@ $(srcdir)/uxnt/utf8.c $(srcdir)/uxnt/uxnt.c
OBJS=pl-buffer.o pl-ctype.o pl-error.o pl-feature.o \ OBJS=pl-buffer.o pl-ctype.o pl-error.o pl-feature.o \
pl-file.o pl-os.o \ pl-file.o pl-os.o \
pl-stream.o pl-string.o pl-table.o pl-text.o pl-utf8.o \ pl-stream.o pl-string.o pl-table.o pl-text.o pl-utf8.o \
pl-yap.o pl-yap.o @ENABLE_WINCONSOLE@ utf8.o uxnt.o
SOBJS=plstream@SHLIB_SUFFIX@ SOBJS=plstream@SHLIB_SUFFIX@
#in some systems we just create a single object, in others we need to #in some systems we just create a single object, in others we need to
@ -95,6 +97,12 @@ pl-utf8.o: $(srcdir)/pl-utf8.c
pl-yap.o: $(srcdir)/pl-yap.c pl-yap.o: $(srcdir)/pl-yap.c
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/pl-yap.c -o pl-yap.o $(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/pl-yap.c -o pl-yap.o
uxnt.o: $(srcdir)/uxnt/uxnt.c
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/uxnt/uxnt.c -o uxnt.o
utf8.o: $(srcdir)/uxnt/utf8.c
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/uxnt/utf8.c -o utf8.o
@DO_SECOND_LD@%@SHLIB_SUFFIX@: %.o @DO_SECOND_LD@%@SHLIB_SUFFIX@: %.o
@DO_SECOND_LD@ @SHLIB_LD@ -o $@ $< @DO_SECOND_LD@ @SHLIB_LD@ -o $@ $<

View File

@ -837,7 +837,7 @@ static const enc_map map[] =
{ NULL, ENC_UNKNOWN } { NULL, ENC_UNKNOWN }
}; };
static IOENC IOENC
initEncoding(void) initEncoding(void)
{ if ( LD ) { if ( LD )
{ if ( !LD->encoding ) { if ( !LD->encoding )

View File

@ -609,7 +609,7 @@ isConsoleStream(IOSTREAM *s)
#endif #endif
static bool bool
reportStreamError(IOSTREAM *s) reportStreamError(IOSTREAM *s)
{ if ( GD->cleaning == CLN_NORMAL && { if ( GD->cleaning == CLN_NORMAL &&
!isConsoleStream(s) && !isConsoleStream(s) &&
@ -4271,6 +4271,11 @@ pl_delete_directory(term_t name)
} }
/* mkdir/2 works in SWI, and not in YAP, why? */
#ifdef __WINDOWS__
#define mkdir(X,Y) mkdir(X)
#endif
static word static word
pl_make_directory(term_t name) pl_make_directory(term_t name)
{ char *n; { char *n;

View File

@ -1,5 +1,8 @@
#include "config.h" #include "config.h"
#define PL_KERNEL 1
#include <SWI-Prolog.h> #include <SWI-Prolog.h>
typedef int bool; typedef int bool;
@ -389,6 +392,24 @@ typedef double real;
#define forwards static /* forwards function declarations */ #define forwards static /* forwards function declarations */
/* uxnt package interface */
#if defined(__YAP_PROLOG__) && defined(__MINGW32__)
#define O_XOS 1
#define _XOS_ISFILE 0x01
#define _XOS_ISDIR 0x02
#define _XOS_FILE 0x0001 /* is a file */
#define _XOS_DIR 0x0002 /* is a directory */
#define XOS_DOWNCASE 0x01 /* _xos_canonical_filename() */
#ifndef __WINDOWS__
#define __WINDOWS__ 1
#endif
#endif
#define PL_dispatch(FD, COM) #define PL_dispatch(FD, COM)
extern int PL_unify_char(term_t chr, int c, int how); extern int PL_unify_char(term_t chr, int c, int how);
extern int PL_get_char(term_t chr, int *c, int eof); extern int PL_get_char(term_t chr, int *c, int eof);
@ -460,10 +481,7 @@ word pl_noprotocol(void);
IOSTREAM *PL_current_input(void); IOSTREAM *PL_current_input(void);
IOSTREAM *PL_current_output(void); IOSTREAM *PL_current_output(void);
extern int PL_release_stream(IOSTREAM *s);
extern int PL_get_stream_handle(term_t t, IOSTREAM **s);
extern int PL_unify_stream_or_alias(term_t t, IOSTREAM *s); extern int PL_unify_stream_or_alias(term_t t, IOSTREAM *s);
extern int PL_unify_stream(term_t t, IOSTREAM *s);
extern bool PL_open_stream(term_t handle, IOSTREAM *s); extern bool PL_open_stream(term_t handle, IOSTREAM *s);
extern void PL_write_prompt(int dowrite); extern void PL_write_prompt(int dowrite);

View File

@ -34,6 +34,12 @@
#endif #endif
#include "pl-incl.h" #include "pl-incl.h"
#ifdef __YAP_PROLOG__
#ifdef __MINGW32__
#define O_XOS 1
#define statfunc _xos_stat
#endif
#endif
#include "pl-ctype.h" #include "pl-ctype.h"
#include "pl-utf8.h" #include "pl-utf8.h"
#undef abs #undef abs
@ -485,7 +491,8 @@ static void
initRandom(void) initRandom(void)
{ unsigned int seed; { unsigned int seed;
#ifdef __WINDOWS__ #if defined(__WINDOWS__) && !defined(__MINGW32__)
seed = (unsigned int)GetTickCount(); seed = (unsigned int)GetTickCount();
#else #else
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
@ -810,6 +817,7 @@ OsPath(const char *p, char *buf)
#endif /*__unix__*/ #endif /*__unix__*/
#if O_XOS #if O_XOS
char * char *
PrologPath(const char *p, char *buf, size_t len) PrologPath(const char *p, char *buf, size_t len)
{ int flags = (trueFeature(FILE_CASE_FEATURE) ? 0 : XOS_DOWNCASE); { int flags = (trueFeature(FILE_CASE_FEATURE) ? 0 : XOS_DOWNCASE);

View File

@ -22,13 +22,22 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifdef __MINGW32__
#define __WINDOWS__ 1
#endif
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#include <uxnt.h> #include <uxnt.h>
#ifdef __MINGW32__
#include "config.h"
#include <windows.h>
#else
#ifdef WIN64 #ifdef WIN64
#define MD "config/win64.h" #define MD "config/win64.h"
#else #else
#define MD "config/win32.h" #define MD "config/win32.h"
#endif #endif
#endif
#include <winsock2.h> #include <winsock2.h>
#include "pl-mswchar.h" #include "pl-mswchar.h"
#define CRLF_MAPPING 1 #define CRLF_MAPPING 1

View File

@ -32,14 +32,14 @@
#include <sys/_mbstate_t.h> #include <sys/_mbstate_t.h>
#endif #endif
#if defined(_MSC_VER) && !defined(__WINDOWS__) #if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(__WINDOWS__)
#define __WINDOWS__ 1 #define __WINDOWS__ 1
#endif #endif
#include <stdarg.h> #include <stdarg.h>
#include <wchar.h> #include <wchar.h>
#include <stddef.h> #include <stddef.h>
#ifdef __WINDOWS__ #if defined(__WINDOWS__) && !defined(__MINGW32__)
typedef __int64 int64_t; typedef __int64 int64_t;
#if (_MSC_VER < 1300) #if (_MSC_VER < 1300)
typedef long intptr_t; typedef long intptr_t;