From 78d848715605735f0003e01006a8c342ea72169a Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 25 Jul 2011 23:50:50 +0100 Subject: [PATCH 1/3] fix for OSX Lion. --- H/Yap.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/H/Yap.h b/H/Yap.h index 22b41634d..c812cd044 100755 --- a/H/Yap.h +++ b/H/Yap.h @@ -251,17 +251,12 @@ typedef unsigned long int YAP_ULONG_LONG; #endif /* FORCE_SECOND_QUADRANT */ #if !defined(IN_SECOND_QUADRANT) -#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(mips) || defined(__APPLE__) || defined(__DragonFly__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(mips) || (__DragonFly__) #if defined(YAPOR) && defined(__alpha) #define MMAP_ADDR 0x40000000 #elif defined(mips) #define MMAP_ADDR 0x02000000 -#elif defined(__APPLE__) && __LP64__ -// this address is high enough that it is likely not to confuse Apple's malloc debugger; lowest possible is 0x100200000 -#define MMAP_ADDR 0x200000000 -#elif defined(__APPLE__) && !__LP64__ -#define MMAP_ADDR 0x20000000 #elif defined(__powerpc__) #define MMAP_ADDR 0x20000000 #else From f73d7ef5f608772f4ca6bc91720374c73dbcfd3f Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 25 Jul 2011 23:51:45 +0100 Subject: [PATCH 2/3] fixes for WIN32 compilation. --- packages/PLStream/pl-incl.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/PLStream/pl-incl.h b/packages/PLStream/pl-incl.h index 362371302..281bb9849 100755 --- a/packages/PLStream/pl-incl.h +++ b/packages/PLStream/pl-incl.h @@ -5,6 +5,12 @@ #define O_GMP 1 #endif +#ifdef __WINDOWS__ +#include +#include +#define O_HASDRIVES 1 +#endif + #ifndef PL_CONSOLE #define PL_KERNEL 1 #endif @@ -18,10 +24,6 @@ #endif #include "Yap.h" -#ifdef __WINDOWS__ -#include -#include -#endif #include "YapHeap.h" /* try not to pollute the SWI space */ #ifdef P From 69f1bedf47caad18f0ead34bbc6e3db411c1c1ba Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Mon, 25 Jul 2011 23:52:05 +0100 Subject: [PATCH 3/3] copy error routines from SWI. That was easy. --- include/SWI-Prolog.h | 30 ++++++++++++++++ packages/PLStream/pl-error.c | 70 ++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/include/SWI-Prolog.h b/include/SWI-Prolog.h index 3eb92156e..d6f4e1749 100755 --- a/include/SWI-Prolog.h +++ b/include/SWI-Prolog.h @@ -683,6 +683,36 @@ PL_EXPORT(LRESULT) PL_win_message_proc(HWND hwnd, X_API intptr_t PL_query(int); /* get information from Prolog */ + /******************************* + * ERRORS * + *******************************/ + +PL_EXPORT(int) PL_get_atom_ex(term_t t, atom_t *a); +PL_EXPORT(int) PL_get_integer_ex(term_t t, int *i); +PL_EXPORT(int) PL_get_long_ex(term_t t, long *i); +PL_EXPORT(int) PL_get_int64_ex(term_t t, int64_t *i); +PL_EXPORT(int) PL_get_intptr_ex(term_t t, intptr_t *i); +PL_EXPORT(int) PL_get_size_ex(term_t t, size_t *i); +PL_EXPORT(int) PL_get_bool_ex(term_t t, int *i); +PL_EXPORT(int) PL_get_float_ex(term_t t, double *f); +PL_EXPORT(int) PL_get_char_ex(term_t t, int *p, int eof); +PL_EXPORT(int) PL_unify_bool_ex(term_t t, int val); +PL_EXPORT(int) PL_get_pointer_ex(term_t t, void **addrp); +PL_EXPORT(int) PL_unify_list_ex(term_t l, term_t h, term_t t); +PL_EXPORT(int) PL_unify_nil_ex(term_t l); +PL_EXPORT(int) PL_get_list_ex(term_t l, term_t h, term_t t); +PL_EXPORT(int) PL_get_nil_ex(term_t l); + +PL_EXPORT(int) PL_instantiation_error(term_t culprit); +PL_EXPORT(int) PL_representation_error(const char *resource); +PL_EXPORT(int) PL_type_error(const char *expected, term_t culprit); +PL_EXPORT(int) PL_domain_error(const char *expected, term_t culprit); +PL_EXPORT(int) PL_existence_error(const char *type, term_t culprit); +PL_EXPORT(int) PL_permission_error(const char *operation, + const char *type, term_t culprit); +PL_EXPORT(int) PL_resource_error(const char *resource); + + /******************************* * BLOBS * *******************************/ diff --git a/packages/PLStream/pl-error.c b/packages/PLStream/pl-error.c index a15da7b3d..2055e1daa 100644 --- a/packages/PLStream/pl-error.c +++ b/packages/PLStream/pl-error.c @@ -184,6 +184,76 @@ PL_unify_bool_ex(term_t t, bool val) return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_bool, t); } + /******************************* + * TYPICAL ERRORS * + *******************************/ + +int +PL_instantiation_error(term_t actual) +{ return PL_error(NULL, 0, NULL, ERR_INSTANTIATION); +} + +int +PL_representation_error(const char *resource) +{ atom_t r = PL_new_atom(resource); + int rc = PL_error(NULL, 0, NULL, ERR_RESOURCE, r); + PL_unregister_atom(r); + + return rc; +} + + +int +PL_type_error(const char *expected, term_t actual) +{ return PL_error(NULL, 0, NULL, ERR_CHARS_TYPE, expected, actual); +} + + +int +PL_domain_error(const char *expected, term_t actual) +{ atom_t a = PL_new_atom(expected); + int rc = PL_error(NULL, 0, NULL, ERR_DOMAIN, a, actual); + PL_unregister_atom(a); + + return rc; +} + + +int +PL_existence_error(const char *type, term_t actual) +{ atom_t a = PL_new_atom(type); + int rc = PL_error(NULL, 0, NULL, ERR_EXISTENCE, a, actual); + PL_unregister_atom(a); + + return rc; +} + + +int +PL_permission_error(const char *op, const char *type, term_t obj) +{ atom_t t = PL_new_atom(type); + atom_t o = PL_new_atom(op); + int rc = PL_error(NULL, 0, NULL, ERR_PERMISSION, o, t, obj); + + PL_unregister_atom(t); + PL_unregister_atom(o); + + return rc; +} + + +int +PL_resource_error(const char *resource) +{ atom_t r = PL_new_atom(resource); + int rc = PL_error(NULL, 0, NULL, ERR_RESOURCE, r); + + PL_unregister_atom(r); + + return rc; +} + + + word notImplemented(char *name, int arity) { return (word)PL_error(NULL, 0, NULL, ERR_NOT_IMPLEMENTED_PROC, name, arity);