2015-06-19 00:53:09 +01:00
|
|
|
/*************************************************************************
|
2005-05-27 23:27:59 +01:00
|
|
|
* *
|
|
|
|
* YAP Prolog %W% %G% *
|
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
2011-11-02 22:53:49 +00:00
|
|
|
* File: Yap.h *
|
2005-05-27 23:27:59 +01:00
|
|
|
* mods: *
|
|
|
|
* comments: main header file for YAP *
|
2008-06-18 11:02:27 +01:00
|
|
|
* version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ *
|
2005-05-27 23:27:59 +01:00
|
|
|
*************************************************************************/
|
|
|
|
|
2011-03-02 23:19:39 +00:00
|
|
|
#ifndef YAP_H
|
2015-06-19 00:53:09 +01:00
|
|
|
|
2011-03-02 23:19:39 +00:00
|
|
|
#define YAP_H 1
|
|
|
|
|
2011-04-14 19:19:13 +01:00
|
|
|
#if defined(YAPOR)
|
2015-06-19 00:53:09 +01:00
|
|
|
// #error Do not explicitly define YAPOR
|
2011-04-14 19:19:13 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#if (defined(YAPOR_COPY) && \
|
|
|
|
(defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_THREADS))) || \
|
|
|
|
(defined(YAPOR_COW) && (defined(YAPOR_SBA) || defined(YAPOR_THREADS))) || \
|
|
|
|
(defined(YAPOR_SBA) && defined(YAPOR_THREADS))
|
2011-04-14 19:19:13 +01:00
|
|
|
#error Do not define multiple or-parallel models
|
2016-03-29 02:02:43 +01:00
|
|
|
#endif /* (YAPOR_COPY && (YAPOR_COW || YAPOR_SBA || YAPOR_THREADS)) || \
|
|
|
|
(YAPOR_COW && (YAPOR_SBA || YAPOR_THREADS)) || (YAPOR_SBA || \
|
|
|
|
YAPOR_THREADS) */
|
2011-04-14 19:19:13 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA) || \
|
|
|
|
defined(YAPOR_THREADS)
|
2011-04-14 19:19:13 +01:00
|
|
|
#define YAPOR 1
|
2011-04-18 14:59:17 +01:00
|
|
|
#define FIXED_STACKS 1
|
|
|
|
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA || YAPOR_THREADS */
|
2011-04-14 19:19:13 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#if defined(TABLING) && \
|
|
|
|
(defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_THREADS))
|
2011-04-18 14:59:17 +01:00
|
|
|
#error TABLING only works with YAPOR_COPY
|
2011-04-14 20:00:35 +01:00
|
|
|
#endif /* TABLING && (YAPOR_COW || YAPOR_SBA || YAPOR_THREADS) */
|
2011-04-14 19:19:13 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#if defined(THREADS) && \
|
|
|
|
(defined(YAPOR_COW) || defined(YAPOR_SBA) || defined(YAPOR_COPY))
|
2011-04-18 14:59:17 +01:00
|
|
|
#error THREADS only works with YAPOR_THREADS
|
|
|
|
#endif /* THREADS && (YAPOR_COW || YAPOR_SBA || YAPOR_COPY) */
|
|
|
|
|
2014-06-22 17:35:05 +01:00
|
|
|
// Bad export from Python
|
2005-05-27 23:27:59 +01:00
|
|
|
#include "config.h"
|
2014-02-16 13:03:09 +00:00
|
|
|
|
2015-01-20 03:00:42 +00:00
|
|
|
#ifndef COROUTINING
|
|
|
|
#define COROUTINING 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RATIONAL_TREES
|
|
|
|
#define RATIONAL_TREES 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CUT_C
|
|
|
|
#define CUT_C 1
|
|
|
|
#endif
|
|
|
|
|
2014-02-16 13:03:09 +00:00
|
|
|
#define FunAdr(X) X
|
|
|
|
|
2012-06-29 22:44:08 +01:00
|
|
|
#include "inline-only.h"
|
2011-04-18 14:59:17 +01:00
|
|
|
#if defined(YAPOR) || defined(TABLING)
|
2009-07-03 00:54:39 +01:00
|
|
|
#include "opt.config.h"
|
|
|
|
#endif /* YAPOR || TABLING */
|
2014-06-11 19:36:50 +01:00
|
|
|
#if HAVE_STDINT_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif
|
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
/*
|
|
|
|
|
|
|
|
#define RATIONAL_TREES 1
|
|
|
|
#define DEPTH_LIMIT 1
|
|
|
|
#define COROUTINING 1
|
|
|
|
#define ANALYST 1
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MULTI_ASSIGNMENT_VARIABLES 1
|
|
|
|
|
2011-04-15 10:48:24 +01:00
|
|
|
#if defined(YAPOR) || defined(THREADS)
|
2011-04-14 18:51:11 +01:00
|
|
|
#define MULTIPLE_STACKS 1
|
|
|
|
#define PARALLEL_YAP 1
|
2011-04-18 14:59:17 +01:00
|
|
|
#endif /* YAPOR || THREADS */
|
2011-04-14 18:51:11 +01:00
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) || defined(TABLING)
|
|
|
|
#undef TRAILING_REQUIRES_BRANCH
|
|
|
|
#endif /* YAPOR || TABLING */
|
|
|
|
|
2011-04-18 14:59:17 +01:00
|
|
|
#if defined(TABLING) || defined(YAPOR_SBA)
|
|
|
|
#define FROZEN_STACKS 1
|
|
|
|
#endif /* TABLING || YAPOR_SBA */
|
|
|
|
|
|
|
|
#if defined(THREADS) || defined(SUPPORT_CONDOR)
|
|
|
|
#define USE_SYSTEM_MALLOC 1
|
|
|
|
#endif /* THREADS || SUPPORT_CONDOR */
|
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
#if defined(ANALYST) && defined(USE_THREADED_CODE)
|
2005-05-27 23:27:59 +01:00
|
|
|
#undef USE_THREADED_CODE
|
2011-05-23 16:19:47 +01:00
|
|
|
#endif /* ANALYST && USE_THREADED_CODE */
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
#if defined(COROUTINING) && !defined(TERM_EXTENSIONS)
|
2005-05-27 23:27:59 +01:00
|
|
|
#define TERM_EXTENSIONS 1
|
2011-05-23 16:19:47 +01:00
|
|
|
#endif /* COROUTINING && !TERM_EXTENSIONS */
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2014-10-22 14:54:54 +01:00
|
|
|
/**
|
2016-03-29 02:02:43 +01:00
|
|
|
* Stolen from Mozzila, this code should deal with bad implementations of
|
|
|
|
* stdc++.
|
2014-10-22 14:54:54 +01:00
|
|
|
*
|
|
|
|
* Use C++11 nullptr if available; otherwise use a C++ typesafe template; and
|
|
|
|
* for C, fall back to longs. See bugs 547964 and 626472.
|
|
|
|
*/
|
2015-02-03 02:58:49 +00:00
|
|
|
#if !defined(nullptr) && !defined(HAVE_NULLPTR)
|
2014-10-22 14:54:54 +01:00
|
|
|
#ifndef __cplusplus
|
2016-03-29 02:02:43 +01:00
|
|
|
#define nullptr NULL
|
2014-10-22 14:54:54 +01:00
|
|
|
#elif defined(__GNUC__)
|
2016-03-29 02:02:43 +01:00
|
|
|
#define nullptr __null
|
2014-10-22 14:54:54 +01:00
|
|
|
#elif defined(_WIN64)
|
2016-03-29 02:02:43 +01:00
|
|
|
#define nullptr 0LL
|
2014-10-22 14:54:54 +01:00
|
|
|
#else
|
2016-03-29 02:02:43 +01:00
|
|
|
#define nullptr 0L
|
2014-10-22 14:54:54 +01:00
|
|
|
#endif
|
|
|
|
#endif /* defined(HAVE_NULLPTR) */
|
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
/* Microsoft's Visual C++ Compiler */
|
2016-03-29 02:02:43 +01:00
|
|
|
#ifdef _MSC_VER /* adjust a config.h from mingw32 to work with vc++ */
|
2005-05-27 23:27:59 +01:00
|
|
|
#ifdef HAVE_GCC
|
2011-05-23 16:19:47 +01:00
|
|
|
#undef HAVE_GCC
|
|
|
|
#endif /* HAVE_GCC */
|
2016-03-29 02:02:43 +01:00
|
|
|
#ifdef USE_THREADED_CODE
|
|
|
|
#undef USE_THREADED_CODE
|
2011-05-23 16:19:47 +01:00
|
|
|
#endif /* USE_THREADED_CODE */
|
2005-05-27 23:27:59 +01:00
|
|
|
#define inline __inline
|
2013-01-20 19:28:33 +00:00
|
|
|
#define YAP_VERSION "YAP-6.3.4"
|
2005-08-23 19:11:55 +01:00
|
|
|
#define BIN_DIR "c:\\Yap\\bin"
|
|
|
|
#define LIB_DIR "c:\\Yap\\lib\\Yap"
|
|
|
|
#define SHARE_DIR "c:\\Yap\\share\\Yap"
|
2011-05-23 16:19:47 +01:00
|
|
|
#ifdef HOST_ALIAS
|
|
|
|
#undef HOST_ALIAS
|
|
|
|
#endif /* HOST_ALIAS */
|
2005-05-27 23:27:59 +01:00
|
|
|
#define HOST_ALIAS "i386-pc-win32"
|
2011-05-23 16:19:47 +01:00
|
|
|
#ifdef HAVE_IEEEFP_H
|
|
|
|
#undef HAVE_IEEEFP_H
|
|
|
|
#endif /* HAVE_IEEEFP_H */
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#undef HAVE_UNISTD_H
|
|
|
|
#endif /* HAVE_UNISTD_H */
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
#undef HAVE_SYS_TIME_H
|
|
|
|
#endif /* HAVE_SYS_TIME_H */
|
|
|
|
#endif /* _MSC_VER */
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2013-02-05 14:22:17 +00:00
|
|
|
#if HAVE_TIME_H
|
|
|
|
#include <time.h>
|
|
|
|
#endif
|
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
#ifndef _WIN32
|
|
|
|
#define _WIN32 1
|
2011-05-25 16:40:36 +01:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
#endif /* __MINGW32__ */
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2015-02-09 01:53:28 +00:00
|
|
|
#if HAVE_GCC && !defined(__cplusplus)
|
2005-05-27 23:27:59 +01:00
|
|
|
#define MIN_ARRAY 0
|
|
|
|
#define DUMMY_FILLER_FOR_ABS_TYPE
|
|
|
|
#else
|
|
|
|
#define MIN_ARRAY 1
|
|
|
|
#define DUMMY_FILLER_FOR_ABS_TYPE int dummy;
|
2011-05-25 16:40:36 +01:00
|
|
|
#endif /* HAVE_GCC */
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2015-01-26 04:02:46 +00:00
|
|
|
/* funcions that return a generic pointer */
|
2016-03-29 02:02:43 +01:00
|
|
|
typedef void *(*fptr_t)(void);
|
2015-01-26 04:02:46 +00:00
|
|
|
|
2015-01-20 03:00:42 +00:00
|
|
|
/*************************************************************************************************
|
|
|
|
main exports in YapInterface.h
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
/* Basic exports */
|
|
|
|
|
|
|
|
#include "YapDefs.h"
|
|
|
|
|
|
|
|
/* expect controls the direction of branches */
|
|
|
|
|
2013-01-15 16:51:55 +00:00
|
|
|
#ifdef HAVE___BUILTIN_EXPECT
|
2016-03-29 02:02:43 +01:00
|
|
|
#define likely(x) __builtin_expect((x), 1)
|
|
|
|
#define unlikely(x) __builtin_expect((x), 0)
|
2013-01-15 16:51:55 +00:00
|
|
|
#else
|
2016-03-29 02:02:43 +01:00
|
|
|
#define likely(x) (x)
|
|
|
|
#define unlikely(x) (x)
|
2013-01-15 16:51:55 +00:00
|
|
|
#endif
|
|
|
|
|
2011-11-02 22:53:49 +00:00
|
|
|
#ifdef THREADS
|
|
|
|
#if USE_PTHREAD_LOCKING
|
|
|
|
#ifndef _XOPEN_SOURCE
|
|
|
|
#define _XOPEN_SOURCE 600
|
2016-03-29 02:02:43 +01:00
|
|
|
#endif /* !_XOPEN_SOURCE */
|
2011-11-02 22:53:49 +00:00
|
|
|
#endif /* USE_PTHREAD_LOCKING */
|
|
|
|
#include <pthread.h>
|
|
|
|
#endif /* THREADS */
|
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
/* null pointer */
|
2016-03-29 02:02:43 +01:00
|
|
|
#define NIL 0
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* Basic types */
|
2016-03-29 02:02:43 +01:00
|
|
|
#if HAVE_SIGPROF && (defined(__linux__) || defined(__APPLE__))
|
2005-05-27 23:27:59 +01:00
|
|
|
#define LOW_PROF 1
|
|
|
|
#endif
|
|
|
|
|
2014-10-28 12:56:26 +00:00
|
|
|
#if !defined(HAVE_STRNLEN)
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN size_t strnlen(const char *s, size_t maxlen);
|
2014-10-28 12:56:26 +00:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
INLINE_ONLY inline EXTERN size_t strnlen(const char *s, size_t maxlen) {
|
2014-10-28 12:56:26 +00:00
|
|
|
size_t i = 0;
|
|
|
|
while (s[i]) {
|
|
|
|
if (i == maxlen)
|
|
|
|
return i;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
#endif
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* #define FORCE_SECOND_QUADRANT 1 */
|
|
|
|
|
|
|
|
#if defined(FORCE_SECOND_QUADRANT)
|
|
|
|
#define IN_SECOND_QUADRANT 1
|
|
|
|
#define MMAP_ADDR 0x42000000
|
2011-05-25 16:40:36 +01:00
|
|
|
#endif /* FORCE_SECOND_QUADRANT */
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2008-03-25 22:03:14 +00:00
|
|
|
#if !defined(IN_SECOND_QUADRANT)
|
2016-03-29 02:02:43 +01:00
|
|
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
|
2016-05-30 11:18:35 +01:00
|
|
|
defined(mips) || defined(__mips64) || defined(__aarch64__) || (__DragonFly__)
|
2005-05-27 23:27:59 +01:00
|
|
|
#if defined(YAPOR) && defined(__alpha)
|
|
|
|
|
|
|
|
#define MMAP_ADDR 0x40000000
|
2008-03-25 22:03:14 +00:00
|
|
|
#elif defined(mips)
|
2005-05-27 23:27:59 +01:00
|
|
|
#define MMAP_ADDR 0x02000000
|
2016-05-30 11:18:35 +01:00
|
|
|
#elif defined(__mips64)
|
|
|
|
#define MMAP_ADDR 0x02000000
|
|
|
|
#elif defined(__aarch64__)
|
|
|
|
#define MMAP_ADDR 0x02000000
|
2010-12-31 04:14:45 +00:00
|
|
|
#elif defined(__powerpc__)
|
|
|
|
#define MMAP_ADDR 0x20000000
|
2005-05-27 23:27:59 +01:00
|
|
|
#else
|
2009-10-16 08:09:22 +01:00
|
|
|
#define MMAP_ADDR 0x10000000
|
2011-05-25 16:40:36 +01:00
|
|
|
#endif /* YAPOR && __alpha */
|
2005-05-27 23:27:59 +01:00
|
|
|
#elif __svr4__ || defined(__SVR4)
|
|
|
|
#define MMAP_ADDR 0x02000000
|
2016-05-30 11:18:35 +01:00
|
|
|
#endif /* __linux__ || __FreeBSD__ || __NetBSD__ || mips || __mips64 || __APPLE__ || \
|
2016-03-29 02:02:43 +01:00
|
|
|
__DragonFly__ */
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif /* !IN_SECOND_QUADRANT */
|
|
|
|
|
2010-06-19 14:38:04 +01:00
|
|
|
/* #define RANDOMIZE_START_ADDRESS 1 */
|
2009-11-18 23:32:00 +00:00
|
|
|
|
2008-05-15 14:41:48 +01:00
|
|
|
#ifdef USE_SYSTEM_MALLOC
|
2016-03-29 02:02:43 +01:00
|
|
|
#define HEAP_INIT_BASE 0L
|
|
|
|
#define AtomBase NULL
|
2011-05-25 16:40:36 +01:00
|
|
|
#else /* !USE_SYSTEM_MALLOC */
|
2016-03-29 02:02:43 +01:00
|
|
|
#if defined(MMAP_ADDR) && (defined(USE_MMAP) || USE_SHMAT) && \
|
|
|
|
!defined(__simplescalar__) && !defined(RANDOMIZE_START_ADDRESS)
|
|
|
|
#define HEAP_INIT_BASE (MMAP_ADDR)
|
|
|
|
#define AtomBase ((char *)MMAP_ADDR)
|
|
|
|
#else /*! (MMAP_ADDR && (USE_MMAP || USE_SHMAT) && !__simplescalar__ && \
|
|
|
|
!RANDOMIZE_START_ADDRESS) */
|
|
|
|
#define HEAP_INIT_BASE ((CELL)Yap_HeapBase)
|
|
|
|
#define AtomBase (Yap_HeapBase)
|
|
|
|
#endif /* MMAP_ADDR && (USE_MMAP || USE_SHMAT) && !__simplescalar__ && \
|
|
|
|
!RANDOMIZE_START_ADDRESS */
|
2011-05-25 16:40:36 +01:00
|
|
|
#endif /* USE_SYSTEM_MALLOC */
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#ifndef ALIGN_LONGS
|
|
|
|
#define ALIGN_LONGS 1
|
|
|
|
#endif
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define K1 ((CELL)1024)
|
|
|
|
#define K16 ((CELL)(1024 * 64))
|
|
|
|
#define K64 ((CELL)(1024 * 64))
|
|
|
|
#define M1 ((CELL)(1024 * 1024))
|
|
|
|
#define M2 ((CELL)(2048 * 1024))
|
2010-05-11 12:25:49 +01:00
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
#if ALIGN_LONGS
|
|
|
|
typedef CELL SFLAGS;
|
|
|
|
#else
|
|
|
|
typedef BITS16 SFLAGS;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef char *ADDR;
|
|
|
|
typedef CELL OFFSET;
|
|
|
|
typedef unsigned char *CODEADDR;
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define TermPtr(V) ((Term *)(V))
|
|
|
|
#define Addr(V) ((ADDR)(V))
|
2011-06-21 16:53:17 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define CodePtr(V) ((CODEADDR)(V))
|
|
|
|
#define CellPtr(V) ((CELL *)(V))
|
|
|
|
#define OpCodePtr(V) ((OPCODE *)(V))
|
|
|
|
#define OpRegPtr(V) ((OPREG *)(V))
|
|
|
|
#define SmallPtr(V) ((SMALLUNSGN *)(V))
|
|
|
|
#define WordPtr(V) ((BITS16 *)(V))
|
|
|
|
#define DisplPtr(V) ((DISPREG *)(V))
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#if !defined(YAPOR) && !defined(THREADS)
|
|
|
|
#include <nolocks.h>
|
2015-06-19 00:53:09 +01:00
|
|
|
#else
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#ifndef _XOPEN_SOURCE
|
|
|
|
#define _XOPEN_SOURCE 600
|
|
|
|
#endif
|
|
|
|
|
2010-04-19 02:34:08 +01:00
|
|
|
#include <locks_pthread.h>
|
2005-05-27 23:27:59 +01:00
|
|
|
typedef pthread_mutex_t lockvar;
|
|
|
|
typedef pthread_rwlock_t rwlock_t;
|
2015-06-19 00:53:09 +01:00
|
|
|
#endif
|
|
|
|
/*
|
2010-10-15 02:06:37 +01:00
|
|
|
#elif defined(i386)|| defined(__x86_64__)
|
2005-05-27 23:27:59 +01:00
|
|
|
typedef volatile int lockvar;
|
2010-04-19 02:34:08 +01:00
|
|
|
#include <locks_x86.h>
|
2005-05-27 23:27:59 +01:00
|
|
|
#elif defined(sparc) || defined(__sparc)
|
|
|
|
typedef volatile int lockvar;
|
2010-04-19 02:34:08 +01:00
|
|
|
#include <locks_sparc.h>
|
2005-05-27 23:27:59 +01:00
|
|
|
#elif defined(__alpha)
|
|
|
|
typedef volatile int lockvar;
|
2010-04-19 02:34:08 +01:00
|
|
|
#include <locks_alpha.h>
|
2005-05-27 23:27:59 +01:00
|
|
|
#else
|
|
|
|
|
|
|
|
#ifndef _XOPEN_SOURCE
|
|
|
|
#define _XOPEN_SOURCE 600
|
|
|
|
#endif
|
2015-06-19 00:53:09 +01:00
|
|
|
*/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2014-06-12 01:25:50 +01:00
|
|
|
#define FUNC_READ_LOCK(X) READ_LOCK((X)->FRWLock)
|
|
|
|
#define FUNC_READ_UNLOCK(X) READ_UNLOCK((X)->FRWLock)
|
|
|
|
#define FUNC_WRITE_LOCK(X) WRITE_LOCK((X)->FRWLock)
|
|
|
|
#define FUNC_WRITE_UNLOCK(X) WRITE_UNLOCK((X)->FRWLock)
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
2015-01-20 03:00:42 +00:00
|
|
|
use an auxiliary function for ranges
|
2011-05-25 16:40:36 +01:00
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
2016-03-29 02:02:43 +01:00
|
|
|
#define IN_BETWEEN(MIN, X, MAX) \
|
|
|
|
(Unsigned((Int)(X) - (Int)(MIN)) <= Unsigned((Int)(MAX) - (Int)(MIN)))
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define OUTSIDE(MIN, X, MAX) \
|
|
|
|
(Unsigned((Int)(X) - (Int)(MIN)) > Unsigned((Int)(MAX) - (Int)(MIN)))
|
2005-05-27 23:27:59 +01:00
|
|
|
#else
|
2016-03-29 02:02:43 +01:00
|
|
|
#define IN_BETWEEN(MIN, X, MAX) \
|
|
|
|
((void *)(X) >= (void *)(MIN) && (void *)(X) <= (void *)(MAX))
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define OUTSIDE(MIN, X, MAX) \
|
|
|
|
((void *)(X) < (void *)(MIN) || (void *)(X) > (void *)(MAX))
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif
|
|
|
|
|
2014-05-25 20:50:07 +01:00
|
|
|
/*************************************************************************************************
|
2015-01-20 03:00:42 +00:00
|
|
|
Atoms
|
2011-05-25 16:40:36 +01:00
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#include "Atoms.h"
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
2015-01-20 03:00:42 +00:00
|
|
|
Coroutining
|
2011-05-25 16:40:36 +01:00
|
|
|
*************************************************************************************************/
|
|
|
|
|
2005-05-27 23:27:59 +01:00
|
|
|
#ifdef COROUTINING
|
|
|
|
/* Support for co-routining */
|
|
|
|
#include "corout.h"
|
|
|
|
#endif
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
2015-01-20 03:00:42 +00:00
|
|
|
abstract machine registers
|
2011-05-25 16:40:36 +01:00
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#include "amidefs.h"
|
|
|
|
|
|
|
|
#include "Regs.h"
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/*************************************************************************************************
|
|
|
|
OPTYAP includes
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
#if defined(YAPOR) || defined(TABLING)
|
|
|
|
#include "opt.structs.h"
|
2016-03-29 02:02:43 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#include "opt.proto.h"
|
2016-03-29 02:02:43 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#include "opt.macros.h"
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#endif /* YAPOR || TABLING */
|
2016-01-03 02:06:09 +00:00
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
2015-01-20 03:00:42 +00:00
|
|
|
variables concerned with Error Handling
|
2011-05-25 16:40:36 +01:00
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
|
|
#if defined(SIMICS) || !HAVE_SIGSETJMP
|
|
|
|
#define sigjmp_buf jmp_buf
|
|
|
|
#define sigsetjmp(Env, Arg) setjmp(Env)
|
|
|
|
#define siglongjmp(Env, Arg) longjmp(Env, Arg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Support for arrays */
|
|
|
|
#include "arrays.h"
|
|
|
|
|
2013-10-03 11:24:59 +01:00
|
|
|
#include "YapError.h"
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
typedef enum {
|
2012-03-09 11:46:34 +00:00
|
|
|
GPROF_NO_EVENT,
|
|
|
|
GPROF_NEW_PRED_FUNC,
|
|
|
|
GPROF_NEW_PRED_THREAD,
|
|
|
|
GPROF_NEW_PRED_ATOM,
|
|
|
|
GPROF_INDEX,
|
|
|
|
GPROF_INDEX_EXPAND,
|
|
|
|
GPROF_CLAUSE,
|
|
|
|
GPROF_MEGA,
|
|
|
|
GPROF_LU_INDEX,
|
|
|
|
GPROF_STATIC_INDEX,
|
|
|
|
GPROF_INIT_OPCODE,
|
|
|
|
GPROF_INIT_SYSTEM_CODE,
|
|
|
|
GPROF_INIT_EXPAND,
|
|
|
|
GPROF_INIT_LOG_UPD_CLAUSE,
|
|
|
|
GPROF_INIT_DYNAMIC_CLAUSE,
|
|
|
|
GPROF_INIT_STATIC_CLAUSE,
|
|
|
|
GPROF_INIT_COMMA,
|
|
|
|
GPROF_INIT_FAIL,
|
|
|
|
GPROF_NEW_LU_CLAUSE,
|
|
|
|
GPROF_NEW_LU_SWITCH,
|
|
|
|
GPROF_NEW_STATIC_SWITCH,
|
|
|
|
GPROF_NEW_EXPAND_BLOCK
|
|
|
|
} gprof_info;
|
|
|
|
|
2013-04-30 21:23:01 +01:00
|
|
|
#define MAX_EMPTY_WAKEUPS 16
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
prototypes
|
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#include "Yapproto.h"
|
|
|
|
|
2011-11-02 22:53:49 +00:00
|
|
|
#include "YapTags.h"
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define TermSize sizeof(Term)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
2015-01-20 03:00:42 +00:00
|
|
|
variables related to memory allocation
|
2011-05-25 16:40:36 +01:00
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
/* must be before TermExt.h */
|
|
|
|
|
|
|
|
extern ADDR Yap_HeapBase;
|
|
|
|
|
|
|
|
/* This is ok for Linux, should be ok for everyone */
|
|
|
|
#define YAP_FILENAME_MAX 1024
|
|
|
|
|
|
|
|
#define MAX_ERROR_MSG_SIZE YAP_FILENAME_MAX
|
|
|
|
|
2011-06-20 14:49:24 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
Debugging Support
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
extern int Yap_output_msg;
|
|
|
|
#endif
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2014-06-12 01:25:50 +01:00
|
|
|
#if __ANDROID__
|
2016-05-30 11:18:35 +01:00
|
|
|
|
2014-06-12 01:25:50 +01:00
|
|
|
#include <android/asset_manager.h>
|
|
|
|
#include <android/asset_manager_jni.h>
|
|
|
|
#include <android/log.h>
|
2016-03-29 02:02:43 +01:00
|
|
|
#include <jni.h>
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
extern AAssetManager *Yap_assetManager;
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
extern void *Yap_openAssetFile(const char *path);
|
|
|
|
extern bool Yap_isAsset(const char *path);
|
|
|
|
extern bool Yap_AccessAsset(const char *name, int mode);
|
|
|
|
extern bool Yap_AssetIsFile(const char *name);
|
|
|
|
extern bool Yap_AssetIsDir(const char *name);
|
|
|
|
extern int64_t Yap_AssetSize(const char *name);
|
2014-06-12 01:25:50 +01:00
|
|
|
#endif
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
variables concerned with atoms table
|
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define MaxHash 3333
|
|
|
|
#define MaxWideHash (MaxHash / 10 + 1)
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-04-18 01:05:03 +01:00
|
|
|
typedef enum e_restore_t {
|
|
|
|
FAIL_RESTORE = 0,
|
|
|
|
DO_EVERYTHING = 1,
|
|
|
|
DO_ONLY_CODE = 2,
|
|
|
|
YAP_BOOT_FROM_PROLOG = 4
|
|
|
|
} restore_t;
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
common instructions codes
|
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define MAX_PROMPT 256
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#if USE_THREADED_CODE
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
reverse lookup of instructions
|
|
|
|
*************************************************************************************************/
|
2016-03-29 02:02:43 +01:00
|
|
|
typedef struct opcode_tab_entry {
|
2005-05-27 23:27:59 +01:00
|
|
|
OPCODE opc;
|
|
|
|
op_numbers opnum;
|
2014-12-14 11:49:51 +00:00
|
|
|
} op_entry;
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
2015-01-20 03:00:42 +00:00
|
|
|
Prolog may be in several modes
|
2011-05-25 16:40:36 +01:00
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
typedef enum {
|
|
|
|
BootMode = 0x1, /** if booting or restoring */
|
|
|
|
UserMode = 0x2, /** Normal mode */
|
|
|
|
CritMode = 0x4, /** If we are meddling with the heap */
|
|
|
|
AbortMode = 0x8, /** expecting to abort */
|
|
|
|
InterruptMode = 0x10, /*8 under an interrupt */
|
|
|
|
InErrorMode = 0x20, /** error handling */
|
|
|
|
ConsoleGetcMode = 0x40, /** blocked reading from console */
|
|
|
|
ExtendStackMode = 0x80, /** trying to extend stack */
|
|
|
|
GrowHeapMode = 0x100, /** extending Heap */
|
|
|
|
GrowStackMode = 0x200, /** extending Stack */
|
|
|
|
GCMode = 0x400, /** doing Garbage Collecting */
|
|
|
|
ErrorHandlingMode = 0x800, /** doing error handling */
|
|
|
|
CCallMode = 0x1000, /** In c Call */
|
|
|
|
UnifyMode = 0x2000, /** In Unify Code */
|
|
|
|
UserCCallMode = 0x4000, /** In User C-call Code */
|
|
|
|
MallocMode = 0x8000, /** Doing malloc, realloc, free */
|
|
|
|
SystemMode = 0x10000, /** in system mode */
|
|
|
|
AsyncIntMode = 0x20000, /** YAP has just been interrupted from the outside */
|
|
|
|
InReadlineMode =
|
|
|
|
0x40000, /** YAP has just been interrupted from the outside */
|
|
|
|
TopGoalMode = 0x40000 /** creating a new autonomous goal */
|
2005-05-27 23:27:59 +01:00
|
|
|
} prolog_exec_mode;
|
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
/*************************************************************************************************
|
2011-05-25 16:40:36 +01:00
|
|
|
number of modules
|
2011-05-23 16:19:47 +01:00
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define DefaultMaxModules 256
|
2005-05-27 23:27:59 +01:00
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
Critical sections
|
|
|
|
*************************************************************************************************/
|
2008-03-25 22:03:14 +00:00
|
|
|
#ifdef YAPOR
|
2016-03-29 02:02:43 +01:00
|
|
|
#define YAPEnterCriticalSection() \
|
|
|
|
{ \
|
|
|
|
if (worker_id != GLOBAL_locks_who_locked_heap) { \
|
|
|
|
LOCK(GLOBAL_locks_heap_access); \
|
|
|
|
GLOBAL_locks_who_locked_heap = worker_id; \
|
|
|
|
} \
|
|
|
|
LOCAL_PrologMode |= CritMode; \
|
|
|
|
LOCAL_CritLocks++; \
|
|
|
|
}
|
|
|
|
#define YAPLeaveCriticalSection() \
|
|
|
|
{ \
|
|
|
|
LOCAL_CritLocks--; \
|
|
|
|
if (!LOCAL_CritLocks) { \
|
|
|
|
LOCAL_PrologMode &= ~CritMode; \
|
|
|
|
if (LOCAL_PrologMode & AbortMode) { \
|
|
|
|
LOCAL_PrologMode &= ~AbortMode; \
|
|
|
|
Yap_Error(ABORT_EVENT, 0, ""); \
|
|
|
|
} \
|
|
|
|
GLOBAL_locks_who_locked_heap = MAX_WORKERS; \
|
|
|
|
UNLOCK(GLOBAL_locks_heap_access); \
|
|
|
|
} \
|
|
|
|
}
|
2008-03-25 22:03:14 +00:00
|
|
|
#elif defined(THREADS)
|
2016-03-29 02:02:43 +01:00
|
|
|
#define YAPEnterCriticalSection() \
|
|
|
|
{ \
|
|
|
|
/* LOCK(BGL); */ \
|
|
|
|
LOCAL_PrologMode |= CritMode; \
|
|
|
|
}
|
|
|
|
#define YAPLeaveCriticalSection() \
|
|
|
|
{ \
|
|
|
|
LOCAL_PrologMode &= ~CritMode; \
|
|
|
|
if (LOCAL_PrologMode & AbortMode) { \
|
|
|
|
LOCAL_PrologMode &= ~AbortMode; \
|
|
|
|
Yap_Error(ABORT_EVENT, 0, ""); \
|
|
|
|
Yap_RestartYap(1); \
|
|
|
|
} \
|
|
|
|
/* UNLOCK(BGL); */ \
|
|
|
|
}
|
2005-05-27 23:27:59 +01:00
|
|
|
#else
|
2016-03-29 02:02:43 +01:00
|
|
|
#define YAPEnterCriticalSection() \
|
|
|
|
{ \
|
|
|
|
LOCAL_PrologMode |= \
|
|
|
|
CritMode; /* printf("%d, \
|
|
|
|
%s:%d\n",LOCAL_CritLocks+1,__FILE__,__LINE__);*/ \
|
|
|
|
LOCAL_CritLocks++; \
|
|
|
|
}
|
|
|
|
#define YAPLeaveCriticalSection() \
|
|
|
|
{ \
|
|
|
|
LOCAL_CritLocks--; \
|
|
|
|
/*printf("%d, %s:%d\n",LOCAL_CritLocks,__FILE__,__LINE__);*/ \
|
|
|
|
if (!LOCAL_CritLocks) { \
|
|
|
|
LOCAL_PrologMode &= ~CritMode; \
|
|
|
|
if (LOCAL_PrologMode & AbortMode) { \
|
|
|
|
LOCAL_PrologMode &= ~AbortMode; \
|
|
|
|
Yap_RestartYap(1); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
2005-05-27 23:27:59 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
|
|
|
|
/* when we are calling the InitStaff procedures */
|
2016-03-29 02:02:43 +01:00
|
|
|
#define AT_BOOT 0
|
|
|
|
#define AT_RESTORE 1
|
2011-05-25 16:40:36 +01:00
|
|
|
|
|
|
|
/*************************************************************************************************
|
|
|
|
mutable variables
|
|
|
|
*************************************************************************************************/
|
2005-05-27 23:27:59 +01:00
|
|
|
|
|
|
|
/* I assume that the size of this structure is a multiple of the size
|
|
|
|
of CELL!!! */
|
2016-03-29 02:02:43 +01:00
|
|
|
typedef struct TIMED_MAVAR {
|
2005-05-27 23:27:59 +01:00
|
|
|
CELL value;
|
|
|
|
CELL clock;
|
|
|
|
} timed_var;
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
execution mode
|
|
|
|
*************************************************************************************************/
|
2009-04-08 00:32:36 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
typedef enum {
|
|
|
|
INTERPRETED = 0x1, /* interpreted */
|
|
|
|
MIXED_MODE_USER = 0x2, /* mixed mode only for user predicates */
|
|
|
|
MIXED_MODE_ALL = 0x4, /* mixed mode for all predicates */
|
|
|
|
COMPILE_USER = 0x8, /* compile all user predicates*/
|
|
|
|
COMPILE_ALL = 0x10 /* compile all predicates */
|
|
|
|
} yap_exec_mode;
|
2009-04-08 00:32:36 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define MIXED_MODE (MIXED_MODE_USER | MIXED_MODE_ALL)
|
2015-01-20 03:00:42 +00:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define COMPILED (COMPILE_USER | COMPILE_ALL)
|
2011-05-25 16:40:36 +01:00
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
/************************/
|
2016-03-29 02:02:43 +01:00
|
|
|
// queues are an example of collections of DB objects
|
|
|
|
typedef struct queue_entry {
|
|
|
|
struct queue_entry *next;
|
|
|
|
struct DB_TERM *DBT;
|
|
|
|
} QueueEntry;
|
|
|
|
|
|
|
|
typedef struct idb_queue {
|
|
|
|
struct FunctorEntryStruct
|
|
|
|
*id; /* identify this as being pointed to by a DBRef */
|
|
|
|
SMALLUNSGN Flags; /* always required */
|
|
|
|
#if PARALLEL_YAP
|
|
|
|
rwlock_t QRWLock; /* a simple lock to protect this entry */
|
|
|
|
#endif
|
|
|
|
QueueEntry *FirstInQueue, *LastInQueue;
|
|
|
|
} db_queue;
|
|
|
|
|
|
|
|
void Yap_init_tqueue(db_queue *dbq);
|
|
|
|
void Yap_destroy_tqueue(db_queue *dbq USES_REGS);
|
2014-10-13 12:34:52 +01:00
|
|
|
bool Yap_enqueue_tqueue(db_queue *father_key, Term t USES_REGS);
|
2016-03-29 02:02:43 +01:00
|
|
|
bool Yap_dequeue_tqueue(db_queue *father_key, Term t, bool first,
|
|
|
|
bool release USES_REGS);
|
2014-10-13 12:34:52 +01:00
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
#ifdef THREADS
|
2014-10-13 12:34:52 +01:00
|
|
|
|
|
|
|
typedef struct thread_mbox {
|
2016-03-29 02:02:43 +01:00
|
|
|
Term name;
|
|
|
|
pthread_mutex_t mutex;
|
|
|
|
pthread_cond_t cond;
|
|
|
|
struct idb_queue msgs;
|
|
|
|
int nmsgs, nclients; // if nclients < 0 mailbox has been closed.
|
|
|
|
bool open;
|
|
|
|
struct thread_mbox *next;
|
2014-10-13 12:34:52 +01:00
|
|
|
} mbox_t;
|
|
|
|
|
2011-05-23 16:19:47 +01:00
|
|
|
typedef struct thandle {
|
|
|
|
int in_use;
|
|
|
|
int zombie;
|
|
|
|
UInt ssize;
|
|
|
|
UInt tsize;
|
|
|
|
UInt sysize;
|
|
|
|
void *stack_address;
|
|
|
|
Term tdetach;
|
2016-03-29 02:02:43 +01:00
|
|
|
Term cmod, texit_mod;
|
2011-05-23 16:19:47 +01:00
|
|
|
struct DB_TERM *tgoal, *texit;
|
|
|
|
int id;
|
|
|
|
int ret;
|
|
|
|
REGSTORE *default_yaam_regs;
|
|
|
|
REGSTORE *current_yaam_regs;
|
|
|
|
struct pred_entry *local_preds;
|
|
|
|
pthread_t pthread_handle;
|
2016-03-29 02:02:43 +01:00
|
|
|
mbox_t mbox_handle;
|
2011-05-23 16:19:47 +01:00
|
|
|
int ref_count;
|
|
|
|
#ifdef LOW_LEVEL_TRACER
|
|
|
|
long long int thread_inst_count;
|
|
|
|
int been_here1;
|
|
|
|
int been_here2;
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
int been_here;
|
|
|
|
#endif
|
|
|
|
pthread_mutex_t tlock;
|
|
|
|
pthread_mutex_t tlock_status;
|
2013-02-05 14:22:17 +00:00
|
|
|
#if HAVE_GETHRTIME
|
|
|
|
hrtime_t start_of_w_times;
|
|
|
|
hrtime_t last_w_time;
|
|
|
|
#endif
|
2012-12-20 21:13:20 +00:00
|
|
|
#if HAVE_GETRUSAGE
|
2011-05-23 16:19:47 +01:00
|
|
|
struct timeval *start_of_timesp;
|
|
|
|
struct timeval *last_timep;
|
2012-12-11 22:07:10 +00:00
|
|
|
struct timeval *start_of_times_sysp;
|
|
|
|
struct timeval *last_time_sysp;
|
2012-12-20 21:13:20 +00:00
|
|
|
#elif _WIN32
|
|
|
|
struct _FILETIME *start_of_timesp;
|
|
|
|
struct _FILETIME *last_timep;
|
|
|
|
struct _FILETIME *start_of_times_sysp;
|
|
|
|
struct _FILETIME *last_time_sysp;
|
2011-05-23 16:19:47 +01:00
|
|
|
#endif
|
|
|
|
} yap_thandle;
|
|
|
|
#endif /* THREADS */
|
|
|
|
|
|
|
|
#define GC_MAVARS_HASH_SIZE 512
|
|
|
|
typedef struct gc_ma_hash_entry_struct {
|
|
|
|
UInt timestmp;
|
|
|
|
#ifdef TABLING
|
|
|
|
tr_fr_ptr loc;
|
|
|
|
struct gc_ma_hash_entry_struct *more;
|
|
|
|
#endif
|
2016-03-29 02:02:43 +01:00
|
|
|
CELL *addr;
|
2011-05-23 16:19:47 +01:00
|
|
|
struct gc_ma_hash_entry_struct *next;
|
|
|
|
} gc_ma_hash_entry;
|
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
typedef int (*Agc_hook)(Atom);
|
2011-05-23 16:19:47 +01:00
|
|
|
|
|
|
|
typedef struct scratch_block_struct {
|
|
|
|
char *ptr;
|
|
|
|
UInt sz, msz;
|
|
|
|
} scratch_block;
|
|
|
|
|
|
|
|
/* scanner types */
|
|
|
|
#include "ScannerTypes.h"
|
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
GLOBAL and LOCAL variables
|
|
|
|
*************************************************************************************************/
|
2011-05-23 16:19:47 +01:00
|
|
|
|
|
|
|
#if defined(YAPOR_COPY) || defined(YAPOR_COW) || defined(YAPOR_SBA)
|
|
|
|
extern struct global_data *Yap_global;
|
|
|
|
extern long Yap_worker_area_size;
|
|
|
|
#else
|
|
|
|
extern struct global_data Yap_Global;
|
|
|
|
#define Yap_global (&Yap_Global)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(THREADS)
|
|
|
|
extern struct worker_local *Yap_local[MAX_THREADS];
|
2016-03-29 02:02:43 +01:00
|
|
|
#define REMOTE(wid) (Yap_local[wid])
|
2011-05-23 16:19:47 +01:00
|
|
|
#elif defined(YAPOR)
|
|
|
|
extern struct worker_local *Yap_local;
|
2016-03-29 02:02:43 +01:00
|
|
|
#define REMOTE(wid) (Yap_local + wid)
|
2011-05-23 16:19:47 +01:00
|
|
|
#else /* !THREADS && !YAPOR */
|
|
|
|
extern struct worker_local Yap_local;
|
2016-03-29 02:02:43 +01:00
|
|
|
#define REMOTE(wid) (&Yap_local)
|
2011-05-23 16:19:47 +01:00
|
|
|
#endif
|
|
|
|
|
2015-06-19 00:53:09 +01:00
|
|
|
#include "encoding.h"
|
|
|
|
|
2012-04-18 20:14:56 +01:00
|
|
|
#include <stdio.h>
|
2016-03-29 02:02:43 +01:00
|
|
|
#define YP_FILE FILE
|
2016-01-03 02:06:09 +00:00
|
|
|
|
|
|
|
#include <YapHeap.h>
|
2011-05-23 16:19:47 +01:00
|
|
|
|
2011-05-25 16:40:36 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
unification routines
|
|
|
|
*************************************************************************************************/
|
2011-05-23 16:19:47 +01:00
|
|
|
|
|
|
|
#ifdef YAPOR_SBA
|
|
|
|
#include "or.sba_amiops.h"
|
2011-06-02 17:01:00 +01:00
|
|
|
#include "or.sba_unify.h"
|
2011-05-23 16:19:47 +01:00
|
|
|
#else
|
|
|
|
#include "amiops.h"
|
|
|
|
#endif /* YAPOR_SBA */
|
|
|
|
|
2013-09-04 11:05:01 +01:00
|
|
|
/*************************************************************************************************
|
|
|
|
unification support
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
#include "YapCompoundTerm.h"
|
2011-05-25 16:40:36 +01:00
|
|
|
|
2013-11-20 22:27:46 +00:00
|
|
|
#include "YapHandles.h"
|
2011-07-27 16:31:10 +01:00
|
|
|
|
2014-03-06 02:09:48 +00:00
|
|
|
// take care of signal handling within YAP
|
|
|
|
|
|
|
|
#include "YapSignals.h"
|
|
|
|
|
2015-01-20 03:00:42 +00:00
|
|
|
/*************************************************************************************************
|
|
|
|
Global variables for JIT
|
|
|
|
*************************************************************************************************/
|
|
|
|
|
|
|
|
#if YAP_JIT
|
|
|
|
#ifndef __cplusplus
|
|
|
|
#ifndef _NATIVE
|
|
|
|
#include "JIT.hpp"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
2014-03-06 02:09:48 +00:00
|
|
|
|
2015-04-13 13:28:17 +01:00
|
|
|
#if DEBUGX
|
2016-03-29 02:02:43 +01:00
|
|
|
inline static void LOG0(const char *f, int l, const char *fmt, ...) {
|
2015-04-13 13:28:17 +01:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
#if __ANDROID__
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, "YAP ", fmt, ap);
|
|
|
|
#else __WINDOWS__
|
2016-03-29 02:02:43 +01:00
|
|
|
FILE *fd;
|
|
|
|
fd = fopen("c:\\cygwin\\Log.txt", "a");
|
|
|
|
vfprintf(fd, fmt, ap);
|
|
|
|
fclose(fd);
|
2015-04-13 13:28:17 +01:00
|
|
|
#endif
|
2016-03-29 02:02:43 +01:00
|
|
|
vfprintf(stderr, fmt, ap);
|
|
|
|
va_end(ap);
|
2015-04-13 13:28:17 +01:00
|
|
|
}
|
2015-04-15 11:21:15 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define LOG(...) LOG0(__FILE__, __LINE__, __VA_ARGS__)
|
2015-04-15 11:21:15 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define REGS_LOG(...) CACHE_REGS LOG0(__FILE__, __LINE__, __VA_ARGS__)
|
2015-04-15 11:21:15 +01:00
|
|
|
|
2015-04-13 13:28:17 +01:00
|
|
|
#else
|
2016-03-29 02:02:43 +01:00
|
|
|
#define LOG(...)
|
2015-04-15 11:21:15 +01:00
|
|
|
|
2016-03-29 02:02:43 +01:00
|
|
|
#define REGS_LOG(...)
|
2015-04-13 13:28:17 +01:00
|
|
|
#endif
|
|
|
|
|
2015-07-28 04:22:44 +01:00
|
|
|
// YAP lexicon
|
|
|
|
|
2015-06-19 00:53:09 +01:00
|
|
|
#include "GitSHA1.h"
|
2015-04-13 13:28:17 +01:00
|
|
|
|
2011-03-02 23:19:39 +00:00
|
|
|
#endif /* YAP_H */
|