2010-04-03 05:58:14 +01:00
|
|
|
/************************************************************************
|
|
|
|
** **
|
|
|
|
** The YapTab/YapOr/OPTYap systems **
|
|
|
|
** **
|
|
|
|
** YapTab extends the Yap Prolog engine to support sequential tabling **
|
|
|
|
** YapOr extends the Yap Prolog engine to support or-parallelism **
|
|
|
|
** OPTYap extends the Yap Prolog engine to support or-parallel tabling **
|
|
|
|
** **
|
|
|
|
** **
|
|
|
|
** Yap Prolog was developed at University of Porto, Portugal **
|
|
|
|
** **
|
|
|
|
************************************************************************/
|
2005-05-31 09:24:24 +01:00
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/***********************
|
2001-04-09 20:54:03 +01:00
|
|
|
** Includes **
|
2010-04-03 05:58:14 +01:00
|
|
|
***********************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
#include "Yap.h"
|
|
|
|
#if defined(YAPOR) || defined(TABLING)
|
2005-06-03 19:28:11 +01:00
|
|
|
#define OPT_MAVAR_STATIC
|
2001-04-09 20:54:03 +01:00
|
|
|
#include "Yatom.h"
|
2009-10-23 14:22:17 +01:00
|
|
|
#include "YapHeap.h"
|
2016-02-28 19:32:55 +00:00
|
|
|
#if HAVE_UNISTD_H
|
2001-04-09 20:54:03 +01:00
|
|
|
#include <unistd.h>
|
2016-02-28 19:32:55 +00:00
|
|
|
#endif
|
2001-04-09 20:54:03 +01:00
|
|
|
#include <signal.h>
|
|
|
|
#ifdef YAPOR
|
|
|
|
#include "or.macros.h"
|
2016-01-03 02:06:09 +00:00
|
|
|
#endif /* YAPOR */
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef TABLING
|
|
|
|
#include "tab.macros.h"
|
2011-04-14 19:19:13 +01:00
|
|
|
#elif !defined(YAPOR_COW)
|
2001-04-09 20:54:03 +01:00
|
|
|
#include "opt.mavar.h"
|
2011-04-14 19:19:13 +01:00
|
|
|
#endif /* TABLING */
|
2011-03-30 16:39:09 +01:00
|
|
|
#ifdef YAPOR_COW
|
2001-04-09 20:54:03 +01:00
|
|
|
#include "sys/wait.h"
|
2011-03-30 16:39:09 +01:00
|
|
|
#endif /* YAPOR_COW */
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/*********************
|
|
|
|
** Macros **
|
|
|
|
*********************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2011-04-28 09:48:42 +01:00
|
|
|
#ifdef USE_PAGES_MALLOC
|
2016-01-03 02:06:09 +00:00
|
|
|
#define STRUCTS_PER_PAGE(STR_TYPE) \
|
|
|
|
((Yap_page_size - ADJUST_SIZE(sizeof(struct page_header))) / \
|
|
|
|
ADJUST_SIZE(sizeof(STR_TYPE)))
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
#define INIT_GLOBAL_PAGE_ENTRY(PG, STR_TYPE) \
|
|
|
|
INIT_LOCK(PgEnt_lock(PG)); \
|
|
|
|
PgEnt_pages_in_use(PG) = 0; \
|
|
|
|
PgEnt_strs_in_use(PG) = 0; \
|
|
|
|
PgEnt_strs_per_page(PG) = STRUCTS_PER_PAGE(STR_TYPE); \
|
|
|
|
PgEnt_first(PG) = NULL; \
|
|
|
|
PgEnt_last(PG) = NULL;
|
|
|
|
#define INIT_LOCAL_PAGE_ENTRY(PG, STR_TYPE) \
|
|
|
|
PgEnt_pages_in_use(PG) = 0; \
|
|
|
|
PgEnt_strs_in_use(PG) = 0; \
|
|
|
|
PgEnt_strs_per_page(PG) = STRUCTS_PER_PAGE(STR_TYPE); \
|
|
|
|
PgEnt_first(PG) = NULL; \
|
|
|
|
PgEnt_last(PG) = NULL;
|
2009-09-27 02:31:31 +01:00
|
|
|
#else
|
2016-01-03 02:06:09 +00:00
|
|
|
#define INIT_GLOBAL_PAGE_ENTRY(PG, STR_TYPE) PgEnt_strs_in_use(PG) = 0
|
|
|
|
#define INIT_LOCAL_PAGE_ENTRY(PG, STR_TYPE) PgEnt_strs_in_use(PG) = 0
|
2011-04-28 09:48:42 +01:00
|
|
|
#endif /* USE_PAGES_MALLOC */
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2010-04-03 05:58:14 +01:00
|
|
|
/*******************************
|
2001-04-09 20:54:03 +01:00
|
|
|
** Global functions **
|
2010-04-03 05:58:14 +01:00
|
|
|
*******************************/
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
void Yap_init_global_optyap_data(int max_table_size, int n_workers,
|
|
|
|
int sch_loop, int delay_load) {
|
2001-04-09 20:54:03 +01:00
|
|
|
int i;
|
|
|
|
|
2016-01-03 02:06:09 +00:00
|
|
|
/* global data related to memory management */
|
2012-05-22 14:47:47 +01:00
|
|
|
#ifdef USE_PAGES_MALLOC
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_alloc, void *);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_void, void *);
|
2012-05-22 14:47:47 +01:00
|
|
|
#endif /* USE_PAGES_MALLOC */
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef TABLING
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tab_ent, struct table_entry);
|
2011-12-07 13:53:20 +00:00
|
|
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_sg_ent, struct subgoal_entry);
|
2011-12-07 13:53:20 +00:00
|
|
|
#endif
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_sg_fr, struct subgoal_frame);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_dep_fr, struct dependency_frame);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_sg_node, struct subgoal_trie_node);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_sg_hash, struct subgoal_trie_hash);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_ans_node, struct answer_trie_node);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_ans_hash, struct answer_trie_hash);
|
|
|
|
#if defined(THREADS_FULL_SHARING)
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_ans_ref_node, struct answer_ref_node);
|
2011-12-07 13:53:20 +00:00
|
|
|
#endif
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_gt_node, struct global_trie_node);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_gt_hash, struct global_trie_hash);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* TABLING */
|
2011-12-07 13:53:20 +00:00
|
|
|
#ifdef YAPOR
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_or_fr, struct or_frame);
|
2016-01-03 02:06:09 +00:00
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_sol_fr,
|
|
|
|
struct query_goal_solution_frame);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_qg_ans_fr,
|
|
|
|
struct query_goal_answer_frame);
|
2012-05-14 19:11:58 +01:00
|
|
|
#ifdef TABLING
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_susp_fr, struct suspension_frame);
|
|
|
|
#endif
|
2011-12-07 13:53:20 +00:00
|
|
|
#ifdef TABLING_INNER_CUTS
|
2016-01-03 02:06:09 +00:00
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_sol_fr,
|
|
|
|
struct table_subgoal_solution_frame);
|
|
|
|
INIT_GLOBAL_PAGE_ENTRY(GLOBAL_pages_tg_ans_fr,
|
|
|
|
struct table_subgoal_answer_frame);
|
2012-05-14 19:11:58 +01:00
|
|
|
#endif
|
|
|
|
#endif /* YAPOR */
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
#ifdef YAPOR
|
|
|
|
/* global static data */
|
2016-01-03 02:06:09 +00:00
|
|
|
GLOBAL_number_workers = n_workers;
|
2011-05-10 11:47:18 +01:00
|
|
|
GLOBAL_worker_pid(0) = getpid();
|
2016-01-03 02:06:09 +00:00
|
|
|
for (i = 1; i < GLOBAL_number_workers; i++)
|
|
|
|
GLOBAL_worker_pid(i) = 0;
|
2011-05-10 11:47:18 +01:00
|
|
|
GLOBAL_scheduler_loop = sch_loop;
|
|
|
|
GLOBAL_delayed_release_load = delay_load;
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* global data related to or-parallelism */
|
2011-05-10 11:47:18 +01:00
|
|
|
ALLOC_OR_FRAME(GLOBAL_root_or_fr);
|
|
|
|
BITMAP_clear(GLOBAL_bm_present_workers);
|
2016-01-03 02:06:09 +00:00
|
|
|
for (i = 0; i < GLOBAL_number_workers; i++)
|
2011-05-10 11:47:18 +01:00
|
|
|
BITMAP_insert(GLOBAL_bm_present_workers, i);
|
|
|
|
BITMAP_copy(GLOBAL_bm_idle_workers, GLOBAL_bm_present_workers);
|
|
|
|
BITMAP_clear(GLOBAL_bm_root_cp_workers);
|
|
|
|
BITMAP_clear(GLOBAL_bm_invisible_workers);
|
|
|
|
BITMAP_clear(GLOBAL_bm_requestable_workers);
|
|
|
|
BITMAP_copy(GLOBAL_bm_finished_workers, GLOBAL_bm_present_workers);
|
|
|
|
INIT_LOCK(GLOBAL_locks_bm_idle_workers);
|
|
|
|
INIT_LOCK(GLOBAL_locks_bm_root_cp_workers);
|
|
|
|
INIT_LOCK(GLOBAL_locks_bm_invisible_workers);
|
|
|
|
INIT_LOCK(GLOBAL_locks_bm_requestable_workers);
|
|
|
|
INIT_LOCK(GLOBAL_locks_bm_finished_workers);
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef TABLING_INNER_CUTS
|
2011-05-10 11:47:18 +01:00
|
|
|
INIT_LOCK(GLOBAL_locks_bm_pruning_workers);
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* TABLING_INNER_CUTS */
|
2011-05-10 11:47:18 +01:00
|
|
|
GLOBAL_locks_who_locked_heap = MAX_WORKERS;
|
|
|
|
INIT_LOCK(GLOBAL_locks_heap_access);
|
|
|
|
INIT_LOCK(GLOBAL_locks_alloc_block);
|
2011-06-21 15:19:07 +01:00
|
|
|
if (GLOBAL_number_workers == 1)
|
|
|
|
GLOBAL_parallel_mode = PARALLEL_MODE_OFF;
|
2001-04-09 20:54:03 +01:00
|
|
|
else
|
2011-06-21 15:19:07 +01:00
|
|
|
GLOBAL_parallel_mode = PARALLEL_MODE_ON;
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
|
|
|
|
#ifdef TABLING
|
|
|
|
/* global data related to tabling */
|
2012-05-14 19:11:58 +01:00
|
|
|
GLOBAL_root_gt = NULL;
|
2011-05-10 11:47:18 +01:00
|
|
|
GLOBAL_root_tab_ent = NULL;
|
2005-08-04 16:45:56 +01:00
|
|
|
#ifdef LIMIT_TABLING
|
2011-12-07 13:53:20 +00:00
|
|
|
if (max_table_size)
|
2016-01-03 02:06:09 +00:00
|
|
|
GLOBAL_max_pages = ((max_table_size - 1) * 1024 * 1024 / SHMMAX + 1) *
|
|
|
|
SHMMAX / Yap_page_size;
|
2011-12-07 13:53:20 +00:00
|
|
|
else
|
|
|
|
GLOBAL_max_pages = -1;
|
2011-05-10 11:47:18 +01:00
|
|
|
GLOBAL_first_sg_fr = NULL;
|
|
|
|
GLOBAL_last_sg_fr = NULL;
|
2011-05-10 12:20:22 +01:00
|
|
|
GLOBAL_check_sg_fr = NULL;
|
2005-08-04 16:45:56 +01:00
|
|
|
#endif /* LIMIT_TABLING */
|
2011-07-26 16:49:49 +01:00
|
|
|
#ifdef YAPOR
|
2016-01-03 02:06:09 +00:00
|
|
|
new_dependency_frame(GLOBAL_root_dep_fr, FALSE, NULL, NULL, NULL, NULL, FALSE,
|
|
|
|
NULL);
|
2011-07-26 16:49:49 +01:00
|
|
|
#endif /* YAPOR */
|
2005-11-04 01:17:17 +00:00
|
|
|
for (i = 0; i < MAX_TABLE_VARS; i++) {
|
2011-05-10 11:47:18 +01:00
|
|
|
CELL *pt = GLOBAL_table_var_enumerator_addr(i);
|
2005-11-04 01:17:17 +00:00
|
|
|
RESET_VARIABLE(pt);
|
|
|
|
}
|
2011-11-16 11:42:04 +00:00
|
|
|
#ifdef TRIE_LOCK_USING_GLOBAL_ARRAY
|
|
|
|
for (i = 0; i < TRIE_LOCK_BUCKETS; i++)
|
|
|
|
INIT_LOCK(GLOBAL_trie_locks(i));
|
|
|
|
#endif /* TRIE_LOCK_USING_GLOBAL_ARRAY */
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* TABLING */
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-09 19:36:51 +01:00
|
|
|
void Yap_init_local_optyap_data(int wid) {
|
2012-01-05 16:04:32 +00:00
|
|
|
#if defined(YAPOR_THREADS) || defined(THREADS_CONSUMER_SHARING)
|
2011-03-07 16:02:55 +00:00
|
|
|
CACHE_REGS
|
2012-01-05 16:04:32 +00:00
|
|
|
#endif /* YAPOR_THREADS || THREADS_CONSUMER_SHARING */
|
2011-12-07 13:53:20 +00:00
|
|
|
|
|
|
|
#if defined(TABLING) && (defined(YAPOR) || defined(THREADS))
|
2016-01-03 02:06:09 +00:00
|
|
|
/* local data related to memory management */
|
2012-05-14 19:11:58 +01:00
|
|
|
#ifdef YAPOR
|
2011-12-07 13:53:20 +00:00
|
|
|
REMOTE_next_free_ans_node(wid) = NULL;
|
2012-05-14 19:11:58 +01:00
|
|
|
#elif THREADS
|
2012-05-22 14:47:47 +01:00
|
|
|
#ifdef USE_PAGES_MALLOC
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_void(wid), void *);
|
2012-05-22 14:47:47 +01:00
|
|
|
#endif
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_tab_ent(wid), struct table_entry);
|
|
|
|
#if defined(THREADS_FULL_SHARING) || defined(THREADS_CONSUMER_SHARING)
|
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_sg_ent(wid), struct subgoal_entry);
|
2011-12-07 13:53:20 +00:00
|
|
|
#endif
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_sg_fr(wid), struct subgoal_frame);
|
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_dep_fr(wid), struct dependency_frame);
|
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_sg_node(wid), struct subgoal_trie_node);
|
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_sg_hash(wid), struct subgoal_trie_hash);
|
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_ans_node(wid), struct answer_trie_node);
|
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_ans_hash(wid), struct answer_trie_hash);
|
2011-12-07 13:53:20 +00:00
|
|
|
#if defined(THREADS_FULL_SHARING)
|
2012-05-14 19:11:58 +01:00
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_ans_ref_node(wid), struct answer_ref_node);
|
|
|
|
#endif
|
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_gt_node(wid), struct global_trie_node);
|
|
|
|
INIT_LOCAL_PAGE_ENTRY(REMOTE_pages_gt_hash(wid), struct global_trie_hash);
|
2011-12-07 13:53:20 +00:00
|
|
|
#endif
|
|
|
|
#endif /* TABLING && (YAPOR || THREADS) */
|
|
|
|
|
|
|
|
#ifdef YAPOR
|
2001-04-09 20:54:03 +01:00
|
|
|
/* local data related to or-parallelism */
|
2016-01-03 02:06:09 +00:00
|
|
|
Set_REMOTE_top_cp(wid, (choiceptr)LOCAL_LocalBase);
|
2011-05-10 11:47:18 +01:00
|
|
|
REMOTE_top_or_fr(wid) = GLOBAL_root_or_fr;
|
2011-05-09 19:36:51 +01:00
|
|
|
REMOTE_load(wid) = 0;
|
|
|
|
REMOTE_share_request(wid) = MAX_WORKERS;
|
|
|
|
REMOTE_reply_signal(wid) = worker_ready;
|
2011-03-30 14:35:10 +01:00
|
|
|
#ifdef YAPOR_COPY
|
2011-05-09 19:36:51 +01:00
|
|
|
INIT_LOCK(REMOTE_lock_signals(wid));
|
2011-03-30 14:35:10 +01:00
|
|
|
#endif /* YAPOR_COPY */
|
2011-05-09 19:36:51 +01:00
|
|
|
Set_REMOTE_prune_request(wid, NULL);
|
|
|
|
INIT_LOCK(REMOTE_lock(wid));
|
2011-05-27 17:21:03 +01:00
|
|
|
#endif /* YAPOR */
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef TABLING
|
|
|
|
/* local data related to tabling */
|
2016-01-03 02:06:09 +00:00
|
|
|
REMOTE_top_sg_fr(wid) = NULL;
|
|
|
|
REMOTE_top_dep_fr(wid) = NULL;
|
2001-04-09 20:54:03 +01:00
|
|
|
#ifdef YAPOR
|
2016-01-03 02:06:09 +00:00
|
|
|
REMOTE_top_dep_fr(wid) = GLOBAL_root_dep_fr;
|
|
|
|
Set_REMOTE_top_cp_on_stack(wid, (choiceptr)LOCAL_LocalBase); /* ??? */
|
2011-05-10 11:47:18 +01:00
|
|
|
REMOTE_top_susp_or_fr(wid) = GLOBAL_root_or_fr;
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR */
|
2011-12-22 16:50:20 +00:00
|
|
|
#ifdef THREADS_CONSUMER_SHARING
|
|
|
|
ThDepFr_terminator(GLOBAL_th_dep_fr(wid)) = 0;
|
|
|
|
ThDepFr_next(GLOBAL_th_dep_fr(wid)) = wid;
|
|
|
|
ThDepFr_state(GLOBAL_th_dep_fr(wid)) = working;
|
|
|
|
INIT_LOCK(ThDepFr_lock(GLOBAL_th_dep_fr(wid)));
|
|
|
|
#endif /* THREADS_CONSUMER_SHARING */
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* TABLING */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-05-09 19:36:51 +01:00
|
|
|
void Yap_init_root_frames(void) {
|
2011-03-07 16:02:55 +00:00
|
|
|
CACHE_REGS
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2011-05-09 19:36:51 +01:00
|
|
|
#ifdef YAPOR
|
|
|
|
/* root or frame */
|
2011-05-10 11:47:18 +01:00
|
|
|
or_fr_ptr or_fr = GLOBAL_root_or_fr;
|
2001-04-09 20:54:03 +01:00
|
|
|
INIT_LOCK(OrFr_lock(or_fr));
|
|
|
|
OrFr_alternative(or_fr) = NULL;
|
2011-05-10 11:47:18 +01:00
|
|
|
BITMAP_copy(OrFr_members(or_fr), GLOBAL_bm_present_workers);
|
2016-01-03 02:06:09 +00:00
|
|
|
SetOrFr_node(or_fr, (choiceptr)LOCAL_LocalBase);
|
2001-04-09 20:54:03 +01:00
|
|
|
OrFr_nearest_livenode(or_fr) = NULL;
|
|
|
|
OrFr_depth(or_fr) = 0;
|
2010-02-02 23:42:15 +00:00
|
|
|
Set_OrFr_pend_prune_cp(or_fr, NULL);
|
2001-04-09 20:54:03 +01:00
|
|
|
OrFr_nearest_leftnode(or_fr) = or_fr;
|
|
|
|
OrFr_qg_solutions(or_fr) = NULL;
|
|
|
|
#ifdef TABLING_INNER_CUTS
|
|
|
|
OrFr_tg_solutions(or_fr) = NULL;
|
|
|
|
#endif /* TABLING_INNER_CUTS */
|
|
|
|
#ifdef TABLING
|
2011-05-10 11:47:18 +01:00
|
|
|
OrFr_owners(or_fr) = GLOBAL_number_workers;
|
2001-04-09 20:54:03 +01:00
|
|
|
OrFr_next_on_stack(or_fr) = NULL;
|
|
|
|
OrFr_suspensions(or_fr) = NULL;
|
|
|
|
OrFr_nearest_suspnode(or_fr) = or_fr;
|
|
|
|
#endif /* TABLING */
|
|
|
|
OrFr_next(or_fr) = NULL;
|
|
|
|
#endif /* YAPOR */
|
|
|
|
|
|
|
|
#ifdef TABLING
|
2012-05-14 19:11:58 +01:00
|
|
|
/* root global trie node */
|
|
|
|
new_global_trie_node(GLOBAL_root_gt, 0, NULL, NULL, NULL);
|
2016-01-03 02:06:09 +00:00
|
|
|
/* root dependency frame */
|
2011-07-26 16:49:49 +01:00
|
|
|
#ifdef YAPOR
|
2016-01-03 02:06:09 +00:00
|
|
|
DepFr_cons_cp(GLOBAL_root_dep_fr) = B; /* with YAPOR, at that point,
|
|
|
|
LOCAL_top_dep_fr shouldn't be the
|
|
|
|
same as GLOBAL_root_dep_fr ? */
|
2011-07-26 16:49:49 +01:00
|
|
|
#else
|
2016-01-03 02:06:09 +00:00
|
|
|
new_dependency_frame(LOCAL_top_dep_fr, FALSE, NULL, NULL, B, NULL, FALSE,
|
|
|
|
NULL);
|
2011-07-26 16:49:49 +01:00
|
|
|
#endif /* YAPOR */
|
2010-11-28 11:51:31 +00:00
|
|
|
#endif /* TABLING */
|
2001-04-09 20:54:03 +01:00
|
|
|
}
|
2010-04-19 02:34:08 +01:00
|
|
|
|
|
|
|
void itos(int i, char *s) {
|
2016-01-03 02:06:09 +00:00
|
|
|
int n, r, j;
|
2010-04-19 02:34:08 +01:00
|
|
|
n = 10;
|
2016-01-03 02:06:09 +00:00
|
|
|
while (n <= i)
|
|
|
|
n *= 10;
|
2010-04-19 02:34:08 +01:00
|
|
|
j = 0;
|
|
|
|
while (n > 1) {
|
2016-01-03 02:06:09 +00:00
|
|
|
n = n / 10;
|
2010-04-19 02:34:08 +01:00
|
|
|
r = i / n;
|
|
|
|
i = i - r * n;
|
|
|
|
s[j++] = r + '0';
|
|
|
|
}
|
|
|
|
s[j] = 0;
|
|
|
|
return;
|
|
|
|
}
|
2001-04-09 20:54:03 +01:00
|
|
|
#endif /* YAPOR || TABLING */
|