fix win64

This commit is contained in:
Vitor Santos Costa 2013-11-16 16:58:07 +00:00
parent 84bd55df0d
commit 2a5f6535ae
22 changed files with 247 additions and 212 deletions

4
C/exo.c Normal file → Executable file
View File

@ -40,10 +40,10 @@
#define MAX_ARITY 256
#define FNV32_PRIME 16777619
#define FNV32_PRIME ((UInt)16777619)
#define FNV64_PRIME ((UInt)1099511628211)
#define FNV32_OFFSET 2166136261
#define FNV32_OFFSET ((UInt)2166136261)
#define FNV64_OFFSET ((UInt)14695981039346656037)
/*MurmurHash3 from: https://code.google.com/p/smhasher/wiki/MurmurHash3*/

6
C/exo_udi.c Normal file → Executable file
View File

@ -297,7 +297,6 @@ Interval(struct index_t *it, Term min, Term max, Term op, BITS32 off USES_REGS)
BITS32 n;
BITS32 *pt;
BITS32 *end;
BITS32 *pt0, *end0;
Atom at;
LOCAL_exo_it = it;
@ -309,14 +308,11 @@ Interval(struct index_t *it, Term min, Term max, Term op, BITS32 off USES_REGS)
n = it->nels;
pt = c;
end = c+(n-1);
pt0 = pt;
end0 = end+1;
} else if (it->links[off]) {
c = (BITS32 *)it->udi_data;
n = c[it->links[off]];
pt0 = pt = c+(it->links[off]+1);
pt = c;
end = c+(it->links[off]+n);
end0 = end+1;
// fprintf(stderr," %d links %d=%d \n", off, it->links[off], n);
} else {
if (!IsVarTerm(min)) {

2
C/grow.c Normal file → Executable file
View File

@ -1638,7 +1638,7 @@ growstack(size_t size USES_REGS)
fprintf(GLOBAL_stderr, "%% Local:%8ld cells (%p-%p)\n", (unsigned long int)(LCL0-ASP),LCL0,ASP);
fprintf(GLOBAL_stderr, "%% Trail:%8ld cells (%p-%p)\n",
(unsigned long int)(TR-(tr_fr_ptr)LOCAL_TrailBase),LOCAL_TrailBase,TR);
fprintf(GLOBAL_stderr, "%% Growing the stacks %ld bytes\n", size);
fprintf(GLOBAL_stderr, "%% Growing the stacks " UInt_FORMAT " bytes\n", (UInt) size);
}
if (!execute_growstack(size, FALSE, FALSE, NULL, NULL, NULL PASS_REGS))
return FALSE;

View File

@ -18,8 +18,12 @@
static char SccsId[] = "@(#)save.c 1.3 3/15/90";
#endif
#include "config.h"
#include "SWI-Stream.h"
#if _MSC_VER || defined(__MINGW32__)
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#include <windows.h>
#include <psapi.h>
#endif

View File

@ -42,6 +42,10 @@
#if defined(YAPOR) || defined(TABLING)
#include "opt.config.h"
#endif /* YAPOR || TABLING */
#if HAVE_STRINGS_H
/* bzero */
#include <strings.h>
#endif
/*

1
H/hstruct.h Normal file → Executable file
View File

@ -228,6 +228,7 @@
UInt dirty_cps;
UInt freed_cps;
#endif
UInt expand_clauses_sz;
struct udi_info *udi_control_blocks;

157
H/pl-basic.h Normal file → Executable file
View File

@ -1,157 +0,0 @@
// SWI stuff that is needed everywhere
#ifndef PL_BASIC_H
#define PL_BASIC_H
/* we are in YAP */
#ifndef __YAP_PROLOG__
#define __YAP_PROLOG__ 1
#endif
#if USE_GMP
#define O_GMP 1
#endif
#define O_LOCALE 1
#ifndef PL_CONSOLE
#define PL_KERNEL 1
#endif
#include <SWI-Prolog.h>
#ifdef __MINGW32__
#ifndef O_XOS
#define O_XOS 1
#endif
#ifndef __WINDOWS__
#define __WINDOWS__ 1
#endif
#endif
#ifdef __WINDOWS__
#include <windows.h>
#include <windows/uxnt.h>
#endif
#ifndef __unix__
#if defined(_AIX) || defined(__APPLE__) || defined(__unix) || defined(__BEOS__) || defined(__NetBSD__)
#define __unix__ 1
#endif
#endif
#ifdef THREADS
#define O_PLMT 1
#else
#ifdef _REENTRANT
#undef _REENTRANT
#endif
#endif
#if defined(__GNUC__) && !defined(MAY_ALIAS)
#define MAY_ALIAS __attribute__ ((__may_alias__))
#else
#define MAY_ALIAS
#endif
#ifndef PL_HAVE_TERM_T
#define PL_HAVE_TERM_T
typedef uintptr_t term_t;
#endif
#if _WIN32
#ifndef THREADS
typedef int pthread_t;
#endif
#endif
typedef uintptr_t word; /* Anonymous 4 byte object */
typedef int bool;
#define GLOBAL_LD (LOCAL_PL_local_data_p)
#if !defined(O_PLMT) && !defined(YAPOR)
#define LOCAL_LD (GLOBAL_LD)
#define LD (GLOBAL_LD)
#define ARG1_LD void
#define ARG_LD
#define GET_LD
#define PRED_LD
#define PASS_LD
#define PASS_LD1
#define IGNORE_LD
#define REGS_FROM_LD
#define LD_FROM_REGS
#else
#define LOCAL_LD (__PL_ld)
#define LD LOCAL_LD
#define GET_LD CACHE_REGS struct PL_local_data *__PL_ld = GLOBAL_LD;
#define ARG1_LD struct PL_local_data *__PL_ld
#define ARG_LD , ARG1_LD
#define PASS_LD1 LD
#define PASS_LD , LD
#define PRED_LD GET_LD
#define IGNORE_LD (void)__PL_ld;
#define REGS_FROM_LD struct regstore_t *regcache = __PL_ld->reg_cache;
#define LD_FROM_REGS struct PL_local_data *__PL_ld = LOCAL_PL_local_data_p;
#endif
static inline Term
OpenList(int n USES_REGS)
{
Term t;
BACKUP_H();
while (H+2*n > ASP-1024) {
if (!Yap_dogc( 0, NULL PASS_REGS )) {
RECOVER_H();
return FALSE;
}
}
t = AbsPair(H);
H += 2*n;
RECOVER_H();
return t;
}
static inline Term
ExtendList(Term t0, Term inp)
{
Term t;
CELL *ptr = RepPair(t0);
BACKUP_H();
ptr[0] = inp;
ptr[1] = AbsPair(ptr+2);
t = AbsPair(ptr+2);
RECOVER_H();
return t;
}
static inline int
CloseList(Term t0, Term tail)
{
CELL *ptr = RepPair(t0);
RESET_VARIABLE(ptr-1);
if (!Yap_unify((Term)(ptr-1), tail))
return FALSE;
return TRUE;
}
#endif

7
H/pl-global.h Normal file → Executable file
View File

@ -1,3 +1,8 @@
#ifndef PL_GLOBAL_H
#define PL_GLOBAL_H
#include <setjmp.h>
typedef enum
@ -403,3 +408,5 @@ typedef struct PL_local_data {
extern PL_local_data_t lds;
#endif

View File

@ -3,13 +3,34 @@
#define PL_INCL_H 1
/* define that we are in the pl-* code */
#define _PL_EMULATION_LAYER 1
#ifndef __WINDOWS__
#if defined(_MSC_VER) || defined(__MINGW32__)
#define __WINDOWS__ 1
#endif
#endif
#ifdef __WINDOWS__
#if HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#include <windows.h>
#if HAVE_XOS_H
#include <xos.h> /* Windows POSIX enhancements */
#endif
#include "windows/uxnt.h" /* More Windows POSIX enhancements */
#endif
#include "Yap.h"
#include "YapHeap.h"
/* define that we are in the pl-* code */
#define _PL_EMULATION_LAYER 1
/* include all stuff that is exported to yap */
#include "pl-shared.h"
@ -35,6 +56,13 @@ typedef word * Word;
#undef H
#endif
/* swi code called from pl-incl.h */
/* should have messages here */
#ifdef DEBUG
#undef DEBUG
#endif
#define DEBUG(LEVEL, COMMAND)
/* vsc: needs defining before getting rid of YAP locks */
static inline int
do_startCritical(void) {
@ -220,7 +248,7 @@ users foreign language code.
#define CREF PL_FA_CREF
#define ISO PL_FA_ISO
/********************************
/********************************
* THREADS *
*********************************/
@ -578,16 +606,9 @@ extern bool tellString(char **s, size_t *size, IOENC enc);
extern bool tellString(char **s, size_t *size, IOENC enc);
extern bool toldString(void);
extern int setupOutputRedirect(term_t to, redir_context *ctx, int redir);
extern void discardOutputRedirect(redir_context *ctx);
extern int closeOutputRedirect(redir_context *ctx);
extern IOENC atom_to_encoding(atom_t);
void closeFiles(int);
atom_t PrologPrompt(void);
word pl_current_input(term_t);
word pl_current_output(term_t);
word pl_exists_file(term_t name);
char *DirName(const char *f, char *dir);
void outOfCore(void);

186
H/pl-shared.h Normal file → Executable file
View File

@ -3,15 +3,119 @@
#define PL_SHARED_H
#include "config.h"
/* we are in YAP */
#ifndef __YAP_PROLOG__
#define __YAP_PROLOG__ 1
#endif
#include "pl-basic.h"
// SWI stuff that is needed everywhere
#include "SWI-Stream.h"
#ifndef __unix__
#if defined(_AIX) || defined(__APPLE__) || defined(__unix) || defined(__BEOS__) || defined(__NetBSD__)
#define __unix__ 1
#endif
#endif
#define O_LOCALE 1
#ifndef PL_CONSOLE
#define PL_KERNEL 1
#endif
#include "pl-locale.h" /* Locale objects */
#ifndef __WINDOWS__
#if defined(_MSC_VER) || defined(__MINGW32__)
#define __WINDOWS__ 1
#endif
#endif
// SWI Options
#define O_STRING 1
#define O_QUASIQUOTATIONS 1
#define O_LOCALE 1
//#define O_ATOMGC 1
//#define O_CLAUSEGC 1
#ifdef HAVE_GMP_H
#define O_GMP 1
#endif
#ifdef __WINDOWS__
#define NOTTYCONTROL TRUE
#define O_DDE 1
#define O_DLL 1
#define O_HASDRIVES 1
#define O_HASSHARES 1
#define O_XOS 1
#define O_RLC 1
#endif
#ifdef THREADS
#define O_PLMT 1
#else
#ifdef _REENTRANT
#undef _REENTRANT
#endif
#endif
#include <SWI-Prolog.h>
#define COMMON(X) extern X
#if defined(__GNUC__) && !defined(MAY_ALIAS)
#define MAY_ALIAS __attribute__ ((__may_alias__))
#else
#define MAY_ALIAS
#endif
#ifndef PL_HAVE_TERM_T
#define PL_HAVE_TERM_T
typedef uintptr_t term_t;
#endif
#if _WIN32
#ifndef THREADS
typedef int pthread_t;
#endif
#endif
typedef uintptr_t word; /* Anonymous 4 byte object */
typedef int bool;
#ifndef THREADS
#define GLOBAL_LD (LOCAL_PL_local_data_p)
#if !defined(O_PLMT) && !defined(YAPOR)
#define LOCAL_LD (GLOBAL_LD)
#define LD (GLOBAL_LD)
#define ARG1_LD void
#define ARG_LD
#define GET_LD
#define PRED_LD
#define PASS_LD
#define PASS_LD1
#define IGNORE_LD
#define REGS_FROM_LD
#define LD_FROM_REGS
#else
#define LOCAL_LD (__PL_ld)
#define LD LOCAL_LD
#define GET_LD CACHE_REGS struct PL_local_data *__PL_ld = GLOBAL_LD;
#define ARG1_LD struct PL_local_data *__PL_ld
#define ARG_LD , ARG1_LD
#define PASS_LD1 LD
#define PASS_LD , LD
#define PRED_LD GET_LD
#define IGNORE_LD (void)__PL_ld;
#define REGS_FROM_LD struct regstore_t *regcache = __PL_ld->reg_cache;
#define LD_FROM_REGS struct PL_local_data *__PL_ld = LOCAL_PL_local_data_p;
#endif
/*******************************
* STREAM I/O *
@ -83,6 +187,17 @@ typedef struct initialise_handle * InitialiseHandle;
#include "pl-table.h"
/********************************
* LOCALE *
*********************************/
#define O_LOCALE 1
#include "pl-locale.h" /* Locale objects */
/********************************
* GLOBALS *
*********************************/
/* vsc: global variables */
#include "pl-global.h"
@ -93,15 +208,8 @@ typedef struct initialise_handle * InitialiseHandle;
#define false(s, a) (!true((s), (a)))
#define set(s, a) ((s)->flags |= (a))
#define clear(s, a) ((s)->flags &= ~(a))
#ifdef DEBUG
/* should have messages here */
#define DEBUG_YAP 1
#undef DEBUG
#define DEBUG(LEVEL, COMMAND)
#else
#define DEBUG(LEVEL, COMMAND)
#endif
#define P_QUASI_QUOTATION_SYNTAX (0x00000004) /* <![Type[Quasi Quote]]> */
#define PLFLAG_CHARESCAPE 0x000001 /* handle \ in atoms */
#define PLFLAG_GC 0x000002 /* do GC */
#define PLFLAG_TRACE_GC 0x000004 /* verbose gc */
@ -124,6 +232,8 @@ typedef struct initialise_handle * InitialiseHandle;
#define PLFLAG_SIGNALS 0x080000 /* Handle signals */
#define PLFLAG_DEBUGINFO 0x100000 /* generate debug info */
#define PLFLAG_FILEERRORS 0x200000 /* Edinburgh file errors */
#define PLFLAG_WARN_OVERRIDE_IMPLICIT_IMPORT 0x200000 /* Warn overriding weak symbols */
#define PLFLAG_QUASI_QUOTES 0x400000 /* Support quasi quotes */
/* Flags on module. Most of these flags are copied to the read context
in pl-read.c.
@ -153,4 +263,54 @@ COMMON(void) Yap_setCurrentSourceLocation(IOSTREAM **s);
#define SWIAtomToAtom(X) SWI_Atoms[(X)>>1]
static inline Term
OpenList(int n USES_REGS)
{
Term t;
BACKUP_H();
while (H+2*n > ASP-1024) {
if (!Yap_dogc( 0, NULL PASS_REGS )) {
RECOVER_H();
return FALSE;
}
}
t = AbsPair(H);
H += 2*n;
RECOVER_H();
return t;
}
static inline Term
ExtendList(Term t0, Term inp)
{
Term t;
CELL *ptr = RepPair(t0);
BACKUP_H();
ptr[0] = inp;
ptr[1] = AbsPair(ptr+2);
t = AbsPair(ptr+2);
RECOVER_H();
return t;
}
static inline int
CloseList(Term t0, Term tail)
{
CELL *ptr = RepPair(t0);
RESET_VARIABLE(ptr-1);
if (!Yap_unify((Term)(ptr-1), tail))
return FALSE;
return TRUE;
}
#endif
#endif /* PL_SHARED_INCLUDE */

View File

@ -50,6 +50,12 @@ extern "C" {
#include <time.h>
#endif
#ifndef __WINDOWS__
#if defined(_MSC_VER) || defined(__MINGW32__)
#define __WINDOWS__ 1
#endif
#endif
#ifndef X_API
#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(PL_KERNEL)
#define X_API __declspec(dllexport)
@ -58,12 +64,6 @@ extern "C" {
#endif
#endif
#ifndef __WINDOWS__
#if defined(_MSC_VER) || defined(__MINGW32__)
#define __WINDOWS__ 1
#endif
#endif
/*******************************
* EXPORT *
@ -154,15 +154,8 @@ typedef uintptr_t PL_fid_t; /* opaque foreign context handle */
typedef int (*PL_dispatch_hook_t)(int fd);
typedef void *pl_function_t;
#define O_STRING 1
#define COMMON(X) X
#define fid_t PL_fid_t /* avoid AIX name-clash */
typedef struct _PL_extension
{ const char *predicate_name; /* Name of the predicate */
short arity; /* Arity of the predicate */

6
os/pl-dtoa.h Normal file → Executable file
View File

@ -25,7 +25,13 @@
#ifndef PL_DTOA_H_INCLUDED
#define PL_DTOA_H_INCLUDED
#ifdef dtoa
#undef dtoa
#endif
#define dtoa PL_dtoa /* avoid library conflicts */
#ifdef strtod /* avoid redefinition warnings */
#undef strtod
#endif
#define strtod PL_strtod /* avoid library conflicts */
COMMON(char *) dtoa(double dd, int mode, int ndigits,

2
os/pl-os.c Normal file → Executable file
View File

@ -1408,7 +1408,7 @@ isDriveRelativePath(const char *p) /* '/...' */
#endif
static int
GetCurrentDriveLetter()
GetCurrentDriveLetter( void )
{
#ifdef OS2
return _getdrive();

View File

@ -141,7 +141,7 @@ STRYLOCK(IOSTREAM *s)
#endif
extern int fatalError(const char *fm, ...);
extern int PL_handle_signals();
extern int PL_handle_signals( void );
extern IOENC initEncoding(void);
extern int reportStreamError(IOSTREAM *s);
extern record_t PL_record(term_t t);

4
os/windows/popen.c Normal file → Executable file
View File

@ -112,7 +112,7 @@ CRITICAL_SECTION lock;
#define UNLOCK() LeaveCriticalSection(&lock);
static void
pt_init()
pt_init( void )
{ InitializeCriticalSection(&lock);
}
@ -130,7 +130,7 @@ typedef struct pipe_context
static pipe_context *pipes = NULL;
static pipe_context *
allocPipeContext()
allocPipeContext( void )
{ pipe_context *pc = malloc(sizeof(*pc));
if ( !pc )

@ -1 +1 @@
Subproject commit 5b577c8414aeaba18c2eb9eff987060fa9df96d8
Subproject commit 9995994768d968c6059f255cd3077abdd34e61a1

@ -1 +1 @@
Subproject commit 3ea73d3b1d23631a3545a9578539ea7e3df567f6
Subproject commit c62502891b02569fc9d6b7fe90b9373c6d3c2f92

@ -1 +1 @@
Subproject commit f96cfb7533c57789fa25db64b73c09aa7269d244
Subproject commit 1743351432230388c7b7c877d2a8b3d7bae190fa

@ -1 +1 @@
Subproject commit 0593a65587ffbada6b6679204d0254a2a46b1535
Subproject commit 0bac35ec257cecca8f4cef9e3bcb4384637e38f0

@ -1 +1 @@
Subproject commit 9ff05eaf6a47d856f0e43c14ddb105f2bedcbafb
Subproject commit 42164151ac5f3a016cf50aba58b577ae84fd4495

@ -1 +1 @@
Subproject commit 2505370b84226fb21d71cfa447bc1c1ada9b5d22
Subproject commit 3ed10e016db8d5f6c925f922c3d744dc10039f4a

@ -1 +1 @@
Subproject commit 22db6b08d5ee26235e7ab22da194e2b4edadf4a7
Subproject commit 18647f78aa21d494aceac0dcaaac6fc6699f0df0