From 19807d46f74b3267606cea16901b9d9cf31de663 Mon Sep 17 00:00:00 2001 From: "U-WIN-UA9ACS5GS9N\\vitor" Date: Wed, 18 Apr 2012 14:14:56 -0500 Subject: [PATCH] WIN32 and CYGWIN fixes. --- C/load_dl.c | 7 +++++-- C/pl-yap.c | 2 +- C/sysbits.c | 3 ++- H/Yap.h | 1 + H/arith2.h | 3 ++- OPTYap/tab.macros.h | 32 ++++++++++++++++---------------- console/yap.c | 4 ++-- 7 files changed, 29 insertions(+), 23 deletions(-) mode change 100644 => 100755 C/load_dl.c mode change 100644 => 100755 C/pl-yap.c mode change 100644 => 100755 C/sysbits.c mode change 100644 => 100755 H/Yap.h mode change 100644 => 100755 H/arith2.h mode change 100644 => 100755 OPTYap/tab.macros.h mode change 100644 => 100755 console/yap.c diff --git a/C/load_dl.c b/C/load_dl.c old mode 100644 new mode 100755 index a11132df6..026676c46 --- a/C/load_dl.c +++ b/C/load_dl.c @@ -34,14 +34,17 @@ Yap_CallFunctionByName(const char *thing_string); int Yap_CallFunctionByName(const char *thing_string) { - void * handle = dlopen(NULL, RTLD_LAZY | RTLD_NOLOAD); + void * handle = dlopen(NULL, RTLD_LAZY +#ifndef __CYGWIN__ + | RTLD_NOLOAD +#endif + ); // you could do RTLD_NOW as well. shouldn't matter if (!handle) { CACHE_REGS Yap_Error(SYSTEM_ERROR, ARG1, "Dynamic linking on main module : %s\n", dlerror()); } prismf * addr = (prismf *)dlsym(handle, thing_string); - fprintf(stderr, "%s is at %p\n", thing_string, addr); if (addr) (*addr)(); return TRUE; diff --git a/C/pl-yap.c b/C/pl-yap.c old mode 100644 new mode 100755 index 2351bfc11..f92858ba0 --- a/C/pl-yap.c +++ b/C/pl-yap.c @@ -887,7 +887,7 @@ warning(const char *fm, ...) return TRUE; } -#if defined(HAVE_SELECT) && !defined(__WINDOWS__) +#if defined(HAVE_SELECT) && !defined(__WINDOWS__) && !defined(__CYGWIN__) #ifdef __WINDOWS__ #include diff --git a/C/sysbits.c b/C/sysbits.c old mode 100644 new mode 100755 index 639bdc425..c99721ed0 --- a/C/sysbits.c +++ b/C/sysbits.c @@ -81,7 +81,8 @@ static char SccsId[] = "%W% %G%"; #include #endif #endif -#if HAVE_FENV_H +/* CYGWIN seems to include this automatically */ +#if HAVE_FENV_H && !defined(__CYGWIN__) #include #endif #if HAVE_READLINE_READLINE_H diff --git a/H/Yap.h b/H/Yap.h old mode 100644 new mode 100755 index 2bb178339..5ccf5903b --- a/H/Yap.h +++ b/H/Yap.h @@ -810,6 +810,7 @@ extern struct worker_local Yap_local; #define REMOTE(wid) (&Yap_local) #endif +#include #define YP_FILE FILE #include "hglobals.h" #include "dglobals.h" diff --git a/H/arith2.h b/H/arith2.h old mode 100644 new mode 100755 index 2bd6ffc6e..92d92d87f --- a/H/arith2.h +++ b/H/arith2.h @@ -120,6 +120,7 @@ times_int(Int i1, Int i2) { } +#ifdef USE_GMP #ifndef __GNUC__X static int clrsb(Int i) @@ -147,7 +148,7 @@ clrsb(Int i) return j; } #endif - +#endif inline static Term do_sll(Int i, Int j) /* j > 0 */ diff --git a/OPTYap/tab.macros.h b/OPTYap/tab.macros.h old mode 100644 new mode 100755 index f0a8abe93..170cae906 --- a/OPTYap/tab.macros.h +++ b/OPTYap/tab.macros.h @@ -193,27 +193,27 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int); #endif /* DETERMINISTIC_TABLING */ /* tagging nodes */ -#define TAG_AS_SUBGOAL_LEAF_NODE(NODE) TrNode_child(NODE) = (sg_node_ptr)((unsigned long int) TrNode_child(NODE) | 0x1) -#define IS_SUBGOAL_LEAF_NODE(NODE) ((unsigned long int) TrNode_child(NODE) & 0x1) -#define TAG_AS_ANSWER_LEAF_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((unsigned long int) TrNode_parent(NODE) | 0x1) -#define IS_ANSWER_LEAF_NODE(NODE) ((unsigned long int) TrNode_parent(NODE) & 0x1) -#define TAG_AS_ANSWER_INVALID_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((unsigned long int) TrNode_parent(NODE) | 0x2) -#define IS_ANSWER_INVALID_NODE(NODE) ((unsigned long int) TrNode_parent(NODE) & 0x2) -#define UNTAG_SUBGOAL_NODE(NODE) ((unsigned long int) (NODE) & ~(0x1)) -#define UNTAG_ANSWER_NODE(NODE) ((unsigned long int) (NODE) & ~(0x3)) +#define TAG_AS_SUBGOAL_LEAF_NODE(NODE) TrNode_child(NODE) = (sg_node_ptr)((CELL) TrNode_child(NODE) | 0x1) +#define IS_SUBGOAL_LEAF_NODE(NODE) ((CELL) TrNode_child(NODE) & 0x1) +#define TAG_AS_ANSWER_LEAF_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((CELL) TrNode_parent(NODE) | 0x1) +#define IS_ANSWER_LEAF_NODE(NODE) ((CELL) TrNode_parent(NODE) & 0x1) +#define TAG_AS_ANSWER_INVALID_NODE(NODE) TrNode_parent(NODE) = (ans_node_ptr)((CELL) TrNode_parent(NODE) | 0x2) +#define IS_ANSWER_INVALID_NODE(NODE) ((CELL) TrNode_parent(NODE) & 0x2) +#define UNTAG_SUBGOAL_NODE(NODE) ((CELL) (NODE) & ~(0x1)) +#define UNTAG_ANSWER_NODE(NODE) ((CELL) (NODE) & ~(0x3)) /* trie hashes */ #define MAX_NODES_PER_TRIE_LEVEL 8 #define MAX_NODES_PER_BUCKET (MAX_NODES_PER_TRIE_LEVEL / 2) #define BASE_HASH_BUCKETS 64 -#define HASH_ENTRY(ENTRY, NUM_BUCKETS) ((((unsigned long int) ENTRY) >> NumberOfLowTagBits) & (NUM_BUCKETS - 1)) +#define HASH_ENTRY(ENTRY, NUM_BUCKETS) ((((CELL) ENTRY) >> NumberOfLowTagBits) & (NUM_BUCKETS - 1)) #define SUBGOAL_TRIE_HASH_MARK ((Term) MakeTableVarTerm(MAX_TABLE_VARS)) #define IS_SUBGOAL_TRIE_HASH(NODE) (TrNode_entry(NODE) == SUBGOAL_TRIE_HASH_MARK) #define ANSWER_TRIE_HASH_MARK 0 #define IS_ANSWER_TRIE_HASH(NODE) (TrNode_instr(NODE) == ANSWER_TRIE_HASH_MARK) #define GLOBAL_TRIE_HASH_MARK ((Term) MakeTableVarTerm(MAX_TABLE_VARS)) #define IS_GLOBAL_TRIE_HASH(NODE) (TrNode_entry(NODE) == GLOBAL_TRIE_HASH_MARK) -#define HASH_TRIE_LOCK(NODE) GLOBAL_trie_locks((((unsigned long int) (NODE)) >> 5) & (TRIE_LOCK_BUCKETS - 1)) +#define HASH_TRIE_LOCK(NODE) GLOBAL_trie_locks((((CELL) (NODE)) >> 5) & (TRIE_LOCK_BUCKETS - 1)) /* auxiliary stack */ #define STACK_PUSH_UP(ITEM, STACK) *--(STACK) = (CELL)(ITEM) @@ -449,9 +449,9 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int); /* ... pointing to SgEnt_first_answer(SgFr_sg_ent(SG_FR)) */ \ if (SG_FR) \ DepFr_last_answer(DEP_FR) = (ans_node_ptr) ( \ - (unsigned long int) (SgFr_sg_ent((sg_fr_ptr)SG_FR)) + \ - (unsigned long int) (&SgEnt_first_answer((sg_ent_ptr)DEP_FR)) - \ - (unsigned long int) (&TrNode_child((ans_node_ptr)DEP_FR))); \ + (CELL) (SgFr_sg_ent((sg_fr_ptr)SG_FR)) + \ + (CELL) (&SgEnt_first_answer((sg_ent_ptr)DEP_FR)) - \ + (CELL) (&TrNode_child((ans_node_ptr)DEP_FR))); \ else \ DepFr_last_answer(DEP_FR) = NULL #else @@ -460,9 +460,9 @@ static inline tg_sol_fr_ptr CUT_prune_tg_solution_frames(tg_sol_fr_ptr, int); /* ... pointing to SgFr_first_answer(SG_FR) */ \ if (SG_FR) \ DepFr_last_answer(DEP_FR) = (ans_node_ptr) ( \ - (unsigned long int) (SG_FR) + \ - (unsigned long int) (&SgFr_first_answer((sg_fr_ptr)DEP_FR)) - \ - (unsigned long int) (&TrNode_child((ans_node_ptr)DEP_FR))); \ + (CELL) (SG_FR) + \ + (CELL) (&SgFr_first_answer((sg_fr_ptr)DEP_FR)) - \ + (CELL) (&TrNode_child((ans_node_ptr)DEP_FR))); \ else \ DepFr_last_answer(DEP_FR) = NULL #endif /* THREADS_FULL_SHARING || THREADS_CONSUMER_SHARING */ diff --git a/console/yap.c b/console/yap.c old mode 100644 new mode 100755 index 27dd0253e..9a9f627c3 --- a/console/yap.c +++ b/console/yap.c @@ -79,8 +79,8 @@ #include #endif -static void PROTO(do_top_goal,(YAP_Term)); -static void PROTO(exec_top_level,(int, YAP_init_args *)); +static void do_top_goal(YAP_Term Goal); +static void exec_top_level(int BootMode, YAP_init_args *iap); #ifdef DEBUG static int output_msg;