File: pl-funcs.h

package info (click to toggle)
swi-prolog 3.1.0-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 8,772 kB
  • ctags: 12,869
  • sloc: ansic: 43,657; perl: 12,577; lisp: 4,359; sh: 1,534; makefile: 798; awk: 14
file content (766 lines) | stat: -rw-r--r-- 27,657 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
/*  $Id: pl-funcs.h,v 1.91 1998/08/06 13:27:01 jan Exp $

    Part of SWI-Prolog
    Designed and implemented by Jan Wielemaker
    E-mail: jan@swi.psy.uva.nl

    Copyright (C) 1994 University of Amsterdam. All rights reserved.
*/

/* pl-alloc.c */
void		free_heap(Void mem, size_t n);
void		outOfStack(Stack s, int how);
volatile void	outOfCore(void);
Word		allocGlobal(int words);
Void		alloc_heap(size_t n);
void		initMemAlloc(void);
word		globalFunctor(functor_t def);
int		sizeString(word w);
word		globalString(const char *s);
word		globalNString(long len, const char *s);
Word		newTerm(void);
void		doublecpy(void *to, void *from);
word		globalReal(real f);
word		globalLong(long i);
double		valReal(word w);
word		globalIndirect(word in);
int		equalIndirect(word r1, word r2);
word		globalIndirectFromCode(Code *PC);
word		makeRef(Word p);
#ifndef consPtr
word		consPtr(void *p, int ts);
#endif
char *		store_string(const char *s);
void		remove_string(char *s);
int		unboundStringHashValue(const char *t);
void *		xmalloc(size_t size);
void *		xrealloc(void *mem, size_t size);

/* pl-wam.c */
word		pl_count(void);
bool		unify(Word t1, Word t2, LocalFrame env);
bool		unify_ptrs(Word t1, Word t2);
bool		can_unify(Word t1, Word t2);
word		pl_alt(word h);
void		TrailAssignment(Word p);
void		DoTrail(Word p);
void		do_undo(mark *m);
void		fix_term_ref_count(void);

/* pl-atom.c */
word		lookupAtom(const char *s);
word		pl_atom_hashstat(term_t i, term_t n);
void		initAtoms(void);
word		pl_current_atom(term_t a, word h);
word		pl_complete_atom(term_t prefix, term_t common, term_t unique);
word		pl_atom_completions(term_t prefix, term_t alts);

/* pl-arith.c */

word		pl_between(term_t l, term_t h, term_t n, word b);
word		pl_succ(term_t n1, term_t n2);
word		pl_plus(term_t a, term_t b, term_t c);
int		ar_compare(Number n1, Number n2, int what);
word		pl_lessNumbers(term_t n1, term_t n2);
word		pl_greaterNumbers(term_t n1, term_t n2);
word		pl_lessEqualNumbers(term_t n1, term_t n2);
word		pl_greaterEqualNumbers(term_t n1, term_t n2);
word		pl_nonEqualNumbers(term_t n1, term_t n2);
word		pl_equalNumbers(term_t n1, term_t n2);
word		pl_is(term_t v, term_t e);
word		pl_arithmetic_function(term_t descr);
word		pl_current_arithmetic_function(term_t f, word h);
void		initArith(void);
int		indexArithFunction(functor_t fdef, Module m);
functor_t	functorArithFunction(int n);
bool		ar_func_n(code n, int argc, Number *stack);
int		valueExpression(term_t p, Number n);
int		toIntegerNumber(Number n);
void		canoniseNumber(Number n);

/* pl-bag.c */
word		pl_record_bag(term_t term);
int 		checkBags(void);
word		pl_collect_bag(term_t bindings, term_t bag);

/* pl-comp.c */
void		initWamTable(void);
void		get_head_and_body_clause(term_t clause,
					 term_t head, term_t body, Module *m);
Clause		assert_term(term_t term, int where, SourceLoc loc);
word		pl_assertz(term_t term);
word		pl_asserta(term_t term);
word		pl_assertz2(term_t term, term_t ref);
word		pl_asserta2(term_t term, term_t ref);
word		pl_record_clause(term_t term, term_t file, term_t ref);
word		pl_redefine_system_predicate(term_t term);
bool		decompileHead(Clause clause, term_t head);
int		arg1Key(Clause clause, word *key);
bool		decompile(Clause clause, term_t term, term_t bindings);
word		pl_clause4(term_t p, term_t t, term_t ref, term_t b, word h);
word		pl_clause(term_t p, term_t term, term_t ref, word h);
word		pl_nth_clause(term_t p, term_t n, term_t ref, word h);
word		pl_xr_member(term_t ref, term_t term, word h);
void		wamListClause(Clause clause);
word		pl_wam_list(term_t ref);
word		pl_fetch_vm(term_t ref, term_t offset, term_t noffset,
			    term_t instruction);
int		unify_definition(term_t head, Definition def,
				 term_t thehead, int flags);
word		pl_clause_term_position(term_t ref, term_t pc, term_t locterm);
word		pl_break_pc(term_t ref, term_t pc, term_t nextpc, control_t h);
word		pl_break_at(term_t ref, term_t pc, term_t set);
code		replacedBreak(Code PC);
void		clearBreakPointsClause(Clause clause);
word		pl_current_break(term_t ref, term_t pc, control_t h);

/* pl-dump.c */
word		saveProgram(term_t new);
word		pl_save_program(term_t new, term_t args);
word		pl_save(term_t file, term_t restore);
word		pl_restore(term_t file);
word		parseSaveProgramOptions(term_t args,
			int *local, int *global, int *trail, int *argument,
			char **goal, char **toplevel, char **init_file,
			bool *tty, bool *standalone);

/* pl-index.c */
int		cardinalityPattern(unsigned long pattern);
void		getIndex(Word argv, unsigned long pattern, int card,
			 struct index *);
ClauseRef	findClause(ClauseRef cl,
			   Word argv, Definition def, bool *deterministic);
bool		reindexClause(Clause clause);
bool		unify_index_pattern(Procedure proc, term_t value);
bool		hashDefinition(Definition def, int buckets);
word		pl_hash(term_t pred);
void		addClauseToIndex(Definition def, Clause cl, int where);
void		delClauseFromIndex(ClauseIndex ci, Clause cl);
void		gcClauseIndex(ClauseIndex ci);
void		unallocClauseIndexTable(ClauseIndex ci);
void		markDirtyClauseIndex(ClauseIndex ci, Clause cl);

/* pl-dwim.c */
word		pl_dwim_match(term_t a1, term_t a2, term_t mm);
word		pl_dwim_predicate(term_t term, term_t dwim, word h);

/* pl-ext.c */
void		initBuildIns(void);

/* pl-error.c */

int		PL_error(const char *pred, int arity, const char *msg,
			 int id, ...);
char *		tostr(char *buf, const char *fmt, ...);

/* pl-file.c */
void		initIO(void);
void		dieIO(void);
void		closeFiles(int all);
void		protocol(char *s, int n);
int		currentLinePosition(void);
void		setCurrentSourceLocation(void);
int		getSingleChar(void);
word		pl_rawtty(term_t goal);
bool		readLine(char *buffer);
bool		LockStream(void);
bool		UnlockStream(void);
bool		Put(int c);
bool		PutOpenToken(int c);
word		pl_dup_stream(term_t from, term_t to);
IOSTREAM *	PL_current_input(void);
IOSTREAM *	PL_current_output(void);
word		Putf(char *fm, ...);
bool		Puts(const char *str);
word		pl_told(void);
word		pl_flush(void);
word		pl_see(term_t f);
word		pl_seen(void);
word		pl_noprotocol(void);
bool		seeString(char *s);
bool		seeingString(void);
bool		seenString(void);
bool		tellString(char **s, int size);
bool		toldString(void);
atom_t		currentStreamName(void);
word		pl_wait_for_input(term_t streams, term_t avail, term_t tmo);
word		pl_put(term_t c);
word		pl_put2(term_t stream, term_t chr);
word		pl_get(term_t chr);
word		pl_skip(term_t chr);
word		pl_skip2(term_t stream, term_t chr);
word		pl_get2(term_t stream, term_t chr);
word		pl_tty(void);
word		pl_get_single_char(term_t c);
word		pl_get0(term_t c);
word		pl_get02(term_t stream, term_t c);
word		pl_seeing(term_t f);
word		pl_telling(term_t f);
word		pl_tell(term_t f);
word		pl_append(term_t f);
word		pl_ttyflush(void);
word		pl_protocol(term_t file);
word		pl_protocola(term_t file);
word		pl_protocolling(term_t file);
word		pl_prompt(term_t old, term_t new);
void		prompt1(char *prompt);
word		pl_prompt1(term_t prompt);
word		pl_tab(term_t n);
char *		PrologPrompt(void);
word		pl_tab2(term_t stream, term_t n);
word		pl_open4(term_t file, term_t mode, term_t stream, term_t opt);
word		pl_open(term_t file, term_t mode, term_t stream);
word		pl_open_null_stream(term_t stream);
int		streamNo(term_t spec, int mode);
word		pl_close(term_t stream);
void		release_stream_handle(term_t spec);
word		pl_current_stream(term_t file, term_t mode, term_t s, word h);
word		pl_flush_output(term_t stream);
word		pl_stream_position(term_t stream, term_t old, term_t new);
word		pl_seek(term_t stream,
			term_t offset, term_t method, term_t newloc);
word		pl_set_input(term_t stream);
word		pl_set_output(term_t stream);
word		pl_current_input(term_t stream);
word		pl_current_output(term_t stream);
word		pl_character_count(term_t stream, term_t count);
word		pl_line_count(term_t stream, term_t count);
word		pl_line_position(term_t stream, term_t count);
word		pl_source_location(term_t file, term_t line);
word		pl_at_end_of_stream1(term_t stream);
word		pl_at_end_of_stream0();
word		pl_peek_byte2(term_t stream, term_t chr);
word		pl_peek_byte1(term_t chr);
bool		unifyTime(term_t t, long time);
word		pl_time_file(term_t name, term_t t);
word		pl_size_file(term_t name, term_t len);
word		pl_size_stream(term_t stream, term_t len);
word		pl_access_file(term_t name, term_t mode);
word		pl_read_link(term_t file, term_t link, term_t to);
word		pl_exists_file(term_t name);
word		pl_exists_directory(term_t name);
word		pl_tmp_file(term_t base, term_t name);
word		pl_delete_file(term_t name);
word		pl_same_file(term_t file1, term_t file2);
word		pl_rename_file(term_t old, term_t new);
word		pl_fileerrors(term_t old, term_t new);
word		pl_absolute_file_name(term_t name, term_t expanded);
word		pl_is_absolute_file_name(term_t name);
word		pl_chdir(term_t dir);
word		pl_file_base_name(term_t f, term_t b);
word		pl_file_dir_name(term_t f, term_t b);
word		pl_file_name_extension(term_t base, term_t ext, term_t full);
word		pl_prolog_to_os_filename(term_t pl, term_t os);
foreign_t	pl_mark_executable(term_t path);
#ifdef __WIN32__
word		pl_make_fat_filemap(term_t dir);
#endif

/* pl-flag.c */
void		initFlags(void);
word		pl_flag(term_t name, term_t old, term_t new);
word		pl_current_flag(term_t k, word h);

/* pl-fli.c */
word		makeNum(long i);
void		finish_foreign_frame();
void		_PL_put_number(term_t t, Number n);
int		_PL_unify_number(term_t t, Number n);
predicate_t	_PL_predicate(const char *name, int arity, const char *module,
			      predicate_t *bin);
void		initialiseForeign(int argc, char **argv);
char *		buffer_string(const char *s, int flags);

/* pl-fmt.c */
word		pl_format_predicate(term_t chr, term_t descr);
word		pl_format(term_t fmt, term_t args);
word		pl_format3(term_t s, term_t fmt, term_t args);

/* pl-funct.c */
functor_t	lookupFunctorDef(atom_t atom, int arity);
functor_t	isCurrentFunctor(atom_t atom, int arity);
void		initFunctors(void);
int 		checkFunctors(void);
word		pl_current_functor(term_t name, term_t arity, word h);

/* pl-gc.c */
void		considerGarbageCollect(Stack s);
void		garbageCollect(LocalFrame fr);
word		pl_garbage_collect(term_t d);
void		resetGC(void);
void		blockGC(void);
void		unblockGC(void);
Word		findGRef(int n);
int		growStacks(LocalFrame fr, Code PC, int l, int g, int t);
void		clearUninitialisedVarsFrame(LocalFrame, Code);
word		check_foreign(void);	/* O_SECURE stuff */


/* pl-glob.c */
word		pl_wildcard_match(term_t pattern, term_t string);
word		pl_expand_file_name(term_t f, term_t l);

/* pl-itf.c */
void		resetForeign(void);

/* pl-list.c */
word		pl_is_list(term_t list);
word		pl_proper_list(term_t list);
word		pl_length(term_t list, term_t l);
word		pl_memberchk(term_t e, term_t list);
word		pl_msort(term_t list, term_t sorted);
word		pl_sort(term_t list, term_t sorted);

/* pl-load.c */
bool		getSymbols(void);
void		resetLoader(void);
long		allocText(long int size);
word		pl_load_foreign(term_t file, term_t entry, term_t options,
				term_t libraries, term_t size);
word		pl_load_foreign1(term_t file);
word		pl_open_shared_object(term_t file, term_t h, term_t flags);
word		pl_close_shared_object(term_t plhandle);
word		pl_call_shared_object_function(term_t plhandle, term_t name);
word		pl_load_shared_object(term_t file, term_t entry);

/* pl-modul.c */
Module		lookupModule(atom_t name);
void		initModules(void);
int		isSuperModule(Module s, Module m);
Word		stripModule(Word term, Module *module);
bool		isPublicModule(Module module, Procedure proc);
int		declareModule(atom_t name, SourceFile sf);
word		pl_default_module(term_t me, term_t old, term_t new);
word		pl_current_module(term_t module, term_t file, word h);
word		pl_strip_module(term_t spec, term_t module, term_t term);
word		pl_module(term_t old, term_t new);
word		pl_set_source_module(term_t old, term_t new);
word		pl_term_expansion_module(term_t name, word h);
word		pl_declare_module(term_t name, term_t file);
word		pl_export_list(term_t modulename, term_t list);
word		pl_export(term_t head);
word		pl_check_export(void);
word		pl_context_module(term_t module);
word		pl_import(term_t pred);

/* pl-op.c */
Operator	isCurrentOperator(atom_t name, int type);
word		pl_current_op(term_t prec, term_t type, term_t name, word h);
bool		isPrefixOperator(atom_t atom, int *type, int *priority);
bool		isPostfixOperator(atom_t atom, int *type, int *priority);
bool		isInfixOperator(atom_t atom, int *type, int *priority);
word		pl_op1(term_t priority, term_t type, term_t name);
bool		newOp(char *name, int type, int pri);
void		initOperators(void);
word		pl_reset_operators(void);

/* pl-os.c */
bool		initOs(void);
volatile void	Halt(int status);
char *		OsError(void);
real		CpuTime(void);
Void		Allocate(long int n);
long		Random(void);
char *		canonisePath(char *path);
char *		OsPath(const char *plpath, char *ospath);
char *		PrologPath(const char *ospath, char *plpath);
long		LastModifiedFile(char *f);
bool		ExistsFile(const char *path);
bool		AccessFile(const char *path, int mode);
bool		ExistsDirectory(const char *path);
long		SizeFile(const char *path);
int		RemoveFile(const char *path);
bool		RenameFile(const char *old, const char *new);
bool		SameFile(const char *f1, const char *f2);
bool		OpenStream(int fd);
bool		MarkExecutable(const char *name);
bool		expandVars(const char *pattern, char *expanded);
char *		ExpandOneFile(const char *spec, char *file);
char *		getwd(char *buf);
char *		AbsoluteFile(const char *spec, char *path);
int		IsAbsolutePath(const char *spec);
char *		BaseName(const char *f);
char *		DirName(const char *f, char *buf);
char *		ReadLink(const char *f, char *buf);
char *		DeRefLink(const char *link, char *buf);
bool		ChDir(const char *path);
atom_t		TemporaryFile(const char *id);
struct tm *	LocalTime(long int *t);
Char		GetChar(void);
void		ResetTty(void);
bool		PushTty(ttybuf *buf, int mode);
bool		PopTty(ttybuf *buf);
char *		getenv3(const char *, char *buf, int buflen);
int		getenvl(const char *);
int		Setenv(char *name, char *value);
int		Unsetenv(char *name);
int		System(char *cmd);
char *		Symbols(char *buf);
void		Pause(real time);
#if __WIN32__
int		iswin32s(void);
#endif /*__WIN32__*/

/* pl-prims.c */
word		pl_nonvar(term_t k);
word		pl_var(term_t k);
word		pl_integer(term_t k);
word		pl_float(term_t k);
word		pl_string(term_t k);
word		pl_number(term_t k);
word		pl_atom(term_t k);
word		pl_atomic(term_t k);
word		pl_ground(term_t term);
word		pl_compound(term_t term);
#ifdef O_HASHTERM
word		pl_hash_term(term_t term, term_t hval);
#endif
word		pl_unify(term_t t1, term_t t2);
word		pl_notunify(term_t t1, term_t t2);
word		pl_equal(term_t t1, term_t t2);
word		pl_nonequal(term_t t1, term_t t2);
int		compareStandard(Word t1, Word t2);
word		pl_compare(term_t rel, term_t t1, term_t t2);
word		pl_lessStandard(term_t t1, term_t t2);
word		pl_lessEqualStandard(term_t t1, term_t t2);
word		pl_greaterStandard(term_t t1, term_t t2);
word		pl_greaterEqualStandard(term_t t1, term_t t2);
word		pl_structural_equal(term_t t1, term_t t2);
word		pl_structural_nonequal(term_t t1, term_t t2);
word		pl_functor(term_t t, term_t f, term_t a);
word		pl_arg(term_t n, term_t t, term_t a, word b);
word		pl_setarg(term_t n, term_t term, term_t arg);
int		lengthList(term_t list);
word		pl_univ(term_t t, term_t l);
int		numberVars(term_t t, functor_t functor, int n);
word		pl_numbervars(term_t t, term_t atom,
			      term_t start, term_t end);
word		pl_free_variables(term_t t, term_t l);
word		pl_e_free_variables(term_t t, term_t l);
word		pl_copy_term(term_t f, term_t t);
word		stringToList(char *s);
word		pl_atom_length(term_t w, term_t n);
word		pl_int_to_atom(term_t number, term_t base,
			       term_t atom);
char *		formatInteger(bool split, int div, int radix,
			      bool small, long n, char *out);
word		pl_format_number(term_t format, term_t number,
				 term_t string);
word		pl_name(term_t atom, term_t string);
word		pl_atom_chars(term_t atom, term_t string);
word		pl_number_chars(term_t number, term_t string);
word		pl_atom_char(term_t atom, term_t chr);
word		pl_atom_prefix(term_t atom, term_t prefix);
word		pl_concat(term_t a1, term_t a2, term_t a3);
word		pl_concat_atom(term_t list, term_t atom);
word		pl_concat_atom3(term_t list, term_t sep, term_t atom);
word		pl_apropos_match(term_t a1, term_t a2);
word		pl_string_length(term_t str, term_t l);
word		pl_string_concat(term_t a1, term_t a2, term_t a3, word h);
word		pl_string_to_atom(term_t str, term_t a);
word		pl_string_to_list(term_t str, term_t list);
word		pl_substring(term_t str, term_t offset,
			     term_t length, term_t sub);
word		pl_write_on_atom(term_t goal, term_t atom);
word		pl_write_on_string(term_t goal, term_t string);
word		pl_write_on_list(term_t goal, term_t string);
word		pl_term_to_atom(term_t term, term_t atom,
				term_t bindings, term_t e);
word		pl_repeat(word h);
word		pl_fail(void);
word		pl_true(void);
word		pl_halt(term_t code);
word		pl_statistics(term_t k, term_t value);
int		setFeature(atom_t name, int type, ...);
void		CSetFeature(const char *name, const char *value);
word		pl_feature(term_t key, term_t value, word h);
word		pl_set_feature(term_t key, term_t value);
word		pl_option(term_t key, term_t old, term_t new, control_t h);
int		set_pl_option(const char *name, const char *value);
word		pl_please(term_t key, term_t old, term_t new);
word		pl_style_check(term_t old, term_t new);
word		pl_novice(term_t old, term_t new);

/* pl-pro.c */
word		pl_break(void);
word		pl_break1(term_t goal);
word		pl_notrace1(term_t goal);
#ifdef O_LIMIT_DEPTH
word		pl_depth_limit(term_t limit, term_t olimit, term_t oreached);
word		pl_depth_limit_true(term_t limit,
				    term_t olimit, term_t oreached,
				    term_t res, term_t cut, word b);
word		pl_depth_limit_false(term_t limit,
				     term_t olimit, term_t oreached,
				     term_t res);
#endif /*O_LIMIT_DEPTH*/
int		callProlog(Module module, term_t goal, int debug);
word		pl_abort(void);
bool		prolog(atom_t toplevel);
word		pl_metacut(void);
int 		trap_gdb(void);
word		checkData(Word p);

/* pl-proc.c */
Procedure	lookupProcedure(functor_t f, Module m);
Procedure	isCurrentProcedure(functor_t f, Module m);
Procedure	lookupProcedureToDefine(functor_t def, Module m);
bool		isDefinedProcedure(Procedure proc);
int		get_head_functor(term_t head, functor_t *fdef);
int		get_procedure(term_t descr, Procedure *proc, term_t he, int f);
word		pl_current_predicate(term_t name, term_t functor, word h);
bool		assertProcedure(Procedure proc, Clause clause, int where);
bool		abolishProcedure(Procedure proc, Module module);
bool		retractClauseProcedure(Procedure proc, Clause clause);
void		freeClause(Clause c);
void		freeClauseRef(ClauseRef c);
ClauseRef	newClauseRef(Clause cl);
void		gcClausesDefinition(Definition def);
void		resetReferences(void);
Procedure	resolveProcedure(functor_t f, Module module);
Definition	trapUndefined(Definition def);
word		pl_retract(term_t term, word h);
word		pl_retractall(term_t head);
word		pl_abolish(term_t atom, term_t arity);
word		pl_abolish1(term_t pred);
word		pl_get_clause_attribute(term_t ref, term_t att, term_t value);
word		pl_get_predicate_attribute(term_t pred, term_t k, term_t v);
word		pl_set_predicate_attribute(term_t pred, term_t k, term_t v);
void		reindexDefinition(Definition def);
void		startConsult(SourceFile f);
word		pl_index(term_t pred);
SourceFile	lookupSourceFile(atom_t name);
SourceFile	indexToSourceFile(int index);
void		addProcedureSourceFile(SourceFile sf, Procedure proc);
word		pl_make_system_source_files(void);
word		pl_source_file(term_t descr, term_t file, control_t h);
word		pl_time_source_file(term_t file, term_t t, control_t h);
word		pl_start_consult(term_t file);
word		pl_default_predicate(term_t d1, term_t d2);
Definition	autoImport(functor_t f, Module m);
word		pl_require(term_t pred);
word		pl_check_definition(term_t spec);
word		pl_clause_from_source(term_t file, term_t line, term_t clause);

/* pl-prof.c */
void		stopItimer(void);
word		pl_profile(term_t old, term_t new);
word		pl_profile_count(term_t head, term_t calls, term_t prom);
word		pl_profile_box(term_t head,
			       term_t calls, term_t redos,
			       term_t exits, term_t fails);
word		pl_reset_profiler(void);

/* pl-read.c */
void		resetRead(void);
int		syntaxerrors(int new);
word		pl_syntaxerrors(term_t old, term_t new);
int		get_number(const unsigned char *string,
			   unsigned char **end,
			   Number value);
word		pl_raw_read(term_t term);
word		pl_raw_read2(term_t stream, term_t term);
word		pl_read_variables(term_t term, term_t variables);
word		pl_read_variables3(term_t stream, term_t term,
				   term_t variables);
word		pl_read(term_t term);
word		pl_read2(term_t stream, term_t term);
word		pl_read_clause(term_t term);
word		pl_read_clause2(term_t stream, term_t term);
word		pl_read_term(term_t term, term_t pos);
word		pl_read_term3(term_t stream, term_t term, term_t pos);

/* pl-rec.c */
void		initRecords(void);
Record		compileTermToHeap(term_t term);
void		copyRecordToGlobal(term_t copy, Record term);
int		structuralEqualArg1OfRecord(term_t t, Record r);
bool		freeRecord(Record record);
bool		unifyKey(term_t key, word val);
word		getKey(term_t key);
word		pl_current_key(term_t k, word h);
word		pl_recorda(term_t key, term_t term, term_t ref);
word		pl_recordz(term_t key, term_t term, term_t ref);
word		pl_recorded(term_t key, term_t term, term_t ref, word h);
word		pl_erase(term_t ref);
word		pl_term_complexity(term_t t, term_t mx, term_t count);
void		undo_while_saving_term(mark *m, Word term);

/* pl-rl.c */
void		install_rl(void);

/* pl-setup.c */
void		setupProlog(void);
foreign_t	pl_on_signal(term_t sig, term_t name, term_t old, term_t new);
handler_t	set_sighandler(int sig, handler_t func);
void		blockSignals(void);
void		unblockSignals(void);
void		unblockSignal(int sig);
void		resetSignals(void);
void		deallocateStacks(void);
bool		restoreStack(Stack s);
void		trimStacks(void);
void		resetStacks(void);
void		emptyStacks(void);
word		pl_trim_stacks(void);
word		pl_limit_stack(term_t s, term_t l);
word		pl_stack_parameter(term_t s, term_t k, term_t o, term_t n);
void		ensureRoomStack(Stack s, int n);


/* pl-sys.c */
word		pl_shell(term_t command, term_t status);
word		pl_getenv(term_t var, term_t value);
word		pl_setenv(term_t var, term_t value);
word		pl_unsetenv(term_t var);
word		pl_argv(term_t list);
word		pl_convert_time(term_t time, term_t year,
				term_t month, term_t day,
				term_t hour, term_t minute,
				term_t second, term_t usec);
word		pl_get_time(term_t t);
word		pl_sleep(term_t time);

/* pl-table.c */
Table		newHTable(int size);
void		destroyHTable(Table ht);
Symbol		lookupHTable(Table ht, Void name);
bool		addHTable(Table ht, Void name, Void value);
void		deleteSymbolHTable(Table ht, Symbol s);
Symbol		nextHTable(Table ht, Symbol s);
Symbol		firstHTable(Table ht);
void		clearHTable(Table ht);
void		initTables();

/* pl-trace.c */
int		tracePort(LocalFrame frame, LocalFrame bfr, int port, Code PC);
void		backTrace(LocalFrame frame, int depth);
void		initTracer(void);
void		resetTracer(void);
int		tracemode(int new, int *old);
int		debugmode(int new, int *old);
word		pl_trace(void);
word		pl_notrace(void);
word		pl_tracing(void);
word		pl_debug(void);
word		pl_nodebug(void);
word		pl_debugging(void);
word		pl_skip_level(term_t old, term_t new);
word		pl_spy(term_t p);
word		pl_nospy(term_t p);
word		pl_leash(term_t old, term_t new);
word		pl_visible(term_t old, term_t new);
word		pl_debuglevel(term_t old, term_t new);
word		pl_unknown(term_t old, term_t new);
word		pl_prolog_current_frame(term_t fr);
word		pl_prolog_frame_attribute(term_t fr, term_t key, term_t val);
void		callEventHook(int ev, ...);

/* pl-util.c */
char		digitName(int n, bool small);
int		digitValue(int b, int c);
char *		procedureName(Procedure proc);
char *		predicateName(Definition def);
word		notImplemented(char *name, int arity);
word		setBoolean(int *flag, const char *name, term_t o, term_t n);
word		setInteger(int *val, const char *name, term_t old, term_t new);
word		setLong(long *val, const char *name, term_t old, term_t new);
bool		strprefix(char *string, char *prefix);
bool		strpostfix(char *string, char *postfix);
bool		stripostfix(const char *string, const char *postfix);
void		systemMode(bool accept);
bool		scan_options(term_t list, int flags, atom_t name,
			     const opt_spec *specs, ...);
#ifndef HAVE_STRICMP
int		stricmp(const char *s1, const char *s2);
#endif
#ifndef HAVE_STRLWR
char *		strlwr(char *s);
#endif

/* pl-wic.c */
bool		loadWicFromStream(IOSTREAM *fd);
word		pl_open_wic(term_t name);
word		pl_close_wic(void);
word		pl_add_directive_wic(term_t term);
word		pl_import_wic(term_t module, term_t head);
bool		compileFileList(IOSTREAM *out, int argc, char **argv);
void		qlfCleanup(void);

word		pl_qlf_put_states(void);
word		pl_qlf_start_module(term_t name);
word		pl_qlf_start_sub_module(term_t name);
word		pl_qlf_start_file(term_t name);
word		pl_qlf_end_part(void);
word		pl_qlf_open(term_t file);
word		pl_qlf_close(void);
word		pl_qlf_load(term_t file, term_t module);
word		pl_qlf_assert_clause(term_t ref, term_t saveclass);
word		pl_qlf_info(term_t file, term_t cvers, term_t fvers, term_t i);

/* pl-write.c */
char *		varName(term_t var, char *buf);
word		pl_nl(void);
word		pl_nl1(term_t stream);
word		pl_write_canonical(term_t term);
word		pl_write_canonical2(term_t stream, term_t term);
word		pl_write_term(term_t term, term_t options);
word		pl_write_term3(term_t stream,
			       term_t term, term_t options);
word		pl_write(term_t term);
word		pl_writeq(term_t term);
word		pl_print(term_t term);
word		pl_write2(term_t stream, term_t term);
word		pl_writeq2(term_t stream, term_t term);
word		pl_print2(term_t stream, term_t term);

/* pl-term.c */
void		resetTerm(void);
word		pl_tty_get_capability(term_t name, term_t type, term_t value);
word		pl_tty_goto(term_t x, term_t y);
word		pl_tty_put(term_t a, term_t affcnt);
word		pl_set_tty(term_t old, term_t new);

/* pl-main.c */
int		startProlog(int argc, char **argv);
bool		sysError(const char *fm, ...);
bool		fatalError(const char *fm, ...);
bool		warning(const char *fm, ...);
bool		vfatalError(const char *fm, va_list args);
bool		vwarning(const char *fm, va_list args);

/* pl-dde.c */

word		pl_open_dde_conversation(term_t serv, term_t top, term_t hdl);
word		pl_close_dde_conversation(term_t handle);
word		pl_dde_request(term_t h, term_t it, term_t value, term_t tmo);
word		pl_dde_execute(term_t handle, term_t cmd, term_t tmo);
word		pl_dde_register_service(term_t service, term_t onoff);
word		pl_dde_poke(term_t h, term_t item, term_t data, term_t tmo);

/* pl-dll.c */
word		pl_open_dll(term_t name, term_t handle);
word		pl_close_dll(term_t handle);
word		pl_call_dll_function(term_t handle, term_t funcname);

/* pl-nt.c */

void		PlMessage(const char *buf, ...);
word		pl_window_title(term_t old, term_t new);
word		pl_win_exec(term_t command, term_t show);

/* pl-rc.c */
IOSTREAM *      SopenRC(void *rca,
			const char *name, const char *rcclass, int flags);
foreign_t	pl_rc_handle(term_t h);
foreign_t       pl_rc_open(term_t rc_h,
			   term_t name, term_t class,
			   term_t rw, term_t handle);
foreign_t       pl_rc_open_archive(term_t file, term_t handle);
foreign_t       pl_rc_close_archive(term_t rc_h);
foreign_t       pl_rc_save_archive(term_t rc_h, term_t to);
foreign_t       pl_rc_append_file(term_t rc_h,
				  term_t name, term_t class, term_t encoding,
				  term_t file);
foreign_t	pl_rc_members(term_t rc_h, term_t members);
foreign_t	pl_copy_stream(term_t in, term_t out);