yap-6.2.2/ 000755 000765 000024 00000000000 11702065316 012251 5 ustar 00vsc staff 000000 000000 yap-6.2.2/.gitignore 000644 000765 000024 00000000111 11457004724 014235 0 ustar 00vsc staff 000000 000000 *~
*.itf
*.po
*.qlf
*.xwam
*.wam
*.ma
*.s
*.o
*.so
*.dylib
docs/yap.info* yap-6.2.2/.gitmodules 000644 000765 000024 00000000374 11457004724 014435 0 ustar 00vsc staff 000000 000000 [submodule "packages/chr"]
path = packages/chr
url = git://yap.dcc.fc.up.pt/chr
[submodule "packages/clpqr"]
path = packages/clpqr
url = git://yap.dcc.fc.up.pt/clpqr
[submodule "packages/jpl"]
path = packages/jpl
url = git://yap.dcc.fc.up.pt/jpl
yap-6.2.2/Artistic 000644 000765 000024 00000021306 11457004724 013763 0 ustar 00vsc staff 000000 000000 The Artistic License 2.0
Copyright (c) 2000-2006, The Perl Foundation.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
This license establishes the terms under which a given free software
Package may be copied, modified, distributed, and/or redistributed.
The intent is that the Copyright Holder maintains some artistic
control over the development of that Package while still keeping the
Package available as open source and free software.
You are always permitted to make arrangements wholly outside of this
license directly with the Copyright Holder of a given Package. If the
terms of this license do not permit the full use that you propose to
make of the Package, you should contact the Copyright Holder and seek
a different licensing arrangement.
Definitions
"Copyright Holder" means the individual(s) or organization(s)
named in the copyright notice for the entire Package.
"Contributor" means any party that has contributed code or other
material to the Package, in accordance with the Copyright Holder's
procedures.
"You" and "your" means any person who would like to copy,
distribute, or modify the Package.
"Package" means the collection of files distributed by the
Copyright Holder, and derivatives of that collection and/or of
those files. A given Package may consist of either the Standard
Version, or a Modified Version.
"Distribute" means providing a copy of the Package or making it
accessible to anyone else, or in the case of a company or
organization, to others outside of your company or organization.
"Distributor Fee" means any fee that you charge for Distributing
this Package or providing support for this Package to another
party. It does not mean licensing fees.
"Standard Version" refers to the Package if it has not been
modified, or has been modified only in ways explicitly requested
by the Copyright Holder.
"Modified Version" means the Package, if it has been changed, and
such changes were not explicitly requested by the Copyright
Holder.
"Original License" means this Artistic License as Distributed with
the Standard Version of the Package, in its current version or as
it may be modified by The Perl Foundation in the future.
"Source" form means the source code, documentation source, and
configuration files for the Package.
"Compiled" form means the compiled bytecode, object code, binary,
or any other form resulting from mechanical transformation or
translation of the Source form.
Permission for Use and Modification Without Distribution
(1) You are permitted to use the Standard Version and create and use
Modified Versions for any purpose without restriction, provided that
you do not Distribute the Modified Version.
Permissions for Redistribution of the Standard Version
(2) You may Distribute verbatim copies of the Source form of the
Standard Version of this Package in any medium without restriction,
either gratis or for a Distributor Fee, provided that you duplicate
all of the original copyright notices and associated disclaimers. At
your discretion, such verbatim copies may or may not include a
Compiled form of the Package.
(3) You may apply any bug fixes, portability changes, and other
modifications made available from the Copyright Holder. The resulting
Package will still be considered the Standard Version, and as such
will be subject to the Original License.
Distribution of Modified Versions of the Package as Source
(4) You may Distribute your Modified Version as Source (either gratis
or for a Distributor Fee, and with or without a Compiled form of the
Modified Version) provided that you clearly document how it differs
from the Standard Version, including, but not limited to, documenting
any non-standard features, executables, or modules, and provided that
you do at least ONE of the following:
(a) make the Modified Version available to the Copyright Holder
of the Standard Version, under the Original License, so that the
Copyright Holder may include your modifications in the Standard
Version.
(b) ensure that installation of your Modified Version does not
prevent the user installing or running the Standard Version. In
addition, the Modified Version must bear a name that is different
from the name of the Standard Version.
(c) allow anyone who receives a copy of the Modified Version to
make the Source form of the Modified Version available to others
under
(i) the Original License or
(ii) a license that permits the licensee to freely copy,
modify and redistribute the Modified Version using the same
licensing terms that apply to the copy that the licensee
received, and requires that the Source form of the Modified
Version, and of any works derived from it, be made freely
available in that license fees are prohibited but Distributor
Fees are allowed.
Distribution of Compiled Forms of the Standard Version
or Modified Versions without the Source
(5) You may Distribute Compiled forms of the Standard Version without
the Source, provided that you include complete instructions on how to
get the Source of the Standard Version. Such instructions must be
valid at the time of your distribution. If these instructions, at any
time while you are carrying out such distribution, become invalid, you
must provide new instructions on demand or cease further distribution.
If you provide valid instructions or cease distribution within thirty
days after you become aware that the instructions are invalid, then
you do not forfeit any of your rights under this license.
(6) You may Distribute a Modified Version in Compiled form without
the Source, provided that you comply with Section 4 with respect to
the Source of the Modified Version.
Aggregating or Linking the Package
(7) You may aggregate the Package (either the Standard Version or
Modified Version) with other packages and Distribute the resulting
aggregation provided that you do not charge a licensing fee for the
Package. Distributor Fees are permitted, and licensing fees for other
components in the aggregation are permitted. The terms of this license
apply to the use and Distribution of the Standard or Modified Versions
as included in the aggregation.
(8) You are permitted to link Modified and Standard Versions with
other works, to embed the Package in a larger work of your own, or to
build stand-alone binary or bytecode versions of applications that
include the Package, and Distribute the result without restriction,
provided the result does not expose a direct interface to the Package.
Items That are Not Considered Part of a Modified Version
(9) Works (including, but not limited to, modules and scripts) that
merely extend or make use of the Package, do not, by themselves, cause
the Package to be a Modified Version. In addition, such works are not
considered parts of the Package itself, and are not subject to the
terms of this license.
General Provisions
(10) Any use, modification, and distribution of the Standard or
Modified Versions is governed by this Artistic License. By using,
modifying or distributing the Package, you accept this license. Do not
use, modify, or distribute the Package, if you do not accept this
license.
(11) If your Modified Version has been derived from a Modified
Version made by someone other than you, you are nevertheless required
to ensure that your Modified Version complies with the requirements of
this license.
(12) This license does not grant you the right to use any trademark,
service mark, tradename, or logo of the Copyright Holder.
(13) This license includes the non-exclusive, worldwide,
free-of-charge patent license to make, have made, use, offer to sell,
sell, import and otherwise transfer the Package with respect to any
patent claims licensable by the Copyright Holder that are necessarily
infringed by the Package. If you institute patent litigation
(including a cross-claim or counterclaim) against any party alleging
that the Package constitutes direct or contributory patent
infringement, then this Artistic License to you shall terminate on the
date that such litigation is filed.
(14) Disclaimer of Warranty:
THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS
IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL
LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
yap-6.2.2/BEAM/ 000755 000765 000024 00000000000 11702065321 012751 5 ustar 00vsc staff 000000 000000 yap-6.2.2/build-distr 000755 000765 000024 00000002221 11457004724 014421 0 ustar 00vsc staff 000000 000000 #!/bin/bash
#
# small but nasty script to build a new YAP release from the current
# directory: it first builds a new tar file, next creates
# rpms, and last creates a new web page directory.
#
YAP_DIR=`pwd`
PAGE_DIR=~vitor/lpublic_html/Yap/Yap4.3
OWNER=vitor
parent=$(cd ..;pwd)
version=${PWD##$parent/}
splat() {
rm -f core
for i in *.tex; do
rm -f ${i%.tex}.aux
rm -f ${i%.tex}.log
rm -f ${i%.tex}.dvi
rm -f ${i%.tex}.bbl
rm -f ${i%.tex}.blg
# get rid of outputs from original file.
rm -f ${i%.tex}.ps
done
rm -f *~
rm -f *.BAK
rm -f \#*\#
}
. distribute --small
cp $YAP_DIR/../"$version".tar.gz $PAGE_DIR/"$version"-small.tar.gz
cd /usr/src/RPM/SPECS
cp $YAP_DIR/misc/Yap.spec .
mv $YAP_DIR/../"$version".tar.gz ../SOURCES
rpm -ba Yap.spec
cd /usr/src/RPM
mv SRPMS/Yap* $PAGE_DIR
mv RPMS/*/Yap* $PAGE_DIR
rm -rf BUILD/Yap*
rm -rf SOURCES/Yap*
rm -rf SPECS/Yap*
cd $YAP_DIR
# get rid of silly $1
shift
. distribute
mv -f $YAP_DIR/../"$version".tar.gz $PAGE_DIR
cp -f $YAP_DIR/changes4.3.html $PAGE_DIR
cd $YAP_DIR/docs
make html
cd $YAP_DIR
cp -f $YAP_DIR/docs/*.html $PAGE_DIR
chown $OWNER $PAGE_DIR/*
chmod 666 $PAGE_DIR/*
yap-6.2.2/C/ 000755 000765 000024 00000000000 11710550723 012433 5 ustar 00vsc staff 000000 000000 yap-6.2.2/changes-5.0.html 000644 000765 000024 00000002466 11457004724 015062 0 ustar 00vsc staff 000000 000000
YAP change log
Changes in YAP-5.0
Yap-5.0.2:
FIXED: excessive backtracking in multifile declaration.
FIXED: broken do_print_message for defined_elsewhere.
FIXED: debugger option.
FIXED: trace through undefined predicates correctly.
Yap-5.0.1:
FIXED: WIN32 missing include files (untested)
FIXED: -L trouble (my thanks to Takeyuchi Shiramoto-san)!
FIXED: debugging of backtrable user-C preds would core dump.
FIXED: redeclaring a C-predicate as Prolog core dumps.
FIXED: badly protected YapInterface.h.
FIXED: break/0 was failing at exit.
FIXED: YAP_cut_fail and YAP_cut_succeed were different from manual.
FIXED: tracing through data-bases could core dump.
FIXED: cut could break on very large computations.
FIXED: first pass at BigNum issues (reported by Roberto).
FIXED: debugger could get go awol after fail port.
FIXED: head of if/3, ->/2, *->/2 and once/1 should not be able to
cut up to predicate level. Don't ask me why.
NEW: *->/2 (SWI-compatibility).
NEW: variable_names_may_end_with_quotes allows A' in variable
names (request from Nicos Angelopoulos).
SPEEDUP: quickly check if we are importing an undefined goal.
FIXED: current_predicate/1 should enumerate all non-system predicates
visible (obs from Nicos Angelopoulos).
NEW: time/1 (based on the SWI-Prolog time/1 predicate; request from Paulo Moura).
FIXED: with 64 bits indexing would separate ints from atoms (obs from A N Saravanaraj).
FIXED: duplicated clause when starting from trace (obs from A N Saravanaraj).
FIXED: always remember wchar_t is unsigned in WIN32.
FIXED: more BOM trouble (obs from P Moura).
FIXED: testing for BOM forced incorrect execution of gets (obs
from A N Saravanaraj), also fixed stup call to Ungetc in getc and
friends.
FIXED: bad handling of trail overflow.
FIXED: overflow at entry goal (obs from Paulo Moura).
FIXED: bug with signals while process wasa dying (obs from Paulo Moura).
FIXED: compilation in OSX/64 (patches from Will Benton).
FIXED: do not access erased code (obs from Paulo Moura).
FIXED: clause/3 should not follow fail.
FIXED: make sure we don't ask for 0-sized blocks, minimal 64K.
FIXED: Aux reallocation should always increase aux size.
NEW: start atom garbage collector by default (except for threads).
FIXED: restore indices should run over the indices, and not mess
them up.
FIXED: make sure to always remove try-trust chains.
FIXED: don't adjust garbage when doing stack shift.
FIXED: stack shifter would get ignore big terms.
FIXED: retract and friends should remove mf pointers.
FIXED: small memory leaks and use of uninitialised memory (valgrind).
NEW: char_type/2 and code_type/2 (request from Brian DeVries).
FIXED: memory leak where I'd try to clear refs from an index
block before I released the kids (so the refs would never be released).
FIXED: small glitches with profon.
NEW: allow re-exporting other modules.
FIXED: graph add_ and del_ predicates should have the original
graph as the first argument (obs from A N Saravanaraj).
FIXED: implement atom holds so that the C-interface can make sure
the atom garbage collector will not remove an object.
FIXED: implement JT for CLP(BN).
FIXED: use safe locking to ensure that dynamic predicates
run correctly.
FIXED: use matrices to implement variavel elimination, also fix
some overflow bugs with matrices.
FIXED: Yap_shift_visit assumed we were using AUX DL_MALLOC (obs
from Bernd Gutmann).
FIXED: auxiliary stack overflow in term_vars (obs from Bernd
Gutmann).
FIXED: trail overflow while copying huge terms (obs from Bernd
Gutmann).
NEW: compilation_mode option for load_files (request from
Saverio).
FIXED: predicate table could not enough room while overflowing
(obs from Bernd Gutmann).
FIXED: compile large ground terms outside clauses (obs from Bernd
Gutmann).
FIXED: YAP_LeaveGoal should always backtrack, if asked for, for
deterministic computations (obs from Trevor Walker).
FIXED: in_this_file_before should check predicate module, not
current module.
FIXED: overflow when copying constraints.
FIXED: MkBlob should try to allocate more space.
FIXED: make viterbi more efficient by not generating the whole graph.
FIXED: make static_clause more careful about when static clauses begin.
NEW: support conditional compilation using if/1,elif/1,else/0,endif/0 directives.
FIXED: delay abort until garbage collection or stack shifting is over.
FIXED: grow_trail assumed SREG points to stack top!
FIXED: latest SWI chr.
FIXED: allow abolishing imports.
FIXED: YAP_EnterGoal would set YENV[E_CB] before setting YENV
(obs from Trevor Walker).
FIXED: setarg/3 should always set a global variable.
NEW: define dialect and version_data flags.
NEW: define __YAP_PROLOG__.
FIXED: LAM compilation was broken (obs from Bernd Gutmann).
FIXED: profon was broken.
NEW: send newline even for unleashed ports (obs from Miguel
Filgueiras).
NEW: atom_number/2 for SWI compatibility.
FIXED: fix YAP_LeaveGoal() (obs from Trevor Walker).
FIXED: gc generation should not be an integer: otherwise it can
be misled by global growth.
FIXED: sub_atom 0 should work.
FIXED: have has table of preds with repeated functors (obs from
Bernd Gutmann).
FIXED: major bugs in encoding support (obs from
Paulo Moura).
FIXED: overflow while gc was storing pointers in trail (obs from Angelika Kimmig).
FIXED: implement directive encoding/1 (obs from Paulo Moura).
UPGRADED: to current JPL.
FIXED: incremental garbage collection conflicts with global variables (disable it for now).
FIXED: trail overflow from calling dynamic predicates (obs from Bernd Gutmann).
NEW: add nb_*arg versions.
FIXED: overflow in indexing code (obs from Jesse Davis).
NEW: improve nb_ routines with linkvar and set_shared_var.
NEW: make copy_term share ground-terms and add non-sharing
version, duplicate_term/2.
FIXED: improve efficiency of global variables.
FIXED: simplify Makefile of yap2swi by moving yap2swi.o to main.
FIXED: tabling broken (obs from Will Benton).
FIXED: updates to SWI C-interface and corresponding extensions to
C-interface .
FIXED: be careful to give delayarena exactly what it needs to expand.
FIXED: improve BNT support with CLP(BN).
FIXED: support checking for big_nums and readline. (obs from
Rui Camacho)
FIXED: make thread_create more compatible with SWI. (obs from
Paulo Moura)
FIXED: give startup path to chr. (obs from Paulo Moura)
FIXED: optimise pre-compiled meta-calls.
FIXED: CLP(BN) with BNT.
FIXED: allow dgraphs with graphs of vars.
FIXED: add matrix library documentation.
NEW: start atom_gc by default.
FIXED: array add was not working for dyamic arrays (obs from Rui
Camacho).
FIXED: add MATLAB interface docs.
Yap-5.1.2:
FIXED: clauses with floats/large ints should be pinnned (obs from Bernd
Gutmann).
FIXED: indexing-code emulator should update S (obs from Rui
Camacho).
FIXED: error with atoms in arithmetic messages (obs from Paulo Moura).
FIXED: bug in meta-calls to external C code (obs from Bernd Gutmann).
NEW: matlab interface.
FIXED: search for libraries right.
FIXED: alarm used alarm(2) but it should use setitimer(2) so that
timeout can work with millisecs (obs from Bernd Gutmann).
FIXED: add . to -g goal (obs from Paulo Moura).
FIXED: min_list (obs from Angelika, Bernd & Niels).
FIXED: issues with C-Interface (obs from Trevor Walker).
FIXED: mktime needs to know if daylight time savings are on
(obs from Bernd Gutmann).
FIXED: handle atom lookup and functor overflows while parsing
(obs from Bernd Gutmann).
FIXED: get rid of static structures for modules (obs from Bernd
Gutmann).
FIXED: SREG might be lost on trail/heap overflow, and that would
confuse later pruning.
FIXED: UNICODE16 was broken.
NEW: support for BOM.
FIXED: debugging and clause/3 over tabled predicates would kill YAP.
FIXED: memory expansion in deallocate would lose cut pointer.
FIXED: make growtrail do more than grow chunks of 64KB.
FIXED: growtrail was broken if called while doing variable shunting.
FIXED: by default,allow defining infix+prefix/posfix instead of
using standard ISO.
FIXED: nb_current was unimplemented (obs from Pablo Beltran).
FIXED: by default,allow defining infix+prefix/posfix instead of
using standard ISO.
NEW: --with-max-workers tells us how many threads we can have (request from Paulo Moura).
FIXED: wchar_t in the WIN32 is unsigned and 16 bits.
FIXED: stack overflow when growing the delay stack.
FIXED: overflows with MIN_INT (obs from Marius Filip).
NEW: make debugger more like standard debuggers (obs from Miguel Filgueiras).
NEW: glist_void_varx was broken (obs from Marius Filip).
NEW: unify_with_occurs_check/2 was broken with extensions (obs from Aline Paes).
NEW: stack_dump/0 from Trevor.
NEW: with_mutex/2.
NEW: call_cleanup/2 and call_cleanup/3 at the request of Paulo
Moura and Christian.
FIXED: garbage collector would not understand bindings to mavars in
tabling version.
FIXED: cut might not prune correctly around meta-call (obs by
Trevor Walker).
NEW: keep history around (use nb and friends).
NEW: fix determinsitic debugging.
NEW: make debugger compatible with threads (use nb and friends).
FIXED: debugger was confused when crossing between regions.
NEW: unify_with_occurs_check was very broken (obs from Aline Paes).
NEW: partial support for UNICODE.
FIXED: ÿ has ISO-LATIN1 code 255, so it would be confused with EOF
(obs from Miguel Filgueiras).
FIXED: mess with \+ meta-call and modules (obs from Nicos Angelopoulos).
FIXED: reconsult with spy was broken (obs from Miguel Filgueiras).
FIXED: mess with EOF and open (obs from Nicos Angelopoulos).
FIXED: make use_module/3 handle case where module is given.
FIXED: library_directory/1 was not being used.
FIXED: style_checker was failing on DCGs (obs from Miguel Filgueiras).
FIXED: +inf is a number (obs from Trevor Walker).
FIXED: if peek finds EOF get should not return an error (obs
from Miguel Filgueiras).
FIXED: allow overflows on timestamps.
FIXED: more fixes for new dynamic code and stack shifting.
FIXED: if we can generate index on an sub-argument and the
argument is unbound we should generate the code, suspend
on it, and then call the system again.
FIXED: avl_new/1 (obs from Miguel Filgueiras).
FIXED: broken all/3 (obs from Miguel Filgueiras).
FIXED: make 128 maximum disjunction depth (obs from Nicos Angelopoulos).
FIXED: first cut at using timestamps with logical updates.
FIXED: indexing on doubles wasn't working properly.
FIXED: sending large lists of atomics to DB was very, very slow.
FIXED: make library_directory/1 better protected.
FIXED: make YAP smarter at finding libraries in WIN32.
NEW: data structures using global variables: queues, heaps and
beam search support.
NEW: global variables a la hProlog, includes major changes in
stack shifter, garbage collector, and setof.
FIXED: do not call garbage collector if the space we need is more
than what is available (obs from Nicos Angelopoulos).
FIXED: recordaifnot(a,_,_) was broken (obs from Jesse Davis).
SPEEDUP: some speedups to garbage collector (obs from Nicos Angelopoulos).
NEW: a first cut at readutil.yap (request from Stefan Weinbrenner).
FIXED: compile | as a disjunction (obs from Ole Edsberg).
NEW: rbqueues keeps a simple db queue
NEW: cut_up_to_next_disjunction/0 tries to prune until the closest
choice-point from the parent disjunction (think query packs).
FIXED: error condition when we expand to maximum number of variables.
FIXED: bug when variable list in parser overflows.
FIXED: min_list (obs from Filip Zelezny).
FIXED: -l and -L options (again?).
FIXED: if we cannot read more chars in saved state we're dead.
FIXED: termination info for failed and detached threads (obs Paulo Moura).
FIXED: check_callable should check for modules (obs Paulo Moura).
NEW: add thread_sleep/1, mostly works like system:sleep/1 (request from Paulo Moura).
NEW: add select/3 and intersection/3 to SWI emulation.
FIXED: always keep in mind that Yap_WakeUp may change H (would
break chr).
FIXED: add_clause of new predicate could get in loop.
FIXED: don't have to print anything if there is not anything to
print.
FIXED: current_thread/2 should fail if called with bad alias or
ID (obs Paulo Moura).
FIXED: correct code statistics with DL_MALLOC or SYSTEM_MALLOC.
NEW: use true_file_name for file operations in system library (obs Paulo Moura).
NEW: make YAP large address aware on WIN32 (should be able to
allocate up to 3GB).
FIXED: WIN32 may have a lot of fragmentation so several memory holes may be active at the same time, keep up to 32 open holes.
FIXED: WIN32 may move functions without moving emulator: always fix C-functtions.
FIXED: use $SYSTEMDRIVE to install YAP in WIN32.
FIXED: compilation bug in arg(X,1,A).
NEW: extend interface to pass chunks of integers/floats.
FIXED: get rid of some more global variables.
NEW: thread_yield/0 (request Paulo Moura).
FIXED: current_thread was not returning aliases (obs Paulo Moura).
FIXED: AuxSp was not properly initialised for new threads (obs Paulo Moura).
FIXED: recusive indexing over unbound compound terms was broken
(obs Ricardo Lopes).
FIXED: toplevel_print_options and debugger_print_options was
broken and undocumented (obs Ashwin Srinivasan).
NEW: lock streams while using them (concurrent writing is still allowed).
FIXED: make current_op only walk over atoms.
FIXED: memory corruption when copying consult stack (obs Paulo Moura).
FIXED: get rid of some silly locks.
FIXED: don't compare block top with <= (obs Paulo Moura).
FIXED: ! was not pruning right in p_execute_clause (obs Nicos
Angelopoulos).
FIXED: system/1 and shell/1 should check return code (obs Nicos
Angelopoulos).
FIXED: thread_peek_message should use aliases (obs Paulo Moura).
FIXED: garbage collector should not rewrite cp_tr fields until
after marking (obs Paulo Moura).
FIXED: garbage collector was allowing garbage trail entries for
multi-assignment variables. Namely, old var value might point to new space
(obs Paulo Moura).
FIXED: thread aliases were being cleaned up just after being
installed (obs Paulo Moura).
FIXED: rb_partial_map was broken.
NEW: wdgraph and wundgraph libraries, for weighted graphs.
Yap-5.1.1:
FIXED: compatibility fixes .
Yap-5.1.0:
NEW: new implementation of association lists, based on red-black
trees.
NEW: undgraph library, based on dgraphs.
NEW: dgraphs library, towards a more efficient implementation of
directed graphs.
NEW: rb_update, rb_apply, rb_visit, rb_keys and rb_map.
FIXED: use rb_ prefix for all red black predicates.
FIXED: got confused about position of syntax error (obs Mark
Goadrich).
FIXED: compiling inline lists would compile the lists and then
some more (obs Nicos Angelopoulos).
FIXED: message queue ops should not fail silently (obs Paulo
Moura).
FIXED: stream bugs in iopreds.c (Takeyuki SHIRAMOTO).
FIXED: extra backtrack in informational_messages (obs Nicos
Angelopoulos).
NEW: abolish_module/1 at the request of Nicos Angelopoulos.
FIXED: variable shunting needs HB initialised before any marking
takes place!!!
FIXED: handle possible overflow in term_variables
FIXED: check for singleton warnings in .yap files, try to catch
bugs before they bite people.
FIXED: make threads compile again, fix some compilation warnings.
FIXED: use different chains for dead static clauses, static
indices and dead mega clauses. Extend dead clauses with next field so that
they can added into chain. Fix restore to see dead clauses.
FIXED: check if indexing code is live before purging it (obs
Bernd Gutmann).
FIXED: pass backtrackable C-preds all flags they ask for (obs
Tiago Soares).
FIXED: compilation with dynamic libraries and JPL compilation.
FIXED: typo in manual (obs Bernd Gutmann).
NEW: track the current block more aggressively, to avoid
expand_index taking too long searching for a block.
FIXED: if LU indices have groups, we should create
try-retry-trust sequences immediately, otherwise LU semantics can be
compromised (obs Bernd Gutmann).
FIXED: when cleaning trail, gc would not always clean value
field! (obs Remko Troncon).
FIXED: when cleaning megaclauses, clean flag too.
FIXED: don't put array twice in list of live arrays (gc would loop).
NEW: debugger will not backtrack over complete deterministic computations.
NEW: debugger can show CP stack.
NEW: internal procedure to show choice-point stack.
FIXED: Incremental GC could still get confused after backtracking
over GEN marker. Associate GEN marker with timestamp and make sure
we only use current GEN markers (obs Mark Goadrich).
FIXED: Yap on OSX should not make CreepFlag a register, as this
breaks Interrupt Handling. Also, it seems that if I do not reserve
r13, GCC will use r14 for its own evil purposes.
FIXED: make Yap files usable again as a script (obs Ales Kozumplik).
FIXED: silent informational_messages was being ignored (obs Nicos Angelopoulos).
FIXED: initialization should only be performed after all
consulted files are done.
FIXED: garbage collector now makes refs to erased LU clauses point
to LogUpdErasedMarker.
FIXED: get rid of old code referring to LogUpds from within ImmediateSemantics.
FIXED: indexing code would get confused about size of inlined
float/1 (obs Paulo Moura).
FIXED: broken SIGINT with tkyap (Keri Harris).
FIXED: indexing of bignums was broken, just disable it for now.
FIXED: pipe open was returning the same descriptor twice (obs Christian Thaeter).
FIXED: style check should compare with true file name.
FIXED: ^c should take care about TR and B.
FIXED: don't pass a pointer to a mpz_t. (obs Nuno Fonseca)
FIXED: handle heap overflow from huge atoms in
Yap_LookupAtom/scanner (obs Nuno Fonseca).
FIXED: bignum was using int where should be long int (obs Roberto Bagnara).
NEW: x86_64 should have registers, right? First cut at using them.
FIXED: call_n would break under 64 bits, an int problem.
FIXED: more compilation problems if GMP not there (obs Remko Troncon).
FIXED: make syntax error report the line where the bug was (obs Jude Shavlik).
FIXED: ok, MkBigInt shouldn't free the bigint.
FIXED: MkBigInt already frees bigint.
FIXED: don't pass a pointer to a mpz_t. (obs Nuno Fonseca)
FIXED: YENV may be an HW register (could break some tabling code)
(obs Remko Troncon)
FIXED: All YAAM instructions are now brackedted, so Op introduced an { and EndOp intr
oduces an }. This is because Ricardo assumes that.
FIXED: compile attvars when COROUTING is undefined.
FIXED: compiler warnings due to c-interface changes
.
FIXED: scanner would convert LONG_MIN to bigint, but it can be
represent as a LONG; fixed by using mpz_fits_slong_p (obs Roberto Bagnara).
FIXED: indexing cut should stop looking after a cut!!!! (obs Paulo Moura).
FIXED: mktime was broken in WIN32.
FIXED: don't assume a fixed point for WIN32 memory allocation.
FIXED: don't call goal_expand when looking for handlers of undefined procedures.
FIXED: always walk through modules in the same order when waking
up variables (otherwise, breaks CLP(QR)).
NEW: SWI-like yap_flag(float_format,_).
FIXED: change C-interface to use new interface.
FIXED: << and >> should handle overflows.
FIXED: mod and rem now implement ISO semantics (hopefully).
FIXED: change implementation of bigints to be more like GMP style.
FIXED: handle assert/retracts and gprof overhead right.
FIXED: indexing code was not setting up properly registers on longjmps.
FIXED: use RISC architecture on MacOsX (__POWERPC__ + _POWER).
FIXED: init system predicates should generate full static clause.
NEW: tabling does not conflit with depth limit (Trevor Walker).
NEW: make scanner restartable on seekable files (Nuno Fonseca).
NEW: improve error discovery within scanner (Jude Shavlik).
NEW: change event profiler to do profiling online and
off-line.
NEW: routine to find clause/pred
NEW: always end clauses with Ystop START, so that we can refer
back to the clause's beginning.
NEW: always have a pointer to Pred in clauses, so that we can
find current predicate.
NEW: heapgc should now be concurrent when using threads.
FIXED: heapgc wo tags can handle trail overflows right.
NEW: heapgc wo tags does not write on the collected areas during marking.
FIXED: dif/2 might get into trouble restoring assignments to
attributes.
NEW: Yap_DebugPlWrite and Yap_DebugErrorPutc for those debugging
moments.
FIXED: get rid of dead internal variable MutableList.
NEW: write_depth/3 for very large compound terms.
FIXED: new bug in garbage collection.
FIXED: overflow handling in DB/AttVars was resetting old var, and
wasn't resetting trail.
FIXED: when rebuilding DB term with attvars, set global var to
point to attvar.
NEW: add school CLP(BN) example.
NEW: add sc CLP(BN) example.
FIXED: make exception port more like a true port.
FIXED: don't run ^ in setof if there are no excess variables.
FIXED: prolog_load_context(directory) relied on dead code.
FIXED: some small beautifications for system/1, getcwd/1, sh/1, rename/2.
NEW: operating_system_error.
FIXED: Restore could not recover DL_MALLOC info and was not recovering
DBTerms correctly.
FIXED: with locking field, AtomNil and friends might not be
aligned, and would be confused with int.
FIXED: variables should always be reset when doing trail
expansion from the parser, even if there is no shifting (obs Trevor
Walker).
FIXED: growglobal with realloc was broken.
FIXED: with threads, self-deadlocking in new array codes.
FIXED: in tabling, use malloc when AllocCodeSpace fails.
FIXED: in tabling don't look inside cp_ap == NULL and fix recent
bug in walking dependency frames.
FIXED: with tabling ASP sometimes was miscalculated, causing
trouble with stack shifter (obs Kostis Sagonas).
FIXED: ~D should print bignums (obs Jude Shavlik).
FIXED: format's ~d and ~D were broken (obs Jude Shavlik).
FIXED: profiler should not talk about hidden predicates or idb entries.
FIXED: recentg change in setof could bind argument (obs
Jude Shavlik).
FIXED: EOF (-1) at debugger prompt would generate exception (obs
Jude Shavlik).
FIXED: ^C was very broken: break was not accepted, and debug,
trace and statistics did not work at all (obs Jude Shavlik).
FIXED: format_has_tabs could miss tab signs (obs Jude Shavlik).
FIXED: plug holes in memory allocation from scanner (obs
Mark Goadrich).
FIXED: instrument memory allocation when using system malloc.
FIXED: adjust_cp_hbs was readjusting consumer choice-points (it
can only adjust hb once) (obs Remko Troncon).
FIXED: try to make GC trace message "marked N vars" intelligible.
FIXED: garbage collection of mabindings was broken with tabling
(obs Remko Troncon).
FIXED: did not initialise tabling variables
(obs Remko Troncon).
FIXED: should have meta-predicate definitions for calls and
discontiguous.
FIXED: have discontiguous as a builtin, not just as a
declaration (obs Jude Shavlik).
FIXED: if first argument was unbound, comparisons might be
called with second argument undereferenced!!
FIXED: strip ^ before doing execute in setof or bagof.
FIXED: use CONST declarations in interface (thanks to Roberto Bagnara).
FIXED: absmi should consult PREG, not P (obs Remko Troncon).
FIXED: bad init in tabling code.
FIXED: YAP_MkBigIntTerm was broken (obs Roberto Bagnara).
NEW: update documentation to support new CLP(R) and CHR packages.
FIXED: regression in clpbn/utils.yap.
NEW: put_attrs/2.
FIXED: don't install CLP unless coroutining && rational trees are
active.
FIXED: syntax error in ypp.yap (obs Paulo Moura).
FIXED: save/restore should be as usual if using YAP allocation.
FIXED: save/restore FZ regs.
FIXED: $loop_stream could be defined early in boot process.
NEW: make rational trees default.
v
NEW: make enable-max-memory default.
FIXED: allow people to disable indexing (obs Ricardo Lopes).
FIXED: make undefined exception more ISO like (obs Paulo Moura).
FIXED: add missing dependency in chr's Makefile.in.
FIXED: fix corruption in ypp.yap.
FIXED: ~@ makes format a meta-predicate.
FIXED: format should do immediate exit on exception (from Prolog call).
FIXED: make format reentrant and thread-safe (format may call itself).
FIXED: don't complain if a module is loading a reexported
predicate and the original predicate.
FIXED: change a few defaults for SWI compatibility.
FIXED: library prandom was broken (obs Nuno Fonseca).
NEW: add max_tagged_integer and min_tagged_inter prolog_flags.
NEW: add ~@ option to format.
NEW: memberchk/2 is like builtin in SWI emulation lib.
NEW: SWI like prolog_source_location/2
FIXED: $loop_stream usage was broken. Fix $fetch_stream_alias to
be bidirectional.
FIXED: allow nb_set followed by b_set, bheakkkk! The other way round
is still not allowed.
NEW: from SWI maplist/2, maplist/3, maplist/4.
NEW: call/2, call/3, call/4.
FIXED: disable mutables in SWI mode.
FIXED: safe C-preds should always use P when calling garbage
collector, aarrggh :-(, CP use found in GetTermFromArray.
NEW: SWI-like ord_empty/1 and ord_memberchk/2 in library(ordsets).
FIXED: safe call_c should check for signals before calling a built-in.
NEW: -p option allows setting path from command line.
FIXED: during grow, heap references should not be followed from trail.
FIXED: \= was not resetting wakeups correctly.
FIXED: copy_term was broken if attrs were an unbound variable.
FIXED: during garbage collection, heap references should be
copied to trail, and that's it.
FIXED: excessive backtracking in multifile declaration.
NEW: allow style_check(singleton) and style_check(-singleton).
NEW: SWI module now makes atom_concat/{2,3} behave like atomic_concat/{2,3}.
NEW: add SWI-like copy_term_nat/2.
NEW: add SWI-like get_time and convert_time, but using integers, not floats.
NEW: add SWI-like working_directory/2 and chdir/2.
NEW: add append/3 and member/2 to SWI module.
FIXED: use bootstrap/1 to load up system.
FIXED: use_module/3 did not get info on loaded_module.
NEW: use_load_files as main file loading option.
FIXED: broken do_print_message for defined_elsewhere.
FIXED: debugger option.
FIXED: trace through undefined predicates correctly.
FIXED: WIN32 missing include files (untested)
FIXED: -L trouble (my thanks to Takeyuchi Shiramoto-san)!
FIXED: debugging of backtrable user-C preds would core dump.
FIXED: redeclaring a C-predicate as Prolog core dumps.
FIXED: badly protected YapInterface.h.
FIXED: break/0 was failing at exit.
FIXED: YAP_cut_fail and YAP_cut_succeed were different from manual.
FIXED: tracing through data-bases could core dump.
FIXED: cut could break on very large computations.
FIXED: first pass at BigNum issues (obs Roberto Bagnara).
FIXED: debugger could get go awol after fail port.
FIXED: make sure variables are globalised before spying.
FIXED: tabling in autoconf.
SPEEDUP: improve variable unification where we know one of the variables is in the heap.
FIXED: when sweeping garbage collector should check for variables posing as blobs (USE_OFFSETS).
FIXED: reduce overheads in functor/3.
FIXED: variant and subsumes must check functor and must check for extensions.
FIXED: activate dorming optimised instructions and fix glist_void_var.
FIXED: performance bug in new multiplication code (only for i386).
FIXED: exit at Error() in Error().
FIXED: grow() had trouble with array ptrs in Trail.
FIXED: include Stasinos patches for gmp, HP-UX and on documentation.
FIXED: recorda_stat_source was passing 0 instead of tagged 0, also always initialise ->code!
FIXED: accept multiple block declarations and process them as a conjunction.
FIXED: call_residue/2.
FIXED: block even when you have no - modes.
FIXED: use mkstemp() instead of tmpnam() in alloc.c.
FIXED: now I can wake up goals at disjunction, see merge(A,[2],C), A = [1|B], (B = [2]; B = [3]). I had to save temporary registers in a term. Check push_live_regs and restore_regs() for details.
FIXED: ->p field of either now points to true.
FIXED: we must execute woken up goals before ;/2: force stack checking at either.
FIXED: present a single delayed goal per variable Done.
FIXED: make block/1 and wait/1 directives.
FIXED: make block/1 use when/2.
FIXED: compiling with glibc2.2, gcc-2.96 had small complaints.
FIXED: configure should now work with gmp3.
FIXED: overflow with extremely large terms in copy_term.
FIXED: unification between bignums could fail.
FIXED: improve print_message/2.
FIXED: make number_codes understand inf and nan.
FIXED: parse bigints in files.
FIXED: one should set creep flags whenever adding goals.
FIXED: debugging messages to stderr.
NEW: simpler scheme for delays.
FIXED: (mark_trail) do not mark second assignment to mavar in same choicepoint, helps 5% in mip, zilch in rkf.
FIXED: make goal_expansion and clause_expansion logical and multifile.
FIXED: stackgrow() with biginits.
FIXED: compile bigints properly.
FIXED: ShowCode should know about bigint instructions.
FIXED: arith.yap should understand int != bigint.
FIXED: ==/2 had bugs with attributed variables.
FIXED: make debugger aware of woken goals.
FIXED: bug in debugger with single update semantics dynamic clause.
FIXED: definition of MAX_WORKSPACE had been deleted from alloc.c??
FIXED: frozen/2 and outputting suspended goals.
FIXED: BlobTermAdjust was not always defined.
FIXED: bad memory allocation in parser.c for _ resulted in cryptic error messages.
FIXED: // error in CHR.
FIXED: syntax error in initialization.
FIXED: syntax error messages again point to the error.
FIXED: add extra copyright info about LUM in manual.
Yap-4.3.14:
FIXED: gcc/solaris would not compile.
FIXED: gc instrumentation was still giving noise.
FIXED: bug without GMP.
NEW: CHR manual.
Yap-4.3.13:
FIXED: call_residue/2.
FIXED: == in configure.in.
NEW: document attributed variables and CLP(Q,R).
NEW: initial support for Apple OS/X, thanks to Paulo Moura for the patch.
FIXED: hash trouble in IDB (thanks to Stasinos Konstantinos for the report)).
SPEEDUP: meta_predicate database is now in dynamic procedures with logical updates.
FIXED: module 0 should always be found in DB.
FIXED: alloc space for get_num from trail.
NEW: discontiguous is a valid operator.
FIXED: gcd/2 operator would break on negative numbers.
NEW: support for GMP gnu library and longints.
NEW: back to blobs in global.
NEW: new implementation of arithmetic with a function per operator and no switches.
FIXED: ## breakage in OS/X cpp (c_interface.h. thks Paulo Moura).
NEW: new arithmetic code.
NEW: CHR (Thanks to Thom Fruewirth).
NEW: itemization bugs in the manual (Stasinos Konstatinos).
NEW: add sequential/0 and parallel/0 directives.
FIXED: move Codes and Lists to heap_regs as these variables are in fact supposed to be shared between processes.
FIXED: SBA should be able to store bindings in cell.
FIXED: PutAtt and GetAtt might return NULL in SBA.
FIXED: unify and friends would use uninstantiated variables.
FIXED: only install INTERFACE_HEADERS.
FIXED: DO_MATRAIL had reverse order under SBA.
NEW: prolog_load_context/2.
FIXED: allow reutilising aliases to files.
FIXED: replace term_variables by variables_in_term in pl/*.yap.
NEW: dynamic loading support for HP-UX (Stasinos Konstantinos).
FIXED: help info in configure.in and forgotten $ (Stasinos Konstantinos).
Yap-4.3.12:
NEW: configure compilation process from configure.
FIXED: save/restore should set CurrentModule.
FIXED: InitYaamRegs should not set CurrentModule.
FIXED: load_dld would crash on NULL argv[0].
FIXED: get rid of install_library and build libYap.a by default. Fix minor bugs in yaplib.
FIXED: used TRAIL to remember structure-to-structure bindings in utilpreds.c and cmppreds.c (this avoids overflow noticed by GJVNoord).
FIXED: split yapor_on so that ! is after yapor_on. This should prevent cutting to before the root of the tree.
FIXED: bad handling of libs in load_dl.c (fix from Stasinos Konstantopoulos).
FIXED: free_answer_hash_chain should untag parent pointer (Ricardo Rocha).
FIXED: walltime would compile with cygwin (patch from gzk02612@nifty.com).
FIXED: try_logical_pred was doing nasty things to choice-points in parallel mode.
Yap-4.3.11:
FIXED: read could fail and not restore the original input stream (noticed by GJ VanNoord).
FIXED: crappy handling of multi-assignment variables while growing stacks (noticed by GJ VanNoord).
FIXED: Bad save/restore machine registers in hppa.
FIXED: Bad initialisation for '_' variables.
FIXED: check null ENV in do_toggle_static_predicates_in_use, this seems to break HP-UX machines.
FIXED: Bad default address on SGI machines.
FIXED: Atom operations were being included too soon.
FIXED: alignment issue in LastWTimePtr with SPARC.
FIXED: Bind needs HBREG in p_save_cp/exec.c.
FIXED: small ints in term_hash.
FIXED: bug in installing CLPQR in Makefile.in (noticed by Luis Castro and GJ VanNoord).
Yap-4.3.10:
FIXED: install info by default in /usr/share/info.
NEW: MULTI_ASSIGNMENT_VARIABLES should work with tabling and or-parallel execution.
FIXED: small glitches with lcc.
FIXED: walltime in parallel system.
FIXED: zombies in ACOW.
NEW: CLPR is now in the YAP distribution.
NEW: sequential tabling can do stack shifting.
NEW: sequential tabling uses standard memory management system.
FIXED: make tracer work with tabling.
FIXED: make exec_goal work with tabling.
NEW: integrated latest OPTYap.
NEW: CIAO's pillow library.
FIXED: verify_attributes should follow SICStus order, or else CLPR will break in critical,go2 :-(.
FIXED: debugger was getting confused by modules that import predicates that are also defined in the module.
FIXED: =.. was messing with constraints, make it SDerefHead.
NEW: print $VAR("string") as string.
NEW: write_term(X,[write_depth(X)]) is a legal option in SICStus.
NEW: write_term(X,[portrayed(X)]) is a legal option in SICStus.
FIXED: debugger would get confused with undefined procedures.
FIXED: DB compression bug for lists with rational trees on.
FIXED: the blackboard routines are meta-predicates!
FIXED: initialization should be performed on correct module.
FIXED: make initialization/1 an operator.
NEW: print_message and portray_message.
FIXED: do proper meta-predicate processing for user:a :- meta(...).
FIXED: do term expansion from top level and for end_of_file in consult.
FIXED: don't do grammar expansion if term expansion succeeds.
NEW: yap_flag(toplevel_hook,_): this is a goal to be executed before prompting at the top-level.
NEW: variant/2.
FIXED: term_hash was not documented and in the wrong modules.
NEW: first try at ugraphs module.
NEW: SICStus compatible module/1 and yap_flag(typein_module,_).
NEW: SICStus compatible prolog_flag/2 and prolog_flag/3.
FIXED: for SICStus compatibility primitives module is now prolog module.
FIXED: corrent consulted file could get confused.
FIXED: more fixes to top-level and call-residue with attributed variables.
FIXED: call to compare_terms in optimise_ce relied on correct H. Could corrupt the compiler.
FIXED: fix a few bugs on presenting floundered goals.
FIXED: procedures imported into user should be imported by every module (do that by binding the importer to a variable).
FIXED: do not try to debug over commit.
FIXED: make top-level more SICStus like on how to present variable bindings.
NEW: support columns in format/2 and format/3.
FIXED: p_number and friends should check for var before checking for number with corouting support.
FIXED: init was setting WakeUpCode too late.
FIXED: save_program was not restoring WakeUpCode.
FIXED: terms library.
NEW: SICStus compatible prolog_flag/3.
FIXED: \+ \+ nondet1, !, nondet2.
SPEEDUP: improved exec path.
FIXED: hold locks for longer in i_recorded.
CLEANUP: avoid references to corouting data structures in non-corouting code.
NEW: new hashing function for IDB.
FIXED: make profile_data understand modules.
FIXED: first argument for profile_data was inconsistent.
FIXED: broken trail resetting in p_read (thks G.J. VanNoord).
CLEANUP: ANSI-C code cleanup (thks S. Konstantopoulos).
CLEANUP: new Atom.h.m4 file splits some stuff from Yatom.h.m4.
CLEANUP: linkblk with one less argument and faster code (hopefully).
FIXED: get rid of AtomBase.
FIXED: keep ordering between MkFunctor and friends.
FIXED: PreviousHeap is trash.
FIXED: too many calls to MkFunctor in GetPred.
Yap-4.3.9:
FIXED: VC++ compilation was broken.
FIXED: handle trail overflows in Windows.
FIXED: general fixes as cygnus compilation was broken.
FIXED: yap.exp got out of sync.
FIXED: YAP would include too many headers such as sys/time.h and sys/wait.h breaking -mno-cygwin.
FIXED: don't trust in string.h to initialise NULL, this seems to cause weird problems in gcc -mno-cygwin.
FIXED: lack of heap in assembler shouldn't force compiler to restart.
FIXED: C-stack would overflow with PermVar, make this function non-recursive.
FIXED: hint growheap on the least heap it needs.
FIXED: expand stack on overflow while parsing and overflow while creating the var table.
FIXED: move ParserStack to Trail so that we can read in very large terms.
FIXED: recursion of c_optimise would break for very large clauses, replaced it by iteration.
CLEANUP: replace defined for enum in Yatom.h.m4.
FIXED: bug in compiled terms with DBRefs (same field was used for CodePtr and RefPtr).
FIXED: guarantee correct locking for PreAllocCodeSpace().
FIXED: another typo in charsio.
FIXED: always allow asserts but careful, for now system will only recover some space at top-level.
FIXED: In yap.c read false before someone hides it ;-).
CLEANUP: get rid of AtomLive and of AtomFalse.
FIXED: erase/1 and erased/1 now complain on bad arguments.
FIXED: ANALYST would not compile.
FIXED: go round bad FILENAME_MAX in HPUX (Stasinos Konstantopoulos).
CLEANUP: use sed instead of symbolic links in make depended (Stasinos Konstantopoulos).
FIXED: don't check if someone is looking at an environment while asserting.
FIXED: gc always assumed an immediate DBRef.
FIXED: ! now cuts if != instead of < (fixed cut_by).
FIXED: __hpux to __hpux (Stasinos Konstantopoulos).
FIXED: makedepend works again (Stasinos Konstantopoulos).
FIXED: compile under hpux cc (Stasinos Konstantopoulos).
NEW: locking for internal data base.
FIXED: bad cast in DBProp.
Yap-4.3.8:
FIXED: previous change to ! was wrong.
FIXED: YAP_ARRAYS was still being used in arrays.c and sbaamiops.h.
FIXED: small glitches in the manual.
NEW: change work dir from Yap4 to Yap-4 (that's what everyone else does).
NEW: make install_info.
NEW: yap.spec and automatic generation of rpms.
Yap4.3.7:
FIXED: fix SBA bug in or.cuts.h.
NEW: cut now looks for ==, not <.
NEW: FunctorList is now special.
FIXED: Looking up "." was broken.
FIXED: halt/1 would not send out the error code.
NEW: allow executable Prolog files that call YAP (option -L).
FIXED: bad overflow handling when compiling very large terms.
FIXED: bugs in charsio at open_chars_stream and number_to_chars.
FIXED: search for library() did not use env var YAPLIBDIR.
NEW: parallel locking for MIPS machines.
NEW: parallel locking for Alpha machines.
FIXED: In OPTYAP UNLOCK should be machine dependent.
FIXED: In linux, SBA would mess up with DB because MBIT was in binding_array addresses. Fix that and include a check when we allocate BA space.
NEW: Protect DB updates and use with immediate update semantics.
FIXED: get rid of the stuff on searching whether a predicate is in use for YAPOR, as it wouldn't work.
FIXED: disallow asserting and abolishing static procedures in YAPOR.
NEW: allow asserting database references as arguments for dynamic procedures.
FIXED: consult and friends are now directives (this should avoid trouble with YAPOR).
FIXED: change configure.in for Alpha/Linux.
FIXED: change YAPOR not to try to do parallel execution of consult.
FIXED: protect goals from save_program/2 and also make sure they don't fail.
FIXED: [a] in top level should be executed as a query.
CLEANUP: get rid of c_csult_stream.
FIXED: fix predicates that depended on current_stream returning user name for file.
FIXED: close/1 and close/2 should only close atomic filenames in YAP mode, and should not depend on current_stream/3 returning the original name.
FIXED: current_stream should return real name, not user name.
CLEANUP: add consult/reconsult mode and file name to consult stack.
FIXED: force indexing immediately after consult in YAPOR. This guarantees the system will not get into trouble later trying to generate indexing code for a predicate while someone is entering it.
FIXED: bad init interface with YAPOR.
NEW: support partial locking for predicates.
FIXED: wrong include path in regex's Makefile.in.
FIXED: bb_new was doing a broken property insert.
FIXED: save_program now restores SpyCode so that we can restart saved states with spying data.
FIXED: YapInit wasn't using stack size info from saved states.
FIXED: asserting static predicates would not store the right source.
FIXED: assert would loop with assert((H:-b)).
FIXED: GC bug would not process direct pointers from local or trail to lists in code space.
NEW: change directory structure.
NEW: support locking for arrays.
NEW: support locking for operators.
NEW: support locking for values.
FIXED: bad comparison with BB in write_val (SBA).
NEW: support locking on alloc/free.
NEW: support locking on blackboard.
NEW: support locking for individual atoms (protects the property list).
NEW: support locking the atom table.
NEW: sequential code should now compile empty locks.
FIXED: YAP again compiles and runs under AIX4.1.
FIXED: support creating YAP DLL with VC++.
FIXED: VC++ didn't understand S_ISDIR().
FIXED: small fixes to yap.tex.
FIXED: unsigned/sign comparison warnings in VC++.
Yap4.3.4:
FIXED: IRIX6 is now set up load DLLs.
FIXED: Yap4.3.3 had broken register handling in c_interface.c.
FIXED: bug in library/regex/Makefile.in.
FIXED: FreeBSD/ELF is now set up to load DLLs.
FIXED: in_limbo should now be correct.
FIXED: YAPOR would not compile because of macros.
Yap4.3.3:
FIXED: recover space after every parse/compile in new yap.c.
FIXED: ignore getcwd under simplescalar.
FIXED: only include standard files after YAP headers.
FIXED: save and restore registers correctly under c-interface.
NEW: add YapWrite to C-Interface.
FIXED: mmapped arrays do not compile with simplescalar.
FIXED: force saved states to look up YAP in YAPBINDIR.
FIXED: quoted strings go back to ISO.
FIXED: -DYAP_ARRAYS is no longer an option.
FIXED: get rid of a few of ANSI-C old-style warnings from lcc.
FIXED: TrueFileName had been broken.
FIXED: Yap now configures and compiles with lcc 4.1/Linux.
FIXED: port yap to compile under cygwin 1.1.0/mingw32 and to support winsock2. The new version also supports CreateWaitableTimer.
FIXED: force yap to follow environment variable YAPLIBDIR.
FIXED: force yap to look for dlls in library.
FIXED: replace strcat and strcpy by strncat and strncpy.
FIXED: search for saved states in library.
FIXED: ^c-a in MINGW32.
CLEANUP: ^C handling.
NEW: creating and loading dll now works in YAP/WIN.
NEW: compile core YAP as a dll under MINGW32.
NEW: yap.c is now external to YAP.
NEW: understand Unix paths under WIN32 and MINGW32.
FIXED: make sure you only start compiling objects after having all headers ready.
FIXED: Debugger ($spycalls) should module switches and consulted the table of imported predicates.
FIXED: Compilation bug and warnings under vc++.
FIXED: YAP_ARRAYS required TERM_EXTENSIONS to compile.
FIXED: compile under cygwin's gcc -mno-cygwin, so that YAP won't need the cygwin dll (MINGW32).
FIXED: save.c should reinitialise user streams.
FIXED: predentries for functions may change address in save.c.
FIXED: SimpleSim does not implement getcwd.
FIXED: tracer.c had a C++ comment.
FIXED: ttyname might return NULL, at least in SimpleSim.
FIXED: reconsult was broken.
FIXED: bracket messages for syntax errors.
FIXED: scanner would break if AllocScannerSpace failed.
FIXED: bad checking of eof_action in open.
FIXED: mistake in compiling /\.
FIXED: extra clauses in environ.
FIXED: checking list of operators was wrong in op/3.
FIXED: missing variable in error message.
FIXED: reset CreepFlag in Error.
FIXED: wrong error in name(int(X),_).
FIXED: fix writing "\" when writing strings with no character escapes.
NEW: add yap_flag(write_strings,X) as in Ciao.
NEW: add StringToBuffer routine to the c-interface.
NEW: add routines for allocating and releasing database space to the c-interface.
FIXED: change type for unify in CInterface.
FIXED: PlUnGetc should return int, not Int.
FIXED: get rid of C++ comment in save.c.
Yap4.3.2:
FIXED: Yap can now use shm for memory allocation.
NEW: Yap can use malloc if mmap, shm, and sbrk failed.
FIXED: sbrk allocation should be working again.
CLEANUP: get rid of unused functions in old alloc.c.
CLEANUP: in Yap.h.m4 make clear when you are in second quadrant.
CLEANUP: keep table with all c-predicates. restore now does not need to reinitialise functions.
FIXED: in alloc.c, handle cases where /dev/zero fails properly.
CLEANUP: move atoms and functors into heap_codes.
CLEANUP: move module info to heap_codes.
FIXED: save.c would not restore properly bfunc instructions. Had to add a p field for these instructions.
FIXED: save.c was not always restoring pp->OpcodeOfPred.
FIXED: reset opcode-op hash-table in new calls to InitReverseLookupOpcode.
FIXED: check if emulator shifted when recovering saved states.
NEW: charsio, SICStus compatible reading to and writing from strings.
FIXED: uncaught instantiation errors in eval routines.
NEW: yap_flag(character_escapes,{on,off}).
CLEANUP: get rid of config.c.
Yap4.3.1:
FIXED: $call and $spied_call used with one less argument by debugger.
FIXED: bug in repeat from top level.
FIXED: MAX_DEPTH was set too high.
FIXED: use actual definition of repeat.
FIXED: use < to compare cps for !, not == because of (! ->).
FIXED: $set_depth_limit should work with Integer, not Int.
FIXED: Allow Linux to compile without getrusage but using times (problem with glibc/kernel).
Yap4.3.0 has been released.
Changes in YAP4.2
Yap4.2.1:
FIXED: up release number.
FIXED: swap order of first authors in the manual.
NEW: more patches for OPTYap.
FIXED: not all Linuxen that have fpu_control.h understand _FPU_SETCW.
Yap4.2.0pl18:
FIXED: DebugPutc.
FIXED: SBA must initialise or set public permanent variables in the SBA.
FIXED: get rid of a Prolog definition for number_codes.
FIXED: YOUNGER out of OPTYap and renamed YOUNGER_CP.
FIXED: don't use offsets to local in SBA.
FIXED: make DelayedB and TopB actual choicepointers to support SBA.
FIXED: memory allocation for FreeBSD.
RW Locks are now in YAP (unused yet).
FIXED: dynamic arrays were getting too complex, allow the heap to point to the global stack and change garbage collector to handle it. YAP_ARRAYS is now compatible with everything ;-) and can stop being an option.
FIXED: cut used < instead of !=.
NEW: new YapOr code from Ricardo.
FIXED: a few complaints with Solaris.
NEW: generate exceptions in ISO mode for HP-UX.
FIXED: use_module relies on ensure_loaded, which is now a directive.
FIXED: 64/32 bit errors in Alpha.
FIXED: SEG_SIZE is pre-defined in HP platform.
FIXED: should call Error only after leaving interrupt handler, otherwise sigsetjmp will overwrite registers.
FIXED: fill CharConversionTable with null chars.
FIXED: warning in PowerPCs.
Yap4.2.0pl17:
FIXED: more improvements to Eval.
NEW: predicate_property(X,public).
NEW: public/1 directive, handling of source was cleaned up (it used to be broken if one would switch between source and no-source).
NEW: special meta-call handling for ISO mode. Reduce amount of testing for other cases.
CLEANUP: complete cleanup of eval. No more duplicate code, no more reg and fli.
SPEEDUP: move get_spy_creep to yap_flags. This speeds up execute a bit.
NEW: strict_iso mode.
CLEANUP: InitEval.
FIXED: arithmetic should be consistent even after an error.
NEW: implement ISO exception handling for operations between floating-point numbers in Linux.
NEW: handle floating point exceptions.
CLEANUP: get rid of EQUAL_FLOATS and EQUAL_LONG_INTS as they weren't used any longer (and they were wrong anyway).
NEW: add e, I've always liked this constant better than pi.
FIXED: get a better pi.
FIXED: fix round and friends for ISO mode.
NEW: add xor (#) and sign.
FIXED: get rid of finite, change integer the limits in YAP.
FIXED: define atanh and friends for VC++ environments.
FIXED: Get PlGetChar() back in, as users may want a simple interface to the current input for their own dubious purposes.
NEW: yap_flag(discontiguous_warnings, single_var_warnings, redefine_warnings) as in SICStus. This should eventually replace style_check and no_style_check.
FIXED: do not mark or sweep environments twice. This fixes Bart's YAP GC performance bug (as mentioned in comp.lang.prolog!).
NEW: do variable shunting, not that it helps very much.
FIXED: save should only save as many registers as it needs, and the ones it does should be adjusted when restoring.
NEW: stream_select/3.
NEW: save/2.
NEW: char_conversion/2 and current_char_conversion. Add ISOGetc for this, change scanner for having two getcs (one within strings, the other elsewhere).
FIXED: was recording source for optimised clauses, not just source for module preprocessed clause.
CLEANUP: add specialised versions to PlGetc(): Sockets, EOF, Readline, and Console.
CLEANUP: got rid of PlGetChar().
CLEANUP: replaced PlPutc() by specialised versions for each type of stream: File, Console, Socket, Socket+Console, and Null.
CLEANUP: got rid of PlPutChar().
FIXED: ISO compatible mode for floor and friends.
FIXED: YAP would crash with INTEGER mod 0.
FIXED: miscellaneous error handling in eval.
FIXED: number_chars and friends should be compatible with scanner.
FIXED: stream_property should not work with aliases.
NEW: char_code/2.
FIXED: ISO mode activates fileerrors.
FIXED: avoid using atom_chars within the system.
FIXED: number_chars(X,I) and number_codes/2 with bad I should give error in ISO mode.
FIXED: make ISO abolish/1 succeed for undefined procedures.
FIXED: number_chars and atom_chars should be ISO compatible in ISO mode.
FIXED: errors in call should throw ISO errors.
FIXED: functor/3 should now have standard ISO behaviour on errors.
FIXED: assert(X) would loop.
FIXED: char_conversion/2 is now also a directive.
FIXED: ensure_loaded/1 should be directive and not a built-in.
FIXED: current_predicate/1 should not show system predicates and should be module aware.
FIXED: utilpred.s now compiles with -DEUROTRA.
FIXED: abolish/1 had several nasty bugs, especially in ISO mode.
CLEANUP: got rid of nasty config.cache in main directory.
FIXED: op/3 and set_prolog_flag/2 are directives.
Yap4.2.0pl16:
FIXED: retractall was broken.
Yap4.2.0pl15:
FIXED: in catch/3 set module to original module before handling a ball.
SPEEDUP: improve testing with DEPTH_LIMIT.
FIXED: DEPTH_LIMIT should only stop code running under depth_bound_call/2.
FIXED: bug in parse_args (fix from Stasinos Konstantopoulos <konstant@let.rug.nl>).
FIXED: copy_term/2 should now be able to copy constraints.
FIXED: faster version of copy_term/2 should now handle rational trees.
NEW: generate ps version of manual with make ps.
FIXED: disable save term optimisation for extensions, as we may not have an S ready.
CLEANUP: always use '$execute' instead of call internally.
CLEANUP: get rid of '$user_call' as it should the same as '$execute'.
NEW: separate between the standard catch, that uses the full meta-call, and a system catch, that uses $execute0 and $mod_switch and that should be only used deep within the bowels of the system.
FIXED: expanded head variables of meta_predicates should not be expanded by inner meta-calls.
FIXED: HAVE_STAT was not being generated correctly by autoconf.
NEW: timeout:time_out.
FIXED: make sure catch handlers are processed from within user.
FIXED: processing of style_check by yap_flag(language,_).
FIXED: discontiguous should now be module aware.
FIXED: preprocess calls for meta-predicates from top-level.
FIXED: simplify code that handles the fact that modules from primitives can be called from anywhere.
FIXED: $module_expansion could be called with wrong number of arguments.
FIXED: separate '$execute', the low-level mechanism for meta-call, from '$user_call', that must study meta-predicates.
FIXED: README.VC.
Yap4.2.0pl14:
FIXED: allow big flags.
FIXED: typos in yap.tex.
NEW: yap_flag(host_type,X), where X comes from configure.
NEW: more cleanups for autoconf.
FIXED: more cleanups for autoconf.
NEW: use -DBP_FREE by default for X86 machines.
FIXED: make predicate_property more SICStus Prolog compatible.
NEW: language mode now changes action over dynamic and over directives.
NEW: initial DLL support for WIN32.
FIXED: optimise arithmetic for asserted clauses.
FIXED: calling garbage collector from within a C-backtrackable built-in should also have the extra arguments to the choice-point ready.
NEW: YAP should now be able to load DLLs in WIN32.
FIXED: YAP will now stop creeping after an abort.
FIXED: meta-call within the debugger was externally visible.
FIXED: small ANSI-C compatibility thingies.
FIXED: writeq('aaa===\\''====') now outputs properly.
NEW: yap_flags(update_semantics,logical_assert) if you only want to use logical update semantics for asserted code.
NEW: yap_flags(language,{cprolog,sicstus,iso}).
FIXED: do not test for worken goals before !, it slows down execution too much.
NEW: improve the performance of ==/2.
FIXED: compile without COROUTINING.
FIXED: manual would not compile.
Yap4.2.0pl13:
FIXED: term_expansion should be called in user module.
FIXED: include new operation sderef_op when we want to know what a constrained variable is bound to.
FIXED: try_logical_pred depended on B, but B might have been cut. Use trail for the moment.
FIXED: call of project_attributes.
NEW: blackboard routines bb_get, bb_put, bb_delete, bb_update, and yap_flag(n_of_integer_keys_in_bb,INT). Includes a new file, bb.c.
NEW: yap_flag(n_of_integer_keys_in_db,INT): dynamically set the number of entries for the hash table used in looking up integer keys for the data-base.
Yap4.2.0pl12:
NEW: README.VC for VisualC++ users.
FIXED: several small changes for VisualC++.
FIXED: _WIN32 requires LOWTAGS (0x3000000 kind of address) for garbage collection to work.
FIXED: UnifyBound was not handling extensions right.
FIXED: had wrong definition for non-gcc EXTRA_CBACK_ARG.
FIXED: make Yap compile under VisualC++ 6.0 again.
FIXED: exit_yap would not exit.
Yap4.2.0pl11:
FIXED: multifile was not complaining on missing declaration.
FIXED: multifile declarations were not module aware.
CLEANUP: assert/1 and dynamic/1.
FIXED: for the nth time tried to make modules SICStus compatible :-(.
NEW: integrated latest version of YAPOR (SBA and ACOW still do not work).
Yap4.2.0pl10:
FIXED: could have a bad cut in call(X->Y).
FIXED: add ord_intersect/3 again (same as ord_intersection/3).
FIXED: save_program/2 would not set prompt correctly.
FIXED: bug in stack_shifter after gc (was shifting global pointers).
FIXED: save/1 was broken with coroutining.
FIXED: use_module/2 should handle lists of files.
FIXED: COROUTINING depended on DEBUG code.
Yap4.2.0pl9:
FIXED: list_to_assoc/2.
FIXED: ANALYST should compile again.
FIXED: ensure_loaded and use_module are not directives!
FIXED: bug in cleaning up for logical update semantics.
FIXED: cuts will now call suspended goals.
FIXED: debugger should now step through meta-predicates correctly.
FIXED: trust_logical_pred did not release trail entry correctly.
FIXED: recordedp might be create a new key in a different mode from the one used to create the dynamic procedure.
FIXED: don't go through $undefp for dynamic procedures.
FIXED: bugs in asserting dynamic procedures from compiled clauses.
FIXED: buglets with multifile/1.
FIXED: do not open directories except as binary files.
NEW: library random.
NEW: assoc now has ord_list_to_assoc/2 and get_assoc/5.
NEW: compatibility module terms for term_utils.
NEW: ordsets now has ord_union/4 and ord_del_element/3.
NEW: add public/1 directive but currently this does nothing.
FIXED: be more precise about which files you have consulted.
FIXED: use_module/2 should not handle lists of files.
FIXED: compare would stop whenever it would find two numbers, even if they were equal.
NEW: attributed variables.
FIXED: coroutining would break \=/2.
NEW: ord_add_element/1 in ordsets.
NEW: empty_assoc/1 in assoc_lists.
CLEANUP: compile under lcc4.1/Linux.
FIXED: storing compressed rational trees on DB was buggy.
FIXED: $unknown(_:_) should not give an error.
FIXED: ord_intersect/3 now is ord_intersection/3.
FIXED: recursive do_goal would corrupt coroutining information.
FIXED: handle possible overflows in quoted strings.
CLEANUP: move .pl library files to .yap.
CLEANUP: get rid of unused SusRecTop and SusRecBase.
CLEANUP: move HeapUsed, HeapMax, and HeapTop to Heap.
FIXED: add MMAP_ADDR for WIN32.
Yap4.2.0pl8:
NEW: user:goal_expansion/3.
SPEEDUP: use separate table for integer keys to data base. Table size can be configured with -DMAX_DB_INT_KEYS=.
SPEEDUP: increase the size of HashTable, which was ridiculously small.
CLEANUP: allocate heap_regs as heap start.
SPEEDUP: avoid calculation for compile-time keys.
NEW: get_float.
NEW: change the way functors of processed.
CLEANUP: got rid of disgusting GeneralRef type, it has been replaced by Integer.
FIXED: unknown_error should not complain if print is called with undefined portray.
FIXED: delay cuts that go through embeddeded c-calls. This requires two extra registers, DelayedB and TopB.
CLEANUP: LockPred wasn't being used any longer.
FIXED: fact for true was not being asserted.
NEW: now long ints and floats are tagged.
FIXED: array/2 was a safe predicate that could call gc().
FIXED: growstack in cclause should also call gc().
Yap4.2.0pl7:
FIXED: 8 bit characters would be mangled by char->Int conversion in StringToList.
NEW: Garbage collection should now work for a total space of 1GB on second quadrant (use low_tags).
FIXED: ExtendWorkSpace would not always guarantee aligned size.
NEW: call_with_args/n, meta-call with variable arity (up to 10).
FIXED: array/2 overflow had not been fixed properly.
FIXED: sort and friends would not handle overflow properly.
FIXED: improve manual include small bugs, compatibility stuff.
SPEEDUP: replace opcode(_index_pred) with INDEX_OPCODE.
SPEEDUP: replace opcode(_undef_p) with UNDEF_OPCODE.
FIXED: only optimise common_expressions up to level 5.
Yap4.2.0pl6:
FIXED: coroutining had been broken when initialisation was reordered.
ISO: predicate_property of static predicates now returns static, instead of compiled.
FIXED: if format/2 ~s would complain for empty strings.
FIXED: bug with too large arrays.
NEW: term_hash/2 and term_hash/4.
FIXED: allow modules in bodies of DCGs.
FIXED: get rid of modules in head before they hit DCGs.
FIXED: current_predicate with modules.
FIXED: $undefined/1 should never collapse.
FIXED: listing would collapse because of :/2. :/2 is not an undefined procedure now.
FIXED: in saved states replace $* by "$@".
NEW: user:unknown_predicate_handler/3 from SICStus.
FIXED: declare findall/4 a meta_predicate.
FIXED: switch third and fourth argument to findall/4 to obtain SICStus compatibility.
FIXED: unknown/2 should know about modules.
FIXED: speedup handling of unknown predicates in meta-calls.
FIXED: speedup depth_bound_call(A,D) by using $execute.
FIXED: add chapter on modules to manual.
FIXED: meta_predicates from same module were not being expanded.
FIXED: modules use current module for meta predicate.
REVERSE: default meta_predicates back to user.
Yap4.2.0pl5:
FIXED: meta_predicate should be a directive, not a standard predicate.
FIXED: all default meta_predicates should belong to user, not primitives.
FIXED: give errors when not finding libraries.
FIXED: load_module/1 and load_module/2 are now directives.
FIXED: load_module/2 would not accept libraries and had bad error handling.
FIXED: catch/3 did not have a meta_predicate declaration.
FIXED: meta predicates were not being expanded correctly.
FIXED: saved state script was not passing arguments to Yap.
FIXED: go around gcc bug in current_op for hpux machines.
FIXED: top level abort would crash in hp machines (TR was overwritten).
FIXED: error messages for op/3.
FIXED: ord_member/2 in ordsets.
Yap4.2.0pl4:
NEW: the evil recordaifnot/3 and recordzifnot/3 are now in the manual.
FIXED: include ord_union/2 and ord_member/2 in ordsets.
FIXED: complain about _:G.
FIXED: allow modules in heads for assert and friends.
FIXED: allow modules in multifile and dynamic declarations.
FIXED: send error messages in modules.yap to user_error.
FIXED: get rid of error message in eraseall.
NEW: term_variables/2.
FIXED: directives had broken ensure_loaded/1 for use_module/1.
NEW: small performance improvements in unification routines (UnifyGlobalCells).
Yap4.2.0pl3:
FIXED: small performance improvements in unification routines.
FIXED: logical_update semantics were broken in pl2.
FIXED: findall and friends were broken in pl2.
FIXED: bind_global within unify_struct.
Yap4.2.0pl2:
NEW: static arrays of DB terms.
NEW: close_static_array and resize_static_array now work over mmapped files.
FIXED: rename delete_static_array to close_static_array.
FIXED: improve the manual a little bit. Add info in README to Manual.
FIXED: support for ISO-style atom_chars/2 and number_chars/2.
NEW: ISO include/1 directive.
ISO: ensure_loaded/1 is now a directive (and it cannot be called as a procedure).
NEW: discontiguous/1 directive.
NEW: process multifile/1 as a directive.
FIXED: give warning if multifile procedures are used before multifile declaration.
FIXED: multifile was very severy broken.
FIXED: initialize/1 now follows ANSI semantics. We have prolog_initialize/1 for SICStus Prolog code.
FIXED: don't explode if the compiler finds too many variables or if there is not enough code space to store our code.
NEW: ISO quoted character sequences (note that this means that '\+' will break now).
FIXED: remove limit on size of strings and quoted atoms.
FIXED: [ ] is now parsed as [], like other Prologs do.
FIXED: read-in clauses predicated by modules (mod:clause).
FIXED: gcc/HP-UX would generate incorrect code for PredForCode. Use an extra temporary (at) and the probably goes away.
NEW: add "make install-info", "make info" and "make html".
FIXED: create a README file mentioning the license, get rid of the INSTALL file for now.
FIXED: don't shadow S, CP, HB in hppa. They have their own registers.
FIXED: change x86 back to base address 0x10000000 and tags back to opstags for Linux.
Yap4.2.0pl1:
FIXED: works(?) in HP/UX.
NEW: update_array for dynamic arrays.
FIXED: works in FreeBSD.
FIXED: improvements and additions to configuration scripts.
NEW: port to Visual C++ (_MSC_VER).
NEW: major improvements and bug fixes to YAPOR.
CLEANUP: _REG to _.
NEW: arrays of bytes and of unsigned bytes.
FIXED: worked a bit on manual.
NEW: resize_static_array/3.
NEW: delete_static_array/1.
FIXED: ACOW in YAPOR.
FIXED: Error after Error would not notice there was no place to cut back to.
FIXED: SBA in YAPOR.
NEW: version/0 and version/1. Deleted yap_version/1.
NEW: is_mutable/1.
FIXED: recent bug in dif.
SYNCH: with Ricardo Rocha's optyap. SBA is broken.
FIXED: reverse_opcode_lookup table.
NEW: YAP as a library:
New functions provide an interface for initialising and calling Yap from external environments. Note that Yap is still a big chunk.
Restoring embedded C-functions is now performed by restore_heap together with InitStaff.
The code to restore a clause has been updated to use yamop and GONEXT. The same code does both indices and clauses.
All macros that adjust pointers are now functions, and type-check their arguments.
All functions that restore a stack (from restore, growheap and growlocal) have now been merged in a general function in grow.c. This decreases efficiency slightly, but should improve maintainability.
InitStaff() now has an argument saying whether we are calling from boot or from restore. Note that most Prolog executions will actually call InitStaff() twice.
initialisation code in yap.c was simplified. Several functions and variables were moved out to init.c.
routines that start new goals were moved out of cdmgr.c to exec.c.
FIXED: all clauses should terminate with _Ystop, but we just did emit_op instead of a_e.
NEW: save_program/2.
NEW: save_program/1. Default startup is now through save_program.
FIXED: break should not remove choice-points.
FIXED: allow (call(X), X) to possibly succeed. It is unclear whether that conforms to the ISO standard, but there is the excuse it is SICStus compatible.
FIXED: $undefp would call a bad $user_call.
FIXED: bad calculations for walltime.
FIXED: bug with depth_bound_call for not and \+.
FIXED: execute_goal would not recover registers correctly.
NEW: SICStus compatibility predicates including incore/1, callable/1, and simple/1.
NEW: add arity as an extra argument to _struct functions.
FIXED: uninitialised profiling counters.
FIXED: OPTYap had broken unknown=error.
FIXED: small bug in assembling index code.
FIXED: growheap would not fix trail properly.
NEW: logical update semantics for internal data-base.
CLEANUP: indexed code also has a tag.
FIXED: putenv/2 must allocate static memory.
FIXED: remove duplicate clauses in environ/2.
Yap4.2.0:
NEW: YAP4.2.0 is out.
REMOVED: file RELEASE.NOTES.
Changes in YAP4.1
Yap4.1.19:
FIXED: phrase/3 had bad call to $t_body.
FIXED: warnings on alpha.
FIXED: make YAP compile on SGI's cc.
ISO-YAP: accept 0o notation for octal integers.
FIXED: rcdifnot would try to unify with NULL return pointer.
FIXED: when/3 did not link Done variables.
FIXED: bad copying of arguments in co-routining.
NEW: first cut at SBA or-parallel execution.
FIXED: YAP version is now in Makefile.
NEW: alarm/3 (see manual).
FIXED: errno handling is in io.h.
Yap4.1.18:
FIXED: debugger would not work after change to call.
FIXED: do not trace !G within debugger.
Yap4.1.17:
FIXED: error handler for floats was too enthusiastic in format/3.
FIXED: accept list of dynamic predicates.
NEW: merge new version of Ricardo Rocha's OPTYAP including support for tabulation.
NEW: improve performance of call.
FIXED: trail overflow in heap gc (store_ref_in_dbtable).
FIXED: close fd if mmap fails.
FIXED: IsPrimitiveTerm would succeed on suspended variables.
FIXED: small bug in socket_select.
FIXED: garbage collector would follow old values of multi-assignment variables even if they were not heap pointers.
FIXED: garbage collector was following list of suspended goals as if a variable.
FIXED: call/1 was not importing modules correctly.
NEW: A library. Right now it just consists of several files copied from the Edinburg Prolog library, with little or no change. To use it, you must do "make install" or have LIBDIR in the Makefile set to the YAP source directory.
FIXED: garbage in debugger.
FIXED: fix writing \+ (a,b) properly.
NEW: get rid of addresses for the unify() routines. Unify now receives values, as it should, instead of addresses.
NEW: get rid of the representant stuff for coroutining. Instead of trying to find out if we bound an external variable, from now on we must guarantee that we pass a non-dereferenced external variable (e.g. argument) to the unification routine, otherwise delayed variables may not wake up.
FIXED: get rid of bind_variable.
FIXED: exit_yap was not working (halt).
FIXED: write version number when booting from a saved state.
Yap4.1.16:
FIXED: don't crash if you're not booting from the standard file (SavedInfo should not assume LookupAtom works).
FIXED: prompt (again).
FIXED: debugging dynamic or source mode procedures would ignore depth limits.
FIXED: -DBP_FREE could lose program counter, if changed by ErCl or ErDBE.
FIXED: global registers could be smashed by the compiler within error handlers (SGI).
FIXED: fix a bug on and thus enable garbage collection of code space.
FIXED: bug in cut_by_y.
FIXED: be less optimistic about when to expand the trail after a sigsegv.
Yap4.1.15:
FIXED: disable garbage collection of code space.
FIXED: growstack did not know OldH.
FIXED: be conservative about new variables in branches (active_branch).
NEW: change code to Artistic license.
FIXED: include errno.h in socket code.
FIXED: strcpy of NULL pointers in sysbits.c.
FIXED: writing \+ (a,b) would not output middle space, confusing the parser.
NEW: initial support for the SBA model (parallelism).
FIXED: make the system more robust when it can't get more memory.
FIXED: recorded with unbounded key was crashing.
CLEANUP: use derefa when we know the possible address for a variable. This avoids reading a memory cell twice.
CLEANUP: make sockets a special stream, make actual reading and writing on sockets work, unify all close operations on sockets, update iopreds to take special care of sockets. Still not working: ungetc on sockets, eof has not been tested.
CLEANUP: conditions on c-interface.
FIXED: growheap could be called with wrong local stack pointer.
NEW: always_prompt_user/0, for those who hide behind pipes and sockets.
FIXED: bug in frozen/2 and friends.
CLEANUP: use Prolog terms in coroutining, avoid NULL pointers.
FIXED: save/restore was breaking corouting.
FIXED: readline does not work under parallel execution.
CLEANUP: cleanup some constructs so that YAP will compile under lcc again.
FIXED: incorrect detection of overflows in index.c.
Yap4.1.14:
FIXED: texi2dvi failed on the manual because of incorrect placement of @*.
FIXED: RECOVER_MACHINE_REGS for MIPS in Regs.h had somehow lost an E!
FIXED: expand stacks if effectiveness of garbage collection is below 20%.
FIXED: YAP was not checking for excessive number of labels while assembling.
FIXED: get rid of no in sequential init.
FIXED: bug in checking modules for abolish and friends.
FIXED: with readline, prompt even if stderr is not a tty. Also make sure prompt goes to stderr, not to stdout.
NEW: SICStus Prolog compatible socket interface (see manual, still experimental).
Yap4.1.13:
FIXED: Cygnus getrusage does not work under WIN95.
FIXED: extraneous push in compiling bvmap for either.
FIXED: long printf in heapgc.c.
FIXED: extraneous printf in dbase.c.
NEW: sync until leftmost in YAPOR.
NEW: sequential predicates in YAPOR.
FIXED: YAPOR in OPTYap now runs queens.
Yap4.1.12:
FIXED: make sure that when you backtrack to an erased clause you don't get caught by dangling pointers.
FIXED: check args to arithmetic comparisons are not free.
FIXED: make sure you only mark an env var as initialised if the instruction refers it for the first time.
FIXED: Error handler depended on pointer to freed code.
FIXED: always fully gc clean the last environment.
FIXED: new dbref gc cleaner could mess with dbqueues.
FIXED: test if YAP can allocate more memory.
FIXED: YAP now makes procedures dynamic after first assert.
FIXED: because of disjunctions, variables in clauses do not always grow linearly. Change compiler to informe gc of actual live variables in an environment at any point, not including variables outside the current branch (even if at ancestor's branches). Take special care with optimised if-then-elses.
NEW: speedup compact_heap.
FIXED: CheckDBOverflow in MkDBTerm would not reset variables, as it should.
FIXED: recover HB in gc.
NEW: Integer macros for integers that may overflow.
NEW: jump across unmarked cells in downward pass.
NEW: simplify marking longints and doubles.
NEW: small performance improvement in meta-call.
FIXED: make toggle preds robust to meta-calls.
FIXED: bad error handling in evaluable predicates.
NEW: upgrade YAPOR to most recent OPTYAP.
CLEANUP: use the RESET_VARIABLE macro to reset a variable.
FIXED: ITERATIVE_DEEPENING option is now called DEPTH_LIMIT.
NEW: simplified autoconf script and Makefile.
FIXED: YAPOR now compiles again and reaches top-level.
CLEANUP: make assembly built-ins accessible as standard predicates. This makes meta-calls somewhat less bulky.
FIXED: YAP could crash while reading in binary files. The problem was that the hash function could return an offset < 0.
NEW: in GC check if db terms are in use, and if not reset counters. Further reclaim immediately space for terms erased and not in use (current implementation uses an inefficient unbalanced binary tree).
NEW: in GC untrail unmarked bindings and reset the pointers.
Yap4.1.11:
NEW: after several requests, added assert_static and friends.
FIXED: bug in adding spaces while writing X is $VAR(2)+...
NEW: stream aliases.
FIXED: ^C-a now works on PUSH_REGS (eg, X86).
FIXED: catch could remove other valid catches.
FIXED: several cases of non-compatible ISO error handling.
FIXED: current_input and current_output would fail for instantiated arguments.
FIXED: writing $VAR(X) terms could core dump miserably.
FIXED: initialisation was not protected by a catch/3.
FIXED: system would exit after trying to compile Numeric or DBRef goal.
NEW: improve performance of arithmetic comparisons by inserting them as ops in abstract machine.
FIXED: meta-call would get lost in call((X,Y)). Callable checking is now ISO (almost).
FIXED: recursive compare was not catching term_exts on second argument to comparison.
FIXED: compilation warning on printing Int in alpha.
FIXED: gc would mark terms accessible only from the trail. Change so that these pointers are only relocated, and remove dangling pointers from the trail.
Yap4.1.10:
FIXED: get rid of ExecuteProlog as used by print/1, execute_goal can do the same.
FIXED: execute_goal should survive garbage collection and/or stack shifting.
FIXED: $undefined succeeded for predicates written in assembly.
FIXED: provide 16 registers (ARG1 to ARG16).
FIXED: some changes to make YAP work without ALIGN_LONGS.
FIXED: old timing bug.
FIXED: bug in generating cut.
FIXED: don't crash if have several errors on the same expression.
FIXED: use strerror instead of sys_errlist.
FIXED: make system more resilient to small ints.
FIXED: system should be more resilient when allocating large chunks of memory.
FIXED: X is cputime should have no rounding problems.
FIXED: silently fail on wrong array accesses.
FIXED: true was not seen as built-in.
FIXED: DEPTH was not always saved correctly in execute_prolog.
Yap4.1.9:
FIXED: bug in scanner.
FIXED: bug in allocating large chunks of memory under NT, and change to allow YAP to at least run under WIN95/98 (memory allocation and timing are not working yet for WIN98).
Yap4.1.8:
FIXED: random would only work in Linux.
FIXED: better names for array_element/3 and update_array/3.
FIXED: array access now does boundary checking, and fails if you try to access an undefined reference.
NEW: profiling now counts calls to non-profiled predicates, included system built-ins.
FIXED: profiling now does not need to disable indexing.
FIXED: predicate_property was returning just the name for unbound calls.
NEW: putenv/2. If you want to start shell scripts.
NEW: YAP now supports 8 bits char sets. The default is iso-latin.
NEW: call_residue/2 now available.
FIXED: serious bug in can_unify: HB was not set to H. Should be no problem with B.
FIXED: trim_trail is not compatible with Multi-Assignment variables.
FIXED: under a few cases code could have problems if some was using a dynamic clause and retracted it.
NEW: improve absmi for coroutining.
FIXED: bug in statistics(runtime,T).
NEW: statics(walltime,T) and internal walltime() function.
FIXED: changed code that assumed dir_separator could only be a single character. Some MS-DOS systems accept both slash and backslash.
FIXED: for compatibility with other Prologs, YAP now changes directory to the directory containing the file it is consulting. Don't need to create an init.yap any longer.
NEW: getcwd/1.
FIXED: disallow integer as argument to cd/1 and friends.
FIXED: rand should depend on MAX_RAND; document srandom.
NEW: environ now allows access to a process' environment.
Yap4.1.7:
FIXED: bug in read_term/singletons. I incorrectly assumed variables were being allocated in order.
FIXED: too much space was being allocated for 64 bit architectures.
FIXED: error handling in data base could collapse.
FIXED: ASP for growheap could be wrong.
FIXED: growheap and growstack forgot about dangling pointers in the trail.
FIXED: increase margins as garbage collections happens.
FIXED: make recorded and friends restartable for the case there is no space left to copy the new term.
FIXED: make memory allocation routine more generic, try to use temporary files when /dev/zero is not available, control whether we are fetching the right addresses, and close open mmaped stream.
FIXED: make sure we always have an error handler in the debugger.
FIXED: GC should now work with named dynamic arrays and array extensions. Access to named dynamic arrays now goes through the trail.
FIXED: make arg/3 silently fail on negative or 0 first arguments. Breaks the ISO standard, but seems to be compatible with other Prologs.
FIXED: dequeue could leave dangling pointers to the data-base.
FIXED: bad error handling in arithmetic built-ins.
FIXED: absolute_file_name/2 was buggy.
NEW: extend C-interface to allow calling back Prolog.
FIXED: moved to version 98.
FIXED: variable ppc was causing trouble with Rhapsody.
FIXED: GC should now work with coroutining.
FIXED: coroutining had bug with reference chains.
FIXED: error handler called unexisting procedure $close/2.
FIXED: small bug in unknown/2.
CLEANUP: improve meta-call performance by avoiding unnecessary choice-points.
FIXED: assert and source mode are now aware that modules call meta-calls.
FIXED: libraries should be checked for existence before checking for the files themselves.
NEW: dynamic loader now works in Linux/Alpha and in Digital Unix/Alpha! Fixed bugs where YAP would corrupt global variables allocated by external functions.
FIXED: BP_FREE didn't do callee save for PREG, possibly corrupting the caller. Core dumped print/1 on X86.
CLEANUP: separate error handling into separate files.
FIXED: RATIONAL_TREES should now work in all built-ins.
FIXED: make sure the GC does not follow invalid trail entries.
Yap4.1.6:
NEW: execute_goal(Goal) function allows calling Prolog from C. Still under testing, and not yet officially in the interface. Note that execute_goal will destroy all X arguments, and that it only keeps the first solution (it performs an implicit cut).
FIXED: complaints while compiling YAP in WIN/NT platform.
FIXED: debugger got confused when quasi-skipping through inline builtins.
FIXED: DEPTH_BOUND_CALL was not restoring depth for retry_c.
NEW: compilation flag LOW_LEVEL_TRACER, if this flag is defined, enables detailing execution. Use start_low_level_trace and stop_level_trace, or T from interrupt to access this functionality.
CLEANUP: overflows are now processed within the emulator, not back in the caller.
FIXED: memory allocation during boot could crash returning NULL pointer, system would then crash.
ISO-YAP: many new predicates, major rewrite of manual.
FIXED: debugger should now understand better immediate update semantics (eg, dynamic predicates).
ISO-YAP: all error handling is now ISO style.
FIXED: could not write MIN_INT.
ISO-YAP: add Z is float_integer_part(X).
ISO-YAP: add Z is float_fractional_part(X).
ISO-YAP: arg/3 now generates errors.
ISO-YAP: abolish/1 now does errors the YAP way, and only abolishes dynamic procedures. Use abolish/2 to clear static procedures.
Break boot.yap file into smaller files.
YAP now compiles well under Linux/Alpha.
X now is called XREGS to avoid problems with Linux/Alpha includes.
Abort now jumps to before the absmi emulator and then does a long cut. This should simplify YapOr, and allow for restricting toplevels.
Yap4.1.5:
FIXED: MAX_INT on Tags_LowTag was wrong.
NEW: first cut of profiling. Right now, Currently, for static predicates, profiling disables indexing. That should be fixed in the next version.
NEW: source mode debugging is active. Compile with ":- source" and debug/step through all your builtins!
FIXED: major bug in cut_by, since early 4.1 :-(. Affects debugging.
NEW: fetch first op from pred before jumping.
NEW: use SREG to cache A1 for switches and tries.
FIXED: warning messages for SGI CC.
FIXED: warning messages for alphas.
NEW: optimise switch_on_list for the list case.
NEW: WAM registers optimised for MIPS.
FIXED: shadow CP and HB on sparcs. They need every bit of performance we can get them.
FIXED: famous curprio bug in parser, from now on parser backtracks cleanly.
NEW: Got rid of SREG for call-type instructions.
NEW: CPREG in absmi for Suns.
CLEANUP: got rid of obsolete absmi regs.
FIXED: small bug in the Prolog code for unknown/2.
NEW: Small speed improvements for complex absmi instructions.
Yap4.1.4:
NEW: read_term/3 and new syntax_error option to yap_flag.
FIXED: got rid of fast predicates from compiler.
NEW: Makefile now generates a bootable save state as YAP default.
NEW: started working on manual for 4.1. Fixed info format so that it will generate info files. Add several missing built-ins to manual.
NEW: bootable saved states with arguments, accessible though unix(argv(L)).
NEW: optimised code for tests (var/1 and friends) and arithmetic (is/2).
NEW: much faster code for /\, \/, >> and <<.
FIXED: debugger does not go into recorded/3 and friends.
Yap4.1.3:
NEW: unix(argv(X)).
FIXED: abs complains if int != Int.
Yap4.1.2:
NEW: saved states now search for $BINDIR/yap.exe to boot.
FIXED: bugs with handling errors.
FIXED: got rid of $recorded/3 for now.
NEW: generate specialised code for OR, AND, SHIFT LEFT, and SHIFT RIGHT.
FIXED: statistics(runtime,_) now does not count GC time, as in other Prologs. statistics(cputime,_) counts everything.
FIXED: time is returned as an integer, not as a float.
Yap4.1.1:
CLEANUP: get rid of warnings under Cygnus GCC.
FIXED: Use Windows memory allocation routine, now YAP can recover from saved states for smaller stacks.
CLEANUP: don't use the UNIX define. Use instead configure to say exactly which UNIX feature you need.
FIXED: compiler would not handle correctly unsafe variable from disjunctions.
FIXED: force indexing to ask for more stack if stack runs out. This should help if you have really many clauses.
CLEANUP: clean all error code from C to use the new Error() routine.
NEW: use throw/1 to send system errors.
NEW: catch/3 and throw/1.
NEW: load_foreign_file/3 for SunOS4 (tested) and AIX (compiles).
Yap4.1.0:
NEW: memory mapped arrays.
NEW: make garbage collector expand stack quickly to avoid excessive number of GCs.
NEW: do the same for heap overflow detector.
CLEANUP: cleanup readline code for not using strcpy, strlen and friends. Current code was broken for very large input strings.
NEW: sort and friends implemented in C.
NEW: Removed 256B limitation on atom size while parsing.
CLEANUP: Change AllocCodeSpace to return NULL on code failure, make cclause() call growstack on stack failure.
NEW: Static Arrays!
Split previous support for arrays and co-routines. We now have TERM_EXTENSIONS to control extensions to unification. Tried to redesign the extensions so that they would be modular, the file TermExt.h.m4 shows how to implement an extension.
Got rid of lock_pred and friends. Usage of static predicates is now detected when compilation starts, or when assert is used.
Got rid of hash table in optimise_ce, it wasn't working.
Current predicate access:
add new argument to call, so that call can recognise which predicate it is working on.
add extra argument to try and frieds, so that they can directly access a predicate.
Internal cleanup: change cdmgr.c and friends so that we now move in a clause through the Clause structure. Get rid of ptrs, except for save.c.
Changes to immediate update semantics implementation:
Entries are now removed from the chain immediately, instead of only when they are physically deleted.
Each entry has an age (positive if entry is from recordz, negative if from recorda).
When we backtrack to deleted entries, we search the property list for entries with younger ages.
When we erase a clause, we don't place a fail in the clause. Instead, we remove the clause from the chain immediately.
NEW: MIPS architecture support in Regs.h and absmi.c.
X86 Speedups:
Force opcode prefetching for simple instructions in X86.
Cache Y for control instructions in X86.
Optimise Bind() for X86 by jumping only if we need to trail for cases close to the end of the instruction. This does not seem to improve performance for X86 machines.
Cache SREG usage.
Cleanup:
Move AuxSp and AuxTop to REGS.
Use Aux for emulator PDL.
Cleanup: compiler.h. Use enum for compiler ops.
NEW: Indexing:
simplify GC and ORP: instructions do not store intermediate values in global.
unnecessary instructions purged.
new try_tail like trail_head, but jumps to atomic code.
switch on types insts after backtracking now look like retry and have correct clause information for ORP.
switch_on_type talks to switch_on_func through S, and to switch on cons through A[0]. I_R disappeared.
yap-6.2.2/config.guess 000644 000765 000024 00000131054 11457004724 014575 0 ustar 00vsc staff 000000 000000 #! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
timestamp='2009-06-10'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner .
# Please send patches to . Submit a context
# diff and a properly formatted ChangeLog entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit build system type.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
Output the configuration name of the system \`$me' is run on.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help" >&2
exit 1 ;;
* )
break ;;
esac
done
if test $# != 0; then
echo "$me: too many arguments$help" >&2
exit 1
fi
trap 'exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > $dummy.c ;
for c in cc gcc c89 c99 ; do
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac ; set_cc_for_build= ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
sh5el) machine=sh5le-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE_ARCH}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ELF__
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
os=netbsd
else
os=netbsdelf
fi
;;
*)
os=netbsd
;;
esac
# The OS release
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case "${UNAME_VERSION}" in
Debian*)
release='-gnu'
;;
*)
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
exit ;;
*:ekkoBSD:*:*)
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
exit ;;
*:SolidBSD:*:*)
echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
exit ;;
macppc:MirBSD:*:*)
echo powerpc-unknown-mirbsd${UNAME_RELEASE}
exit ;;
*:MirBSD:*:*)
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
# OSF/1 and Tru64 systems produced since 1995. I hope that
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
case "$ALPHA_CPU_TYPE" in
"EV4 (21064)")
UNAME_MACHINE="alpha" ;;
"EV4.5 (21064)")
UNAME_MACHINE="alpha" ;;
"LCA4 (21066/21068)")
UNAME_MACHINE="alpha" ;;
"EV5 (21164)")
UNAME_MACHINE="alphaev5" ;;
"EV5.6 (21164A)")
UNAME_MACHINE="alphaev56" ;;
"EV5.6 (21164PC)")
UNAME_MACHINE="alphapca56" ;;
"EV5.7 (21164PC)")
UNAME_MACHINE="alphapca57" ;;
"EV6 (21264)")
UNAME_MACHINE="alphaev6" ;;
"EV6.7 (21264A)")
UNAME_MACHINE="alphaev67" ;;
"EV6.8CB (21264C)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8AL (21264B)")
UNAME_MACHINE="alphaev68" ;;
"EV6.8CX (21264D)")
UNAME_MACHINE="alphaev68" ;;
"EV6.9A (21264/EV69A)")
UNAME_MACHINE="alphaev69" ;;
"EV7 (21364)")
UNAME_MACHINE="alphaev7" ;;
"EV7.9 (21364A)")
UNAME_MACHINE="alphaev79" ;;
esac
# A Pn.n version is a patched version.
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
# of the specific Alpha model?
echo alpha-pc-interix
exit ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit ;;
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
exit ;;
*:OS/390:*:*)
echo i370-ibm-openedition
exit ;;
*:z/VM:*:*)
echo s390-ibm-zvmoe
exit ;;
*:OS400:*:*)
echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
arm:riscos:*:*|arm:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit ;;
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit ;;
DRS?6000:unix:4.0:6*)
echo sparc-icl-nx6
exit ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7; exit ;;
esac ;;
s390x:SunOS:*:*)
echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
eval $set_cc_for_build
SUN_ARCH="i386"
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH="x86_64"
fi
fi
echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
exit ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
;;
sun4)
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
exit ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE}
exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE}
exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit ;;
m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE}
exit ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
exit ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
#include /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c &&
dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`$dummy $dummyarg` &&
{ echo "$SYSTEM_NAME"; exit; }
echo mips-mips-riscos${UNAME_RELEASE}
exit ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
exit ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
exit ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
exit ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
[ ${TARGET_BINARY_INTERFACE}x = x ]
then
echo m88k-dg-dgux${UNAME_RELEASE}
else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
fi
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
exit ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
exit ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
exit ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
echo i386-ibm-aix
exit ;;
ia64:AIX:*:*)
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
exit ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
then
echo "$SYSTEM_NAME"
else
echo rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
exit ;;
*:AIX:*:[456])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
exit ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
exit ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
exit ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit ;;
9000/[34678]??:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include
#include
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ ${HP_ARCH} = "hppa2.0w" ]
then
eval $set_cc_for_build
# hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
# 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
# generating 64-bit code. GNU and HP use different nomenclature:
#
# $ CC_FOR_BUILD=cc ./config.guess
# => hppa2.0w-hp-hpux11.23
# $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
grep -q __LP64__
then
HP_ARCH="hppa2.0w"
else
HP_ARCH="hppa64"
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit ;;
ia64:HP-UX:*:*)
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ia64-hp-hpux${HPUX_REV}
exit ;;
3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
int
main ()
{
long cpu = sysconf (_SC_CPU_VERSION);
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
results, however. */
if (CPU_IS_PA_RISC (cpu))
{
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
default: puts ("hppa-hitachi-hiuxwe2"); break;
}
}
else if (CPU_IS_HP_MC68K (cpu))
puts ("m68k-hitachi-hiuxwe2");
else puts ("unknown-hitachi-hiuxwe2");
exit (0);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
echo unknown-hitachi-hiuxwe2
exit ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
exit ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
echo hppa1.0-hp-mpeix
exit ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit ;;
i*86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
exit ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
*:UNICOS/mp:*:*)
echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:BSD/OS:*:*)
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
case ${UNAME_MACHINE} in
pc98)
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
amd64)
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac
exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
exit ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
*:Interix*:[3456]*)
case ${UNAME_MACHINE} in
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
EM64T | authenticamd | genuineintel)
echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
IA64)
echo ia64-unknown-interix${UNAME_RELEASE}
exit ;;
esac ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit ;;
8664:Windows_NT:*)
echo x86_64-pc-mks
exit ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
echo i586-pc-interix
exit ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
exit ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
echo x86_64-unknown-cygwin
exit ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
exit ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
*:GNU:*:*)
# the GNU system
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
exit ;;
crisv32:Linux:*:*)
echo crisv32-axis-linux-gnu
exit ;;
frv:Linux:*:*)
echo frv-unknown-linux-gnu
exit ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
m32r*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
mips:Linux:*:* | mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef ${UNAME_MACHINE}
#undef ${UNAME_MACHINE}el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=${UNAME_MACHINE}el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=${UNAME_MACHINE}
#else
CPU=
#endif
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^CPU/{
s: ::g
p
}'`"
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
exit ;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
exit ;;
ppc64:Linux:*:*)
echo powerpc64-unknown-linux-gnu
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) echo hppa1.1-unknown-linux-gnu ;;
PA8*) echo hppa2.0-unknown-linux-gnu ;;
*) echo hppa-unknown-linux-gnu ;;
esac
exit ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
echo hppa64-unknown-linux-gnu
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
exit ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
# Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
s/.*supported targets: *//
s/ .*//
p'`
case "$ld_supported_targets" in
elf32-i386)
TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
;;
esac
# Determine whether the default compiler is a.out or elf
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
#ifdef __dietlibc__
LIBC=dietlibc
#endif
EOF
eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
/^LIBC/{
s: ::g
p
}'`"
test x"${LIBC}" != x && {
echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
exit
}
test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
echo i386-sequent-sysv4
exit ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
exit ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit ;;
i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable
exit ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
fi
exit ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
exit ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configury will decide that
# this is a cross-build.
echo i586-pc-msdosdjgpp
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
paragon:*:*:*)
echo i860-intel-osf1
exit ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
fi
exit ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
exit ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit ;;
M68*:*:R3V[5678]*:*)
test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; }
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit ;;
RM*:ReliantUNIX-*:*:*)
echo mips-sni-sysv4
exit ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
echo ${UNAME_MACHINE}-sni-sysv4
else
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes .
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
exit ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit ;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
echo ${UNAME_MACHINE}-stratus-vos
exit ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
exit ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit ;;
news*:NEWS-OS:6*:*)
echo mips-sony-newsos6
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
exit ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
exit ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit ;;
SX-7:SUPER-UX:*:*)
echo sx7-nec-superux${UNAME_RELEASE}
exit ;;
SX-8:SUPER-UX:*:*)
echo sx8-nec-superux${UNAME_RELEASE}
exit ;;
SX-8R:SUPER-UX:*:*)
echo sx8r-nec-superux${UNAME_RELEASE}
exit ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit ;;
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
unknown) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
exit ;;
BS2000:POSIX*:*:*)
echo bs2000-siemens-sysv
exit ;;
DS/*:UNIX_System_V:*:*)
echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
exit ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
if test "$cputype" = "386"; then
UNAME_MACHINE=i386
else
UNAME_MACHINE="$cputype"
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit ;;
*:TENEX:*:*)
echo pdp10-unknown-tenex
exit ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
echo pdp10-dec-tops20
exit ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
echo pdp10-xkl-tops20
exit ;;
*:TOPS-20:*:*)
echo pdp10-unknown-tops20
exit ;;
*:ITS:*:*)
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
exit ;;
*:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
V*) echo vax-dec-vms ; exit ;;
esac ;;
*:XENIX:*:SysV)
echo i386-pc-xenix
exit ;;
i*86:skyos:*:*)
echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
exit ;;
i*86:rdos:*:*)
echo ${UNAME_MACHINE}-pc-rdos
exit ;;
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <
# include
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
I don't know.... */
printf ("mips-sony-bsd\n"); exit (0);
#else
#include
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
printf ("arm-acorn-riscix\n"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
printf ("m68k-hp-bsd\n"); exit (0);
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
if (version < 4)
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
else
printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
printf ("ns32k-encore-mach\n"); exit (0);
#else
printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif
#if defined (__386BSD__)
printf ("i386-pc-bsd\n"); exit (0);
#endif
#if defined (sequent)
#if defined (i386)
printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif
#if defined (_SEQUENT_)
struct utsname un;
uname(&un);
if (strncmp(un.version, "V2", 2) == 0) {
printf ("i386-sequent-ptx2\n"); exit (0);
}
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
printf ("i386-sequent-ptx1\n"); exit (0);
}
printf ("i386-sequent-ptx\n"); exit (0);
#endif
#if defined (vax)
# if !defined (ultrix)
# include
# if defined (BSD)
# if BSD == 43
printf ("vax-dec-bsd4.3\n"); exit (0);
# else
# if BSD == 199006
printf ("vax-dec-bsd4.3reno\n"); exit (0);
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# endif
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# else
printf ("vax-dec-ultrix\n"); exit (0);
# endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
# Convex versions that predate uname can use getsysinfo(1)
if [ -x /usr/convex/getsysinfo ]
then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
exit ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
c34*)
echo c34-convex-bsd
exit ;;
c38*)
echo c38-convex-bsd
exit ;;
c4*)
echo c4-convex-bsd
exit ;;
esac
fi
cat >&2 < in order to provide the needed
information to handle your system.
config.guess timestamp = $timestamp
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
hostinfo = `(hostinfo) 2>/dev/null`
/bin/universe = `(/bin/universe) 2>/dev/null`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
/bin/arch = `(/bin/arch) 2>/dev/null`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
UNAME_MACHINE = ${UNAME_MACHINE}
UNAME_RELEASE = ${UNAME_RELEASE}
UNAME_SYSTEM = ${UNAME_SYSTEM}
UNAME_VERSION = ${UNAME_VERSION}
EOF
exit 1
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
yap-6.2.2/config.h.in 000755 000765 000024 00000016007 11502264327 014304 0 ustar 00vsc staff 000000 000000
#include "parms.h"
/* are we using gcc */
#undef HAVE_GCC
/* should we use gcc threaded code (i.e. goto *adrs) */
#undef USE_THREADED_CODE
/* Should we use lib readline ? */
#undef HAVE_LIBREADLINE
/* Should we use lib readline ? */
#undef HAVE_LIBSOCKET
#undef HAVE_LIBNSL
/* Should we use gmp ? */
#undef HAVE_LIBGMP
/* What MPI libraries are there? */
#define HAVE_LIBMPI 0
#define HAVE_LIBMPICH 0
/* Should we use MPI ? */
#if HAVE_LIBMPI || HAVE_LIBMPICH
#define HAVE_MPI 1
#else
#define HAVE_MPI 0
#endif
/* Is there an MPE library? */
#define HAVE_LIBMPE 0
/* Should we use MPE ? */
#if HAVE_LIBMPE && HAVE_MPI
#define HAVE_MPE 1
#else
#define HAVE_MPE 0
#endif
/* does the compiler support inline ? */
#undef inline
/* Do we have Ansi headers ? */
#undef STDC_HEADERS
/* Host Name ? */
#undef HOST_ALIAS
#undef SUPPORT_CONDOR
#undef SUPPORT_THREADS
#undef USE_PTHREAD_LOCKING
#undef HAVE_SYS_WAIT_H
#undef NO_UNION_WAIT
#undef HAVE_ALLOCA_H
#undef HAVE_ARPA_INET_H
#undef HAVE_CTYPE_H
#undef HAVE_CRYPT_H
#undef HAVE_CUDD_H
#undef HAVE_DIRECT_H
#undef HAVE_DIRENT_H
#undef HAVE_DLFCN_H
#undef HAVE_ERRNO_H
#undef HAVE_EXECINFO_H
#undef HAVE_FCNTL_H
#undef HAVE_FENV_H
#undef HAVE_FLOAT_H
#undef HAVE_FPU_CONTROL_H
#undef HAVE_GMP_H
#undef HAVE_IEEEFP_H
#undef HAVE_IO_H
#undef HAVE_LIMITS_H
#undef HAVE_LOCALE_H
#undef HAVE_MACH_O_DYLD_H
#undef HAVE_MALLOC_H
#undef HAVE_MATH_H
#undef HAVE_MEMORY_H
#undef HAVE_MPE_H
#undef HAVE_MPI_H
#undef HAVE_NETDB_H
#undef HAVE_NETINET_IN_H
#undef HAVE_NETINET_TCP_H
#undef HAVE_PTHREAD_H
#undef HAVE_PWD_H
#undef HAVE_READLINE_READLINE_H
#undef HAVE_REGEX_H
#undef HAVE_SIGINFO_H
#undef HAVE_SIGNAL_H
#undef HAVE_STDARG_H
#undef HAVE_STRING_H
#undef HAVE_STROPTS_H
#undef HAVE_SYS_CONF_H
#undef HAVE_SYS_DIR_H
#undef HAVE_SYS_FILE_H
#undef HAVE_SYS_MMAN_H
#undef HAVE_SYS_NDIR_H
#undef HAVE_SYS_PARAM_H
#undef HAVE_SYS_RESOURCE_H
#undef HAVE_SYS_SELECT_H
#undef HAVE_SYS_SHM_H
#undef HAVE_SYS_SOCKET_H
#undef HAVE_SYS_STAT_H
#undef HAVE_SYS_TIME_H
#undef HAVE_SYS_TIMES_H
#undef HAVE_SYS_TYPES_H
#undef HAVE_SYS_UCONTEXT_H
#undef HAVE_SYS_UN_H
#undef HAVE_SYS_WAIT_H
#undef HAVE_TIME_H
#undef HAVE_UNISTD_H
#undef HAVE_UTIME_H
#undef HAVE_WCTYPE_H
#undef HAVE_WINSOCK_H
#undef HAVE_WINSOCK2_H
#if __MINGW32__
#define __WINDOWS__ 1
#endif
/* Do we have restartable syscalls */
#undef HAVE_RESTARTABLE_SYSCALLS
/* is 'tms' defined in ? */
#undef TM_IN_SYS_TIME
/* define type of prt returned by malloc: char or void */
#undef MALLOC_T
/* Define byte order */
#undef WORDS_BIGENDIAN
/* Define sizes of some basic types */
#undef SIZEOF_INT_P
#undef SIZEOF_INT
#undef SIZEOF_SHORT_INT
#undef SIZEOF_LONG_INT
#undef SIZEOF_LONG_LONG_INT
#undef SIZEOF_FLOAT
#undef SIZEOF_DOUBLE
/* Define representation of floats */
/* only one of the following shoud be set */
/* to add a new representation you must edit FloatOfTerm and MkFloatTerm
in adtdefs.c
*/
#define FFIEEE 1
/*manual */
#undef FFVAX
/* Define the standard type of a float argument to a function */
/*manual */
#define FAFloat double
/* Set the minimum and default heap, trail and stack size */
#undef MinTrailSpace
#undef MinStackSpace
#undef MinHeapSpace
#undef DefTrailSpace
#undef DefStackSpace
#undef DefHeapSpace
/* Define return type for signal */
#undef RETSIGTYPE
#undef HAVE__NSGETENVIRON
#undef HAVE_ACCESS
#undef HAVE_ACOSH
#undef HAVE_ALARM
#undef HAVE_ALLOCA
#undef HAVE_ASINH
#undef HAVE_ATANH
#undef HAVE_CHDIR
#undef HAVE_CTIME
#undef HAVE_DLOPEN
#undef HAVE_DUP2
#undef HAVE_ERF
#undef HAVE_FECLEAREXCEPT
#undef HAVE_FESETTRAPENABLE
#undef HAVE_FETESTEXCEPT
#undef HAVE_FGETPOS
#undef HAVE_FINITE
#undef HAVE_FPCLASS
#undef HAVE_FTIME
#undef HAVE_GETCWD
#undef HAVE_GETENV
#undef HAVE_GETHOSTBYNAME
#undef HAVE_GETHOSTENT
#undef HAVE_GETHOSTID
#undef HAVE_GETHOSTNAME
#undef HAVE_GETHRTIME
#undef HAVE_GETPAGESIZE
#undef HAVE_GETPWNAM
#undef HAVE_GETRUSAGE
#undef HAVE_GETTIMEOFDAY
#undef HAVE_GETWD
#undef HAVE_ISATTY
#undef HAVE_ISINF
#undef HAVE_ISNAN
#undef HAVE_KILL
#undef HAVE_LABS
#undef HAVE_LGAMMA
#undef HAVE_LINK
#undef HAVE_LOCALTIME
#undef HAVE_LSTAT
#undef HAVE_MALLINFO
#undef HAVE_MBSNRTOWCS
#undef HAVE_MEMCPY
#undef HAVE_MEMMOVE
#undef HAVE_MKSTEMP
#undef HAVE_MKTEMP
#undef HAVE_MKTIME
#undef HAVE_MMAP
#undef HAVE_NANOSLEEP
#undef HAVE_NSLINKMODULE
#undef HAVE_OPENDIR
#undef HAVE_POPEN
#undef HAVE_PTHREAD_MUTEXATTR_SETKIND_NP
#undef HAVE_PTHREAD_MUTEXATTR_SETTYPE
#undef HAVE_PUTENV
#undef HAVE_RAND
#undef HAVE_RANDOM
#undef HAVE_READLINK
#undef HAVE_REGEXEC
#undef HAVE_RENAME
#undef HAVE_RINT
#undef HAVE_RL_SET_PROMPT
#undef HAVE_SBRK
#undef HAVE_SELECT
#undef HAVE_SETBUF
#undef HAVE_SETITIMER
#undef HAVE_SETLINEBUF
#undef HAVE_SETLOCALE
#undef HAVE_SETSID
#undef HAVE_SHMAT
#undef HAVE_SIGACTION
#undef HAVE_SIGGETMASK
#undef HAVE_SIGINTERRUPT
#undef HAVE_SIGNAL
#undef HAVE_SIGPROCMASK
#undef HAVE_SIGSETJMP
#undef HAVE_SLEEP
#undef HAVE_SNPRINTF
#undef HAVE_SOCKET
#undef HAVE_STAT
#undef HAVE_STRCHR
#undef HAVE_STRERROR
#undef HAVE_STRICMP
#undef HAVE_STRNCAT
#undef HAVE_STRNCPY
#undef HAVE_STRTOD
#undef HAVE_SYSTEM
#undef HAVE_TIME
#undef HAVE_TIMES
#undef HAVE_TMPNAM
#undef HAVE_TTYNAME
#undef HAVE_USLEEP
#undef HAVE_VSNPRINTF
#undef HAVE_WAITPID
#undef HAVE_MPZ_XOR
#undef HAVE_SIGINFO
#undef HAVE_SIGSEGV
#undef HAVE_SIGPROF
#undef HAVE_ENVIRON
#undef HAVE_VAR_TIMEZONE
#undef HAVE_STRUCT_TIME_TM_GMTOFF
#define SELECT_TYPE_ARG1
#define SELECT_TYPE_ARG234
#define SELECT_TYPE_ARG5
#define TYPE_SELECT_
#define MYTYPE(X) MYTYPE1#X
/* define how to pass the address of a function */
#define FunAdr(Fn) Fn
#define ALIGN_LONGS 1
#define LOW_ABSMI 0
#define MSHIFTOFFS 1
#undef USE_DL_MALLOC
#undef USE_MALLOC
#undef USE_SYSTEM_MALLOC
#define USE_MMAP (HAVE_MMAP & !USE_MALLOC & !USE_SYSTEM_MALLOC)
#define USE_SHM (HAVE_SHMAT & !HAVE_MMAP & !USE_MALLOC & !USE_SYSTEM_MALLOC)
#define USE_SBRK (HAVE_SBRK & !HAVE_MMAP & !HAVE_SHMAT & !USE_MALLOC & !USE_SYSTEM_MALLOC)
/* for OSes that do not allow user access to the first
quadrant of the memory space */
#undef FORCE_SECOND_QUADRANT
#if (HAVE_SOCKET || defined(__MINGW32__)) && !defined(SIMICS)
#define USE_SOCKET 1
#endif
#if defined(__hpux)
/* HP-UX requires extra definitions for X/Open networking */
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE_EXTENDED 0
#endif
#if HAVE_GMP_H && HAVE_LIBGMP
#define USE_GMP 1
#endif
/* Should we use MPI ? */
#if defined(HAVE_MPI_H) && (HAVE_LIBMPI || HAVE_LIBMPICH)
#define HAVE_MPI 1
#else
#define HAVE_MPI 0
#endif
/* Should we use MPE ? */
#if defined(HAVE_MPI_H) && HAVE_LIBMPE && HAVE_MPI
#define HAVE_MPE 1
#else
#define HAVE_MPE 0
#endif
/* should we avoid realloc() in mpi.c? */
#define MPI_AVOID_REALLOC 0
/* Is fflush(NULL) clobbering input streams? */
#undef BROKEN_FFLUSH_NULL
/* sunpro cc */
#ifdef __SUNPRO_CC
#ifdef HAVE_GCC
#undef HAVE_GCC
#endif
#endif
#undef GC_NO_TAGS
#undef MAX_WORKERS
#undef MAX_THREADS
yap-6.2.2/config.sub 000644 000765 000024 00000102425 11457004724 014240 0 ustar 00vsc staff 000000 000000 #! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc.
timestamp='2009-06-11'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Please send patches to . Submit a context
# diff and a properly formatted ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support. The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.
# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION] CPU-MFR-OPSYS
$0 [OPTION] ALIAS
Canonicalize a configuration name.
Operation modes:
-h, --help print this help, then exit
-t, --time-stamp print date of last modification, then exit
-v, --version print version number, then exit
Report bugs and patches to ."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
Try \`$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
break ;;
-* )
echo "$me: invalid option $1$help"
exit 1 ;;
*local*)
# First pass through any local machine types.
echo $1
exit ;;
* )
break ;;
esac
done
case $# in
0) echo "$me: missing argument$help" >&2
exit 1;;
1) ;;
*) echo "$me: too many arguments$help" >&2
exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
then os=`echo $1 | sed 's/.*-/-/'`
else os=; fi
;;
esac
### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work. We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray)
os=
basic_machine=$1
;;
-bluegene*)
os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
;;
-scout)
;;
-wrs)
os=-vxworks
basic_machine=$1
;;
-chorusos*)
os=-chorusos
basic_machine=$1
;;
-chorusrdb)
os=-chorusrdb
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco6)
os=-sco5v6
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5v6*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-udk*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*)
os=-lynxos
;;
-ptx*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
;;
-windowsnt*)
os=`echo $os | sed -e 's/windowsnt/winnt/'`
;;
-psos*)
os=-psos
;;
-mint | -mint[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64octeon | mips64octeonel \
| mips64orion | mips64orionel \
| mips64r5900 | mips64r5900el \
| mips64vr | mips64vrel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nios | nios2 \
| ns16k | ns32k \
| or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
ms1)
basic_machine=mt-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64octeon-* | mips64octeonel-* \
| mips64orion-* | mips64orionel-* \
| mips64r5900-* | mips64r5900el-* \
| mips64vr-* | mips64vrel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-* | z80-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=$basic_machine-unknown
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
basic_machine=i386-unknown
os=-bsd
;;
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
a29khif)
basic_machine=a29k-amd
os=-udi
;;
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
altos | altos3068)
basic_machine=m68k-altos
;;
am29k)
basic_machine=a29k-none
os=-bsd
;;
amd64)
basic_machine=x86_64-pc
;;
amd64-*)
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-unknown
;;
amigaos | amigados)
basic_machine=m68k-unknown
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
os=-bsd
;;
aros)
basic_machine=i386-pc
os=-aros
;;
aux)
basic_machine=m68k-apple
os=-aux
;;
balance)
basic_machine=ns32k-sequent
os=-dynix
;;
blackfin)
basic_machine=bfin-unknown
os=-linux
;;
blackfin-*)
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
bluegene*)
basic_machine=powerpc-ibm
os=-cnk
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
;;
convex-c2)
basic_machine=c2-convex
os=-bsd
;;
convex-c32)
basic_machine=c32-convex
os=-bsd
;;
convex-c34)
basic_machine=c34-convex
os=-bsd
;;
convex-c38)
basic_machine=c38-convex
os=-bsd
;;
cray | j90)
basic_machine=j90-cray
os=-unicos
;;
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16)
basic_machine=cr16-unknown
os=-elf
;;
crds | unos)
basic_machine=m68k-crds
;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
crx)
basic_machine=crx-unknown
os=-elf
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
;;
delta88)
basic_machine=m88k-motorola
os=-sysv3
;;
dicos)
basic_machine=i686-pc
os=-dicos
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
;;
dpx2* | dpx2*-bull)
basic_machine=m68k-bull
os=-sysv3
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
;;
elxsi)
basic_machine=elxsi-elxsi
os=-bsd
;;
encore | umax | mmax)
basic_machine=ns32k-encore
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
os=-ose
;;
fx2800)
basic_machine=i860-alliant
;;
genix)
basic_machine=ns32k-ns
;;
gmicro)
basic_machine=tron-gmicro
os=-sysv
;;
go32)
basic_machine=i386-pc
os=-go32
;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
h8300hms)
basic_machine=h8300-hitachi
os=-hms
;;
h8300xray)
basic_machine=h8300-hitachi
os=-xray
;;
h8500hms)
basic_machine=h8500-hitachi
os=-hms
;;
harris)
basic_machine=m88k-harris
os=-sysv3
;;
hp300-*)
basic_machine=m68k-hp
;;
hp300bsd)
basic_machine=m68k-hp
os=-bsd
;;
hp300hpux)
basic_machine=m68k-hp
os=-hpux
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
hp9k6[0-9][0-9] | hp6[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hp9k7[0-79][0-9] | hp7[0-79][0-9])
basic_machine=hppa1.1-hp
;;
hp9k78[0-9] | hp78[0-9])
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
# FIXME: really hppa2.0-hp
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][13679] | hp8[0-9][13679])
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hppa-next)
os=-nextstep3
;;
hppaosf)
basic_machine=hppa1.1-hp
os=-osf
;;
hppro)
basic_machine=hppa1.1-hp
os=-proelf
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i*86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i*86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i*86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
i386mach)
basic_machine=i386-mach
os=-mach
;;
i386-vsta | vsta)
basic_machine=i386-unknown
os=-vsta
;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
-irix*)
;;
*)
os=-irix4
;;
esac
;;
isi68 | isi)
basic_machine=m68k-isi
os=-sysv
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
m88k-omron*)
basic_machine=m88k-omron
;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
;;
merlin)
basic_machine=ns32k-utek
os=-sysv
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
;;
mingw32ce)
basic_machine=arm-unknown
os=-mingw32ce
;;
miniframe)
basic_machine=m68000-convergent
;;
*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
basic_machine=m68k-atari
os=-mint
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos)
basic_machine=i386-pc
os=-msdos
;;
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
netbsd386)
basic_machine=i386-unknown
os=-netbsd
;;
netwinder)
basic_machine=armv4l-rebel
os=-linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
;;
news1000)
basic_machine=m68030-sony
os=-newsos
;;
news-3600 | risc-news)
basic_machine=mips-sony
os=-newsos
;;
necv70)
basic_machine=v70-nec
os=-sysv
;;
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep* )
;;
-ns2*)
os=-nextstep2
;;
*)
os=-nextstep3
;;
esac
;;
nh3000)
basic_machine=m68k-harris
os=-cxux
;;
nh[45]000)
basic_machine=m88k-harris
os=-cxux
;;
nindy960)
basic_machine=i960-intel
os=-nindy
;;
mon960)
basic_machine=i960-intel
os=-mon960
;;
nonstopux)
basic_machine=mips-compaq
os=-nonstopux
;;
np1)
basic_machine=np1-gould
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
;;
openrisc | openrisc-*)
basic_machine=or32-unknown
;;
os400)
basic_machine=powerpc-ibm
os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
;;
os68k)
basic_machine=m68k-none
os=-os68k
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
paragon)
basic_machine=i860-intel
os=-osf
;;
parisc)
basic_machine=hppa-unknown
os=-linux
;;
parisc-*)
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
pbd)
basic_machine=sparc-tti
;;
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pc98)
basic_machine=i386-pc
;;
pc98-*)
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc
;;
pentiumii | pentium2 | pentiumiii | pentium3)
basic_machine=i686-pc
;;
pentium4)
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium4-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
pw32)
basic_machine=i586-unknown
os=-pw32
;;
rdos)
basic_machine=i386-pc
os=-rdos
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sde)
basic_machine=mipsisa32-sde
os=-elf
;;
sei)
basic_machine=mips-sei
os=-seiux
;;
sequent)
basic_machine=i386-sequent
;;
sh)
basic_machine=sh-hitachi
os=-hms
;;
sh5el)
basic_machine=sh5le-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
;;
spur)
basic_machine=spur-unknown
;;
st2000)
basic_machine=m68k-tandem
;;
stratus)
basic_machine=i860-stratus
os=-sysv4
;;
sun2)
basic_machine=m68000-sun
;;
sun2os3)
basic_machine=m68000-sun
os=-sunos3
;;
sun2os4)
basic_machine=m68000-sun
os=-sunos4
;;
sun3os3)
basic_machine=m68k-sun
os=-sunos3
;;
sun3os4)
basic_machine=m68k-sun
os=-sunos4
;;
sun4os3)
basic_machine=sparc-sun
os=-sunos3
;;
sun4os4)
basic_machine=sparc-sun
os=-sunos4
;;
sun4sol2)
basic_machine=sparc-sun
os=-solaris2
;;
sun3 | sun3-*)
basic_machine=m68k-sun
;;
sun4)
basic_machine=sparc-sun
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
sv1)
basic_machine=sv1-cray
os=-unicos
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
t3e)
basic_machine=alphaev5-cray
os=-unicos
;;
t90)
basic_machine=t90-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
tile*)
basic_machine=tile-unknown
os=-linux-gnu
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
tpf)
basic_machine=s390x-ibm
os=-tpf
;;
udi29k)
basic_machine=a29k-amd
os=-udi
;;
ultra3)
basic_machine=a29k-nyu
os=-sym1
;;
v810 | necv810)
basic_machine=v810-nec
os=-none
;;
vaxv)
basic_machine=vax-dec
os=-sysv
;;
vms)
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
;;
vxworks68)
basic_machine=m68k-wrs
os=-vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
os=-vxworks
;;
w65*)
basic_machine=w65-wdc
os=-none
;;
w89k-*)
basic_machine=hppa1.1-winbond
os=-proelf
;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
;;
z80-*-coff)
basic_machine=z80-unknown
os=-sim
;;
none)
basic_machine=none-none
os=-none
;;
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
w89k)
basic_machine=hppa1.1-winbond
;;
op50n)
basic_machine=hppa1.1-oki
;;
op60c)
basic_machine=hppa1.1-oki
;;
romp)
basic_machine=romp-ibm
;;
mmix)
basic_machine=mmix-knuth
;;
rs6000)
basic_machine=rs6000-ibm
;;
vax)
basic_machine=vax-dec
;;
pdp10)
# there are many clones, so DEC is not a safe bet
basic_machine=pdp10-unknown
;;
pdp11)
basic_machine=pdp11-dec
;;
we32k)
basic_machine=we32k-att
;;
sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
basic_machine=cydra-cydrome
;;
orion)
basic_machine=orion-highlevel
;;
orion105)
basic_machine=clipper-highlevel
;;
mac | mpw | mac-mpw)
basic_machine=m68k-apple
;;
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
;;
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
-solaris)
os=-solaris2
;;
-svr4*)
os=-sysv4
;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# First accept the basic system types.
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -kopensolaris* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
case $basic_machine in
x86-* | i*86-*)
;;
*)
os=-nto$os
;;
esac
;;
-nto-qnx*)
;;
-nto*)
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
;;
-linux-dietlibc)
os=-linux-dietlibc
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-opened*)
os=-openedition
;;
-os400*)
os=-os400
;;
-wince*)
os=-wince
;;
-osfrose*)
os=-osfrose
;;
-osf*)
os=-osf
;;
-utek*)
os=-bsd
;;
-dynix*)
os=-bsd
;;
-acis*)
os=-aos
;;
-atheos*)
os=-atheos
;;
-syllable*)
os=-syllable
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-nova*)
os=-rtmk-nova
;;
-ns2 )
os=-nextstep2
;;
-nsk*)
os=-nsk
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
-sinix*)
os=-sysv4
;;
-tpf*)
os=-tpf
;;
-triton*)
os=-sysv3
;;
-oss*)
os=-sysv3
;;
-svr4)
os=-sysv4
;;
-svr3)
os=-sysv3
;;
-sysvr4)
os=-sysv4
;;
# This must come after -sysvr4.
-sysv*)
;;
-ose*)
os=-ose
;;
-es1800*)
os=-ose
;;
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
-dicos*)
os=-dicos
;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
exit 1
;;
esac
else
# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.
# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
case $basic_machine in
score-*)
os=-elf
;;
spu-*)
os=-elf
;;
*-acorn)
os=-riscix1.2
;;
arm*-rebel)
os=-linux
;;
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
pdp11-*)
os=-none
;;
*-dec | vax-*)
os=-ultrix4.2
;;
m68*-apollo)
os=-domain
;;
i386-sun)
os=-sunos4.0.2
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
m68*-cisco)
os=-aout
;;
mep-*)
os=-elf
;;
mips*-cisco)
os=-elf
;;
mips*-*)
os=-elf
;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-be)
os=-beos
;;
*-haiku)
os=-haiku
;;
*-ibm)
os=-aix
;;
*-knuth)
os=-mmixware
;;
*-wec)
os=-proelf
;;
*-winbond)
os=-proelf
;;
*-oki)
os=-proelf
;;
*-hp)
os=-hpux
;;
*-hitachi)
os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=-sysv
;;
*-cbm)
os=-amigaos
;;
*-dg)
os=-dgux
;;
*-dolphin)
os=-sysv3
;;
m68k-ccur)
os=-rtu
;;
m88k-omron*)
os=-luna
;;
*-next )
os=-nextstep
;;
*-sequent)
os=-ptx
;;
*-crds)
os=-unos
;;
*-ns)
os=-genix
;;
i370-*)
os=-mvs
;;
*-next)
os=-nextstep3
;;
*-gould)
os=-sysv
;;
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
os=-irix
;;
*-siemens)
os=-sysv4
;;
*-masscomp)
os=-rtu
;;
f30[01]-fujitsu | f700-fujitsu)
os=-uxpv
;;
*-rom68k)
os=-coff
;;
*-*bug)
os=-coff
;;
*-apple)
os=-macos
;;
*-atari*)
os=-mint
;;
*)
os=-none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
vendor=unknown
case $basic_machine in
*-unknown)
case $os in
-riscix*)
vendor=acorn
;;
-sunos*)
vendor=sun
;;
-cnk*|-aix*)
vendor=ibm
;;
-beos*)
vendor=be
;;
-hpux*)
vendor=hp
;;
-mpeix*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
-unos*)
vendor=crds
;;
-dgux*)
vendor=dg
;;
-luna*)
vendor=omron
;;
-genix*)
vendor=ns
;;
-mvs* | -opened*)
vendor=ibm
;;
-os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-tpf*)
vendor=ibm
;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
vendor=apple
;;
-hms*)
vendor=hitachi
;;
-mpw* | -macos*)
vendor=apple
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
-vos*)
vendor=stratus
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os
exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "timestamp='"
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "'"
# End:
yap-6.2.2/configure 000755 000765 000024 00001107270 11651110414 014161 0 ustar 00vsc staff 000000 000000 #! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
#
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='print -r --'
as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in #(
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
exit 1
fi
# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there. '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
&& ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
if test "x$CONFIG_SHELL" = x; then
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
# is contrary to our usage. Disable this feature.
alias -g '\${1+\"\$@\"}'='\"\$@\"'
setopt NO_GLOB_SUBST
else
case \`(set -o) 2>/dev/null\` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
"
as_required="as_fn_return () { (exit \$1); }
as_fn_success () { as_fn_return 0; }
as_fn_failure () { as_fn_return 1; }
as_fn_ret_success () { return 0; }
as_fn_ret_failure () { return 1; }
exitcode=0
as_fn_success || { exitcode=1; echo as_fn_success failed.; }
as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
else
exitcode=1; echo positional parameters were not saved.
fi
test x\$exitcode = x0 || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
test \$(( 1 + 1 )) = 2 || exit 1"
if (eval "$as_required") 2>/dev/null; then :
as_have_required=yes
else
as_have_required=no
fi
if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
as_found=false
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
as_found=:
case $as_dir in #(
/*)
for as_base in sh bash ksh sh5; do
# Try only shells that exist, to save several forks.
as_shell=$as_dir/$as_base
if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
{ $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
CONFIG_SHELL=$as_shell as_have_required=yes
if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
break 2
fi
fi
done;;
esac
as_found=false
done
$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
{ $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
CONFIG_SHELL=$SHELL as_have_required=yes
fi; }
IFS=$as_save_IFS
if test "x$CONFIG_SHELL" != x; then :
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
export CONFIG_SHELL
exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
fi
if test x$as_have_required = xno; then :
$as_echo "$0: This script requires a shell more modern than all"
$as_echo "$0: the shells that I found on your system."
if test x${ZSH_VERSION+set} = xset ; then
$as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
$as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
$0: including any error possibly output before this
$0: message. Then install a modern shell, or manually run
$0: the script under such a shell if you do have one."
fi
exit 1
fi
fi
fi
SHELL=${CONFIG_SHELL-/bin/sh}
export SHELL
# Unset more variables known to interfere with behavior of common tools.
CLICOLOR_FORCE= GREP_OPTIONS=
unset CLICOLOR_FORCE GREP_OPTIONS
## --------------------- ##
## M4sh Shell Functions. ##
## --------------------- ##
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
{ eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
return $1
} # as_fn_set_status
# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
set +e
as_fn_set_status $1
exit $1
} # as_fn_exit
# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || eval $as_mkdir_p || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
} # as_fn_mkdir_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
eval 'as_fn_append ()
{
eval $1+=\$2
}'
else
as_fn_append ()
{
eval $1=\$$1\$2
}
fi # as_fn_append
# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
eval 'as_fn_arith ()
{
as_val=$(( $* ))
}'
else
as_fn_arith ()
{
as_val=`expr "$@" || test $? -eq 1`
}
fi # as_fn_arith
# as_fn_error ERROR [LINENO LOG_FD]
# ---------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with status $?, using 1 if that was 0.
as_fn_error ()
{
as_status=$?; test $as_status -eq 0 && as_status=1
if test "$3"; then
as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
fi
$as_echo "$as_me: error: $1" >&2
as_fn_exit $as_status
} # as_fn_error
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
as_lineno_1=$LINENO as_lineno_1a=$LINENO
as_lineno_2=$LINENO as_lineno_2a=$LINENO
eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
# Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
sed -n '
p
/[$]LINENO/=
' <$as_myself |
sed '
s/[$]LINENO.*/&-/
t lineno
b
:lineno
N
:loop
s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
t loop
s/-\n.*//
' >$as_me.lineno &&
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
. "./$as_me.lineno"
# Exit status is that of the last command.
exit
}
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
case `echo 'xy\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
xy) ECHO_C='\c';;
*) echo `echo ksh88 bug on AIX 6.1` > /dev/null
ECHO_T=' ';;
esac;;
*)
ECHO_N='-n';;
esac
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
if mkdir -p . 2>/dev/null; then
as_mkdir_p='mkdir -p "$as_dir"'
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
test -n "$DJDIR" || exec 7<&0 &1
# Name of the host.
# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
#
# Initializations.
#
ac_default_prefix=/usr/local
ac_clean_files=
ac_config_libobj_dir=.
LIBOBJS=
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME=
PACKAGE_TARNAME=
PACKAGE_VERSION=
PACKAGE_STRING=
PACKAGE_BUGREPORT=
PACKAGE_URL=
ac_unique_file="console/yap.c"
# Factoring default headers for most tests.
ac_includes_default="\
#include
#ifdef HAVE_SYS_TYPES_H
# include
#endif
#ifdef HAVE_SYS_STAT_H
# include
#endif
#ifdef STDC_HEADERS
# include
# include
#else
# ifdef HAVE_STDLIB_H
# include
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
# include
# endif
# include
#endif
#ifdef HAVE_STRINGS_H
# include
#endif
#ifdef HAVE_INTTYPES_H
# include
#endif
#ifdef HAVE_STDINT_H
# include
#endif
#ifdef HAVE_UNISTD_H
# include
#endif"
ac_subst_vars='LTLIBOBJS
LIBOBJS
CLIB_CRYPTLIBS
CLIB_NETLIBS
CLIB_PLTARGETS
CLIB_TARGETS
CLIB_PTHREADS
CHR_TARGETS
PLTARGETS
TARGETS
IN_SWI
IN_YAP
PROLOG_SYSTEM
M4GENABSMI
MATLAB_INCLUDE
INSTALL_MATLAB
USE_MINISAT
CUDD_CPPFLAGS
CUDD_LDFLAGS
USE_CUDD
ENABLE_WINCONSOLE
STATIC_MODE
MAX_WORKERS
LAMOBJS
JAVAINCPATH
JAVALIBPATH
INSTALLCLP
INSTALL_COMMAND
MPI_LIBS
MPI_OBJS
LAM_MPI_CC
YAPMPILIB
IN_UNIX
JAR
JAVADOC
JAVAC
JUNIT
JAVA_HOME
JAVA
ENABLE_JPL
ENABLE_CLPQR
ENABLE_CHR
NO_BUILTIN_REGEXP
YAP_EXTRAS
SONAMEFLAG
DYNYAPLIB
YAPLIB
EXTRA_LIBS_FOR_SWIDLLS
EXTRA_LIBS_FOR_DLLS
YAPLIB_CFLAGS
YAPLIB_LD
SHLIB_CXX_LD
SHLIB_LD
DO_SECOND_LD
EXEC_SUFFIX
SO
SHLIB_CXXFLAGS
SHLIB_CFLAGS
MERGE_DLL_OBJS
INSTALL_DLLS
ARCH
M4GENHDRS
M4
ZLIB_INSTALL
ZLIB_PLTARGETS
ZLIB_TARGETS
ZLIBS
PRE_INSTALL_ENV
INSTALL_ENV
ENABLE_CPLINT
SHLIB_SUFFIX
CPLINT_SHLIB_LD
CPLINT_LDFLAGS
CPLINT_CFLAGS
CPLINT_LIBS
EGREP
GREP
CPP
INSTALL_INFO
MPI_CC
AR
INDENT
RANLIB
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
LN_S
target_os
target_vendor
target_cpu
target
host_os
host_vendor
host_cpu
host
build_os
build_vendor
build_cpu
build
DefTrailSpace
DefStackSpace
DefHeapSpace
C_PARSER_FLAGS
C_INTERF_FLAGS
GCC
AWK
ac_ct_CXX
CXXFLAGS
CXX
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
CC
target_alias
host_alias
build_alias
LIBS
ECHO_T
ECHO_N
ECHO_C
DEFS
mandir
localedir
libdir
psdir
pdfdir
dvidir
htmldir
infodir
docdir
oldincludedir
includedir
localstatedir
sharedstatedir
sysconfdir
datadir
datarootdir
libexecdir
sbindir
bindir
program_transform_name
prefix
exec_prefix
PACKAGE_URL
PACKAGE_BUGREPORT
PACKAGE_STRING
PACKAGE_VERSION
PACKAGE_TARNAME
PACKAGE_NAME
PATH_SEPARATOR
SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_tabling
enable_or_parallelism
enable_rational_trees
enable_coroutining
enable_depth_limit
enable_wam_profile
enable_low_level_tracer
enable_threads
enable_pthread_locking
enable_max_performance
enable_max_memory
enable_debug_yap
enable_eam
enable_cygwin
enable_dynamic_loading
enable_static_compilation
enable_use_malloc
enable_condor
enable_chr
enable_clpqr
enable_win64
enable_april
enable_dlcompat
enable_cplint
with_gmp
with_minisat
with_cudd
enable_myddas
enable_myddas_stats
enable_myddas_top_level
with_java
with_readline
with_matlab
with_mpi
with_mpe
with_lam
with_heap_space
with_stack_space
with_trail_space
with_max_workers
with_max_threads
with_junit
'
ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CXX
CXXFLAGS
CCC
CPP'
# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
ac_unrecognized_opts=
ac_unrecognized_sep=
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE
# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
# (The list follows the same order as the GNU Coding Standards.)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'
ac_prev=
ac_dashdash=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval $ac_prev=\$ac_option
ac_prev=
continue
fi
case $ac_option in
*=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
*) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_dashdash$ac_option in
--)
ac_dashdash=yes ;;
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file=$ac_optarg ;;
--config-cache | -C)
cache_file=config.cache ;;
-datadir | --datadir | --datadi | --datad)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=*)
datadir=$ac_optarg ;;
-datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
| --dataroo | --dataro | --datar)
ac_prev=datarootdir ;;
-datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
| --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
datarootdir=$ac_optarg ;;
-disable-* | --disable-*)
ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=no ;;
-docdir | --docdir | --docdi | --doc | --do)
ac_prev=docdir ;;
-docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
docdir=$ac_optarg ;;
-dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
ac_prev=dvidir ;;
-dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
dvidir=$ac_optarg ;;
-enable-* | --enable-*)
ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"enable_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=\$ac_optarg ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix=$ac_optarg ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he | -h)
ac_init_help=long ;;
-help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
ac_init_help=recursive ;;
-help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
ac_init_help=short ;;
-host | --host | --hos | --ho)
ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
host_alias=$ac_optarg ;;
-htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
ac_prev=htmldir ;;
-htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
| --ht=*)
htmldir=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir=$ac_optarg ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir=$ac_optarg ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir=$ac_optarg ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir=$ac_optarg ;;
-localedir | --localedir | --localedi | --localed | --locale)
ac_prev=localedir ;;
-localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
localedir=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst | --locals)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
localstatedir=$ac_optarg ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir=$ac_optarg ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c | -n)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir=$ac_optarg ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix=$ac_optarg ;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix=$ac_optarg ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix=$ac_optarg ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name=$ac_optarg ;;
-pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
ac_prev=pdfdir ;;
-pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
pdfdir=$ac_optarg ;;
-psdir | --psdir | --psdi | --psd | --ps)
ac_prev=psdir ;;
-psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
psdir=$ac_optarg ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir=$ac_optarg ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir=$ac_optarg ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site=$ac_optarg ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir=$ac_optarg ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers | -V)
ac_init_version=: ;;
-with-* | --with-*)
ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=\$ac_optarg ;;
-without-* | --without-*)
ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=no ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes=$ac_optarg ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries=$ac_optarg ;;
-*) as_fn_error "unrecognized option: \`$ac_option'
Try \`$0 --help' for more information."
;;
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
case $ac_envvar in #(
'' | [0-9]* | *[!_$as_cr_alnum]* )
as_fn_error "invalid variable name: \`$ac_envvar'" ;;
esac
eval $ac_envvar=\$ac_optarg
export $ac_envvar ;;
*)
# FIXME: should be removed in autoconf 3.0.
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
: ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
;;
esac
done
if test -n "$ac_prev"; then
ac_option=--`echo $ac_prev | sed 's/_/-/g'`
as_fn_error "missing argument to $ac_option"
fi
if test -n "$ac_unrecognized_opts"; then
case $enable_option_checking in
no) ;;
fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
*) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
esac
fi
# Check all directory arguments for consistency.
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
case $ac_val in
*/ )
ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
eval $ac_var=\$ac_val;;
esac
# Be sure to have absolute directory names.
case $ac_val in
[\\/$]* | ?:[\\/]* ) continue;;
NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
esac
as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
done
# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
# FIXME: To remove some day.
build=$build_alias
host=$host_alias
target=$target_alias
# FIXME: To remove some day.
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
$as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used." >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
fi
ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-
test "$silent" = yes && exec 6>/dev/null
ac_pwd=`pwd` && test -n "$ac_pwd" &&
ac_ls_di=`ls -di .` &&
ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
as_fn_error "working directory cannot be determined"
test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
as_fn_error "pwd does not report name of working directory"
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then the parent directory.
ac_confdir=`$as_dirname -- "$as_myself" ||
$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_myself" : 'X\(//\)[^/]' \| \
X"$as_myself" : 'X\(//\)$' \| \
X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_myself" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
srcdir=$ac_confdir
if test ! -r "$srcdir/$ac_unique_file"; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
if test ! -r "$srcdir/$ac_unique_file"; then
test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
fi
ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
ac_abs_confdir=`(
cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
pwd)`
# When building in place, set srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
srcdir=.
fi
# Remove unnecessary trailing slashes from srcdir.
# Double slashes in file names in object file debugging info
# mess up M-x gdb in Emacs.
case $srcdir in
*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
esac
for ac_var in $ac_precious_vars; do
eval ac_env_${ac_var}_set=\${${ac_var}+set}
eval ac_env_${ac_var}_value=\$${ac_var}
eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
eval ac_cv_env_${ac_var}_value=\$${ac_var}
done
#
# Report the --help message.
#
if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures this package to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print \`checking...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for \`--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or \`..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, \`make install' will install all the files in
\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
an installation prefix other than \`$ac_default_prefix' using \`--prefix',
for instance \`--prefix=\$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
_ACEOF
cat <<\_ACEOF
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]
_ACEOF
fi
if test -n "$ac_init_help"; then
cat <<\_ACEOF
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-tabling support tabling
--enable-or-parallelism support or-parallelism as: env-copy,sba,a-cow
--enable-rational-trees support infinite rational trees
--enable-coroutining support co-routining, attributed variables and constraints
--enable-depth-limit support depth-bound computation
--enable-wam-profile support low level profiling of abstract machine
--enable-low-level-tracer support support for procedure-call tracing
--enable-threads support system threads
--enable-pthread-locking use pthread locking primitives for internal locking (requires threads)
--enable-max-performance try using the best flags for specific architecture
--enable-max-memory try using the best flags for using the memory to the most
--enable-debug-yap enable C-debugging for YAP
--enable-eam enable EAM on YAP
--enable-cygwin use cygwin library in WIN32
--enable-dynamic-loading compile YAP as a DLL
--enable-static-compilation compile YAP statically
--enable-use-malloc use malloc to allocate memory
--enable-condor allow YAP to be used from condor
--enable-chr install chr library
--enable-clpqr install clpqr library
--enable-win64 compile YAP for win64
--enable-april compile Yap to support April ILP system
--enable-dlcompat use dlcompat library for dynamic loading on Mac OS X
--enable-cplint=DIR enable the cplint library using the cudd library in DIR/lib
v --enable-myddas[=DIR] enable the MYDDAS library
--enable-myddas-stats enable the MYDDAS library statistics support
--enable-myddas-top-level enable the MYDDAS top-level support to MySQL
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-gmp=DIR use GNU Multiple Precision in DIR
--enable-minisat use minisat interface
--with-cudd=DIR use CUDD package in DIR
--with-java=JAVA_HOME use Java instalation in JAVA_HOME
--with-readline=DIR use GNU Readline Library in DIR
--with-matlab=DIR use MATLAB package in DIR
--with-mpi=DIR use MPI library in DIR
--with-mpe=DIR use MPE library in DIR
--with-lam=DIR use LAM MPI library in DIR
--with-heap-space=space default heap size in Kbytes
--with-stack-space=space default stack size in Kbytes
--with-trail-space=space default trail size in Kbytes
--with-max-workers=integer maximum number of or-parallel processes
--with-max-threads=integer maximum number of or-parallel processes
--with-junit=PATH Specify location of the junit JAR file
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory
LIBS libraries to pass to the linker, e.g. -l
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if
you have headers in a nonstandard directory
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.
_ACEOF
ac_status=$?
fi
if test "$ac_init_help" = "recursive"; then
# If there are subdirs, report their specific --help.
for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
test -d "$ac_dir" ||
{ cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
continue
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
cd "$ac_dir" || { ac_status=$?; continue; }
# Check for guested configure.
if test -f "$ac_srcdir/configure.gnu"; then
echo &&
$SHELL "$ac_srcdir/configure.gnu" --help=recursive
elif test -f "$ac_srcdir/configure"; then
echo &&
$SHELL "$ac_srcdir/configure" --help=recursive
else
$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
fi || ac_status=$?
cd "$ac_pwd" || { ac_status=$?; break; }
done
fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
configure
generated by GNU Autoconf 2.65
Copyright (C) 2009 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
exit
fi
## ------------------------ ##
## Autoconf initialization. ##
## ------------------------ ##
# ac_fn_c_try_compile LINENO
# --------------------------
# Try to compile conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext
if { { ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compile") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
as_fn_set_status $ac_retval
} # ac_fn_c_try_compile
# ac_fn_cxx_try_compile LINENO
# ----------------------------
# Try to compile conftest.$ac_ext, and return whether this succeeded.
ac_fn_cxx_try_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext
if { { ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compile") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_cxx_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
as_fn_set_status $ac_retval
} # ac_fn_cxx_try_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_cpp ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } >/dev/null && {
test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
test ! -s conftest.err
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
as_fn_set_status $ac_retval
} # ac_fn_c_try_cpp
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
# the include files in INCLUDES and setting the cache variable VAR
# accordingly.
ac_fn_c_check_header_mongrel ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
# Is the header compilable?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
$as_echo_n "checking $2 usability... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_header_compiler=yes
else
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }
# Is the header present?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
$as_echo_n "checking $2 presence... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <$2>
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
ac_header_preproc=yes
else
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
yes:no: )
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
;;
no:yes:* )
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
else
eval "$3=\$ac_header_compiler"
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_header_mongrel
# ac_fn_c_try_run LINENO
# ----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_c_try_run ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
as_fn_set_status $ac_retval
} # ac_fn_c_try_run
# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists and can be compiled using the include files in
# INCLUDES, setting the cache variable VAR accordingly.
ac_fn_c_check_header_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_header_compile
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
ac_fn_c_check_func ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Define $2 to an innocuous variant, in case declares $2.
For example, HP-UX 11i declares gettimeofday. */
#define $2 innocuous_$2
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $2 (); below.
Prefer to if __STDC__ is defined, since
exists even on freestanding compilers. */
#ifdef __STDC__
# include
#else
# include
#endif
#undef $2
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$2 || defined __stub___$2
choke me
#endif
int
main ()
{
return $2 ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_func
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
# --------------------------------------------
# Tries to find the compile-time value of EXPR in a program that includes
# INCLUDES, setting VAR accordingly. Returns whether the value could be
# computed
ac_fn_c_compute_int ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if test "$cross_compiling" = yes; then
# Depending upon the size, compute the lo and hi bounds.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) >= 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_lo=0 ac_mid=0
while :; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=$ac_mid; break
else
as_fn_arith $ac_mid + 1 && ac_lo=$as_val
if test $ac_lo -le $ac_mid; then
ac_lo= ac_hi=
break
fi
as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) < 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=-1 ac_mid=-1
while :; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) >= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_lo=$ac_mid; break
else
as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
if test $ac_mid -le $ac_hi; then
ac_lo= ac_hi=
break
fi
as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
ac_lo= ac_hi=
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# Binary search between lo and hi bounds.
while test "x$ac_lo" != "x$ac_hi"; do
as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=$ac_mid
else
as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
case $ac_lo in #((
?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
'') ac_retval=1 ;;
esac
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
static long int longval () { return $2; }
static unsigned long int ulongval () { return $2; }
#include
#include
int
main ()
{
FILE *f = fopen ("conftest.val", "w");
if (! f)
return 1;
if (($2) < 0)
{
long int i = longval ();
if (i != ($2))
return 1;
fprintf (f, "%ld", i);
}
else
{
unsigned long int i = ulongval ();
if (i != ($2))
return 1;
fprintf (f, "%lu", i);
}
/* Do not output a trailing newline, as this causes \r\n confusion
on some platforms. */
return ferror (f) || fclose (f) != 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
echo >>conftest.val; read $3 &5
$as_echo_n "checking for $2... " >&6; }
if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
else
eval "$3=no"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
if (sizeof ($2))
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
if (sizeof (($2)))
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
eval "$3=yes"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_type
# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
# ----------------------------------------------------
# Tries to find if the field MEMBER exists in type AGGR, after including
# INCLUDES, setting cache variable VAR accordingly.
ac_fn_c_check_member ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
$as_echo_n "checking for $2.$3... " >&6; }
if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$5
int
main ()
{
static $2 ac_aggr;
if (ac_aggr.$3)
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$4=yes"
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$5
int
main ()
{
static $2 ac_aggr;
if (sizeof ac_aggr.$3)
return 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
eval "$4=yes"
else
eval "$4=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$4
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_member
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
generated by GNU Autoconf 2.65. Invocation command line was
$ $0 $@
_ACEOF
exec 5>>config.log
{
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##
hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`
/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
_ASUNAME
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
$as_echo "PATH: $as_dir"
done
IFS=$as_save_IFS
} >&5
cat >&5 <<_ACEOF
## ----------- ##
## Core tests. ##
## ----------- ##
_ACEOF
# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
ac_configure_args0=
ac_configure_args1=
ac_must_keep_next=false
for ac_pass in 1 2
do
for ac_arg
do
case $ac_arg in
-no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
continue ;;
*\'*)
ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
case $ac_pass in
1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
2)
as_fn_append ac_configure_args1 " '$ac_arg'"
if test $ac_must_keep_next = true; then
ac_must_keep_next=false # Got value, back to normal.
else
case $ac_arg in
*=* | --config-cache | -C | -disable-* | --disable-* \
| -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
| -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
| -with-* | --with-* | -without-* | --without-* | --x)
case "$ac_configure_args0 " in
"$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
esac
;;
-* ) ac_must_keep_next=true ;;
esac
fi
as_fn_append ac_configure_args " '$ac_arg'"
;;
esac
done
done
{ ac_configure_args0=; unset ac_configure_args0;}
{ ac_configure_args1=; unset ac_configure_args1;}
# When interrupted or exit'd, cleanup temporary files, and complete
# config.log. We remove comments because anyway the quotes in there
# would cause problems or look ugly.
# WARNING: Use '\'' to represent an apostrophe within the trap.
# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
trap 'exit_status=$?
# Save into config.log some information that might help in debugging.
{
echo
cat <<\_ASBOX
## ---------------- ##
## Cache variables. ##
## ---------------- ##
_ASBOX
echo
# The following way of writing the cache mishandles newlines in values,
(
for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) { eval $ac_var=; unset $ac_var;} ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
sed -n \
"s/'\''/'\''\\\\'\'''\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
;; #(
*)
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
)
echo
cat <<\_ASBOX
## ----------------- ##
## Output variables. ##
## ----------------- ##
_ASBOX
echo
for ac_var in $ac_subst_vars
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
if test -n "$ac_subst_files"; then
cat <<\_ASBOX
## ------------------- ##
## File substitutions. ##
## ------------------- ##
_ASBOX
echo
for ac_var in $ac_subst_files
do
eval ac_val=\$$ac_var
case $ac_val in
*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
esac
$as_echo "$ac_var='\''$ac_val'\''"
done | sort
echo
fi
if test -s confdefs.h; then
cat <<\_ASBOX
## ----------- ##
## confdefs.h. ##
## ----------- ##
_ASBOX
echo
cat confdefs.h
echo
fi
test "$ac_signal" != 0 &&
$as_echo "$as_me: caught signal $ac_signal"
$as_echo "$as_me: exit $exit_status"
} >&5
rm -f core *.core core.conftest.* &&
rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
done
ac_signal=0
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -f -r conftest* confdefs.h
$as_echo "/* confdefs.h */" > confdefs.h
# Predefined preprocessor variables.
cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_VERSION "$PACKAGE_VERSION"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_STRING "$PACKAGE_STRING"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define PACKAGE_URL "$PACKAGE_URL"
_ACEOF
# Let the site file select an alternate cache file if it wants to.
# Prefer an explicitly selected file to automatically selected ones.
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
ac_site_file1=$CONFIG_SITE
elif test "x$prefix" != xNONE; then
ac_site_file1=$prefix/share/config.site
ac_site_file2=$prefix/etc/config.site
else
ac_site_file1=$ac_default_prefix/share/config.site
ac_site_file2=$ac_default_prefix/etc/config.site
fi
for ac_site_file in "$ac_site_file1" "$ac_site_file2"
do
test "x$ac_site_file" = xNONE && continue
if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
sed 's/^/| /' "$ac_site_file" >&5
. "$ac_site_file"
fi
done
if test -r "$cache_file"; then
# Some versions of bash will fail to source /dev/null (special files
# actually), so we avoid doing that. DJGPP emulates it as a regular file.
if test /dev/null != "$cache_file" && test -f "$cache_file"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
$as_echo "$as_me: loading cache $cache_file" >&6;}
case $cache_file in
[\\/]* | ?:[\\/]* ) . "$cache_file";;
*) . "./$cache_file";;
esac
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
$as_echo "$as_me: creating cache $cache_file" >&6;}
>$cache_file
fi
# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in $ac_precious_vars; do
eval ac_old_set=\$ac_cv_env_${ac_var}_set
eval ac_new_set=\$ac_env_${ac_var}_set
eval ac_old_val=\$ac_cv_env_${ac_var}_value
eval ac_new_val=\$ac_env_${ac_var}_value
case $ac_old_set,$ac_new_set in
set,)
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
ac_cache_corrupted=: ;;
,set)
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
ac_cache_corrupted=: ;;
,);;
*)
if test "x$ac_old_val" != "x$ac_new_val"; then
# differences in whitespace do not lead to failure.
ac_old_val_w=`echo x $ac_old_val`
ac_new_val_w=`echo x $ac_new_val`
if test "$ac_old_val_w" != "$ac_new_val_w"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
ac_cache_corrupted=:
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
eval $ac_var=\$ac_old_val
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
fi;;
esac
# Pass precious variables to config.status.
if test "$ac_new_set" = set; then
case $ac_new_val in
*\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
*) ac_arg=$ac_var=$ac_new_val ;;
esac
case " $ac_configure_args " in
*" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
*) as_fn_append ac_configure_args " '$ac_arg'" ;;
esac
fi
done
if $ac_cache_corrupted; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
fi
## -------------------- ##
## Main body of script. ##
## -------------------- ##
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_config_headers="$ac_config_headers config.h"
mycflags="$CFLAGS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
else
CC="$ac_cv_prog_CC"
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
ac_prog_rejected=no
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
fi
ac_cv_prog_CC="cc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
if test $ac_prog_rejected = yes; then
# We found a bogon in the path, so make sure we never use it.
set dummy $ac_cv_prog_CC
shift
if test $# != 0; then
# We chose a different compiler from the bogus one.
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
for ac_prog in cl.exe
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CC+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in cl.exe
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$ac_ct_CC" && break
done
if test "x$ac_ct_CC" = x; then
CC=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CC=$ac_ct_CC
fi
fi
fi
test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "no acceptable C compiler found in \$PATH
See \`config.log' for more details." "$LINENO" 5; }
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
for ac_option in --version -v -V -qversion; do
{ { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compiler $ac_option >&5") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
sed '10a\
... rest of stderr output deleted ...
10q' conftest.err >conftest.er1
cat conftest.er1 >&5
fi
rm -f conftest.er1 conftest.err
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
done
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
$as_echo_n "checking whether the C compiler works... " >&6; }
ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
# The possible output files:
ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
ac_rmfiles=
for ac_file in $ac_files
do
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
* ) ac_rmfiles="$ac_rmfiles $ac_file";;
esac
done
rm -f $ac_rmfiles
if { { ac_try="$ac_link_default"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link_default") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then :
# Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
# in a Makefile. We should not override ac_cv_exeext if it was cached,
# so that the user can short-circuit this test for compilers unknown to
# Autoconf.
for ac_file in $ac_files ''
do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
;;
[ab].out )
# We found the default executable, but exeext='' is most
# certainly right.
break;;
*.* )
if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
then :; else
ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
fi
# We set ac_cv_exeext here because the later test for it is not
# safe: cross compilers may not add the suffix if given an `-o'
# argument, so we may need to know it at that point already.
# Even if this section looks crufty: it has the advantage of
# actually working.
break;;
* )
break;;
esac
done
test "$ac_cv_exeext" = no && ac_cv_exeext=
else
ac_file=''
fi
if test -z "$ac_file"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ as_fn_set_status 77
as_fn_error "C compiler cannot create executables
See \`config.log' for more details." "$LINENO" 5; }; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
$as_echo_n "checking for C compiler default output file name... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
ac_exeext=$ac_cv_exeext
rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
$as_echo_n "checking for suffix of executables... " >&6; }
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then :
# If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in conftest.exe conftest conftest.*; do
test -f "$ac_file" || continue
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
*.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
break;;
* ) break;;
esac
done
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details." "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
$as_echo "$ac_cv_exeext" >&6; }
rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
int
main ()
{
FILE *f = fopen ("conftest.out", "w");
return ferror (f) || fclose (f) != 0;
;
return 0;
}
_ACEOF
ac_clean_files="$ac_clean_files conftest.out"
# Check that the compiler produces executables we can run. If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
$as_echo_n "checking whether we are cross compiling... " >&6; }
if test "$cross_compiling" != yes; then
{ { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
if { ac_try='./conftest$ac_cv_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then
cross_compiling=no
else
if test "$cross_compiling" = maybe; then
cross_compiling=yes
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details." "$LINENO" 5; }
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
$as_echo "$cross_compiling" >&6; }
rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
if test "${ac_cv_objext+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { { ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compile") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then :
for ac_file in conftest.o conftest.obj conftest.*; do
test -f "$ac_file" || continue;
case $ac_file in
*.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
*) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
break;;
esac
done
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "cannot compute suffix of object files: cannot compile
See \`config.log' for more details." "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
$as_echo "$ac_cv_objext" >&6; }
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
if test "${ac_cv_c_compiler_gnu+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_compiler_gnu=yes
else
ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
$as_echo "$ac_cv_c_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
GCC=yes
else
GCC=
fi
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
if test "${ac_cv_prog_cc_g+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
ac_cv_prog_cc_g=no
CFLAGS="-g"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_g=yes
else
CFLAGS=""
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
else
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="-g"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_g=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
$as_echo "$ac_cv_prog_cc_g" >&6; }
if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if test "${ac_cv_prog_cc_c89+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
#include
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
char **p;
int i;
{
return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
char *s;
va_list v;
va_start (v,p);
s = g (p, va_arg (v,int));
va_end (v);
return s;
}
/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
function prototypes and stuff, but not '\xHH' hex character constants.
These don't provoke an error unfortunately, instead are silently treated
as 'x'. The following induces an error, until -std is added to get
proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
array size at least. It's necessary to write '\x00'==0 to get something
that's true only with -std. */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];
/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
inside strings and character constants. */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
;
return 0;
}
_ACEOF
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_prog_cc_c89=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC
fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
x)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
xno)
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
*)
CC="$CC $ac_cv_prog_cc_c89"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
if test "x$ac_cv_prog_cc_c89" != xno; then :
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
if test -z "$CXX"; then
if test -n "$CCC"; then
CXX=$CCC
else
if test -n "$ac_tool_prefix"; then
for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_CXX+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CXX"; then
ac_cv_prog_CXX="$CXX" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
CXX=$ac_cv_prog_CXX
if test -n "$CXX"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
$as_echo "$CXX" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$CXX" && break
done
fi
if test -z "$CXX"; then
ac_ct_CXX=$CXX
for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CXX"; then
ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CXX="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
if test -n "$ac_ct_CXX"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
$as_echo "$ac_ct_CXX" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$ac_ct_CXX" && break
done
if test "x$ac_ct_CXX" = x; then
CXX="g++"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
CXX=$ac_ct_CXX
fi
fi
fi
fi
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
set X $ac_compile
ac_compiler=$2
for ac_option in --version -v -V -qversion; do
{ { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_compiler $ac_option >&5") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
sed '10a\
... rest of stderr output deleted ...
10q' conftest.err >conftest.er1
cat conftest.er1 >&5
fi
rm -f conftest.er1 conftest.err
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
if test "${ac_cv_cxx_compiler_gnu+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
ac_compiler_gnu=yes
else
ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
GXX=yes
else
GXX=
fi
ac_test_CXXFLAGS=${CXXFLAGS+set}
ac_save_CXXFLAGS=$CXXFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
$as_echo_n "checking whether $CXX accepts -g... " >&6; }
if test "${ac_cv_prog_cxx_g+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_cv_prog_cxx_g=no
CXXFLAGS="-g"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
ac_cv_prog_cxx_g=yes
else
CXXFLAGS=""
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
else
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="-g"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
ac_cv_prog_cxx_g=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cxx_werror_flag=$ac_save_cxx_werror_flag
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
$as_echo "$ac_cv_prog_cxx_g" >&6; }
if test "$ac_test_CXXFLAGS" = set; then
CXXFLAGS=$ac_save_CXXFLAGS
elif test $ac_cv_prog_cxx_g = yes; then
if test "$GXX" = yes; then
CXXFLAGS="-g -O2"
else
CXXFLAGS="-g"
fi
else
if test "$GXX" = yes; then
CXXFLAGS="-O2"
else
CXXFLAGS=
fi
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
for ac_prog in gawk mawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_AWK+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$AWK"; then
ac_cv_prog_AWK="$AWK" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_AWK="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
AWK=$ac_cv_prog_AWK
if test -n "$AWK"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
$as_echo "$AWK" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -n "$AWK" && break
done
# Check whether --enable-tabling was given.
if test "${enable_tabling+set}" = set; then :
enableval=$enable_tabling; tabling="$enableval"
else
tabling=no
fi
# Check whether --enable-or-parallelism was given.
if test "${enable_or_parallelism+set}" = set; then :
enableval=$enable_or_parallelism; orparallelism="$enableval"
else
orparallelism=no
fi
# Check whether --enable-rational-trees was given.
if test "${enable_rational_trees+set}" = set; then :
enableval=$enable_rational_trees; rationaltrees="$enableval"
else
rationaltrees=yes
fi
# Check whether --enable-coroutining was given.
if test "${enable_coroutining+set}" = set; then :
enableval=$enable_coroutining; rationaltrees="$enableval";coroutining="$enableval"
else
coroutining=yes
fi
# Check whether --enable-depth-limit was given.
if test "${enable_depth_limit+set}" = set; then :
enableval=$enable_depth_limit; depthlimit="$enableval"
else
depthlimit=yes
fi
# Check whether --enable-wam-profile was given.
if test "${enable_wam_profile+set}" = set; then :
enableval=$enable_wam_profile; wamprofile="$enableval"
else
wamprofile=no
fi
# Check whether --enable-low-level-tracer was given.
if test "${enable_low_level_tracer+set}" = set; then :
enableval=$enable_low_level_tracer; lowleveltracer="$enableval"
else
lowleveltracer=no
fi
# Check whether --enable-threads was given.
if test "${enable_threads+set}" = set; then :
enableval=$enable_threads; threads="$enableval"
else
threads=no
fi
# Check whether --enable-pthread-locking was given.
if test "${enable_pthread_locking+set}" = set; then :
enableval=$enable_pthread_locking; pthreadlocking="$enableval"
else
pthreadlocking=no
fi
# Check whether --enable-max-performance was given.
if test "${enable_max_performance+set}" = set; then :
enableval=$enable_max_performance; maxperformance="$enableval"
else
maxperformance=no
fi
# Check whether --enable-max-memory was given.
if test "${enable_max_memory+set}" = set; then :
enableval=$enable_max_memory; maxmemory="$enableval"
else
maxmemory=yes
fi
# Check whether --enable-debug-yap was given.
if test "${enable_debug_yap+set}" = set; then :
enableval=$enable_debug_yap; debugyap="$enableval"
else
debugyap=no
fi
# Check whether --enable-eam was given.
if test "${enable_eam+set}" = set; then :
enableval=$enable_eam; eam="$enableval"
else
eam=no
fi
# Check whether --enable-cygwin was given.
if test "${enable_cygwin+set}" = set; then :
enableval=$enable_cygwin; cygwin="$enableval"
else
cygwin=no
fi
# Check whether --enable-dynamic_loading was given.
if test "${enable_dynamic_loading+set}" = set; then :
enableval=$enable_dynamic_loading; dynamic_loading="$enableval"
else
dynamic_loading=no
fi
# Check whether --enable-static_compilation was given.
if test "${enable_static_compilation+set}" = set; then :
enableval=$enable_static_compilation; static_compilation="$enableval"
else
static_compilation=no
fi
# Check whether --enable-use-malloc was given.
if test "${enable_use_malloc+set}" = set; then :
enableval=$enable_use_malloc; use_malloc="$enableval"
else
use_malloc=no
fi
# Check whether --enable-condor was given.
if test "${enable_condor+set}" = set; then :
enableval=$enable_condor; use_condor="$enableval"
else
use_condor=no
fi
# Check whether --enable-chr was given.
if test "${enable_chr+set}" = set; then :
enableval=$enable_chr; use_chr="$enableval"
else
use_chr=yes
fi
# Check whether --enable-clpqr was given.
if test "${enable_clpqr+set}" = set; then :
enableval=$enable_clpqr; use_clpqr="$enableval"
else
use_clpqr=yes
fi
# Check whether --enable-win64 was given.
if test "${enable_win64+set}" = set; then :
enableval=$enable_win64; target_win64="$enableval"
else
target_win64=no
fi
# Check whether --enable-april was given.
if test "${enable_april+set}" = set; then :
enableval=$enable_april; use_april="$enableval"
else
use_april=no
fi
# Check whether --enable-dlcompat was given.
if test "${enable_dlcompat+set}" = set; then :
enableval=$enable_dlcompat; use_dlcompat="$enableval"
else
use_dlcompat=no
fi
# Check whether --enable-cplint was given.
if test "${enable_cplint+set}" = set; then :
enableval=$enable_cplint; yap_cv_cplint=$enableval
else
yap_cv_cplint=no
fi
# Check whether --with-gmp was given.
if test "${with_gmp+set}" = set; then :
withval=$with_gmp; if test "$withval" = yes; then
yap_cv_gmp=yes
elif test "$withval" = no; then
yap_cv_gmp=no
else
yap_cv_gmp=$with_gmp
LDFLAGS="$LDFLAGS -L${yap_cv_gmp}/lib"
LIBS="$LIBS -L${yap_cv_gmp}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_gmp}/include"
CFLAGS="$CFLAGS -I${yap_cv_gmp}/include"
fi
else
yap_cv_gmp=yes
fi
# Check whether --with-minisat was given.
if test "${with_minisat+set}" = set; then :
withval=$with_minisat; if test "$withval" = yes; then
yap_cv_minisat=yes
elif test "$withval" = no; then
yap_cv_minisat=no
else
yap_cv_minisat="$GXX"
fi
else
yap_cv_minisat=yes
fi
# Check whether --with-cudd was given.
if test "${with_cudd+set}" = set; then :
withval=$with_cudd; if test "$withval" = yes; then
yap_cv_cudd=yes
elif test "$withval" = no; then
yap_cv_cudd=no
elif test "$withval" = /opt/local; then
yap_cv_cudd=$with_cudd
CUDD_LDFLAGS="-L/opt/local/lib/cudd -lcudd"
CUDD_CPPFLAGS="-I /opt/local/include/cudd"
elif test "$withval" = /usr; then
yap_cv_cudd=$with_cudd
CUDD_LDFLAGS="-lcudd -lmtr -lcuddst -lcuddutil -lepd"
CUDD_CPPFLAGS="-I /usr/include/cudd"
else
yap_cv_cudd=$with_cudd
CUDD_LDFLAGS="$yap_cv_cudd/cudd/libcudd.a $yap_cv_cudd/mtr/libmtr.a $yap_cv_cudd/st/libst.a $yap_cv_cudd/util/libutil.a $yap_cv_cudd/epd/libepd.a"
CUDD_CPPFLAGS="-I $yap_cv_cudd/include"
fi
else
yap_cv_cudd=no
fi
# Check whether --enable-myddas was given.
if test "${enable_myddas+set}" = set; then :
enableval=$enable_myddas; if test "$enableval" = yes; then
yap_cv_myddas=/usr
elif test "$enableval" = no; then
yap_cv_myddas=no
else
yap_cv_myddas=$enable_myddas
LDFLAGS="$LDFLAGS -L${yap_cv_myddas}/lib "
CPPFLAGS="$CPPFLAGS -I${yap_cv_myddas}/include "
fi
else
yap_cv_myddas=/usr
fi
# Check whether --enable-myddas-stats was given.
if test "${enable_myddas_stats+set}" = set; then :
enableval=$enable_myddas_stats; if test "$yap_cv_myddas" = no; then
myddasstats=no
else
myddasstats="$enableval"
fi
else
myddasstats=no
fi
# Check whether --enable-myddas-top-level was given.
if test "${enable_myddas_top_level+set}" = set; then :
enableval=$enable_myddas_top_level; if test "$yap_cv_myddas" = no; then
myddastoplevel=no
else
myddastoplevel="$enableval"
fi
else
myddastoplevel=no
fi
# Check whether --with-java was given.
if test "${with_java+set}" = set; then :
withval=$with_java; if test "$withval" = yes; then
yap_cv_java="$JAVA_HOME"
dynamic_loading=yes
maxmemory=yes
elif test "$withval" = no; then
yap_cv_java=no
else
yap_cv_java=$with_java
dynamic_loading=yes
maxmemory=yes
fi
else
yap_cv_java=no
fi
# Check whether --with-readline was given.
if test "${with_readline+set}" = set; then :
withval=$with_readline; if test "$withval" = yes; then
yap_cv_readline=yes
elif test "$withval" = no; then
yap_cv_readline=no
else
yap_cv_readline=$with_readline
LDFLAGS="$LDFLAGS -L${yap_cv_readline}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_readline}/include"
fi
else
yap_cv_readline=yes
fi
# Check whether --with-matlab was given.
if test "${with_matlab+set}" = set; then :
withval=$with_matlab; if test "$withval" = yes; then
yap_cv_matlab=yes
elif test "$withval" = no; then
yap_cv_matlab=no
else
yap_cv_matlab=$with_matlab
MATLAB_INCLUDE="-I${yap_cv_matlab}/extern/include"
fi
else
yap_cv_matlab=no
fi
# Check whether --with-mpi was given.
if test "${with_mpi+set}" = set; then :
withval=$with_mpi; if test "$withval" = yes; then
yap_cv_mpi=yes
elif test "$withval" = no; then
yap_cv_mpi=no
else
yap_cv_mpi=$with_mpi
LDFLAGS="$LDFLAGS -L${yap_cv_mpi}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_mpi}/include"
fi
else
yap_cv_mpi=no
fi
# Check whether --with-mpe was given.
if test "${with_mpe+set}" = set; then :
withval=$with_mpe; if test "$withval" = yes; then
yap_cv_mpe=yes
elif test "$withval" = no; then
yap_cv_mpe=no
else
yap_cv_mpe=$with_mpe
LDFLAGS="$LDFLAGS -L${yap_cv_mpe}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_mpe}/include"
fi
else
yap_cv_mpe=no
fi
# Check whether --with-lam was given.
if test "${with_lam+set}" = set; then :
withval=$with_lam; if test "$withval" = yes; then
yap_cv_lam=yes
elif test "$withval" = no; then
yap_cv_lam=no
else
yap_cv_lam=$with_lam
LDFLAGS="$LDFLAGS -L${yap_cv_lam}/lib/lam"
CPPFLAGS="$CPPFLAGS -I${yap_cv_lam}/include"
fi
else
yap_cv_lam=no
fi
# Check whether --with-heap-space was given.
if test "${with_heap_space+set}" = set; then :
withval=$with_heap_space; if test "$withval" = yes; then
yap_cv_heap_space=0
elif test "$withval" = no; then
yap_cv_heap_space=0
else
yap_cv_heap_space=$withval
fi
else
yap_cv_heap_space=0
fi
# Check whether --with-stack-space was given.
if test "${with_stack_space+set}" = set; then :
withval=$with_stack_space; if test "$withval" = yes; then
yap_cv_stack_space=0
elif test "$withval" = no; then
yap_cv_stack_space=0
else
yap_cv_stack_space=$withval
fi
else
yap_cv_stack_space=0
fi
# Check whether --with-trail-space was given.
if test "${with_trail_space+set}" = set; then :
withval=$with_trail_space; if test "$withval" = yes; then
yap_cv_trail_space=0
elif test "$withval" = no; then
yap_cv_trail_space=0
else
yap_cv_trail_space=$withval
fi
else
yap_cv_trail_space=0
fi
# Check whether --with-max-workers was given.
if test "${with_max_workers+set}" = set; then :
withval=$with_max_workers; if test "$withval" = yes; then
yap_cv_max_workers="(8*SIZEOF_INT_P)"
elif test "$withval" = no; then
yap_cv_max_workers="1"
else
yap_cv_max_workers=$withval
fi
else
yap_cv_max_workers="(8*SIZEOF_INT_P)"
fi
# Check whether --with-max-threads was given.
if test "${with_max_threads+set}" = set; then :
withval=$with_max_threads; if test "$withval" = yes; then
yap_cv_max_threads="1024"
elif test "$withval" = no; then
yap_cv_max_threads="1"
else
yap_cv_max_threads=$withval
fi
else
yap_cv_max_threads="1024"
fi
# Check whether --with-junit was given.
if test "${with_junit+set}" = set; then :
withval=$with_junit; case "$withval" in
yes) JUNIT=/usr/share/java/junit.jar
;;
no) JUNIT=""
;;
*) JUNIT="$withval"
;;
esac
fi
$as_echo "#define MinHeapSpace (1000*SIZEOF_INT_P)" >>confdefs.h
$as_echo "#define MinStackSpace (300*SIZEOF_INT_P)" >>confdefs.h
$as_echo "#define MinTrailSpace ( 48*SIZEOF_INT_P)" >>confdefs.h
cat >>confdefs.h <<_ACEOF
#define DefHeapSpace $yap_cv_heap_space
_ACEOF
cat >>confdefs.h <<_ACEOF
#define DefStackSpace $yap_cv_stack_space
_ACEOF
cat >>confdefs.h <<_ACEOF
#define DefTrailSpace $yap_cv_trail_space
_ACEOF
ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
for ac_t in install-sh install.sh shtool; do
if test -f "$ac_dir/$ac_t"; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/$ac_t -c"
break 2
fi
done
done
if test -z "$ac_aux_dir"; then
as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
fi
# These three variables are undocumented and unsupported,
# and are intended to be withdrawn in a future Autoconf release.
# They can cause serious problems if a builder's source tree is in a directory
# whose full name contains unusual characters.
ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
$as_echo_n "checking build system type... " >&6; }
if test "${ac_cv_build+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_build_alias=$build_alias
test "x$ac_build_alias" = x &&
ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
test "x$ac_build_alias" = x &&
as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
$as_echo "$ac_cv_build" >&6; }
case $ac_cv_build in
*-*-*) ;;
*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_build
shift
build_cpu=$1
build_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
build_os=$*
IFS=$ac_save_IFS
case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
$as_echo_n "checking host system type... " >&6; }
if test "${ac_cv_host+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test "x$host_alias" = x; then
ac_cv_host=$ac_cv_build
else
ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
$as_echo "$ac_cv_host" >&6; }
case $ac_cv_host in
*-*-*) ;;
*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
esac
host=$ac_cv_host
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_host
shift
host_cpu=$1
host_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
host_os=$*
IFS=$ac_save_IFS
case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
$as_echo_n "checking target system type... " >&6; }
if test "${ac_cv_target+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test "x$target_alias" = x; then
ac_cv_target=$ac_cv_host
else
ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
as_fn_error "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
$as_echo "$ac_cv_target" >&6; }
case $ac_cv_target in
*-*-*) ;;
*) as_fn_error "invalid value of canonical target" "$LINENO" 5;;
esac
target=$ac_cv_target
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_target
shift
target_cpu=$1
target_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
target_os=$*
IFS=$ac_save_IFS
case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
# The aliases save the names the user supplied, while $host etc.
# will get canonicalized.
test -n "$target_alias" &&
test "$program_prefix$program_suffix$program_transform_name" = \
NONENONEs,x,x, &&
program_prefix=${target_alias}-
cat >>confdefs.h <<_ACEOF
#define HOST_ALIAS "${target}"
_ACEOF
if test "$or-parallelism" = no
then
$as_echo "#define MAX_WORKERS 1" >>confdefs.h
else
cat >>confdefs.h <<_ACEOF
#define MAX_WORKERS $yap_cv_max_workers
_ACEOF
fi
if test "$threads" = no
then
$as_echo "#define MAX_THREADS 1" >>confdefs.h
else
cat >>confdefs.h <<_ACEOF
#define MAX_THREADS $yap_cv_max_threads
_ACEOF
fi
if test "$yap_cv_matlab" = no
then
INSTALL_MATLAB="@# "
elif test "$yap_cv_matlab" = yes
then
INSTALL_MATLAB=""
else
case "$target_cpu" in
i*86*)
LDFLAGS="$LDFLAGS -L${yap_cv_matlab}/bin/glnx86"
;;
x86*)
LDFLAGS="$LDFLAGS -L${yap_cv_matlab}/bin/glnxa64"
;;
sparc*)
LDFLAGS="$LDFLAGS -L${yap_cv_matlab}/bin/sol2"
;;
esac
INSTALL_MATLAB=""
fi
if test "$yap_cv_cudd" = no
then
USE_CUDD="@# "
else
USE_CUDD=""
fi
if test "$use_condor" = yes
then
static_compilation="yes"
use_malloc="yes"
CC="condor_compile $CC"
CXX="condor_compile $CXX"
yap_cv_readline="no"
$as_echo "#define SUPPORT_CONDOR 1" >>confdefs.h
yap_cv_minisat=no
STATIC_MODE=""
else
static_compilation="no"
STATIC_MODE="# "
fi
if test "$yap_cv_minisat" = no
then
USE_MINISAT="@# "
elif test "$INSTALL_DLLS" = "#"
then
USE_MINISAT="@# "
else
USE_MINISAT=""
fi
if test "$GCC" = "yes"
then
if test "$debugyap" = "yes"
then
CXXFLAGS="-O -g -Wall $CFLAGS"
C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
else
CXXFLAGS="-O3 -fomit-frame-pointer -Wall $CFLAGS"
C_INTERF_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
C_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
CFLAGS="-O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
case "`$CC --version < /dev/null`" in
*3.4*) CFLAGS="-fno-gcse -fno-crossjumping $CFLAGS" ;;
esac
case "$target_cpu" in
i*86*)
CFLAGS="-DBP_FREE $CFLAGS"
CXXFLAGS="-DBP_FREE $CXXFLAGS"
;;
sparc*)
case "$target_os" in
*solaris2-9*) CFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFLAGS"
CXXFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFPPLAGS"
;;
esac
;;
esac
if test "$tcpu"; then
target_cpu=$tcpu
fi
if test "$maxperformance" = "yes"
then
case "$target_cpu" in
athlon)
CFLAGS="-march=athlon $CFLAGS"
CXXFLAGS="-march=athlon $CXXFLAGS"
;;
i686*)
CFLAGS="-march=i686 $CFLAGS"
CXXFLAGS="-march=i686 $CXXFLAGS"
;;
i586*)
CFLAGS="-march=i586 $CFLAGS"
CXXFLAGS="-march=i586 $CXXFLAGS"
;;
i486*)
CFLAGS="-march=i486 $CFLAGS"
CXXFLAGS="-march=i486 $CXXFLAGS"
;;
i386*)
CFLAGS="-march=i386 $CFLAGS"
CXXFLAGS="-march=i386 $CXXFLAGS"
;;
esac
fi
fi
if test "$CC" = "sslittle-na-sstrix-gcc"
then
RANLIB="sslittle-na-sstrix-ranlib"
AR="sslittle-na-sstrix-ar"
PRE_INSTALL_ENV="sim-fast"
INSTALL_ENV="sim-fast"
fi
else
case "$target_cpu" in
i?86*)
if test "$CC" = "lcc"
then
CFLAGS="-A -A $CFLAGS"
elif test "$CC" = "cl"
then
CXXFLAGS="-/nologo $CFLAGS"
CFLAGS="/nologo $CFLAGS"
CPP="/nologo /E"
fi
;;
hppa*)
if test "$CC" = "cc" -o $CC = c89
then
if test "$debugyap" = "yes"
then
CXXFLAGS="-Ae -g -O $CFLAGS"
CFLAGS="-Ae -g -O $CFLAGS"
else
CXXFLAGS="-Ae +O3 +Onolimit $CFLAGS"
CFLAGS="-Ae +O3 +Onolimit $CFLAGS"
fi
fi
;;
esac
C_INTERF_FLAGS="$CFLAGS"
C_PARSER_FLAGS="$CFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
$as_echo_n "checking whether ln -s works... " >&6; }
LN_S=$as_ln_s
if test "$LN_S" = "ln -s"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
$as_echo "no, using $LN_S" >&6; }
fi
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AmigaOS /C/install, which installs bootblocks on floppy discs
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
# Reject install programs that cannot install multiple files.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
$as_echo_n "checking for a BSD-compatible install... " >&6; }
if test -z "$INSTALL"; then
if test "${ac_cv_path_install+set}" = set; then :
$as_echo_n "(cached) " >&6
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
# Account for people who put trailing slashes in PATH elements.
case $as_dir/ in #((
./ | .// | /[cC]/* | \
/etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
/usr/ucb/* ) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
# Don't use installbsd from OSF since it installs stuff as root
# by default.
for ac_prog in ginstall scoinst install; do
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
if test $ac_prog = install &&
grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
:
elif test $ac_prog = install &&
grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# program-specific install script used by HP pwplus--don't use.
:
else
rm -rf conftest.one conftest.two conftest.dir
echo one > conftest.one
echo two > conftest.two
mkdir conftest.dir
if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
test -s conftest.one && test -s conftest.two &&
test -s conftest.dir/conftest.one &&
test -s conftest.dir/conftest.two
then
ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
break 3
fi
fi
fi
done
done
;;
esac
done
IFS=$as_save_IFS
rm -rf conftest.one conftest.two conftest.dir
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL=$ac_cv_path_install
else
# As a last resort, use the slow shell script. Don't cache a
# value for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
# removed, or if the value is a relative name.
INSTALL=$ac_install_sh
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
$as_echo "$INSTALL" >&6; }
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_RANLIB+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
RANLIB=$ac_cv_prog_RANLIB
if test -n "$RANLIB"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
$as_echo "$RANLIB" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_RANLIB"; then
ac_ct_RANLIB=$RANLIB
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_RANLIB"; then
ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_RANLIB="ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
if test -n "$ac_ct_RANLIB"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
$as_echo "$ac_ct_RANLIB" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_RANLIB" = x; then
RANLIB=":"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
RANLIB=$ac_ct_RANLIB
fi
else
RANLIB="$ac_cv_prog_RANLIB"
fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}indent", so it can be a program name with args.
set dummy ${ac_tool_prefix}indent; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_INDENT+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$INDENT"; then
ac_cv_prog_INDENT="$INDENT" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_INDENT="${ac_tool_prefix}indent"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
INDENT=$ac_cv_prog_INDENT
if test -n "$INDENT"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INDENT" >&5
$as_echo "$INDENT" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_INDENT"; then
ac_ct_INDENT=$INDENT
# Extract the first word of "indent", so it can be a program name with args.
set dummy indent; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_INDENT+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_INDENT"; then
ac_cv_prog_ac_ct_INDENT="$ac_ct_INDENT" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_INDENT="indent"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_INDENT=$ac_cv_prog_ac_ct_INDENT
if test -n "$ac_ct_INDENT"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_INDENT" >&5
$as_echo "$ac_ct_INDENT" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_INDENT" = x; then
INDENT=":"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
INDENT=$ac_ct_INDENT
fi
else
INDENT="$ac_cv_prog_INDENT"
fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_AR+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$AR"; then
ac_cv_prog_AR="$AR" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_AR="${ac_tool_prefix}ar"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
AR=$ac_cv_prog_AR
if test -n "$AR"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
$as_echo "$AR" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_AR"; then
ac_ct_AR=$AR
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_AR"; then
ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_AR="ar"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_AR=$ac_cv_prog_ac_ct_AR
if test -n "$ac_ct_AR"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
$as_echo "$ac_ct_AR" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_AR" = x; then
AR=":"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
AR=$ac_ct_AR
fi
else
AR="$ac_cv_prog_AR"
fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}mpicc", so it can be a program name with args.
set dummy ${ac_tool_prefix}mpicc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_MPI_CC+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$MPI_CC"; then
ac_cv_prog_MPI_CC="$MPI_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_MPI_CC="${ac_tool_prefix}mpicc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
MPI_CC=$ac_cv_prog_MPI_CC
if test -n "$MPI_CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MPI_CC" >&5
$as_echo "$MPI_CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_MPI_CC"; then
ac_ct_MPI_CC=$MPI_CC
# Extract the first word of "mpicc", so it can be a program name with args.
set dummy mpicc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_prog_ac_ct_MPI_CC+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_MPI_CC"; then
ac_cv_prog_ac_ct_MPI_CC="$ac_ct_MPI_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_MPI_CC="mpicc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_MPI_CC=$ac_cv_prog_ac_ct_MPI_CC
if test -n "$ac_ct_MPI_CC"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MPI_CC" >&5
$as_echo "$ac_ct_MPI_CC" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_ct_MPI_CC" = x; then
MPI_CC=":"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
MPI_CC=$ac_ct_MPI_CC
fi
else
MPI_CC="$ac_cv_prog_MPI_CC"
fi
# Extract the first word of "install-info", so it can be a program name with args.
set dummy install-info; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_INSTALL_INFO+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $INSTALL_INFO in
[\\/]* | ?:[\\/]*)
ac_cv_path_INSTALL_INFO="$INSTALL_INFO" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
as_dummy="$PATH:/sbin:/usr/sbin:/usr/etc:/usr/local/sbin"
for as_dir in $as_dummy
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_INSTALL_INFO="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_INSTALL_INFO" && ac_cv_path_INSTALL_INFO="true"
;;
esac
fi
INSTALL_INFO=$ac_cv_path_INSTALL_INFO
if test -n "$INSTALL_INFO"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL_INFO" >&5
$as_echo "$INSTALL_INFO" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
# Extract the first word of "sh", so it can be a program name with args.
set dummy sh; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_SHELL+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $SHELL in
[\\/]* | ?:[\\/]*)
ac_cv_path_SHELL="$SHELL" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_SHELL="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
SHELL=$ac_cv_path_SHELL
if test -n "$SHELL"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SHELL" >&5
$as_echo "$SHELL" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "$target_os" = "cygwin" -o "$target_os" = "mingw32"
then
INSTALL_COMMAND=install_win32
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
then
if test "$target_win64" = yes
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lws2_32" >&5
$as_echo_n "checking for main in -lws2_32... " >&6; }
if test "${ac_cv_lib_ws2_32_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lws2_32 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_ws2_32_main=yes
else
ac_cv_lib_ws2_32_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ws2_32_main" >&5
$as_echo "$ac_cv_lib_ws2_32_main" >&6; }
if test "x$ac_cv_lib_ws2_32_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBWS2_32 1
_ACEOF
LIBS="-lws2_32 $LIBS"
fi
EXTRA_LIBS_FOR_DLLS="-lws2_32 \$(abs_top_builddir)/yap.dll"
elif test "$target_os" = "cygwin"
then
CC="${CC} -mno-cygwin"
CXX="${CXX} -mno-cygwin"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lwsock32" >&5
$as_echo_n "checking for main in -lwsock32... " >&6; }
if test "${ac_cv_lib_wsock32_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lwsock32 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_wsock32_main=yes
else
ac_cv_lib_wsock32_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_wsock32_main" >&5
$as_echo "$ac_cv_lib_wsock32_main" >&6; }
if test "x$ac_cv_lib_wsock32_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBWSOCK32 1
_ACEOF
LIBS="-lwsock32 $LIBS"
fi
EXTRA_LIBS_FOR_DLLS="\$(abs_top_builddir)/yap.dll"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lwsock32" >&5
$as_echo_n "checking for main in -lwsock32... " >&6; }
if test "${ac_cv_lib_wsock32_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lwsock32 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_wsock32_main=yes
else
ac_cv_lib_wsock32_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_wsock32_main" >&5
$as_echo "$ac_cv_lib_wsock32_main" >&6; }
if test "x$ac_cv_lib_wsock32_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBWSOCK32 1
_ACEOF
LIBS="-lwsock32 $LIBS"
fi
EXTRA_LIBS_FOR_DLLS="\$(abs_top_builddir)/yap.dll"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpsapi" >&5
$as_echo_n "checking for main in -lpsapi... " >&6; }
if test "${ac_cv_lib_psapi_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpsapi $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_psapi_main=yes
else
ac_cv_lib_psapi_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_psapi_main" >&5
$as_echo "$ac_cv_lib_psapi_main" >&6; }
if test "x$ac_cv_lib_psapi_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPSAPI 1
_ACEOF
LIBS="-lpsapi $LIBS"
fi
yap_cv_readline=no
if test "$target_win64" = yes
CLIB_NETLIBS="-lws2_32 -lpsapi -lgdi32"
then
CLIB_NETLIBS="-lwsock32 -lpsapi -lgdi32"
fi
if test "$prefix" = "NONE"
then
if test "$target_win64" = yes
then
prefix="\${SYSTEMDRIVE}/Yap64"
CLIB_NETLIBS="-lwsock32 -lpsapi -lgdi32"
else
prefix="\${SYSTEMDRIVE}/Yap"
fi
fi
ENABLE_WINCONSOLE=""
else
ENABLE_WINCONSOLE="#"
LIBS="-lcygwin"
EXTRA_LIBS_FOR_DLLS="\$(abs_top_builddir)/yap.dll"
fi
else
INSTALL_COMMAND="install_unix"
ENABLE_WINCONSOLE="#"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sin in -lm" >&5
$as_echo_n "checking for sin in -lm... " >&6; }
if test "${ac_cv_lib_m_sin+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lm $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sin ();
int
main ()
{
return sin ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_m_sin=yes
else
ac_cv_lib_m_sin=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_sin" >&5
$as_echo "$ac_cv_lib_m_sin" >&6; }
if test "x$ac_cv_lib_m_sin" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBM 1
_ACEOF
LIBS="-lm $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5
$as_echo_n "checking for socket in -lsocket... " >&6; }
if test "${ac_cv_lib_socket_socket+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char socket ();
int
main ()
{
return socket ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_socket_socket=yes
else
ac_cv_lib_socket_socket=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5
$as_echo "$ac_cv_lib_socket_socket" >&6; }
if test "x$ac_cv_lib_socket_socket" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBSOCKET 1
_ACEOF
LIBS="-lsocket $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for getsockname in -lxnet" >&5
$as_echo_n "checking for getsockname in -lxnet... " >&6; }
if test "${ac_cv_lib_xnet_getsockname+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lxnet $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char getsockname ();
int
main ()
{
return getsockname ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_xnet_getsockname=yes
else
ac_cv_lib_xnet_getsockname=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xnet_getsockname" >&5
$as_echo "$ac_cv_lib_xnet_getsockname" >&6; }
if test "x$ac_cv_lib_xnet_getsockname" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBXNET 1
_ACEOF
LIBS="-lxnet $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lstdc++" >&5
$as_echo_n "checking for main in -lstdc++... " >&6; }
if test "${ac_cv_lib_stdcpp_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lstdc++ $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_stdcpp_main=yes
else
ac_cv_lib_stdcpp_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_stdcpp_main" >&5
$as_echo "$ac_cv_lib_stdcpp_main" >&6; }
if test "x$ac_cv_lib_stdcpp_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBSTDC__ 1
_ACEOF
LIBS="-lstdc++ $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnsl" >&5
$as_echo_n "checking for main in -lnsl... " >&6; }
if test "${ac_cv_lib_nsl_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nsl_main=yes
else
ac_cv_lib_nsl_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_main" >&5
$as_echo "$ac_cv_lib_nsl_main" >&6; }
if test "x$ac_cv_lib_nsl_main" = x""yes; then :
have_nsl=yes
else
have_nsl=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lcrypt" >&5
$as_echo_n "checking for main in -lcrypt... " >&6; }
if test "${ac_cv_lib_crypt_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcrypt $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_crypt_main=yes
else
ac_cv_lib_crypt_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_main" >&5
$as_echo "$ac_cv_lib_crypt_main" >&6; }
if test "x$ac_cv_lib_crypt_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCRYPT 1
_ACEOF
LIBS="-lcrypt $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnss_files" >&5
$as_echo_n "checking for main in -lnss_files... " >&6; }
if test "${ac_cv_lib_nss_files_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnss_files $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nss_files_main=yes
else
ac_cv_lib_nss_files_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nss_files_main" >&5
$as_echo "$ac_cv_lib_nss_files_main" >&6; }
if test "x$ac_cv_lib_nss_files_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBNSS_FILES 1
_ACEOF
LIBS="-lnss_files $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnss_dns" >&5
$as_echo_n "checking for main in -lnss_dns... " >&6; }
if test "${ac_cv_lib_nss_dns_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnss_dns $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nss_dns_main=yes
else
ac_cv_lib_nss_dns_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nss_dns_main" >&5
$as_echo "$ac_cv_lib_nss_dns_main" >&6; }
if test "x$ac_cv_lib_nss_dns_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBNSS_DNS 1
_ACEOF
LIBS="-lnss_dns $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lresolv" >&5
$as_echo_n "checking for main in -lresolv... " >&6; }
if test "${ac_cv_lib_resolv_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lresolv $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_resolv_main=yes
else
ac_cv_lib_resolv_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_main" >&5
$as_echo "$ac_cv_lib_resolv_main" >&6; }
if test "x$ac_cv_lib_resolv_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBRESOLV 1
_ACEOF
LIBS="-lresolv $LIBS"
fi
fi
if test "$yap_cv_readline" != "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lreadline" >&5
$as_echo_n "checking for main in -lreadline... " >&6; }
if test "${ac_cv_lib_readline_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lreadline -lncurses $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_readline_main=yes
else
ac_cv_lib_readline_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_main" >&5
$as_echo "$ac_cv_lib_readline_main" >&6; }
if test "x$ac_cv_lib_readline_main" = x""yes; then :
$as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h
LIBS="$LIBS -lreadline -lncurses"
else
if test "x$with_readline" != xcheck; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "--with-readline was given, but test for readline failed
See \`config.log' for more details." "$LINENO" 5; }
fi
fi
fi
if test "$yap_cv_gmp" != "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lgmp" >&5
$as_echo_n "checking for main in -lgmp... " >&6; }
if test "${ac_cv_lib_gmp_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lgmp $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_gmp_main=yes
else
ac_cv_lib_gmp_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gmp_main" >&5
$as_echo "$ac_cv_lib_gmp_main" >&6; }
if test "x$ac_cv_lib_gmp_main" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBGMP 1
_ACEOF
LIBS="-lgmp $LIBS"
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlibVersion in -lz" >&5
$as_echo_n "checking for zlibVersion in -lz... " >&6; }
if test "${ac_cv_lib_z_zlibVersion+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lz $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char zlibVersion ();
int
main ()
{
return zlibVersion ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_z_zlibVersion=yes
else
ac_cv_lib_z_zlibVersion=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_zlibVersion" >&5
$as_echo "$ac_cv_lib_z_zlibVersion" >&6; }
if test "x$ac_cv_lib_z_zlibVersion" = x""yes; then :
ZLIBS="-lz"
ZLIB=yes
else
ZLIB=no
fi
if test $ZLIB = yes
then
LIBS="$LIBS -lz"
fi
if test "$yap_cv_myddas" != "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lmysqlclient" >&5
$as_echo_n "checking for main in -lmysqlclient... " >&6; }
if test "${yap_cv_mysql+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
int
main ()
{
MYSQL *conn;
conn = mysql_init(NULL);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
yap_cv_mysql=yes
else
yap_cv_mysql=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_mysql" >&5
$as_echo "$yap_cv_mysql" >&6; }
if test "$yap_cv_mysql" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_MYSQL"
LIBS="$LIBS -L${yap_cv_myddas}/lib/mysql -lmysqlclient "
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lodbc" >&5
$as_echo_n "checking for main in -lodbc... " >&6; }
if test "${yap_cv_odbc+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
int
main ()
{
SQLHENV henv;
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
yap_cv_odbc=yes
else
yap_cv_odbc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_odbc" >&5
$as_echo "$yap_cv_odbc" >&6; }
if test "$yap_cv_odbc" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_ODBC"
case "$target_os" in
*darwin9*)
LIBS="$LIBS -lodbc -framework CoreFoundation"
;;
**)
LIBS="$LIBS -lodbc"
;;
esac
fi
fi
if test "$myddasstats" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_STATS"
fi
if test "$myddastoplevel" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_TOP_LEVEL"
fi
if test "$threads" = yes
then
$as_echo "#define SUPPORT_THREADS 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
$as_echo_n "checking for pthread_create in -lpthread... " >&6; }
if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char pthread_create ();
int
main ()
{
return pthread_create ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_pthread_pthread_create=yes
else
ac_cv_lib_pthread_pthread_create=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5
$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; }
if test "x$ac_cv_lib_pthread_pthread_create" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBPTHREAD 1
_ACEOF
LIBS="-lpthread $LIBS"
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if test "${ac_cv_prog_CPP+set}" = set; then :
$as_echo_n "(cached) " >&6
else
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
else
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
# Broken: success on invalid input.
continue
else
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
break
fi
done
ac_cv_prog_CPP=$CPP
fi
CPP=$ac_cv_prog_CPP
else
ac_cv_prog_CPP=$CPP
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
$as_echo "$CPP" >&6; }
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
else
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
# Broken: success on invalid input.
continue
else
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." "$LINENO" 5; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if test "${ac_cv_path_GREP+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
ac_path_GREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'GREP' >> "conftest.nl"
"$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_GREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_GREP="$ac_path_GREP"
ac_path_GREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_GREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_GREP"; then
as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_GREP=$GREP
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
GREP="$ac_cv_path_GREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if test "${ac_cv_path_EGREP+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
then ac_cv_path_EGREP="$GREP -E"
else
if test -z "$EGREP"; then
ac_path_EGREP_found=false
# Loop through the user's path and test for each of PROGNAME-LIST
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
ac_count=0
$as_echo_n 0123456789 >"conftest.in"
while :
do
cat "conftest.in" "conftest.in" >"conftest.tmp"
mv "conftest.tmp" "conftest.in"
cp "conftest.in" "conftest.nl"
$as_echo 'EGREP' >> "conftest.nl"
"$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
as_fn_arith $ac_count + 1 && ac_count=$as_val
if test $ac_count -gt ${ac_path_EGREP_max-0}; then
# Best one so far, save it but keep looking for a better one
ac_cv_path_EGREP="$ac_path_EGREP"
ac_path_EGREP_max=$ac_count
fi
# 10*(2^10) chars as input seems more than enough
test $ac_count -gt 10 && break
done
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac
$ac_path_EGREP_found && break 3
done
done
done
IFS=$as_save_IFS
if test -z "$ac_cv_path_EGREP"; then
as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
fi
else
ac_cv_path_EGREP=$EGREP
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
EGREP="$ac_cv_path_EGREP"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if test "${ac_cv_header_stdc+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
#include
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_stdc=yes
else
ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then :
:
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
else
ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then
$as_echo "#define STDC_HEADERS 1" >>confdefs.h
fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in pthread.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
if test "x$ac_cv_header_pthread_h" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_PTHREAD_H 1
_ACEOF
fi
done
for ac_func in pthread_mutexattr_setkind_np pthread_mutexattr_settype
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
if test "$pthreadlocking" = yes
then
$as_echo "#define USE_PTHREAD_LOCKING 1" >>confdefs.h
fi
use_malloc=yes
fi
if test ! -z "$GCC"; then
COFLAGS="${COFLAGS--O2 -cc-options,-fno-strict-aliasing}"
CWFLAGS="${CWFLAGS--Wall}"
else
COFLAGS="${COFLAGS--O}"
CWFLAGS="${CWFLAGS-}"
fi
CMFLAGS=-fpic
CIFLAGS=-I.
if test "$use_chr" = no; then
ENABLE_CHR="@# "
elif test -e "$srcdir"/packages/chr/Makefile.in; then
ENABLE_CHR=""
else
ENABLE_CHR="@# "
fi
if test "$use_clpqr" = no; then
ENABLE_CLPQR="@# "
elif test -e "$srcdir"/packages/clpqr/Makefile.in; then
ENABLE_CLPQR=""
else
ENABLE_CLPQR="@# "
fi
if test "$yap_cv_java" = no; then
ENABLE_JPL="@#"
elif test -e "$srcdir"/packages/jpl/Makefile.in; then
ENABLE_JPL=""
JAVA=java
JAVA_HOME="$yap_cv_java"
case "$target_os" in
*cygwin*|*mingw*)
if test $threads = yes; then
JAVALIBPATH="\"$JAVA_HOME\"/lib/jvm.lib -lpthread"
else
JAVALIBPATH="\"$JAVA_HOME\"/lib/jvm.lib"
fi
JAVAINCPATH="-I\"$JAVA_HOME\"/include -I\"$JAVA_HOME\"/include/win32"
;;
*darwin*)
LIBS="$LIBS -framework JavaVM"
JAVALIBPATH="-L/System/Library/Frameworks/JavaVM.framework/Libraries -Wl,-framework,JavaVM"
JAVAINCPATH="-I/System/Library/Frameworks/JavaVM.framework/Headers"
;;
*)
case "$target_os" in
*linux*)
JAVAINCPATH="-I\"$JAVA_HOME\"/include -I\"$JAVA_HOME\"/include/linux"
;;
*solaris*)
JAVAINCPATH="-I\"$JAVA_HOME\"/include -I\"$JAVA_HOME\"/include/solaris"
;;
esac
case "$target_cpu" in
i*86*)
JAVA_TARGET=i386
;;
x86*)
JAVA_TARGET=amd64
;;
sparc*)
JAVA_TARGET=sparc
;;
esac
JAVALIBPATH="-L$JAVA_HOME/jre/lib/$JAVA_TARGET -L$JAVA_HOME/jre/lib/$JAVA_TARGET/client -L$JAVA_HOME/jre/lib/$JAVA_TARGET/server -Wl,-R,$JAVA_HOME/jre/lib/$JAVA_TARGET -ljava -lverify -ljvm "
;;
esac
if test "$yap_cv_java" = ""; then
JAVA=java
JAR=jar
JAVAC=javac
JAVADOC=javadoc
else
JAVA="$yap_cv_java"/bin/java
JAR="$yap_cv_java"/bin/jar
JAVAC="$yap_cv_java"/bin/javac
JAVADOC="$yap_cv_java"/bin/javadoc
fi
else
ENABLE_JPL="@#"
fi
LAM_MPI_CC=${MPI_CC}
MPI_OBJS=
if test "$yap_cv_mpi" != "no"
then
OLD_CC=${CC}
CC=${MPI_CC}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPI_Init in -lmpi" >&5
$as_echo_n "checking for MPI_Init in -lmpi... " >&6; }
if test "${ac_cv_lib_mpi_MPI_Init+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmpi $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char MPI_Init ();
int
main ()
{
return MPI_Init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_mpi_MPI_Init=yes
else
ac_cv_lib_mpi_MPI_Init=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpi_MPI_Init" >&5
$as_echo "$ac_cv_lib_mpi_MPI_Init" >&6; }
if test "x$ac_cv_lib_mpi_MPI_Init" = x""yes; then :
$as_echo "#define HAVE_LIBMPI 1" >>confdefs.h
else
$as_echo "#define HAVE_LIBMPI 0" >>confdefs.h
fi
if test "$ac_cv_lib_mpi_MPI_Init" = yes
then
#YAPMPILIB=YapMPI.a
MPI_OBJS=mpi.o
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPI_Init in -lmpich" >&5
$as_echo_n "checking for MPI_Init in -lmpich... " >&6; }
if test "${ac_cv_lib_mpich_MPI_Init+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmpich $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char MPI_Init ();
int
main ()
{
return MPI_Init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_mpich_MPI_Init=yes
else
ac_cv_lib_mpich_MPI_Init=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpich_MPI_Init" >&5
$as_echo "$ac_cv_lib_mpich_MPI_Init" >&6; }
if test "x$ac_cv_lib_mpich_MPI_Init" = x""yes; then :
$as_echo "#define HAVE_LIBMPICH 1" >>confdefs.h
else
$as_echo "#define HAVE_LIBMPICH 0" >>confdefs.h
fi
if test "$ac_cv_lib_mpich_MPI_Init" = yes
then
#YAPMPILIB=YapMPI.a
MPI_OBJS=mpi.o
else
#YAPMPILIB=
MPI_CC=${CC}
fi
fi
CC=${OLD_CC}
else
# MPI_CC=${MPI_CC}
MPI_CC=${CC}
fi
MPI_LIBS=
if test "$yap_cv_mpi" != "no" -a "$yap_cv_mpe" != "no"
then
OLD_CC=${CC}
CC=${MPI_CC}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MPE_Init_log in -lmpe" >&5
$as_echo_n "checking for MPE_Init_log in -lmpe... " >&6; }
if test "${ac_cv_lib_mpe_MPE_Init_log+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmpe $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char MPE_Init_log ();
int
main ()
{
return MPE_Init_log ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_mpe_MPE_Init_log=yes
else
ac_cv_lib_mpe_MPE_Init_log=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpe_MPE_Init_log" >&5
$as_echo "$ac_cv_lib_mpe_MPE_Init_log" >&6; }
if test "x$ac_cv_lib_mpe_MPE_Init_log" = x""yes; then :
$as_echo "#define HAVE_LIBMPE 1" >>confdefs.h
else
$as_echo "#define HAVE_LIBMPE 0" >>confdefs.h
fi
if test "$ac_cv_lib_mpe_MPE_Init_log" = yes
then
MPI_LIBS="-lmpe"
MPI_OBJS="$MPI_OBJS mpe.o"
fi
CC=${OLD_CC}
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
if test "${ac_cv_prog_CPP+set}" = set; then :
$as_echo_n "(cached) " >&6
else
# Double quotes because CPP needs to be expanded
for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
do
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
else
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
# Broken: success on invalid input.
continue
else
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
break
fi
done
ac_cv_prog_CPP=$CPP
fi
CPP=$ac_cv_prog_CPP
else
ac_cv_prog_CPP=$CPP
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
$as_echo "$CPP" >&6; }
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
# Use a header file that comes with gcc, so configuring glibc
# with a fresh cross-compiler works.
# Prefer to if __STDC__ is defined, since
# exists even on freestanding compilers.
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. "Syntax error" is here to catch this case.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifdef __STDC__
# include
#else
# include
#endif
Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
else
# Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.$ac_ext
# OK, works on sane cases. Now check whether nonexistent headers
# can be detected and how.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
# Broken: success on invalid input.
continue
else
# Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.$ac_ext
done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details." "$LINENO" 5; }
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test "$cross_compiling" = "yes"
then
YAP_EXTRAS=
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5
$as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; }
if test "${ac_cv_header_sys_wait_h+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
int
main ()
{
int s;
wait (&s);
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_sys_wait_h=yes
else
ac_cv_header_sys_wait_h=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5
$as_echo "$ac_cv_header_sys_wait_h" >&6; }
if test $ac_cv_header_sys_wait_h = yes; then
$as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for restartable system calls" >&5
$as_echo_n "checking for restartable system calls... " >&6; }
if test "${ac_cv_sys_restartable_syscalls+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "cannot run test program while cross compiling
See \`config.log' for more details." "$LINENO" 5; }
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Exit 0 (true) if wait returns something other than -1,
i.e. the pid of the child, which means that wait was restarted
after getting the signal. */
$ac_includes_default
#include
#ifdef HAVE_SYS_WAIT_H
# include
#endif
/* Some platforms explicitly require an extern "C" signal handler
when using C++. */
#ifdef __cplusplus
extern "C" void ucatch (int dummy) { }
#else
void ucatch (dummy) int dummy; { }
#endif
int
main ()
{
int i = fork (), status;
if (i == 0)
{
sleep (3);
kill (getppid (), SIGINT);
sleep (3);
return 0;
}
signal (SIGINT, ucatch);
status = wait (&i);
if (status == -1)
wait (&i);
return status == -1;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ac_cv_sys_restartable_syscalls=yes
else
ac_cv_sys_restartable_syscalls=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_restartable_syscalls" >&5
$as_echo "$ac_cv_sys_restartable_syscalls" >&6; }
if test $ac_cv_sys_restartable_syscalls = yes; then
$as_echo "#define HAVE_RESTARTABLE_SYSCALLS 1" >>confdefs.h
fi
fi
INSTALL_DLLS="#"
EXTRA_OBJS=""
SHLIB_LD="#"
SHLIB_CXX_LD="#"
DO_SECOND_LD="#"
M4="m4"
MERGE_DLL_OBJS="#"
IN_UNIX=""
YAPLIB="libYap.a"
case "$target_os" in
*linux*)
if test "$static_compilation" = "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char dlopen ();
int
main ()
{
return dlopen ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_dl_dlopen=yes
else
ac_cv_lib_dl_dlopen=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
have_dl=yes
else
have_dl=no
fi
if test "$have_dl" = "yes"
then
SO="so"
SHLIB_LD="$CC -shared -export-dynamic"
SHLIB_CXX_LD="$CXX -shared -export-dynamic"
DO_SECOND_LD=""
LIBS="$LIBS -ldl"
case "$target_cpu" in
alpha*)
LDFLAGS="-dynamic $LDFLAGS"
;;
*)
if test "$CC" != "lcc"
then
LDFLAGS="-rdynamic $LDFLAGS"
fi
;;
esac
fi
if test "$ac_cv_c_compiler_gnu" = "yes"
then
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
INSTALL_DLLS=""
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG="-Wl,-soname=$DYNYAPLIB"
fi
if test "$have_nsl" = yes
then
LIBS="$LIBS -lnsl"
fi
if test "$dynamic_loading" = "yes"
then
YAPLIB_LD="\$(CC) -shared"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
else
YAPLIB_LD="\$(CC)"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
INSTALL_ENV="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
PRE_INSTALL_ENV=""
fi
;;
*sunos4*)
M4="/usr/5bin/m4"
LDFLAGS="$LDFLAGS -N"
if test "$have_nsl" = yes
then
LIBS="$LIBS -lnsl"
fi
SO="o"
INSTALL_DLLS=""
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*hpux*)
#do not use the first memory quadrant
$as_echo "#define FORCE_SECOND_QUADRANT 1" >>confdefs.h
M4="/usr/bin/m4"
if test ${use_condor} = no
then
SHLIB_INTERFACE="load_shl.o"
if test "$CC" = cc -o "$CC" = c89
then
#this tells ld to export all non-static symbols,
#otherwise no external predicates.
SHLIB_LD="$CC -shared -export-dynamic"
SHLIB_CXX_LD="$CXX -shared -export-dynamic"
DO_SECOND_LD=""
SO="sl"
SHLIB_CFLAGS="+z $CFLAGS"
SHLIB_CXXFLAGS="+z $CXXFLAGS"
INSTALL_DLLS=""
# If the xnet library was found, turn on X/Open networking
if test "$ac_cv_lib_xnet_getsockname" = yes
then
$as_echo "#define _XOPEN_SOURCE 1" >>confdefs.h
$as_echo "#define _XOPEN_SOURCE_EXTENDED 1" >>confdefs.h
fi
else
INSTALL_DLLS="#"
fi
fi
#do not use realloc() from HP-UX 10.20 together with MPI
if test ${target_os} = hpux10.20
then
$as_echo "#define MPI_AVOID_REALLOC 1" >>confdefs.h
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*aix*)
# To actually use dlls in AIX I'd need to build YAP as a DLL first.
# I won't bother for now.
#
# SO="a"
#SHLIB_LD="\$(srcdir)/../../ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
#INSTALL_DLLS=""
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*osf*)
if ${use_condor} = no
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char dlopen ();
int
main ()
{
return dlopen ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_dl_dlopen=yes
else
ac_cv_lib_dl_dlopen=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
have_dl=yes
else
have_dl=no
fi
SO="so"
SHLIB_LD="ld -shared -expect_unresolved '*'"
DO_SECOND_LD=""
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*irix6*)
SHLIB_CFLAGS="$CFLAGS"
SHLIB_CXXFLAGS="$CXXFLAGS"
SO="so"
DO_SECOND_LD=""
SHLIB_LD="ld -n32 -shared -rdata_shared"
SHLIB_CXX_LD="$SHLIB_LD"
INSTALL_DLLS=""
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*darwin*)
if test ${use_dlcompat} = yes
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char dlopen ();
int
main ()
{
return dlopen ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_dl_dlopen=yes
else
ac_cv_lib_dl_dlopen=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
have_dl=yes
else
have_dl=no
fi
if test ${have_dl} = yes
then
LIBS="$LIBS -ldl"
fi
fi
SO="dylib"
DO_SECOND_LD=""
if test "$dynamic_loading" = "yes"
then
SHLIB_LD="$CC -dynamiclib"
SHLIB_CXX_LD="$CXX -dynamiclib"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-install_name,\$(YAPLIBDIR)/\$@"
INSTALL_ENV="DYLD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
else
SHLIB_LD="$CC -dynamiclib -Wl,-undefined,dynamic_lookup"
SHLIB_CXX_LD="$CXX -dynamiclib -Wl,-undefined,dynamic_lookup"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -Wl,-install_name,\$(YAPLIBDIR)/\$@"
INSTALL_ENV="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
fi
if test "$ac_cv_c_compiler_gnu" = "yes"
then
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
INSTALL_DLLS=""
fi
CC="$CC -fstrict-aliasing -freorder-blocks -fsched-interblock -Wall -Wstrict-aliasing=2"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
YAPLIB_LD="$CC -dynamiclib -Wl,-install_name,$prefix/lib/libYap.$SO"
PRE_INSTALL_ENV="DYLD_LIBRARY_PATH=\$(abs_top_builddir)"
;;
*netbsd*|*openbsd*|*freebsd*|*dragonfly*)
if echo __ELF__ | ${CC:-cc} -E - | grep -q __ELF__
then
#an a.out system
SHLIB_CFLAGS="$CFLAGS"
SHLIB_CXXFLAGS="$CXXFLAGS"
SO="o"
else
#an elf system
LDFLAGS="-Wl,--export-dynamic $LDFLAGS"
SHLIB_CFLAGS="-fPIC $CFLAGS"
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
SHLIB_LD="$CC -shared -export-dynamic"
SHLIB_CXX_LD="$CXX -shared -export-dynamic"
DO_SECOND_LD=""
SO="so"
INSTALL_DLLS=""
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG="-Wl,--soname=$DYNYAPLIB"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -Wl,-R,\$(YAPLIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*solaris*)
#an elf system
LDFLAGS="-dynamic $LDFLAGS"
SHLIB_CFLAGS="-fPIC $CFLAGS"
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
SHLIB_LD="$CC -shared"
SHLIB_CXX_LD="$CXX -shared"
DO_SECOND_LD=""
SO="so"
INSTALL_DLLS=""
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG="-Wl,--soname=$DYNYAPLIB"
if test "$dynamic_loading" = "yes"
then
YAPLIB_LD="\$(CC)"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
else
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV=""
YAPLIB_LD="\$(CC) -shared"
INSTALL_ENV="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
fi
;;
*cyg*|*mingw*)
# gcc on cygwin seems to have trouble with longjmp
# and -fomit-frame-point -DBP_FREE
YAPLIB="yap.dll"
DYNYAPLIB="yap.dll"
SONAMEFLAG=""
SHLIB_CFLAGS="$CFLAGS"
SHLIB_CXXFLAGS="$CXXFLAGS"
if test "$target_win64" = no
then
LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
fi
SHLIB_LD="\$(CC) -shared -Wl,--export-all-symbols"
SHLIB_CXX_LD="\$(CXX) -shared -Wl,--export-all-symbols"
SO="dll"
C_PARSER_FLAGS="$C_INTERF_FLAGS"
EXEC_SUFFIX=".exe"
INSTALL_DLLS=""
DO_SECOND_LD=""
MERGE_DLL_OBJS=""
IN_UNIX="#"
YAPLIB_LD="\$(CC) -shared -Wl,--export-all-symbols"
PRE_INSTALL_ENV=""
INSTALL_ENV=""
;;
*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
$as_echo_n "checking for dlopen in -ldl... " >&6; }
if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ldl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char dlopen ();
int
main ()
{
return dlopen ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_dl_dlopen=yes
else
ac_cv_lib_dl_dlopen=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
have_dl=yes
else
have_dl=no
fi
if test "$have_dl" = yes
then
SO="o"
LIBS="$LIBS -ldl"
INSTALL_DLLS=""
if test "$GCC" = "yes"
then
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
fi
fi
if test "$have_nsl" = yes
then
LIBS="$LIBS -lnsl"
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
esac
EXTRA_LIBS_FOR_SWIDLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir)/packages/PLStream -lplstream"
if test "$dynamic_loading" = "yes"
then
YAPLIB_CFLAGS="$SHLIB_CFLAGS"
YAPLIB="$DYNYAPLIB"
else
YAPLIB_CFLAGS="$CFLAGS"
fi
if test "$coroutining" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DCOROUTINING=1"
fi
if test "$rationaltrees" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DRATIONAL_TREES=1"
fi
if test "$rationaltrees" = "yes" -a "$coroutining" = "yes"
then
INSTALLCLP=""
else
INSTALLCLP="@#"
fi
if test "$debugyap" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DDEBUG=1"
fi
if test "$eam" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DBEAM"
fi
if test "$wamprofile" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DANALYST=1"
fi
if test "$depthlimit" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DDEPTH_LIMIT=1"
fi
if test "$use_april" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DDEPTH_LIMIT=1 -DAPRIL"
LDFLAGS="$LDFLAGS -L."
LIBS="$LIBS -lApril"
fi
if test "$lowleveltracer" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DLOW_LEVEL_TRACER=1"
fi
if test "$threads" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DTHREADS=1"
if test "$GCC" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -D_GNU_SOURCE"
fi
fi
case "$orparallelism" in
sba)
YAP_EXTRAS="$YAP_EXTRAS -DSBA=1"
;;
a-cow)
YAP_EXTRAS="$YAP_EXTRAS -DACOW=1"
;;
yes|env-copy)
YAP_EXTRAS="$YAP_EXTRAS -DENV_COPY=1"
;;
esac
if test "$cutc" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DCUT_C=1"
fi
if test "$tabling" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DTABLING=1"
fi
if test ! "$yap_cv_cplint" = "no"
then
if test ! "$yap_cv_cplint" = "yes"
then
CPLINT_LDFLAGS+=" -L${yap_cv_cplint}/cudd -L${yap_cv_cplint}/mtr -L${yap_cv_cplint}/st -L${yap_cv_cplint}/util -L${yap_cv_cplint}/epd "
CPLINT_CFLAGS+=" -I${yap_cv_cplint}/include"
CPLINT_LIBS="-lcudd -lmtr -lst -lepd -lutil -lm "$CPLINT_LIBS
fi
ENABLE_CPLINT=""
if test "$target_os" = "cygwin" -o "$target_os" = "mingw32"
then
CPLINT_SHLIB_LD="gcc -shared ../../yap.dll"
SHLIB_SUFFIX="dll"
else
CPLINT_SHLIB_LD=$SHLIB_LD
SHLIB_SUFFIX="so"
fi
else
ENABLE_CPLINT="@#"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlibVersion in -lz" >&5
$as_echo_n "checking for zlibVersion in -lz... " >&6; }
if test "${ac_cv_lib_z_zlibVersion+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lz $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char zlibVersion ();
int
main ()
{
return zlibVersion ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_z_zlibVersion=yes
else
ac_cv_lib_z_zlibVersion=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_zlibVersion" >&5
$as_echo "$ac_cv_lib_z_zlibVersion" >&6; }
if test "x$ac_cv_lib_z_zlibVersion" = x""yes; then :
ZLIBS="-lz"
ZLIB=yes
else
ZLIB=no
fi
if test "$ZLIB" = yes; then
ZLIB_TARGETS="zlib4pl.$SO"
ZLIB_PLTARGETS='$(srcdir)/zlib.pl'
ZLIB_INSTALL=install
else
ZLIB_TARGETS=nolib
ZLIB_INSTALL=nolib
cat << EOF
##################################################################
# ERROR: Could not find library zlib (-lz). Dropped library(zlib)
# Library zlib is available from http://www.zlib.net/
# Most Unix/Linux distributions are shipped with binaries. Make
# sure to have the development library installed.
##################################################################
EOF
fi
# LAM
OLD_CC=${CC}
CC=${LAM_MPI_CC}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -llam" >&5
$as_echo_n "checking for main in -llam... " >&6; }
if test "${ac_cv_lib_lam_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llam $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_lam_main=yes
else
ac_cv_lib_lam_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lam_main" >&5
$as_echo "$ac_cv_lib_lam_main" >&6; }
if test "x$ac_cv_lib_lam_main" = x""yes; then :
LAMOBJS=yap_mpi."$SO"
else
LAMOBJS=no
fi
CC=${OLD_CC}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if test "${ac_cv_header_stdc+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#include
#include
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_stdc=yes
else
ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "memchr" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "free" >/dev/null 2>&1; then :
else
ac_cv_header_stdc=no
fi
rm -f conftest*
fi
if test $ac_cv_header_stdc = yes; then
# /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
if test "$cross_compiling" = yes; then :
:
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
(('a' <= (c) && (c) <= 'i') \
|| ('j' <= (c) && (c) <= 'r') \
|| ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
else
ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then
$as_echo "#define STDC_HEADERS 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5
$as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; }
if test "${ac_cv_header_sys_wait_h+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#ifndef WEXITSTATUS
# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
#endif
#ifndef WIFEXITED
# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
#endif
int
main ()
{
int s;
wait (&s);
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_header_sys_wait_h=yes
else
ac_cv_header_sys_wait_h=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5
$as_echo "$ac_cv_header_sys_wait_h" >&6; }
if test $ac_cv_header_sys_wait_h = yes; then
$as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h
fi
for ac_header in arpa/inet.h alloca.h crypt.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in ctype.h direct.h dirent.h dlfcn.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in errno.h execinfo.h fcntl.h fenv.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in float.h fpu_control.h ieeefp.h io.h limits.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in locale.h malloc.h math.h memory.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in mpe.h mpi.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in netdb.h netinet/in.h netinet/tcp.h pwd.h regex.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in siginfo.h signal.h stdarg.h string.h stropts.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in sys/conf.h sys/dir.h sys/file.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in sys/mman.h sys/ndir.h sys/param.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in sys/resource.h sys/select.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in sys/shm.h sys/socket.h sys/stat.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in sys/time.h sys/times.h sys/types.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in sys/ucontext.h sys/un.h sys/wait.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in time.h unistd.h utime.h wctype.h winsock.h winsock2.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in zlib.h zutil.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
eval as_val=\$$as_ac_Header
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_header in mach-o/dyld.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "mach-o/dyld.h" "ac_cv_header_mach_o_dyld_h" "$ac_includes_default"
if test "x$ac_cv_header_mach_o_dyld_h" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MACH_O_DYLD_H 1
_ACEOF
fi
done
if test "$yap_cv_gmp" != "no"
then
for ac_header in gmp.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "gmp.h" "ac_cv_header_gmp_h" "$ac_includes_default"
if test "x$ac_cv_header_gmp_h" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_GMP_H 1
_ACEOF
fi
done
fi
if test "$yap_cv_cudd" != "no"
then
for ac_header in cudd.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "cudd.h" "ac_cv_header_cudd_h" "$ac_includes_default"
if test "x$ac_cv_header_cudd_h" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_CUDD_H 1
_ACEOF
fi
done
fi
if test "$yap_cv_myddas" != "no"
then
for ac_header in mysql/mysql.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "mysql/mysql.h" "ac_cv_header_mysql_mysql_h" "$ac_includes_default"
if test "x$ac_cv_header_mysql_mysql_h" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MYSQL_MYSQL_H 1
_ACEOF
fi
done
fi
if test "$yap_cv_readline" != "no"
then
for ac_header in readline/readline.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "readline/readline.h" "ac_cv_header_readline_readline_h" "$ac_includes_default"
if test "x$ac_cv_header_readline_readline_h" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_READLINE_READLINE_H 1
_ACEOF
fi
done
fi
for ac_header in mpe.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "mpe.h" "ac_cv_header_mpe_h" "$ac_includes_default"
if test "x$ac_cv_header_mpe_h" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MPE_H 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
$as_echo_n "checking for inline... " >&6; }
if test "${ac_cv_c_inline+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#ifndef __cplusplus
typedef int foo_t;
static $ac_kw foo_t static_foo () {return 0; }
$ac_kw foo_t foo () {return 0; }
#endif
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_c_inline=$ac_kw
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
test "$ac_cv_c_inline" != no && break
done
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
$as_echo "$ac_cv_c_inline" >&6; }
case $ac_cv_c_inline in
inline | yes) ;;
*)
case $ac_cv_c_inline in
no) ac_val=;;
*) ac_val=$ac_cv_c_inline;;
esac
cat >>confdefs.h <<_ACEOF
#ifndef __cplusplus
#define inline $ac_val
#endif
_ACEOF
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
if test "${ac_cv_struct_tm+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
int
main ()
{
struct tm tm;
int *p = &tm.tm_sec;
return !p;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_struct_tm=time.h
else
ac_cv_struct_tm=sys/time.h
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5
$as_echo "$ac_cv_struct_tm" >&6; }
if test $ac_cv_struct_tm = sys/time.h; then
$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
fi
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int *" >&5
$as_echo_n "checking size of int *... " >&6; }
if test "${ac_cv_sizeof_int_p+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int *))" "ac_cv_sizeof_int_p" "$ac_includes_default"; then :
else
if test "$ac_cv_type_int_p" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ as_fn_set_status 77
as_fn_error "cannot compute sizeof (int *)
See \`config.log' for more details." "$LINENO" 5; }; }
else
ac_cv_sizeof_int_p=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int_p" >&5
$as_echo "$ac_cv_sizeof_int_p" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_INT_P $ac_cv_sizeof_int_p
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short int" >&5
$as_echo_n "checking size of short int... " >&6; }
if test "${ac_cv_sizeof_short_int+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short int))" "ac_cv_sizeof_short_int" "$ac_includes_default"; then :
else
if test "$ac_cv_type_short_int" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ as_fn_set_status 77
as_fn_error "cannot compute sizeof (short int)
See \`config.log' for more details." "$LINENO" 5; }; }
else
ac_cv_sizeof_short_int=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short_int" >&5
$as_echo "$ac_cv_sizeof_short_int" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_SHORT_INT $ac_cv_sizeof_short_int
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
$as_echo_n "checking size of int... " >&6; }
if test "${ac_cv_sizeof_int+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then :
else
if test "$ac_cv_type_int" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ as_fn_set_status 77
as_fn_error "cannot compute sizeof (int)
See \`config.log' for more details." "$LINENO" 5; }; }
else
ac_cv_sizeof_int=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
$as_echo "$ac_cv_sizeof_int" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_INT $ac_cv_sizeof_int
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long int" >&5
$as_echo_n "checking size of long int... " >&6; }
if test "${ac_cv_sizeof_long_int+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long int))" "ac_cv_sizeof_long_int" "$ac_includes_default"; then :
else
if test "$ac_cv_type_long_int" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ as_fn_set_status 77
as_fn_error "cannot compute sizeof (long int)
See \`config.log' for more details." "$LINENO" 5; }; }
else
ac_cv_sizeof_long_int=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_int" >&5
$as_echo "$ac_cv_sizeof_long_int" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_LONG_INT $ac_cv_sizeof_long_int
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long int" >&5
$as_echo_n "checking size of long long int... " >&6; }
if test "${ac_cv_sizeof_long_long_int+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long int))" "ac_cv_sizeof_long_long_int" "$ac_includes_default"; then :
else
if test "$ac_cv_type_long_long_int" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ as_fn_set_status 77
as_fn_error "cannot compute sizeof (long long int)
See \`config.log' for more details." "$LINENO" 5; }; }
else
ac_cv_sizeof_long_long_int=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long_int" >&5
$as_echo "$ac_cv_sizeof_long_long_int" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_LONG_LONG_INT $ac_cv_sizeof_long_long_int
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of float" >&5
$as_echo_n "checking size of float... " >&6; }
if test "${ac_cv_sizeof_float+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (float))" "ac_cv_sizeof_float" "$ac_includes_default"; then :
else
if test "$ac_cv_type_float" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ as_fn_set_status 77
as_fn_error "cannot compute sizeof (float)
See \`config.log' for more details." "$LINENO" 5; }; }
else
ac_cv_sizeof_float=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_float" >&5
$as_echo "$ac_cv_sizeof_float" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_FLOAT $ac_cv_sizeof_float
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of double" >&5
$as_echo_n "checking size of double... " >&6; }
if test "${ac_cv_sizeof_double+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default"; then :
else
if test "$ac_cv_type_double" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
{ as_fn_set_status 77
as_fn_error "cannot compute sizeof (double)
See \`config.log' for more details." "$LINENO" 5; }; }
else
ac_cv_sizeof_double=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_double" >&5
$as_echo "$ac_cv_sizeof_double" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_DOUBLE $ac_cv_sizeof_double
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for type of malloc" >&5
$as_echo_n "checking for type of malloc... " >&6; }
if test "${yap_cv_malloct+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
yap_cv_malloct=void
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
char *malloc(size_t);
int main() {
void *p=malloc(1);
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
yap_cv_malloct=char
else
yap_cv_malloct=void
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_malloct *" >&5
$as_echo "$yap_cv_malloct *" >&6; }
if test "$yap_cv_malloct" = void
then $as_echo "#define MALLOC_T void *" >>confdefs.h
else $as_echo "#define MALLOC_T char *" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc inline" >&5
$as_echo_n "checking for gcc inline... " >&6; }
if test "${yap_cv_gcc+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
yap_cv_gcc=yes
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#undef inline
inline int f(int x) {return x+1;}
int main() { return 0;}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
yap_cv_gcc=yes
else
yap_cv_gcc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_gcc" >&5
$as_echo "$yap_cv_gcc" >&6; }
if test "$yap_cv_gcc" = yes
then
M4GENHDRS=m4/gcc_genhdrs.m4
$as_echo "#define HAVE_GCC 1" >>confdefs.h
else
M4GENHDRS=m4/cc_genhdrs.m4
$as_echo "#define HAVE_GCC 0" >>confdefs.h
fi
if test "x$ARCH" = "x"; then
case "$host" in
*linux*)
ARCH=`echo $host | sed 's/-.*/-linux/'`
;;
*-gnu)
ARCH=`echo $host | sed 's/\([^-]*\)-[^-]*-\([^-]*\)-gnu/\1-\2/'`
;;
*)
ARCH=`echo $host | sed 's/\([^-]*\)-[^-]*-\([^-]*\)/\1-\2/'`
;;
esac
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc threaded code" >&5
$as_echo_n "checking for gcc threaded code... " >&6; }
if test "${yap_cv_threaded_code+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
yap_cv_threaded_code=yes
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int main() {
void *t = &&l2;
l1: goto *t;
l2: return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
yap_cv_threaded_code=yes
else
yap_cv_threaded_code=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_threaded_code" >&5
$as_echo "$yap_cv_threaded_code" >&6; }
if test "$yap_cv_threaded_code" = yes && test "$yap_cv_gcc" = yes
then
$as_echo "#define USE_THREADED_CODE 1" >>confdefs.h
M4GENABSMI=gen_gcc.m4
else
$as_echo "#define USE_THREADED_CODE 0" >>confdefs.h
M4GENABSMI=gen_ansi.m4
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for IEEE floats" >&5
$as_echo_n "checking for IEEE floats... " >&6; }
if test "${yap_cv_ffieee+set}" = set; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
yap_cv_ffieee=yes
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int main() {
union { float f; int i} a;
a.f = 1;
if (a.i==0x3f800000) return 0;
return 1;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
yap_cv_ffieee=yes
else
yap_cv_ffieee=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_ffieee" >&5
$as_echo "$yap_cv_ffieee" >&6; }
if test "$yap_cv_ffieee" = yes
then
$as_echo "#define FFIEEE 1" >>confdefs.h
else
$as_echo "#define FFIEEE 0" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsetjmp" >&5
$as_echo_n "checking for sigsetjmp... " >&6; }
if test "${yap_cv_sigsetjmp+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
int
main ()
{
sigjmp_buf RestartEnv;
siglongjmp (RestartEnv, 1);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
yap_cv_sigsetjmp=yes
else
yap_cv_sigsetjmp=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_sigsetjmp" >&5
$as_echo "$yap_cv_sigsetjmp" >&6; }
if test "$yap_cv_sigsetjmp" = yes
then
$as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
else
$as_echo "#define HAVE_SIGSETJMP 0" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigsegv" >&5
$as_echo_n "checking for sigsegv... " >&6; }
if test "${yap_cv_sigsegv+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
int
main ()
{
printf("Signal value is %d\n", SIGSEGV);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
yap_cv_sigsegv=yes
else
yap_cv_sigsegv=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_sigsegv" >&5
$as_echo "$yap_cv_sigsegv" >&6; }
if test "$yap_cv_sigsegv" = yes
then
$as_echo "#define HAVE_SIGSEGV 1" >>confdefs.h
else
$as_echo "#define HAVE_SIGSEGV 0" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sigprof" >&5
$as_echo_n "checking for sigprof... " >&6; }
if test "${yap_cv_sigprof+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
int
main ()
{
printf("Signal value is %d\n", SIGPROF);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
yap_cv_sigprof=yes
else
yap_cv_sigprof=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_sigprof" >&5
$as_echo "$yap_cv_sigprof" >&6; }
if test "$yap_cv_sigsegv" = yes
then
$as_echo "#define HAVE_SIGPROF 1" >>confdefs.h
else
$as_echo "#define HAVE_SIGPROF 0" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for siginfo" >&5
$as_echo_n "checking for siginfo... " >&6; }
if test "${yap_cv_siginfo+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
int
main ()
{
printf("SIGINFO value is %d\n", SA_SIGINFO);
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
yap_cv_siginfo=yes
else
yap_cv_siginfo=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_siginfo" >&5
$as_echo "$yap_cv_siginfo" >&6; }
if test "$yap_cv_siginfo" = yes
then
$as_echo "#define HAVE_SIGINFO 1" >>confdefs.h
else
$as_echo "#define HAVE_SIGINFO 0" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking union wait" >&5
$as_echo_n "checking union wait... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
int
main ()
{
union wait x;
wait(&x); /* make sure we can compile wait */
WIFEXITED(x); /* Generates compiler error if WIFEXITED
* uses an int. */
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
union_wait_ok=yes
else
union_wait_ok=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $union_wait_ok" >&5
$as_echo "$union_wait_ok" >&6; }
if test "$union_wait_ok" = no; then
$as_echo "#define NO_UNION_WAIT 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking environ" >&5
$as_echo_n "checking environ... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
extern char **environ;
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
environ_ok=yes
else
environ_ok=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $environ_ok" >&5
$as_echo "$environ_ok" >&6; }
if test "$environ_ok" = yes; then
$as_echo "#define HAVE_ENVIRON 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
$as_echo_n "checking return type of signal handlers... " >&6; }
if test "${ac_cv_type_signal+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
int
main ()
{
return *(signal (0, 0)) (0) == 1;
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_cv_type_signal=int
else
ac_cv_type_signal=void
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
$as_echo "$ac_cv_type_signal" >&6; }
cat >>confdefs.h <<_ACEOF
#define RETSIGTYPE $ac_cv_type_signal
_ACEOF
for ac_func in _NSGetEnviron access acosh
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in alloca asinh atanh chdir ctime dlopen dup2
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in erf feclearexcept
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in fesettrapenable fgetpos finite fpclass ftime getcwd getenv
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in gethostbyname gethostent gethostid gethostname
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in gethrtime getpagesize
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in getpwnam getrlimit getrusage gettimeofday getwd
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in isatty isnan isinf kill labs link lgamma
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in localtime lstat mallinfo
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in mbsnrtowcs
do :
ac_fn_c_check_func "$LINENO" "mbsnrtowcs" "ac_cv_func_mbsnrtowcs"
if test "x$ac_cv_func_mbsnrtowcs" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_MBSNRTOWCS 1
_ACEOF
fi
done
for ac_func in memcpy memmove mkstemp mktemp
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in nanosleep mktime opendir
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in putenv rand random readlink regexec
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in rename rint rl_set_prompt sbrk select
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in setbuf setitimer setsid setlinebuf sigaction
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in siggetmask siginterrupt
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in signal sigprocmask socket stat
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in strchr strerror stricmp strncat strncpy strtod
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
for ac_func in time times tmpnam usleep utime vsnprintf
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
ac_fn_c_check_func "$LINENO" "regexec" "ac_cv_func_regexec"
if test "x$ac_cv_func_regexec" = x""yes; then :
NO_BUILTIN_REGEXP="#"
else
NO_BUILTIN_REGEXP=""
fi
for ac_func in NSLinkModule
do :
ac_fn_c_check_func "$LINENO" "NSLinkModule" "ac_cv_func_NSLinkModule"
if test "x$ac_cv_func_NSLinkModule" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_NSLINKMODULE 1
_ACEOF
fi
done
if test "$use_condor" = "no"
then
for ac_func in alarm mmap popen shmat sleep system ttyname waitpid
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
fi
if test "$target_os" != "mingw32"
then
for ac_func in fetestexcept snprintf
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
eval as_val=\$$as_ac_var
if test "x$as_val" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
done
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpz_xor" >&5
$as_echo_n "checking for mpz_xor... " >&6; }
if test "${yap_cv_mpz_xor+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
void check(mpz_t rop,mpz_t op1,mpz_t op2) {
mpz_xor(rop,op1,op2);
}
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
yap_cv_mpz_xor=yes
else
yap_cv_mpz_xor=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_mpz_xor" >&5
$as_echo "$yap_cv_mpz_xor" >&6; }
if test "$yap_cv_mpz_xor" = yes
then
$as_echo "#define HAVE_MPZ_XOR 1" >>confdefs.h
else
$as_echo "#define HAVE_MPZ_XOR 0" >>confdefs.h
fi
if test "$use_malloc" = "yes" -a "$maxmemory" = "yes"
then
maxmemory="no"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if fflush(NULL) clobbers input pipes" >&5
$as_echo_n "checking if fflush(NULL) clobbers input pipes... " >&6; }
if test "${yap_cv_broken_fflush_null+set}" = set; then :
$as_echo_n "(cached) " >&6
else
cat >conftest.$ac_ext <
#include
int main(int argc, char **argv)
{
char *buf;
int i;
char *bp;
bp = buf = malloc(1024);
while (1) {
while ((i = getc(stdin)) != -1
&& (*bp++ = i) != '\n'
&& (bp - buf < 1024) )
/* DO NOTHING */ ;
*bp = '\0';
fprintf(stdout, "%s", buf);
fflush(NULL);
if( i == EOF ) return 0;
bp = buf;
}
}
EOF
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
(eval $ac_link) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
if test "$?" = 0
then
cat conftest.$ac_ext | ./conftest$ac_exeext > conftest.out
{ ac_try='cmp conftest.$ac_ext conftest.out'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }
if test "$?" = 0
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
yap_cv_broken_fflush_null=no
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
yap_cv_broken_fflush_null=yes
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
$as_echo "failed" >&6; }
yap_cv_broken_fflush_null=failed
fi
rm -f conftest.$ac_ext conftest.$ac_objext conftest$ac_exeext conftest.out
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $yap_cv_broken_fflush_null" >&5
$as_echo "$yap_cv_broken_fflush_null" >&6; }
if test "$yap_cv_broken_fflush_null" = no
then
$as_echo "#define BROKEN_FFLUSH_NULL 0" >>confdefs.h
else
$as_echo "#define BROKEN_FFLUSH_NULL 1" >>confdefs.h
fi
if test "$use_malloc" = yes
then
$as_echo "#define USE_SYSTEM_MALLOC 1" >>confdefs.h
$as_echo "#define GC_NO_TAGS 1" >>confdefs.h
fi
if test "$maxmemory" = yes
then
$as_echo "#define GC_NO_TAGS 1" >>confdefs.h
$as_echo "#define USE_DL_MALLOC 1" >>confdefs.h
fi
PROLOG_SYSTEM=yap
IN_YAP=
IN_SWI="#"
CHR_TARGETS=chr_support."$SO"
CLIB_TARGETS="random.$SO socket.$SO cgi.$SO memfile.$SO files.$SO mime.$SO crypt.$SO"
CLIB_PLTARGETS="\$(srcdir)/random.pl \$(srcdir)/socket.pl \$(srcdir)/cgi.pl \$(srcdir)/memfile.pl \$(srcdir)/filesex.pl \$(srcdir)/mime.pl \$(srcdir)/crypt.pl"
if test "$ac_cv_func_setitimer" = "yes"; then
CLIB_TARGETS="$CLIB_TARGETS time.$SO"
CLIB_PLTARGETS="$CLIB_PLTARGETS \$(srcdir)/time.pl"
else
echo "WARNING: no setitimer(); dropping time.pl from targets"
fi
if test "$IN_UNIX" = ""; then
CLIB_TARGETS="unix.$SO $CLIB_TARGETS"
CLIB_PLTARGETS="\$(srcdir)/unix.pl $CLIB_PLTARGETS"
CLIB_NETLIBS=
else
ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket"
if test "x$ac_cv_func_socket" = x""yes; then :
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5
$as_echo_n "checking for socket in -lsocket... " >&6; }
if test "${ac_cv_lib_socket_socket+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char socket ();
int
main ()
{
return socket ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_socket_socket=yes
else
ac_cv_lib_socket_socket=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5
$as_echo "$ac_cv_lib_socket_socket" >&6; }
if test "x$ac_cv_lib_socket_socket" = x""yes; then :
CLIB_NETLIBS="$CLIB_NETLIBS -lsocket"
$as_echo "#define HAVE_LIBSOCKET 1" >>confdefs.h
fi
fi
ac_fn_c_check_func "$LINENO" "gethostent" "ac_cv_func_gethostent"
if test "x$ac_cv_func_gethostent" = x""yes; then :
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostent in -lnsl" >&5
$as_echo_n "checking for gethostent in -lnsl... " >&6; }
if test "${ac_cv_lib_nsl_gethostent+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char gethostent ();
int
main ()
{
return gethostent ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nsl_gethostent=yes
else
ac_cv_lib_nsl_gethostent=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostent" >&5
$as_echo "$ac_cv_lib_nsl_gethostent" >&6; }
if test "x$ac_cv_lib_nsl_gethostent" = x""yes; then :
CLIB_NETLIBS="$CLIB_NETLIBS -lnsl"
$as_echo "#define HAVE_LIBNSL 1" >>confdefs.h
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
$as_echo_n "checking for pthread_create in -lpthread... " >&6; }
if test "${ac_cv_lib_pthread_pthread_create+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lpthread $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char pthread_create ();
int
main ()
{
return pthread_create ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_pthread_pthread_create=yes
else
ac_cv_lib_pthread_pthread_create=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5
$as_echo "$ac_cv_lib_pthread_pthread_create" >&6; }
if test "x$ac_cv_lib_pthread_pthread_create" = x""yes; then :
CLIB_PTHREADS="-lpthread"
else
CLIB_PTHREADS=""
fi
oldlibs="$LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5
$as_echo_n "checking for crypt in -lcrypt... " >&6; }
if test "${ac_cv_lib_crypt_crypt+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lcrypt $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char crypt ();
int
main ()
{
return crypt ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_crypt_crypt=yes
else
ac_cv_lib_crypt_crypt=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt" >&5
$as_echo "$ac_cv_lib_crypt_crypt" >&6; }
if test "x$ac_cv_lib_crypt_crypt" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBCRYPT 1
_ACEOF
LIBS="-lcrypt $LIBS"
fi
CLIB_CRYPTLIBS="$LIBS"
for ac_func in crypt
do :
ac_fn_c_check_func "$LINENO" "crypt" "ac_cv_func_crypt"
if test "x$ac_cv_func_crypt" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_CRYPT 1
_ACEOF
fi
done
LIBS="$oldlibs"
ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "
#include
#include
"
if test "x$ac_cv_type_socklen_t" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SOCKLEN_T 1
_ACEOF
fi
ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "
#include
#include
"
if test "x$ac_cv_type_ssize_t" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SSIZE_T 1
_ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking \"variable timezone in tzset\"" >&5
$as_echo_n "checking \"variable timezone in tzset\"... " >&6; }
if test "$cross_compiling" = yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: assuming no" >&5
$as_echo "assuming no" >&6; }
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include
#include
#ifdef __CYGWIN__
#define timezone _timezone
#endif
extern long timezone;
main()
{ tzset();
if ( timezone > -15*3600 &&
timezone < 15*3600 &&
timezone % 60 == 0 )
return 0;
exit(1);
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_VAR_TIMEZONE 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
ac_fn_c_check_member "$LINENO" "struct tm" "tm_gmtoff" "ac_cv_member_struct_tm_tm_gmtoff" "#include
"
if test "x$ac_cv_member_struct_tm_tm_gmtoff" = x""yes; then :
$as_echo "#define HAVE_STRUCT_TIME_TM_GMTOFF /**/" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking _XOPEN_SOURCE" >&5
$as_echo_n "checking _XOPEN_SOURCE... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _XOPEN_SOURCE
#include
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
$as_echo "#define DEFINE_XOPEN_SOURCE 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
if test "$with_time" = yes; then
if test "$ac_cv_func_setitimer" = "yes"; then
TARGETS="$TARGETS time.$SO"
else
echo "WARNING: no setitimer(); dropping time.pl from targets"
fi
fi
if test "$ac_cv_func_getrlimit" = "yes"; then
TARGETS="$TARGETS rlimit.$SO"
else
echo "WARNING: no getrlimit(); dropping rlimit.pl from targets"
fi
mkdir -p library/lammpi
mkdir -p library/matrix
mkdir -p library/matlab
mkdir -p library/mpi
mkdir -p library/random
mkdir -p library/regex
mkdir -p library/system
mkdir -p library/tries
mkdir -p library/rltree
mkdir -p LGPL/clp
mkdir -p LGPL/swi_console
mkdir -p GPL
mkdir -p packages/
mkdir -p packages/clib
mkdir -p packages/clib/sha1
mkdir -p packages/clib/maildrop
mkdir -p packages/clib/maildrop/rfc822
mkdir -p packages/clib/maildrop/rfc2045
mkdir -p packages/CLPBN
mkdir -p packages/clpqr
mkdir -p packages/cplint
mkdir -p packages/cplint/approx
mkdir -p packages/cplint/slipcase
mkdir -p packages/cplint/approx/simplecuddLPADs
mkdir -p packages/http
mkdir -p packages/jpl
mkdir -p packages/jpl/src/java
mkdir -p packages/jpl/src/java/jpl
mkdir -p packages/jpl/src/java/jpl/fli
mkdir -p packages/jpl/src/java/jpl/test
mkdir -p packages/jpl/examples
mkdir -p packages/jpl/examples/java
mkdir -p packages/tai
mkdir -p packages/tai/libtai
mkdir -p packages/PLStream
mkdir -p packages/plunit
mkdir -p packages/ProbLog
mkdir -p packages/ProbLog/simplecudd
mkdir -p packages/ProbLog/simplecudd_lfi
mkdir -p packages/RDF
mkdir -p packages/semweb
mkdir -p packages/sgml
mkdir -p packages/zlib
ac_config_files="$ac_config_files Makefile"
ac_config_files="$ac_config_files GPL/Makefile"
ac_config_files="$ac_config_files library/Makefile"
ac_config_files="$ac_config_files library/lammpi/Makefile"
ac_config_files="$ac_config_files library/matlab/Makefile"
ac_config_files="$ac_config_files library/matrix/Makefile"
ac_config_files="$ac_config_files library/mpi/Makefile"
ac_config_files="$ac_config_files library/random/Makefile"
ac_config_files="$ac_config_files library/regex/Makefile"
ac_config_files="$ac_config_files library/rltree/Makefile"
ac_config_files="$ac_config_files library/system/Makefile"
ac_config_files="$ac_config_files library/tries/Makefile"
ac_config_files="$ac_config_files LGPL/Makefile"
ac_config_files="$ac_config_files LGPL/clp/Makefile"
ac_config_files="$ac_config_files LGPL/swi_console/Makefile"
ac_config_files="$ac_config_files packages/clib/Makefile"
ac_config_files="$ac_config_files packages/clib/maildrop/rfc822/Makefile"
ac_config_files="$ac_config_files packages/clib/maildrop/rfc2045/Makefile"
ac_config_files="$ac_config_files packages/CLPBN/Makefile"
ac_config_files="$ac_config_files packages/cplint/Makefile"
ac_config_files="$ac_config_files packages/cplint/approx/simplecuddLPADs/Makefile"
ac_config_files="$ac_config_files packages/cplint/slipcase/Makefile"
ac_config_files="$ac_config_files packages/http/Makefile"
ac_config_files="$ac_config_files packages/tai/Makefile"
ac_config_files="$ac_config_files packages/tai/libtai/Makefile"
ac_config_files="$ac_config_files packages/PLStream/Makefile"
ac_config_files="$ac_config_files packages/plunit/Makefile"
ac_config_files="$ac_config_files packages/ProbLog/Makefile"
ac_config_files="$ac_config_files packages/RDF/Makefile"
ac_config_files="$ac_config_files packages/semweb/Makefile"
ac_config_files="$ac_config_files packages/sgml/Makefile"
ac_config_files="$ac_config_files packages/zlib/Makefile"
if test "$ENABLE_CHR" = ""; then
ac_config_files="$ac_config_files packages/chr/Makefile"
fi
if test "$ENABLE_CLPQR" = ""; then
ac_config_files="$ac_config_files packages/clpqr/Makefile"
fi
if test "$ENABLE_JPL" = ""; then
ac_config_files="$ac_config_files packages/jpl/Makefile packages/jpl/jpl_paths.yap packages/jpl/src/java/Makefile packages/pyswip/Makefile"
fi
if test "$USE_CUDD" = ""; then
ac_config_files="$ac_config_files packages/ProbLog/simplecudd/Makefile"
ac_config_files="$ac_config_files packages/ProbLog/simplecudd_lfi/Makefile"
fi
if test "$USE_MINISAT" = ""; then
ac_config_files="$ac_config_files packages/swi-minisat2/Makefile"
ac_config_files="$ac_config_files packages/swi-minisat2/C/Makefile"
fi
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems. If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.
_ACEOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, we kill variables containing newlines.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(
for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
eval ac_val=\$$ac_var
case $ac_val in #(
*${as_nl}*)
case $ac_var in #(
*_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
esac
case $ac_var in #(
_ | IFS | as_nl) ;; #(
BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
*) { eval $ac_var=; unset $ac_var;} ;;
esac ;;
esac
done
(set) 2>&1 |
case $as_nl`(ac_space=' '; set) 2>&1` in #(
*${as_nl}ac_space=\ *)
# `set' does not quote correctly, so add quotes: double-quote
# substitution turns \\\\ into \\, and sed turns \\ into \.
sed -n \
"s/'/'\\\\''/g;
s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
;; #(
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
;;
esac |
sort
) |
sed '
/^ac_cv_env_/b end
t clear
:clear
s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
t end
s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
:end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
test "x$cache_file" != "x/dev/null" &&
{ $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
cat confcache >$cache_file
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
fi
fi
rm -f confcache
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
DEFS=-DHAVE_CONFIG_H
ac_libobjs=
ac_ltlibobjs=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
# 1. Remove the extension, and $U if already installed.
ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
# 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
# will be set to the directory where LIBOBJS objects are built.
as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
: ${CONFIG_STATUS=./config.status}
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
as_write_fail=0
cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
#! $SHELL
# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.
debug=false
ac_cs_recheck=false
ac_cs_silent=false
SHELL=\${CONFIG_SHELL-$SHELL}
export SHELL
_ASEOF
cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##
# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
NULLCMD=:
# Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
# is contrary to our usage. Disable this feature.
alias -g '${1+"$@"}'='"$@"'
setopt NO_GLOB_SUBST
else
case `(set -o) 2>/dev/null` in #(
*posix*) :
set -o posix ;; #(
*) :
;;
esac
fi
as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='print -r --'
as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in #(
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
PATH_SEPARATOR=:
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
(PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
PATH_SEPARATOR=';'
}
fi
# IFS
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
done
IFS=$as_save_IFS
;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
as_myself=$0
fi
if test ! -f "$as_myself"; then
$as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
exit 1
fi
# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there. '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
&& ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '
# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
# as_fn_error ERROR [LINENO LOG_FD]
# ---------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with status $?, using 1 if that was 0.
as_fn_error ()
{
as_status=$?; test $as_status -eq 0 && as_status=1
if test "$3"; then
as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
fi
$as_echo "$as_me: error: $1" >&2
as_fn_exit $as_status
} # as_fn_error
# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
return $1
} # as_fn_set_status
# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
set +e
as_fn_set_status $1
exit $1
} # as_fn_exit
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
{ eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
eval 'as_fn_append ()
{
eval $1+=\$2
}'
else
as_fn_append ()
{
eval $1=\$$1\$2
}
fi # as_fn_append
# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
eval 'as_fn_arith ()
{
as_val=$(( $* ))
}'
else
as_fn_arith ()
{
as_val=`expr "$@" || test $? -eq 1`
}
fi # as_fn_arith
if expr a : '\(a\)' >/dev/null 2>&1 &&
test "X`expr 00001 : '.*\(...\)'`" = X001; then
as_expr=expr
else
as_expr=false
fi
if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
as_basename=basename
else
as_basename=false
fi
if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
as_dirname=dirname
else
as_dirname=false
fi
as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
X"$0" : 'X\(//\)$' \| \
X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
/^X\/\(\/\/\)$/{
s//\1/
q
}
/^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
case `echo 'xy\c'` in
*c*) ECHO_T=' ';; # ECHO_T is single tab character.
xy) ECHO_C='\c';;
*) echo `echo ksh88 bug on AIX 6.1` > /dev/null
ECHO_T=' ';;
esac;;
*)
ECHO_N='-n';;
esac
rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
rm -f conf$$.dir/conf$$.file
else
rm -f conf$$.dir
mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
if ln -s conf$$.file conf$$ 2>/dev/null; then
as_ln_s='ln -s'
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -p'
fi
else
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{
case $as_dir in #(
-*) as_dir=./$as_dir;;
esac
test -d "$as_dir" || eval $as_mkdir_p || {
as_dirs=
while :; do
case $as_dir in #(
*\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
*) as_qdir=$as_dir;;
esac
as_dirs="'$as_qdir' $as_dirs"
as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$as_dir" : 'X\(//\)[^/]' \| \
X"$as_dir" : 'X\(//\)$' \| \
X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
test -d "$as_dir" && break
done
test -z "$as_dirs" || eval "mkdir $as_dirs"
} || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
} # as_fn_mkdir_p
if mkdir -p . 2>/dev/null; then
as_mkdir_p='mkdir -p "$as_dir"'
else
test -d ./-p && rmdir ./-p
as_mkdir_p=false
fi
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
exec 6>&1
## ----------------------------------- ##
## Main body of $CONFIG_STATUS script. ##
## ----------------------------------- ##
_ASEOF
test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Save the log message, to keep $0 and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by $as_me, which was
generated by GNU Autoconf 2.65. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
CONFIG_LINKS = $CONFIG_LINKS
CONFIG_COMMANDS = $CONFIG_COMMANDS
$ $0 $@
on `(hostname || uname -n) 2>/dev/null | sed 1q`
"
_ACEOF
case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac
case $ac_config_headers in *"
"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
esac
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_headers="$ac_config_headers"
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
ac_cs_usage="\
\`$as_me' instantiates files and other configuration actions
from templates according to the current configuration. Unless the files
and actions are specified as TAGs, all are instantiated by default.
Usage: $0 [OPTION]... [TAG]...
-h, --help print this help, then exit
-V, --version print version number and configuration settings, then exit
--config print configuration, then exit
-q, --quiet, --silent
do not print progress messages
-d, --debug don't remove temporary files
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
--header=FILE[:TEMPLATE]
instantiate the configuration header FILE
Configuration files:
$config_files
Configuration headers:
$config_headers
Report bugs to the package provider."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
config.status
configured by $0, generated by GNU Autoconf 2.65,
with options \\"\$ac_cs_config\\"
Copyright (C) 2009 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
ac_pwd='$ac_pwd'
srcdir='$srcdir'
INSTALL='$INSTALL'
AWK='$AWK'
test -n "\$AWK" || AWK=awk
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# The default lists apply if the user does not specify any file.
ac_need_defaults=:
while test $# != 0
do
case $1 in
--*=*)
ac_option=`expr "X$1" : 'X\([^=]*\)='`
ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
ac_shift=:
;;
*)
ac_option=$1
ac_optarg=$2
ac_shift=shift
;;
esac
case $ac_option in
# Handling of the options.
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
ac_cs_recheck=: ;;
--version | --versio | --versi | --vers | --ver | --ve | --v | -V )
$as_echo "$ac_cs_version"; exit ;;
--config | --confi | --conf | --con | --co | --c )
$as_echo "$ac_cs_config"; exit ;;
--debug | --debu | --deb | --de | --d | -d )
debug=: ;;
--file | --fil | --fi | --f )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
as_fn_append CONFIG_FILES " '$ac_optarg'"
ac_need_defaults=false;;
--header | --heade | --head | --hea )
$ac_shift
case $ac_optarg in
*\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
as_fn_append CONFIG_HEADERS " '$ac_optarg'"
ac_need_defaults=false;;
--he | --h)
# Conflict between --help and --header
as_fn_error "ambiguous option: \`$1'
Try \`$0 --help' for more information.";;
--help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
ac_cs_silent=: ;;
# This is an error.
-*) as_fn_error "unrecognized option: \`$1'
Try \`$0 --help' for more information." ;;
*) as_fn_append ac_config_targets " $1"
ac_need_defaults=false ;;
esac
shift
done
ac_configure_extra_args=
if $ac_cs_silent; then
exec 6>/dev/null
ac_configure_extra_args="$ac_configure_extra_args --silent"
fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
export CONFIG_SHELL
exec "\$@"
fi
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
echo
sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
$as_echo "$ac_log"
} >&5
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Handling of arguments.
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"GPL/Makefile") CONFIG_FILES="$CONFIG_FILES GPL/Makefile" ;;
"library/Makefile") CONFIG_FILES="$CONFIG_FILES library/Makefile" ;;
"library/lammpi/Makefile") CONFIG_FILES="$CONFIG_FILES library/lammpi/Makefile" ;;
"library/matlab/Makefile") CONFIG_FILES="$CONFIG_FILES library/matlab/Makefile" ;;
"library/matrix/Makefile") CONFIG_FILES="$CONFIG_FILES library/matrix/Makefile" ;;
"library/mpi/Makefile") CONFIG_FILES="$CONFIG_FILES library/mpi/Makefile" ;;
"library/random/Makefile") CONFIG_FILES="$CONFIG_FILES library/random/Makefile" ;;
"library/regex/Makefile") CONFIG_FILES="$CONFIG_FILES library/regex/Makefile" ;;
"library/rltree/Makefile") CONFIG_FILES="$CONFIG_FILES library/rltree/Makefile" ;;
"library/system/Makefile") CONFIG_FILES="$CONFIG_FILES library/system/Makefile" ;;
"library/tries/Makefile") CONFIG_FILES="$CONFIG_FILES library/tries/Makefile" ;;
"LGPL/Makefile") CONFIG_FILES="$CONFIG_FILES LGPL/Makefile" ;;
"LGPL/clp/Makefile") CONFIG_FILES="$CONFIG_FILES LGPL/clp/Makefile" ;;
"LGPL/swi_console/Makefile") CONFIG_FILES="$CONFIG_FILES LGPL/swi_console/Makefile" ;;
"packages/clib/Makefile") CONFIG_FILES="$CONFIG_FILES packages/clib/Makefile" ;;
"packages/clib/maildrop/rfc822/Makefile") CONFIG_FILES="$CONFIG_FILES packages/clib/maildrop/rfc822/Makefile" ;;
"packages/clib/maildrop/rfc2045/Makefile") CONFIG_FILES="$CONFIG_FILES packages/clib/maildrop/rfc2045/Makefile" ;;
"packages/CLPBN/Makefile") CONFIG_FILES="$CONFIG_FILES packages/CLPBN/Makefile" ;;
"packages/cplint/Makefile") CONFIG_FILES="$CONFIG_FILES packages/cplint/Makefile" ;;
"packages/cplint/approx/simplecuddLPADs/Makefile") CONFIG_FILES="$CONFIG_FILES packages/cplint/approx/simplecuddLPADs/Makefile" ;;
"packages/cplint/slipcase/Makefile") CONFIG_FILES="$CONFIG_FILES packages/cplint/slipcase/Makefile" ;;
"packages/http/Makefile") CONFIG_FILES="$CONFIG_FILES packages/http/Makefile" ;;
"packages/tai/Makefile") CONFIG_FILES="$CONFIG_FILES packages/tai/Makefile" ;;
"packages/tai/libtai/Makefile") CONFIG_FILES="$CONFIG_FILES packages/tai/libtai/Makefile" ;;
"packages/PLStream/Makefile") CONFIG_FILES="$CONFIG_FILES packages/PLStream/Makefile" ;;
"packages/plunit/Makefile") CONFIG_FILES="$CONFIG_FILES packages/plunit/Makefile" ;;
"packages/ProbLog/Makefile") CONFIG_FILES="$CONFIG_FILES packages/ProbLog/Makefile" ;;
"packages/RDF/Makefile") CONFIG_FILES="$CONFIG_FILES packages/RDF/Makefile" ;;
"packages/semweb/Makefile") CONFIG_FILES="$CONFIG_FILES packages/semweb/Makefile" ;;
"packages/sgml/Makefile") CONFIG_FILES="$CONFIG_FILES packages/sgml/Makefile" ;;
"packages/zlib/Makefile") CONFIG_FILES="$CONFIG_FILES packages/zlib/Makefile" ;;
"packages/chr/Makefile") CONFIG_FILES="$CONFIG_FILES packages/chr/Makefile" ;;
"packages/clpqr/Makefile") CONFIG_FILES="$CONFIG_FILES packages/clpqr/Makefile" ;;
"packages/jpl/Makefile") CONFIG_FILES="$CONFIG_FILES packages/jpl/Makefile" ;;
"packages/jpl/jpl_paths.yap") CONFIG_FILES="$CONFIG_FILES packages/jpl/jpl_paths.yap" ;;
"packages/jpl/src/java/Makefile") CONFIG_FILES="$CONFIG_FILES packages/jpl/src/java/Makefile" ;;
"packages/pyswip/Makefile") CONFIG_FILES="$CONFIG_FILES packages/pyswip/Makefile" ;;
"packages/ProbLog/simplecudd/Makefile") CONFIG_FILES="$CONFIG_FILES packages/ProbLog/simplecudd/Makefile" ;;
"packages/ProbLog/simplecudd_lfi/Makefile") CONFIG_FILES="$CONFIG_FILES packages/ProbLog/simplecudd_lfi/Makefile" ;;
"packages/swi-minisat2/Makefile") CONFIG_FILES="$CONFIG_FILES packages/swi-minisat2/Makefile" ;;
"packages/swi-minisat2/C/Makefile") CONFIG_FILES="$CONFIG_FILES packages/swi-minisat2/C/Makefile" ;;
*) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
done
# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used. Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
fi
# Have a temporary directory for convenience. Make it in the build tree
# simply because there is no reason against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
tmp=
trap 'exit_status=$?
{ test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
' 0
trap 'as_fn_exit 1' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
test -n "$tmp" && test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then
ac_cr=`echo X | tr X '\015'`
# On cygwin, bash can eat \r inside `` if the user requested igncr.
# But we know of no other shell where ac_cr would be empty at this
# point, so we can use a bashism as a fallback.
if test "x$ac_cr" = x; then
eval ac_cr=\$\'\\r\'
fi
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
ac_cs_awk_cr='\r'
else
ac_cs_awk_cr=$ac_cr
fi
echo 'BEGIN {' >"$tmp/subs1.awk" &&
_ACEOF
{
echo "cat >conf$$subs.awk <<_ACEOF" &&
echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
echo "_ACEOF"
} >conf$$subs.sh ||
as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
. ./conf$$subs.sh ||
as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
if test $ac_delim_n = $ac_delim_num; then
break
elif $ac_last_try; then
as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
rm -f conf$$subs.sh
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{148\}\)..*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t nl
:delim
h
s/\(.\{148\}\)..*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t delim
' >$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
}
{
line = $ 0
nfields = split(line, field, "@")
substed = 0
len = length(field[1])
for (i = 2; i < nfields; i++) {
key = field[i]
keylen = length(key)
if (S_is_set[key]) {
value = S[key]
line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
len += length(value) + length(field[++i])
substed = 1
} else
len += 1 + keylen
}
print line
}
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
|| as_fn_error "could not setup config files machinery" "$LINENO" 5
_ACEOF
# VPATH may cause trouble with some makes, so we remove $(srcdir),
# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=/{
s/:*\$(srcdir):*/:/
s/:*\${srcdir}:*/:/
s/:*@srcdir@:*/:/
s/^\([^=]*=[ ]*\):*/\1/
s/:*$//
s/^[^=]*=[ ]*$//
}'
fi
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"
# Set up the scripts for CONFIG_HEADERS section.
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
cat >"$tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF
# Transform confdefs.h into an awk script `defines.awk', embedded as
# here-document in config.status, that substitutes the proper values into
# config.h.in to produce config.h.
# Create a delimiter string that does not exist in confdefs.h, to ease
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
ac_t=`sed -n "/$ac_delim/p" confdefs.h`
if test -z "$ac_t"; then
break
elif $ac_last_try; then
as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
else
ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
fi
done
# For the awk script, D is an array of macro values keyed by name,
# likewise P contains macro parameters if any. Preserve backslash
# newline sequences.
ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
sed -n '
s/.\{148\}/&'"$ac_delim"'/g
t rset
:rset
s/^[ ]*#[ ]*define[ ][ ]*/ /
t def
d
:def
s/\\$//
t bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3"/p
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
d
:bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3\\\\\\n"\\/p
t cont
s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
t cont
d
:cont
n
s/.\{148\}/&'"$ac_delim"'/g
t clear
:clear
s/\\$//
t bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/"/p
d
:bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
b cont
' >$CONFIG_STATUS || ac_write_fail=1
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
for (key in D) D_is_set[key] = 1
FS = ""
}
/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
line = \$ 0
split(line, arg, " ")
if (arg[1] == "#") {
defundef = arg[2]
mac1 = arg[3]
} else {
defundef = substr(arg[1], 2)
mac1 = arg[2]
}
split(mac1, mac2, "(") #)
macro = mac2[1]
prefix = substr(line, 1, index(line, defundef) - 1)
if (D_is_set[macro]) {
# Preserve the white space surrounding the "#".
print prefix "define", macro P[macro] D[macro]
next
} else {
# Replace #undef with comments. This is necessary, for example,
# in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it.
if (defundef == "undef") {
print "/*", prefix defundef, macro, "*/"
next
}
}
}
{ print }
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
as_fn_error "could not setup config headers machinery" "$LINENO" 5
fi # test -n "$CONFIG_HEADERS"
eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
shift
for ac_tag
do
case $ac_tag in
:[FHLC]) ac_mode=$ac_tag; continue;;
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
:L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
ac_save_IFS=$IFS
IFS=:
set x $ac_tag
IFS=$ac_save_IFS
shift
ac_file=$1
shift
case $ac_mode in
:L) ac_source=$1;;
:[FH])
ac_file_inputs=
for ac_f
do
case $ac_f in
-) ac_f="$tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
test -f "$ac_f" ||
case $ac_f in
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
done
# Let's still pretend it is `configure' which instantiates (i.e., don't
# use $as_me), people would be surprised to read:
# /* config.h. Generated by config.status. */
configure_input='Generated from '`
$as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
`' by configure.'
if test x"$ac_file" != x-; then
configure_input="$ac_file. $configure_input"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
fi
# Neutralize special characters interpreted by sed in replacement strings.
case $configure_input in #(
*\&* | *\|* | *\\* )
ac_sed_conf_input=`$as_echo "$configure_input" |
sed 's/[\\\\&|]/\\\\&/g'`;; #(
*) ac_sed_conf_input=$configure_input;;
esac
case $ac_tag in
*:-:* | *:-) cat >"$tmp/stdin" \
|| as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac
ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$ac_file" : 'X\(//\)[^/]' \| \
X"$ac_file" : 'X\(//\)$' \| \
X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
as_dir="$ac_dir"; as_fn_mkdir_p
ac_builddir=.
case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
# A ".." for each directory in $ac_dir_suffix.
ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
case $ac_top_builddir_sub in
"") ac_top_builddir_sub=. ac_top_build_prefix= ;;
*) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix
case $srcdir in
.) # We are building in place.
ac_srcdir=.
ac_top_srcdir=$ac_top_builddir_sub
ac_abs_top_srcdir=$ac_pwd ;;
[\\/]* | ?:[\\/]* ) # Absolute name.
ac_srcdir=$srcdir$ac_dir_suffix;
ac_top_srcdir=$srcdir
ac_abs_top_srcdir=$srcdir ;;
*) # Relative name.
ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
ac_top_srcdir=$ac_top_build_prefix$srcdir
ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
case $ac_mode in
:F)
#
# CONFIG_FILE
#
case $INSTALL in
[\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
*) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
esac
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# If the template does not know about datarootdir, expand it.
# FIXME: This hack should be removed a few years after 2.60.
ac_datarootdir_hack=; ac_datarootdir_seen=
ac_sed_dataroot='
/datarootdir/ {
p
q
}
/@datadir@/p
/@docdir@/p
/@infodir@/p
/@localedir@/p
/@mandir@/p'
case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
*datarootdir*) ac_datarootdir_seen=yes;;
*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_datarootdir_hack='
s&@datadir@&$datadir&g
s&@docdir@&$docdir&g
s&@infodir@&$infodir&g
s&@localedir@&$localedir&g
s&@mandir@&$mandir&g
s&\\\${datarootdir}&$datarootdir&g' ;;
esac
_ACEOF
# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
s&@INSTALL@&$ac_INSTALL&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
|| as_fn_error "could not create $ac_file" "$LINENO" 5
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
{ ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
{ ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined." >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined." >&2;}
rm -f "$tmp/stdin"
case $ac_file in
-) cat "$tmp/out" && rm -f "$tmp/out";;
*) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
esac \
|| as_fn_error "could not create $ac_file" "$LINENO" 5
;;
:H)
#
# CONFIG_HEADER
#
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
} >"$tmp/config.h" \
|| as_fn_error "could not create $ac_file" "$LINENO" 5
if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
mv "$tmp/config.h" "$ac_file" \
|| as_fn_error "could not create $ac_file" "$LINENO" 5
fi
else
$as_echo "/* $configure_input */" \
&& eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
|| as_fn_error "could not create -" "$LINENO" 5
fi
;;
esac
done # for ac_tag
as_fn_exit 0
_ACEOF
ac_clean_files=$ac_clean_files_save
test $ac_write_fail = 0 ||
as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded. So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status. When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
ac_cs_success=:
ac_config_status_args=
test "$silent" = yes &&
ac_config_status_args="$ac_config_status_args --quiet"
exec 5>/dev/null
$SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
exec 5>>config.log
# Use ||, not &&, to avoid exiting from the if with $? = 1, which
# would make configure fail if this is the last instruction.
$ac_cs_success || as_fn_exit $?
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
yap-6.2.2/configure.in 000755 000765 000024 00000156401 11651110416 014567 0 ustar 00vsc staff 000000 000000 dnl
dnl Process this file with autoconf to produce a configure script.
dnl
AC_PREREQ([2.50])
dnl VARIABLES EXPORTED
dnl
dnl ARCH
dnl
dnl DefHeapSpace= Default DB space
dnl DefStackSpace= Default global+local
dnl DefTrailSpace= Default trail
dnl
dnl CPLINT
dnl
dnl CPLINT_LIBS=
dnl CPLINT_LIBS=
dnl CPLINT_LDFLAGS=
dnl CPLINT_SHLIB_LD=
dnl
dnl ENVIRONMENT to run YAP before Install is complete
dnl PRE_INSTALL_ENV= prefix to run YAP after libYap.so and yap are available
dnl but before make install
dnl INSTALL_ENV= prefix to run YAP while doing make install
dnl
dnl EXEC_SUFFIX=suffix for executable (.exe)
dnl
dnl INSTALL_DLLS= we can do dynamic linking
dnl SO= suffix for loadable binary (.so,.dll,.o)
dnl MERGE_DLL_OBJS= we need to merge several .o files into a single dll.
dnl
dnl CXXFLAGS= C++-flags
dnl SHLIB_FLAGS= C-flags used to compile a file that will be loaded dynamically
dnl DO_SECOND_LD= call a separate dll ld
dnl YAPLIB_LD= construct libYap.DLL
dnl SHLIB_LD= dll ld (C)
dnl SHLIB_CXX_LD= dll ld (C++)
dnl SHLIB_CFLAGS= cflags to use when constructing a DLL
dnl SHLIB_CXX_CFLAGS= c++flags to use when constructing a DLL
dnl YAPLIB_CFLAGS=flags to construct libYap
dnl EXTRA_LIBS_FOR_DLLS= libs that are required when lding a so
dnl EXTRA_LIBS_FOR_SWIDLLS= libs that are required when lding a SWI so
AC_INIT(console/yap.c)
AC_CONFIG_HEADER(config.h)
dnl store the environment's compilation flags
mycflags="$CFLAGS"
AC_PROG_CC
AC_PROG_CXX
AC_PROG_AWK
AC_SUBST(GCC)
AC_SUBST(C_INTERF_FLAGS)
AC_SUBST(C_PARSER_FLAGS)
AC_ARG_ENABLE(tabling,
[ --enable-tabling support tabling ],
tabling="$enableval", tabling=no)
AC_ARG_ENABLE(or-parallelism,
[ --enable-or-parallelism support or-parallelism as: env-copy,sba,a-cow ],
orparallelism="$enableval", orparallelism=no)
AC_ARG_ENABLE(rational-trees,
[ --enable-rational-trees support infinite rational trees ],
rationaltrees="$enableval" , rationaltrees=yes)
AC_ARG_ENABLE(coroutining,
[ --enable-coroutining support co-routining, attributed variables and constraints],
rationaltrees="$enableval";coroutining="$enableval", coroutining=yes)
AC_ARG_ENABLE(depth-limit,
[ --enable-depth-limit support depth-bound computation ],
depthlimit="$enableval", depthlimit=yes)
AC_ARG_ENABLE(wam-profile,
[ --enable-wam-profile support low level profiling of abstract machine ],
wamprofile="$enableval", wamprofile=no)
AC_ARG_ENABLE(low-level-tracer,
[ --enable-low-level-tracer support support for procedure-call tracing ],
lowleveltracer="$enableval", lowleveltracer=no)
AC_ARG_ENABLE(threads,
[ --enable-threads support system threads ],
threads="$enableval", threads=no)
AC_ARG_ENABLE(pthread-locking,
[ --enable-pthread-locking use pthread locking primitives for internal locking (requires threads) ],
pthreadlocking="$enableval", pthreadlocking=no)
AC_ARG_ENABLE(max-performance,
[ --enable-max-performance try using the best flags for specific architecture ],
maxperformance="$enableval", maxperformance=no)
AC_ARG_ENABLE(max-memory,
[ --enable-max-memory try using the best flags for using the memory to the most ],
maxmemory="$enableval", maxmemory=yes)
AC_ARG_ENABLE(debug-yap,
[ --enable-debug-yap enable C-debugging for YAP ],
debugyap="$enableval", debugyap=no)
AC_ARG_ENABLE(eam,
[ --enable-eam enable EAM on YAP ],
eam="$enableval", eam=no)
AC_ARG_ENABLE(cygwin,
[ --enable-cygwin use cygwin library in WIN32 ],
cygwin="$enableval", cygwin=no)
AC_ARG_ENABLE(dynamic_loading,
[ --enable-dynamic-loading compile YAP as a DLL ],
dynamic_loading="$enableval", dynamic_loading=no)
AC_ARG_ENABLE(static_compilation,
[ --enable-static-compilation compile YAP statically ],
static_compilation="$enableval", static_compilation=no)
AC_ARG_ENABLE(use-malloc,
[ --enable-use-malloc use malloc to allocate memory ],
use_malloc="$enableval", use_malloc=no)
AC_ARG_ENABLE(condor,
[ --enable-condor allow YAP to be used from condor ],
use_condor="$enableval", use_condor=no)
AC_ARG_ENABLE(chr,
[ --enable-chr install chr library ],
use_chr="$enableval", use_chr=yes)
AC_ARG_ENABLE(clpqr,
[ --enable-clpqr install clpqr library ],
use_clpqr="$enableval", use_clpqr=yes)
AC_ARG_ENABLE(win64,
[ --enable-win64 compile YAP for win64 ],
target_win64="$enableval", target_win64=no)
AC_ARG_ENABLE(april,
[ --enable-april compile Yap to support April ILP system],
use_april="$enableval", use_april=no)
AC_ARG_ENABLE(dlcompat,
[ --enable-dlcompat use dlcompat library for dynamic loading on Mac OS X],
use_dlcompat="$enableval", use_dlcompat=no)
AC_ARG_ENABLE(cplint,
[ --enable-cplint[=DIR] enable the cplint library using the cudd library in DIR/lib],
yap_cv_cplint=$enableval, yap_cv_cplint=no)
AC_ARG_WITH(gmp,
[ --with-gmp[=DIR] use GNU Multiple Precision in DIR],
if test "$withval" = yes; then
yap_cv_gmp=yes
elif test "$withval" = no; then
yap_cv_gmp=no
else
yap_cv_gmp=$with_gmp
LDFLAGS="$LDFLAGS -L${yap_cv_gmp}/lib"
LIBS="$LIBS -L${yap_cv_gmp}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_gmp}/include"
CFLAGS="$CFLAGS -I${yap_cv_gmp}/include"
fi,
[yap_cv_gmp=yes])
dnl best test we could do.
AC_ARG_WITH(minisat,
[ --enable-minisat use minisat interface],
if test "$withval" = yes; then
yap_cv_minisat=yes
elif test "$withval" = no; then
yap_cv_minisat=no
else
yap_cv_minisat="$GXX"
fi,
[yap_cv_minisat=yes])
AC_ARG_WITH(cudd,
[ --with-cudd[=DIR] use CUDD package in DIR],
if test "$withval" = yes; then
yap_cv_cudd=yes
elif test "$withval" = no; then
yap_cv_cudd=no
elif test "$withval" = /opt/local; then
yap_cv_cudd=$with_cudd
CUDD_LDFLAGS="-L/opt/local/lib/cudd -lcudd"
CUDD_CPPFLAGS="-I /opt/local/include/cudd"
elif test "$withval" = /usr; then
yap_cv_cudd=$with_cudd
CUDD_LDFLAGS="-lcudd -lmtr -lcuddst -lcuddutil -lepd"
CUDD_CPPFLAGS="-I /usr/include/cudd"
else
yap_cv_cudd=$with_cudd
CUDD_LDFLAGS="$yap_cv_cudd/cudd/libcudd.a $yap_cv_cudd/mtr/libmtr.a $yap_cv_cudd/st/libst.a $yap_cv_cudd/util/libutil.a $yap_cv_cudd/epd/libepd.a"
CUDD_CPPFLAGS="-I $yap_cv_cudd/include"
fi,
[yap_cv_cudd=no])
AC_ARG_ENABLE(myddas,
v [ --enable-myddas[[=DIR]] enable the MYDDAS library],
if test "$enableval" = yes; then
yap_cv_myddas=/usr
elif test "$enableval" = no; then
yap_cv_myddas=no
else
yap_cv_myddas=$enable_myddas
LDFLAGS="$LDFLAGS -L${yap_cv_myddas}/lib "
CPPFLAGS="$CPPFLAGS -I${yap_cv_myddas}/include "
fi,
[yap_cv_myddas=/usr])
AC_ARG_ENABLE(myddas-stats,
[ --enable-myddas-stats enable the MYDDAS library statistics support],
if test "$yap_cv_myddas" = no; then
myddasstats=no
else
myddasstats="$enableval"
fi, myddasstats=no)
AC_ARG_ENABLE(myddas-top-level,
[ --enable-myddas-top-level enable the MYDDAS top-level support to MySQL],
if test "$yap_cv_myddas" = no; then
myddastoplevel=no
else
myddastoplevel="$enableval"
fi, myddastoplevel=no)
AC_ARG_WITH(java,
[ --with-java=JAVA_HOME use Java instalation in JAVA_HOME],
if test "$withval" = yes; then
yap_cv_java="$JAVA_HOME"
dynamic_loading=yes
maxmemory=yes
dnl threads=yes
elif test "$withval" = no; then
yap_cv_java=no
else
yap_cv_java=$with_java
dynamic_loading=yes
maxmemory=yes
dnl threads=yes
fi,
[yap_cv_java=no])
AC_ARG_WITH(readline,
[ --with-readline[=DIR] use GNU Readline Library in DIR],
if test "$withval" = yes; then
yap_cv_readline=yes
elif test "$withval" = no; then
yap_cv_readline=no
else
yap_cv_readline=$with_readline
LDFLAGS="$LDFLAGS -L${yap_cv_readline}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_readline}/include"
fi,
[yap_cv_readline=yes])
AC_ARG_WITH(matlab,
[ --with-matlab[=DIR] use MATLAB package in DIR],
if test "$withval" = yes; then
yap_cv_matlab=yes
elif test "$withval" = no; then
yap_cv_matlab=no
else
yap_cv_matlab=$with_matlab
MATLAB_INCLUDE="-I${yap_cv_matlab}/extern/include"
fi,
[yap_cv_matlab=no])
AC_ARG_WITH(mpi,
[ --with-mpi[=DIR] use MPI library in DIR],
if test "$withval" = yes; then
yap_cv_mpi=yes
elif test "$withval" = no; then
yap_cv_mpi=no
else
yap_cv_mpi=$with_mpi
LDFLAGS="$LDFLAGS -L${yap_cv_mpi}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_mpi}/include"
fi,
[yap_cv_mpi=no])
AC_ARG_WITH(mpe,
[ --with-mpe[=DIR] use MPE library in DIR],
if test "$withval" = yes; then
yap_cv_mpe=yes
elif test "$withval" = no; then
yap_cv_mpe=no
else
yap_cv_mpe=$with_mpe
LDFLAGS="$LDFLAGS -L${yap_cv_mpe}/lib"
CPPFLAGS="$CPPFLAGS -I${yap_cv_mpe}/include"
fi,
[yap_cv_mpe=no])
AC_ARG_WITH(lam,
[ --with-lam[=DIR] use LAM MPI library in DIR],
if test "$withval" = yes; then
yap_cv_lam=yes
elif test "$withval" = no; then
yap_cv_lam=no
else
yap_cv_lam=$with_lam
LDFLAGS="$LDFLAGS -L${yap_cv_lam}/lib/lam"
CPPFLAGS="$CPPFLAGS -I${yap_cv_lam}/include"
fi,
[yap_cv_lam=no])
AC_ARG_WITH(heap-space,
[ --with-heap-space[=space] default heap size in Kbytes],
if test "$withval" = yes; then
yap_cv_heap_space=0
elif test "$withval" = no; then
yap_cv_heap_space=0
else
yap_cv_heap_space=$withval
fi,
[yap_cv_heap_space=0])
AC_ARG_WITH(stack-space,
[ --with-stack-space[=space] default stack size in Kbytes],
if test "$withval" = yes; then
yap_cv_stack_space=0
elif test "$withval" = no; then
yap_cv_stack_space=0
else
yap_cv_stack_space=$withval
fi,
[yap_cv_stack_space=0])
AC_ARG_WITH(trail-space,
[ --with-trail-space[=space] default trail size in Kbytes],
if test "$withval" = yes; then
yap_cv_trail_space=0
elif test "$withval" = no; then
yap_cv_trail_space=0
else
yap_cv_trail_space=$withval
fi,
[yap_cv_trail_space=0])
AC_ARG_WITH(max-workers,
[ --with-max-workers[=integer] maximum number of or-parallel processes],
if test "$withval" = yes; then
yap_cv_max_workers="(8*SIZEOF_INT_P)"
elif test "$withval" = no; then
yap_cv_max_workers="1"
else
yap_cv_max_workers=$withval
fi,
[yap_cv_max_workers="(8*SIZEOF_INT_P)"])
AC_ARG_WITH(max-threads,
[ --with-max-threads[=integer] maximum number of or-parallel processes],
if test "$withval" = yes; then
yap_cv_max_threads="1024"
elif test "$withval" = no; then
yap_cv_max_threads="1"
else
yap_cv_max_threads=$withval
fi,
[yap_cv_max_threads="1024"])
AC_ARG_WITH(junit, [ --with-junit=PATH Specify location of the junit JAR file],
[case "$withval" in
yes) JUNIT=/usr/share/java/junit.jar
;;
no) JUNIT=""
;;
*) JUNIT="$withval"
;;
esac])
AC_DEFINE(MinHeapSpace, (1000*SIZEOF_INT_P))
AC_DEFINE(MinStackSpace,(300*SIZEOF_INT_P))
AC_DEFINE(MinTrailSpace,( 48*SIZEOF_INT_P))
AC_DEFINE_UNQUOTED(DefHeapSpace,$yap_cv_heap_space)
AC_DEFINE_UNQUOTED(DefStackSpace,$yap_cv_stack_space)
AC_DEFINE_UNQUOTED(DefTrailSpace,$yap_cv_trail_space)
AC_SUBST(DefHeapSpace)
AC_SUBST(DefStackSpace)
AC_SUBST(DefTrailSpace)
AC_CANONICAL_SYSTEM
AC_DEFINE_UNQUOTED(HOST_ALIAS,"${target}")
if test "$or-parallelism" = no
then
AC_DEFINE(MAX_WORKERS,1)
else
AC_DEFINE_UNQUOTED(MAX_WORKERS,$yap_cv_max_workers)
fi
if test "$threads" = no
then
AC_DEFINE(MAX_THREADS,1)
else
AC_DEFINE_UNQUOTED(MAX_THREADS,$yap_cv_max_threads)
fi
dnl condor does not like dynamic linking on Linux, DEC, and HP-UX platforms.
if test "$yap_cv_matlab" = no
then
INSTALL_MATLAB="@# "
elif test "$yap_cv_matlab" = yes
then
INSTALL_MATLAB=""
else
case "$target_cpu" in
i*86*)
LDFLAGS="$LDFLAGS -L${yap_cv_matlab}/bin/glnx86"
;;
x86*)
LDFLAGS="$LDFLAGS -L${yap_cv_matlab}/bin/glnxa64"
;;
sparc*)
LDFLAGS="$LDFLAGS -L${yap_cv_matlab}/bin/sol2"
;;
esac
INSTALL_MATLAB=""
fi
if test "$yap_cv_cudd" = no
then
USE_CUDD="@# "
else
USE_CUDD=""
fi
dnl condor universe does not like dynamic linking on Linux, DEC, and HP-UX platforms.
if test "$use_condor" = yes
then
static_compilation="yes"
use_malloc="yes"
CC="condor_compile $CC"
CXX="condor_compile $CXX"
dnl no readline with condor.
yap_cv_readline="no"
AC_DEFINE(SUPPORT_CONDOR, 1)
dnl and it disables minisat
yap_cv_minisat=no
STATIC_MODE=""
else
static_compilation="no"
STATIC_MODE="# "
fi
if test "$yap_cv_minisat" = no
then
USE_MINISAT="@# "
elif test "$INSTALL_DLLS" = "#"
then
USE_MINISAT="@# "
else
USE_MINISAT=""
fi
dnl Compilation Flags
if test "$GCC" = "yes"
then
if test "$debugyap" = "yes"
then
CXXFLAGS="-O -g -Wall $CFLAGS"
C_INTERF_FLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
CFLAGS="-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
else
CXXFLAGS="-O3 -fomit-frame-pointer -Wall $CFLAGS"
C_INTERF_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
C_PARSER_FLAGS="-O3 -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
CFLAGS="-O3 -fomit-frame-pointer -Wall -Wstrict-prototypes -Wmissing-prototypes $CFLAGS"
case "`$CC --version < /dev/null`" in
*3.4*) CFLAGS="-fno-gcse -fno-crossjumping $CFLAGS" ;;
esac
case "$target_cpu" in
i*86*)
CFLAGS="-DBP_FREE $CFLAGS"
CXXFLAGS="-DBP_FREE $CXXFLAGS"
;;
sparc*)
case "$target_os" in
*solaris[2-9]*) dnl
CFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFLAGS"
CXXFLAGS="-mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1 $CFPPLAGS"
;;
esac
;;
esac
if test "$tcpu"; then
target_cpu=$tcpu
fi
if test "$maxperformance" = "yes"
then
case "$target_cpu" in
athlon)
CFLAGS="-march=athlon $CFLAGS"
CXXFLAGS="-march=athlon $CXXFLAGS"
;;
i686*)
CFLAGS="-march=i686 $CFLAGS"
CXXFLAGS="-march=i686 $CXXFLAGS"
;;
i586*)
CFLAGS="-march=i586 $CFLAGS"
CXXFLAGS="-march=i586 $CXXFLAGS"
;;
i486*)
CFLAGS="-march=i486 $CFLAGS"
CXXFLAGS="-march=i486 $CXXFLAGS"
;;
i386*)
CFLAGS="-march=i386 $CFLAGS"
CXXFLAGS="-march=i386 $CXXFLAGS"
;;
esac
fi
fi
if test "$CC" = "sslittle-na-sstrix-gcc"
then
RANLIB="sslittle-na-sstrix-ranlib"
AR="sslittle-na-sstrix-ar"
PRE_INSTALL_ENV="sim-fast"
INSTALL_ENV="sim-fast"
fi
else
case "$target_cpu" in
i?86*)
if test "$CC" = "lcc"
then
CFLAGS="-A -A $CFLAGS"
elif test "$CC" = "cl"
then
CXXFLAGS="-/nologo $CFLAGS"
CFLAGS="/nologo $CFLAGS"
CPP="/nologo /E"
fi
;;
hppa*)
if test "$CC" = "cc" -o $CC = c89
then
if test "$debugyap" = "yes"
then
CXXFLAGS="-Ae -g -O $CFLAGS"
CFLAGS="-Ae -g -O $CFLAGS"
else
CXXFLAGS="-Ae +O3 +Onolimit $CFLAGS"
CFLAGS="-Ae +O3 +Onolimit $CFLAGS"
fi
fi
dnl LDFLAGS="+e UserCPredicate $LDFLAGS"
;;
esac
C_INTERF_FLAGS="$CFLAGS"
C_PARSER_FLAGS="$CFLAGS"
fi
dnl Checks for programs.
AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_CHECK_TOOL(INDENT,indent,:)
AC_CHECK_TOOL(AR,ar,:)
AC_CHECK_TOOL(MPI_CC,mpicc,:)
AC_PATH_PROG(INSTALL_INFO,install-info,true,$PATH:/sbin:/usr/sbin:/usr/etc:/usr/local/sbin)
AC_PATH_PROG(SHELL,sh)
dnl Check for libraries.
dnl mingw does not get along well with libm
dnl cygnus and mingw32 also need wsock32 to use sockets.
dnl
if test "$target_os" = "cygwin" -o "$target_os" = "mingw32"
then
INSTALL_COMMAND=install_win32
if test "$cygwin" = "no" -o "$target_os" = "mingw32"
then
if test "$target_win64" = yes
then
AC_CHECK_LIB(ws2_32,main)
EXTRA_LIBS_FOR_DLLS="-lws2_32 \$(abs_top_builddir)/yap.dll"
elif test "$target_os" = "cygwin"
then
CC="${CC} -mno-cygwin"
CXX="${CXX} -mno-cygwin"
AC_CHECK_LIB(wsock32,main)
EXTRA_LIBS_FOR_DLLS="\$(abs_top_builddir)/yap.dll"
else
AC_CHECK_LIB(wsock32,main)
EXTRA_LIBS_FOR_DLLS="\$(abs_top_builddir)/yap.dll"
fi
AC_CHECK_LIB(psapi,main)
yap_cv_readline=no
if test "$target_win64" = yes
CLIB_NETLIBS="-lws2_32 -lpsapi -lgdi32"
then
CLIB_NETLIBS="-lwsock32 -lpsapi -lgdi32"
fi
if test "$prefix" = "NONE"
then
if test "$target_win64" = yes
then
prefix="\${SYSTEMDRIVE}/Yap64"
CLIB_NETLIBS="-lwsock32 -lpsapi -lgdi32"
else
prefix="\${SYSTEMDRIVE}/Yap"
fi
fi
ENABLE_WINCONSOLE=""
else
ENABLE_WINCONSOLE="#"
LIBS="-lcygwin"
EXTRA_LIBS_FOR_DLLS="\$(abs_top_builddir)/yap.dll"
fi
else
INSTALL_COMMAND="install_unix"
ENABLE_WINCONSOLE="#"
AC_CHECK_LIB(m,sin)
AC_CHECK_LIB(socket,socket)
dnl X/Open Networking is sometimes a separate library
AC_CHECK_LIB(xnet,getsockname)
AC_CHECK_LIB(stdc++,main)
AC_CHECK_LIB(nsl,main,
have_nsl=yes
,
have_nsl=no)
AC_CHECK_LIB(crypt,main)
AC_CHECK_LIB(nss_files,main)
AC_CHECK_LIB(nss_dns,main)
AC_CHECK_LIB(resolv,main)
fi
if test "$yap_cv_readline" != "no"
then
AC_CHECK_LIB([readline], [main],[
AC_DEFINE([HAVE_LIBREADLINE], [1],[Define if you have libreadline])
LIBS="$LIBS -lreadline -lncurses"
],
[if test "x$with_readline" != xcheck; then
AC_MSG_FAILURE(
[--with-readline was given, but test for readline failed])
fi
], -lncurses)
fi
if test "$yap_cv_gmp" != "no"
then
AC_CHECK_LIB(gmp,main)
fi
dnl if test "$yap_cv_cudd" != "no"
dnl then
dnl AC_CHECK_LIB(cudd,Cudd_Init)
dnl fi
dnl check if we have zlib
AC_CHECK_LIB(z, zlibVersion,
ZLIBS="-lz"
ZLIB=yes,
ZLIB=no)
if test $ZLIB = yes
then
LIBS="$LIBS -lz"
fi
if test "$yap_cv_myddas" != "no"
then
dnl check for mysql
AC_MSG_CHECKING(for main in -lmysqlclient)
AC_CACHE_VAL(yap_cv_mysql,[
AC_TRY_COMPILE(
#include
#include
,
MYSQL *conn;
conn = mysql_init(NULL);
,
yap_cv_mysql=yes,yap_cv_mysql=no)])
AC_MSG_RESULT($yap_cv_mysql)
if test "$yap_cv_mysql" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_MYSQL"
LIBS="$LIBS -L${yap_cv_myddas}/lib/mysql -lmysqlclient "
fi
dnl check for odbc
AC_MSG_CHECKING(for main in -lodbc)
AC_CACHE_VAL(yap_cv_odbc,[
AC_TRY_COMPILE(
#include
#include
#include
,
SQLHENV henv;
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
,
yap_cv_odbc=yes,yap_cv_odbc=no)])
AC_MSG_RESULT($yap_cv_odbc)
if test "$yap_cv_odbc" = yes
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_ODBC"
case "$target_os" in
*darwin9*)
LIBS="$LIBS -lodbc -framework CoreFoundation"
;;
**)
LIBS="$LIBS -lodbc"
;;
esac
fi
fi
if test "$myddasstats" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_STATS"
fi
if test "$myddastoplevel" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DMYDDAS_TOP_LEVEL"
fi
if test "$threads" = yes
then
AC_DEFINE(SUPPORT_THREADS, 1)
AC_CHECK_LIB(pthread,pthread_create)
AC_CHECK_HEADERS(pthread.h)
AC_CHECK_FUNCS(pthread_mutexattr_setkind_np pthread_mutexattr_settype)
if test "$pthreadlocking" = yes
then
AC_DEFINE(USE_PTHREAD_LOCKING, 1)
fi
use_malloc=yes
fi
if test ! -z "$GCC"; then
COFLAGS="${COFLAGS--O2 -cc-options,-fno-strict-aliasing}"
CWFLAGS="${CWFLAGS--Wall}"
else
COFLAGS="${COFLAGS--O}"
CWFLAGS="${CWFLAGS-}"
fi
CMFLAGS=-fpic
CIFLAGS=-I.
if test "$use_chr" = no; then
ENABLE_CHR="@# "
elif test -e "$srcdir"/packages/chr/Makefile.in; then
ENABLE_CHR=""
else
ENABLE_CHR="@# "
fi
if test "$use_clpqr" = no; then
ENABLE_CLPQR="@# "
elif test -e "$srcdir"/packages/clpqr/Makefile.in; then
ENABLE_CLPQR=""
else
ENABLE_CLPQR="@# "
fi
dnl
dnl java is hard
dnl
if test "$yap_cv_java" = no; then
ENABLE_JPL="@#"
elif test -e "$srcdir"/packages/jpl/Makefile.in; then
ENABLE_JPL=""
JAVA=java
JAVA_HOME="$yap_cv_java"
case "$target_os" in
*cygwin*|*mingw*)
if test $threads = yes; then
JAVALIBPATH="\"$JAVA_HOME\"/lib/jvm.lib -lpthread"
else
JAVALIBPATH="\"$JAVA_HOME\"/lib/jvm.lib"
fi
JAVAINCPATH="-I\"$JAVA_HOME\"/include -I\"$JAVA_HOME\"/include/win32"
;;
*darwin*)
LIBS="$LIBS -framework JavaVM"
JAVALIBPATH="-L/System/Library/Frameworks/JavaVM.framework/Libraries -Wl,-framework,JavaVM"
JAVAINCPATH="-I/System/Library/Frameworks/JavaVM.framework/Headers"
;;
*)
case "$target_os" in
*linux*)
JAVAINCPATH="-I\"$JAVA_HOME\"/include -I\"$JAVA_HOME\"/include/linux"
;;
*solaris*)
JAVAINCPATH="-I\"$JAVA_HOME\"/include -I\"$JAVA_HOME\"/include/solaris"
;;
esac
case "$target_cpu" in
i*86*)
JAVA_TARGET=i386
;;
x86*)
JAVA_TARGET=amd64
;;
sparc*)
JAVA_TARGET=sparc
;;
esac
JAVALIBPATH="-L$JAVA_HOME/jre/lib/$JAVA_TARGET -L$JAVA_HOME/jre/lib/$JAVA_TARGET/client -L$JAVA_HOME/jre/lib/$JAVA_TARGET/server -Wl,-R,$JAVA_HOME/jre/lib/$JAVA_TARGET -ljava -lverify -ljvm "
;;
esac
if test "$yap_cv_java" = ""; then
JAVA=java
JAR=jar
JAVAC=javac
JAVADOC=javadoc
else
JAVA="$yap_cv_java"/bin/java
JAR="$yap_cv_java"/bin/jar
JAVAC="$yap_cv_java"/bin/javac
JAVADOC="$yap_cv_java"/bin/javadoc
fi
else
ENABLE_JPL="@#"
fi
LAM_MPI_CC=${MPI_CC}
MPI_OBJS=
if test "$yap_cv_mpi" != "no"
then
OLD_CC=${CC}
CC=${MPI_CC}
AC_CHECK_LIB(mpi,MPI_Init,
[AC_DEFINE(HAVE_LIBMPI, 1)],
[AC_DEFINE(HAVE_LIBMPI, 0)])
if test "$ac_cv_lib_mpi_MPI_Init" = yes
then
#YAPMPILIB=YapMPI.a
MPI_OBJS=mpi.o
else
AC_CHECK_LIB(mpich,MPI_Init,
[AC_DEFINE(HAVE_LIBMPICH, 1)],
[AC_DEFINE(HAVE_LIBMPICH, 0)])
if test "$ac_cv_lib_mpich_MPI_Init" = yes
then
#YAPMPILIB=YapMPI.a
MPI_OBJS=mpi.o
else
#YAPMPILIB=
MPI_CC=${CC}
fi
fi
CC=${OLD_CC}
else
# MPI_CC=${MPI_CC}
MPI_CC=${CC}
fi
MPI_LIBS=
if test "$yap_cv_mpi" != "no" -a "$yap_cv_mpe" != "no"
then
OLD_CC=${CC}
CC=${MPI_CC}
AC_CHECK_LIB(mpe,MPE_Init_log,
[AC_DEFINE(HAVE_LIBMPE, 1)],
[AC_DEFINE(HAVE_LIBMPE, 0)])
if test "$ac_cv_lib_mpe_MPE_Init_log" = yes
then
MPI_LIBS="-lmpe"
MPI_OBJS="$MPI_OBJS mpe.o"
fi
CC=${OLD_CC}
fi
AC_PROG_CPP
if test "$cross_compiling" = "yes"
then
YAP_EXTRAS=
else
AC_SYS_RESTARTABLE_SYSCALLS
fi
dnl defaults
INSTALL_DLLS="#"
EXTRA_OBJS=""
SHLIB_LD="#"
SHLIB_CXX_LD="#"
DO_SECOND_LD="#"
M4="m4"
MERGE_DLL_OBJS="#"
IN_UNIX=""
dnl This has to be before $target_os
YAPLIB="libYap.a"
dnl now this is where things get nasty.
dnl trying to get the libraries
case "$target_os" in
*linux*)
if test "$static_compilation" = "no"
then
AC_CHECK_LIB(dl,dlopen,
have_dl=yes
,
have_dl=no)
if test "$have_dl" = "yes"
then
SO="so"
SHLIB_LD="$CC -shared -export-dynamic"
SHLIB_CXX_LD="$CXX -shared -export-dynamic"
DO_SECOND_LD=""
LIBS="$LIBS -ldl"
case "$target_cpu" in
alpha*)
LDFLAGS="-dynamic $LDFLAGS"
;;
*)
if test "$CC" != "lcc"
then
LDFLAGS="-rdynamic $LDFLAGS"
fi
;;
esac
fi
if test "$ac_cv_prog_gcc" = "yes"
then
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
INSTALL_DLLS=""
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG="-Wl,-soname=$DYNYAPLIB"
fi
if test "$have_nsl" = yes
then
LIBS="$LIBS -lnsl"
fi
if test "$dynamic_loading" = "yes"
then
YAPLIB_LD="\$(CC) -shared"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
else
YAPLIB_LD="\$(CC)"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
INSTALL_ENV="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
PRE_INSTALL_ENV=""
fi
;;
*sunos4*)
M4="/usr/5bin/m4"
LDFLAGS="$LDFLAGS -N"
if test "$have_nsl" = yes
then
LIBS="$LIBS -lnsl"
fi
SO="o"
INSTALL_DLLS=""
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*hpux*)
#do not use the first memory quadrant
AC_DEFINE(FORCE_SECOND_QUADRANT)
M4="/usr/bin/m4"
if test ${use_condor} = no
then
SHLIB_INTERFACE="load_shl.o"
if test "$CC" = cc -o "$CC" = c89
then
#this tells ld to export all non-static symbols,
#otherwise no external predicates.
SHLIB_LD="$CC -shared -export-dynamic"
SHLIB_CXX_LD="$CXX -shared -export-dynamic"
DO_SECOND_LD=""
SO="sl"
SHLIB_CFLAGS="+z $CFLAGS"
SHLIB_CXXFLAGS="+z $CXXFLAGS"
INSTALL_DLLS=""
# If the xnet library was found, turn on X/Open networking
if test "$ac_cv_lib_xnet_getsockname" = yes
then
AC_DEFINE(_XOPEN_SOURCE)
AC_DEFINE(_XOPEN_SOURCE_EXTENDED,1)
fi
else
INSTALL_DLLS="#"
fi
fi
#do not use realloc() from HP-UX 10.20 together with MPI
if test ${target_os} = hpux10.20
then
AC_DEFINE(MPI_AVOID_REALLOC,1)
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*aix*)
# To actually use dlls in AIX I'd need to build YAP as a DLL first.
# I won't bother for now.
#
# SO="a"
#SHLIB_LD="\$(srcdir)/../../ldAix /bin/ld -bhalt:4 -bM:SRE -bE:lib.exp -H512 -T512 -bnoentry"
#INSTALL_DLLS=""
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*osf*)
if ${use_condor} = no
then
AC_CHECK_LIB(dl,dlopen,
dnl Linux has both elf and a.out, in this case we found elf
have_dl=yes
,
have_dl=no)
SO="so"
SHLIB_LD="ld -shared -expect_unresolved '*'"
DO_SECOND_LD=""
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*irix6*)
SHLIB_CFLAGS="$CFLAGS"
SHLIB_CXXFLAGS="$CXXFLAGS"
SO="so"
DO_SECOND_LD=""
SHLIB_LD="ld -n32 -shared -rdata_shared"
SHLIB_CXX_LD="$SHLIB_LD"
INSTALL_DLLS=""
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*darwin*)
if test ${use_dlcompat} = yes
then
AC_CHECK_LIB(dl,dlopen,
have_dl=yes
,
have_dl=no)
if test ${have_dl} = yes
then
LIBS="$LIBS -ldl"
fi
fi
SO="dylib"
DO_SECOND_LD=""
if test "$dynamic_loading" = "yes"
then
SHLIB_LD="$CC -dynamiclib"
SHLIB_CXX_LD="$CXX -dynamiclib"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-install_name,\$(YAPLIBDIR)/\$@"
INSTALL_ENV="DYLD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
else
SHLIB_LD="$CC -dynamiclib -Wl,-undefined,dynamic_lookup"
SHLIB_CXX_LD="$CXX -dynamiclib -Wl,-undefined,dynamic_lookup"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -Wl,-install_name,\$(YAPLIBDIR)/\$@"
INSTALL_ENV="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
fi
if test "$ac_cv_prog_gcc" = "yes"
then
SHLIB_CFLAGS="-shared -fPIC $CFLAGS"
SHLIB_CXXFLAGS="-shared -fPIC $CXXFLAGS"
INSTALL_DLLS=""
fi
CC="$CC -fstrict-aliasing -freorder-blocks -fsched-interblock -Wall -Wstrict-aliasing=2"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
YAPLIB_LD="$CC -dynamiclib -Wl,-install_name,$prefix/lib/libYap.$SO"
PRE_INSTALL_ENV="DYLD_LIBRARY_PATH=\$(abs_top_builddir)"
;;
*netbsd*|*openbsd*|*freebsd*|*dragonfly*)
if echo __ELF__ | ${CC:-cc} -E - | grep -q __ELF__
then
#an a.out system
SHLIB_CFLAGS="$CFLAGS"
SHLIB_CXXFLAGS="$CXXFLAGS"
SO="o"
else
#an elf system
LDFLAGS="-Wl,--export-dynamic $LDFLAGS"
SHLIB_CFLAGS="-fPIC $CFLAGS"
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
SHLIB_LD="$CC -shared -export-dynamic"
SHLIB_CXX_LD="$CXX -shared -export-dynamic"
DO_SECOND_LD=""
SO="so"
INSTALL_DLLS=""
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG="-Wl,--soname=$DYNYAPLIB"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -Wl,-R,\$(YAPLIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
*solaris*)
#an elf system
LDFLAGS="-dynamic $LDFLAGS"
SHLIB_CFLAGS="-fPIC $CFLAGS"
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
SHLIB_LD="$CC -shared"
SHLIB_CXX_LD="$CXX -shared"
DO_SECOND_LD=""
SO="so"
INSTALL_DLLS=""
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG="-Wl,--soname=$DYNYAPLIB"
if test "$dynamic_loading" = "yes"
then
YAPLIB_LD="\$(CC)"
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
else
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV=""
YAPLIB_LD="\$(CC) -shared"
INSTALL_ENV="YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
fi
;;
*cyg*|*mingw*)
# gcc on cygwin seems to have trouble with longjmp
# and -fomit-frame-point -DBP_FREE
YAPLIB="yap.dll"
DYNYAPLIB="yap.dll"
SONAMEFLAG=""
SHLIB_CFLAGS="$CFLAGS"
SHLIB_CXXFLAGS="$CXXFLAGS"
if test "$target_win64" = no
then
LDFLAGS="-Wl,--large-address-aware $LDFLAGS"
fi
SHLIB_LD="\$(CC) -shared -Wl,--export-all-symbols"
SHLIB_CXX_LD="\$(CXX) -shared -Wl,--export-all-symbols"
SO="dll"
C_PARSER_FLAGS="$C_INTERF_FLAGS"
EXEC_SUFFIX=".exe"
INSTALL_DLLS=""
DO_SECOND_LD=""
MERGE_DLL_OBJS=""
IN_UNIX="#"
YAPLIB_LD="\$(CC) -shared -Wl,--export-all-symbols"
PRE_INSTALL_ENV=""
INSTALL_ENV=""
;;
*)
AC_CHECK_LIB(dl,dlopen,
have_dl=yes
,
have_dl=no)
if test "$have_dl" = yes
then
SO="o"
LIBS="$LIBS -ldl"
INSTALL_DLLS=""
if test "$GCC" = "yes"
then
SHLIB_CXXFLAGS="-fPIC $CXXFLAGS"
fi
fi
if test "$have_nsl" = yes
then
LIBS="$LIBS -lnsl"
fi
LDFLAGS="$LDFLAGS -L\$(abs_top_builddir) -Wl,-R,\$(LIBDIR) -Wl,-R,\$(YAPLIBDIR)"
DYNYAPLIB=libYap."$SO"
SONAMEFLAG=""
EXTRA_LIBS_FOR_DLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir) -lYap -Wl,-R,\$(YAPLIBDIR) -Wl,-R,\$(LIBDIR)"
PRE_INSTALL_ENV="LD_LIBRARY_PATH=\$(abs_top_builddir)"
INSTALL_ENV="LD_LIBRARY_PATH=\$(DESTDIR)\$(LIBDIR):\$(DESTDIR)\$(YAPLIBDIR): YAPSHAREDIR=\$(DESTDIR)\$(SHAREDIR) YAPLIBDIR=\$(DESTDIR)\$(YAPLIBDIR)"
;;
esac
EXTRA_LIBS_FOR_SWIDLLS="$EXTRA_LIBS_FOR_DLLS -L\$(abs_top_builddir)/packages/PLStream -lplstream"
if test "$dynamic_loading" = "yes"
then
YAPLIB_CFLAGS="$SHLIB_CFLAGS"
YAPLIB="$DYNYAPLIB"
else
YAPLIB_CFLAGS="$CFLAGS"
fi
if test "$coroutining" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DCOROUTINING=1"
fi
if test "$rationaltrees" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DRATIONAL_TREES=1"
fi
if test "$rationaltrees" = "yes" -a "$coroutining" = "yes"
then
INSTALLCLP=""
else
INSTALLCLP="@#"
fi
if test "$debugyap" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DDEBUG=1"
fi
if test "$eam" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DBEAM"
fi
if test "$wamprofile" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DANALYST=1"
fi
if test "$depthlimit" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DDEPTH_LIMIT=1"
fi
if test "$use_april" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DDEPTH_LIMIT=1 -DAPRIL"
LDFLAGS="$LDFLAGS -L."
LIBS="$LIBS -lApril"
fi
if test "$lowleveltracer" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DLOW_LEVEL_TRACER=1"
fi
if test "$threads" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DTHREADS=1"
if test "$GCC" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -D_GNU_SOURCE"
fi
fi
case "$orparallelism" in
sba)
YAP_EXTRAS="$YAP_EXTRAS -DSBA=1"
;;
a-cow)
YAP_EXTRAS="$YAP_EXTRAS -DACOW=1"
;;
yes|env-copy)
YAP_EXTRAS="$YAP_EXTRAS -DENV_COPY=1"
;;
esac
if test "$cutc" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DCUT_C=1"
fi
if test "$tabling" = "yes"
then
YAP_EXTRAS="$YAP_EXTRAS -DTABLING=1"
fi
if test ! "$yap_cv_cplint" = "no"
then
if test ! "$yap_cv_cplint" = "yes"
then
CPLINT_LDFLAGS+=" -L${yap_cv_cplint}/cudd -L${yap_cv_cplint}/mtr -L${yap_cv_cplint}/st -L${yap_cv_cplint}/util -L${yap_cv_cplint}/epd "
CPLINT_CFLAGS+=" -I${yap_cv_cplint}/include"
CPLINT_LIBS="-lcudd -lmtr -lst -lepd -lutil -lm "$CPLINT_LIBS
fi
ENABLE_CPLINT=""
if test "$target_os" = "cygwin" -o "$target_os" = "mingw32"
then
CPLINT_SHLIB_LD="gcc -shared ../../yap.dll"
SHLIB_SUFFIX="dll"
else
CPLINT_SHLIB_LD=$SHLIB_LD
SHLIB_SUFFIX="so"
fi
AC_SUBST(CPLINT_LIBS)
AC_SUBST(CPLINT_CFLAGS)
AC_SUBST(CPLINT_LDFLAGS)
AC_SUBST(CPLINT_SHLIB_LD)
AC_SUBST(SHLIB_SUFFIX)
else
ENABLE_CPLINT="@#"
fi
AC_SUBST(ENABLE_CPLINT)
AC_SUBST(INSTALL_ENV)
AC_SUBST(PRE_INSTALL_ENV)
AC_CHECK_LIB(z, zlibVersion,
ZLIBS="-lz"
ZLIB=yes,
ZLIB=no)
if test "$ZLIB" = yes; then
ZLIB_TARGETS="zlib4pl.$SO"
ZLIB_PLTARGETS='$(srcdir)/zlib.pl'
ZLIB_INSTALL=install
else
ZLIB_TARGETS=nolib
ZLIB_INSTALL=nolib
cat << EOF
##################################################################
# ERROR: Could not find library zlib (-lz). Dropped library(zlib)
# Library zlib is available from http://www.zlib.net/
# Most Unix/Linux distributions are shipped with binaries. Make
# sure to have the development library installed.
##################################################################
EOF
fi
AC_SUBST(ZLIBS)
AC_SUBST(ZLIB_TARGETS)
AC_SUBST(ZLIB_PLTARGETS)
AC_SUBST(ZLIB_INSTALL)
# LAM
OLD_CC=${CC}
CC=${LAM_MPI_CC}
AC_CHECK_LIB([lam], [main],
LAMOBJS=yap_mpi."$SO",
LAMOBJS=no)
CC=${OLD_CC}
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(arpa/inet.h alloca.h crypt.h)
AC_CHECK_HEADERS(ctype.h direct.h dirent.h dlfcn.h)
AC_CHECK_HEADERS(errno.h execinfo.h fcntl.h fenv.h)
AC_CHECK_HEADERS(float.h fpu_control.h ieeefp.h io.h limits.h)
AC_CHECK_HEADERS(locale.h malloc.h math.h memory.h)
AC_CHECK_HEADERS(mpe.h mpi.h)
AC_CHECK_HEADERS(netdb.h netinet/in.h netinet/tcp.h pwd.h regex.h)
AC_CHECK_HEADERS(siginfo.h signal.h stdarg.h string.h stropts.h)
AC_CHECK_HEADERS(sys/conf.h sys/dir.h sys/file.h)
AC_CHECK_HEADERS(sys/mman.h sys/ndir.h sys/param.h)
AC_CHECK_HEADERS(sys/resource.h sys/select.h)
AC_CHECK_HEADERS(sys/shm.h sys/socket.h sys/stat.h)
AC_CHECK_HEADERS(sys/time.h sys/times.h sys/types.h)
AC_CHECK_HEADERS(sys/ucontext.h sys/un.h sys/wait.h)
AC_CHECK_HEADERS(time.h unistd.h utime.h wctype.h winsock.h winsock2.h)
AC_CHECK_HEADERS(zlib.h zutil.h)
AC_CHECK_HEADERS(mach-o/dyld.h)
if test "$yap_cv_gmp" != "no"
then
AC_CHECK_HEADERS(gmp.h)
fi
if test "$yap_cv_cudd" != "no"
then
AC_CHECK_HEADERS(cudd.h)
fi
if test "$yap_cv_myddas" != "no"
then
AC_CHECK_HEADERS(mysql/mysql.h)
fi
if test "$yap_cv_readline" != "no"
then
AC_CHECK_HEADERS( readline/readline.h)
fi
AC_CHECK_HEADERS(mpe.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_STRUCT_TM
AC_CHECK_SIZEOF(int *,4)
AC_CHECK_SIZEOF(short int,2)
AC_CHECK_SIZEOF(int,4)
AC_CHECK_SIZEOF(long int,4)
AC_CHECK_SIZEOF(long long int,8)
AC_CHECK_SIZEOF(float,4)
AC_CHECK_SIZEOF(double,8)
dnl check type of malloc (i.e. char * or void *)
AC_MSG_CHECKING(for type of malloc)
AC_CACHE_VAL(yap_cv_malloct,[
AC_TRY_RUN(
#include
char *malloc(size_t);
int main() {
void *p=malloc(1);
return 0;
}
,
yap_cv_malloct=char,yap_cv_malloct=void,yap_cv_malloct=void)])
AC_MSG_RESULT($yap_cv_malloct *)
if test "$yap_cv_malloct" = void
then AC_DEFINE(MALLOC_T,void *)
else AC_DEFINE(MALLOC_T,char *)
fi
dnl check how to generate headers (i.e. should we use GCC inline?)
AC_MSG_CHECKING(for gcc inline)
AC_CACHE_VAL(yap_cv_gcc,[
AC_TRY_RUN(
#undef inline
inline int f(int x) {return x+1;}
int main() { return 0;}
,
yap_cv_gcc=yes,yap_cv_gcc=no,yap_cv_gcc=yes)])
AC_MSG_RESULT($yap_cv_gcc)
if test "$yap_cv_gcc" = yes
then
M4GENHDRS=m4/gcc_genhdrs.m4
AC_DEFINE(HAVE_GCC,1)
else
M4GENHDRS=m4/cc_genhdrs.m4
AC_DEFINE(HAVE_GCC,0)
fi
AC_SUBST(M4)
AC_SUBST(M4GENHDRS)
dnl SWI compatibility, I don't know why just use host...
changequote(,)dnl
if test "x$ARCH" = "x"; then
case "$host" in
*linux*)
ARCH=`echo $host | sed 's/-.*/-linux/'`
;;
*-gnu)
ARCH=`echo $host | sed 's/\([^-]*\)-[^-]*-\([^-]*\)-gnu/\1-\2/'`
;;
*)
ARCH=`echo $host | sed 's/\([^-]*\)-[^-]*-\([^-]*\)/\1-\2/'`
;;
esac
fi
changequote([,])dnl
AC_SUBST(ARCH)
dnl System stuff for dynamic linking.
dnl
dnl Exports:
dnl
dnl "" if we can do dynamic linking, "#" otherwise
AC_SUBST(INSTALL_DLLS)
dnl if we need to merge several .o files into a single dll.
AC_SUBST(MERGE_DLL_OBJS)
dnl C-flags used to compile a file that will be loaded dynamically
AC_SUBST(CXXFLAGS)
AC_SUBST(SHLIB_CFLAGS)
AC_SUBST(SHLIB_CXXFLAGS)
dnl suffix for loadable binary (.so,.dll,.o)
AC_SUBST(SO)
dnl suffix for executable (.exe)
AC_SUBST(EXEC_SUFFIX)
dnl how to call the loader
AC_SUBST(DO_SECOND_LD)
AC_SUBST(SHLIB_LD)
AC_SUBST(SHLIB_CXX_LD)
AC_SUBST(YAPLIB_LD)
AC_SUBST(YAPLIB_CFLAGS)
AC_SUBST(EXTRA_LIBS_FOR_DLLS)
AC_SUBST(EXTRA_LIBS_FOR_SWIDLLS)
dnl objects in YAP library
AC_SUBST(YAPLIB)
AC_SUBST(DYNYAPLIB)
AC_SUBST(LDFLAGS)
AC_SUBST(SONAMEFLAG)
dnl install_info
AC_SUBST(INSTALL_INFO)
dnl let YAP_EXTRAS fall through configure, from the env into Makefile
AC_SUBST(YAP_EXTRAS)
AC_SUBST(NO_BUILTIN_REGEXP)
AC_SUBST(ENABLE_CHR)
AC_SUBST(ENABLE_CLPQR)
AC_SUBST(ENABLE_JPL)
AC_SUBST(JAVA)
AC_SUBST(JAVA_HOME)
AC_SUBST(JUNIT)
AC_SUBST(JAVAC)
AC_SUBST(JAVADOC)
AC_SUBST(JAR)
AC_SUBST(IN_UNIX)
AC_SUBST(YAPMPILIB)
AC_SUBST(LAM_MPI_CC)
AC_SUBST(MPI_OBJS)
AC_SUBST(MPI_LIBS)
AC_SUBST(INSTALL_COMMAND)
AC_SUBST(INSTALLCLP)
AC_SUBST(JAVALIBPATH)
AC_SUBST(JAVAINCPATH)
AC_SUBST(LAMOBJS)
AC_SUBST(MAX_WORKERS)
AC_SUBST(STATIC_MODE)
AC_SUBST(ENABLE_WINCONSOLE)
AC_SUBST(USE_CUDD)
AC_SUBST(CUDD_LDFLAGS)
AC_SUBST(CUDD_CPPFLAGS)
AC_SUBST(USE_MINISAT)
AC_SUBST(INSTALL_MATLAB)
AC_SUBST(MATLAB_INCLUDE)
dnl check for threaded code
AC_MSG_CHECKING(for gcc threaded code)
AC_CACHE_VAL(yap_cv_threaded_code,[
AC_TRY_RUN(
int main() {
void *t = &&l2;
l1: goto *t;
l2: return 0;
}
,
yap_cv_threaded_code=yes,yap_cv_threaded_code=no,yap_cv_threaded_code=yes)])
AC_MSG_RESULT($yap_cv_threaded_code)
if test "$yap_cv_threaded_code" = yes && test "$yap_cv_gcc" = yes
then
AC_DEFINE(USE_THREADED_CODE,1)
M4GENABSMI=gen_gcc.m4
else
AC_DEFINE(USE_THREADED_CODE,0)
M4GENABSMI=gen_ansi.m4
fi
AC_SUBST(M4GENABSMI)
dnl check for IEEE floats
AC_MSG_CHECKING(for IEEE floats)
AC_CACHE_VAL(yap_cv_ffieee,[
AC_TRY_RUN(
int main() {
union { float f; int i} a;
a.f = 1;
if (a.i==0x3f800000) return 0;
return 1;
}
,
yap_cv_ffieee=yes,yap_cv_ffieee=no,yap_cv_ffieee=yes)])
AC_MSG_RESULT($yap_cv_ffieee)
if test "$yap_cv_ffieee" = yes
then
AC_DEFINE(FFIEEE,1)
else
AC_DEFINE(FFIEEE,0)
fi
dnl check for sigsetjmp
AC_MSG_CHECKING(for sigsetjmp)
AC_CACHE_VAL(yap_cv_sigsetjmp,[
AC_TRY_COMPILE(
#include
,
sigjmp_buf RestartEnv;
siglongjmp (RestartEnv, 1);
,
yap_cv_sigsetjmp=yes,yap_cv_sigsetjmp=no)])
AC_MSG_RESULT($yap_cv_sigsetjmp)
if test "$yap_cv_sigsetjmp" = yes
then
AC_DEFINE(HAVE_SIGSETJMP,1)
else
AC_DEFINE(HAVE_SIGSETJMP,0)
fi
dnl check for sigsegv
AC_MSG_CHECKING(for sigsegv)
AC_CACHE_VAL(yap_cv_sigsegv,[
AC_TRY_COMPILE(
#include
#include
,
printf("Signal value is %d\n", SIGSEGV);
,
yap_cv_sigsegv=yes,yap_cv_sigsegv=no)])
AC_MSG_RESULT($yap_cv_sigsegv)
if test "$yap_cv_sigsegv" = yes
then
AC_DEFINE(HAVE_SIGSEGV,1)
else
AC_DEFINE(HAVE_SIGSEGV,0)
fi
dnl check for sigsegv
AC_MSG_CHECKING(for sigprof)
AC_CACHE_VAL(yap_cv_sigprof,[
AC_TRY_COMPILE(
#include
#include
,
printf("Signal value is %d\n", SIGPROF);
,
yap_cv_sigprof=yes,yap_cv_sigprof=no)])
AC_MSG_RESULT($yap_cv_sigprof)
if test "$yap_cv_sigsegv" = yes
then
AC_DEFINE(HAVE_SIGPROF,1)
else
AC_DEFINE(HAVE_SIGPROF,0)
fi
dnl check for siginfo
AC_MSG_CHECKING(for siginfo)
AC_CACHE_VAL(yap_cv_siginfo,[
AC_TRY_COMPILE(
#include
#include
,
printf("SIGINFO value is %d\n", SA_SIGINFO);
,
yap_cv_siginfo=yes,yap_cv_siginfo=no)])
AC_MSG_RESULT($yap_cv_siginfo)
if test "$yap_cv_siginfo" = yes
then
AC_DEFINE(HAVE_SIGINFO,1)
else
AC_DEFINE(HAVE_SIGINFO,0)
fi
dnl this is copied from the Tcl code
dnl this code checks whether the system defines an union wait
AC_MSG_CHECKING([union wait])
AC_TRY_LINK([#include
#include ], [
union wait x;
wait(&x); /* make sure we can compile wait */
WIFEXITED(x); /* Generates compiler error if WIFEXITED
* uses an int. */
], union_wait_ok=yes, union_wait_ok=no)
AC_MSG_RESULT($union_wait_ok)
if test "$union_wait_ok" = no; then
AC_DEFINE(NO_UNION_WAIT)
fi
dnl check whether the system supports the environ variable
AC_MSG_CHECKING([environ])
AC_TRY_LINK([], [
extern char **environ;
], environ_ok=yes, environ_ok=no)
AC_MSG_RESULT($environ_ok)
if test "$environ_ok" = yes; then
AC_DEFINE(HAVE_ENVIRON)
fi
dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(_NSGetEnviron access acosh)
AC_CHECK_FUNCS(alloca asinh atanh chdir ctime dlopen dup2)
AC_CHECK_FUNCS(erf feclearexcept)
AC_CHECK_FUNCS(fesettrapenable fgetpos finite fpclass ftime getcwd getenv)
AC_CHECK_FUNCS(gethostbyname gethostent gethostid gethostname)
AC_CHECK_FUNCS(gethrtime getpagesize)
AC_CHECK_FUNCS(getpwnam getrlimit getrusage gettimeofday getwd)
AC_CHECK_FUNCS(isatty isnan isinf kill labs link lgamma)
AC_CHECK_FUNCS(localtime lstat mallinfo)
AC_CHECK_FUNCS(mbsnrtowcs)
AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp)
AC_CHECK_FUNCS(nanosleep mktime opendir)
AC_CHECK_FUNCS(putenv rand random readlink regexec)
AC_CHECK_FUNCS(rename rint rl_set_prompt sbrk select)
AC_CHECK_FUNCS(setbuf setitimer setsid setlinebuf sigaction)
AC_CHECK_FUNCS(siggetmask siginterrupt)
AC_CHECK_FUNCS(signal sigprocmask socket stat)
AC_CHECK_FUNCS(strchr strerror stricmp strncat strncpy strtod)
AC_CHECK_FUNCS(time times tmpnam usleep utime vsnprintf)
AC_CHECK_FUNC(regexec, [NO_BUILTIN_REGEXP="#"], [NO_BUILTIN_REGEXP=""])
AC_CHECK_FUNCS(NSLinkModule)
if test "$use_condor" = "no"
then
AC_CHECK_FUNCS(alarm mmap popen shmat sleep system ttyname waitpid)
fi
if test "$target_os" != "mingw32"
then
AC_CHECK_FUNCS(fetestexcept snprintf)
fi
dnl check for mpz_xor
AC_MSG_CHECKING(for mpz_xor)
AC_CACHE_VAL(yap_cv_mpz_xor,[
AC_TRY_LINK(
#include
void check(mpz_t rop,mpz_t op1,mpz_t op2) {
mpz_xor(rop,op1,op2);
}
,
,
yap_cv_mpz_xor=yes,yap_cv_mpz_xor=no)])
AC_MSG_RESULT($yap_cv_mpz_xor)
if test "$yap_cv_mpz_xor" = yes
then
AC_DEFINE(HAVE_MPZ_XOR,1)
else
AC_DEFINE(HAVE_MPZ_XOR,0)
fi
if test "$use_malloc" = "yes" -a "$maxmemory" = "yes"
then
maxmemory="no"
fi
dnl On some systems doing a fflush(NULL) to flush all output streams
dnl has the side-effect of makeing all charactes waiting in input
dnl pipes disapear.
AC_CACHE_CHECK(
[if fflush(NULL) clobbers input pipes],
[yap_cv_broken_fflush_null],
[ cat >conftest.$ac_ext <
#include
int main(int argc, char **argv)
{
char *buf;
int i;
char *bp;
bp = buf = malloc(1024);
while (1) {
while ((i = getc(stdin)) != -1
&& (*bp++ = i) != '\n'
&& (bp - buf < 1024) )
/* DO NOTHING */ ;
*bp = '\0';
fprintf(stdout, "%s", buf);
fflush(NULL);
if( i == EOF ) return 0;
bp = buf;
}
}
EOF
AC_TRY_EVAL(ac_link)
if test "$?" = 0
then
cat conftest.$ac_ext | ./conftest$ac_exeext > conftest.out
AC_TRY_COMMAND(cmp conftest.$ac_ext conftest.out)
if test "$?" = 0
then
AC_MSG_RESULT(no)
yap_cv_broken_fflush_null=no
else
AC_MSG_RESULT(yes)
yap_cv_broken_fflush_null=yes
fi
else
dnl This should never happen
AC_MSG_RESULT(failed)
yap_cv_broken_fflush_null=failed
fi
rm -f conftest.$ac_ext conftest.$ac_objext conftest$ac_exeext conftest.out ])
if test "$yap_cv_broken_fflush_null" = no
then
AC_DEFINE(BROKEN_FFLUSH_NULL,0)
else
dnl be conservative: if the test failed, assume fflush(NULL) is
dnl not working properly
AC_DEFINE(BROKEN_FFLUSH_NULL,1)
fi
dnl disable smart memory management
if test "$use_malloc" = yes
then
AC_DEFINE(USE_SYSTEM_MALLOC,1)
AC_DEFINE(GC_NO_TAGS,1)
fi
dnl large memory configuration, don't trust Yap allocation routines
if test "$maxmemory" = yes
then
AC_DEFINE(GC_NO_TAGS,1)
AC_DEFINE(USE_DL_MALLOC,1)
fi
dnl SWI compatibility support!
PROLOG_SYSTEM=yap
IN_YAP=
IN_SWI="#"
CHR_TARGETS=chr_support."$SO"
AC_SUBST(PROLOG_SYSTEM)
AC_SUBST(IN_YAP)
AC_SUBST(IN_SWI)
AC_SUBST(TARGETS)
AC_SUBST(PLTARGETS)
AC_SUBST(CHR_TARGETS)
CLIB_TARGETS="random.$SO socket.$SO cgi.$SO memfile.$SO files.$SO mime.$SO crypt.$SO"
CLIB_PLTARGETS="\$(srcdir)/random.pl \$(srcdir)/socket.pl \$(srcdir)/cgi.pl \$(srcdir)/memfile.pl \$(srcdir)/filesex.pl \$(srcdir)/mime.pl \$(srcdir)/crypt.pl"
if test "$ac_cv_func_setitimer" = "yes"; then
CLIB_TARGETS="$CLIB_TARGETS time.$SO"
CLIB_PLTARGETS="$CLIB_PLTARGETS \$(srcdir)/time.pl"
else
echo "WARNING: no setitimer(); dropping time.pl from targets"
fi
if test "$IN_UNIX" = ""; then
CLIB_TARGETS="unix.$SO $CLIB_TARGETS"
CLIB_PLTARGETS="\$(srcdir)/unix.pl $CLIB_PLTARGETS"
CLIB_NETLIBS=
else
AC_CHECK_FUNC(socket, [], [
AC_CHECK_LIB(socket, socket,
[CLIB_NETLIBS="$CLIB_NETLIBS -lsocket"]
AC_DEFINE(HAVE_LIBSOCKET, 1,
"Define if you have the socket library (-lsocket)."))])
AC_CHECK_FUNC(gethostent, [], [
AC_CHECK_LIB(nsl, gethostent,
[CLIB_NETLIBS="$CLIB_NETLIBS -lnsl"]
AC_DEFINE(HAVE_LIBNSL, 1,
"Define if you have the nsl library (-lnsl)."))])
fi
AC_CHECK_LIB(pthread, pthread_create,
[CLIB_PTHREADS="-lpthread"],[CLIB_PTHREADS=""])
oldlibs="$LIBS"
AC_CHECK_LIB(crypt, crypt)
CLIB_CRYPTLIBS="$LIBS"
AC_CHECK_FUNCS(crypt)
LIBS="$oldlibs"
AC_SUBST(CLIB_PTHREADS)
AC_SUBST(CLIB_TARGETS)
AC_SUBST(CLIB_PLTARGETS)
AC_SUBST(CLIB_NETLIBS)
AC_SUBST(CLIB_CRYPTLIBS)
AC_CHECK_TYPES(socklen_t, [], [],
[
#include
#include
])
AC_CHECK_TYPES(ssize_t, [], [],
[
#include
#include
])
dnl tszet and timezone trouble
AC_MSG_CHECKING("variable timezone in tzset")
AC_TRY_RUN(
[ #include
#include
#ifdef __CYGWIN__
#define timezone _timezone
#endif
extern long timezone;
main()
{ tzset();
if ( timezone > -15*3600 &&
timezone < 15*3600 &&
timezone % 60 == 0 )
return 0;
exit(1);
}
],
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_VAR_TIMEZONE, 1,
[Define if tzset sets timezone variable]),
AC_MSG_RESULT(no),
AC_MSG_RESULT(assuming no))
AC_CHECK_MEMBER(struct tm.tm_gmtoff,
AC_DEFINE(HAVE_STRUCT_TIME_TM_GMTOFF, [],
[Define is struct tm has tm_gmtoff]),
[],
[#include ])
AC_MSG_CHECKING(_XOPEN_SOURCE)
AC_TRY_COMPILE(
[
#define _XOPEN_SOURCE
#include
],
[
], AC_DEFINE(DEFINE_XOPEN_SOURCE, 1,
"Define if _XOPEN_SOURCE is needed")
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
if test "$with_time" = yes; then
if test "$ac_cv_func_setitimer" = "yes"; then
TARGETS="$TARGETS time.$SO"
else
echo "WARNING: no setitimer(); dropping time.pl from targets"
fi
fi
if test "$ac_cv_func_getrlimit" = "yes"; then
TARGETS="$TARGETS rlimit.$SO"
else
echo "WARNING: no getrlimit(); dropping rlimit.pl from targets"
fi
mkdir -p library/lammpi
mkdir -p library/matrix
mkdir -p library/matlab
mkdir -p library/mpi
mkdir -p library/random
mkdir -p library/regex
mkdir -p library/system
mkdir -p library/tries
mkdir -p library/rltree
mkdir -p LGPL/clp
mkdir -p LGPL/swi_console
mkdir -p GPL
mkdir -p packages/
mkdir -p packages/clib
mkdir -p packages/clib/sha1
mkdir -p packages/clib/maildrop
mkdir -p packages/clib/maildrop/rfc822
mkdir -p packages/clib/maildrop/rfc2045
mkdir -p packages/CLPBN
mkdir -p packages/clpqr
mkdir -p packages/cplint
mkdir -p packages/cplint/approx
mkdir -p packages/cplint/slipcase
mkdir -p packages/cplint/approx/simplecuddLPADs
mkdir -p packages/http
mkdir -p packages/jpl
mkdir -p packages/jpl/src/java
mkdir -p packages/jpl/src/java/jpl
mkdir -p packages/jpl/src/java/jpl/fli
mkdir -p packages/jpl/src/java/jpl/test
mkdir -p packages/jpl/examples
mkdir -p packages/jpl/examples/java
mkdir -p packages/tai
mkdir -p packages/tai/libtai
mkdir -p packages/PLStream
mkdir -p packages/plunit
mkdir -p packages/ProbLog
mkdir -p packages/ProbLog/simplecudd
mkdir -p packages/ProbLog/simplecudd_lfi
mkdir -p packages/RDF
mkdir -p packages/semweb
mkdir -p packages/sgml
mkdir -p packages/zlib
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([GPL/Makefile])
AC_CONFIG_FILES([library/Makefile])
AC_CONFIG_FILES([library/lammpi/Makefile])
AC_CONFIG_FILES([library/matlab/Makefile])
AC_CONFIG_FILES([library/matrix/Makefile])
AC_CONFIG_FILES([library/mpi/Makefile])
AC_CONFIG_FILES([library/random/Makefile])
AC_CONFIG_FILES([library/regex/Makefile])
AC_CONFIG_FILES([library/rltree/Makefile])
AC_CONFIG_FILES([library/system/Makefile])
AC_CONFIG_FILES([library/tries/Makefile])
AC_CONFIG_FILES([LGPL/Makefile])
AC_CONFIG_FILES([LGPL/clp/Makefile])
AC_CONFIG_FILES([LGPL/swi_console/Makefile])
AC_CONFIG_FILES([packages/clib/Makefile])
AC_CONFIG_FILES([packages/clib/maildrop/rfc822/Makefile])
AC_CONFIG_FILES([packages/clib/maildrop/rfc2045/Makefile])
AC_CONFIG_FILES([packages/CLPBN/Makefile])
AC_CONFIG_FILES([packages/cplint/Makefile])
AC_CONFIG_FILES([packages/cplint/approx/simplecuddLPADs/Makefile])
AC_CONFIG_FILES([packages/cplint/slipcase/Makefile])
AC_CONFIG_FILES([packages/http/Makefile])
AC_CONFIG_FILES([packages/tai/Makefile])
AC_CONFIG_FILES([packages/tai/libtai/Makefile])
AC_CONFIG_FILES([packages/PLStream/Makefile])
AC_CONFIG_FILES([packages/plunit/Makefile])
AC_CONFIG_FILES([packages/ProbLog/Makefile ])
AC_CONFIG_FILES([packages/RDF/Makefile])
AC_CONFIG_FILES([packages/semweb/Makefile])
AC_CONFIG_FILES([packages/sgml/Makefile])
AC_CONFIG_FILES([packages/zlib/Makefile])
if test "$ENABLE_CHR" = ""; then
AC_CONFIG_FILES([packages/chr/Makefile])
fi
if test "$ENABLE_CLPQR" = ""; then
AC_CONFIG_FILES([packages/clpqr/Makefile])
fi
if test "$ENABLE_JPL" = ""; then
AC_CONFIG_FILES([packages/jpl/Makefile packages/jpl/jpl_paths.yap packages/jpl/src/java/Makefile packages/pyswip/Makefile ])
fi
if test "$USE_CUDD" = ""; then
AC_CONFIG_FILES([packages/ProbLog/simplecudd/Makefile])
AC_CONFIG_FILES([packages/ProbLog/simplecudd_lfi/Makefile])
fi
if test "$USE_MINISAT" = ""; then
AC_CONFIG_FILES([packages/swi-minisat2/Makefile])
AC_CONFIG_FILES([packages/swi-minisat2/C/Makefile])
fi
AC_OUTPUT()
yap-6.2.2/console/ 000755 000765 000024 00000000000 11702065321 013707 5 ustar 00vsc staff 000000 000000 yap-6.2.2/COPYING 000755 000765 000024 00000000170 11457004724 013310 0 ustar 00vsc staff 000000 000000 This system is distributed under the LGPL licence terms. For details
visit http://www.gnu.org/copyleft/lesser.html.
yap-6.2.2/CVSROOT/ 000755 000765 000024 00000000000 11702065321 013404 5 ustar 00vsc staff 000000 000000 yap-6.2.2/distribute 000755 000765 000024 00000004525 11457004724 014366 0 ustar 00vsc staff 000000 000000 #/bin/bash
# Guess what: this code works for me!
version="Yap-5.1.4"
splat
cd C
splat
cd ../H
splat
cd ../BEAM
splat
cd ../OPTYap
splat
cd ../VC
splat
cd ../LGPL
splat
cd chr
splat
cd ../clp
splat
cd ../JPL
splat
cd src
splat
cd ../java
splat
cd jpl
splat
cd fli
splat
cd ../../../../pillow
splat
cd examples
splat
cd ../../../GPL
splat
cd clpqr
splat
cd clpq
splat
cd ../clpqr
splat
cd ../clpr
splat
cd ../../../include
splat
cd ../CLPBN
splat
cd clpbn
splat
cd examples
splat
cd School
splat
cd ../mn
splat
cd ../HMMer
splat
cd ../../../learning
splat
cd aleph_model
splat
cd ../nbayes
splat
cd ../utils
splat
#/bin/cp config.h config.h.mine
#/bin/cp ../../../bins/cyg/*.h .
#/bin/mv config.h.mine config.h
cd ../../../console
splat
cd ../docs
splat
cd ../include
splat
cd ../library
splat
cd regex
splat
cd ../system
splat
cd ../lammpi
splat
cd ../Tries
splat
cd ../mpi
splat
cd examples
splat
cd ../../tries
splat
cd ../matlab
splat
cd ../yap2swi
splat
cd ../../misc
splat
cd ../pl
splat
cd ../CLPQR
splat
cd clpq
splat
cd ../clpqr
splat
cd examples
splat
cd SESSION
splat
cd ../monash
splat
cd ../../../clpr
splat
cd ../../CHR
splat
cd chr
splat
cd ../../CLPBN
splat
cd clpbn
splat
cd examples
splat
cd ../../learning
splat
cd ../../..
if test "$1" = "--small"; then
tar cvzf "$version"-small.tar.gz --exclude=CVS "$version"/{Artistic,COPYING,INSTALL,README*,changes*,config*,install-sh,Makefile.in,.depend.in,distribute,C,H,VC,console,docs/*.tex,include,library,misc,pl,LGPL/README,LGPL/pillow/[C-Z]*,LGPL/pillow/*.pl,LGPL/pillow/doc/*info*,LGPL/JPL/jpl.yap,LGPL/JPL/jpl_paths.yap.in,LGPL/JPL/Makefile.in,LGPL/JPL/java,LGPL/JPL/src,build-distr,OPTYap,BEAM,MYDDAS,LGPL/clpr,LGPL/chr,LGPL/clp,CLPBN} --exclude=CLPBN/clpbn/backup --exclude=CLPBN/clpbn/devel --exclude=CLPBN/test
else
tar cvzf "$version".tar.gz --exclude=CVS "$version"/{Artistic,COPYING,INSTALL,README*,changes*,config*,install-sh,Makefile.in,.depend.in,distribute,C,H,VC,console,docs,include,library,misc,pl,LGPL/README,LGPL/pillow/[C-Z]*,LGPL/pillow/*.pl,LGPL/pillow/doc/*info*,LGPL/*.pl,LGPL/Makefile.in,LGPL/JPL/jpl.yap,LGPL/JPL/jpl_paths.yap.in,LGPL/JPL/Makefile.in,LGPL/JPL/java,LGPL/JPL/src,build-distr,build-distr,OPTYap,BEAM,MYDDAS,LGPL/chr,GPL/Makefile.in,GPL/*.pl,GPL/clpqr,CLPBN} --exclude=CLPBN/clpbn/backup --exclude=CLPBN/clpbn/devel --exclude=docs/index --exclude=CLPBN/test
fi
yap-6.2.2/docs/ 000755 000765 000024 00000000000 11702065321 013175 5 ustar 00vsc staff 000000 000000 yap-6.2.2/GIT 000644 000765 000024 00000000331 11457004724 012617 0 ustar 00vsc staff 000000 000000
You need at least git-1.6 to install the development version.
Please proceed as follows for the main branch:
git clone git://gitorious.org/yap-git/mainline.git yap
cd yap-6
git submodule init
git submodule update
yap-6.2.2/GPL/ 000755 000765 000024 00000000000 11702065321 012667 5 ustar 00vsc staff 000000 000000 yap-6.2.2/H/ 000755 000765 000024 00000000000 11710530301 012426 5 ustar 00vsc staff 000000 000000 yap-6.2.2/include/ 000755 000765 000024 00000000000 11702065320 013667 5 ustar 00vsc staff 000000 000000 yap-6.2.2/INSTALL 000644 000765 000024 00000007031 11457004724 013306 0 ustar 00vsc staff 000000 000000
These are some basic instructions to compile and install YAP:
1. How to compile Yap:
To compile YAP just do:
(1) mkdir arch
(2) cd arch
(3) ../configure ...options...
(4) check the Makefile for any extensions or changes you want to make.
(5) make
(6) If the compilation succeeds, try ./yap
(7) Happy? make install
If you want corouting or CLP(QR), please do replace step 3 by
(3') ../configure --enable-coroutining ...other options...
1.1 Where to install Yap
Recent versions of Yap try to follow GNU conventions on where to
place software.
o The main executable is placed at BINDIR. This executable is
actually a script that calls the Prolog engine, stored at LIBDIR.
o LIBDIR contains the Prolog engine and a Prolog library.
o INCLUDEDIR is used if you want to use Yap as a library.
1.2 Which Yap
Compiling Yap with the standard options give you a plain vanilla
Prolog. You can tune Yap to include some extra functionality
o -DCOROUTINING=1 gives you delaying on goals, eg, freeze.
o -DRATIONAL_TREES=1 includes support for rational trees.
o -DDEPTH_LIMIT=1 allows depth limited evaluation, say for
implementing iterative deepening.
o -DYAP_ARRAYS gives you two different styles of arrays.
o -DANALYST and -DLOW_LEVEL_TRACER give you low level
debugging. ANALYST tells how your program uses the abstract machine
instructions. LOW_LEVEL_TRACER dumps the gory details of what your
program is doing.
The next two options are good fun, but arguably not production
quality:
o -DTABLING gives tabling in XSB style.
o -DYAPOR gives or-parallelism in Muse style. If you add -DSBA to it
you will have the Sparse Binding Array instead of copying. If you add
-DACOW instead you will have the \alphaCOW model, that is, forking
instead of copying.
1.3 Porting Yap
The system has been mainly tested with GCC, but we have been able to
compile versions of Yap under lcc in Linux, Sun's cc compiler, IBM's
xlc, SGI's cc, Microsoft's Visual C++ 6.0 and HP's cc.
1.3.1 Yap and GCC
Yap has been developed to take advantage of GCC (but not to depend on
it). The major advantage of GCC is threaded code and register
reservation.
YAP is set by default to compile with the best compilation flags we
know. Even so, a few specific options can be used depending on the
architecture:
1.3.1.1 x86
The flag:
YAP_EXTRAS= ... -DBP_FREE=1
tells us to use the %bp register (frame-pointer) as the emulator's
program counter. This seems to be stable and should become default
real soon now.
1.3.1.2 Sparc/Solaris2
Use:
YAP_EXTRAS= ... -mno-app-regs -DOPTIMISE_ALL_REGS_FOR_SPARC=1
and YAP will get two extra registers! This trick does not work on
SunOS 4 machines.
1.3.1.3 Tuning GCC/Yap for your machine model
Versions of GCC can be tweaked for different processors, eg, 486,
Pentium, PentiumPro, Ultrasparc, Supersparc. Unfortunately, some of
these tweaks do may make Yap run slower or not at all in other machines
with the same instruction set, so they cannot be made default.
The best options also depends on the version of GCC you are using, and
it is a good idea to consult the GCC manual under the menus "Invoking
GCC"/"Submodel Options". We next describe a few:
(a) GCC up to 2.7.*:
o 486:
YAP_EXTRAS= ... -m486 -DBP_FREE=1
to take advantage of 486 specific optimisations in GCC 2.7.*.
o Pentium:
YAP_EXTRAS= ... -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2
o PentiumPros are known not to require alignment.
o Super and UltraSparcs:
YAP_EXTRAS= ... -msupersparc
(b) GCC 2.8.*, EGCS, GCC 2.95.*
o Check -march=XXX for fun.
yap-6.2.2/install-sh 000755 000765 000024 00000012721 11457004724 014263 0 ustar 00vsc staff 000000 000000 #! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
yap-6.2.2/LGPL/ 000755 000765 000024 00000000000 11702065320 013002 5 ustar 00vsc staff 000000 000000 yap-6.2.2/library/ 000755 000765 000024 00000000000 11702065320 013710 5 ustar 00vsc staff 000000 000000 yap-6.2.2/Makefile.in 000755 000765 000024 00000070526 11650110006 014320 0 ustar 00vsc staff 000000 000000 #
# default base directory for YAP installation
# (EROOT for architecture-dependent files)
#
prefix = @prefix@
exec_prefix = @exec_prefix@
ROOTDIR = $(prefix)
EROOTDIR = @exec_prefix@
#
# where the binary should be
#
BINDIR = $(EROOTDIR)/bin
#
# where YAP should look for binary libraries
#
LIBDIR=@libdir@
YAPLIBDIR=@libdir@/Yap
#
# where YAP should look for architecture-independent Prolog libraries
#
SHAREDIR=$(ROOTDIR)/share
#
# where the includes should be stored
#
INCLUDEDIR=$(ROOTDIR)/include/Yap
#
# where to store info files
#
INFODIR=$(SHAREDIR)/info
#
# where to store documentation files
#
DOCSDIR=$(SHAREDIR)/doc/Yap
#
# Add this flag to YAP_EXTRAS if you need the extension:
# -DRATIONAL_TREES: allow unification and builtins over rational trees
# -DCOROUTINING: implement extra control primitives
# -DANALYST: low level profiler
# -DDEPTH_LIMIT: support depth-limits in Prolog execution
# -DLOW_LEVEL_TRACER: low level tracing
#
# very experimental stuff, you'll need to contact the developers
# if you want to use this:
# -DENV_COPY: or-parallelism with environment copying, in Muse style.
# -DSBA: or-parallelism with sparse binding arrays.
# -DACOW: or-parallelism with copy-on-write.
# -DTABLING: support for tabling
#
#
# check also optimisation options in INSTALL file.
#
YAP_EXTRAS=-DCUT_C=1 @YAP_EXTRAS@
YAPSTARTUP=startup.yss
#
# Please do not add YAP_EXTRA flags here: if you do check the flags
# for c_interface.c
#
CC=@CC@
MPI_CC=@MPI_CC@
CPPFLAGS=@CPPFLAGS@ -I. -I$(srcdir)/H -I$(srcdir)/OPTYap -I$(srcdir)/BEAM -I$(srcdir)/MYDDAS
EXECUTABLE_CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS)
CFLAGS= @YAPLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS)
C_INTERF_FLAGS= @YAPLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS) -I$(srcdir)/include
C_PARSER_FLAGS= @YAPLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) $(CPPFLAGS)
#
#
# You shouldn't need to change what follows.
#
ARCH=@ARCH@
AWK=@AWK@
CPP=@CPP@
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
LIBS=@LIBS@
LDFLAGS=@LDFLAGS@
LN_S=@LN_S@
M4=@M4@
GCC=@GCC@
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_INFO=@INSTALL_INFO@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
M4GENHDRS=$(srcdir)/@M4GENHDRS@
M4GENABSMI=$(srcdir)/@M4GENABSMI@
INDENT=@INDENT@
SHELL=@SHELL@
RANLIB=@RANLIB@
AR=@AR@
srcdir=@srcdir@
abs_top_builddir=@abs_top_builddir@
SO=@SO@
MAKEINFO=makeinfo
TEXI2DVI=texi2dvi
TEXI2HTML=texi2html
TEXI2PDF=texi2pdf
YAPLIB=@YAPLIB@
SONAMEFLAG=@SONAMEFLAG@
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
CWD=$(PWD)
#
VERSION=6.2.2
MYDDAS_VERSION=MYDDAS-0.9.1
#
INTERFACE_HEADERS = \
$(srcdir)/include/c_interface.h \
$(srcdir)/include/clause_list.h \
$(srcdir)/include/dswiatoms.h \
$(srcdir)/include/udi.h \
$(srcdir)/include/rtree_udi.h \
$(srcdir)/include/yap_structs.h \
$(srcdir)/include/YapInterface.h \
$(srcdir)/include/SWI-Prolog.h \
$(srcdir)/include/SWI-Stream.h
HEADERS = \
$(srcdir)/H/TermExt.h \
$(srcdir)/H/Atoms.h \
$(srcdir)/H/Tags_32bits.h \
$(srcdir)/H/Tags_32Ops.h \
$(srcdir)/H/Tags_32LowTag.h \
$(srcdir)/H/Tags_64bits.h \
$(srcdir)/H/Tags_24bits.h \
$(srcdir)/H/sshift.h \
$(srcdir)/H/Yap.h \
$(srcdir)/H/Yatom.h \
$(srcdir)/H/YapHeap.h \
$(srcdir)/H/Regs.h \
$(srcdir)/H/Yapproto.h \
$(srcdir)/H/absmi.h \
$(srcdir)/H/alloc.h \
$(srcdir)/H/amidefs.h \
$(srcdir)/H/amiops.h \
$(srcdir)/H/arrays.h \
$(srcdir)/H/arith2.h \
$(srcdir)/H/attvar.h \
$(srcdir)/H/clause.h \
$(srcdir)/H/compile.h \
$(srcdir)/H/corout.h \
$(srcdir)/H/dlmalloc.h \
$(srcdir)/H/dglobals.h \
$(srcdir)/H/dhstruct.h \
$(srcdir)/H/eval.h \
$(srcdir)/H/heapgc.h \
$(srcdir)/H/hglobals.h \
$(srcdir)/H/hstruct.h \
$(srcdir)/H/iglobals.h \
$(srcdir)/H/ihstruct.h \
$(srcdir)/H/index.h \
$(srcdir)/H/iopreds.h \
$(srcdir)/H/iswiatoms.h \
$(srcdir)/H/rclause.h \
$(srcdir)/H/rglobals.h \
$(srcdir)/H/rheap.h \
$(srcdir)/H/rhstruct.h \
$(srcdir)/H/threads.h \
$(srcdir)/H/tracer.h \
$(srcdir)/H/trim_trail.h \
$(srcdir)/H/yapio.h \
$(srcdir)/BEAM/eam.h $(srcdir)/BEAM/eamamasm.h \
$(srcdir)/OPTYap/opt.config.h \
$(srcdir)/OPTYap/opt.proto.h $(srcdir)/OPTYap/opt.structs.h \
$(srcdir)/OPTYap/opt.macros.h $(srcdir)/OPTYap/or.macros.h \
$(srcdir)/OPTYap/or.sbaamiops.h $(srcdir)/OPTYap/or.sbaunify.h \
$(srcdir)/OPTYap/tab.structs.h $(srcdir)/OPTYap/locks_x86.h \
$(srcdir)/OPTYap/locks_sparc.h $(srcdir)/OPTYap/locks_mips.h \
$(srcdir)/OPTYap/locks_mips_funcs.h $(srcdir)/OPTYap/locks_alpha.h \
$(srcdir)/OPTYap/locks_alpha_funcs.h \
$(srcdir)/OPTYap/locks_pthread.h \
$(srcdir)/H/cut_c.h \
$(srcdir)/H/iatoms.h $(srcdir)/H/ratoms.h $(srcdir)/H/tatoms.h \
$(srcdir)/library/dialect/swi/fli/swi.h \
$(srcdir)/MYDDAS/myddas.h $(srcdir)/MYDDAS/myddas_structs.h \
$(srcdir)/MYDDAS/myddas_statistics.h \
$(srcdir)/MYDDAS/myddas_statistics_structs.h \
$(srcdir)/MYDDAS/myddas_wkb.h $(srcdir)/MYDDAS/myddas_wkb2prolog.h
C_SOURCES= \
$(srcdir)/C/absmi.c $(srcdir)/C/adtdefs.c \
$(srcdir)/C/agc.c $(srcdir)/C/alloc.c \
$(srcdir)/C/amasm.c $(srcdir)/C/analyst.c \
$(srcdir)/C/arith0.c $(srcdir)/C/arith1.c $(srcdir)/C/arith2.c \
$(srcdir)/C/arrays.c \
$(srcdir)/C/attvar.c $(srcdir)/C/bb.c \
$(srcdir)/C/bignum.c \
$(srcdir)/C/c_interface.c $(srcdir)/C/cdmgr.c $(srcdir)/C/cmppreds.c \
$(srcdir)/C/clause_list.c \
$(srcdir)/C/compiler.c $(srcdir)/C/computils.c \
$(srcdir)/C/corout.c $(srcdir)/C/dbase.c $(srcdir)/C/dlmalloc.c \
$(srcdir)/C/errors.c \
$(srcdir)/C/eval.c $(srcdir)/C/exec.c \
$(srcdir)/C/globals.c $(srcdir)/C/gmp_support.c \
$(srcdir)/C/gprof.c $(srcdir)/C/grow.c \
$(srcdir)/C/heapgc.c $(srcdir)/C/index.c \
$(srcdir)/C/init.c $(srcdir)/C/inlines.c \
$(srcdir)/C/iopreds.c $(srcdir)/C/depth_bound.c \
$(srcdir)/C/load_foreign.c \
$(srcdir)/C/load_dl.c $(srcdir)/C/load_dld.c $(srcdir)/C/load_none.c \
$(srcdir)/C/load_aout.c $(srcdir)/C/load_aix.c $(srcdir)/C/load_dll.c \
$(srcdir)/C/load_shl.c $(srcdir)/C/load_dyld.c \
$(srcdir)/C/mavar.c $(srcdir)/C/modules.c $(srcdir)/C/other.c \
$(srcdir)/C/parser.c \
$(srcdir)/C/readutil.c \
$(srcdir)/C/save.c $(srcdir)/C/scanner.c \
$(srcdir)/C/sort.c $(srcdir)/C/stdpreds.c $(srcdir)/C/sysbits.c \
$(srcdir)/C/threads.c \
$(srcdir)/C/tracer.c $(srcdir)/C/unify.c $(srcdir)/C/userpreds.c \
$(srcdir)/C/udi.c \
$(srcdir)/packages/udi/rtree.c \
$(srcdir)/packages/udi/rtree_udi.c \
$(srcdir)/C/utilpreds.c $(srcdir)/C/write.c $(srcdir)/console/yap.c \
$(srcdir)/C/ypsocks.c $(srcdir)/C/ypstdio.c \
$(srcdir)/BEAM/eam_am.c $(srcdir)/BEAM/eam_showcode.c \
$(srcdir)/BEAM/eamindex.c $(srcdir)/BEAM/eamamasm.c \
$(srcdir)/BEAM/eam_gc.c $(srcdir)/BEAM/eam_split.c \
$(srcdir)/OPTYap/opt.memory.c $(srcdir)/OPTYap/opt.init.c \
$(srcdir)/OPTYap/opt.preds.c $(srcdir)/OPTYap/or.engine.c \
$(srcdir)/OPTYap/or.cowengine.c $(srcdir)/OPTYap/or.sbaengine.c \
$(srcdir)/OPTYap/or.threadengine.c \
$(srcdir)/OPTYap/or.scheduler.c $(srcdir)/OPTYap/or.cut.c \
$(srcdir)/OPTYap/tab.tries.c $(srcdir)/OPTYap/tab.completion.c \
$(srcdir)/library/mpi/mpi.c $(srcdir)/library/mpi/mpe.c \
$(srcdir)/library/lammpi/yap_mpi.c $(srcdir)/library/lammpi/hash.c $(srcdir)/library/lammpi/prologterms2c.c \
$(srcdir)/C/cut_c.c \
$(srcdir)/library/dialect/swi/fli/swi.c \
$(srcdir)/library/dialect/swi/fli/blobs.c \
$(srcdir)/MYDDAS/myddas_mysql.c \
$(srcdir)/MYDDAS/myddas_odbc.c \
$(srcdir)/MYDDAS/myddas_util.c \
$(srcdir)/MYDDAS/myddas_initialization.c \
$(srcdir)/MYDDAS/myddas_shared.c \
$(srcdir)/MYDDAS/myddas_statistics.c \
$(srcdir)/MYDDAS/myddas_top_level.c \
$(srcdir)/MYDDAS/myddas_wkb2prolog.c
PL_SOURCES= \
$(srcdir)/pl/arith.yap \
$(srcdir)/pl/arrays.yap \
$(srcdir)/pl/attributes.yap \
$(srcdir)/pl/boot.yap \
$(srcdir)/pl/callcount.yap\
$(srcdir)/pl/checker.yap $(srcdir)/pl/chtypes.yap \
$(srcdir)/pl/consult.yap \
$(srcdir)/pl/control.yap \
$(srcdir)/pl/corout.yap $(srcdir)/pl/debug.yap \
$(srcdir)/pl/depth_bound.yap \
$(srcdir)/pl/dialect.yap \
$(srcdir)/pl/directives.yap \
$(srcdir)/pl/eam.yap \
$(srcdir)/pl/eval.yap \
$(srcdir)/pl/errors.yap \
$(srcdir)/pl/flags.yap \
$(srcdir)/pl/grammar.yap \
$(srcdir)/pl/ground.yap \
$(srcdir)/pl/hacks.yap \
$(srcdir)/pl/init.yap \
$(srcdir)/pl/listing.yap \
$(srcdir)/pl/lists.yap \
$(srcdir)/pl/messages.yap \
$(srcdir)/pl/load_foreign.yap \
$(srcdir)/pl/modules.yap $(srcdir)/pl/preds.yap \
$(srcdir)/pl/profile.yap \
$(srcdir)/pl/protect.yap \
$(srcdir)/pl/save.yap \
$(srcdir)/pl/setof.yap \
$(srcdir)/pl/signals.yap \
$(srcdir)/pl/sockets.yap $(srcdir)/pl/sort.yap \
$(srcdir)/pl/statistics.yap \
$(srcdir)/pl/strict_iso.yap \
$(srcdir)/pl/tabling.yap $(srcdir)/pl/threads.yap \
$(srcdir)/pl/udi.yap \
$(srcdir)/pl/utils.yap \
$(srcdir)/pl/yapor.yap $(srcdir)/pl/yio.yap
YAPDOCS=$(srcdir)/docs/yap.tex $(srcdir)/docs/chr.tex \
$(srcdir)/docs/clpr.tex $(srcdir)/docs/swi.tex
ENGINE_OBJECTS = \
agc.o absmi.o adtdefs.o alloc.o amasm.o analyst.o arrays.o \
arith0.o arith1.o arith2.o attvar.o \
bignum.o bb.o \
cdmgr.o cmppreds.o compiler.o computils.o \
corout.o cut_c.o dbase.o dlmalloc.o errors.o eval.o \
exec.o globals.o gmp_support.o gprof.o grow.o \
heapgc.o index.o init.o inlines.o \
iopreds.o depth_bound.o mavar.o \
myddas_mysql.o myddas_odbc.o myddas_shared.o myddas_initialization.o \
myddas_util.o myddas_statistics.o myddas_top_level.o \
myddas_wkb2prolog.o modules.o other.o \
parser.o readutil.o save.o scanner.o sort.o stdpreds.o \
sysbits.o threads.o tracer.o \
udi.o rtree.o rtree_udi.o\
unify.o userpreds.o utilpreds.o \
write.o \
blobs.o swi.o ypsocks.o ypstdio.o @MPI_OBJS@
C_INTERFACE_OBJECTS = \
load_foreign.o load_dl.o load_dld.o load_dyld.o \
load_none.o load_aout.o load_aix.o load_dll.o load_shl.o \
c_interface.o clause_list.o
OR_OBJECTS = \
opt.memory.o opt.init.o opt.preds.o \
or.engine.o or.cowengine.o or.sbaengine.o or.threadengine.o \
or.scheduler.o or.cut.o \
tab.tries.o tab.completion.o
BEAM_OBJECTS = \
eamamasm.o eam_showcode.o eamindex.o eam_am.o
STATIC_OBJECTS = \
@STATIC_MODE@sys.o yap_random.o regexp.o @NO_BUILTIN_REGEXP@ regcomp.o regerror.o regfree.o regexec.o
LIB_OBJECTS = $(ENGINE_OBJECTS) $(C_INTERFACE_OBJECTS) $(OR_OBJECTS) $(BEAM_OBJECTS) $(STATIC_OBJECTS)
OBJECTS = yap.o $(LIB_OBJECTS)
all: parms.h startup.yss
Makefile: $(srcdir)/Makefile.in
$(srcdir)/H/Yap.h: config.h
config.h: parms.h
parms.h: Makefile
@echo "#define YAP_ROOTDIR \"$(prefix)\"" > $@%
@echo "#define YAP_BINDIR \"$(BINDIR)\"" >> $@%
@echo "#define YAP_LIBDIR \"$(YAPLIBDIR)\"" >> $@%
@echo "#define YAP_SHAREDIR \"$(SHAREDIR)\"" >> $@%
@echo "#define YAP_PL_SRCDIR \"$(SHAREDIR)/Yap/pl\"" >> $@%
@echo "#define YAP_STARTUP \"$(YAPSTARTUP)\"" >> $@%
@echo $(VERSION) | $(AWK) -F. '{ printf("#define YAP_VERSION %d\n", $$1 * 10000 + $$2 * 100 + $$3); }' >> $@%
@echo "#define MYDDAS_VERSION \"$(MYDDAS_VERSION)\"" >> $@%
@echo "#define YAP_ARCH \"$(ARCH)\"" >> $@%
@echo "#define YAP_LIBS \"$(LIBS)\"" >> $@%
@echo "#define YAP_YAPLIB \"$(YAPLIB)\"" >> $@%
@echo "#define YAP_CC \"$(CC)\"" >> $@%
@echo "#define YAP_CFLAGS \"$(CFLAGS)\"" >> $@%
@echo "#define YAP_LDFLAGS \"$(LDFLAGS)\"" >> $@%
@echo "#define YAP_SHLIB_SUFFIX \".\" \"$(SO)\"" >> $@%
@echo "#define YAP_TIMESTAMP \"`date +%s`\"" >> $@%
@echo "#define YAP_SVERSION \"YAP $(VERSION) ($(ARCH)): `date`\"" >> $@%
@if cmp -s $@% $@; then rm $@%; else mv $@% $@; fi
#special rule for this one: we cannot use -fomit-frame-pointer because this will
# interface with the outside world.
c_interface.o: $(srcdir)/C/c_interface.c $(srcdir)/include/c_interface.h config.h
$(CC) $(C_INTERF_FLAGS) -c $(srcdir)/C/c_interface.c -o c_interface.o
clause_list.o: $(srcdir)/C/clause_list.c $(srcdir)/include/clause_list.h config.h
$(CC) $(C_INTERF_FLAGS) -c $(srcdir)/C/clause_list.c -o clause_list.o
init.o: $(srcdir)/C/init.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/init.c -o $@
load_foreign.o: $(srcdir)/C/load_foreign.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/load_foreign.c -o $@
save.o: $(srcdir)/C/save.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/save.c -o $@
sysbits.o: $(srcdir)/C/sysbits.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/sysbits.c -o $@
udi.o: $(srcdir)/C/udi.c config.h
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/C/udi.c -o $@
rtree.o: $(srcdir)/packages/udi/rtree.c config.h
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/packages/udi/rtree.c -o $@
rtree_udi.o: $(srcdir)/packages/udi/rtree_udi.c config.h
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/packages/udi/rtree_udi.c -o $@
yap.o: $(srcdir)/console/yap.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/console/yap.c -o $@
mpi.o: $(srcdir)/library/mpi/mpi.c config.h
$(MPI_CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpi.c -o $@
mpe.o: $(srcdir)/library/mpi/mpe.c config.h
$(MPI_CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpe.c -o $@
myddas_mysql.o: $(srcdir)/MYDDAS/myddas_mysql.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_mysql.c -o $@
myddas_odbc.o: $(srcdir)/MYDDAS/myddas_odbc.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_odbc.c -o $@
myddas_shared.o: $(srcdir)/MYDDAS/myddas_shared.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_shared.c -o $@
myddas_util.o: $(srcdir)/MYDDAS/myddas_util.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_util.c -o $@
myddas_initialization.o: $(srcdir)/MYDDAS/myddas_initialization.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_initialization.c -o $@
myddas_top_level.o: $(srcdir)/MYDDAS/myddas_top_level.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_top_level.c -o $@
myddas_wkb2prolog.o: $(srcdir)/MYDDAS/myddas_wkb2prolog.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_wkb2prolog.c -o $@
myddas_statistics.o: $(srcdir)/MYDDAS/myddas_statistics.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_statistics.c -o $@
opt.memory.o: $(srcdir)/OPTYap/opt.memory.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.memory.c -o $@
opt.init.o: $(srcdir)/OPTYap/opt.init.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.init.c -o $@
opt.preds.o: $(srcdir)/OPTYap/opt.preds.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.preds.c -o $@
or.cut.o: $(srcdir)/OPTYap/or.cut.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.cut.c -o $@
or.engine.o: $(srcdir)/OPTYap/or.engine.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.engine.c -o $@
or.cowengine.o: $(srcdir)/OPTYap/or.cowengine.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.cowengine.c -o $@
or.sbaengine.o: $(srcdir)/OPTYap/or.sbaengine.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.sbaengine.c -o $@
or.threadengine.o: $(srcdir)/OPTYap/or.threadengine.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.threadengine.c -o $@
or.scheduler.o: $(srcdir)/OPTYap/or.scheduler.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.scheduler.c -o $@
tab.tries.o: $(srcdir)/OPTYap/tab.tries.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/tab.tries.c -o $@
tab.completion.o: $(srcdir)/OPTYap/tab.completion.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/tab.completion.c -o $@
eam_showcode.o: $(srcdir)/BEAM/eam_showcode.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/BEAM/eam_showcode.c -o $@
eam_am.o: $(srcdir)/BEAM/eam_am.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/BEAM/eam_am.c -o $@
eamamasm.o: $(srcdir)/BEAM/eamamasm.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/BEAM/eamamasm.c -o $@
eamindex.o: $(srcdir)/BEAM/eamindex.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/BEAM/eamindex.c -o $@
sys.o: $(srcdir)/library/system/sys.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/system/sys.c -o $@
swi.o: $(srcdir)/library/dialect/swi/fli/swi.c $(srcdir)/library/dialect/swi/fli/swi.h $(srcdir)/include/SWI-Prolog.h $(srcdir)/include/SWI-Stream.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/dialect/swi/fli $(srcdir)/library/dialect/swi/fli/swi.c -o $@
blobs.o: $(srcdir)/library/dialect/swi/fli/blobs.c $(srcdir)/library/dialect/swi/fli/swi.h $(srcdir)/include/SWI-Prolog.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/dialect/swi/fli $(srcdir)/library/dialect/swi/fli/blobs.c -o $@
yap_random.o: $(srcdir)/library/random/yap_random.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/random/yap_random.c -o $@
regexp.o: $(srcdir)/library/regex/regexp.c @NO_BUILTIN_REGEXP@ $(srcdir)/library/regex/regex2.h $(srcdir)/library/regex/engine.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regexp.c -o regexp.o
regcomp.o: $(srcdir)/library/regex/regcomp.c $(srcdir)/library/regex/regex2.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regcomp.c -o regcomp.o
regerror.o: $(srcdir)/library/regex/regerror.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regerror.c -o regerror.o
regfree.o: $(srcdir)/library/regex/regfree.c $(srcdir)/library/regex/regex2.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regfree.c -o regfree.o
regexec.o: $(srcdir)/library/regex/regexec.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regexec.c -o regexec.o
# default rule
%.o : $(srcdir)/C/%.c config.h
$(CC) -c $(CFLAGS) $< -o $@
## CPP'ed files (for macro debugging)
%.i : $(srcdir)/C/%.c
$(CC) -E $< $(CFLAGS) > $@
absmi.i: $(srcdir)/C/absmi.c
$(CC) -E $(CFLAGS) $(ABSMI_FLAGS) $(srcdir)/C/absmi.c > $@
c_interface.i: $(srcdir)/C/c_interface.c $(srcdir)/include/c_interface.h
$(CC) -E $(C_INTERF_FLAGS) $(srcdir)/C/c_interface.c > $@
#
mycb: $(srcdir)/mycb.c
$(CC) $(CFLAGS) $(srcdir)/mycb.c -o mycb
all: startup.yss
@INSTALL_DLLS@ (cd packages/PLStream; $(MAKE))
@INSTALL_DLLS@ (cd library/lammpi; $(MAKE))
@INSTALL_MATLAB@ (cd library/matlab; $(MAKE))
@INSTALL_DLLS@ (cd library/matrix; $(MAKE))
@INSTALL_DLLS@ (cd library/random; $(MAKE))
@INSTALL_DLLS@ (cd library/regex; $(MAKE))
@INSTALL_DLLS@ (cd library/rltree; $(MAKE))
@INSTALL_DLLS@ (cd library/system; $(MAKE))
@INSTALL_DLLS@ (cd library/tries; $(MAKE))
@INSTALL_DLLS@ (cd packages/clib; $(MAKE))
@INSTALL_DLLS@ (cd packages/http; $(MAKE))
@INSTALL_DLLS@ (cd packages/plunit; $(MAKE))
@INSTALL_DLLS@ (cd packages/RDF; $(MAKE))
@INSTALL_DLLS@ (cd packages/semweb; $(MAKE))
@INSTALL_DLLS@ (cd packages/sgml; $(MAKE))
@USE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE))
@INSTALL_DLLS@ (cd packages/tai; $(MAKE))
@INSTALL_DLLS@ (cd packages/zlib; $(MAKE))
@ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE))
@ENABLE_CPLINT@ (cd packages/cplint/slipcase; $(MAKE))
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE))
@USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE))
@USE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE))
@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE))
startup.yss: yap@EXEC_SUFFIX@ $(PL_SOURCES)
-rm -f startup.yss
echo "bootstrap('$(srcdir)/pl/init.yap'). module(user). save_program('startup.yss')." | @PRE_INSTALL_ENV@ ./yap -b $(srcdir)/pl/boot.yap
yap@EXEC_SUFFIX@: $(HEADERS) yap.o @YAPLIB@
$(MPI_CC) $(EXECUTABLE_CFLAGS) $(LDFLAGS) -o yap yap.o @YAPLIB@ $(LIBS) @MPI_LIBS@
libYap.a: $(LIB_OBJECTS)
-rm -f libYap.a
$(AR) rc libYap.a $(LIB_OBJECTS)
$(RANLIB) libYap.a
@DYNYAPLIB@: $(LIB_OBJECTS)
@YAPLIB_LD@ -o @YAPLIB@ $(LIB_OBJECTS) $(LIBS) $(LDFLAGS) $(SONAMEFLAG)
install: install_bin install_data
install_bin: @INSTALL_COMMAND@
install_unix: startup.yss libYap.a
mkdir -p $(DESTDIR)$(BINDIR)
$(INSTALL_PROGRAM) -m 755 yap@EXEC_SUFFIX@ $(DESTDIR)$(BINDIR)/yap
mkdir -p $(DESTDIR)$(YAPLIBDIR)
$(INSTALL_DATA) startup.yss $(DESTDIR)$(YAPLIBDIR)/startup.yss
@INSTALL_DLLS@ $(INSTALL_DATA) -m 755 @YAPLIB@ $(DESTDIR)$(LIBDIR)
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/pl
mkdir -p $(DESTDIR)$(DOCSDIR)
$(INSTALL) $(srcdir)/Artistic $(DESTDIR)$(DOCSDIR)
$(INSTALL) $(srcdir)/README $(DESTDIR)$(DOCSDIR)
$(INSTALL) $(srcdir)/COPYING $(DESTDIR)$(DOCSDIR)
for f in $(PL_SOURCES); do $(INSTALL) $$f $(DESTDIR)$(SHAREDIR)/Yap/pl; done
@INSTALL_DLLS@ (cd packages/PLStream; $(MAKE) install)
@INSTALL_DLLS@ (cd library/lammpi; $(MAKE) install)
@INSTALL_DLLS@ (cd library/matrix; $(MAKE) install)
@INSTALL_DLLS@ (cd library/random; $(MAKE) install)
@INSTALL_DLLS@ (cd library/regex; $(MAKE) install)
@INSTALL_DLLS@ (cd library/rltree; $(MAKE) install)
@INSTALL_DLLS@ (cd library/system; $(MAKE) install)
@INSTALL_DLLS@ (cd library/tries; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/clib; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/http; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/plunit; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/sgml; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/RDF; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/semweb; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/tai; $(MAKE) install)
@INSTALL_DLLS@ (cd packages/zlib; $(MAKE) @ZLIB_INSTALL@)
@USE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE) install)
@INSTALL_MATLAB@ (cd library/matlab; $(MAKE) install)
@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE) install)
#@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/pyswip; $(MAKE) install)
mkdir -p $(DESTDIR)$(INCLUDEDIR)
$(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)
for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done
$(INSTALL) config.h $(DESTDIR)$(INCLUDEDIR)/config.h
$(INSTALL) parms.h $(DESTDIR)$(INCLUDEDIR)/parms.h
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install)
# @ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) install)
# @ENABLE_CPLINT@ (cd packages/cplint/slipcase; $(MAKE) install)
@USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) install)
@USE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE) install)
install_win32: startup.yss
mkdir -p $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(LIBDIR)
mkdir -p $(DESTDIR)$(YAPLIBDIR)
mkdir -p $(DESTDIR)$(INCLUDEDIR)
$(INSTALL_PROGRAM) -m 755 yap.exe $(DESTDIR)$(BINDIR)/yap.exe
$(INSTALL_PROGRAM) -m 755 yap.dll $(DESTDIR)$(BINDIR)/yap.dll
$(INSTALL_PROGRAM) -m 755 @YAPLIB@ $(DESTDIR)$(YAPLIBDIR)/@YAPLIB@
$(INSTALL_PROGRAM) -m 755 startup.yss $(DESTDIR)$(YAPLIBDIR)/startup.yss
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/pl
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/swi
mkdir -p $(DESTDIR)$(DOCSDIR)
$(INSTALL) $(srcdir)/Artistic $(DESTDIR)$(DOCSDIR)
$(INSTALL) $(srcdir)/README $(DESTDIR)$(DOCSDIR)/README.TXT
$(INSTALL) $(srcdir)/COPYING $(DESTDIR)$(DOCSDIR)/COPYING.TXT
for f in $(PL_SOURCES); do $(INSTALL) $$f $(DESTDIR)$(SHAREDIR)/Yap/pl; done
$(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)
for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done
$(INSTALL) config.h $(DESTDIR)$(INCLUDEDIR)/config.h
$(INSTALL) parms.h $(DESTDIR)$(INCLUDEDIR)/parms.h
(cd library/random; $(MAKE) install)
(cd library/matrix; $(MAKE) install)
(cd library/regex; $(MAKE) install)
(cd library/rltree; $(MAKE) install)
(cd library/system; $(MAKE) install)
@ENABLE_WINCONSOLE@ (cd LGPL/swi_console; $(MAKE) install)
@INSTALL_MATLAB@ (cd library/matlab; $(MAKE) install)
(cd library/tries; $(MAKE) install)
(cd packages/PLStream; $(MAKE) install)
(cd packages/tai; $(MAKE) install)
(cd packages/clib; $(MAKE) install)
(cd packages/plunit; $(MAKE) install)
(cd packages/http; $(MAKE) install)
(cd packages/RDF; $(MAKE) install)
(cd packages/sgml; $(MAKE) install)
(cd packages/semweb; $(MAKE) install)
(cd packages/zlib; $(MAKE) @ZLIB_INSTALL@)
@ENABLE_JPL@ (cd packages/jpl ; $(MAKE) install)
@USE_MINISAT@ (cd packages/swi-minisat2/C; $(MAKE) install)
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) install)
@USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) install)
@USE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE) install)
install_library: @YAPLIB@
mkdir -p $(DESTDIR)$(INCLUDEDIR)
for h in $(HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done
install_data: install_copied_files install_bin
@ENABLE_CHR@ (cd packages/chr ; $(MAKE) install)
@ENABLE_CHR@ (cd packages/clpqr ; $(MAKE) install)
install_copied_files:
(cd library ; $(MAKE) install)
(cd packages/swi-minisat2; $(MAKE) install)
(cd LGPL ; $(MAKE) install)
(cd GPL ; $(MAKE) install)
$(INSTALL_DATA) $(srcdir)/LGPL/pillow/icon_address.pl $(DESTDIR)$(SHAREDIR)/Yap/
$(INSTALL_DATA) $(srcdir)/LGPL/pillow/pillow.pl $(DESTDIR)$(SHAREDIR)/Yap/
@INSTALLCLP@(cd LGPL/clp ; $(MAKE) install)
(cd packages/CLPBN ; $(MAKE) install)
(cd packages/ProbLog ; $(MAKE) install)
##########
TAGS: $(C_SOURCES) $(PL_SOURCES) $(HEADERS)
etags $(C_SOURCES) $(PL_SOURCES) $(HEADERS)
depend: $(HEADERS) $(C_SOURCES)
-@if test "$(GCC)" = yes; then\
$(CC) -MM $(CFLAGS) -I$(srcdir)/include $(C_SOURCES) >> Makefile;\
else\
makedepend -f - -- $(CFLAGS) -I$(srcdir)/include -- $(C_SOURCES) |\
sed 's|.*/\([^:]*\):|\1:|' >> Makefile ;\
fi
clean: clean_docs
rm -f *.o *~ *.BAK *.a
@INSTALL_DLLS@ (cd packages/PLStream; $(MAKE) clean)
@INSTALL_DLLS@ (cd library/lammpi; $(MAKE) clean)
@INSTALL_MATLAB@ (cd library/matlab; $(MAKE) clean)
@INSTALL_DLLS@ (cd library/matrix; $(MAKE) clean)
@INSTALL_DLLS@ (cd library/random; $(MAKE) clean)
@INSTALL_DLLS@ (cd library/regex; $(MAKE) clean)
@INSTALL_DLLS@ (cd library/rltree; $(MAKE) clean)
@INSTALL_DLLS@ (cd library/system; $(MAKE) clean)
@INSTALL_DLLS@ (cd library/tries; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/clib; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/http; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/plunit; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/RDF; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/semweb; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/sgml; $(MAKE) clean)
@USE_MINISAT@ (cd packages/swi-minisat2; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/tai; $(MAKE) clean)
@INSTALL_DLLS@ (cd packages/zlib; $(MAKE) clean)
@ENABLE_CPLINT@ (cd packages/cplint/approx/simplecuddLPADs; $(MAKE) clean)
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) clean)
@USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE) clean)
@USE_CUDD@ (cd packages/ProbLog/simplecudd_lfi; $(MAKE) clean)
@ENABLE_JPL@ @INSTALL_DLLS@ (cd packages/jpl; $(MAKE) clean)
realclean: clean realclean_docs
rm -f yap@EXEC_SUFFIX@ startup.yss config.log config.cache config.h
dist:
.c.s:
$(CC) $(CFLAGS) -S $<
# use my own .def file.
libWYap.a: yap.dll
dlltool --def $(srcdir)/misc/yap.def \
--dllname yap.dll \
--output-lib libWYap.a
yap.dll: libYap.a
$(CC) $(CFLAGS) -shared -o yap.dll \
-Wl,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--whole-archive libYap.a \
-Wl,--no-whole-archive $(LIBS) $(LDFLAGS)
install_info:
$(MAKE) info; \
$(INSTALL) yap.info* $(DESTDIR)$(INFODIR); \
if test -e $(DESTDIR)$(INFODIR)/emacs.bz2; then \
bzip2 --quiet --force $(DESTDIR)$(INFODIR)/yap.info*; \
else \
if test -e $(DESTDIR)$(INFODIR)/emacs.gz; then \
gzip --quiet --force $(DESTDIR)$(INFODIR)/yap.info*; \
fi \
fi; \
$(INSTALL_INFO) --quiet --section "Programming Languages" yap.info $(DESTDIR)$(INFODIR)/dir; \
cd $(srcdir)/LGPL/pillow/doc ; \
$(INSTALL) pillow_doc.info $(DESTDIR)$(INFODIR); \
if test -e $(DESTDIR)$(INFODIR)/emacs.bz2; then \
bzip2 --quiet --force $(DESTDIR)$(INFODIR)/pillow_doc.info; \
else \
if test -e $(DESTDIR)$(INFODIR)/emacs.gz; then \
gzip --quiet --force $(DESTDIR)$(INFODIR)/pillow_doc.info; \
fi \
fi; \
$(INSTALL_INFO) --quiet --section "Programming Languages" --entry="`cat pillow_doc.infoindex`" --info-dir=$(DESTDIR)$(INFODIR) pillow_doc.info
install_docs:
$(MAKE) pdf
$(MAKE) html
$(INSTALL_DATA) yap.html* $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) yap.pdf $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) $(srcdir)/Artistic $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) $(srcdir)/COPYING $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) $(srcdir)/changes4.3.html $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) $(srcdir)/changes-5.0.html $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) $(srcdir)/changes-5.1.html $(DESTDIR)$(DOCSDIR)
$(INSTALL_DATA) $(srcdir)/changes-6.0.html $(DESTDIR)$(DOCSDIR)
info: yap.info
yap.info: $(YAPDOCS)
$(MAKEINFO) $(srcdir)/docs/yap.tex
html: yap.html
yap.html: $(srcdir)/docs/yap.tex
$(TEXI2HTML) $(srcdir)/docs/yap.tex
dvi: yap.dvi
yap.dvi: $(YAPDOCS)
$(TEXI2DVI) $(srcdir)/docs/yap.tex
ps: yap.ps
yap.ps: $(YAPDOCS)
dvips -o yap.ps $(srcdir)/docs/yap
pdf: yap.pdf
yap.pdf: $(YAPDOCS)
$(TEXI2PDF) $(srcdir)/docs/yap.tex
clean_docs:
rm -f *.aux *.ca *.cas *.cn *.cns *.cp *.cps *.cy *.cys *.dvi *.fn *.fns *.ky *.log *.sa *.sas *.sn *.sns *.sy *.sys *~ *.tp *.vr *.toc *.pg
realclean_docs: clean_docs
rm -f yap.ps yap.html yap_toc.html yap.pdf yap.info*
installcheck:
@ENABLE_CPLINT@ (cd packages/cplint; $(MAKE) installcheck)
# DO NOT DELETE THIS LINE -- make depend depends on it.
yap-6.2.2/misc/ 000755 000765 000024 00000000000 11702065320 013177 5 ustar 00vsc staff 000000 000000 yap-6.2.2/MYDDAS/ 000755 000765 000024 00000000000 11702065320 013225 5 ustar 00vsc staff 000000 000000 yap-6.2.2/OPTYap/ 000755 000765 000024 00000000000 11702065320 013360 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/ 000755 000765 000024 00000000000 11702065316 014027 5 ustar 00vsc staff 000000 000000 yap-6.2.2/pl/ 000755 000765 000024 00000000000 11702065316 012664 5 ustar 00vsc staff 000000 000000 yap-6.2.2/README 000644 000765 000024 00000020436 11574674627 013160 0 ustar 00vsc staff 000000 000000
README for YAP6
This directory contains a release of the YAP 6.2.* Prolog system,
originally developed at the Universidade do Porto by Luis Damas and
Vitor Santos Costa, with contributions from the Edinburgh Prolog
library, the C-Prolog manual authors, Ricardo Lopes, Ricardo Rocha,
M. Hermenegildo, D. Cabeza, Eric Alphonse, Paulo Moura, Nuno Fonseca,
Jan Wielemaker, Paul Singleton, Fred Dushin, Jan Wielemaker, Markus
Triska, and many others. You should read the rest of this file for
information on what YAP is and for instructions on how to build it.
YAP 6 has been built with several versions on GCC on a variety of
Linux, MacOSX. It has been built on Windows XP and VISTA using the
mingw toolkit and cygwin from Cygnus Solutions.
The main core of the YAP distribution is distributed under a dual
license: the Perl Artistic license 2 and the FSF's LGPL. The YAP
distribution also contains files distributed under the LGPL
exclusively, and under the GPL.
The YAP distribution includes several packages ported to YAP, such as
Pillow, JPL, CLP(R) and CHR. We would like to take the opportunity to
thank the developers of these packages for their generosity in
allowing YAP to distribute these packages. Any bugs in these packages
are probably our fault.
If you have a question about this software, desire to add code, found
a bug, want to request a feature, or wonder how to get further
assistance, please send e-mail to yap-users@lists.sourceforge.net. To
subscribe to the mailing list or access the list archives, please see
http://lists.sourceforge.net/lists/listinfo/yap-users
Online documentation is available for YAP at:
http://www.dcc.fc.up.pt/~vsc/YAP/
Recent versions of YAP, including both source and selected binaries,
can be found from this same URL.
1. What is YAP
The YAP Prolog System is a high-performance Prolog compiler developed
at LIACC, Universidade do Porto. YAP provides several important
features:
o speed: YAP is widely considered one of the fastest available Prolog
systems.
o functionality: it supports stream I/O, sockets, modules,
exceptions, Prolog debugger, C-interface, dynamic code, internal
database, DCGs, saved states, co-routining, arrays.
o we explicitly allow both commercial and non-commercial use of YAP.
YAP is based on the David H. D. Warren's WAM (Warren Abstract
Machine), with several optimizations for better performance. YAP
follows the Edinburgh tradition, and was originally designed to be
largely compatible with DEC-10 Prolog, Quintus Prolog, and especially
with C-Prolog.
YAP implements most of the ISO-Prolog standard. We are striving at
full compatibility, and the manual describes what is still
missing. The manual also includes a (largely incomplete) comparison
with SICStus Prolog.
2. Obtaining YAP's development sources.
YAP is now being maintained using the git source management system. A
public repository is available at
http://gitorious.org/projects/yap-git
Please use
git clone git://gitorious.org/yap-git/mainline.git
to obtain a copy of the current YAP tree.
3. How to compile YAP
First, make sure you have gmp and readline development packages
installed. If you plan to use ProbLog, also check for cudd.
Now, to compile YAP from the source directory just do:
(1) ./configure
(2) check the Makefile for any extensions or changes you want to make.
(3) make
(4) If the compilation succeeds, try ./yap
(5) Happy? "make install"
(6) "make install_info" will create the info files in the standard
info directory.
(7) "make html" will create documentation in html format in the
current directory.
In most systems you will need to be superuser in order to do "make
install" and "make info" on the standard system directories.
3.1 Where to install YAP
YAP uses autoconf. Recent versions of YAP try to follow GNU
conventions on where to place software. By default, this location is
/usr/local on Unix, Linux, and OS/X machines.
You can use the --prefix configure option to set the ROOTDIR macro and
the --exec-prefix option to set the EROOTDIR macro (for
architecture-dependent files). EROOTDIR defaults to ROOTDIR.
o The main executable is placed at BINDIR, which defaults at
$(EROOTDIR)/bin. This executable is actually a script that calls the
Prolog engine, stored at YAPLIBDIR.
o SHAREDIR is the directory where the Prolog libraries are stored.
Its default value is $(ROOTDIR)/share. The Prolog libraries are
machine-independent text files that only need to be installed once,
even on systems where multiple copies of YAP of the same version are
installed. (e.g. with different configurations or for different
architectures sharing a file server.)
o LIBDIR is the directory where binary libraries are stored. It is
set to $(EROOTDIR)/lib by default. YAPLIBDIR is a subdirectory (by
default $(EROOTDIR)/lib/YAP) that contains the Prolog engine and the
binary Prolog libraries.
o INCLUDEDIR is used if you want to use YAP as a library.
o INFODIR is where the info help files will be stored. It defaults
to $(SHAREDIR)/info.
3.2 Which YAP to compile
Compiling YAP with the standard options give you a plain vanilla
Prolog. You can tune YAP to use extra functionality by using the
following options to configure:
Compilation options:
o --enable-depth-limit=yes allows depth limited evaluation, say for
implementing iterative deepening. It is required by the ILP system
Aleph.
o --enable-use-malloc=yes makes YAP use the system's C-library
allocation routines for all memory allocation. It is not compatible
with save and restore.
o --enable-threads=yes enables POSIX thread support.
o --enable-pthread-locking=yes always use POSIX p-thread routines for locking.
o --enable-low-level-tracer=yes allows support for tracing all calls,
retries, and backtracks in the system. This can help in debugging your
application, but results in performance loss.
o --enable-wam-profile=yes allows profiling of abstract machine
instructions. This is useful when developing YAP and will not be very
useful for normal users.
o --enable-tabling=yes allows tabling support.
o --enable-or-parallelism={env-copy,sba,a-cow} allows or-parallelism
supported by one of these three forms. This is experimental.
o --enable-dynamic-loading compile YAP as as a shared library.
o --enable-win64 compile YAP as a WIN64 application.
o --enable-cygwin compile YAP as a CYGWIN environment application, and not as stand-alone application.
o --with-cudd=CUDD_PATH enable support of the CUDD library, used by
packages such as ProbLog. Usually CUDD has to compiled from source
(http://vlsi.colorado.edu/~fabio/CUDD/), but Fedora and MacPorts have
cudd packages. In the case of Fedora, install cudd-dev and use
--with-cud=/usr, in the case of MacPorts install cudd-dev and use
--with-cud=/opt/local.
o --with-gmp=GMP_PATH provide a path for GMP, in case GMP is not
installed in the system. In a Linux machine, make sure you have
installed the gmp-dev package. Binary versions of GMP are available
for WIN32.
Functionality options:
o --with-java=JAVA_PATH activates the Java Interface Library JPL. In
Linux and WIN32 you have to provide a path to the Java library, in
OSX it is sufficient to say yes.
o --enable-condor compile YAP as a static program that can be run by condor
o --enable-chr install CHR (enabled by default, if CHR is available)
o --enable-clpqr install CLPQR (enabled by default, if CLPQR is available)
o --enable-myddas install the MYDDAS MYSQL and/or ODBC interface
package. YAP tries to compile this by default, if the odbc or MySql
development files can be found.
o --with-matlab install the MATLAB interface (not default). You need
to provide the full path of the MATLAB install.
o --with-mpi install the MPICH based MPI interface. This is default,
if the development libraries can be found.
o --with-mpe install the MPE interface.
o --with-lam install the MPI LAM-based interface.
3.3 Porting YAP
The system has been mainly tested with GCC, but we have been able to
compile older versions of YAP under lcc in Linux, Sun's cc compiler,
IBM's xlc, SGI's cc, HP's cc, and Microsoft's Visual C++ 6.0. Recent
versions of YAP have also been compiled using Intel's lcc.
yap-6.2.2/README.EAM.html 000644 000765 000024 00000023414 11457004724 014504 0 ustar 00vsc staff 000000 000000 BEAM How-to-get-started
This document gives you an introduction on how to use the EAM withing YAP.
We start by explaining how to prepare YAP to use the EAM.
Then we present some code examples that you can use to try
out the EAM.
WARNING:
THE BEAM WITHING YAP IS STILL IN EARLY DEVELOPMENT,
SO DON'T EXPECT IT TO RUN SMOOTHLY...
WE ARE WORKING TO IMPROVE THE INTEGRATION OF BEAM WITHIN
YAP, BUT THIS THINGS TAKE TIME. SO PLEASE BE PATIENT...
---------------------------------------------------------------------------
1. Compiling Yap to support the EAM.
---------------------------------------------------------------------------
If you want to use the BEAM prototype you must compile YAP using the
flag --enable-eam
tar -xvzf yapfile.tar.gz <- will extract yap to $YAPDIR
mkdir tmp
cd tmp
../YAPDIR/configure --enable-eam <- prepare yap to compilation
make <- compile yap
su <- enter as root
make install <- install yap
You are now ready to try YAP-BEAM. Just run "yap" on the
command line.
---------------------------------------------------------------------------
2. Quick start + Examples...
---------------------------------------------------------------------------
Quick example on how to run a Prolog program using the EAM.
-FIRST ALTERNATIVE:
Consult your program using eamconsult(+File)
?- eamconsult(qsort).
then you should write your queries using ?- eam(query).
You can write the query normally as in normal Prolog mode, but
in this case you will only receive the first solution (or yes or no).
The eamconsult will pre-compile your prolog code to control
cases where changing the order in execution can be problematic...
For example consider the query: ?- g(X), f(X).
Supose that g/1 is non-deterministic and that f/1 has a single clause.
The EAM engine will try to execute f/1 first, since it is deterministic.
Now supose that f/1 depends on a bound argument, for example:
f(X):- X > 1, ...
The eamconsult will be transform this code into
f(X):- skip_while_var([X]), X>1, ...
The skip_while_var/1 will not allow the comparision X>1 to be executed
while X is unbound.
-SECOND ALTERNATIVE:
First you must enable the EAM using the comand
?- eam.
yes
then you should load your program, and make your queries
using ?- eam(query).
You can write the query normally as in normal Prolog mode, but
in this case you will only receive the first solution (or yes or no).
Small example:
Supose that you have the file Example.pl with the Prolog code:
f(1).
f(2).
f(3).
Here is an execution example:
[user]$ ./yap
% Restoring file /.../startup
YAP version Yap-5.0.0
?- eam.
yes
?- [t].
% consulting /.../t.pl...
% consulted /.../t.pl in module user, 1 msec 1328 bytes
yes
?- eam(f(X)).
[ EAM execution started to solve f/1 ]
X = 1 ? ;
X = 2 ? ;
X = 3 ? ;
no
?- f(X).
[ EAM execution started to solve f/1 ]
X = 1 ? ;
no
?-
---------------------------------------------------------------------------
A first example:
You can try out the next example, the well-known benchmark scanner.pl
that behaves badly in standard Prolog systems.
Just run the demos... (demo1, demo2, demo3 or demo4).
Remember to enable the EAM before loading the program.
After running the examples, try restarting YAP and
loading the program without the EAM enabled. Try to run
the demo4... :)
demo1:- demo(tiny).
demo2:- demo(small).
demo3:- demo(data).
demo4:- demo(snake).
demo(Data):-
scannerdata(Data,R,C,D1,D2),
write('Rows '), write(R),nl,
write('Columns '), write(C),nl,
write('Left diagonals '), write(D1),nl,
write('Right diagonals '), write(D2),nl,nl,
scanner(R,C,D1,D2,Image), !,
displi(Image).
sequence(Spec):-
samples(Spec,Samples),
cat(Samples,Images), !,
displ(Images).
samples([],Samples):- !, Samples=[].
samples([S|Spec],Samples):- !,
scannerdata(S,R,C,D1,D2),
Samples=[sample(R,C,D1,D2)|Smpls],
samples(Spec,Smpls).
cat([],Images):- !, Images=[].
cat([Sample|Samples], Images):- !,
image(Sample,Image),
Images=[Image|Imgs],
cat(Samples,Imgs).
image(sample(R,C,D1,D2), Image):-
scanner(proc,R,C,D1,D2,I), !,
Image=I.
displ([]):- nl, nl.
displ([I|Imgs]):- nl, displi(I), nl, displ(Imgs).
displi([]):- nl .
displi([R|Rws]):- write(' '),displr(R), displi(Rws).
displr([]):- nl.
displr([on|R]):- write('X '), displr(R).
displr([off|R]):- write('_ '), displr(R).
scannerdata(tiny, [1,1],[2,0],[1,1,0],[0,1,1]).
scannerdata(small, [1,2,1],[2,1,1],[1,1,1,0,1],[0,0,3,1,0]).
scannerdata(double,
[2,2,3,2,2,1],
[1,3,3,1,3,1],
[0,1,1,2,1,2,3,1,1,0,0],
[0,2,0,1,2,2,2,1,2,0,0]).
scannerdata(snake,
[4,2,6,2,4,4,3,2],
[3,5,5,3,2,3,3,3],
[1,2,2,1,1,2,5,2,2,3,3,2,1,0,0],
[0,1,0,3,2,2,4,3,3,3,1,3,2,0,0]).
scanner(RwData,ClData,D1Data, D2Data, Rws):-
llength(RwData,R),
llength(ClData,C),
board(R,C,All,Rws,Cls,D1,D2),
check(RwData,Rws),
check(ClData,Cls),
check(D1Data,D1),
check(D2Data,D2).
pixle(on).
pixle(off).
check([],[]).
check([K|RwsD],[R|Rws]):-
llength(R,L),
line(K,L,R),
check(RwsD,Rws).
line(0,0,[]).
line(K,L,[on|R]):-
K > 0,
K1 is K - 1,
L1 is L - 1,
line(K1,L1,R).
line(K,L,[off|R]):-
L > K,
L1 is L - 1,
line(K,L1,R).
board(0,C,[],[],Cls,D,D):-
C > 0,
C1 is C - 1,
seed(C,Cls),
seed(C1,D).
board(R,C,All,[Row|Rws],Cols,Rdiag,Ldiag):-
R > 0,
R1 is R - 1,
row(C, Row),
all2(Row,Al,All),
column(Row,Cls,Cols),
diagonal(Row,Rdg,Rdiag),
rev(Row,[],Rev),
diagonal(Rev,Ldg,Ldiag),
board(R1,C,Al,Rws,Cls,Rdg,Ldg).
seed(0,[]).
seed(C,[[]|S1]):- C > 0, C1 is C -1 , seed(C1,S1).
all2([],Al,Al).
all2([H|Row],Al,[H|All]):- all2(Row,Al,All).
row(0,[]).
row(C,[_|R]):- C > 0, C1 is C -1, row(C1,R).
column([],X,X).
column([H|R],[Cl|Cls],[[H|Cl]|Columns]):- column(R,Cls,Columns).
diagonal([H|Row],Dg, [[H]|Diag]):- column(Row,Dg,Diag).
rev([],Y,Y).
rev([H|T],Y,Z):- rev(T,[H|Y],Z).
llength([],0).
llength([A|R],N):- llength(R,M), N is M+1.
---------------------------------------------------------------------------
Another example:
The famours queens...
Try to evaluate in normal Prolog que query:
?- queens([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],X).
Now quit YAP and enable eam before loading the queens program
Here is the code for you to try it:
demo1:- queens([1,2,3,4,5,6,7,8,9],L), write(L), nl, fail.
demo2:- queens([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],L), write(L), nl.
queens(L,C):-
perm(L,P),
pair(L,P,C),
safe([],C).
perm([],[]).
perm(Xs,[Z|Zs]):-
select(Z,Xs,Ys),
perm(Ys,Zs).
select(X,[X|Xs],Xs).
select(X,[Y|Ys],[Y|Zs]):-
select(X,Ys,Zs).
pair([],[],[]).
pair([X|Y],[U|V],[p(X,U)|W]):-
pair(Y,V,W).
safe(X,[]).
safe(X,[Q|R]):-
test(X,Q),
safe([Q|X],R).
test([],X).
test([p(C1,R1)|S],p(C2,R2)):-
test(S,p(C2,R2)),
nd(p(C1,R1),p(C2,R2)).
nd(p(C1,R1),p(C2,R2)):-
wait_while_var([C1,C2,R1,R2]),
C is C1-C2,
R is R1-R2,
C=\=R,
NR is R2-R1,
C=\=NR.
Note that on the nd predicate, we have used wait_while_var
to force the EAM to wait while C1, C2, R1, R2 are not bound,
because the operations in this predicate can't be done with
those variables unbound.
Alternatively, and if you don't want to use wait_while_var,
you can compile the prolog code using eamconsult.
eamconsult will insert this instructions for you automatically.
---------------------------------------------------------------------------
3. Some notes...
---------------------------------------------------------------------------
- A lot of builtins/code are not yet supported...
For example var(X), not , ; (or), ...
You will have a internal compiler error for these cases.
and the clause that uses the builtin/code not supported will always fail.
Example: consider the code:
tst(X):- var(X), X=1.
tst(2).
You will receive a warning that there is unsupported code.
Although you can still use the tst predicate, the first alternative
will always fail...
?- tst(X).
[ EAM execution started to solve tst/1 ]
X = 2 ? ;
no
---------------------------------------------------------------------------
- The EAM prefers deterministic instead of non-deterministic.
and thus can change the order of goals of your code to delay
non-deterministic bindings.
So, you must be careful when using builtins that have side-effects,
or that may expect variables to be bound.
For example, supose that you have the following Prolog code:
f(1).
f(2).
tst(Y):- f(X), Y is X+1.
Normal prolog would be fine, but the EAM can not execute this
code correctly because since f(X) is non-deterministic,
Y is X+1 is executed before X being bound. The result would be:
?- tst(X).
[ EAM execution started to solve tst/1 ]
% INSTANTIATION ERROR- in arithmetic at user:tst/1 (clause 1): expected bound value
The solution for this case is to force the EAM to wait for X to be bound.
This can be done by using eamconsult(File) instead of the normal
consult, or by inserting the control instructions explicitly in the code.
So the code correct code would be:
tst(Y):- f(X), skip_while_var(X), Y is X+1.
That means that the code Y is X+1 should be skipped
while X is var. Note that in this case there is no more
after Y is X+1. If there were, execution would continue
on that code.
Another alternative is to use:
tst(Y):- f(X), wait_while_var(X), Y is X+1.
that means what execution can not proceed while X is not bound.
---------------------------------------------------------------------------
- To support the EAM within the YAP the WAM compilation was
specially the classification of permanent variables.
This code was adapted from the initial BEAM implementation and is not
yet completed.
I've have already discover some code examples where the variables
should are not being classified as permanent, and as result the BEAM
returns false solutions. We are also working on this problem...
---------------------------------------------------------------------------
Expect more info soon...
...
yap-6.2.2/README.nt 000644 000765 000024 00000012064 11457004724 013557 0 ustar 00vsc staff 000000 000000 COMPILING YAP UNDER WIN32 (WIN95, WIN98, NT, 2000)
Yap should compile under both cygwin and Visual C++ 6.0. We next describe
how to do it from scratch.
$YAPSRC is the directory where you can find the sources
$YAPVERSION is the current version for YAP.
GCC-Based compilation:
GCC is distributed in the MINGW32 and CYGWIN packages.
The Mingw32 environment is available from the URL:
@code{http://www.mingw.org}
You will need to install the @code{msys} and @code{mingw}
packages. You should be able to do configure, make and make install.
If you use mingw32 you may want to search the contributed packages for
the @code{gmp} multi-precision arithmetic library. If you do setup Yap
with @code{gmp} note that @code{libgmp.dll} must be in the path,
otherwise Yap will not be able to execute.
CygWin environment is available from the URL:
@code{http://www.cygwin.com}
@noindent
and mirrors. We suggest using recent versions of the cygwin shell. The
compilation steps under the cygwin shell are as follows:
@example
mkdir cyg
$YAPSRC/configure --enable-coroutining \\
--enable-depth-limit \\
--enable-max-performance
make
make install
@end example
By default, Yap will use the @code{--enable-cygwin=no} option to
disable the use of the cygwin dll and to enable the mingw32 subsystem
instead. Yap thus will not need the cygwin dll. It instead accesses
the system's @code{CRTDLL.DLL} @code{C} run time library supplied with
Win32 platforms through the mingw32 interface. Note that some older
WIN95 systems may not have @code{CRTDLL.DLL}, in this case it should
be sufficient to import the file from a newer WIN95 or WIN98 machine.
You should check the default installation path which is set to
@code{/PROGRA~1/Yap} in the standard Makefile. This string will usually
be expanded into @code{c:\Program Files\Yap} by Windows.
The cygwin environment does not provide @t{gmp}. You can fetch a dll for
the @t{gmp} library from @url{http://www.sf.net/projects/mingwrep}.
It is also possible to configure Yap to be a part of the cygwin
environment. In this case you should use:
@example
mkdir cyg
$YAPSRC/configure --enable-coroutining \\
--enable-max-performance \\
--enable-cygwin=yes
make
make install
@end example
Yap will then compile using the cygwin library and will be installed
in cygwin's @code{/usr/local}. You can use Yap from a cygwin console,
or as a standalone application as long as it can find
@code{cygwin1.dll} in its path.
VISUAL C++:
To the best of my knowledge, Yap compiles cleanly under VC++ release
6.0.
First, it is a good idea to build Yap as a DLL:
1. create a project named yap using File.New. The project will be a
DLL project, initially *empty*.
NOTICE: Either the project is named yap or you must replace
YAP_EXPORTS to match your project names in c_interface.h and
c_interface.c.
o Use the FileView tab to add all .c files in the $YAPSRC/C directory
and in the $YAPSRC/OPTYap directory to the "Source Files".
o add all .h files in the $YAPSRC/H directory, $YAPSRC/include directory and in the $YAPSRC/OPTYap subdirectory to the "Header Files".
o include the .h from .m4 files and config.h. You can find these files at $YAPSRC/VC/include.
o You may want to go to Build.Set Active Configuration and set Project Type to Release
o set Project.Settings.C/C++.Preprocessor.Additional Include Directories to include the $YAPSRC/H, $YAPSRC/VC/include, $YAPSRC/OPTYap and $YAPSRC/include.
The syntax is:
$YAPSRC\H, $YAPSRC\VC\include, $YAPSRC\OPTYap, $YAPSRC\include
o Build: the system should generate an yap.dll and an yap.lib.
o Copy the yapdll.dll file to your path. The yapdll.lib should be copied to
where the linker can find it (you can also give the explicit path).
2. create a second project say wyap with File.New. The project will be a
WIN32 console project, initially empty.
o add $YAPSRC/console/yap.c to the Source Files.
o add $YAPSRC/VC/include/config.h and the files in $YAPSRC/include/ to
the Header Files.
o You may want to go to Build.Set Active Configuration and set Project Type to Release
o you will eventually need to bootstrap the system by booting from
boot.yap, so write:
-b $YAPSRC\pl\boot.yap
in Project.Project Settings.Debug.Program Arguments
o You need the sockets and yap libraries. Add
ws2_32.lib yapdll.lib to
to
Project.Project Settings.Link.Object/Library Modules
You may also need to set the Link Path so that VC++ will find yap.lib.
o set Project.Project Settings.C/C++.Preprocessor.Additional Include Directories to include the $YAPSRC/VC/include and $YAPSRC/include.
The syntax is:
$YAPSRC\VC\include, $YAPSRC\include
o Build the system.
o Use Build.Start Debug to boot the system, and then create the saved state with
['$YAPSRC\\pl\\init'].
save_program('startup.yss').
^Z
That's it, you've got YAP and the saved state!
The $YAPSRC\VC directory has the make files to build Yap4.3.17 under VC++ 6.0.
Problems with this release:
o alarm/3 does not work in WIN98. This seems to be a limitation of WIN98.
o signals still do not work properly with console applications :-(.
o ??
Enjoy!
Vitor
yap-6.2.2/TO_DO 000644 000765 000024 00000006720 11457004724 013110 0 ustar 00vsc staff 000000 000000 6.0
o Rogério Salvini's report
o Fix meta-commas
o Document CLPBN
o Fix meta-call conjunction
o exo-emulation.
o EMACS interface.
o talk to Fabrizio
o upgrade save/restore
o R Interface
5.1.4
BEFORE 4.4:
- mixed attributes and delays.
- write infinite terms
- fix restore when code is moved around.
- document new interface functions.
- mask when installing.
- reports from Nicos.
- fix ensure_loaded/1.
STK:
- move architecture #ifdef's out of C files.
- collapse windows and POSIX makefile recipes.
- inline c_interface functions (static #included?)
- look for a system regexp library before using the one in Yap.
- see why tag2.pl is not compiling.
- make docs/Makefile configurable.
- break up yap.tex.
- start devel.tex.
- should sigactions be executed when Yap is waiting at the prompt?
- see if on_signal/3 works through the C interface as well.
- current_signal/3 does not know the SigId.
- see how MPI libraries interact with YAP's signal handling.
- atomic (as opposed or to numerical) tags (and communicators).
- configure.in:236: check for mpicc in the user's prefix, if any
TO CHECK:
- bad register allocation for a(X,Y) :- X is Y+2.3 ?
TABLING
- pass all tabling tests from Kostis and Bart paper
- handle floats, long ints and friends in tables.
- backtracking over mutable and tabling does not work (ai_tests).
PARALLELISM
- copying: Fix stack copying after new stack.
- SBA: fix constraint and unification.
- IAP.
AFTER 4.4(?)
- improve debugger functionality
- change compilation order for arguments
- fix code for arithmetic
- large memory configurations on 32 bit machines (3GB).
- big data-bases
- CLP(FD)
- garbage collector cleans up clauses and logical update DB.
- atom garbage collector.
- lpdoc.
- incremental garbage collector.
- threads.
DONE:
- compilation of bignums.
- expansion in the middle of compilation.
- garbage collect multiple assignment variables properly.
- read inf, nan, improve print_message.
- Too large term in copy_term.
- block.
- include Stasinos patches for gmp configuration and documentation.
- debug new code for delays
- debug new code for attributes.
- bug in CHR, run3, deussen1(X).
- functor
- check how terms are written by debugger
- tabling garbage collector.
- port to HP-UX (4.3.15)
- port to Alpha (4.3.15)
- fix trail overflow in gc
- fix opt.mavar.h trouble
- fix [] lookup
- fix documentation complaint
- fix overflow in tab_fib
- fix rpm build
- build problems with cygwin 1.1.7?
- Trail Overflow in WIN32.
- save/restore for DB
- Ashwin bug on storing floats as head of db term.
- save/restore for arrays.
- save/restore for arithmetic.
- fix aliases, user error, etc.
- set user_input, user_output, and user_error
- include Mandrake makefiles
- system enters loop if predicate exported by module is not defined.
- copying garbage collector: implemented hybrid
- dif example in Manual.
- initial port to OS_X
- listing (Steve Moyle).
- logtalk.
- fix bugs from Nicos.
- remove pl/nfr.yap and misc/yap.spec from CVS.
- deterministic trail entries for multi-assignment variables.
- weird going ons with prompt and readline
- check library(random)
- document system(library)
- interrupt handling in WIN32
- ^C can break code.
- system library
- library(system) for WIN32
- timestamps on files.
- add more precision when outputting floats.
- make statistics/0 better looking.
- fix Yap under Emacs/WIN32
- warnings in documentation file.
- make gc work after mutable var changes (done)
- knap-sack (done)
- Yap core dumps under simple configure/make in WIN32
yap-6.2.2/VC/ 000755 000765 000024 00000000000 11702065316 012561 5 ustar 00vsc staff 000000 000000 yap-6.2.2/VC/include/ 000755 000765 000024 00000000000 11702065316 014204 5 ustar 00vsc staff 000000 000000 yap-6.2.2/VC/wyap.mak 000755 000765 000024 00000010156 11457004724 014244 0 ustar 00vsc staff 000000 000000 # Microsoft Developer Studio Generated NMAKE File, Based on wyap.dsp
!IF "$(CFG)" == ""
CFG=wyap - Win32 Debug
!MESSAGE No configuration specified. Defaulting to wyap - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "wyap - Win32 Release" && "$(CFG)" != "wyap - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "wyap.mak" CFG="wyap - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "wyap - Win32 Release" (based on "Win32 (x86) Console Application")
!MESSAGE "wyap - Win32 Debug" (based on "Win32 (x86) Console Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "wyap - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\wyap.exe"
CLEAN :
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\yap.obj"
-@erase "$(OUTDIR)\wyap.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\include" /I "..\VC\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\wyap.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\wyap.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib ..\yapdll\Release\yapdll.lib /nologo /subsystem:console /incremental:no /pdb:"$(OUTDIR)\wyap.pdb" /machine:I386 /out:"$(OUTDIR)\wyap.exe"
LINK32_OBJS= \
"$(INTDIR)\yap.obj"
"$(OUTDIR)\wyap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "wyap - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\wyap.exe"
CLEAN :
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\yap.obj"
-@erase "$(OUTDIR)\wyap.exe"
-@erase "$(OUTDIR)\wyap.ilk"
-@erase "$(OUTDIR)\wyap.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Fp"$(INTDIR)\wyap.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\wyap.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"$(OUTDIR)\wyap.pdb" /debug /machine:I386 /out:"$(OUTDIR)\wyap.exe" /pdbtype:sept
LINK32_OBJS= \
"$(INTDIR)\yap.obj"
"$(OUTDIR)\wyap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("wyap.dep")
!INCLUDE "wyap.dep"
!ELSE
!MESSAGE Warning: cannot find "wyap.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "wyap - Win32 Release" || "$(CFG)" == "wyap - Win32 Debug"
SOURCE="\Yap\Yap-4.3.17\console\yap.c"
"$(INTDIR)\yap.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
yap-6.2.2/VC/yapdll.mak 000755 000765 000024 00000046645 11457004724 014565 0 ustar 00vsc staff 000000 000000 # Microsoft Developer Studio Generated NMAKE File, Based on yapdll.dsp
!IF "$(CFG)" == ""
CFG=yapdll - Win32 Debug
!MESSAGE No configuration specified. Defaulting to yapdll - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "yapdll - Win32 Release" && "$(CFG)" != "yapdll - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "yapdll.mak" CFG="yapdll - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "yapdll - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "yapdll - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "yapdll - Win32 Release"
OUTDIR=.\Release
INTDIR=.\Release
# Begin Custom Macros
OutDir=.\Release
# End Custom Macros
ALL : "$(OUTDIR)\yapdll.dll"
CLEAN :
-@erase "$(INTDIR)\absmi.obj"
-@erase "$(INTDIR)\adtdefs.obj"
-@erase "$(INTDIR)\alloc.obj"
-@erase "$(INTDIR)\amasm.obj"
-@erase "$(INTDIR)\analyst.obj"
-@erase "$(INTDIR)\arith0.obj"
-@erase "$(INTDIR)\arith1.obj"
-@erase "$(INTDIR)\arith2.obj"
-@erase "$(INTDIR)\arrays.obj"
-@erase "$(INTDIR)\attvar.obj"
-@erase "$(INTDIR)\bb.obj"
-@erase "$(INTDIR)\bignum.obj"
-@erase "$(INTDIR)\c_interface.obj"
-@erase "$(INTDIR)\cdmgr.obj"
-@erase "$(INTDIR)\cmppreds.obj"
-@erase "$(INTDIR)\compiler.obj"
-@erase "$(INTDIR)\computils.obj"
-@erase "$(INTDIR)\corout.obj"
-@erase "$(INTDIR)\dbase.obj"
-@erase "$(INTDIR)\depth_bound.obj"
-@erase "$(INTDIR)\errors.obj"
-@erase "$(INTDIR)\eval.obj"
-@erase "$(INTDIR)\exec.obj"
-@erase "$(INTDIR)\grow.obj"
-@erase "$(INTDIR)\heapgc.obj"
-@erase "$(INTDIR)\index.obj"
-@erase "$(INTDIR)\init.obj"
-@erase "$(INTDIR)\iopreds.obj"
-@erase "$(INTDIR)\load_aix.obj"
-@erase "$(INTDIR)\load_aout.obj"
-@erase "$(INTDIR)\load_coff.obj"
-@erase "$(INTDIR)\load_dl.obj"
-@erase "$(INTDIR)\load_dld.obj"
-@erase "$(INTDIR)\load_dll.obj"
-@erase "$(INTDIR)\load_foreign.obj"
-@erase "$(INTDIR)\load_none.obj"
-@erase "$(INTDIR)\load_shl.obj"
-@erase "$(INTDIR)\mavar.obj"
-@erase "$(INTDIR)\modules.obj"
-@erase "$(INTDIR)\opt.init.obj"
-@erase "$(INTDIR)\opt.memory.obj"
-@erase "$(INTDIR)\opt.preds.obj"
-@erase "$(INTDIR)\or.cowengine.obj"
-@erase "$(INTDIR)\or.cut.obj"
-@erase "$(INTDIR)\or.engine.obj"
-@erase "$(INTDIR)\or.sbaengine.obj"
-@erase "$(INTDIR)\or.scheduler.obj"
-@erase "$(INTDIR)\other.obj"
-@erase "$(INTDIR)\parser.obj"
-@erase "$(INTDIR)\save.obj"
-@erase "$(INTDIR)\scanner.obj"
-@erase "$(INTDIR)\sort.obj"
-@erase "$(INTDIR)\stdpreds.obj"
-@erase "$(INTDIR)\sysbits.obj"
-@erase "$(INTDIR)\tab.completion.obj"
-@erase "$(INTDIR)\tab.tries.obj"
-@erase "$(INTDIR)\tracer.obj"
-@erase "$(INTDIR)\unify.obj"
-@erase "$(INTDIR)\userpreds.obj"
-@erase "$(INTDIR)\utilpreds.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\write.obj"
-@erase "$(INTDIR)\ypsocks.obj"
-@erase "$(INTDIR)\ypstdio.obj"
-@erase "$(OUTDIR)\yapdll.dll"
-@erase "$(OUTDIR)\yapdll.exp"
-@erase "$(OUTDIR)\yapdll.lib"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MT /W3 /GX /O2 /I "..\include" /I "..\H" /I "..\OPTYap" /I "..\VC\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "YAPDLL_EXPORTS" /Fp"$(INTDIR)\yapdll.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\yapdll.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\yapdll.pdb" /machine:I386 /out:"$(OUTDIR)\yapdll.dll" /implib:"$(OUTDIR)\yapdll.lib"
LINK32_OBJS= \
"$(INTDIR)\absmi.obj" \
"$(INTDIR)\adtdefs.obj" \
"$(INTDIR)\alloc.obj" \
"$(INTDIR)\amasm.obj" \
"$(INTDIR)\analyst.obj" \
"$(INTDIR)\arith0.obj" \
"$(INTDIR)\arith1.obj" \
"$(INTDIR)\arith2.obj" \
"$(INTDIR)\arrays.obj" \
"$(INTDIR)\attvar.obj" \
"$(INTDIR)\bb.obj" \
"$(INTDIR)\bignum.obj" \
"$(INTDIR)\c_interface.obj" \
"$(INTDIR)\cdmgr.obj" \
"$(INTDIR)\cmppreds.obj" \
"$(INTDIR)\compiler.obj" \
"$(INTDIR)\computils.obj" \
"$(INTDIR)\corout.obj" \
"$(INTDIR)\dbase.obj" \
"$(INTDIR)\depth_bound.obj" \
"$(INTDIR)\errors.obj" \
"$(INTDIR)\eval.obj" \
"$(INTDIR)\exec.obj" \
"$(INTDIR)\grow.obj" \
"$(INTDIR)\heapgc.obj" \
"$(INTDIR)\index.obj" \
"$(INTDIR)\init.obj" \
"$(INTDIR)\iopreds.obj" \
"$(INTDIR)\load_aix.obj" \
"$(INTDIR)\load_aout.obj" \
"$(INTDIR)\load_coff.obj" \
"$(INTDIR)\load_dl.obj" \
"$(INTDIR)\load_dld.obj" \
"$(INTDIR)\load_dll.obj" \
"$(INTDIR)\load_foreign.obj" \
"$(INTDIR)\load_none.obj" \
"$(INTDIR)\load_shl.obj" \
"$(INTDIR)\mavar.obj" \
"$(INTDIR)\modules.obj" \
"$(INTDIR)\opt.init.obj" \
"$(INTDIR)\opt.memory.obj" \
"$(INTDIR)\opt.preds.obj" \
"$(INTDIR)\or.cowengine.obj" \
"$(INTDIR)\or.cut.obj" \
"$(INTDIR)\or.engine.obj" \
"$(INTDIR)\or.sbaengine.obj" \
"$(INTDIR)\or.scheduler.obj" \
"$(INTDIR)\other.obj" \
"$(INTDIR)\parser.obj" \
"$(INTDIR)\save.obj" \
"$(INTDIR)\scanner.obj" \
"$(INTDIR)\sort.obj" \
"$(INTDIR)\stdpreds.obj" \
"$(INTDIR)\sysbits.obj" \
"$(INTDIR)\tab.completion.obj" \
"$(INTDIR)\tab.tries.obj" \
"$(INTDIR)\tracer.obj" \
"$(INTDIR)\unify.obj" \
"$(INTDIR)\userpreds.obj" \
"$(INTDIR)\utilpreds.obj" \
"$(INTDIR)\write.obj" \
"$(INTDIR)\ypsocks.obj" \
"$(INTDIR)\ypstdio.obj"
"$(OUTDIR)\yapdll.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "yapdll - Win32 Debug"
OUTDIR=.\Debug
INTDIR=.\Debug
# Begin Custom Macros
OutDir=.\Debug
# End Custom Macros
ALL : "$(OUTDIR)\yapdll.dll"
CLEAN :
-@erase "$(INTDIR)\absmi.obj"
-@erase "$(INTDIR)\adtdefs.obj"
-@erase "$(INTDIR)\alloc.obj"
-@erase "$(INTDIR)\amasm.obj"
-@erase "$(INTDIR)\analyst.obj"
-@erase "$(INTDIR)\arith0.obj"
-@erase "$(INTDIR)\arith1.obj"
-@erase "$(INTDIR)\arith2.obj"
-@erase "$(INTDIR)\arrays.obj"
-@erase "$(INTDIR)\attvar.obj"
-@erase "$(INTDIR)\bb.obj"
-@erase "$(INTDIR)\bignum.obj"
-@erase "$(INTDIR)\c_interface.obj"
-@erase "$(INTDIR)\cdmgr.obj"
-@erase "$(INTDIR)\cmppreds.obj"
-@erase "$(INTDIR)\compiler.obj"
-@erase "$(INTDIR)\computils.obj"
-@erase "$(INTDIR)\corout.obj"
-@erase "$(INTDIR)\dbase.obj"
-@erase "$(INTDIR)\depth_bound.obj"
-@erase "$(INTDIR)\errors.obj"
-@erase "$(INTDIR)\eval.obj"
-@erase "$(INTDIR)\exec.obj"
-@erase "$(INTDIR)\grow.obj"
-@erase "$(INTDIR)\heapgc.obj"
-@erase "$(INTDIR)\index.obj"
-@erase "$(INTDIR)\init.obj"
-@erase "$(INTDIR)\iopreds.obj"
-@erase "$(INTDIR)\load_aix.obj"
-@erase "$(INTDIR)\load_aout.obj"
-@erase "$(INTDIR)\load_coff.obj"
-@erase "$(INTDIR)\load_dl.obj"
-@erase "$(INTDIR)\load_dld.obj"
-@erase "$(INTDIR)\load_dll.obj"
-@erase "$(INTDIR)\load_foreign.obj"
-@erase "$(INTDIR)\load_none.obj"
-@erase "$(INTDIR)\load_shl.obj"
-@erase "$(INTDIR)\mavar.obj"
-@erase "$(INTDIR)\modules.obj"
-@erase "$(INTDIR)\opt.init.obj"
-@erase "$(INTDIR)\opt.memory.obj"
-@erase "$(INTDIR)\opt.preds.obj"
-@erase "$(INTDIR)\or.cowengine.obj"
-@erase "$(INTDIR)\or.cut.obj"
-@erase "$(INTDIR)\or.engine.obj"
-@erase "$(INTDIR)\or.sbaengine.obj"
-@erase "$(INTDIR)\or.scheduler.obj"
-@erase "$(INTDIR)\other.obj"
-@erase "$(INTDIR)\parser.obj"
-@erase "$(INTDIR)\save.obj"
-@erase "$(INTDIR)\scanner.obj"
-@erase "$(INTDIR)\sort.obj"
-@erase "$(INTDIR)\stdpreds.obj"
-@erase "$(INTDIR)\sysbits.obj"
-@erase "$(INTDIR)\tab.completion.obj"
-@erase "$(INTDIR)\tab.tries.obj"
-@erase "$(INTDIR)\tracer.obj"
-@erase "$(INTDIR)\unify.obj"
-@erase "$(INTDIR)\userpreds.obj"
-@erase "$(INTDIR)\utilpreds.obj"
-@erase "$(INTDIR)\vc60.idb"
-@erase "$(INTDIR)\vc60.pdb"
-@erase "$(INTDIR)\write.obj"
-@erase "$(INTDIR)\ypsocks.obj"
-@erase "$(INTDIR)\ypstdio.obj"
-@erase "$(OUTDIR)\yapdll.dll"
-@erase "$(OUTDIR)\yapdll.exp"
-@erase "$(OUTDIR)\yapdll.ilk"
-@erase "$(OUTDIR)\yapdll.lib"
-@erase "$(OUTDIR)\yapdll.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP_PROJ=/nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "YAPDLL_EXPORTS" /U "..\include" /U "..\H" /U "..\OPTYap" /U "..\VC\include" /Fp"$(INTDIR)\yapdll.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\yapdll.bsc"
BSC32_SBRS= \
LINK32=link.exe
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\yapdll.pdb" /debug /machine:I386 /out:"$(OUTDIR)\yapdll.dll" /implib:"$(OUTDIR)\yapdll.lib" /pdbtype:sept
LINK32_OBJS= \
"$(INTDIR)\absmi.obj" \
"$(INTDIR)\adtdefs.obj" \
"$(INTDIR)\alloc.obj" \
"$(INTDIR)\amasm.obj" \
"$(INTDIR)\analyst.obj" \
"$(INTDIR)\arith0.obj" \
"$(INTDIR)\arith1.obj" \
"$(INTDIR)\arith2.obj" \
"$(INTDIR)\arrays.obj" \
"$(INTDIR)\attvar.obj" \
"$(INTDIR)\bb.obj" \
"$(INTDIR)\bignum.obj" \
"$(INTDIR)\c_interface.obj" \
"$(INTDIR)\cdmgr.obj" \
"$(INTDIR)\cmppreds.obj" \
"$(INTDIR)\compiler.obj" \
"$(INTDIR)\computils.obj" \
"$(INTDIR)\corout.obj" \
"$(INTDIR)\dbase.obj" \
"$(INTDIR)\depth_bound.obj" \
"$(INTDIR)\errors.obj" \
"$(INTDIR)\eval.obj" \
"$(INTDIR)\exec.obj" \
"$(INTDIR)\grow.obj" \
"$(INTDIR)\heapgc.obj" \
"$(INTDIR)\index.obj" \
"$(INTDIR)\init.obj" \
"$(INTDIR)\iopreds.obj" \
"$(INTDIR)\load_aix.obj" \
"$(INTDIR)\load_aout.obj" \
"$(INTDIR)\load_coff.obj" \
"$(INTDIR)\load_dl.obj" \
"$(INTDIR)\load_dld.obj" \
"$(INTDIR)\load_dll.obj" \
"$(INTDIR)\load_foreign.obj" \
"$(INTDIR)\load_none.obj" \
"$(INTDIR)\load_shl.obj" \
"$(INTDIR)\mavar.obj" \
"$(INTDIR)\modules.obj" \
"$(INTDIR)\opt.init.obj" \
"$(INTDIR)\opt.memory.obj" \
"$(INTDIR)\opt.preds.obj" \
"$(INTDIR)\or.cowengine.obj" \
"$(INTDIR)\or.cut.obj" \
"$(INTDIR)\or.engine.obj" \
"$(INTDIR)\or.sbaengine.obj" \
"$(INTDIR)\or.scheduler.obj" \
"$(INTDIR)\other.obj" \
"$(INTDIR)\parser.obj" \
"$(INTDIR)\save.obj" \
"$(INTDIR)\scanner.obj" \
"$(INTDIR)\sort.obj" \
"$(INTDIR)\stdpreds.obj" \
"$(INTDIR)\sysbits.obj" \
"$(INTDIR)\tab.completion.obj" \
"$(INTDIR)\tab.tries.obj" \
"$(INTDIR)\tracer.obj" \
"$(INTDIR)\unify.obj" \
"$(INTDIR)\userpreds.obj" \
"$(INTDIR)\utilpreds.obj" \
"$(INTDIR)\write.obj" \
"$(INTDIR)\ypsocks.obj" \
"$(INTDIR)\ypstdio.obj"
"$(OUTDIR)\yapdll.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.obj::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.c{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cpp{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
.cxx{$(INTDIR)}.sbr::
$(CPP) @<<
$(CPP_PROJ) $<
<<
!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("yapdll.dep")
!INCLUDE "yapdll.dep"
!ELSE
!MESSAGE Warning: cannot find "yapdll.dep"
!ENDIF
!ENDIF
!IF "$(CFG)" == "yapdll - Win32 Release" || "$(CFG)" == "yapdll - Win32 Debug"
SOURCE="\Yap\Yap-4.3.17\C\absmi.c"
"$(INTDIR)\absmi.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\adtdefs.c"
"$(INTDIR)\adtdefs.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\alloc.c"
"$(INTDIR)\alloc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\amasm.c"
"$(INTDIR)\amasm.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\analyst.c"
"$(INTDIR)\analyst.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\arith0.c"
"$(INTDIR)\arith0.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\arith1.c"
"$(INTDIR)\arith1.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\arith2.c"
"$(INTDIR)\arith2.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\arrays.c"
"$(INTDIR)\arrays.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\attvar.c"
"$(INTDIR)\attvar.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\bb.c"
"$(INTDIR)\bb.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\bignum.c"
"$(INTDIR)\bignum.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\c_interface.c"
"$(INTDIR)\c_interface.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\cdmgr.c"
"$(INTDIR)\cdmgr.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\cmppreds.c"
"$(INTDIR)\cmppreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\compiler.c"
"$(INTDIR)\compiler.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\computils.c"
"$(INTDIR)\computils.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\corout.c"
"$(INTDIR)\corout.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\dbase.c"
"$(INTDIR)\dbase.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\depth_bound.c"
"$(INTDIR)\depth_bound.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\errors.c"
"$(INTDIR)\errors.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\eval.c"
"$(INTDIR)\eval.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\exec.c"
"$(INTDIR)\exec.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\grow.c"
"$(INTDIR)\grow.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\heapgc.c"
"$(INTDIR)\heapgc.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\index.c"
"$(INTDIR)\index.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\init.c"
"$(INTDIR)\init.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\iopreds.c"
"$(INTDIR)\iopreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_aix.c"
"$(INTDIR)\load_aix.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_aout.c"
"$(INTDIR)\load_aout.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_coff.c"
"$(INTDIR)\load_coff.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_dl.c"
"$(INTDIR)\load_dl.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_dld.c"
"$(INTDIR)\load_dld.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_dll.c"
"$(INTDIR)\load_dll.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_foreign.c"
"$(INTDIR)\load_foreign.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_none.c"
"$(INTDIR)\load_none.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\load_shl.c"
"$(INTDIR)\load_shl.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\mavar.c"
"$(INTDIR)\mavar.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\modules.c"
"$(INTDIR)\modules.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\opt.init.c"
"$(INTDIR)\opt.init.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\opt.memory.c"
"$(INTDIR)\opt.memory.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\opt.preds.c"
"$(INTDIR)\opt.preds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.cowengine.c"
"$(INTDIR)\or.cowengine.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.cut.c"
"$(INTDIR)\or.cut.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.engine.c"
"$(INTDIR)\or.engine.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.sbaengine.c"
"$(INTDIR)\or.sbaengine.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\or.scheduler.c"
"$(INTDIR)\or.scheduler.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\other.c"
"$(INTDIR)\other.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\parser.c"
"$(INTDIR)\parser.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\save.c"
"$(INTDIR)\save.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\scanner.c"
"$(INTDIR)\scanner.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\sort.c"
"$(INTDIR)\sort.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\stdpreds.c"
"$(INTDIR)\stdpreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\sysbits.c"
"$(INTDIR)\sysbits.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\tab.completion.c"
"$(INTDIR)\tab.completion.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\OPTYap\tab.tries.c"
"$(INTDIR)\tab.tries.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\tracer.c"
"$(INTDIR)\tracer.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\unify.c"
"$(INTDIR)\unify.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\userpreds.c"
"$(INTDIR)\userpreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\utilpreds.c"
"$(INTDIR)\utilpreds.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\write.c"
"$(INTDIR)\write.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\ypsocks.c"
"$(INTDIR)\ypsocks.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE="\Yap\Yap-4.3.17\C\ypstdio.c"
"$(INTDIR)\ypstdio.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
yap-6.2.2/VC/include/Atoms.h 000755 000765 000024 00000005767 11457004724 015465 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: Atoms.h.m4 *
* Last rev: 19/2/88 *
* mods: *
* comments: atom properties header file for YAP *
* *
*************************************************************************/
#undef EXTERN
#ifndef ADTDEFS_C
#define EXTERN static
#else
#define EXTERN
#endif
/********* operations for atoms ****************************************/
/* Atoms are assumed to be uniquely represented by an OFFSET and to have
associated with them a struct of type AtomEntry
The two functions
RepAtom : Atom -> *AtomEntry
AbsAtom : *AtomEntry -> Atom
are used to encapsulate the implementation of atoms
*/
typedef struct AtomEntryStruct *Atom;
typedef struct PropEntryStruct *Prop;
/* I can only define the structure after I define the actual atoms */
/* atom structure */
typedef struct AtomEntryStruct {
Atom NextOfAE; /* used to build hash chains */
Prop PropsOfAE; /* property list for this atom */
#if defined(YAPOR) || defined(THREADS)
rwlock_t ARWLock;
#endif
char StrOfAE[MIN_ARRAY]; /* representation of atom as a string */
}
AtomEntry;
/* Props and Atoms are stored in chains, ending with a NIL */
#if USE_OFFSETS
# define EndOfPAEntr(P) ( Addr(P) == AtomBase)
#else
# define EndOfPAEntr(P) ( Addr(P) == NIL )
#endif
#define AtomName(at) RepAtom(at)->StrOfAE
/* ********************** Properties **********************************/
#if USE_OFFSETS
#define USE_OFFSETS_IN_PROPS 1
#else
#define USE_OFFSETS_IN_PROPS 0
#endif
typedef SFLAGS PropFlags;
/* basic property entry structure */
typedef struct PropEntryStruct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
} PropEntry;
/* ************************* Functors **********************************/
/* Functor data type
abstype Functor = atom # int
with MkFunctor(a,n) = ...
and NameOfFunctor(f) = ...
and ArityOfFunctor(f) = ... */
#define MaxArity 255
#define FunctorProperty ((PropFlags)(0xbb00))
/* functor property */
typedef struct FunctorEntryStruct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfFE; /* arity of functor */
Atom NameOfFE; /* back pointer to owner atom */
Prop PropsOfFE; /* pointer to list of properties for this functor */
#if defined(YAPOR) || defined(THREADS)
rwlock_t FRWLock;
#endif
} FunctorEntry;
typedef FunctorEntry *Functor;
yap-6.2.2/VC/include/config.h 000644 000765 000024 00000013105 11457004724 015625 0 ustar 00vsc staff 000000 000000 /* config.h. Generated automatically by configure. */
/* are we using gcc */
/* #define HAVE_GCC 1 */
/* should we use gcc threaded code (i.e. goto *adrs) */
/* #define USE_THREADED_CODE 1*/
/* Should we use lib readline ? */
/* #undef HAVE_LIBREADLINE */
/* Should we use gmp ? */
/* #define HAVE_LIBGMP 1 */
/* does the compiler support inline ? */
/* #undef inline */
/* Do we have Ansi headers ? */
#define STDC_HEADERS 1
/* Host Name ? */
#define HOST_ALIAS ""
/* #undef HAVE_SYS_WAIT_H */
#define NO_UNION_WAIT 1
/* #undef HAVE_ARPA_INET_H */
#define HAVE_CTYPE_H 1
#define HAVE_DIRECT_H 1
#define HAVE_DIRENT_H 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
/* #undef HAVE_FENV_H */
/* #undef HAVE_FPU_CONTROL_H */
/* #undef HAVE_GMP_H */
/* #undef HAVE_IEEEFP_H */
#define HAVE_IO_H 1
#define HAVE_LIMITS_H 1
#define HAVE_MEMORY_H 1
/* #undef HAVE_NETDB_H */
/* #undef HAVE_NETINET_IN_H */
/* #undef HAVE_READLINE_READLINE_H */
/* #undef HAVE_REGEX_H */
/* #undef HAVE_SIGINFO_H */
#define HAVE_SIGNAL_H 1
#define HAVE_STDARG_H 1
#define HAVE_STRING_H 1
/* #undef HAVE_STROPTS_H */
/* #undef HAVE_SYS_CONF_H */
#define HAVE_SYS_FILE_H 1
/* #undef HAVE_SYS_MMAN_H */
/* #undef HAVE_SYS_PARAM_H */
/* #undef HAVE_SYS_RESOURCE_H */
/* #undef HAVE_SYS_SELECT_H */
/* #undef HAVE_SYS_SHM_H */
/* #undef HAVE_SYS_SOCKET_H */
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIME_H 1
/* #undef HAVE_SYS_TIMES_H */
#define HAVE_SYS_TYPES_H 1
/* #undef HAVE_SYS_UCONTEXT_H */
/* #undef HAVE_SYS_UN_H */
#define HAVE_TIME_H 1
#define HAVE_UNISTD_H 1
#define HAVE_WINSOCK_H 1
#define HAVE_WINSOCK2_H 1
/* Do we have restartable syscalls */
/* #undef HAVE_RESTARTABLE_SYSCALLS */
/* is 'tms' defined in ? */
/* #undef TM_IN_SYS_TIME */
/* define type of prt returned by malloc: char or void */
#define MALLOC_T void *
/* Define byte order */
/* #undef WORDS_BIGENDIAN */
/* Define sizes of some basic types */
#define SIZEOF_INT_P 4
#define SIZEOF_INT 4
#define SIZEOF_SHORT_INT 2
#define SIZEOF_LONG_INT 4
#define SIZEOF_LONG_LONG_INT 8
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
/* Define representation of floats */
/* only one of the following shoud be set */
/* to add a new representation you must edit FloatOfTerm and MkFloatTerm
in adtdefs.c
*/
#define FFIEEE 1
/* #undef FFVAX */ /* manual */
/* Define the standard type of a float argument to a function */
#define FAFloat double /* manual */
/* Set the minimum and default heap, trail and stack size */
#define MinTrailSpace ( 32*SIZEOF_INT_P)
#define MinStackSpace (200*SIZEOF_INT_P)
#define MinHeapSpace (200*SIZEOF_INT_P)
#define UsrTrailSpace (0)
#define UsrStackSpace (0)
#define UsrHeapSpace (0)
#if (UsrTrailSpace > MinTrailSpace)
#define DefTrailSpace UsrTrailSpace
#else
#define DefTrailSpace MinTrailSpace
#endif
#if (UsrStackSpace > MinStackSpace)
#define DefStackSpace UsrStackSpace
#else
#define DefStackSpace MinStackSpace
#endif
#if (UsrHeapSpace > MinHeapSpace)
#define DefHeapSpace UsrHeapSpace
#else
#define DefHeapSpace MinHeapSpace
#endif
/* Define return type for signal */
#define RETSIGTYPE void
/* #undef HAVE_ACOSH */
/* #undef HAVE_ALARM */
/* #undef HAVE_ASINH */
/* #undef HAVE_ATANH */
#define HAVE_CHDIR 1
#define HAVE_DUP2 1
/* #undef HAVE_FETESTEXCEPT */
/* #undef HAVE_FINITE */
#define HAVE_GETCWD 1
#define HAVE_GETENV 1
/* #undef HAVE_GETHOSTBYNAME */
/* #undef HAVE_GETHOSTID */
/* #undef HAVE_GETHOSTNAME */
/* #undef HAVE_GETHRTIME */
/* #undef HAVE_GETPWNAM */
/* #undef HAVE_GETRUSAGE */
/* #undef HAVE_GETTIMEOFDAY */
/* #undef HAVE_GETWD */
#define HAVE_ISATTY 1
/* #undef HAVE_ISNAN */
/* #undef HAVE_KILL */
#define HAVE_LABS 1
/* #undef HAVE_LINK */
#define HAVE_LOCALTIME 1
/* #undef HAVE_LSTAT */
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
/* #undef HAVE_MKSTEMP */
#define HAVE_MKTEMP 1
/* #undef HAVE_MMAP */
#define HAVE_OPENDIR 1
#define HAVE_POPEN 1
#define HAVE_PUTENV 1
#define HAVE_RAND 1
/* #undef HAVE_RANDOM */
#define HAVE_RENAME 1
/* #undef HAVE_RINT */
/* #undef HAVE_RL_SET_PROMPT */
/* #undef HAVE_SBRK */
/* #undef HAVE_SELECT */
#define HAVE_SETBUF 1
/* #undef HAVE_SETLINEBUF */
/* #undef HAVE_SHMAT */
/* #undef HAVE_SIGACTION */
/* #undef HAVE_SIGGETMASK */
/* #undef HAVE_SIGINTERRUPT */
#define HAVE_SIGNAL 1
/* #undef HAVE_SIGPROCMASK */
#define HAVE_SIGSETJMP 0
#define HAVE_SLEEP 1
/* #undef HAVE_SNPRINTF */
/* #undef HAVE_SOCKET */
#define HAVE_STAT 1
#define HAVE_STRCHR 1
#define HAVE_STRERROR 1
#define HAVE_STRNCAT 1
#define HAVE_STRNCPY 1
#define HAVE_STRTOD 1
#define HAVE_SYSTEM 1
#define HAVE_TIME 1
/* #undef HAVE_TIMES */
#define HAVE_TMPNAM 1
/* #undef HAVE_USLEEP */
/* #undef HAVE_VSNPRINTF */
/* #undef HAVE_WAITPID */
#define HAVE_MPZ_XOR 0
#define HAVE_SIGSEGV 1
#define HAVE_ENVIRON 1
#define SELECT_TYPE_ARG1
#define SELECT_TYPE_ARG234
#define SELECT_TYPE_ARG5
#define TYPE_SELECT_
#define MYTYPE(X) MYTYPE1#X
/* define how to pass the address of a function */
#define FunAdr(Fn) Fn
#define ALIGN_LONGS 1
#define LOW_ABSMI 0
#define MSHIFTOFFS 1
#define USE_MMAP (HAVE_MMAP)
#define USE_SHM (HAVE_SHMAT & !HAVE_MMAP)
#define USE_SBRK (HAVE_SBRK & !HAVE_MMAP & !HAVE_SHMAT)
/* for OSes that do not allow user access to the first
quadrant of the memory space */
/* #undef FORCE_SECOND_QUADRANT */
#if (HAVE_SOCKET || defined(__MINGW32__)) && !defined(SIMICS)
#define USE_SOCKET 1
#endif
#if HAVE_GMP_H && HAVE_LIBGMP
#define USE_GMP 1
#endif
/* Is fflush(NULL) clobbering input streams? */
#define BROKEN_FFLUSH_NULL 1
yap-6.2.2/VC/include/corout_utils.h 000644 000765 000024 00000004216 11457004724 017116 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: corout_utils.h *
* Last rev: *
* mods: *
* comments: Co-routining from within YAP *
* *
*************************************************************************/
STATIC_PROTO (Term SDeref, (Term));
STATIC_PROTO (Term SDerefa, (CELL *));
STATIC_PROTO (sus_tag * deref_susp_chain, (sus_tag *));
static inline Term
SDeref (Term a)
{
while (IsVarTerm (a))
{
Term *b = (Term *) a;
a = *b;
#if SBA
if (a == (0))
return (CELL) b;
#else
if (a == ((Term) b))
return a;
#endif
}
return (a);
}
static inline Term
SDerefa (CELL * b)
{
Term a = *b;
while (IsVarTerm (a))
{
#if SBA
if (a == (0))
return (CELL) b;
#else
if (a == ((Term) b))
return a;
#endif
b = (Term *) a;
a = *b;
}
return (a);
}
static inline CELL *
SADerefa (CELL * b)
{
Term a = *b;
while (IsVarTerm (a))
{
#if SBA
if (a == (0))
return b;
#else
if (a == ((Term) b))
return b;
#endif
b = (Term *) a;
a = *b;
}
return (b);
}
inline EXTERN Term SArgOfTerm (int i, Term t);
inline EXTERN Term
SArgOfTerm (int i, Term t)
{
return (Term) (SDerefa (RepAppl (t) + (i)));
}
inline EXTERN Term SHeadOfTerm (Term);
inline EXTERN Term
SHeadOfTerm (Term t)
{
return (Term) (SDerefa (RepPair (t)));
}
inline EXTERN Term STailOfTerm (Term);
inline EXTERN Term
STailOfTerm (Term t)
{
return (Term) (SDerefa (RepPair (t) + 1));
}
static inline sus_tag *
deref_susp_chain (sus_tag * susp)
{
/* we may have bound several suspension chains together. Follow the
reference chain
*/
while (IsVarTerm (susp->ActiveSus)
&& susp->ActiveSus != (CELL) & susp->ActiveSus)
susp =
(sus_tag *) (susp->ActiveSus - (Int) (&(((sus_tag *) (0))->ActiveSus)));
return (susp);
}
yap-6.2.2/VC/include/sshift.h 000644 000765 000024 00000022446 11457004724 015670 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: sshift.h *
* Last rev: 19/2/88 *
* mods: *
* comments: stack shifter functionality for YAP *
* *
*************************************************************************/
/* The difference between the old stack pointers and the new ones */
extern Int HDiff,
GDiff,
LDiff,
TrDiff,
XDiff,
DelayDiff;
/* The old stack pointers */
extern CELL *OldASP, *OldLCL0;
extern tr_fr_ptr OldTR;
extern CELL *OldGlobalBase, *OldH, *OldH0;
extern ADDR OldTrailBase, OldTrailTop;
extern ADDR OldHeapBase, OldHeapTop;
#define CharP(ptr) ((char *) (ptr))
inline EXTERN int IsHeapP(CELL *);
inline EXTERN int IsHeapP(CELL * ptr)
{
return (int) ((ptr >= (CELL *)HeapBase && ptr <= (CELL *)HeapTop) );
}
/* Adjusting cells and pointers to cells */
inline EXTERN CELL * PtoGloAdjust(CELL *);
inline EXTERN CELL * PtoGloAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + GDiff)) );
}
inline EXTERN CELL * PtoDelayAdjust(CELL *);
inline EXTERN CELL * PtoDelayAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + DelayDiff)) );
}
inline EXTERN tr_fr_ptr PtoTRAdjust(tr_fr_ptr);
inline EXTERN tr_fr_ptr PtoTRAdjust(tr_fr_ptr ptr)
{
return (tr_fr_ptr) (((tr_fr_ptr)(CharP(ptr) + TrDiff)) );
}
inline EXTERN CELL * CellPtoTRAdjust(CELL *);
inline EXTERN CELL * CellPtoTRAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + TrDiff)) );
}
inline EXTERN CELL * PtoLocAdjust(CELL *);
inline EXTERN CELL * PtoLocAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + LDiff)) );
}
inline EXTERN choiceptr ChoicePtrAdjust(choiceptr);
inline EXTERN choiceptr ChoicePtrAdjust(choiceptr ptr)
{
return (choiceptr) (((choiceptr)(CharP(ptr) + LDiff)) );
}
#ifdef TABLING
inline EXTERN choiceptr ConsumerChoicePtrAdjust(choiceptr);
inline EXTERN choiceptr ConsumerChoicePtrAdjust(choiceptr ptr)
{
return (choiceptr) (((choiceptr)(CharP(ptr) + LDiff)) );
}
inline EXTERN choiceptr GeneratorChoicePtrAdjust(choiceptr);
inline EXTERN choiceptr GeneratorChoicePtrAdjust(choiceptr ptr)
{
return (choiceptr) (((choiceptr)(CharP(ptr) + LDiff)) );
}
#endif /* TABLING */
inline EXTERN CELL GlobalAdjust(CELL);
inline EXTERN CELL GlobalAdjust(CELL val)
{
return (CELL) ((val+GDiff) );
}
inline EXTERN CELL DelayAdjust(CELL);
inline EXTERN CELL DelayAdjust(CELL val)
{
return (CELL) ((val+DelayDiff) );
}
inline EXTERN ADDR GlobalAddrAdjust(ADDR);
inline EXTERN ADDR GlobalAddrAdjust(ADDR ptr)
{
return (ADDR) ((ptr+GDiff) );
}
inline EXTERN ADDR DelayAddrAdjust(ADDR);
inline EXTERN ADDR DelayAddrAdjust(ADDR ptr)
{
return (ADDR) ((ptr+DelayDiff) );
}
inline EXTERN CELL LocalAdjust(CELL);
inline EXTERN CELL LocalAdjust(CELL val)
{
return (CELL) ((val+LDiff) );
}
inline EXTERN ADDR LocalAddrAdjust(ADDR);
inline EXTERN ADDR LocalAddrAdjust(ADDR ptr)
{
return (ADDR) ((ptr+LDiff) );
}
inline EXTERN CELL TrailAdjust(CELL);
inline EXTERN CELL TrailAdjust(CELL val)
{
return (CELL) ((val+TrDiff) );
}
inline EXTERN ADDR TrailAddrAdjust(ADDR);
inline EXTERN ADDR TrailAddrAdjust(ADDR ptr)
{
return (ADDR) ((ptr+TrDiff) );
}
/* heap data structures */
inline EXTERN Functor FuncAdjust(Functor);
inline EXTERN Functor FuncAdjust(Functor f)
{
return (Functor) ((Functor)(CharP(f)+HDiff) );
}
inline EXTERN CELL * CellPtoHeapAdjust(CELL *);
inline EXTERN CELL * CellPtoHeapAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + HDiff)) );
}
#if USE_OFFSETS
inline EXTERN Atom AtomAdjust(Atom);
inline EXTERN Atom AtomAdjust(Atom at)
{
return (Atom) ((at) );
}
inline EXTERN Prop PropAdjust(Prop);
inline EXTERN Prop PropAdjust(Prop p)
{
return (Prop) ((p) );
}
#else
inline EXTERN Atom AtomAdjust(Atom);
inline EXTERN Atom AtomAdjust(Atom at)
{
return (Atom) ((at == NULL ? (at) : (Atom)(CharP(at)+HDiff) ));
}
inline EXTERN Prop PropAdjust(Prop);
inline EXTERN Prop PropAdjust(Prop p)
{
return (Prop) ((p == NULL ? (p) : (Prop)(CharP(p)+HDiff)) );
}
#endif
inline EXTERN Term AtomTermAdjust(Term);
inline EXTERN Term AtomTermAdjust(Term at)
{
return (Term) ((at) );
}
#if TAGS_FAST_OPS
inline EXTERN Term BlobTermAdjust(Term);
inline EXTERN Term BlobTermAdjust(Term t)
{
return (Term) ((t-HDiff) );
}
#else
inline EXTERN Term BlobTermAdjust(Term);
inline EXTERN Term BlobTermAdjust(Term t)
{
return (Term) ((t+HDiff) );
}
#endif
inline EXTERN AtomEntry * AtomEntryAdjust(AtomEntry *);
inline EXTERN AtomEntry * AtomEntryAdjust(AtomEntry * at)
{
return (AtomEntry *) ((AtomEntry *)(CharP(at)+HDiff) );
}
inline EXTERN union CONSULT_OBJ * ConsultObjAdjust(union CONSULT_OBJ *);
inline EXTERN union CONSULT_OBJ * ConsultObjAdjust(union CONSULT_OBJ * co)
{
return (union CONSULT_OBJ *) ((union CONSULT_OBJ *)(CharP(co)+HDiff) );
}
inline EXTERN DBRef DBRefAdjust(DBRef);
inline EXTERN DBRef DBRefAdjust(DBRef dbr)
{
return (DBRef) ((DBRef)(CharP(dbr)+HDiff) );
}
inline EXTERN Term CodeAdjust(Term);
inline EXTERN Term CodeAdjust(Term dbr)
{
return (Term) (((Term)(dbr)+HDiff) );
}
inline EXTERN ADDR AddrAdjust(ADDR);
inline EXTERN ADDR AddrAdjust(ADDR addr)
{
return (ADDR) ((ADDR)(CharP(addr)+HDiff) );
}
inline EXTERN CODEADDR CodeAddrAdjust(CODEADDR);
inline EXTERN CODEADDR CodeAddrAdjust(CODEADDR addr)
{
return (CODEADDR) ((CODEADDR)(CharP(addr)+HDiff) );
}
inline EXTERN BlockHeader * BlockAdjust(BlockHeader *);
inline EXTERN BlockHeader * BlockAdjust(BlockHeader * addr)
{
return (BlockHeader *) ((BlockHeader *)(CharP(addr)+HDiff) );
}
inline EXTERN yamop * PtoOpAdjust(yamop *);
inline EXTERN yamop * PtoOpAdjust(yamop * ptr)
{
return (yamop *) (((yamop *)(CharP(ptr) + HDiff)) );
}
inline EXTERN CELL * PtoHeapCellAdjust(CELL *);
inline EXTERN CELL * PtoHeapCellAdjust(CELL * ptr)
{
return (CELL *) (((CELL *)(CharP(ptr) + HDiff)) );
}
inline EXTERN PredEntry * PtoPredAdjust(PredEntry *);
inline EXTERN PredEntry * PtoPredAdjust(PredEntry * ptr)
{
return (PredEntry *) (((PredEntry *)(CharP(ptr) + HDiff)) );
}
inline EXTERN ArrayEntry * PtoArrayEAdjust(ArrayEntry *);
inline EXTERN ArrayEntry * PtoArrayEAdjust(ArrayEntry * ptr)
{
return (ArrayEntry *) (((ArrayEntry *)(CharP(ptr) + HDiff)) );
}
#if PRECOMPUTE_REGADDRESS
inline EXTERN AREG XAdjust(AREG);
inline EXTERN AREG XAdjust(AREG reg)
{
return (AREG) ((AREG)((reg)+XDiff) );
}
#else
inline EXTERN AREG XAdjust(AREG);
inline EXTERN AREG XAdjust(AREG reg)
{
return (AREG) ((reg) );
}
#endif
inline EXTERN YREG YAdjust(YREG);
inline EXTERN YREG YAdjust(YREG reg)
{
return (YREG) ((reg) );
}
inline EXTERN int IsOldLocal(CELL);
inline EXTERN int IsOldLocal(CELL reg)
{
return (int) (IN_BETWEEN(OldASP, reg, OldLCL0));
}
/* require because the trail might contain dangling pointers */
inline EXTERN int IsOldLocalInTR(CELL);
inline EXTERN int IsOldLocalInTR(CELL reg)
{
return (int) (IN_BETWEEN(OldH, reg, OldLCL0) );
}
inline EXTERN int IsOldLocalInTRPtr(CELL *);
inline EXTERN int IsOldLocalInTRPtr(CELL * ptr)
{
return (int) (IN_BETWEEN(OldH, ptr, OldLCL0) );
}
inline EXTERN int IsOldH(CELL);
inline EXTERN int IsOldH(CELL reg)
{
return (int) (( CharP(reg) == CharP(OldH) ) );
}
inline EXTERN int IsOldGlobal(CELL);
inline EXTERN int IsOldGlobal(CELL reg)
{
return (int) (IN_BETWEEN(OldH0, reg, OldH) );
}
inline EXTERN int IsOldGlobalPtr(CELL *);
inline EXTERN int IsOldGlobalPtr(CELL * ptr)
{
return (int) (IN_BETWEEN( OldH0, ptr, OldH) );
}
inline EXTERN int IsOldDelay(CELL);
inline EXTERN int IsOldDelay(CELL reg)
{
return (int) (IN_BETWEEN(OldGlobalBase, reg, OldH0) );
}
inline EXTERN int IsOldDelayPtr(CELL *);
inline EXTERN int IsOldDelayPtr(CELL * ptr)
{
return (int) (IN_BETWEEN( OldGlobalBase, ptr, OldH0) );
}
inline EXTERN int IsOldTrail(CELL);
inline EXTERN int IsOldTrail(CELL reg)
{
return (int) (IN_BETWEEN(OldTrailBase, reg, OldTR) );
}
inline EXTERN int IsOldTrailPtr(CELL *);
inline EXTERN int IsOldTrailPtr(CELL * ptr)
{
return (int) (IN_BETWEEN(OldTrailBase, ptr, OldTR) );
}
inline EXTERN int IsOldCode(CELL);
inline EXTERN int IsOldCode(CELL reg)
{
return (int) (IN_BETWEEN(OldHeapBase, reg, OldHeapTop) );
}
inline EXTERN int IsOldCodeCellPtr(CELL *);
inline EXTERN int IsOldCodeCellPtr(CELL * ptr)
{
return (int) (IN_BETWEEN(OldHeapBase, ptr, OldHeapTop) );
}
inline EXTERN int IsGlobal(CELL);
inline EXTERN int IsGlobal(CELL reg)
{
return (int) (IN_BETWEEN(GlobalBase, reg, H) );
}
void STD_PROTO(AdjustStacksAndTrail, (void));
void STD_PROTO(AdjustRegs, (int));
yap-6.2.2/VC/include/Tags_24bits.h 000644 000765 000024 00000007125 11457004724 016452 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: Tags_24bits.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Tag Scheme for machines with 24 bits adresses (m68000) *
* version: $Id: Tags_24bits.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
/* Version for 24 bit addresses (68000)
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1000 numeric value
floats 1m1001 floating point value
pairs 1mr10. ptr to pair
aplied functor 1mr01. ptr to functor followed by args
ref 0mr000 address of cell
undefined 0mr000 pointing to itself
*/
#define AllTagBits 0xfc000000L
#define TagBits 0xbc000000L
#define MaskAdr 0x03ffffffL
#define AdrHiBit 0x02000000L
#define NumberTag 0xa0000000L
#define FloatTag 0xa4000000L
#define AtomTag 0x84000000L
#define PairTag 0x90000000L
#define ApplTag 0x88000000L
#define RefTag 0x80000000L
#define MaskBits 6
#define PairBit 0x10000000L
#define ApplBit 0x08000000L
#define CompBits 0x18000000L
#define NumberMask 0xb8000000L
#define MAX_ABS_INT /* 0xfe00000LL */ ((((UInt)(1<<7))-1) << SHIFT_HIGH_TAG)
#define NonTagPart(X) (Signed(X) & MaskAdr)
#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)))
#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V))
#define BitOn(Bit,V) (Bit & Unsigned(V))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0x00000000L
inline EXTERN int IsVarTerm(Term);
inline EXTERN int IsVarTerm(Term t)
{
return (int) (Signed(t) >= 0);
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (Signed(t) < 0);
}
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) (NonTagPart(t));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (TAGGEDA(PairTag, (p)));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) (BitOn(PairBit, (t)));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) (NonTagPart(t));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) (TAGGEDA(ApplTag, (p)));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) (BitOn(ApplBit, (t)));
}
inline EXTERN Int IsAtomOrIntTerm(Term);
inline EXTERN Int IsAtomOrIntTerm(Term t)
{
return (Int) (!(Unsigned(t) & CompBits));
}
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
static inline Int
IntOfTerm(Term t)
{
Int n;
n = (Unsigned(t) & MaskPrim) >> 2;
if (Unsigned(t) & AdrHiBit)
n |= 0xfc000000;
return (n);
}
yap-6.2.2/VC/include/Tags_32bits.h 000644 000765 000024 00000007721 11457004724 016453 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: Tags_32bits.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32bits.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
/* Original version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1....00 numeric value
atoms 1m0....00 offset of atom entry
pairs 1mr....01 ptr to pair
aplied functor 1mr....10 ptr to functor followed by args
ref 0mr....00 address of cell
undefined 0mr....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
*/
#define SHIFT_HIGH_TAG 29
#define MKTAG(HI,LO) ((((UInt) (HI))<= 0);
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (Signed(t) < 0);
}
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) (NonTagPart(t));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (TAGGEDA(PairTag, (p)));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) (BitOn(PairBit, (t)));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) (NonTagPart(t));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) (TAGGEDA(ApplTag, (p)));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) (BitOn(ApplBit, (t)));
}
inline EXTERN int IsAtomOrIntTerm(Term);
inline EXTERN int IsAtomOrIntTerm(Term t)
{
return (int) (((Unsigned(t) & LowTagBits) == 0));
}
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Int IntOfTerm(Term);
inline EXTERN Int IntOfTerm(Term t)
{
return (Int) (((Int)(t << 3))>>(3+2));
}
yap-6.2.2/VC/include/Tags_32LowTag.h 000644 000765 000024 00000010266 11457004724 016705 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: Tags_32LowTag.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32LowTag.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
#define TAG_LOW_BITS_32 1
/* Version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints m.....110 numeric value
atoms m.....010 offset of atom entry
pairs mr.....11 ptr to pair
aplied functor mr.....01 ptr to functor followed by args
ref mr.....00 address of cell
undefined mr.....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
*/
#define SHIFT_LOW_TAG 2
#define SHIFT_HIGH_TAG 2
#define MKTAG(HI,LO) ((((UInt) (HI))<>1) & ~LowTagBits)
#define TAGGED(TAG,V) (((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)|(TAG))
#define NONTAGGED(TAG,V) ((Unsigned(V)<<(SHIFT_HIGH_TAG+SHIFT_LOW_TAG+1))>>1)
#define TAGGEDA(TAG,V) ((Unsigned(V) << 1)|(TAG))
#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
/* bits that should not be used by anyone but us */
#define YAP_PROTECTED_MASK 0xc0000000L
inline EXTERN int IsVarTerm(Term);
inline EXTERN int IsVarTerm(Term t)
{
return (int) (!((t) & LowTagBits));
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (((t) & LowTagBits));
}
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) ((t)-PairBits);
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (Unsigned(p)+PairBits);
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) ((((t) & LowTagBits) == PairBits));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) (((t)-ApplBit));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) (Unsigned(p)+ApplBit);
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) ((((t) & LowTagBits) == ApplBit));
}
inline EXTERN Int IsAtomOrIntTerm(Term);
inline EXTERN Int IsAtomOrIntTerm(Term t)
{
return (Int) ((((t) & LowTagBits) == 2));
}
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) ((t)+off);
}
inline EXTERN Int IntOfTerm(Term);
inline EXTERN Int IntOfTerm(Term t)
{
return (Int) (((Int)(t << 1))>>(SHIFT_LOW_TAG+SHIFT_HIGH_TAG+1));
}
yap-6.2.2/VC/include/Tags_32Ops.h 000644 000765 000024 00000014300 11457004724 016242 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: Tags_32Ops.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_32Ops.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
/*
Version for 32 bit addresses machines,
Each term is represented internally as an unsigned 32 bit integer as
follows:
tag value
ints 1m1....01 numeric value
atoms 1m0....01 offset of atom entry
pairs 1mr....11 ptr to pair
aplied functor 1mr....00 ptr to functor followed by args
undefined 0mr....00 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
This version speeds up access to lists and to compound
terms by using the XOR and NOT operations to build their tags. This
saves operations on RISC machines.
As a further optimisation, only pairs or compound terms have
the second lowest bit set. This allows one to recognise lists or
compound terms with a single operation.
The main problem is that the default value of the M and R bits for GC
are now 1 in compound terms and structures.
*/
#define TAGS_FAST_OPS 1
#define SHIFT_HIGH_TAG 29
#define MKTAG(HI,LO) ((((UInt) (HI))<= 0);
}
inline EXTERN int IsNonVarTerm(Term);
inline EXTERN int IsNonVarTerm(Term t)
{
return (int) (Signed(t) < 0);
}
#if UNIQUE_TAG_FOR_PAIRS
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) ((~(t)));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) ((~Unsigned(p)));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) (((t) & PairBit));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) ((-Signed(t)));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) ((-Signed(p)));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) ((!((t) & LowTagBits)));
}
#else
inline EXTERN Term * RepPair(Term);
inline EXTERN Term * RepPair(Term t)
{
return (Term *) ((-Signed(t)));
}
inline EXTERN Term AbsPair(Term *);
inline EXTERN Term AbsPair(Term * p)
{
return (Term) (((CELL)(-Signed(p))));
}
inline EXTERN Int IsPairTerm(Term);
inline EXTERN Int IsPairTerm(Term t)
{
return (Int) ((!((t) & LowTagBits)));
}
inline EXTERN Term * RepAppl(Term);
inline EXTERN Term * RepAppl(Term t)
{
return (Term *) ((~(t)));
}
inline EXTERN Term AbsAppl(Term *);
inline EXTERN Term AbsAppl(Term * p)
{
return (Term) ((~Unsigned(p)));
}
inline EXTERN Int IsApplTerm(Term);
inline EXTERN Int IsApplTerm(Term t)
{
return (Int) (((t) & ApplBit));
}
#endif
inline EXTERN Int IsAtomOrIntTerm(Term);
inline EXTERN Int IsAtomOrIntTerm(Term t)
{
return (Int) (((Unsigned(t) & LowTagBits) == 0x2));
}
inline EXTERN Int IntOfTerm(Term);
inline EXTERN Int IntOfTerm(Term t)
{
return (Int) ((Int)(Unsigned(t) << 3) >> 5);
}
#if UNIQUE_TAG_FOR_PAIRS
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) (((IsVarTerm(t) || IsAtomOrIntTerm(t)) ? (t)+(off) : (IsPairTerm(t) ? (CELL)AbsPair((CELL *)((CELL)RepPair(t)+(off))) : (t)-(off))));
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) (IsVarTerm(t) ? (t)+(off) : (t)-(off));
}
#else
inline EXTERN Term AdjustPtr(Term t, Term off);
inline EXTERN Term AdjustPtr(Term t, Term off)
{
return (Term) (((IsVarTerm(t) || IsAtomOrIntTerm(t)) ? (t)+(off) : (IsApplTerm(t) ? (CELL)AbsAppl((CELL *)((CELL)RepAppl(t)+(off))) : (t)-(off))));
}
inline EXTERN Term AdjustIDBPtr(Term t, Term off);
inline EXTERN Term AdjustIDBPtr(Term t, Term off)
{
return (Term) (IsVarTerm(t) ? (t)+(off) : (IsApplTerm(t) ? (CELL)AbsAppl((CELL *)((CELL)RepAppl(t)+(off))) : (t)-(off)));
}
#endif
yap-6.2.2/VC/include/Tags_64bits.h 000644 000765 000024 00000007720 11457004724 016457 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: Tags_32Ops.h.m4 *
* Last rev: December 90 *
* mods: *
* comments: Original Tag Scheme for machines with 32 bits adresses *
* version: $Id: Tags_64bits.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
#define TAG_64BITS 1
/* Version for 64 bit addresses machines,
Each term is represented internally as an unsigned 64 bit integer as
follows:
tag value
ints 0m1....001 numeric value
atoms 0m0....001 offset of atom entry
pairs 0mr....011 ptr to pair
aplied functor 0mr....101 ptr to functor followed by args
undefined 0mr....000 address of cell pointing to itself
functors are represented as ptrs to the functor entry in the atom
property list
We rely on the fact that addresses are always multiple of 8.
*/
#define SHIFT_HIGH_TAG 61
#define MKTAG(HI,LO) ((((UInt) (HI))<> 6);
}
yap-6.2.2/VC/include/TermExt.h 000644 000765 000024 00000021531 11457004724 015752 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: TermExt.h *
* mods: *
* comments: Extensions to standard terms for YAP *
* version: $Id: TermExt.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
#if USE_OFFSETS
#define AtomFoundVar ((Atom)(&(((special_functors *)(NULL))->AtFoundVar)))
#define AtomNil ((Atom)(&(((special_functors *)(NULL))->AtNil)))
#define AtomDot ((Atom)(&(((special_functors *)(NULL))->AtDot)))
#else
#define AtomFoundVar AbsAtom(&(SF_STORE->AtFoundVar))
#define AtomNil AbsAtom(&(SF_STORE->AtNil))
#define AtomDot AbsAtom(&(SF_STORE->AtDot))
#endif
#define TermFoundVar MkAtomTerm(AtomFoundVar)
#define TermNil MkAtomTerm(AtomNil)
#define TermDot MkAtomTerm(AtomDot)
#ifdef IN_SECOND_QUADRANT
typedef enum {
db_ref_e = sizeof(Functor *)|RBIT,
long_int_e = 2*sizeof(Functor *)|RBIT,
#ifdef USE_GMP
big_int_e = 3*sizeof(Functor *)|RBIT,
double_e = 4*sizeof(Functor *)|RBIT
#else
double_e = 3*sizeof(Functor *)|RBIT
#endif
} blob_type;
#else
typedef enum {
db_ref_e = sizeof(Functor *),
long_int_e = 2*sizeof(Functor *),
#ifdef USE_GMP
big_int_e = 3*sizeof(Functor *),
double_e = 4*sizeof(Functor *)
#else
double_e = 3*sizeof(Functor *)
#endif
} blob_type;
#endif
#define FunctorDBRef ((Functor)(db_ref_e))
#define FunctorLongInt ((Functor)(long_int_e))
#ifdef USE_GMP
#define FunctorBigInt ((Functor)(big_int_e))
#endif
#define FunctorDouble ((Functor)(double_e))
#define EndSpecials (double_e)
inline EXTERN blob_type BlobOfFunctor(Functor f);
inline EXTERN blob_type BlobOfFunctor(Functor f)
{
return (blob_type) ((CELL)f);
}
#define SF_STORE ((special_functors *)HEAP_INIT_BASE)
#ifdef COROUTINING
typedef struct {
/* what to do when someone tries to bind our term to someone else
in some predefined context */
void (*bind_op)(Term *, Term);
/* what to do if someone wants to copy our constraint */
int (*copy_term_op)(CELL *, CELL ***, CELL *);
/* copy the constraint into a term and back */
Term (*to_term_op)(CELL *);
int (*term_to_op)(Term, Term);
/* op called to do marking in GC */
void (*mark_op)(CELL *);
} ext_op;
/* known delays */
typedef enum {
empty_ext = 0*sizeof(ext_op), /* default op, this should never be called */
susp_ext = 1*sizeof(ext_op), /* support for delayable goals */
attvars_ext = 2*sizeof(ext_op), /* support for attributed variables */
/* add your own extensions here */
/* keep this one */
} exts;
/* array with the ops for your favourite extensions */
extern ext_op attas[attvars_ext+1];
#endif
/* make sure that these data structures are the first thing to be allocated
in the heap when we start the system */
typedef struct special_functors_struct
{
AtomEntry AtFoundVar;
char AtFoundVarChars[8];
AtomEntry AtNil;
char AtNilChars[8];
AtomEntry AtDot;
char AtDotChars[8];
}
special_functors;
#if SIZEOF_DOUBLE == SIZEOF_LONG_INT
inline EXTERN Term MkFloatTerm(Float);
inline EXTERN Term MkFloatTerm(Float dbl)
{
return (Term) ((H[0] = (CELL)FunctorDouble, *(Float *)(H+1) = dbl, H[2]=((2*sizeof(CELL)+EndSpecials)|MBIT),H+=3,AbsAppl(H-3)));
}
inline EXTERN Float FloatOfTerm(Term t);
inline EXTERN Float FloatOfTerm(Term t)
{
return (Float) (*(Float *)(RepAppl(t)+1));
}
#define InitUnalignedFloat()
#else
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
#ifdef i386X
#define DOUBLE_ALIGNED(ADDR) TRUE
#else
/* first, need to address the alignment problem */
#define DOUBLE_ALIGNED(ADDR) ((CELL)(ADDR) & 0x4)
#endif
inline EXTERN Float STD_PROTO(CpFloatUnaligned,(CELL *));
inline EXTERN void STD_PROTO(AlignGlobalForDouble,(void));
inline EXTERN Float
CpFloatUnaligned(CELL *ptr)
{
union { Float f; CELL d[2]; } u;
u.d[0] = ptr[1];
u.d[1] = ptr[2];
return(u.f);
}
inline EXTERN Term MkFloatTerm(Float);
inline EXTERN Term MkFloatTerm(Float dbl)
{
return (Term) ((AlignGlobalForDouble(), H[0] = (CELL)FunctorDouble, *(Float *)(H+1) = dbl, H[3]=((3*sizeof(CELL)+EndSpecials)|MBIT), H+=4, AbsAppl(H-4)));
}
inline EXTERN Float FloatOfTerm(Term t);
inline EXTERN Float FloatOfTerm(Term t)
{
return (Float) ((DOUBLE_ALIGNED(RepAppl(t)) ? *(Float *)(RepAppl(t)+1) : CpFloatUnaligned(RepAppl(t))));
}
/* no alignment problems for 64 bit machines */
#else
/* OOPS, YAP only understands Floats that are as large as cells or that
take two cells!!! */
#endif
#endif
inline EXTERN int IsFloatTerm(Term);
inline EXTERN int IsFloatTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorDouble);
}
/* extern Functor FunctorLongInt; */
inline EXTERN Term MkLongIntTerm(Int);
inline EXTERN Term MkLongIntTerm(Int i)
{
return (Term) ((H[0] = (CELL)FunctorLongInt,H[1] = (CELL)(i),H[2]=((2*sizeof(CELL)+EndSpecials)|MBIT),H+=3,AbsAppl(H-3)));
}
inline EXTERN Int LongIntOfTerm(Term t);
inline EXTERN Int LongIntOfTerm(Term t)
{
return (Int) (RepAppl(t)[1]);
}
inline EXTERN int IsLongIntTerm(Term);
inline EXTERN int IsLongIntTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
}
#ifdef USE_GMP
#include
#include
MP_INT *STD_PROTO(PreAllocBigNum,(void));
MP_INT *STD_PROTO(InitBigNum,(Int));
Term STD_PROTO(MkBigIntTerm, (MP_INT *));
MP_INT *STD_PROTO(BigIntOfTerm, (Term));
void STD_PROTO(CleanBigNum,(void));
inline EXTERN int IsBigIntTerm(Term);
inline EXTERN int IsBigIntTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorBigInt);
}
inline EXTERN int IsLargeIntTerm(Term);
inline EXTERN int IsLargeIntTerm(Term t)
{
return (int) (IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorBigInt) && (FunctorOfTerm(t) >= FunctorLongInt)));
}
#else
inline EXTERN int IsBigIntTerm(Term);
inline EXTERN int IsBigIntTerm(Term t)
{
return (int) (FALSE);
}
inline EXTERN int IsLargeIntTerm(Term);
inline EXTERN int IsLargeIntTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorLongInt);
}
#endif
/* extern Functor FunctorLongInt; */
inline EXTERN int IsLargeNumTerm(Term);
inline EXTERN int IsLargeNumTerm(Term t)
{
return (int) (IsApplTerm(t) && ((FunctorOfTerm(t) <= FunctorDouble) && (FunctorOfTerm(t) >= FunctorLongInt)));
}
inline EXTERN int IsNumTerm(Term);
inline EXTERN int IsNumTerm(Term t)
{
return (int) ((IsIntTerm(t) || IsLargeNumTerm(t)));
}
inline EXTERN Int IsAtomicTerm(Term);
inline EXTERN Int IsAtomicTerm(Term t)
{
return (Int) (IsAtomOrIntTerm(t) || IsLargeNumTerm(t));
}
inline EXTERN Int IsExtensionFunctor(Functor);
inline EXTERN Int IsExtensionFunctor(Functor f)
{
return (Int) (f <= FunctorDouble);
}
inline EXTERN Int IsBlobFunctor(Functor);
inline EXTERN Int IsBlobFunctor(Functor f)
{
return (Int) ((f <= FunctorDouble && f >= FunctorDBRef));
}
inline EXTERN Int IsPrimitiveTerm(Term);
inline EXTERN Int IsPrimitiveTerm(Term t)
{
return (Int) ((IsAtomOrIntTerm(t) || (IsApplTerm(t) && IsBlobFunctor(FunctorOfTerm(t)))));
}
#ifdef TERM_EXTENSIONS
inline EXTERN Int IsAttachFunc(Functor);
inline EXTERN Int IsAttachFunc(Functor f)
{
return (Int) (FALSE);
}
inline EXTERN Int IsAttachedTerm(Term);
inline EXTERN Int IsAttachedTerm(Term t)
{
return (Int) ((IsVarTerm(t) && VarOfTerm(t) < H0) );
}
inline EXTERN exts ExtFromCell(CELL *);
inline EXTERN exts ExtFromCell(CELL * pt)
{
return (exts) (pt[1]);
}
#else
inline EXTERN Int IsAttachFunc(Functor);
inline EXTERN Int IsAttachFunc(Functor f)
{
return (Int) (FALSE);
}
inline EXTERN Int IsAttachedTerm(Term);
inline EXTERN Int IsAttachedTerm(Term t)
{
return (Int) (FALSE);
}
#endif
EXTERN int STD_PROTO(unify_extension,(Functor, CELL, CELL *, CELL));
inline EXTERN int
unify_extension(Functor f, CELL d0, CELL *pt0, CELL d1)
{
switch(BlobOfFunctor(f)) {
case db_ref_e:
return (d0 == d1);
case long_int_e:
return(pt0[1] == RepAppl(d1)[1]);
#ifdef USE_GMP
case big_int_e:
return (mpz_cmp(BigIntOfTerm(d0),BigIntOfTerm(d1)) == 0);
#endif /* USE_GMP */
case double_e:
{
CELL *pt1 = RepAppl(d1);
return (pt0[1] == pt1[1]
#if SIZEOF_DOUBLE == 2*SIZEOF_LONG_INT
&& pt0[2] == pt1[2]
#endif
);
}
}
return(FALSE);
}
yap-6.2.2/VC/include/Yap.h 000644 000765 000024 00000062170 11457004724 015117 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: Yap.h.m4 *
* mods: *
* comments: main header file for YAP *
* version: $Id: Yap.h,v 1.9 2002-06-01 04:29:01 vsc Exp $ *
*************************************************************************/
#include "config.h"
/*
#define RATIONAL_TREES 1
#define DEPTH_LIMIT 1
#define COROUTINING 1
#define YAPOR 1
#define ANALYST 1
*/
#define MULTI_ASSIGNMENT_VARIABLES 1
#if defined(TABLING)
#error Do not explicitly define TABLING
#endif /* YAPOR */
#if defined(TABLING_BATCHED_SCHEDULING) && defined(TABLING_LOCAL_SCHEDULING)
#error Do not define multiple tabling scheduling strategies
#endif /* TABLING_BATCHED_SCHEDULING || TABLING_LOCAL_SCHEDULING */
#if defined(TABLING_BATCHED_SCHEDULING) || defined(TABLING_LOCAL_SCHEDULING)
#define TABLING 1
#endif /* TABLING_BATCHED_SCHEDULING || TABLING_LOCAL_SCHEDULING */
#if defined(YAPOR)
#error Do not explicitly define YAPOR
#endif /* YAPOR */
#if (defined(ENV_COPY) && (defined(ACOW) || defined(SBA))) || (defined(ACOW) && defined(SBA))
#error Do not define multiple or-parallel models
#endif /* (ENV_COPY && (ACOW || SBA)) || (ACOW && SBA) */
#if defined(ENV_COPY) || defined(ACOW) || defined(SBA)
#define YAPOR 1
#endif /* ENV_COPY || ACOW || SBA */
#if defined(TABLING) && (defined(ACOW) || defined(SBA))
#error Currently TABLING only works with ENV_COPY
#endif /* TABLING && (ACOW || SBA) */
#ifdef YAPOR
#define FIXED_STACKS 1
#endif /* YAPOR */
#if defined(YAPOR) || defined(TABLING)
#undef TRAILING_REQUIRES_BRANCH
#endif /* YAPOR || TABLING */
#if ANALYST
#ifdef USE_THREADED_CODE
#undef USE_THREADED_CODE
#endif
#endif
#ifdef COROUTINING
#ifndef TERM_EXTENSIONS
#define TERM_EXTENSIONS 1
#endif
#endif
#ifdef SBA
#ifdef YAPOR
#ifndef FROZEN_STACKS
#define FROZEN_STACKS 1
#endif
#endif
#endif
#ifdef TABLING
#ifndef FROZEN_STACKS
#define FROZEN_STACKS 1
#endif
#endif
#ifdef _MSC_VER /* Microsoft's Visual C++ Compiler */
/* adjust a config.h from mingw32 to work with vc++ */
#ifdef HAVE_GCC
#undef HAVE_GCC
#endif
#ifdef USE_THREADED_CODE
#undef USE_THREADED_CODE
#endif
#define inline __inline
#define YAP_VERSION "Yap-4.3.21"
#define BIN_DIR "c:\\Program Files\\Yap\\bin"
#define LIB_DIR "c:\\Program Files\\Yap\\lib\\Yap"
#define SHARE_DIR "c:\\Program Files\\Yap\\share\\Yap"
#ifdef HOST_ALIAS
#undef HOST_ALIAS
#endif
#define HOST_ALIAS "i386-pc-win32"
#ifdef HAVE_IEEEFP_H
#undef HAVE_IEEEFP_H
#endif
#ifdef HAVE_UNISTD_H
#undef HAVE_UNISTD_H
#endif
#ifdef HAVE_SYS_TIME_H
#undef HAVE_SYS_TIME_H
#endif
#endif
#ifdef __MINGW32__
#ifndef _WIN32
#define _WIN32 1
#endif
#endif
#if HAVE_GCC
#define MIN_ARRAY 0
#define DUMMY_FILLER_FOR_ABS_TYPE
#else
#define MIN_ARRAY 1
#define DUMMY_FILLER_FOR_ABS_TYPE int dummy;
#endif
#ifndef ADTDEFS_C
#define EXTERN static
#else
#define EXTERN
#endif
/* truth-values */
#define TRUE 1
#define FALSE 0
/* null pointer */
#define NIL 0
/* Basic types */
/* defines integer types Int and UInt (unsigned) with the same size as a ptr
** and integer types Short and UShort with half the size of a ptr
*/
#if SIZEOF_INT_P==4
#if SIZEOF_INT==4
/* */ typedef int Int;
/* */ typedef unsigned int UInt;
#elif SIZEOF_LONG_INT==4
/* */ typedef long int Int;
/* */ typedef unsigned long int UInt;
#else
# error Yap require integer types of the same size as a pointer
#endif
#if SIZEOF_SHORT_INT==2
/* */ typedef short int Short;
/* */ typedef unsigned short int UShort;
#else
# error Yap requires integer types half the size of a pointer
#endif
#elif SIZEOF_INT_P==8
# if SIZEOF_INT==8
/* */ typedef int Int;
/* */ typedef unsigned int UInt;
#elif SIZEOF_LONG_INT==8
/* */ typedef long int Int;
/* */ typedef unsigned long int UInt;
# elif SIZEOF_LONG_LONG_INT==8
/* */ typedef long long int Int;
/* */ typedef unsigned long long int UInt;
# else
# error Yap requires integer types of the same size as a pointer
# endif
# if SIZEOF_SHORT_INT==4
/* */ typedef short int Short;
/* */ typedef unsigned short int UShort;
# elif SIZEOF_INT==4
/* */ typedef int Short;
/* */ typedef short int UShort;
# else
# error Yap requires integer types half the size of a pointer
# endif
#else
# error Yap requires pointers of size 4 or 8
#endif
/* */ typedef double Float;
#if SIZEOF_INT
#else
#ifdef i386
#include
#endif
#if defined(sparc) || defined(__sparc)
#include
#endif
#ifdef mips
#include
#endif
#ifdef __alpha
#include
#endif
#endif
/********************** use an auxiliary function for ranges ************/
#ifdef __GNUC__
#define IN_BETWEEN(MIN,X,MAX) (Unsigned((Int)(X)-(Int)(MIN)) <= \
Unsigned((Int)(MAX)-(Int)(MIN)) )
#define OUTSIDE(MIN,X,MAX) (Unsigned((Int)(X)-(Int)(MIN)) > \
Unsigned((Int)(MAX)-(Int)(MIN)) )
#else
#define IN_BETWEEN(MIN,X,MAX) ((void *)(X) >= (void *)(MIN) && (void *)(X) <= (void *)(MAX))
#define OUTSIDE(MIN,X,MAX) ((void *)(X) < (void *)(MIN) || (void *)(X) > (void *)(MAX))
#endif
/* ************************* Atoms *************************************/
#include "Atoms.h"
/* ************************* Coroutining **********************************/
#ifdef COROUTINING
/* Support for co-routining */
#include "corout.h"
#endif
/********* abstract machine registers **********************************/
#include "amidefs.h"
#include "Regs.h"
#if defined(YAPOR) ||defined(THREADS)
#ifdef mips
#include
#endif
#ifdef __alpha
#include
#endif
#endif
/************ variables concerned with Error Handling *************/
#include
#if defined(SIMICS) || !HAVE_SIGSETJMP
#define sigjmp_buf jmp_buf
#define sigsetjmp(Env, Arg) setjmp(Env)
#define siglongjmp(Env, Arg) longjmp(Env, Arg)
#endif
extern sigjmp_buf RestartEnv; /* used to restart after an abort */
/* Support for arrays */
#include "arrays.h"
/************ variables concerned with Error Handling *************/
/* Types of Errors */
typedef enum {
YAP_NO_ERROR,
FATAL_ERROR,
INTERNAL_ERROR,
PURE_ABORT,
/* ISO_ERRORS */
DOMAIN_ERROR_ARRAY_OVERFLOW,
DOMAIN_ERROR_ARRAY_TYPE,
DOMAIN_ERROR_IO_MODE,
DOMAIN_ERROR_MUTABLE,
DOMAIN_ERROR_NON_EMPTY_LIST,
DOMAIN_ERROR_NOT_LESS_THAN_ZERO,
DOMAIN_ERROR_NOT_NL,
DOMAIN_ERROR_NOT_ZERO,
DOMAIN_ERROR_OUT_OF_RANGE,
DOMAIN_ERROR_OPERATOR_PRIORITY,
DOMAIN_ERROR_OPERATOR_SPECIFIER,
DOMAIN_ERROR_RADIX,
DOMAIN_ERROR_SHIFT_COUNT_OVERFLOW,
DOMAIN_ERROR_SOURCE_SINK,
DOMAIN_ERROR_STREAM,
DOMAIN_ERROR_STREAM_OR_ALIAS,
DOMAIN_ERROR_STREAM_POSITION,
DOMAIN_ERROR_TIMEOUT_SPEC,
DOMAIN_ERROR_SYNTAX_ERROR_HANDLER,
EVALUATION_ERROR_FLOAT_OVERFLOW,
EVALUATION_ERROR_FLOAT_UNDERFLOW,
EVALUATION_ERROR_INT_OVERFLOW,
EVALUATION_ERROR_UNDEFINED,
EVALUATION_ERROR_UNDERFLOW,
EVALUATION_ERROR_ZERO_DIVISOR,
EXISTENCE_ERROR_ARRAY,
EXISTENCE_ERROR_SOURCE_SINK,
EXISTENCE_ERROR_STREAM,
INSTANTIATION_ERROR,
PERMISSION_ERROR_ACCESS_PRIVATE_PROCEDURE,
PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM,
PERMISSION_ERROR_CREATE_ARRAY,
PERMISSION_ERROR_CREATE_OPERATOR,
PERMISSION_ERROR_INPUT_BINARY_STREAM,
PERMISSION_ERROR_INPUT_PAST_END_OF_STREAM,
PERMISSION_ERROR_INPUT_STREAM,
PERMISSION_ERROR_INPUT_TEXT_STREAM,
PERMISSION_ERROR_MODIFY_STATIC_PROCEDURE,
PERMISSION_ERROR_OPEN_SOURCE_SINK,
PERMISSION_ERROR_OUTPUT_BINARY_STREAM,
PERMISSION_ERROR_OUTPUT_STREAM,
PERMISSION_ERROR_OUTPUT_TEXT_STREAM,
PERMISSION_ERROR_RESIZE_ARRAY,
PERMISSION_ERROR_REPOSITION_STREAM,
REPRESENTATION_ERROR_CHARACTER,
REPRESENTATION_ERROR_CHARACTER_CODE,
REPRESENTATION_ERROR_MAX_ARITY,
SYNTAX_ERROR,
SYSTEM_ERROR,
TYPE_ERROR_ARRAY,
TYPE_ERROR_ATOM,
TYPE_ERROR_ATOMIC,
TYPE_ERROR_BYTE,
TYPE_ERROR_CALLABLE,
TYPE_ERROR_CHARACTER,
TYPE_ERROR_COMPOUND,
TYPE_ERROR_DBREF,
TYPE_ERROR_DBTERM,
TYPE_ERROR_EVALUABLE,
TYPE_ERROR_FLOAT,
TYPE_ERROR_INTEGER,
TYPE_ERROR_KEY,
TYPE_ERROR_LIST,
TYPE_ERROR_NUMBER,
TYPE_ERROR_PREDICATE_INDICATOR,
TYPE_ERROR_PTR,
TYPE_ERROR_UBYTE,
TYPE_ERROR_VARIABLE,
UNKNOWN_ERROR
} yap_error_number;
extern char *ErrorMessage; /* used to pass error messages */
extern Term Error_Term; /* used to pass error terms */
extern yap_error_number Error_TYPE; /* used to pass the error */
typedef enum {
YAP_INT_BOUNDED_FLAG = 0,
MAX_ARITY_FLAG = 1,
INTEGER_ROUNDING_FLAG = 2,
YAP_MAX_INTEGER_FLAG = 3,
YAP_MIN_INTEGER_FLAG = 4,
CHAR_CONVERSION_FLAG = 5,
YAP_DOUBLE_QUOTES_FLAG = 6,
YAP_TO_CHARS_FLAG = 7,
LANGUAGE_MODE_FLAG = 8,
STRICT_ISO_FLAG = 9,
SPY_CREEP_FLAG = 10,
SOURCE_MODE_FLAG = 11,
CHARACTER_ESCAPE_FLAG = 12,
WRITE_QUOTED_STRING_FLAG = 13,
ALLOW_ASSERTING_STATIC_FLAG = 14,
HALT_AFTER_CONSULT_FLAG = 15,
FAST_BOOT_FLAG = 16
} yap_flags;
#define STRING_AS_CHARS 0
#define STRING_AS_ATOM 2
#define QUINTUS_TO_CHARS 0
#define ISO_TO_CHARS 1
#define CPROLOG_CHARACTER_ESCAPES 0
#define ISO_CHARACTER_ESCAPES 1
#define SICSTUS_CHARACTER_ESCAPES 2
#define NUMBER_OF_YAP_FLAGS FAST_BOOT_FLAG+1
/************************ prototypes **********************************/
#include "Yapproto.h"
/************************ OPTYap configuration ************************/
/* These must be included before unification handlers */
#if defined(YAPOR) || defined(TABLING)
#include "opt.config.h"
#endif
/***********************************************************************/
/*
absrectype Term = Int + Float + Atom + Pair + Appl + Ref + Var
with AbsAppl(t) : *CELL -> Term
and RepAppl(t) : Term -> *CELL
and AbsPair(t) : *CELL -> Term
and RepPair(t) : Term -> *CELL
and IsIntTerm(t) = ...
and IsAtomTerm(t) = ...
and IsVarTerm(t) = ...
and IsPairTerm(t) = ...
and IsApplTerm(t) = ...
and IsFloatTerm(t) = ...
and IsRefTerm(t) = ...
and IsNonVarTerm(t) = ! IsVar(t)
and IsNumterm(t) = IsIntTerm(t) || IsFloatTerm(t)
and IsAtomicTerm(t) = IsNumTerm(t) || IsAtomTerm(t)
and IsPrimitiveTerm(t) = IsAtomicTerm(t) || IsRefTerm(t)
and MkIntTerm(n) = ...
and MkFloatTerm(f) = ...
and MkAtomTerm(a) = ...
and MkVarTerm(r) = ...
and MkApplTerm(f,n,args) = ...
and MkPairTerm(hd,tl) = ...
and MkRefTerm(R) = ...
and PtrOfTerm(t) : Term -> CELL * = ...
and IntOfTerm(t) : Term -> int = ...
and FloatOfTerm(t) : Term -> flt = ...
and AtomOfTerm(t) : Term -> Atom = ...
and VarOfTerm(t) : Term -> *Term = ....
and HeadOfTerm(t) : Term -> Term = ...
and TailOfTerm(t) : Term -> Term = ...
and FunctorOfTerm(t) : Term -> Functor = ...
and ArgOfTerm(i,t) : Term -> Term= ...
and RefOfTerm(t) : Term -> DBRef = ...
*/
/*
YAP can use several different tag schemes, according to the kind of
machine we are experimenting with.
*/
#if LONG_ADDRESSES && defined(OLD_TAG_SCHEME)
#include "Tags_32bits.h"
#endif /* LONG_ADDRESSES && defined(OLD_TAG_SCHEME) */
/* AIX will by default place mmaped segments at 0x30000000. This is
incompatible with the high tag scheme. Linux-ELF also does not like
if you place things in the lower addresses (power to the libc people).
*/
#if (defined(_AIX) || defined(_WIN32) || defined(sparc) || defined(__sparc) || defined(mips) || defined(__FreeBSD__) || defined(_POWER) || defined(__linux__) || defined(IN_SECOND_QUADRANT)) && !defined(TABLING)
#define USE_LOW32_TAGS 1
#endif
#if LONG_ADDRESSES && SIZEOF_INT_P==4 && !defined(OLD_TAG_SCHEME) && !defined(USE_LOW32_TAGS)
#include "Tags_32Ops.h"
#endif /* LONG_ADDRESSES && !defined(OLD_TAG_SCHEME) && !defined(USE_LOW32_TAGS) */
#if LONG_ADDRESSES && SIZEOF_INT_P==4 && !defined(OLD_TAG_SCHEME) && defined(USE_LOW32_TAGS)
#include "Tags_32LowTag.h"
#endif /* LONG_ADDRESSES && !defined(OLD_TAG_SCHEME) */
#if LONG_ADDRESSES && SIZEOF_INT_P==8 && !defined(OLD_TAG_SCHEME)
#include "Tags_64bits.h"
#endif /* LONG_ADDRESSES && SIZEOF_INT_P==8 && !defined(OLD_TAG_SCHEME) */
#if !LONG_ADDRESSES
#include "Tags_24bits.h"
#endif /* !LONG_ADDRESSES */
#ifdef TAG_LOW_BITS_32
#define MBIT 0x80000000
#define RBIT 0x40000000
#if IN_SECOND_QUADRANT
#define INVERT_RBIT 1 /* RBIT is 1 by default */
#endif
#else
#if defined(SBA) && defined(__linux__)
#define MBIT /* 0x20000000 */ MKTAG(0x1,0) /* mark bit */
#else
#define RBIT /* 0x20000000 */ MKTAG(0x1,0) /* relocation chain bit */
#define MBIT /* 0x40000000 */ MKTAG(0x2,0) /* mark bit */
#endif
#endif
#define TermSize sizeof(Term)
/************* variables related to memory allocation *******************/
/* must be before TermExt.h */
extern ADDR HeapBase,
LocalBase,
GlobalBase,
TrailBase, TrailTop,
ForeignCodeBase, ForeignCodeTop, ForeignCodeMax;
/* applies to unbound variables */
inline EXTERN Term * VarOfTerm(Term t);
inline EXTERN Term * VarOfTerm(Term t)
{
return (Term *) (t);
}
#if SBA
inline EXTERN Term MkVarTerm(void);
inline EXTERN Term MkVarTerm()
{
return (Term) ((*H = 0, H++));
}
inline EXTERN int IsUnboundVar(Term);
inline EXTERN int IsUnboundVar(Term t)
{
return (int) (t == 0);
}
#else
inline EXTERN Term MkVarTerm(void);
inline EXTERN Term MkVarTerm()
{
return (Term) ((*H = (CELL) H, H++));
}
inline EXTERN int IsUnboundVar(Term);
inline EXTERN int IsUnboundVar(Term t)
{
return (int) (*VarOfTerm(t) == (t));
}
#endif
inline EXTERN CELL * PtrOfTerm(Term);
inline EXTERN CELL * PtrOfTerm(Term t)
{
return (CELL *) (*(CELL *)(t));
}
inline EXTERN Functor FunctorOfTerm(Term);
inline EXTERN Functor FunctorOfTerm(Term t)
{
return (Functor) (*RepAppl(t));
}
inline EXTERN Term MkAtomTerm(Atom);
inline EXTERN Term MkAtomTerm(Atom a)
{
return (Term) (TAGGEDA(AtomTag, (CELL)(a)-HEAP_INIT_BASE));
}
inline EXTERN Atom AtomOfTerm(Term t);
inline EXTERN Atom AtomOfTerm(Term t)
{
return (Atom) (HEAP_INIT_BASE+NonTagPart(t));
}
inline EXTERN int IsAtomTerm(Term);
inline EXTERN int IsAtomTerm(Term t)
{
return (int) (CHKTAG((t), AtomTag));
}
inline EXTERN Term MkIntTerm(Int);
inline EXTERN Term MkIntTerm(Int n)
{
return (Term) (TAGGED(NumberTag, (n)));
}
/*
A constant to subtract or add to a well-known term, we assume no
overflow problems are possible
*/
inline EXTERN Term MkIntConstant(Int);
inline EXTERN Term MkIntConstant(Int n)
{
return (Term) (NONTAGGED(NumberTag, (n)));
}
inline EXTERN int IsIntTerm(Term);
inline EXTERN int IsIntTerm(Term t)
{
return (int) (CHKTAG((t), NumberTag));
}
/* Needed to handle numbers:
these two macros are fundamental in the integer/float conversions */
#ifdef M_WILLIAMS
#define IntInBnd(X) (TRUE)
#else
#ifdef TAGS_FAST_OPS
#define IntInBnd(X) (Unsigned( ( (Int)(X) >> (32-7) ) + 1) <= 1)
#else
#define IntInBnd(X) ( (X) < MAX_ABS_INT && \
(X) > -MAX_ABS_INT-1L )
#endif
#endif
#ifdef C_PROLOG
#define FlIsInt(X) ( (X) == (Int)(X) && IntInBnd((X)) )
#else
#define FlIsInt(X) ( FALSE )
#endif
/*
There are two types of functors:
o Special functors mark special terms
on the heap that should be seen as constants.
o Standard functors mark normal applications.
*/
#include "TermExt.h"
#define IsAccessFunc(func) ((func) == FunctorAccess)
inline EXTERN Term MkIntegerTerm(Int);
inline EXTERN Term MkIntegerTerm(Int n)
{
return (Term) (IntInBnd(n) ? MkIntTerm(n) : MkLongIntTerm(n));
}
inline EXTERN int IsIntegerTerm(Term);
inline EXTERN int IsIntegerTerm(Term t)
{
return (int) (IsIntTerm(t) || IsLongIntTerm(t));
}
inline EXTERN Int IntegerOfTerm(Term);
inline EXTERN Int IntegerOfTerm(Term t)
{
return (Int) (IsIntTerm(t) ? IntOfTerm(t) : LongIntOfTerm(t));
}
/*************** unification routines ***********************************/
#if SBA
#include "or.sbaamiops.h"
#else
#include "amiops.h"
#endif
/*************** High level macros to access arguments ******************/
inline EXTERN Term ArgOfTerm(int i, Term t);
inline EXTERN Term ArgOfTerm(int i, Term t)
{
return (Term) (Derefa(RepAppl(t) + (i)));
}
inline EXTERN Term HeadOfTerm(Term);
inline EXTERN Term HeadOfTerm(Term t)
{
return (Term) (Derefa(RepPair(t)));
}
inline EXTERN Term TailOfTerm(Term);
inline EXTERN Term TailOfTerm(Term t)
{
return (Term) (Derefa(RepPair(t) + 1));
}
inline EXTERN Term ArgOfTermCell(int i, Term t);
inline EXTERN Term ArgOfTermCell(int i, Term t)
{
return (Term) ((CELL)(RepAppl(t) + (i)));
}
inline EXTERN Term HeadOfTermCell(Term);
inline EXTERN Term HeadOfTermCell(Term t)
{
return (Term) ((CELL)(RepPair(t)));
}
inline EXTERN Term TailOfTermCell(Term);
inline EXTERN Term TailOfTermCell(Term t)
{
return (Term) ((CELL)(RepPair(t) + 1));
}
/*************** variables concerned with atoms table *******************/
#define MaxHash 1001
/************ variables concerned with save and restore *************/
extern int splfild;
#define FAIL_RESTORE 0
#define DO_EVERYTHING 1
#define DO_ONLY_CODE 2
#ifdef EMACS
/******************** using Emacs mode ********************************/
extern int emacs_mode;
#endif
/************ variable concerned with version number *****************/
extern char version_number[];
/********* common instructions codes*************************/
#define MAX_PROMPT 256
#if USE_THREADED_CODE
/************ reverse lookup of instructions *****************/
typedef struct opcode_tab_entry {
OPCODE opc;
op_numbers opnum;
} opentry;
#endif
/******************* controlling the compiler ****************************/
extern int optimizer_on;
/******************* the line for the current parse **********************/
extern int StartLine;
extern int StartCh;
extern int CurFileNo;
/********************* how to write a Prolog term ***********************/
/********* Prolog may be in several modes *******************************/
typedef enum {
BootMode = 1, /* if booting or restoring */
UserMode = 2, /* Normal mode */
CritMode = 4, /* If we are meddling with the heap */
AbortMode = 8, /* expecting to abort */
InterruptMode = 16, /* under an interrupt */
InErrorMode = 32, /* under an interrupt */
ConsoleGetcMode = 64 /* blocked reading from console */
} prolog_exec_mode;
extern prolog_exec_mode PrologMode;
extern int CritLocks;
/************** Access to yap initial arguments ***************************/
extern char **yap_args;
extern int yap_argc;
/******************* controlling debugging ****************************/
extern int creep_on;
#ifdef YAPOR
#define YAPEnterCriticalSection() \
{ \
if (worker_id != GLOBAL_LOCKS_who_locked_heap) { \
LOCK(GLOBAL_LOCKS_heap_access); \
GLOBAL_LOCKS_who_locked_heap = worker_id; \
} \
PrologMode |= CritMode; \
CritLocks++; \
}
#define YAPLeaveCriticalSection() \
{ \
CritLocks--; \
if (!CritLocks) { \
PrologMode &= ~CritMode; \
if (PrologMode & InterruptMode) { \
PrologMode &= ~InterruptMode; \
ProcessSIGINT(); \
} \
if (PrologMode & AbortMode) { \
PrologMode &= ~AbortMode; \
Error(PURE_ABORT, 0, ""); \
} \
GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS; \
UNLOCK(GLOBAL_LOCKS_heap_access); \
} \
}
#else
#define YAPEnterCriticalSection() \
{ \
PrologMode |= CritMode; \
CritLocks++; \
}
#define YAPLeaveCriticalSection() \
{ \
CritLocks--; \
if (!CritLocks) { \
PrologMode &= ~CritMode; \
if (PrologMode & InterruptMode) { \
PrologMode &= ~InterruptMode; \
ProcessSIGINT(); \
} \
if (PrologMode & AbortMode) { \
PrologMode &= ~AbortMode; \
Error(PURE_ABORT, 0, ""); \
} \
} \
}
#endif /* YAPOR */
/* when we are calling the InitStaff procedures */
#define AT_BOOT 0
#define AT_RESTORE 1
/********* whether we should try to compile array references ******************/
extern int compile_arrays;
/********* mutable variables ******************/
/* I assume that the size of this structure is a multiple of the size
of CELL!!! */
typedef struct TIMED_MAVAR{
CELL value;
CELL clock;
} timed_var;
/********* while debugging you may need some info ***********************/
#if DEBUG
extern int output_msg;
#endif
#if EMACS
extern char emacs_tmp[], emacs_tmp2[];
#endif
#if HAVE_SIGNAL
extern int snoozing;
#endif
#if defined(YAPOR) || defined(TABLING)
#include "opt.structs.h"
#include "opt.macros.h"
#include "opt.proto.h"
#endif /* YAPOR || TABLING */
#if SBA
#include "or.sbaunify.h"
#endif
yap-6.2.2/VC/include/Yatom.h 000644 000765 000024 00000061144 11457004724 015457 0 ustar 00vsc staff 000000 000000
/*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: YAtom.h.m4 *
* Last rev: 19/2/88 *
* mods: *
* comments: atom properties header file for YAP *
* *
*************************************************************************/
/* This code can only be defined *after* including Regs.h!!! */
#if USE_OFFSETS
inline EXTERN Atom AbsAtom(AtomEntry * p);
inline EXTERN Atom AbsAtom(AtomEntry * p)
{
return (Atom) (Addr(p) - AtomBase);
}
inline EXTERN AtomEntry * RepAtom(Atom a);
inline EXTERN AtomEntry * RepAtom(Atom a)
{
return (AtomEntry *) (AtomBase + Unsigned(a));
}
#else
inline EXTERN Atom AbsAtom(AtomEntry * p);
inline EXTERN Atom AbsAtom(AtomEntry * p)
{
return (Atom) (p);
}
inline EXTERN AtomEntry * RepAtom(Atom a);
inline EXTERN AtomEntry * RepAtom(Atom a)
{
return (AtomEntry *) (a);
}
#endif
#if USE_OFFSETS_IN_PROPS
inline EXTERN Prop AbsProp(PropEntry * p);
inline EXTERN Prop AbsProp(PropEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
inline EXTERN PropEntry * RepProp(Prop p);
inline EXTERN PropEntry * RepProp(Prop p)
{
return (PropEntry *) (AtomBase+Unsigned(p));
}
#else
inline EXTERN Prop AbsProp(PropEntry * p);
inline EXTERN Prop AbsProp(PropEntry * p)
{
return (Prop) (p);
}
inline EXTERN PropEntry * RepProp(Prop p);
inline EXTERN PropEntry * RepProp(Prop p)
{
return (PropEntry *) (p);
}
#endif
#if USE_OFFSETS_IN_PROPS
inline EXTERN FunctorEntry * RepFunctorProp(Prop p);
inline EXTERN FunctorEntry * RepFunctorProp(Prop p)
{
return (FunctorEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsFunctorProp(FunctorEntry * p);
inline EXTERN Prop AbsFunctorProp(FunctorEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN FunctorEntry * RepFunctorProp(Prop p);
inline EXTERN FunctorEntry * RepFunctorProp(Prop p)
{
return (FunctorEntry *) (p);
}
inline EXTERN Prop AbsFunctorProp(FunctorEntry * p);
inline EXTERN Prop AbsFunctorProp(FunctorEntry * p)
{
return (Prop) (p);
}
#endif
inline EXTERN Int ArityOfFunctor(Functor);
inline EXTERN Int ArityOfFunctor(Functor Fun)
{
return (Int) (((FunctorEntry *)Fun)->ArityOfFE);
}
inline EXTERN Atom NameOfFunctor(Functor);
inline EXTERN Atom NameOfFunctor(Functor Fun)
{
return (Atom) (((FunctorEntry *)Fun)->NameOfFE);
}
inline EXTERN PropFlags IsFunctorProperty(int);
inline EXTERN PropFlags IsFunctorProperty(int flags)
{
return (PropFlags) ((flags == FunctorProperty) );
}
/* summary of property codes used
00 00 predicate entry
80 00 db property
bb 00 functor entry
ff df sparse functor
ff ex arithmetic property
ff f7 array
ff fa module property
ff fb blackboard property
ff fc value property
ff ff op property
*/
/* Module property */
typedef struct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
SMALLUNSGN IndexOfMod; /* indec in module table */
} ModEntry;
#if USE_OFFSETS_IN_PROPS
inline EXTERN ModEntry * RepModProp(Prop p);
inline EXTERN ModEntry * RepModProp(Prop p)
{
return (ModEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsModProp(ModEntry * p);
inline EXTERN Prop AbsModProp(ModEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN ModEntry * RepModProp(Prop p);
inline EXTERN ModEntry * RepModProp(Prop p)
{
return (ModEntry *) (p);
}
inline EXTERN Prop AbsModProp(ModEntry * p);
inline EXTERN Prop AbsModProp(ModEntry * p)
{
return (Prop) (p);
}
#endif
#define ModProperty ((PropFlags)0xfffa)
inline EXTERN PropFlags IsModProperty(int);
inline EXTERN PropFlags IsModProperty(int flags)
{
return (PropFlags) ((flags == ModProperty));
}
/* operator property entry structure */
typedef struct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
#if defined(YAPOR) || defined(THREADS)
rwlock_t OpRWLock; /* a read-write lock to protect the entry */
#endif
BITS16 Prefix, Infix, Posfix; /* precedences */
} OpEntry;
#if USE_OFFSETS_IN_PROPS
inline EXTERN OpEntry * RepOpProp(Prop p);
inline EXTERN OpEntry * RepOpProp(Prop p)
{
return (OpEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsOpProp(OpEntry * p);
inline EXTERN Prop AbsOpProp(OpEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN OpEntry * RepOpProp(Prop p);
inline EXTERN OpEntry * RepOpProp(Prop p)
{
return (OpEntry *) (p);
}
inline EXTERN Prop AbsOpProp(OpEntry * p);
inline EXTERN Prop AbsOpProp(OpEntry * p)
{
return (Prop) (p);
}
#endif
#define OpProperty ((PropFlags)0xffff)
inline EXTERN PropFlags IsOpProperty(int);
inline EXTERN PropFlags IsOpProperty(int flags)
{
return (PropFlags) ((flags == OpProperty) );
}
/* defines related to operator specifications */
#define MaskPrio 0x0fff
#define DcrlpFlag 0x1000
#define DcrrpFlag 0x2000
typedef union arith_ret *eval_ret;
/* expression property entry structure */
typedef struct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfEE;
BITS16 ENoOfEE;
BITS16 FlagsOfEE;
/* operations that implement the expression */
union {
blob_type (*constant)(eval_ret);
blob_type (*unary)(Term, eval_ret);
blob_type (*binary)(Term, Term, eval_ret);
} FOfEE;
} ExpEntry;
#if USE_OFFSETS_IN_PROPS
inline EXTERN ExpEntry * RepExpProp(Prop p);
inline EXTERN ExpEntry * RepExpProp(Prop p)
{
return (ExpEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsExpProp(ExpEntry * p);
inline EXTERN Prop AbsExpProp(ExpEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN ExpEntry * RepExpProp(Prop p);
inline EXTERN ExpEntry * RepExpProp(Prop p)
{
return (ExpEntry *) (p);
}
inline EXTERN Prop AbsExpProp(ExpEntry * p);
inline EXTERN Prop AbsExpProp(ExpEntry * p)
{
return (Prop) (p);
}
#endif
#define ExpProperty 0xffe0
/* only unary and binary expressions are acceptable */
inline EXTERN PropFlags IsExpProperty(int);
inline EXTERN PropFlags IsExpProperty(int flags)
{
return (PropFlags) ((flags == ExpProperty) );
}
/* value property entry structure */
typedef struct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
#if defined(YAPOR) || defined(THREADS)
rwlock_t VRWLock; /* a read-write lock to protect the entry */
#endif
Term ValueOfVE; /* (atomic) value associated with the atom */
} ValEntry;
#if USE_OFFSETS_IN_PROPS
inline EXTERN ValEntry * RepValProp(Prop p);
inline EXTERN ValEntry * RepValProp(Prop p)
{
return (ValEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsValProp(ValEntry * p);
inline EXTERN Prop AbsValProp(ValEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN ValEntry * RepValProp(Prop p);
inline EXTERN ValEntry * RepValProp(Prop p)
{
return (ValEntry *) (p);
}
inline EXTERN Prop AbsValProp(ValEntry * p);
inline EXTERN Prop AbsValProp(ValEntry * p)
{
return (Prop) (p);
}
#endif
#define ValProperty ((PropFlags)0xfffc)
inline EXTERN PropFlags IsValProperty(int);
inline EXTERN PropFlags IsValProperty(int flags)
{
return (PropFlags) ((flags == ValProperty) );
}
/* predicate property entry structure */
/* AsmPreds are things like var, nonvar, atom ...which are implemented
through dedicated machine instructions. In this case the 8 lower
bits of PredFlags are used to hold the machine instruction code
for the pred.
C_Preds are things write, read, ... implemented in C. In this case
CodeOfPred holds the address of the correspondent C-function.
*/
typedef enum {
CArgsPredFlag = 0x1000000L, /* ! should ! across */
CutTransparentPredFlag = 0x800000L, /* ! should ! across */
SourcePredFlag = 0x400000L, /* static predicate with source declaration */
MetaPredFlag = 0x200000L, /* predicate subject to a meta declaration */
SyncPredFlag = 0x100000L, /* has to synch before it can execute*/
UserCPredFlag = 0x080000L, /* CPred defined by the user */
MultiFileFlag = 0x040000L, /* is multi-file */
FastPredFlag = 0x020000L, /* is "compiled" */
TestPredFlag = 0x010000L, /* is a test (optim. comit) */
AsmPredFlag = 0x008000L, /* inline */
StandardPredFlag= 0x004000L, /* system predicate */
DynamicPredFlag= 0x002000L, /* dynamic predicate */
CPredFlag = 0x001000L, /* written in C */
SafePredFlag = 0x000800L, /* does not alter arguments */
CompiledPredFlag= 0x000400L, /* is static */
IndexedPredFlag= 0x000200L, /* has indexing code */
SpiedPredFlag = 0x000100L, /* is a spy point */
BinaryTestPredFlag=0x000080L, /* test predicate. */
#ifdef TABLING
TabledPredFlag = 0x000040L, /* is tabled */
#endif /* TABLING */
#ifdef YAPOR
SequentialPredFlag=0x000020L, /* may not create par. choice points!*/
#endif /* YAPOR */
ProfiledPredFlag = 0x000010L, /* pred is being profiled */
LogUpdatePredFlag= 0x000008L /* dynamic predicate with log. upd. sem.*/
} pred_flag;
/* profile data */
typedef struct {
#if defined(YAPOR) || defined(THREADS)
lockvar lock; /* a simple lock to protect this entry */
#endif
Int NOfEntries; /* nbr of times head unification succeeded*/
Int NOfHeadSuccesses; /* nbr of times head unification succeeded*/
Int NOfRetries; /* nbr of times a clause for the pred
was retried */
} profile_data;
typedef struct pred_entry {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfPE; /* arity of property */
CELL PredFlags;
CODEADDR CodeOfPred; /* code address */
CODEADDR TrueCodeOfPred; /* if needing to spy or to lock */
Functor FunctorOfPred; /* functor for Predicate */
CODEADDR FirstClause, LastClause;
Atom OwnerFile; /* File where the predicate was defined */
struct pred_entry *NextPredOfModule; /* next pred for same module */
#if defined(YAPOR) || defined(THREADS)
rwlock_t PRWLock; /* a simple lock to protect this entry */
#endif
#ifdef TABLING
tab_ent_ptr TableOfPred;
#endif /* TABLING */
SMALLUNSGN ModuleOfPred; /* module for this definition */
OPCODE OpcodeOfPred; /* undefcode, indexcode, spycode, .... */
profile_data StatisticsForPred; /* enable profiling for predicate */
SMALLUNSGN StateOfPred; /* actual state of predicate */
} PredEntry;
#define PEProp ((PropFlags)(0x0000))
#if USE_OFFSETS_IN_PROPS
inline EXTERN PredEntry * RepPredProp(Prop p);
inline EXTERN PredEntry * RepPredProp(Prop p)
{
return (PredEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsPredProp(PredEntry * p);
inline EXTERN Prop AbsPredProp(PredEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN PredEntry * RepPredProp(Prop p);
inline EXTERN PredEntry * RepPredProp(Prop p)
{
return (PredEntry *) (p);
}
inline EXTERN Prop AbsPredProp(PredEntry * p);
inline EXTERN Prop AbsPredProp(PredEntry * p)
{
return (Prop) (p);
}
#endif
inline EXTERN PropFlags IsPredProperty(int);
inline EXTERN PropFlags IsPredProperty(int flags)
{
return (PropFlags) ((flags == PEProp) );
}
/********* maximum number of C-written predicates and cmp funcs ******************/
#define MAX_C_PREDS 360
#define MAX_CMP_FUNCS 20
typedef struct {
PredEntry *p;
CmpPredicate f;
} cmp_entry;
extern CPredicate c_predicates[MAX_C_PREDS];
extern cmp_entry cmp_funcs[MAX_CMP_FUNCS];
/* Flags for code or dbase entry */
/* There are several flags for code and data base entries */
typedef enum {
GcFoundMask = 0x10000, /* informs this is a dynamic predicate */
DynamicMask = 0x8000, /* informs this is a dynamic predicate */
InUseMask = 0x4000, /* informs this block is being used */
ErasedMask = 0x2000, /* informs this block has been erased */
IndexMask = 0x1000, /* informs this is indexing code */
DBClMask = 0x0800, /* informs this is a data base structure */
LogUpdRuleMask= 0x0400, /* informs the code is for a log upd rule with env */
LogUpdMask = 0x0200, /* informs this is a logic update index. */
StaticMask = 0x0100, /* dealing with static predicates */
SpiedMask = 0x0080 /* this predicate is being spied */
/* other flags belong to DB */
} dbentry_flags;
/* *********************** DBrefs **************************************/
#define KEEP_ENTRY_AGE 1
typedef struct DB_STRUCT {
Functor id; /* allow pointers to this struct to id */
/* as dbref */
Term EntryTerm; /* cell bound to itself */
SMALLUNSGN Flags; /* Term Flags */
SMALLUNSGN NOfRefsTo; /* Number of references pointing here */
struct struct_dbentry *Parent; /* key of DBase reference */
CODEADDR Code; /* pointer to code if this is a clause */
struct DB_STRUCT **DBRefs; /* pointer to other references */
struct DB_STRUCT *Prev; /* Previous element in chain */
struct DB_STRUCT *Next; /* Next element in chain */
#if defined(YAPOR) || defined(THREADS)
lockvar lock; /* a simple lock to protect this entry */
Int ref_count; /* how many branches are using this entry */
#endif
#ifdef KEEP_ENTRY_AGE
Int age; /* entry's age, negative if from recorda,
positive if it was recordz */
#endif /* KEEP_ENTRY_AGE */
#ifdef COROUTINING
CELL attachments; /* attached terms */
#endif
CELL Mask; /* parts that should be cleared */
CELL Key; /* A mask that can be used to check before
you unify */
CELL NOfCells; /* Size of Term */
CELL Entry; /* entry point */
Term Contents[MIN_ARRAY]; /* stored term */
} DBStruct;
#define DBStructFlagsToDBStruct(X) ((DBRef)((X) - (CELL) &(((DBRef) NIL)->Flags)))
#if defined(YAPOR) || defined(THREADS)
#define INIT_DBREF_COUNT(X) (X)->ref_count = 0
#define INC_DBREF_COUNT(X) (X)->ref_count++
#define DEC_DBREF_COUNT(X) (X)->ref_count--
#define DBREF_IN_USE(X) ((X)->ref_count != 0)
#else
#define INIT_DBREF_COUNT(X)
#define INC_DBREF_COUNT(X)
#define DEC_DBREF_COUNT(X)
#define DBREF_IN_USE(X) ((X)->Flags & InUseMask)
#endif
typedef DBStruct *DBRef;
/* extern Functor FunctorDBRef; */
inline EXTERN int IsDBRefTerm(Term);
inline EXTERN int IsDBRefTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorDBRef);
}
inline EXTERN Term MkDBRefTerm(DBRef);
inline EXTERN Term MkDBRefTerm(DBRef p)
{
return (Term) ((AbsAppl(((CELL *)(p)))));
}
inline EXTERN DBRef DBRefOfTerm(Term t);
inline EXTERN DBRef DBRefOfTerm(Term t)
{
return (DBRef) (((DBRef)(RepAppl(t))));
}
inline EXTERN int IsRefTerm(Term);
inline EXTERN int IsRefTerm(Term t)
{
return (int) (IsApplTerm(t) && FunctorOfTerm(t) == FunctorDBRef);
}
inline EXTERN CODEADDR RefOfTerm(Term t);
inline EXTERN CODEADDR RefOfTerm(Term t)
{
return (CODEADDR) (DBRefOfTerm(t));
}
typedef struct struct_dbentry {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfDB; /* kind of property */
Functor FunctorOfDB; /* functor for this property */
#if defined(YAPOR) || defined(THREADS)
rwlock_t DBRWLock; /* a simple lock to protect this entry */
#endif
DBRef First; /* first DBase entry */
DBRef Last; /* last DBase entry */
SMALLUNSGN ModuleOfDB; /* module for this definition */
#ifdef KEEP_ENTRY_AGE
Int age; /* age counter */
#else
DBRef FirstNEr; /* first non-erased DBase entry */
#endif /* KEEP_ENTRY_AGE */
} DBEntry;
typedef DBEntry *DBProp;
#define DBProperty ((PropFlags)0x8000)
typedef struct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
unsigned int ArityOfDB; /* kind of property */
Functor FunctorOfDB; /* functor for this property */
#if defined(YAPOR) || defined(THREADS)
rwlock_t DBRWLock; /* a simple lock to protect this entry */
#endif
DBRef First; /* first DBase entry */
DBRef Last; /* last DBase entry */
SMALLUNSGN ModuleOfDB; /* module for this definition */
Int NOfEntries; /* age counter */
DBRef Index; /* age counter */
} LogUpdDBEntry;
typedef LogUpdDBEntry *LogUpdDBProp;
#define LogUpdDBBit 0x1
#define CodeDBBit 0x2
#define LogUpdDBProperty ((PropFlags)(0x8000|LogUpdDBBit))
#define CodeLogUpdDBProperty (DBProperty|LogUpdDBBit|CodeDBBit)
#define CodeDBProperty (DBProperty|CodeDBBit)
inline EXTERN PropFlags IsDBProperty(int);
inline EXTERN PropFlags IsDBProperty(int flags)
{
return (PropFlags) (((flags & ~(LogUpdDBBit|CodeDBBit)) == DBProperty) );
}
#if USE_OFFSETS_IN_PROPS
inline EXTERN DBProp RepDBProp(Prop p);
inline EXTERN DBProp RepDBProp(Prop p)
{
return (DBProp) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsDBProp(DBProp p);
inline EXTERN Prop AbsDBProp(DBProp p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN DBProp RepDBProp(Prop p);
inline EXTERN DBProp RepDBProp(Prop p)
{
return (DBProp) (p);
}
inline EXTERN Prop AbsDBProp(DBProp p);
inline EXTERN Prop AbsDBProp(DBProp p)
{
return (Prop) (p);
}
#endif
/* These are the actual flags for DataBase terms */
typedef enum {
DBAtomic = 0x1,
DBVar = 0x2,
DBNoVars = 0x4,
DBComplex = 0x8,
DBCode = 0x10,
DBNoCode = 0x20,
DBWithRefs = 0x40
} db_term_flags;
#define MaxModules 256
typedef struct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
Atom KeyOfBB; /* functor for this property */
DBRef Element; /* blackboard element */
#if defined(YAPOR) || defined(THREADS)
rwlock_t BBRWLock; /* a read-write lock to protect the entry */
#endif
SMALLUNSGN ModuleOfBB; /* module for this definition */
} BlackBoardEntry;
typedef BlackBoardEntry *BBProp;
#if USE_OFFSETS_IN_PROPS
inline EXTERN BlackBoardEntry * RepBBProp(Prop p);
inline EXTERN BlackBoardEntry * RepBBProp(Prop p)
{
return (BlackBoardEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsBBProp(BlackBoardEntry * p);
inline EXTERN Prop AbsBBProp(BlackBoardEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN BlackBoardEntry * RepBBProp(Prop p);
inline EXTERN BlackBoardEntry * RepBBProp(Prop p)
{
return (BlackBoardEntry *) (p);
}
inline EXTERN Prop AbsBBProp(BlackBoardEntry * p);
inline EXTERN Prop AbsBBProp(BlackBoardEntry * p)
{
return (Prop) (p);
}
#endif
#define BBProperty ((PropFlags)0xfffb)
inline EXTERN PropFlags IsBBProperty(int);
inline EXTERN PropFlags IsBBProperty(int flags)
{
return (PropFlags) ((flags == BBProperty));
}
/* array property entry structure */
/* first case is for dynamic arrays */
typedef struct array_entry {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
Int ArrayEArity; /* Arity of Array (positive) */
#if defined(YAPOR) || defined(THREADS)
rwlock_t ArRWLock; /* a read-write lock to protect the entry */
#endif
struct array_entry *NextArrayE; /* Pointer to the actual array */
Term ValueOfVE; /* Pointer to the actual array */
} ArrayEntry;
/* second case is for static arrays */
/* first, the valid types */
typedef enum {
array_of_ints,
array_of_chars,
array_of_uchars,
array_of_doubles,
array_of_ptrs,
array_of_atoms,
array_of_dbrefs,
array_of_terms
} static_array_types;
typedef union {
Int *ints;
char *chars;
unsigned char *uchars;
Float *floats;
AtomEntry **ptrs;
Term *atoms;
Term *dbrefs;
DBRef *terms;
} statarray_elements;
/* next, the actual data structure */
typedef struct {
Prop NextOfPE; /* used to chain properties */
PropFlags KindOfPE; /* kind of property */
Int ArrayEArity; /* Arity of Array (negative) */
#if defined(YAPOR) || defined(THREADS)
rwlock_t ArRWLock; /* a read-write lock to protect the entry */
#endif
static_array_types ArrayType; /* Type of Array Elements. */
statarray_elements ValueOfVE; /* Pointer to the Array itself */
} StaticArrayEntry;
#if USE_OFFSETS_IN_PROPS
inline EXTERN ArrayEntry * RepArrayProp(Prop p);
inline EXTERN ArrayEntry * RepArrayProp(Prop p)
{
return (ArrayEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsArrayProp(ArrayEntry * p);
inline EXTERN Prop AbsArrayProp(ArrayEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
inline EXTERN StaticArrayEntry * RepStaticArrayProp(Prop p);
inline EXTERN StaticArrayEntry * RepStaticArrayProp(Prop p)
{
return (StaticArrayEntry *) (AtomBase + Unsigned(p));
}
inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry * p);
inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry * p)
{
return (Prop) (Addr(p)-AtomBase);
}
#else
inline EXTERN ArrayEntry * RepArrayProp(Prop p);
inline EXTERN ArrayEntry * RepArrayProp(Prop p)
{
return (ArrayEntry *) (p);
}
inline EXTERN Prop AbsArrayProp(ArrayEntry * p);
inline EXTERN Prop AbsArrayProp(ArrayEntry * p)
{
return (Prop) (p);
}
inline EXTERN StaticArrayEntry * RepStaticArrayProp(Prop p);
inline EXTERN StaticArrayEntry * RepStaticArrayProp(Prop p)
{
return (StaticArrayEntry *) (p);
}
inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry * p);
inline EXTERN Prop AbsStaticArrayProp(StaticArrayEntry * p)
{
return (Prop) (p);
}
#endif
#define ArrayProperty ((PropFlags)0xfff7)
inline EXTERN int ArrayIsDynamic(ArrayEntry *);
inline EXTERN int ArrayIsDynamic(ArrayEntry * are)
{
return (int) (((are)->ArrayEArity > 0 ));
}
inline EXTERN PropFlags IsArrayProperty(int);
inline EXTERN PropFlags IsArrayProperty(int flags)
{
return (PropFlags) ((flags == ArrayProperty) );
}
/* Proto types */
/* cdmgr.c */
int STD_PROTO(RemoveIndexation,(PredEntry *));
/* dbase.c */
void STD_PROTO(ErDBE,(DBRef));
DBRef STD_PROTO(StoreTermInDB,(int,int));
Term STD_PROTO(FetchTermFromDB,(DBRef,int));
void STD_PROTO(ReleaseTermFromDB,(DBRef));
/* .c */
CODEADDR STD_PROTO(PredIsIndexable,(PredEntry *));
/* init.c */
Atom STD_PROTO(GetOp,(OpEntry *,int *,int));
/* vsc: redefined to GetAProp to avoid conflicts with Windows header files */
Prop STD_PROTO(GetAProp,(Atom,PropFlags));
Prop STD_PROTO(GetAPropHavingLock,(AtomEntry *,PropFlags));
EXTERN inline Prop
PredPropByFunc(Functor f, SMALLUNSGN cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
FunctorEntry *fe = (FunctorEntry *)f;
WRITE_LOCK(fe->FRWLock);
p0 = fe->PropsOfFE;
while (p0) {
PredEntry *p = RepPredProp(p0);
if (/* p->KindOfPE != 0 || only props */
(p->ModuleOfPred == cur_mod || !(p->ModuleOfPred))) {
WRITE_UNLOCK(f->FRWLock);
return (p0);
}
p0 = p->NextOfPE;
}
return(NewPredPropByFunctor(fe,cur_mod));
}
EXTERN inline Prop
PredPropByAtom(Atom at, SMALLUNSGN cur_mod)
/* get predicate entry for ap/arity; create it if neccessary. */
{
Prop p0;
AtomEntry *ae = RepAtom(at);
WRITE_LOCK(ae->ARWLock);
p0 = ae->PropsOfAE;
while (p0) {
PredEntry *pe = RepPredProp(p0);
if ( pe->KindOfPE == PEProp &&
(pe->ModuleOfPred == cur_mod || !pe->ModuleOfPred)) {
WRITE_UNLOCK(ae->ARWLock);
return(p0);
}
p0 = pe->NextOfPE;
}
return(NewPredPropByAtom(ae,cur_mod));
}
#if defined(YAPOR) || defined(THREADS)
void STD_PROTO(ReleasePreAllocCodeSpace, (ADDR));
#else
#define ReleasePreAllocCodeSpace(x)
#endif
yap-6.2.2/pl/arith.yap 000644 000765 000024 00000026764 11572366532 014536 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: arith.yap *
* Last rev: *
* mods: *
* comments: arithmetical optimization *
* *
*************************************************************************/
% the default mode is on
expand_exprs(Old,New) :-
(get_value('$c_arith',true) ->
Old = on ;
Old = off ),
'$set_arith_expan'(New).
'$set_arith_expan'(on) :- set_value('$c_arith',true).
'$set_arith_expan'(off) :- set_value('$c_arith',[]).
compile_expressions :- set_value('$c_arith',true).
do_not_compile_expressions :- set_value('$c_arith',[]).
'$c_built_in'(IN, M, OUT) :-
get_value('$c_arith',true), !,
'$do_c_built_in'(IN, M, OUT).
'$c_built_in'(IN, _, IN).
'$do_c_built_in'(G, M, OUT) :- var(G), !,
'$do_c_built_in'(call(G), M, OUT).
'$do_c_built_in'(Mod:G, _, GN) :- !,
'$do_c_built_in'(G, Mod, GN0),
(GN0 = (_,_) -> GN = GN0 ; GN = Mod:GN0).
'$do_c_built_in'(\+ G, _, OUT) :-
nonvar(G),
G = (A = B),
!,
OUT = (A \= B).
'$do_c_built_in'(call(G), _, OUT) :-
nonvar(G),
G = (Mod:G1), !,
'$do_c_built_metacall'(G1, Mod, OUT).
'$do_c_built_in'(call(G), Mod, OUT) :-
var(G), !,
'$do_c_built_metacall'(G, Mod, OUT).
'$do_c_built_in'(depth_bound_call(G,D), M, OUT) :- !,
'$do_c_built_in'(G, M, NG),
% make sure we don't have something like (A,B) -> $depth_next(D), A, B.
( '$composed_built_in'(NG) ->
OUT = depth_bound_call(NG,D)
;
OUT = ('$set_depth_limit_for_next_call'(D),NG)
).
'$do_c_built_in'(once(G), M, (yap_hacks:current_choice_point(CP),NG,'$$cut_by'(CP))) :- !,
'$do_c_built_in'(G,M,NG0),
'$clean_cuts'(NG0, NG).
'$do_c_built_in'(forall(Cond,Action), M, \+((NCond, \+(NAction)))) :- !,
'$do_c_built_in'(Cond,M,ICond),
'$do_c_built_in'(Action,M,IAction),
'$clean_cuts'(ICond, NCond),
'$clean_cuts'(IAction, NAction).
'$do_c_built_in'(ignore(Goal), M, (NGoal -> true ; true)) :- !,
'$do_c_built_in'(Goal,M,IGoal),
'$clean_cuts'(IGoal, NGoal).
'$do_c_built_in'(if(G,A,B), M, (yap_hacks:current_choicepoint(DCP),NG,yap_hacks:cut_at(DCP),NA; NB)) :- !,
'$do_c_built_in'(G,M,NG0),
'$clean_cuts'(NG0, NG),
'$do_c_built_in'(A,M,NA),
'$do_c_built_in'(B,M,NB).
'$do_c_built_in'((G*->A), M, (NG,NA)) :- !,
'$do_c_built_in'(G,M,NG0),
'$clean_cuts'(NG0, NG),
'$do_c_built_in'(A,M,NA).
'$do_c_built_in'('C'(A,B,C), _, (A=[B|C])) :- !.
'$do_c_built_in'(X is Y, M, P) :-
primitive(X), !,
'$do_c_built_in'(X =:= Y, M, P).
'$do_c_built_in'(X is Y, M, (P,A=X)) :-
nonvar(X), !,
'$do_c_built_in'(A is Y, M, P).
'$do_c_built_in'(X is Y, _, P) :-
nonvar(Y), % Don't rewrite variables
!,
(
number(Y) ->
P = ( X = Y); % This case reduces to an unification
'$expand_expr'(Y, P0, X0),
'$drop_is'(X0, X, P0, P)
).
'$do_c_built_in'(Comp0, _, R) :- % now, do it for comparisons
'$compop'(Comp0, Op, E, F),
!,
'$compop'(Comp, Op, U, V),
'$expand_expr'(E, P, U),
'$expand_expr'(F, Q, V),
'$do_and'(P, Q, R0),
'$do_and'(R0, Comp, R).
'$do_c_built_in'(P, _, P).
'$do_c_built_metacall'(G1, Mod, '$execute_wo_mod'(G1,Mod)) :-
var(Mod), !.
'$do_c_built_metacall'(G1, Mod, '$execute_in_mod'(G1,Mod)) :-
var(G1), atom(Mod), !.
'$do_c_built_metacall'(Mod:G1, _, OUT) :- !,
'$do_c_built_metacall'(G1, Mod, OUT).
'$do_c_built_metacall'(G1, Mod, '$execute_in_mod'(G1,Mod)) :-
atom(Mod), !.
'$do_c_built_metacall'(G1, Mod, call(Mod:G1)).
'$do_and'(true, P, P) :- !.
'$do_and'(P, true, P) :- !.
'$do_and'(P, Q, (P,Q)).
% V is the result of the simplification,
% X the result of the initial expression
% and the last argument is how we are writing this result
'$drop_is'(V, V1, P0, G) :- var(V), !, % usual case
V = V1, P0 = G.
'$drop_is'(V, X, P0, P) :- % atoms
'$do_and'(P1, X is V, P).
% Table of arithmetic comparisons
'$compop'(X < Y, < , X, Y).
'$compop'(X > Y, > , X, Y).
'$compop'(X=< Y,=< , X, Y).
'$compop'(X >=Y, >=, X, Y).
'$compop'(X=:=Y,=:=, X, Y).
'$compop'(X=\=Y,=\=, X, Y).
'$composed_built_in'(V) :- var(V), !,
fail.
'$composed_built_in'((yap_hacks:current_choice_point(_),NG,'$$cut_by'(_))) :- !,
'$composed_built_in'(NG).
'$composed_built_in'((_,_)).
'$composed_built_in'((_;_)).
'$composed_built_in'((_|_)).
'$composed_built_in'((_->_)).
'$composed_built_in'(_:G) :-
'$composed_built_in'(G).
'$composed_built_in'(\+G) :-
'$composed_built_in'(G).
'$composed_built_in'(not(G)) :-
'$composed_built_in'(G).
% expanding an expression:
% first argument is the expression not expanded,
% second argument the expanded expression
% third argument unifies with the result from the expression
'$expand_expr'(V, true, V) :-
var(V), !.
'$expand_expr'([T], E, V) :- !,
'$expand_expr'(T, E, V).
'$expand_expr'(A, true, A) :-
atomic(A), !.
'$expand_expr'(T, E, V) :-
T =.. [O, A], !,
'$expand_expr'(A, Q, X),
'$expand_expr'(O, X, V, Q, E).
'$expand_expr'(T, E, V) :-
T =.. [O, A, B], !,
'$expand_expr'(A, Q, X),
'$expand_expr'(B, R, Y),
'$expand_expr'(O, X, Y, V, Q, S),
'$do_and'(R, S, E).
% expanding an expression of the form:
% O is Op(X),
% after having expanded into Q
% and giving as result P (the last argument)
'$expand_expr'(Op, X, O, Q, Q) :-
number(X), !,
is( O, Op, X).
'$expand_expr'(Op, X, O, Q, P) :-
'$unary_op_as_integer'(Op,IOp),
'$do_and'(Q, is( O, IOp, X), P).
% expanding an expression of the form:
% O is Op(X,Y),
% after having expanded into Q
% and giving as result P (the last argument)
% included is some optimization for:
% incrementing and decrementing,
% the elementar arithmetic operations [+,-,*,//]
'$expand_expr'(Op, X, Y, O, Q, Q) :-
number(X), number(Y), !,
is( O, Op, X, Y).
'$expand_expr'(+, X, Y, O, Q, P) :- !,
'$preprocess_args_for_commutative'(X, Y, X1, Y1, E),
'$do_and'(E, '$plus'(X1,Y1,O), F),
'$do_and'(Q, F, P).
'$expand_expr'(-, X, Y, O, Q, P) :-
var(X), number(Y),
Z is -Y, !,
'$expand_expr'(+, Z, X, O, Q, P).
'$expand_expr'(-, X, Y, O, Q, P) :- !,
'$preprocess_args_for_non_commutative'(X, Y, X1, Y1, E),
'$do_and'(E, '$minus'(X1,Y1,O), F),
'$do_and'(Q, F, P).
'$expand_expr'(*, X, Y, O, Q, P) :- !,
'$preprocess_args_for_commutative'(X, Y, X1, Y1, E),
'$do_and'(E, '$times'(X1,Y1,O), F),
'$do_and'(Q, F, P).
'$expand_expr'(//, X, Y, O, Q, P) :-
nonvar(Y), Y == 0, !,
'$binary_op_as_integer'(//,IOp),
'$do_and'(Q, is(O,IOp,X,Y), P).
'$expand_expr'(//, X, Y, O, Q, P) :- !,
'$preprocess_args_for_non_commutative'(X, Y, X1, Y1, E),
'$do_and'(E, '$div'(X1,Y1,O), F),
'$do_and'(Q, F, P).
'$expand_expr'(/\, X, Y, O, Q, P) :- !,
'$preprocess_args_for_commutative'(X, Y, X1, Y1, E),
'$do_and'(E, '$and'(X1,Y1,O), F),
'$do_and'(Q, F, P).
'$expand_expr'(\/, X, Y, O, Q, P) :- !,
'$preprocess_args_for_commutative'(X, Y, X1, Y1, E),
'$do_and'(E, '$or'(X1,Y1,O), F),
'$do_and'(Q, F, P).
'$expand_expr'(<<, X, Y, O, Q, P) :-
var(X), number(Y), Y < 0,
Z is -Y, !,
'$expand_expr'(>>, X, Z, O, Q, P).
'$expand_expr'(<<, X, Y, O, Q, P) :- !,
'$preprocess_args_for_non_commutative'(X, Y, X1, Y1, E),
'$do_and'(E, '$sll'(X1,Y1,O), F),
'$do_and'(Q, F, P).
'$expand_expr'(>>, X, Y, O, Q, P) :-
var(X), number(Y), Y < 0,
Z is -Y, !,
'$expand_expr'(<<, X, Z, O, Q, P).
'$expand_expr'(>>, X, Y, O, Q, P) :- !,
'$preprocess_args_for_non_commutative'(X, Y, X1, Y1, E),
'$do_and'(E, '$slr'(X1,Y1,O), F),
'$do_and'(Q, F, P).
'$expand_expr'(Op, X, Y, O, Q, P) :-
'$binary_op_as_integer'(Op,IOp),
'$do_and'(Q, is(O,IOp,X,Y), P).
'$preprocess_args_for_commutative'(X, Y, X, Y, true) :-
var(X), var(Y), !.
'$preprocess_args_for_commutative'(X, Y, X, Y, true) :-
var(X), integer(Y), \+ '$bignum'(Y), !.
'$preprocess_args_for_commutative'(X, Y, X, Z, Z = Y) :-
var(X), !.
'$preprocess_args_for_commutative'(X, Y, Y, X, true) :-
integer(X), \+ '$bignum'(X), var(Y), !.
'$preprocess_args_for_commutative'(X, Y, Z, X, Z = Y) :-
integer(X), \+ '$bignum'(X), !.
'$preprocess_args_for_commutative'(X, Y, Z, W, E) :-
'$do_and'(Z = X, Y = W, E).
'$preprocess_args_for_non_commutative'(X, Y, X, Y, true) :-
var(X), var(Y), !.
'$preprocess_args_for_non_commutative'(X, Y, X, Y, true) :-
var(X), integer(Y), \+ '$bignum'(Y), !.
'$preprocess_args_for_non_commutative'(X, Y, X, Z, Z = Y) :-
var(X), !.
'$preprocess_args_for_non_commutative'(X, Y, X, Y, true) :-
integer(X), \+ '$bignum'(X), var(Y), !.
'$preprocess_args_for_non_commutative'(X, Y, X, Z, Z = Y) :-
integer(X), \+ '$bignum'(X), !.
'$preprocess_args_for_non_commutative'(X, Y, Z, W, E) :-
'$do_and'(Z = X, Y = W, E).
/* Arithmetics */
between(I,M,J) :-
(
var(I)
->
'$do_error'(instantiation_error,between(I,M,J))
;
integer(I)
->
(
var(M)
->
'$do_error'(instantiation_error,between(I,M,J))
;
integer(M)
->
(
var(J)
->
I =< M, '$between'(I,M,J)
;
integer(J)
->
J >= I, J =< M
;
'$do_error'(type_error(integer, J),between(I,M,J))
)
;
M == inf ->
(
var(J)
->
'$between_inf'(I,J)
;
integer(J)
->
J >= I
;
'$do_error'(type_error(integer, J),between(I,M,J))
)
;
M == infinity ->
(
var(J)
->
'$between_inf'(I,J)
;
integer(J)
->
J >= I
;
'$do_error'(type_error(integer, J),between(I,M,J))
)
;
'$do_error'(type_error(integer, M),between(I,M,J))
)
;
'$do_error'(type_error(integer, I),between(I,M,J))
).
'$between'(I,M,I) :- (I == M -> ! ; true ).
'$between'(I0,I,J) :- I0 < I,
'$plus'(I0, 1, I1),
'$between'(I1,I,J).
'$between_inf'(I,I).
'$between_inf'(I,J) :-
'$plus'(I, 1, I1),
'$between_inf'(I1,J).
% M and N nonnegative integers, N is the successor of M
succ(M,N) :-
(
var(M)
->
(
integer(N),
N > 0
->
'$plus'(N,-1,M)
;
'$succ_error'(M,N)
)
;
integer(M),
M >= 0
->
(
var(N)
->
'$plus'(M,1,N)
;
integer(N),
N > 0
->
'$plus'(M,1,N)
;
'$succ_error'(M,N)
)
;
'$succ_error'(M,N)
).
'$succ_error'(M,N) :-
var(M),
var(N), !,
'$do_error'(instantiation_error,succ(M,N)).
'$succ_error'(M,N) :-
nonvar(M),
\+ integer(M),
'$do_error'(type_error(integer, M),succ(M,N)).
'$succ_error'(M,N) :-
nonvar(M),
M < 0,
'$do_error'(domain_error(not_less_than_zero, M),succ(M,N)).
'$succ_error'(M,N) :-
nonvar(N),
\+ integer(N),
'$do_error'(type_error(integer, N),succ(M,N)).
'$succ_error'(M,N) :-
nonvar(N),
N < 0,
'$do_error'(domain_error(not_less_than_zero, N),succ(M,N)).
plus(X, Y, Z) :-
(
var(X)
->
(
integer(Y), integer(Z)
->
'$minus'(Z,Y,X)
;
'$plus_error'(X,Y,Z)
)
;
integer(X)
->
(
var(Y)
->
(
integer(Z)
->
'$minus'(Z,X,Y)
;
'$plus_error'(X,Y,Z)
)
;
integer(Y)
->
(
integer(Z)
->
'$minus'(Z,Y,X)
;
var(Z)
->
'$plus'(X,Y,Z)
;
'$plus_error'(X,Y,Z)
)
;
'$plus_error'(X,Y,Z)
)
;
'$plus_error'(X,Y,Z)
).
'$plus_error'(X,Y,Z) :-
nonvar(X),
\+ integer(X),
'$do_error'(type_error(integer, X),plus(X,Y,Z)).
'$plus_error'(X,Y,Z) :-
nonvar(Y),
\+ integer(Y),
'$do_error'(type_error(integer, Y),plus(X,Y,Z)).
'$plus_error'(X,Y,Z) :-
nonvar(Z),
\+ integer(Z),
'$do_error'(type_error(integer, Z),plus(X,Y,Z)).
'$plus_error'(X,Y,Z) :-
'$do_error'(instantiation_error,plus(X,Y,Z)).
yap-6.2.2/pl/arrays.yap 000644 000765 000024 00000004152 11457004725 014706 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: arrays.yap *
* Last rev: *
* mods: *
* comments: Array Manipulation *
* *
*************************************************************************/
%
% These are the array built-in predicates. They will only work if
% YAP_ARRAYS is defined in Yap.h.m4.
%
array(Obj, Size) :-
'$create_array'(Obj, Size).
% arithmetical optimization
'$c_arrays'((P:-Q),(NP:-QF)) :- !,
'$c_arrays_body'(Q, QI),
'$c_arrays_head'(P, NP, QI, QF).
'$c_arrays'(P, NP) :-
'$c_arrays_fact'(P, NP).
'$c_arrays_body'(P, P) :-
var(P), !.
'$c_arrays_body'((P0,Q0), (P,Q)) :- !,
'$c_arrays_body'(P0, P),
'$c_arrays_body'(Q0, Q).
'$c_arrays_body'((P0;Q0), (P;Q)) :- !,
'$c_arrays_body'(P0, P),
'$c_arrays_body'(Q0, Q).
'$c_arrays_body'((P0->Q0), (P->Q)) :- !,
'$c_arrays_body'(P0, P),
'$c_arrays_body'(Q0, Q).
'$c_arrays_body'(P, NP) :- '$c_arrays_lit'(P, NP).
%
% replace references to arrays to references to built-ins.
%
'$c_arrays_lit'(G, GL) :-
'$array_references'(G, NG, VL),
'$add_array_entries'(VL, NG, GL).
'$c_arrays_head'(G, NG, B, NB) :-
'$array_references'(G, NG, VL),
'$add_array_entries'(VL, B, NB).
'$c_arrays_fact'(G, NG) :-
'$array_references'(G, IG, VL),
(VL = [] -> NG = G;
NG = (IG :- NB), '$add_array_entries'(VL, true, NB)).
'$add_array_entries'([], NG, NG).
'$add_array_entries'([Head|Tail], G, (Head, NG)) :-
'$add_array_entries'(Tail, G, NG).
static_array_properties(Name, Size, Type) :-
atom(Name), !,
'$static_array_properties'(Name, Size, Type).
static_array_properties(Name, Size, Type) :-
var(Name), !,
current_atom(Name),
'$static_array_properties'(Name, Size, Type).
static_array_properties(Name, Size, Type) :-
'$do_error'(type_error(atom,Name),static_array_properties(Name,Size,Type)).
yap-6.2.2/pl/attributes.yap 000644 000765 000024 00000020110 11457004725 015563 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: atts.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: attribute support for Prolog *
* *
*************************************************************************/
:- module('$attributes', [
delayed_goals/4
]).
:- dynamic attributes:attributed_module/3, attributes:modules_with_attributes/1.
prolog:get_attr(Var, Mod, Att) :-
functor(AttTerm, Mod, 2),
arg(2, AttTerm, Att),
attributes:get_module_atts(Var, AttTerm).
prolog:put_attr(Var, Mod, Att) :-
functor(AttTerm, Mod, 2),
arg(2, AttTerm, Att),
attributes:put_module_atts(Var, AttTerm).
prolog:del_attr(Var, Mod) :-
functor(AttTerm, Mod, 2),
attributes:del_all_module_atts(Var, AttTerm).
prolog:del_attrs(Var) :-
attributes:del_all_atts(Var).
prolog:get_attrs(AttVar, SWIAtts) :-
attributes:get_all_swi_atts(AttVar,SWIAtts).
prolog:put_attrs(_, []).
prolog:put_attrs(V, Atts) :-
cvt_to_swi_atts(Atts, YapAtts),
attributes:put_att_term(V, YapAtts).
cvt_to_swi_atts([], _).
cvt_to_swi_atts(att(Mod,Attribute,Atts), ModAttribute) :-
ModAttribute =.. [Mod, YapAtts, Attribute],
cvt_to_swi_atts(Atts, YapAtts).
%
% wake_up_goal is called by the system whenever a suspended goal
% resumes.
%
/* The first case may happen if this variable was used for dif.
In this case, we need a way to keep the original
suspended goal around
*/
%'$wake_up_goal'([Module1|Continuation],G) :-
% '$write'(4,vsc_woke:G+[Module1|Continuation]:'
%'), fail.
prolog:'$wake_up_goal'([Module1|Continuation], LG) :-
execute_woken_system_goals(LG),
do_continuation(Continuation, Module1).
%
% in the first two cases restore register immediately and proceed
% to continuation. In the last case take care with modules, but do
% not act as if a meta-call.
%
%
do_continuation('$cut_by'(X), _) :- !,
'$$cut_by'(X).
do_continuation('$restore_regs'(X), _) :- !,
'$restore_regs'(X).
do_continuation('$restore_regs'(X,Y), _) :- !,
'$restore_regs'(X,Y).
do_continuation(Continuation, Module1) :-
execute_continuation(Continuation,Module1).
execute_continuation(Continuation, Module1) :-
'$undefined'(Continuation, Module1), !,
'$undefp'([Module1|Continuation]).
execute_continuation(Continuation, Mod) :-
% do not do meta-expansion nor any fancy stuff.
'$execute0'(Continuation, Mod).
execute_woken_system_goals([]).
execute_woken_system_goals(['$att_do'(V,New)|LG]) :-
execute_woken_system_goals(LG),
call_atts(V,New).
%
% what to do when an attribute gets bound
%
call_atts(V,_) :-
nonvar(V), !.
call_atts(V,_) :-
'$att_bound'(V), !.
call_atts(V,New) :-
attributes:get_all_swi_atts(V,SWIAtts),
(
'$undefined'(woken_att_do(V, New, LGoals, DoNotBind), attributes)
->
LGoals = [],
DoNotBind = false
;
attributes:woken_att_do(V, New, LGoals, DoNotBind)
),
( DoNotBind == true
->
attributes:unbind_attvar(V)
;
attributes:bind_attvar(V)
),
do_hook_attributes(SWIAtts, New),
lcall(LGoals).
do_hook_attributes([], _).
do_hook_attributes(att(Mod,Att,Atts), Binding) :-
('$undefined'(attr_unify_hook(Att,Binding), Mod)
->
true
;
Mod:attr_unify_hook(Att, Binding)
),
do_hook_attributes(Atts, Binding).
lcall([]).
lcall([Mod:Gls|Goals]) :-
lcall2(Gls,Mod),
lcall(Goals).
lcall2([], _).
lcall2([Goal|Goals], Mod) :-
call(Mod:Goal),
lcall2(Goals, Mod).
prolog:call_residue_vars(Goal,Residue) :-
attributes:all_attvars(Vs0),
call(Goal),
attributes:all_attvars(Vs),
% this should not be actually strictly necessary right now.
% but it makes it a safe bet.
sort(Vs, Vss),
sort(Vs0, Vs0s),
'$ord_remove'(Vss, Vs0s, Residue).
'$ord_remove'([], _, []).
'$ord_remove'([V|Vs], [], [V|Vs]).
'$ord_remove'([V1|Vss], [V2|Vs0s], Residue) :-
( V1 == V2 ->
'$ord_remove'(Vss, Vs0s, Residue)
;
V1 @< V2 ->
Residue = [V1|ResidueF],
'$ord_remove'(Vss, [V2|Vs0s], ResidueF)
;
'$ord_remove'([V1|Vss], Vs0s, Residue)
).
%% from SWI
%% copy_term(+Term, -Copy, -Gs) is det.
%
% Creates a regular term Copy as a copy of Term (without any
% attributes), and a list Gs of goals that when executed reinstate
% all attributes onto Copy. The nonterminal attribute_goals//1, as
% defined in the modules the attributes stem from, is used to
% convert attributes to lists of goals.
prolog:copy_term(Term, Copy, Gs) :-
term_attvars(Term, Vs),
( Vs == []
-> Gs = [],
copy_term(Term, Copy)
; findall(Term-Gs,
( attvars_residuals(Vs, Gs, []),
delete_attributes(Term)
),
[Copy-Gs])
).
attvars_residuals([]) --> [].
attvars_residuals([V|Vs]) -->
( { get_attrs(V, As) }
-> attvar_residuals(As, V)
; []
),
attvars_residuals(Vs).
attvar_residuals([], _) --> [].
attvar_residuals(att(Module,Value,As), V) -->
( { nonvar(V) }
-> % a previous projection predicate could have instantiated
% this variable, for example, to avoid redundant goals
[]
; { attributes:attributed_module(Module, _, _) } ->
% SICStus like run, put attributes back first
{ Value =.. [Name,_|Vs],
NValue =.. [Name,_|Vs],
attributes:put_module_atts(V,NValue)
},
attvar_residuals(As, V),
( { '$undefined'(attribute_goal(V, Goal), Module) }
->
[]
;
{ '$notrace'(Module:attribute_goal(V, Goal)) },
dot_list(Goal)
)
; ( { current_predicate(Module:attribute_goals/3) }
-> { '$notrace'(Module:attribute_goals(V, Goals, [])) },
list(Goals)
; { current_predicate(Module:attribute_goal/2) }
-> { '$notrace'(Module:attribute_goal(V, Goal)) },
dot_list(Goal)
; [put_attr(V, Module, Value)]
),
attvar_residuals(As, V)
).
list([]) --> [].
list([L|Ls]) --> [L], list(Ls).
dot_list((A,B)) --> !, dot_list(A), dot_list(B).
dot_list(A) --> [A].
delete_attributes(Term) :-
term_attvars(Term, Vs),
delete_attributes_(Vs).
delete_attributes_([]).
delete_attributes_([V|Vs]) :-
del_attrs(V),
delete_attributes_(Vs).
prolog:call_residue(Goal,Residue) :-
var(Goal), !,
'$do_error'(instantiation_error,call_residue(Goal,Residue)).
prolog:call_residue(Module:Goal,Residue) :-
atom(Module), !,
call_residue(Goal,Module,Residue).
prolog:call_residue(Goal,Residue) :-
'$current_module'(Module),
call_residue(Goal,Module,Residue).
call_residue(Goal,Module,Residue) :-
prolog:call_residue_vars(Module:Goal,NewAttVars),
(
attributes:modules_with_attributes([_|_])
->
project_attributes(NewAttVars, Module:Goal)
;
true
),
copy_term(Goal, Goal, Residue).
delayed_goals(G, Vs, NVs, Gs) :-
project_delayed_goals(G),
copy_term(G.Vs, _.NVs, Gs).
project_delayed_goals(G) :-
% SICStus compatible step,
% just try to simplify store by projecting constraints
% over query variables.
% called by top_level to find out about delayed goals
attributes:modules_with_attributes([_|_]), !,
attributes:all_attvars(LAV),
LAV = [_|_],
project_attributes(LAV, G), !.
project_delayed_goals(_).
attributed(G, Vs) :-
term_variables(G, LAV),
att_vars(LAV, Vs).
att_vars([], []).
att_vars([V|LGs], [V|AttVars]) :- attvar(V), !,
att_vars(LGs, AttVars).
att_vars([_|LGs], AttVars) :-
att_vars(LGs, AttVars).
% make sure we set the suspended goal list to its previous state!
% make sure we have installed a SICStus like constraint solver.
project_attributes(AllVs, G) :-
attributes:modules_with_attributes(LMods),
LMods = [_|_],
term_variables(G, InputVs),
pick_att_vars(InputVs, AttIVs),
project_module(LMods, AttIVs, AllVs).
pick_att_vars([],[]).
pick_att_vars([V|L],[V|NL]) :- attvar(V), !,
pick_att_vars(L,NL).
pick_att_vars([_|L],NL) :-
pick_att_vars(L,NL).
project_module([], _, _).
project_module([Mod|LMods], LIV, LAV) :-
'$pred_exists'(project_attributes(LIV, LAV),Mod),
'$notrace'(Mod:project_attributes(LIV, LAV)), !,
attributes:all_attvars(NLAV),
project_module(LMods,LIV,NLAV).
project_module([_|LMods], LIV, LAV) :-
project_module(LMods,LIV,LAV).
yap-6.2.2/pl/boot.yap 000755 000765 000024 00000102553 11535253312 014352 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: boot.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: boot file for Prolog *
* *
*************************************************************************/
% This one should come first so that disjunctions and long distance
% cuts are compiled right with co-routining.
%
true :- true.
'$live' :-
'$init_system',
'$do_live'.
'$do_live' :-
repeat,
'$current_module'(Module),
( Module==user ->
'$compile_mode'(_,0)
;
format(user_error,'[~w]~n', [Module])
),
'$system_catch'('$enter_top_level',Module,Error,user:'$Error'(Error)).
'$init_system' :-
'$change_alias_to_stream'('$loop_stream','$stream'(0)),
% do catch as early as possible
(
'$access_yap_flags'(15, 0),
'$access_yap_flags'(22, 0),
\+ '$uncaught_throw'
->
'$version'
;
true
),
(
'$access_yap_flags'(22, 0) ->
set_value('$verbose',on)
;
set_value('$verbose',off)
),
(
retractall(user:library_directory(_)),
'$system_library_directories'(D),
assertz(user:library_directory(D)),
fail
;
true
),
'$stream_representation_error'(user_input, 512),
'$stream_representation_error'(user_output, 512),
'$stream_representation_error'(user_error, 512),
'$enter_system_mode',
'$init_globals',
set_value(fileerrors,1),
set_value('$gc',on),
('$exit_undefp' -> true ; true),
prompt(' ?- '),
'$debug_on'(false),
% simple trick to find out if this is we are booting from Prolog.
get_value('$user_module',V),
(
V == []
->
'$current_module'(_,prolog)
;
'$current_module'(_,V), '$compile_mode'(_,0),
('$access_yap_flags'(16,0) ->
( exists('~/.yaprc') -> load_files('~/.yaprc', []) ; true ),
( exists('~/.prologrc') -> load_files('~/.prologrc', []) ; true ),
( exists('~/prolog.ini') -> load_files('~/prolog.ini', []) ; true )
;
true
)
),
'$db_clean_queues'(0),
% this must be executed from C-code.
% '$startup_saved_state',
'$startup_reconsult',
'$startup_goals',
'$set_input'(user_input),'$set_output'(user),
'$init_or_threads',
'$run_at_thread_start'.
'$init_globals' :-
'$init_consult',
nb_setval('$chr_toplevel_show_store',false),
nb_setval('$break',0),
% '$set_read_error_handler'(error), let the user do that
nb_setval('$open_expands_filename',true),
nb_setval('$trace',off),
nb_setval('$system_mode',off),
nb_setval('$chr_toplevel_show_store',false),
nb_setval('$assert_all',off),
nb_setval('$if_skip_mode',no_skip),
b_setval('$spy_glist',[]),
nb_setval('$spy_gn',1),
nb_setval('$debug_run',off),
nb_setval('$debug_jump',off).
'$init_consult' :-
set_value('$lf_verbose',informational),
nb_setval('$if_level',0),
nb_setval('$endif',off),
nb_setval('$consulting_file',[]),
nb_setval('$initialization_goals',off),
nb_setval('$consulting',false),
nb_setval('$included_file',[]).
'$init_or_threads' :-
'$c_yapor_threads'(W), !,
'$start_orp_threads'(W).
'$init_or_threads'.
'$start_orp_threads'(1) :- !.
'$start_orp_threads'(W) :-
thread_create('$c_worker',_,[detached(true)]),
W1 is W-1,
'$start_orp_threads'(W1).
% Start file for yap
/* I/O predicates */
/* meaning of flags for '$write' is
1 quote illegal atoms
2 ignore operator declarations
4 output '$VAR'(N) terms as A, B, C, ...
8 use portray(_)
*/
/* main execution loop */
'$read_vars'(Stream,T,Mod,Pos,V) :-
'$read'(true,T,Mod,V,Pos,Err,Stream),
(nonvar(Err) ->
print_message(error,Err), fail
;
true
).
% reset alarms when entering top-level.
'$enter_top_level' :-
'$alarm'(0, 0, _, _),
fail.
'$enter_top_level' :-
'$clean_up_dead_clauses',
fail.
'$enter_top_level' :-
'$nb_getval'('$break',BreakLevel,fail),
'$debug_on'(DBON),
(
'$nb_getval'('$trace', on, fail)
->
TraceDebug = trace
;
DBON == true
->
TraceDebug = debug
;
true
),
print_message(informational,prompt(BreakLevel,TraceDebug)),
fail.
'$enter_top_level' :-
get_value('$top_level_goal',GA), GA \= [], !,
set_value('$top_level_goal',[]),
'$run_atom_goal'(GA),
set_value('$live','$false').
'$enter_top_level' :-
'$disable_docreep',
prompt(_,' ?- '),
prompt(' | '),
'$run_toplevel_hooks',
'$read_vars'(user_input,Command,_,Pos,Varnames),
nb_setval('$spy_gn',1),
% stop at spy-points if debugging is on.
nb_setval('$debug_run',off),
nb_setval('$debug_jump',off),
prompt(_,' |: '),
'$command'(Command,Varnames,Pos,top),
'$sync_mmapped_arrays',
set_value('$live','$false').
%
% first, recover what we need from the saved state...
%
'$startup_saved_state' :-
% -p option must be processed after initializing the system
'$init_path_extensions',
fail.
% use if we come from a save_program and we have SWI's shlib
'$startup_saved_state' :-
recorded('$reload_foreign_libraries',G,R),
erase(R),
shlib:reload_foreign_libraries,
fail.
% use if we come from a save_program and we have a goal to execute
'$startup_saved_state' :-
recorded('$restore_goal',G,R),
erase(R),
prompt(_,' | '),
'$system_catch'('$do_yes_no'((G->true),user),user,Error,user:'$Error'(Error)),
fail.
'$startup_saved_state'.
% then recover program.
'$startup_reconsult' :-
get_value('$consult_on_boot',X), X \= [], !,
set_value('$consult_on_boot',[]),
'$do_startup_reconsult'(X).
'$startup_reconsult'.
% then we can execute the programs.
'$startup_goals' :-
recorded('$startup_goal',G,_),
'$current_module'(Module),
'$system_catch'('$query'(once(G), []),Module,Error,user:'$Error'(Error)),
fail.
'$startup_goals' :-
get_value('$init_goal',GA),
GA \= [],
set_value('$init_goal',[]),
'$run_atom_goal'(GA),
fail.
'$startup_goals' :-
get_value('$myddas_goal',GA), GA \= [],
set_value('$myddas_goal',[]),
get_value('$myddas_user',User), User \= [],
set_value('$myddas_user',[]),
get_value('$myddas_db',Db), Db \= [],
set_value('$myddas_db',[]),
get_value('$myddas_host',HostT),
( HostT \= [] ->
Host = HostT,
set_value('$myddas_host',[])
;
Host = localhost
),
get_value('$myddas_pass',PassT),
( PassT \= [] ->
Pass = PassT,
set_value('$myddas_pass',[])
;
Pass = ''
),
use_module(library(myddas)),
call(db_open(mysql,myddas,Host/Db,User,Pass)),
'$myddas_import_all',
fail.
'$startup_goals'.
%
% MYDDAS: Import all the tables from one database
%
'$myddas_import_all':-
call(db_my_show_tables(myddas,table(Table))),
call(db_import(myddas,Table,Table)),
fail.
'$myddas_import_all'.
'$erase_sets' :-
eraseall('$'),
eraseall('$$set'),
eraseall('$$one'),
eraseall('$reconsulted'), fail.
'$erase_sets' :- \+ recorded('$path',_,_), recorda('$path',"",_).
'$erase_sets'.
'$version' :-
get_value('$version_name',VersionName),
print_message(help, version(VersionName)),
get_value('$myddas_version_name',MYDDASVersionName),
MYDDASVersionName \== [],
print_message(help, myddas_version(MYDDASVersionName)),
fail.
'$version' :-
recorded('$version',VersionName,_),
print_message(help, VersionName),
fail.
'$version'.
repeat :- '$repeat'.
'$repeat'.
'$repeat'.
'$repeat'.
'$repeat'.
'$repeat'.
'$repeat'.
'$repeat'.
'$repeat'.
'$repeat'.
'$repeat' :- '$repeat'.
'$start_corouts' :-
recorded('$corout','$corout'(Name,_,_),R),
Name \= main,
finish_corout(R),
fail.
'$start_corouts' :-
eraseall('$corout'),
eraseall('$result'),
eraseall('$actual'),
fail.
'$start_corouts' :- recorda('$actual',main,_),
recordz('$corout','$corout'(main,main,'$corout'([],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[])),_Ref),
recorda('$result',going,_).
'$command'(C,VL,Pos,Con) :-
'$access_yap_flags'(9,1), !,
'$execute_command'(C,VL,Pos,Con,C).
'$command'(C,VL,Pos,Con) :-
( (Con = top ; var(C) ; C = [_|_]) ->
'$execute_command'(C,VL,Pos,Con,C), ! ;
% do term expansion
expand_term(C, EC),
% execute a list of commands
'$execute_commands'(EC,VL,Pos,Con,C),
% succeed only if the *original* was at end of file.
C == end_of_file
).
%
% Hack in case expand_term has created a list of commands.
%
'$execute_commands'(V,_,_,_,Source) :- var(V), !,
'$do_error'(instantiation_error,meta_call(Source)).
'$execute_commands'([],_,_,_,_) :- !.
'$execute_commands'([C|Cs],VL,Pos,Con,Source) :- !,
(
'$execute_command'(C,VL,Pos,Con,Source),
fail
;
'$execute_commands'(Cs,VL,Pos,Con,Source)
).
'$execute_commands'(C,VL,Pos,Con,Source) :-
'$execute_command'(C,VL,Pos,Con,Source).
%
%
%
'$execute_command'(C,_,_,top,Source) :- var(C), !,
'$do_error'(instantiation_error,meta_call(Source)).
'$execute_command'(C,_,_,top,Source) :- number(C), !,
'$do_error'(type_error(callable,C),meta_call(Source)).
'$execute_command'(R,_,_,top,Source) :- db_reference(R), !,
'$do_error'(type_error(callable,R),meta_call(Source)).
'$execute_command'(end_of_file,_,_,_,_) :- !.
'$execute_command'(Command,_,_,_,_) :-
'$nb_getval'('$if_skip_mode', skip, fail),
\+ '$if_directive'(Command),
!.
'$execute_command'((:-G),_,_,Option,_) :-
% !,
Option \= top, !,
'$current_module'(M),
% allow user expansion
expand_term((:- G), O),
O = (:- G1),
'$process_directive'(G1, Option, M).
'$execute_command'((?-G), V, Pos, Option, Source) :-
Option \= top, !,
'$execute_command'(G, V, Pos, top, Source).
'$execute_command'(G, V, Pos, Option, Source) :-
'$continue_with_command'(Option, V, Pos, G, Source).
%
% This command is very different depending on the language mode we are in.
%
% ISO only wants directives in files
% SICStus accepts everything in files
% YAP accepts everything everywhere
%
'$process_directive'(G, top, M) :-
'$access_yap_flags'(8, 0), !, % YAP mode, go in and do it,
'$process_directive'(G, consult, M).
'$process_directive'(G, top, _) :- !,
'$do_error'(context_error((:- G),clause),query).
%
% allow modules
%
'$process_directive'(M:G, Mode, _) :- !,
'$process_directive'(G, Mode, M).
%
% default case
%
'$process_directive'(Gs, Mode, M) :-
'$all_directives'(Gs), !,
'$exec_directives'(Gs, Mode, M).
%
% ISO does not allow goals (use initialization).
%
'$process_directive'(D, _, M) :-
'$access_yap_flags'(8, 1), !, % ISO Prolog mode, go in and do it,
'$do_error'(context_error((:- M:D),query),directive).
%
% but YAP and SICStus does.
%
'$process_directive'(G, _, M) :-
'$exit_system_mode',
( '$notrace'(M:G) -> true ; format(user_error,':- ~w:~w failed.~n',[M,G]) ),
'$enter_system_mode'.
'$continue_with_command'(Where,V,'$stream_position'(C,_P,A1,A2,A3),'$source_location'(_F,L):G,Source) :- !,
'$continue_with_command'(Where,V,'$stream_position'(C,L,A1,A2,A3),G,Source).
'$continue_with_command'(reconsult,V,Pos,G,Source) :-
'$go_compile_clause'(G,V,Pos,5,Source),
fail.
'$continue_with_command'(consult,V,Pos,G,Source) :-
'$go_compile_clause'(G,V,Pos,13,Source),
fail.
'$continue_with_command'(top,V,_,G,_) :-
'$query'(G,V).
%
% not 100% compatible with SICStus Prolog, as SICStus Prolog would put
% module prefixes all over the place, although unnecessarily so.
%
'$go_compile_clause'(G,V,Pos,N,Source) :-
'$current_module'(Mod),
'$go_compile_clause'(G,V,Pos,N,Mod,Mod,Source).
'$go_compile_clause'(G,_,_,_,_,_,Source) :-
var(G), !,
'$do_error'(instantiation_error,assert(Source)).
'$go_compile_clause'((G:-_),_,_,_,_,_,Source) :-
var(G), !,
'$do_error'(instantiation_error,assert(Source)).
'$go_compile_clause'(M:G,V,Pos,N,_,_,Source) :- !,
'$go_compile_clause'(G,V,Pos,N,M,M,Source).
'$go_compile_clause'((M:H :- B),V,Pos,N,_,BodyMod,Source) :- !,
'$go_compile_clause'((H :- B),V,Pos,N,M,BodyMod,Source).
'$go_compile_clause'(G,V,Pos,N,HeadMod,BodyMod,Source) :- !,
'$prepare_term'(G, V, Pos, G0, G1, BodyMod, HeadMod, Source),
'$$compile'(G1, G0, N, HeadMod).
'$prepare_term'(G, V, Pos, G0, G1, BodyMod, SourceMod, Source) :-
(
get_value('$syntaxcheckflag',on)
->
'$check_term'(Source, V, Pos, BodyMod)
;
true
),
'$precompile_term'(G, G0, G1, BodyMod, SourceMod).
% process an input clause
'$$compile'(G, G0, L, Mod) :-
'$head_and_body'(G,H,_),
'$flags'(H, Mod, Fl, Fl),
is(NFl, /\, Fl, 0x00002000),
(
NFl \= 0
->
'$assertz_dynamic'(L,G,G0,Mod)
;
nb_getval('$assert_all',on)
->
functor(H,N,A),
'$dynamic'(N/A,Mod),
'$assertz_dynamic'(L,G,G0,Mod)
;
'$not_imported'(H, Mod),
'$compile'(G, L, G0, Mod)
).
'$not_imported'(H, Mod) :-
recorded('$import','$import'(NM,Mod,NH,H,_,_),_),
NM \= Mod, !,
functor(NH,N,Ar),
'$do_error'(permission_error(modify, static_procedure, NM:N/Ar), consult).
'$not_imported'(_, _).
'$check_if_reconsulted'(N,A) :-
once(recorded('$reconsulted',N/A,_)),
recorded('$reconsulted',X,_),
( X = N/A , !;
X = '$', !, fail;
fail
).
'$inform_as_reconsulted'(N,A) :-
recorda('$reconsulted',N/A,_).
'$clear_reconsulting' :-
recorded('$reconsulted',X,Ref),
erase(Ref),
X == '$', !,
( recorded('$reconsulting',_,R) -> erase(R) ).
'$prompt_alternatives_on'(determinism).
/* Executing a query */
'$query'(end_of_file,_).
% ***************************
% * -------- YAPOR -------- *
% ***************************
'$query'(G,V) :-
\+ '$undefined'('$c_yapor_on', prolog),
'$c_yapor_on',
\+ '$undefined'('$c_start_yapor', prolog),
'$parallelizable'(G), !,
'$parallel_query'(G,V),
fail.
% end of YAPOR
'$query'(G,[]) :-
'$prompt_alternatives_on'(OPT),
( OPT = groundness ; OPT = determinism), !,
'$yes_no'(G,(?-)).
'$query'(G,V) :-
(
'$exit_system_mode',
yap_hacks:current_choice_point(CP),
'$execute'(G),
yap_hacks:current_choice_point(NCP),
( '$enter_system_mode' ; '$exit_system_mode', fail),
'$delayed_goals'(G, V, NV, LGs),
'$write_answer'(NV, LGs, Written),
'$write_query_answer_true'(Written),
(
'$prompt_alternatives_on'(determinism), CP = NCP ->
nl(user_error),
!
;
'$another',
!
),
fail
;
'$enter_system_mode',
'$out_neg_answer'
).
'$yes_no'(G,C) :-
'$current_module'(M),
'$do_yes_no'(G,M),
'$delayed_goals'(G, [], NV, LGs),
'$write_answer'(NV, LGs, Written),
( Written = [] ->
!,'$present_answer'(C, yes);
'$another', !
),
fail.
'$yes_no'(_,_) :-
'$enter_system_mode',
'$out_neg_answer'.
'$add_env_and_fail' :- fail.
'$delayed_goals'(G, V, NV, LGs) :-
'$attributes':delayed_goals(G, V, NV, LGs), !.
'$delayed_goals'(_, V, NV, []) :-
copy_term_nat(V, NV).
'$out_neg_answer' :-
( '$undefined'(print_message(_,_),prolog) ->
'$present_answer'(user_error,"no~n", [])
;
print_message(help,no)
),
fail.
'$do_yes_no'([X|L], M) :- !, '$csult'([X|L], M).
'$do_yes_no'(G, M) :-
'$exit_system_mode',
'$execute'(M:G),
( '$enter_system_mode' ; '$exit_system_mode', fail).
'$write_query_answer_true'([]) :- !,
format(user_error,'~ntrue',[]).
'$write_query_answer_true'(_).
%
% present_answer has three components. First it flushes the streams,
% then it presents the goals, and last it shows any goals frozen on
% the arguments.
%
'$present_answer'(_,_):-
'$flush_all_streams',
fail.
'$present_answer'((?-), Answ) :-
nb_getval('$break',BL),
( BL \= 0 -> format(user_error, '[~p] ',[BL]) ;
true ),
( recorded('$print_options','$toplevel'(Opts),_) ->
write_term(user_error,Answ,Opts) ;
format(user_error,'~w',[Answ])
),
format(user_error,'~n', []).
'$another' :-
format(user_error,' ? ',[]),
get0(user_input,C),
'$do_another'(C).
'$do_another'(C) :-
( C== 0'; -> '$skip'(user_input,10), %'
'$add_nl_outside_console',
fail
;
C== 10 -> '$add_nl_outside_console',
( '$undefined'(print_message(_,_),prolog) ->
format(user_error,'yes~n', [])
;
print_message(help,yes)
)
;
C== 13 ->
get0(user_input,NC),
'$do_another'(NC)
;
C== -1 -> halt
;
'$skip'(user_input,10), '$ask_again_for_another'
).
'$add_nl_outside_console' :-
'$is_same_tty'(user_input, user_error), !.
'$add_nl_outside_console' :-
format(user_error,'~n',[]).
'$ask_again_for_another' :-
format(user_error,'Action (\";\" for more choices, for exit)', []),
'$another'.
'$write_answer'(_,_,_) :-
'$flush_all_streams',
fail.
'$write_answer'(Vs, LBlk, FLAnsw) :-
'$purge_dontcares'(Vs,IVs),
'$sort'(IVs, NVs),
'$prep_answer_var_by_var'(NVs, LAnsw, LBlk),
'$name_vars_in_goals'(LAnsw, Vs, NLAnsw),
'$write_vars_and_goals'(NLAnsw, first, FLAnsw).
'$purge_dontcares'([],[]).
'$purge_dontcares'([[[95|_]|_]|Vs],NVs) :- !,
'$purge_dontcares'(Vs,NVs).
'$purge_dontcares'([V|Vs],[V|NVs]) :-
'$purge_dontcares'(Vs,NVs).
'$prep_answer_var_by_var'([], L, L).
'$prep_answer_var_by_var'([[Name|Value]|L], LF, L0) :-
'$delete_identical_answers'(L, Value, NL, Names),
'$prep_answer_var'([Name|Names], Value, LF, LI),
'$prep_answer_var_by_var'(NL, LI, L0).
% fetch all cases that have the same solution.
'$delete_identical_answers'([], _, [], []).
'$delete_identical_answers'([[Name|Value]|L], Value0, FL, [Name|Names]) :-
Value == Value0, !,
'$delete_identical_answers'(L, Value0, FL, Names).
'$delete_identical_answers'([VV|L], Value0, [VV|FL], Names) :-
'$delete_identical_answers'(L, Value0, FL, Names).
% now create a list of pairs that will look like goals.
'$prep_answer_var'(Names, Value, LF, L0) :- var(Value), !,
'$prep_answer_unbound_var'(Names, LF, L0).
'$prep_answer_var'(Names, Value, [nonvar(Names,Value)|L0], L0).
% ignore unbound variables
'$prep_answer_unbound_var'([_], L, L) :- !.
'$prep_answer_unbound_var'(Names, [var(Names)|L0], L0).
'$gen_name_string'(I,L,[C|L]) :- I < 26, !, C is I+65.
'$gen_name_string'(I,L0,LF) :-
I1 is I mod 26,
I2 is I // 26,
C is I1+65,
'$gen_name_string'(I2,[C|L0],LF).
'$write_vars_and_goals'([], _, []).
'$write_vars_and_goals'([nl,G1|LG], First, NG) :- !,
nl(user_error),
'$write_goal_output'(G1, First, NG, Next, IG),
'$write_vars_and_goals'(LG, Next, IG).
'$write_vars_and_goals'([G1|LG], First, NG) :-
'$write_goal_output'(G1, First, NG, Next, IG),
'$write_vars_and_goals'(LG, Next, IG).
'$goal_to_string'(Format, G, String) :-
charsio:open_mem_write_stream(W),
format(W,Format,G),
charsio:peek_mem_write_stream(W, [], String),
close(W).
'$write_goal_output'(var([V|VL]), First, [var([V|VL])|L], next, L) :- !,
( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error,'~s',[V]),
'$write_output_vars'(VL).
'$write_goal_output'(nonvar([V|VL],B), First, [nonvar([V|VL],B)|L], next, L) :- !,
( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error,'~s',[V]),
'$write_output_vars'(VL),
format(user_error,' = ', []),
( recorded('$print_options','$toplevel'(Opts),_) ->
write_term(user_error,B,[priority(699)|Opts]) ;
write_term(user_error,B,[priority(699)])
).
'$write_goal_output'(nl, First, NG, First, NG) :- !,
format(user_error,'~n',[]).
'$write_goal_output'(Format-G, First, NG, Next, IG) :- !,
G = [_|_], !,
% dump on string first so that we can check whether we actually
% had any output from the solver.
'$goal_to_string'(Format, G, String),
( String == [] ->
% we didn't
IG = NG, First = Next
;
% we did
( First = first -> true ; format(user_error,',~n',[]) ),
format(user_error, '~s', [String]),
NG = [G|IG]
).
'$write_goal_output'(_-G, First, [G|NG], next, NG) :- !,
( First = first -> true ; format(user_error,',~n',[]) ),
( recorded('$print_options','$toplevel'(Opts),_) ->
write_term(user_error,G,Opts) ;
format(user_error,'~w',[G])
).
'$write_goal_output'(_M:G, First, [G|NG], next, NG) :- !,
( First = first -> true ; format(user_error,',~n',[]) ),
( recorded('$print_options','$toplevel'(Opts),_) ->
write_term(user_error,G,Opts) ;
format(user_error,'~w',[G])
).
'$write_goal_output'(G, First, [M:G|NG], next, NG) :-
'$current_module'(M),
( First = first -> true ; format(user_error,',~n',[]) ),
( recorded('$print_options','$toplevel'(Opts),_) ->
write_term(user_error,G,Opts) ;
format(user_error,'~w',[G])
).
'$name_vars_in_goals'(G, VL0, G) :-
'$name_well_known_vars'(VL0),
'$variables_in_term'(G, [], GVL),
'$name_vars_in_goals1'(GVL, 0, _).
'$name_well_known_vars'([]).
'$name_well_known_vars'([[Name|V]|NVL0]) :-
var(V), !,
V = '$VAR'(Name),
'$name_well_known_vars'(NVL0).
'$name_well_known_vars'([_|NVL0]) :-
'$name_well_known_vars'(NVL0).
'$name_vars_in_goals1'([], I, I).
'$name_vars_in_goals1'(['$VAR'([95|Name])|NGVL], I0, IF) :-
I is I0+1,
'$gen_name_string'(I0,[],Name), !,
'$name_vars_in_goals1'(NGVL, I, IF).
'$name_vars_in_goals1'([NV|NGVL], I0, IF) :-
nonvar(NV),
'$name_vars_in_goals1'(NGVL, I0, IF).
'$write_output_vars'([]).
'$write_output_vars'([V|VL]) :-
format(user_error,' = ~s',[V]),
'$write_output_vars'(VL).
call(G) :- '$execute'(G).
incore(G) :- '$execute'(G).
%
% standard meta-call, called if $execute could not do everything.
%
'$meta_call'(G, M) :-
yap_hacks:current_choice_point(CP),
'$call'(G, CP, G, M).
','(X,Y) :-
yap_hacks:env_choice_point(CP),
'$current_module'(M),
'$call'(X,CP,(X,Y),M),
'$call'(Y,CP,(X,Y),M).
';'((X->A),Y) :- !,
yap_hacks:env_choice_point(CP),
'$current_module'(M),
( '$execute'(X)
->
'$call'(A,CP,(X->A;Y),M)
;
'$call'(Y,CP,(X->A;Y),M)
).
';'((X*->A),Y) :- !,
yap_hacks:env_choice_point(CP),
'$current_module'(M),
(
yap_hacks:current_choicepoint(DCP),
'$execute'(X),
yap_hacks:cut_at(DCP),
'$call'(A,CP,((X*->A),Y),M)
;
'$call'(Y,CP,((X*->A),Y),M)
).
';'(X,Y) :-
yap_hacks:env_choice_point(CP),
'$current_module'(M),
( '$call'(X,CP,(X;Y),M) ; '$call'(Y,CP,(X;Y),M) ).
'|'(X,Y) :-
yap_hacks:env_choice_point(CP),
'$current_module'(M),
( '$call'(X,CP,(X|Y),M) ; '$call'(Y,CP,(X|Y),M) ).
'->'(X,Y) :-
yap_hacks:env_choice_point(CP),
'$current_module'(M),
( '$call'(X,CP,(X->Y),M) -> '$call'(Y,CP,(X->Y),M) ).
'*->'(X,Y) :-
yap_hacks:env_choice_point(CP),
'$current_module'(M),
( '$call'(X,CP,(X*->Y),M), '$call'(Y,CP,(X*->Y),M) ).
\+(G) :- \+ '$execute'(G).
not(G) :- \+ '$execute'(G).
'$cut_by'(CP) :- '$$cut_by'(CP).
%
% do it in ISO mode.
%
'$meta_call'(G,_ISO,M) :-
'$iso_check_goal'(G,G),
yap_hacks:current_choice_point(CP),
'$call'(G, CP, G, M).
'$meta_call'(G, CP, G0, M) :-
'$call'(G, CP, G0, M).
'$call'(G, CP, G0, _, M) :- /* iso version */
'$iso_check_goal'(G,G0),
'$call'(G, CP, G0, M).
'$call'(M:_,_,G0,_) :- var(M), !,
'$do_error'(instantiation_error,call(G0)).
'$call'(M:G,CP,G0,_) :- !,
'$call'(G,CP,G0,M).
'$call'((X,Y),CP,G0,M) :- !,
'$call'(X,CP,G0,M),
'$call'(Y,CP,G0,M).
'$call'((X->Y),CP,G0,M) :- !,
(
'$call'(X,CP,G0,M)
->
'$call'(Y,CP,G0,M)
).
'$call'((X*->Y),CP,G0,M) :- !,
'$call'(X,CP,G0,M),
'$call'(Y,CP,G0,M).
'$call'((X->Y; Z),CP,G0,M) :- !,
(
'$call'(X,CP,G0,M)
->
'$call'(Y,CP,G0,M)
;
'$call'(Z,CP,G0,M)
).
'$call'((X*->Y; Z),CP,G0,M) :- !,
(
yap_hacks:current_choicepoint(DCP),
'$call'(X,CP,G0,M),
yap_hacks:cut_at(DCP),
'$call'(Y,CP,G0,M)
;
'$call'(Z,CP,G0,M)
).
'$call'((A;B),CP,G0,M) :- !,
(
'$call'(A,CP,G0,M)
;
'$call'(B,CP,G0,M)
).
'$call'((X->Y| Z),CP,G0,M) :- !,
(
'$call'(X,CP,G0,M)
->
'$call'(Y,CP,G0,M)
;
'$call'(Z,CP,G0,M)
).
'$call'((X*->Y| Z),CP,G0,M) :- !,
(
yap_hacks:current_choicepoint(DCP),
'$call'(X,CP,G0,M),
yap_hacks:cut_at(DCP),
'$call'(Y,CP,G0,M)
;
'$call'(Z,CP,G0,M)
).
'$call'((A|B),CP, G0,M) :- !,
(
'$call'(A,CP,G0,M)
;
'$call'(B,CP,G0,M)
).
'$call'(\+ X, _CP, _G0, M) :- !,
yap_hacks:current_choicepoint(CP),
\+ '$call'(X,CP,G0,M).
'$call'(not(X), _CP, _G0, M) :- !,
\+ '$call'(X,CP,G0,M).
'$call'(!, CP, _,_) :- !,
'$$cut_by'(CP).
'$call'([A|B], _, _, M) :- !,
'$csult'([A|B], M).
'$call'(G, CP, G0, CurMod) :-
( '$is_expand_goal_or_meta_predicate'(G,CurMod) ->
(
'$notrace'(user:goal_expansion(G, CurMod, NG)) ->
'$call'(NG, CP, G0,CurMod)
;
% repeat other code.
'$is_metapredicate'(G,CurMod) ->
(
'$meta_expansion'(G,CurMod,CurMod,CurMod,NG,[]) ->
'$execute0'(NG, CurMod)
;
'$execute0'(G, CurMod)
)
;
'$execute0'(G, CurMod)
)
;
'$execute0'(G, CurMod)
).
'$check_callable'(V,G) :- var(V), !,
'$do_error'(instantiation_error,G).
'$check_callable'(M:_G1,G) :- var(M), !,
'$do_error'(instantiation_error,G).
'$check_callable'(_:G1,G) :- !,
'$check_callable'(G1,G).
'$check_callable'(A,G) :- number(A), !,
'$do_error'(type_error(callable,A),G).
'$check_callable'(R,G) :- db_reference(R), !,
'$do_error'(type_error(callable,R),G).
'$check_callable'(_,_).
% Called by the abstract machine, if no clauses exist for a predicate
'$undefp'([M|G]) :-
'$find_goal_definition'(M, G, NM, NG),
'$execute0'(NG, NM).
'$find_goal_definition'(M, G, NM, NG) :-
% make sure we do not loop on undefined predicates
% for undefined_predicates.
'$enter_undefp',
(
'$get_undefined_pred'(G, M, Goal, NM)
->
'$exit_undefp'
;
once('$find_undefp_handler'(G, M, Goal, NM))
),
!,
Goal \= fail,
'$complete_goal'(M, Goal, NM, G, NG).
'$complete_goal'(M, G, CurMod, G0, NG) :-
(
'$is_metapredicate'(G,CurMod)
->
'$meta_expansion'(G, CurMod, M, M, NG,[])
;
NG = G
).
'$find_undefp_handler'(G,M,NG,user) :-
functor(G, Na, Ar),
user:exception(undefined_predicate,M:Na/Ar,Action), !,
'$exit_undefp',
(
Action == fail
->
NG = fail
;
Action == retry
->
NG = G
;
Action = error
->
'$unknown_error'(M:G)
;
'$do_error'(type_error(atom, Action),M:G)
).
'$find_undefp_handler'(G,M,NG,user) :-
\+ '$undefined'(unknown_predicate_handler(_,_,_), user),
'$system_catch'(unknown_predicate_handler(G,M,NG), user, Error, '$leave_undefp'(Error)), !,
'$exit_undefp'.
'$find_undefp_handler'(G,M,US,user) :-
recorded('$unknown','$unknown'(M:G,US),_), !,
'$exit_undefp'.
'$find_undefp_handler'(_,_,_,_) :-
'$exit_undefp',
fail.
'$leave_undefp'(Ball) :-
'$exit_undefp',
throw(Ball).
/* This is the break predicate,
it saves the importante data about current streams and
debugger state */
break :-
nb_getval('$system_mode',SystemMode),
nb_getval('$trace',Trace),
nb_setval('$trace',off),
nb_getval('$debug_jump',Jump),
nb_getval('$debug_run',Run),
'$debug_on'(Debug),
'$debug_on'(false),
nb_getval('$break',BL), NBL is BL+1,
nb_getval('$spy_gn',SPY_GN),
b_getval('$spy_glist',GList),
b_setval('$spy_glist',[]),
nb_setval('$break',NBL),
current_output(OutStream), current_input(InpStream),
format(user_error, '% Break (level ~w)~n', [NBL]),
'$do_live',
!,
set_value('$live','$true'),
b_setval('$spy_glist',GList),
nb_setval('$spy_gn',SPY_GN),
'$set_input'(InpStream), '$set_output'(OutStream),
'$debug_on'(Debug),
nb_setval('$debug_jump',Jump),
nb_setval('$debug_run',Run),
nb_setval('$trace',Trace),
nb_setval('$break',BL),
nb_setval('$system_mode',SystemMode).
'$silent_bootstrap'(F) :-
'$init_globals',
nb_setval('$if_level',0),
get_value('$lf_verbose',OldSilent),
set_value('$lf_verbose',silent),
bootstrap(F),
% -p option must be processed after initializing the system
'$init_path_extensions',
set_value('$lf_verbose', OldSilent).
bootstrap(F) :-
'$open'(F, '$csult', Stream, 0, 0, F),
'$file_name'(Stream,File),
'$start_consult'(consult, File, LC),
file_directory_name(File, Dir),
getcwd(OldD),
cd(Dir),
(
get_value('$lf_verbose',silent)
->
true
;
H0 is heapused, '$cputime'(T0,_),
format(user_error, '~*|% consulting ~w...~n', [LC,F])
),
'$loop'(Stream,consult),
cd(OldD),
'$end_consult',
(
get_value('$lf_verbose',silent)
->
true
;
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
format(user_error, '~*|% ~w consulted ~w bytes in ~d msecs~n', [LC,F,H,T])
),
!,
'$close'(Stream).
'$init_path_extensions' :-
get_value('$extend_file_search_path',P), !,
P \= [],
set_value('$extend_file_search_path',[]),
'$extend_file_search_path'(P).
'$init_path_extensions'.
'$loop'(Stream,Status) :-
'$change_alias_to_stream'('$loop_stream',Stream),
repeat,
( '$current_stream'(_,_,Stream) -> true
; '$abort_loop'(Stream)
),
prompt('| '), prompt(_,'| '),
'$current_module'(OldModule),
'$system_catch'('$enter_command'(Stream,Status), OldModule, Error,
user:'$LoopError'(Error, Status)),
!.
'$enter_command'(Stream,Status) :-
'$read_vars'(Stream,Command,_,Pos,Vars),
'$command'(Command,Vars,Pos,Status).
'$abort_loop'(Stream) :-
'$do_error'(permission_error(input,closed_stream,Stream), loop).
/* General purpose predicates */
'$head_and_body'((H:-B),H,B) :- !.
'$head_and_body'(H,H,true).
%
% split head and body, generate an error if body is unbound.
%
'$check_head_and_body'((H:-B),H,B,P) :- !,
'$check_head'(H,P).
'$check_head_and_body'(H,H,true,P) :-
'$check_head'(H,P).
'$check_head'(H,P) :- var(H), !,
'$do_error'(instantiation_error,P).
'$check_head'(H,P) :- number(H), !,
'$do_error'(type_error(callable,H),P).
'$check_head'(H,P) :- db_reference(H), !,
'$do_error'(type_error(callable,H),P).
'$check_head'(_,_).
% term expansion
%
% return two arguments: Expanded0 is the term after "USER" expansion.
% Expanded is the final expanded term.
%
'$precompile_term'(Term, Expanded0, Expanded, BodyMod, SourceMod) :-
'$module_expansion'(Term, Expanded0, ExpandedI, BodyMod, SourceMod), !,
(
'$access_yap_flags'(9,1) /* strict_iso on */
->
Expanded = ExpandedI,
'$check_iso_strict_clause'(Expanded0)
;
'$expand_array_accesses_in_term'(ExpandedI,Expanded)
).
'$precompile_term'(Term, Term, Term, _, _).
expand_term(Term,Expanded) :-
( '$current_module'(Mod), \+ '$undefined'(term_expansion(_,_), Mod),
'$notrace'(Mod:term_expansion(Term,Expanded))
; \+ '$undefined'(term_expansion(_,_), system),
'$notrace'(system:term_expansion(Term,Expanded))
; \+ '$undefined'(term_expansion(_,_), user),
'$notrace'(user:term_expansion(Term,Expanded))
;
'$expand_term_grammar'(Term,Expanded)
),
!.
%
% Grammar Rules expansion
%
'$expand_term_grammar'((A-->B), C) :-
'$translate_rule'((A-->B),C), !.
'$expand_term_grammar'(A, A).
%
% Arithmetic expansion
%
'$expand_term_arith'(G1, G2) :-
get_value('$c_arith',true),
'$c_arith'(G1, G2), !.
'$expand_term_arith'(G,G).
%
% Arithmetic expansion
%
'$expand_array_accesses_in_term'(Expanded0,ExpandedF) :-
'$array_refs_compiled',
'$c_arrays'(Expanded0,ExpandedF), !.
'$expand_array_accesses_in_term'(Expanded,Expanded).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% catch/throw implementation
% at each catch point I need to know:
% what is ball;
% where was the previous catch
catch(G, C, A) :-
'$catch'(C,A,_),
yap_hacks:current_choice_point(CP0),
'$execute'(G),
yap_hacks:current_choice_point(CP1),
(CP0 == CP1 -> !; true ).
% makes sure we have an environment.
'$true'.
% system_catch is like catch, but it avoids the overhead of a full
% meta-call by calling '$execute0' instead of $execute.
% This way it
% also avoids module preprocessing and goal_expansion
%
'$system_catch'(G, M, C, A) :-
% check current trail
'$catch'(C,A,_),
yap_hacks:current_choice_point(CP0),
'$execute_nonstop'(G, M),
yap_hacks:current_choice_point(CP1),
(CP0 == CP1 -> !; true ).
%
% throw has to be *exactly* after system catch!
%
throw(_Ball) :-
% use existing ball
'$get_exception'(Ball),
!,
'$jump_env_and_store_ball'(Ball).
throw(Ball) :-
% get current jump point
'$jump_env_and_store_ball'(Ball).
% just create a choice-point
'$catch'(_,_,_).
'$catch'(_,_,_) :- fail.
'$handle_throw'(_, _, _).
'$handle_throw'(C, A, _Ball) :-
'$reset_exception'(Ball),
% reset info
('catch_ball'(Ball, C) ->
'$execute'(A)
;
throw(Ball)
).
'catch_ball'(Abort, _) :- Abort == '$abort', !, fail.
% system defined throws should be ignored by used, unless the
% user is hacking away.
'catch_ball'(Ball, V) :-
var(V),
nonvar(Ball),
Ball = error(Type,_), % internal error ??
functor(Type, Name, _),
atom_codes(Name, [0'$|_]), %'0
!, fail.
'catch_ball'(C, C).
'$run_toplevel_hooks' :-
nb_getval('$break',0),
recorded('$toplevel_hooks',H,_), !,
( '$oncenotrace'(H) -> true ; true).
'$run_toplevel_hooks'.
'$enter_system_mode' :-
nb_setval('$system_mode',on).
'$exit_system_mode' :-
nb_setval('$system_mode',off),
( nb_getval('$trace',on) -> '$creep' ; true).
%
% just prevent creeping from going on...
%
'$notrace'(G) :-
'$disable_creep', !,
(
% creep was going on...
yap_hacks:current_choice_point(CP0),
'$execute'(G),
yap_hacks:current_choice_point(CP1),
( CP0 == CP1 ->
!,
'$creep'
;
(
'$creep'
;
'$disable_docreep',
fail
)
)
;
'$creep',
fail
).
'$notrace'(G) :-
'$execute'(G).
'$oncenotrace'(G) :-
'$disable_creep', !,
(
'$execute'(G)
->
'$creep'
;
'$creep',
fail
).
'$oncenotrace'(G) :-
'$execute'(G), !.
'$run_at_thread_start' :-
recorded('$thread_initialization',M:D,_),
'$notrace'(M:D),
fail.
'$run_at_thread_start'.
nb_getval(GlobalVariable, Val) :-
'$nb_getval'(GlobalVariable, Val, Error),
(var(Error)
->
true
;
'$getval_exception'(GlobalVariable, Val, nb_getval(GlobalVariable, Val)) ->
nb_getval(GlobalVariable, Val)
;
'$do_error'(existence_error(variable, GlobalVariable),nb_getval(GlobalVariable, Val))
).
b_getval(GlobalVariable, Val) :-
'$nb_getval'(GlobalVariable, Val, Error),
(var(Error)
->
true
;
'$getval_exception'(GlobalVariable, Val, b_getval(GlobalVariable, Val)) ->
true
;
'$do_error'(existence_error(variable, GlobalVariable),b_getval(GlobalVariable, Val))
).
yap-6.2.2/pl/callcount.yap 000644 000765 000024 00000002230 11457004725 015364 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: callcount.yap *
* Last rev: 8/2/02 *
* mods: *
* comments: Some profiling predicates available in yap *
* *
*************************************************************************/
call_count_data(Calls, Retries, Both) :-
'$call_count_info'(Calls, Retries, Both).
call_count_reset :-
'$call_count_reset'.
call_count(Calls, Retries, Both) :-
'$check_if_call_count_on'(Calls, CallsOn),
'$check_if_call_count_on'(Retries, RetriesOn),
'$check_if_call_count_on'(Both, BothOn),
'$call_count_set'(Calls, CallsOn, Retries, RetriesOn, Both, BothOn).
'$check_if_call_count_on'(Calls, 1) :- integer(Calls), !.
'$check_if_call_count_on'(Calls, 0) :- var(Calls), !.
'$check_if_call_count_on'(Calls, A) :-
'$do_error'(type_error(integer,Calls),call_count(A)).
yap-6.2.2/pl/checker.yap 000644 000765 000024 00000023304 11511123322 014773 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: checker.yap *
* comments: style checker for Prolog *
* *
* Last rev: $Date: 2008-03-31 22:56:22 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.23 2007/11/26 23:43:09 vsc
* fixes to support threads and assert correctly, even if inefficiently.
*
* Revision 1.22 2006/11/17 12:10:46 vsc
* style_checker was failing on DCGs
*
* Revision 1.21 2006/03/24 16:26:31 vsc
* code review
*
* Revision 1.20 2005/11/05 23:56:10 vsc
* should have meta-predicate definitions for calls,
* multifile and discontiguous.
* have discontiguous as a builtin, not just as a
* declaration.
*
* Revision 1.19 2005/10/28 17:38:50 vsc
* sveral updates
*
* Revision 1.18 2005/04/20 20:06:11 vsc
* try to improve error handling and warnings from within consults.
*
* Revision 1.17 2005/04/20 04:08:20 vsc
* fix warnings
*
* Revision 1.16 2005/01/13 05:47:27 vsc
* lgamma broke arithmetic optimisation
* integer_y has type y
* pass original source to checker (and maybe even use option in parser)
* use warning mechanism for checker messages.
*
* Revision 1.15 2004/06/29 19:12:01 vsc
* fix checker messages
*
* Revision 1.14 2004/06/29 19:04:46 vsc
* fix multithreaded version
* include new version of Ricardo's profiler
* new predicat atomic_concat
* allow multithreaded-debugging
* small fixes
*
* Revision 1.13 2004/03/19 11:35:42 vsc
* trim_trail for default machine
* be more aggressive about try-retry-trust chains.
* - handle cases where block starts with a wait
* - don't use _killed instructions, just let the thing rot by itself.
* *
* *
*************************************************************************/
%
% A Small style checker for YAP
:- op(1150, fx, multifile).
style_check(V) :- var(V), !, fail.
style_check(all) :- '$syntax_check_mode'(_,on),
'$syntax_check_single_var'(_,on),
'$syntax_check_discontiguous'(_,on),
'$syntax_check_multiple'(_,on).
style_check(single_var) :- '$syntax_check_mode'(_,on),
'$syntax_check_single_var'(_,on).
style_check(singleton) :-
style_check(single_var).
style_check(-single_var) :-
no_style_check(single_var).
style_check(-singleton) :-
no_style_check(single_var).
style_check(discontiguous) :- '$syntax_check_mode'(_,on),
'$syntax_check_discontiguous'(_,on).
style_check(-discontiguous) :-
no_style_check(discontiguous).
style_check(multiple) :- '$syntax_check_mode'(_,on),
'$syntax_check_multiple'(_,on).
style_check(-multiple) :-
no_style_check(multiple).
style_check([]).
style_check([H|T]) :- style_check(H), style_check(T).
no_style_check(V) :- var(V), !, fail.
no_style_check(all) :- '$syntax_check_mode'(_,off),
'$syntax_check_single_var'(_,off),
'$syntax_check_discontiguous'(_,off),
'$syntax_check_multiple'(_,off).
no_style_check(single_var) :- '$syntax_check_mode'(_,off),
'$syntax_check_single_var'(_,off).
no_style_check(discontiguous) :- '$syntax_check_mode'(_,off),
'$syntax_check_discontiguous'(_,off).
no_style_check(multiple) :- '$syntax_check_mode'(_,on),
'$syntax_check_multiple'(_,off).
no_style_check([]).
no_style_check([H|T]) :- no_style_check(H), no_style_check(T).
'$syntax_check_mode'(O,N) :-
'$values'('$syntaxcheckflag',O,N).
'$syntax_check_single_var'(O,N) :-
'$values'('$syntaxchecksinglevar',O,N).
'$syntax_check_discontiguous'(O,N) :-
'$values'('$syntaxcheckdiscontiguous',O,N).
'$syntax_check_multiple'(O,N) :-
'$values'('$syntaxcheckmultiple',O,N).
% reset current state of style checker.
'$init_style_check'(File) :-
recorded('$predicate_defs','$predicate_defs'(_,_,_,File),R),
erase(R),
fail.
'$init_style_check'(_).
% style checker proper..
'$check_term'(T,VL,P,_) :-
get_value('$syntaxchecksinglevar',on),
'$singletons_in_clause'(T, VL, Sv),
Sv = [_|_],
'$sv_warning'(Sv,T),
fail.
'$check_term'(T,_,P,M) :-
get_value('$syntaxcheckdiscontiguous',on),
'$xtract_head'(T,M,NM,_,F,A),
% should always fail
'$handle_discontiguous'(F,A,NM),
fail.
'$check_term'(T,_,P,M) :-
get_value('$syntaxcheckmultiple',on),
'$xtract_head'(T,M,NM,_,F,A),
'$handle_multiple'(F,A,NM),
fail.
'$check_term'(T,_,_,M) :-
once((
get_value('$syntaxcheckdiscontiguous',on)
;
get_value('$syntaxcheckmultiple',on)
)),
nb_getval('$consulting_file',File),
'$xtract_head'(T,M,NM,_,F,A),
\+ (
% allow duplicates if we are not the last predicate to have
% been asserted.
once(recorded('$predicate_defs','$predicate_defs'(F0,A0,M0,File),_)),
F0 = F, A0 = A, M0 = NM
),
recorda('$predicate_defs','$predicate_defs'(F,A,NM,File),_),
fail.
'$check_term'(_,_,_,_).
%
% output a list of singleton variables...
%
'$singletons_in_clause'(T, VL, Sv) :-
% first check which variables are not singleton
'$non_singletons_in_term'(T,[],V2L),
% bound them
'$ground_vars'(V2L),
% the remainder which do not start by _ are our target!
'$sv_list'(VL, Sv).
'$ground_vars'([]).
'$ground_vars'(ground.V2L) :-
'$ground_vars'(V2L).
'$sv_list'([],[]).
'$sv_list'([[95|_]._|T],L) :- !,
'$sv_list'(T,L).
'$sv_list'([_|V].T,L) :- nonvar(V), !,
'$sv_list'(T,L).
'$sv_list'([Name|_].T, Name.L) :-
'$sv_list'(T,L).
'$sv_warning'([], _) :- !.
'$sv_warning'(SVs, T) :-
'$current_module'(OM),
'$xtract_head'(T, OM, M, H, Name, Arity),
print_message(warning,singletons(SVs,(M:Name/Arity))).
'$xtract_head'(V,M,M,V,call,1) :- var(V), !.
'$xtract_head'((H:-_),OM,M,NH,Name,Arity) :- !,
'$xtract_head'(H,OM,M,NH,Name,Arity).
'$xtract_head'((H,_),OM,M,H1,Name,Arity) :- !,
'$xtract_head'(H,OM,M,H1,Name,Arity).
'$xtract_head'((H-->_),OM,M,HL,Name,Arity) :- !,
'$xtract_head'(H,M,OM,_,Name,A1),
Arity is A1+2,
functor(HL,Name,Arity).
'$xtract_head'(M:H,_,NM,NH,Name,Arity) :- !,
'$xtract_head'(H,M,NM,NH,Name,Arity).
'$xtract_head'(H,M,M,H,Name,Arity) :-
functor(H,Name,Arity).
% check if a predicate is discontiguous.
'$handle_discontiguous'(F,A,M) :-
recorded('$discontiguous_defs','$df'(F,A,M),_), !,
fail.
'$handle_discontiguous'(F,A,M) :-
functor(Head, F, A),
'$is_multifile'(Head, M), !,
fail.
'$handle_discontiguous'(F,A,M) :-
nb_getval('$consulting_file', FileName),
% we have been there before
once(recorded('$predicate_defs','$predicate_defs'(F, A, M, FileName),_)),
% and we are not
\+ (
% the last predicate to have been asserted
once(recorded('$predicate_defs','$predicate_defs'(F0,A0,M0,FileName),_)),
F0 = F, A0 = A, M0 = M
),
print_message(warning,clauses_not_together((M:F/A))),
fail.
% never complain the second time
'$handle_multiple'(F,A,M) :-
nb_getval('$consulting_file', FileName),
recorded('$predicate_defs','$predicate_defs'(F,A,M,FileName),_), !.
% first time we have a definition
'$handle_multiple'(F,A,M) :-
nb_getval('$consulting_file', FileName0),
recorded('$predicate_defs','$predicate_defs'(F,A,M,FileName),_),
FileName \= FileName0,
'$multiple_has_been_defined'(FileName, F/A, M), !.
% be careful about these cases.
% consult does not count
'$multiple_has_been_defined'(_, _, _) :-
nb_getval('$consulting',true), !.
% multifile does not count
'$multiple_has_been_defined'(_, F/A, M) :-
functor(S, F, A),
'$is_multifile'(S, M), !.
'$multiple_has_been_defined'(Fil,F/A,M) :-
% first, clean up all definitions in other files
% don't forget, we just removed everything.
recorded('$predicate_defs','$predicate_defs'(F,A,M,FileName),R),
erase(R),
fail.
'$multiple_has_been_defined'(Fil,P,M) :-
print_message(warning,defined_elsewhere(M:P,Fil)).
'$multifile'(V, _) :- var(V), !,
'$do_error'(instantiation_error,multifile(V)).
'$multifile'((X,Y), M) :- !, '$multifile'(X, M), '$multifile'(Y, M).
'$multifile'(Mod:PredSpec, _) :- !,
'$multifile'(PredSpec, Mod).
'$multifile'(N//A, M) :- !,
integer(A),
A1 is A+2,
'$multifile'(N/A1, M).
'$multifile'(N/A, M) :-
'$add_multifile'(N,A,M),
fail.
'$multifile'(N/A, M) :-
functor(S,N,A),
'$is_multifile'(S, M), !.
'$multifile'(N/A, M) :- !,
'$new_multifile'(N,A,M).
'$multifile'([H|T], M) :- !,
'$multifile'(H,M),
'$multifile'(T,M).
'$multifile'(P, M) :-
'$do_error'(type_error(predicate_indicator,P),multifile(M:P)).
discontiguous(V) :-
var(V), !,
'$do_error'(instantiation_error,discontiguous(V)).
discontiguous(M:F) :- !,
'$discontiguous'(F,M).
discontiguous(F) :-
'$current_module'(M),
'$discontiguous'(F,M).
'$discontiguous'(V,M) :- var(V), !,
'$do_error'(instantiation_error,M:discontiguous(V)).
'$discontiguous'((X,Y),M) :- !,
'$discontiguous'(X,M),
'$discontiguous'(Y,M).
'$discontiguous'(M:A,_) :- !,
'$discontiguous'(A,M).
'$discontiguous'(N//A1, M) :- !,
integer(A1), !,
A is A1+2,
'$discontiguous'(N/A, M).
'$discontiguous'(N/A, M) :- !,
( recordzifnot('$discontiguous_defs','$df'(N,A,M),_) ->
true
;
true
).
'$discontiguous'(P,M) :-
'$do_error'(type_error(predicate_indicator,P),M:discontiguous(P)).
%
% did we declare multifile properly?
%
'$check_multifile_pred'(Hd, M, _) :-
functor(Hd,Na,Ar),
nb_getval('$consulting_file',F),
recorded('$multifile_defs','$defined'(F,Na,Ar,M),_), !.
% oops, we did not.
'$check_multifile_pred'(Hd, M, Fl) :-
% so this is not a multi-file predicate any longer.
functor(Hd,Na,Ar),
NFl is \(0x20000000) /\ Fl,
'$flags'(Hd,M,Fl,NFl),
'$warn_mfile'(Na,Ar).
'$warn_mfile'(F,A) :-
write(user_error,'% Warning: predicate '),
write(user_error,F/A), write(user_error,' was a multifile predicate '),
write(user_error,' (line '),
'$start_line'(LN), write(user_error,LN),
write(user_error,')'),
nl(user_error).
yap-6.2.2/pl/chtypes.yap 000644 000765 000024 00000030211 11457004725 015057 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: chtypes.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: implementation of SWI's code_type/2 *
* *
*************************************************************************/
/*
In addition, there is the library library(ctype) providing compatibility to some other Prolog systems. The predicates of this library are defined in terms of code_type/2.
char_type(?Char, ?Type)
Tests or generates alternative Types or Chars. The character-types are inspired by the standard C primitives.
alnum
Char is a letter (upper- or lowercase) or digit.
alpha
Char is a letter (upper- or lowercase).
csym
Char is a letter (upper- or lowercase), digit or the underscore (_). These are valid C- and Prolog symbol characters.
csymf
Char is a letter (upper- or lowercase) or the underscore (_). These are valid first characters for C- and Prolog symbols
ascii
Char is a 7-bits ASCII character (0..127).
white
Char is a space or tab. E.i. white space inside a line.
cntrl
Char is an ASCII control-character (0..31).
digit
Char is a digit.
digit(Weigth)
Char is a digit with value Weigth. I.e. char_type(X, digit(6) yields X = '6'. Useful for parsing numbers.
xdigit(Weigth)
Char is a haxe-decimal digit with value Weigth. I.e. char_type(a, xdigit(X) yields X = '10'. Useful for parsing numbers.
graph
Char produces a visible mark on a page when printed. Note that the space is not included!
lower
Char is a lower-case letter.
lower(Upper)
Char is a lower-case version of Upper. Only true if Char is lowercase and Upper uppercase.
to_lower(Upper)
Char is a lower-case version of Upper. For non-letters, or letter without case, Char and Lower are the same. See also upcase_atom/2 and downcase_atom/2.
upper
Char is an upper-case letter.
upper(Lower)
Char is an upper-case version of Lower. Only true if Char is uppercase and Lower lowercase.
to_upper(Lower)
Char is an upper-case version of Lower. For non-letters, or letter without case, Char and Lower are the same. See also upcase_atom/2 and downcase_atom/2.
punct
Char is a punctuation character. This is a graph character that is not a letter or digit.
space
Char is some form of layout character (tab, vertical-tab, newline, etc.).
end_of_file
Char is -1.
end_of_line
Char ends a line (ASCII: 10..13).
newline
Char is a the newline character (10).
period
Char counts as the end of a sentence (.,!,?).
quote
Char is a quote-character (", ', `).
paren(Close)
Char is an open-parenthesis and Close is the corresponding close-parenthesis.
code_type(?Code, ?Type)
As char_type/2, but uses character-codes rather than one-character atoms. Please note that both predicates are as flexible as possible. They handle either representation if the argument is instantiated and only will instantiate with an integer code or one-character atom depending of the version used. See also the prolog-flag double_quotes, atom_chars/2 and atom_codes/2.
*/
char_type(A, Spec) :-
var(A), !,
(ground(Spec),
'$handle_special_char_type'(Code, Spec)
->
true
;
'$char_spec_code_from_spec'(Spec, SpecCode),
'$code_enum'(Code, SpecCode),
'$spec_code_to_char'(SpecCode, Spec)
),
atom_codes(A,[Code]).
char_type(A, Spec) :-
atom(A), !,
atom_codes(A,[Code]),
'$code_type'(Code, SpecCode),
'$spec_code_to_char'(SpecCode, Spec).
char_type(Code, Spec) :-
number(Code), !,
'$code_type'(Code, SpecCode),
'$spec_code_to_char'(SpecCode, Spec).
char_type(Code, Spec) :-
'$do_error'(type_error(character,Code),char_type(Code, Spec)).
'$char_spec_code_from_spec'(Spec, Spec) :- atom(Spec), !.
'$char_spec_code_from_spec'(digit(Weight), digit(Weight)).
'$char_spec_code_from_spec'(xdigit(Weight), xdigit(Weight)).
'$char_spec_code_from_spec'(lower(Upper), lower(_)).
'$char_spec_code_from_spec'(to_lower(Upper), to_lower(_)).
'$char_spec_code_from_spec'(upper(Upper), upper(_)).
'$char_spec_code_from_spec'(to_upper(Upper), to_upper(_)).
code_type(Code, Spec) :-
var(Code), !,
(ground(Spec),
'$handle_special_char_type'(Code, Spec)
->
true
;
'$code_enum'(Code, Spec)
).
code_type(A, Spec) :-
atom(A), !,
atom_codes(A,[Code]),
'$code_type'(Code, Spec).
code_type(Code, Spec) :-
number(Code), !,
'$code_type'(Code, Spec).
code_type(Code, Spec) :-
'$do_error'(type_error(character,Code),char_type(Code, Spec)).
'$code_enum'(Code, Spec) :-
'$for'(0, 256, Code),
'$code_type'(Code, Spec).
'$for'(Min, Max, Min).
'$for'(Min, Max, I) :-
Min < Max,
Min1 is Min+1,
'$for'(Min1, Max, I).
'$code_type'(Code, Spec) :-
'$type_of_char'(Code, TypeCode),
'$code_type_name'(TypeCode, Type),
'$type_code'(Type, Code, Spec).
'$code_type_name'( 1,uc). /* Upper case */
'$code_type_name'( 2,ul). /* Underline */
'$code_type_name'( 3,lc). /* Lower case */
'$code_type_name'( 4,nu). /* digit */
'$code_type_name'( 5,qt). /* single quote */
'$code_type_name'( 6,dc). /* double quote */
'$code_type_name'( 7,sy). /* Symbol character */
'$code_type_name'( 8,sl). /* Solo character */
'$code_type_name'( 9,bk). /* Brackets & friends */
'$code_type_name'(10,bs). /* Blank */
'$code_type_name'(11,ef). /* End of File marker */
'$code_type_name'(12,cc). /* comment char % */
'$spec_code_to_char'(lower(Code), lower(Char)) :- !,
atom_codes(Char, [Code]).
'$spec_code_to_char'(to_lower(Code), to_lower(Char)) :- !,
atom_codes(Char, [Code]).
'$spec_code_to_char'(upper(Code), upper(Char)) :- !,
atom_codes(Char, [Code]).
'$spec_code_to_char'(to_upper(Code), to_upper(Char)) :- !,
atom_codes(Char, [Code]).
'$spec_code_to_char'(Spec, Spec).
'$type_code'(Type, _, alnum) :-
'$type_code_alnum'(Type).
'$type_code'(Type, _, alpha) :-
'$type_code_alpha'(Type).
'$type_code'(Type, _, csym) :-
'$type_code_csym'(Type).
'$type_code'(Type, _, csymf) :-
'$type_code_csymf'(Type).
'$type_code'(_, Code, ascii) :-
'$type_code_ascii'(Code).
'$type_code'(_, Code, white) :-
'$type_code_white'(Code).
'$type_code'(_, Code, cntrl) :-
'$type_code_cntrl'(Code).
'$type_code'(Type, _, digit) :-
'$type_code_digit'(Type).
'$type_code'(_, Code, digit(Weight)) :-
'$type_code_digit'(Code, Weight).
'$type_code'(_, Code, xdigit(Weight)) :-
'$type_code_xdigit'(Code, Weight).
'$type_code'(Type, _, graph) :-
'$type_code_graph'(Type).
'$type_code'(Type, _, lower) :-
'$type_code_lower'(Type).
'$type_code'(Type, Code, lower(UpCode)) :-
'$type_code_lower'(Type, Code, UpCode).
'$type_code'(Type, Code, to_lower(UpCode)) :-
'$type_code_to_lower'(Type,Code,UpCode).
'$type_code'(Type, _, upper) :-
'$type_code_upper'(Type).
'$type_code'(Type, Code, upper(UpCode)) :-
'$type_code_upper'(Type,Code,UpCode).
'$type_code'(Type, Code, to_upper(UpCode)) :-
'$type_code_to_upper'(Type,Code,UpCode).
'$type_code'(Type, _, punct) :-
'$type_code_punct'(Type).
'$type_code'(Type, _, space) :-
'$type_code_space'(Type).
'$type_code'(Type, _, end_of_file) :-
'$type_code_end_of_file'(Type).
'$type_code'(_, Code, end_of_line) :-
'$type_code_end_of_line'(Code).
'$type_code'(_, Code, newline) :-
'$type_code_newline'(Code).
'$type_code'(_, Code, period) :-
'$type_code_period'(Code).
'$type_code'(_, Code, quote) :-
'$type_code_quote'(Code).
'$type_code_alnum'(uc).
'$type_code_alnum'(lc).
'$type_code_alnum'(nu).
'$type_code_alpha'(uc).
'$type_code_alpha'(lc).
'$type_code_csym'(uc).
'$type_code_csym'(ul).
'$type_code_csym'(lc).
'$type_code_csym'(nu).
'$type_code_csymf'(uc).
'$type_code_csymf'(ul).
'$type_code_csymf'(lc).
'$type_code_ascii'(Cod) :- Cod < 128.
'$type_code_white'(0' ).
'$type_code_white'(0' ).
'$type_code_cntrl'(C) :- C < 32.
'$type_code_digit'(nu).
'$type_code_digit'(0'0, 0).
'$type_code_digit'(0'1, 1).
'$type_code_digit'(0'2, 2).
'$type_code_digit'(0'3, 3).
'$type_code_digit'(0'4, 4).
'$type_code_digit'(0'5, 5).
'$type_code_digit'(0'6, 6).
'$type_code_digit'(0'7, 7).
'$type_code_digit'(0'8, 8).
'$type_code_digit'(0'9, 9).
'$type_code_xdigit'(0'0, 0).
'$type_code_xdigit'(0'1, 1).
'$type_code_xdigit'(0'2, 2).
'$type_code_xdigit'(0'3, 3).
'$type_code_xdigit'(0'4, 4).
'$type_code_xdigit'(0'5, 5).
'$type_code_xdigit'(0'6, 6).
'$type_code_xdigit'(0'7, 7).
'$type_code_xdigit'(0'8, 8).
'$type_code_xdigit'(0'9, 9).
'$type_code_xdigit'(0'a, 10).
'$type_code_xdigit'(0'A, 10).
'$type_code_xdigit'(0'b, 11).
'$type_code_xdigit'(0'B, 11).
'$type_code_xdigit'(0'c, 12).
'$type_code_xdigit'(0'C, 12).
'$type_code_xdigit'(0'd, 13).
'$type_code_xdigit'(0'D, 13).
'$type_code_xdigit'(0'e, 14).
'$type_code_xdigit'(0'E, 14).
'$type_code_xdigit'(0'f, 15).
'$type_code_xdigit'(0'F, 15).
'$type_code_graph'(uc).
'$type_code_graph'(ul).
'$type_code_graph'(lc).
'$type_code_graph'(nu).
'$type_code_graph'(qt).
'$type_code_graph'(dc).
'$type_code_graph'(sy).
'$type_code_graph'(sl).
'$type_code_graph'(bk).
'$type_code_graph'(cc).
'$type_code_lower'(lc).
'$type_code_lower'(lc, Code, Upcode) :-
'$toupper'(Code, Upcode).
'$type_code_to_lower'(uc, C, C).
'$type_code_to_lower'(ul, C, C).
'$type_code_to_lower'(lc, Code, Upcode) :-
'$toupper'(Code, Upcode).
'$type_code_to_lower'(nu, C, C).
'$type_code_to_lower'(qt, C, C).
'$type_code_to_lower'(dc, C, C).
'$type_code_to_lower'(sy, C, C).
'$type_code_to_lower'(sl, C, C).
'$type_code_to_lower'(bk, C, C).
'$type_code_to_lower'(bs, C, C).
'$type_code_to_lower'(ef, C, C).
'$type_code_to_lower'(cc, C, C).
'$type_code_upper'(uc).
'$type_code_upper'(uc, Code, Upcode) :-
'$tolower'(Code, Upcode).
'$type_code_to_upper'(uc, Code, Upcode) :-
'$tolower'(Code, Upcode).
'$type_code_to_upper'(ul, C, C).
'$type_code_to_upper'(lc, C, C).
'$type_code_to_upper'(nu, C, C).
'$type_code_to_upper'(qt, C, C).
'$type_code_to_upper'(dc, C, C).
'$type_code_to_upper'(sy, C, C).
'$type_code_to_upper'(sl, C, C).
'$type_code_to_upper'(bk, C, C).
'$type_code_to_upper'(bs, C, C).
'$type_code_to_upper'(ef, C, C).
'$type_code_to_upper'(cc, C, C).
'$type_code_punct'(ul).
'$type_code_punct'(qt).
'$type_code_punct'(dc).
'$type_code_punct'(sy).
'$type_code_punct'(sl).
'$type_code_punct'(bk).
'$type_code_punct'(cc).
'$type_code_space'(bs).
'$type_code_end_of_file'(ef).
'$type_code_end_of_line'(10).
'$type_code_end_of_line'(11).
'$type_code_end_of_line'(12).
'$type_code_end_of_line'(13).
'$type_code_newline'(10).
'$type_code_period'( 0).
'$type_code_period'(0'!).
'$type_code_period'(0'.).
'$type_code_period'(0'?).
'$type_code_quote'( 0). %'
'$type_code_quote'(0'").
'$type_code_quote'(0'').
'$type_code_quote'(0'`).
'$type_code_paren'(0'{, 0'}).
'$type_code_paren'(0'[, 0']).
'$type_code_paren'(0'(, 0'(). %'
'$handle_special_char_type'(Spec, digit(N)) :-
integer(N),
N >= 0,
N =< 9,
Spec is "0"+N.
'$handle_special_char_type'(Spec, xdigit(N)) :-
integer(N),
N >= 0,
(
N =< 9
->
Spec is "0"+N
;
N =< 15
->
Spec is "a"+(N-10)
).
'$handle_special_char_type'(Spec, lower(Upper)) :-
Upper >= "A",
Upper =< "Z",
Spec is Upper + ("a"-"A").
'$handle_special_char_type'(Spec, to_lower(Upper)) :-
( Upper >= "A",
Upper =< "Z"
->
Spec is Upper + ("a"-"A")
;
Spec = Upper
).
'$handle_special_char_type'(Spec, upper(Lower)) :-
Lower >= "a",
Lower =< "z",
Spec is Lower + ("A"-"a").
'$handle_special_char_type'(Spec, to_upper(Lower)) :-
( Lower >= "a",
Lower =< "z"
->
Spec is Lower + ("A"-"a")
;
Spec = Lower
).
downcase_atom(U, D) :-
atom_codes(U, Codes),
'$downcase_codes'(Codes, DCodes),
atom_codes(D, DCodes).
'$downcase_codes'([], []).
'$downcase_codes'(C.Codes, D.DCodes) :-
code_type(D, to_lower(C)),
'$downcase_codes'(Codes, DCodes).
upcase_atom(U, D) :-
atom_codes(U, Codes),
'$upcase_codes'(Codes, DCodes),
atom_codes(D, DCodes).
'$upcase_codes'([], []).
'$upcase_codes'(C.Codes, D.DCodes) :-
code_type(D, to_upper(C)),
'$upcase_codes'(Codes, DCodes).
yap-6.2.2/pl/consult.yap 000755 000765 000024 00000106114 11502002105 015055 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: consult.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: Consulting Files in YAP *
* *
*************************************************************************/
%
% SWI options
% autoload(true,false)
% derived_from(File) -> make
% encoding(Encoding) => implemented
% expand({true,false)
% if(changed,true,not_loaded) => implemented
% imports(all,List) => implemented
% qcompile(true,false)
% silent(true,false) => implemented
% stream(Stream) => implemented
% consult(consult,reconsult) => implemented
% compilation_mode(compact,source,assert_all) => implemented
%
load_files(Files,Opts) :-
'$load_files'(Files,Opts,load_files(Files,Opts)).
'$load_files'(Files,Opts,Call) :-
'$check_files'(Files,load_files(Files,Opts)),
'$process_lf_opts'(Opts,Silent,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,Files,Call),
'$check_use_module'(Call,UseModule),
'$current_module'(M0),
'$lf'(Files,M0,Call,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,UseModule),
'$close_lf'(Silent).
'$check_files'(Files,Call) :-
var(Files), !,
'$do_error'(instantiation_error,Call).
'$check_files'(M:Files,Call) :- !,
(var(M)
->
'$do_error'(instantiation_error,Call)
;
atom(M)
->
'$check_files'(Files,Call)
;
'$do_error'(type_error(atom,M),Call)
).
'$check_files'(Files,Call) :-
(ground(Files)
->
true
;
'$do_error'(instantiation_error,Call)
).
'$process_lf_opts'(V,_,_,_,_,_,_,_,_,_,_,_,_,Call) :-
var(V), !,
'$do_error'(instantiation_error,Call).
'$process_lf_opts'([],_,InfLevel,_,_,_,_,_,Encoding,_,_,_,_,_) :-
(var(Encoding) ->
'$default_encoding'(Encoding)
;
true
).
'$process_lf_opts'([Opt|Opts],Silent,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,Files,Call) :-
'$process_lf_opt'(Opt,Silent,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,Files,Call), !,
'$process_lf_opts'(Opts,Silent,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,Files,Call).
'$process_lf_opts'([Opt|_],_,_,_,_,_,_,_,_,_,_,_,_,Call) :-
'$do_error'(domain_error(unimplemented_option,Opt),Call).
'$process_lf_opt'(autoload(true),Silent,InfLevel,_,_,_,_,_,_,_,_,_,_,_) :-
get_value('$verbose_auto_load',VAL),
(VAL = true ->
InfLevel = informational,
(get_value('$lf_verbose',informational) -> true ; Silent = silent),
set_value('$lf_verbose',informational)
;
InfLevel = silent,
(get_value('$lf_verbose',silent) -> true ; Silent = informational),
set_value('$lf_verbose',silent)
).
'$process_lf_opt'(autoload(false),_,_,_,_,_,_,_,_,_,_,_,_,_).
'$process_lf_opt'(derived_from(File),_,_,_,_,_,_,_,_,_,_,_,Files,Call) :-
( atom(File) -> true ; '$do_error'(type_error(atom,File),Call) ),
( atom(Files) -> true ; '$do_error'(type_error(atom,Files),Call) ),
/* call make */
'$do_error'(domain_error(unimplemented_option,derived_from),Call).
'$process_lf_opt'(encoding(Encoding),_,_,_,_,_,_,_,_,EncCode,_,_,_,Call) :-
( var(Encoding) ->
'$do_error'(instantiation_error,Call)
;
'$valid_encoding'(Encoding, EncCode) ->
true
;
'$do_error'(domain_error(io_mode,encoding(Encoding)),Call)
).
'$process_lf_opt'(expand(true),_,_,true,_,_,_,_,_,_,_,_,_,Call) :-
'$do_error'(domain_error(unimplemented_option,expand),Call).
'$process_lf_opt'(expand(false),_,_,false,_,_,_,_,_,_,_,_,_,_).
'$process_lf_opt'(if(changed),_,_,_,changed,_,_,_,_,_,_,_,_,_).
'$process_lf_opt'(if(true),_,_,_,true,_,_,_,_,_,_,_,_,_).
'$process_lf_opt'(if(not_loaded),_,_,_,not_loaded,_,_,_,_,_,_,_,_,_).
'$process_lf_opt'(imports(all),_,_,_,_,_,_,_,_,_,_,_,_,_).
'$process_lf_opt'(imports(Imports),_,_,_,_,_,Imports,_,_,_,_,_,_,_).
'$process_lf_opt'(qcompile(true),_,_,_,_,true,_,_,_,_,_,_,_,Call) :-
'$do_error'(domain_error(unimplemented_option,qcompile),Call).
'$process_lf_opt'(qcompile(false),_,_,_,_,false,_,_,_,_,_,_,_,_).
'$process_lf_opt'(silent(true),Silent,silent,_,_,_,_,_,_,_,_,_,_,_) :-
( get_value('$lf_verbose',silent) -> true ; Silent = informational),
set_value('$lf_verbose',silent).
'$process_lf_opt'(silent(false),Silent,informational,_,_,_,_,_,_,_,_,_,_,_) :-
( get_value('$lf_verbose',informational) -> true ; Silent = silent),
set_value('$lf_verbose',informational).
'$process_lf_opt'(skip_unix_comments,_,_,_,_,_,_,_,_,skip_unix_comments,_,_,_,_).
'$process_lf_opt'(compilation_mode(source),_,_,_,_,_,_,_,_,_,source,_,_,_).
'$process_lf_opt'(compilation_mode(compact),_,_,_,_,_,_,_,_,_,compact,_,_,_).
'$process_lf_opt'(compilation_mode(assert_all),_,_,_,_,_,_,_,_,_,assert_all,_,_,_).
'$process_lf_opt'(consult(reconsult),_,_,_,_,_,_,_,_,_,_,reconsult,_,_).
'$process_lf_opt'(consult(consult),_,_,_,_,_,_,_,_,_,_,consult,_,_).
'$process_lf_opt'(stream(Stream),_,_,_,_,_,_,Stream,_,_,_,_,Files,Call) :-
/* ( '$stream'(Stream) -> true ; '$do_error'(domain_error(stream,Stream),Call) ), */
( atom(Files) -> true ; '$do_error'(type_error(atom,Files),Call) ).
'$check_use_module'(use_module(_),use_module(_)) :- !.
'$check_use_module'(use_module(_,_),use_module(_)) :- !.
'$check_use_module'(use_module(M,_,_),use_module(M)) :- !.
'$check_use_module'(_,load_files) :- !.
'$lf'(V,_,Call,_,_,_,_,_,_,_,_,_,_) :- var(V), !,
'$do_error'(instantiation_error,Call).
'$lf'([],_,_,_,_,_,_,_,_,_,_,_,_,_) :- !.
'$lf'(M:X, _, Call,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,UseModule) :- !,
(
atom(M)
->
'$lf'(X, M, Call,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,UseModule)
;
'$do_error'(type_error(atom,M),Call)
).
'$lf'([F|Fs], Mod,Call,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,UseModule) :- !,
'$lf'(F,Mod,Call,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,_),
'$lf'(Fs, Mod,Call,InfLevel,Expand,Changed,CompilationMode,Imports,Stream,Encoding,SkipUnixComments,CompMode,Reconsult,UseModule).
'$lf'(_, Mod, _,InfLevel,_,_,CompilationMode,Imports,Stream,_,Reconsult,SkipUnixComments,CompMode,UseModule) :-
nonvar(Stream), !,
'$do_lf'(Mod, Stream, InfLevel,CompilationMode,Imports,SkipUnixComments,CompMode,Reconsult,UseModule).
'$lf'(user, Mod, _,InfLevel,_,_,CompilationMode,Imports,_,_,SkipUnixComments,CompMode,Reconsult,UseModule) :- !,
'$do_lf'(Mod, user_input, InfLevel, CompilationMode,Imports,SkipUnixComments,CompMode,Reconsult,UseModule).
'$lf'(user_input, Mod, _,InfLevel,_,_,CompilationMode,Imports,_,_,SkipUnixComments,CompMode,Reconsult,UseModule) :- !,
'$do_lf'(Mod, user_input, InfLevel, CompilationMode,Imports,SkipUnixComments,CompMode,Reconsult,UseModule).
'$lf'(X, Mod, Call, InfLevel,_,Changed,CompilationMode,Imports,_,Enc,SkipUnixComments,CompMode,Reconsult,UseModule) :-
'$find_in_path'(X, Y, Call),
'$open'(Y, '$csult', Stream, 0, Enc, X), !,
'$set_changed_lfmode'(Changed),
'$start_lf'(X, Mod, Stream, InfLevel, CompilationMode, Imports, Changed,SkipUnixComments,CompMode,Reconsult,UseModule),
'$close'(Stream).
'$lf'(X, _, Call, _, _, _, _, _, _, _, _, _, _, _) :-
'$do_error'(permission_error(input,stream,X),Call).
'$set_changed_lfmode'(true) :- !.
'$set_changed_lfmode'(_).
'$start_lf'(_, Mod, Stream,_ ,_, Imports, not_loaded, _, _, _, _) :-
'$file_loaded'(Stream, Mod, Imports), !.
'$start_lf'(_, Mod, Stream, _, _, Imports, changed, _, _, _, _) :-
'$file_unchanged'(Stream, Mod, Imports), !.
'$start_lf'(_, Mod, Stream, InfLevel, CompilationMode, Imports, _, SkipUnixComments, CompMode, Reconsult, UseModule) :-
'$do_lf'(Mod, Stream, InfLevel, CompilationMode, Imports, SkipUnixComments, CompMode, Reconsult, UseModule).
'$close_lf'(Silent) :-
nonvar(Silent), !,
set_value('$lf_verbose',Silent).
'$close_lf'(_).
ensure_loaded(Fs) :-
'$load_files'(Fs, [if(changed)],ensure_loaded(Fs)).
compile(Fs) :-
'$load_files'(Fs, [], compile(Fs)).
% consult(Fs) :-
% '$has_yap_or',
% '$do_error'(context_error(consult(Fs),clause),query).
consult(V) :-
var(V), !,
'$do_error'(instantiation_error,consult(V)).
consult(M0:Fs) :- !,
'$consult'(Fs, M0).
consult(Fs) :-
'$current_module'(M0),
'$consult'(Fs, M0).
'$consult'(Fs,Module) :-
'$access_yap_flags'(8, 2), % SICStus Prolog compatibility
!,
'$load_files'(Module:Fs,[],consult(Fs)).
'$consult'(Fs, Module) :-
'$load_files'(Module:Fs,[consult(consult)],consult(Fs)).
reconsult(Fs) :-
'$load_files'(Fs, [], reconsult(Fs)).
use_module(F) :-
'$load_files'(F, [if(not_loaded)], use_module(F)).
use_module(F,Is) :-
'$load_files'(F, [if(not_loaded),imports(Is)], use_module(F,Is)).
use_module(M,F,Is) :-
'$use_module'(M,F,Is).
'$use_module'(U,_F,Is) :- nonvar(U), U = user, !,
'$import_to_current_module'(user_input, user, Is).
'$use_module'(M,F,Is) :- nonvar(M), !,
recorded('$module','$module'(F1,M,_),_),
'$load_files'(F1, [if(not_loaded),imports(Is)], use_module(M,F,Is)),
F1 = F.
'$use_module'(M,F,Is) :- nonvar(F),
'$load_files'(F, [if(not_loaded),imports(Is)], use_module(M,F,Is)).
'$csult'(V, _) :- var(V), !,
'$do_error'(instantiation_error,consult(V)).
'$csult'([], _).
'$csult'([-F|L], M) :- !, '$load_files'(M:F, [],[-M:F]), '$csult'(L, M).
'$csult'([F|L], M) :- '$consult'(F, M), '$csult'(L, M).
'$do_lf'(ContextModule, Stream, InfLevel, _, Imports, SkipUnixComments, CompMode, Reconsult, UseModule) :-
nb_getval('$if_level',OldIncludeLevel),
nb_setval('$if_level',0),
( nb_getval('$system_mode', OldMode) -> true ; OldMode = off),
( OldMode == off -> '$enter_system_mode' ; true ),
'$record_loaded'(Stream, ContextModule, Reconsult),
'$current_module'(OldModule,ContextModule),
getcwd(OldD),
nb_getval('$consulting_file',OldF),
'$set_consulting_file'(Stream),
H0 is heapused, '$cputime'(T0,_),
'$file_name'(Stream,File),
'$fetch_stream_alias'(OldStream,'$loop_stream'),
'$change_alias_to_stream'('$loop_stream',Stream),
nb_getval('$consulting',Old),
nb_setval('$consulting',false),
'$access_yap_flags'(18,GenerateDebug),
'$consult_infolevel'(InfLevel),
'$comp_mode'(OldCompMode, CompMode),
( get_value('$syntaxcheckflag',on) -> '$init_style_check'(File) ; true ),
recorda('$initialisation','$',_),
( Reconsult = reconsult ->
'$start_reconsulting'(File),
'$start_consult'(Reconsult,File,LC),
'$remove_multifile_clauses'(File),
StartMsg = reconsulting,
EndMsg = reconsulted
;
'$start_consult'(Reconsult,File,LC),
StartMsg = consulting,
EndMsg = consulted
),
print_message(InfLevel, loading(StartMsg, File)),
( SkipUnixComments == skip_unix_comments ->
'$skip_unix_comments'(Stream)
;
true
),
'$loop'(Stream,Reconsult),
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
'$current_module'(Mod,OldModule),
print_message(InfLevel, loaded(EndMsg, File, Mod, T, H)),
'$end_consult',
(
Reconsult = reconsult ->
'$clear_reconsulting'
;
true
),
'$change_alias_to_stream'('$loop_stream',OldStream),
'$set_yap_flags'(18,GenerateDebug),
'$comp_mode'(CompMode, OldCompMode),
nb_setval('$consulting',Old),
nb_setval('$consulting_file',OldF),
cd(OldD),
nb_setval('$if_level',OldIncludeLevel),
% surely, we were in run mode or we would not have included the file!
nb_setval('$if_skip_mode',run),
% back to include mode!
nb_setval('$if_level',OldIncludeLevel),
'$bind_module'(Mod, UseModule),
'$import_to_current_module'(File, ContextModule, Imports),
( LC == 0 -> prompt(_,' |: ') ; true),
( OldMode == off -> '$exit_system_mode' ; true ),
'$exec_initialisation_goals',
!.
'$bind_module'(_, load_files).
'$bind_module'(Mod, use_module(Mod)).
'$import_to_current_module'(File, M, Imports) :-
recorded('$module','$module'(File,NM,Ps),_), M \= NM, !,
'$use_preds'(Imports, Ps, NM, M).
'$import_to_current_module'(_, _, _).
'$consult_infolevel'(InfoLevel) :- nonvar(InfoLevel), !.
'$consult_infolevel'(InfoLevel) :-
get_value('$lf_verbose',InfoLevel), InfoLevel \= [], !.
'$consult_infolevel'(informational).
'$start_reconsulting'(F) :-
recorda('$reconsulted','$',_),
recorda('$reconsulting',F,_).
'$initialization'(V) :-
var(V), !,
'$do_error'(instantiation_error,initialization(V)).
'$initialization'(C) :- number(C), !,
'$do_error'(type_error(callable,C),initialization(C)).
'$initialization'(C) :- db_reference(C), !,
'$do_error'(type_error(callable,C),initialization(C)).
'$initialization'(G) :-
'$show_consult_level'(Level1),
% it will be done after we leave the current consult level.
Level is Level1-1,
recordz('$initialisation',do(Level,G),_),
fail.
'$initialization'(_).
initialization(G,OPT) :-
'$initialization'(G,OPT).
'$initialization'(G,OPT) :-
(
var(G)
->
'$do_error'(instantiation_error,initialization(G,OPT))
;
number(G)
->
'$do_error'(type_error(callable,G),initialization(G,OPT))
;
db_reference(G)
->
'$do_error'(type_error(callable,G),initialization(G,OPT))
;
var(OPT)
->
'$do_error'(instantiation_error,initialization(G,OPT))
;
atom(OPT)
->
(
OPT == now
->
fail
;
OPT == after_load
->
fail
;
OPT == restore
->
fail
;
'$do_error'(domain_error(initialization,OPT),initialization(OPT))
)
;
'$do_error'(type_error(OPT),initialization(G,OPT))
).
'$initialization'(G,now) :-
( '$notrace'(G) -> true ; format(user_error,':- ~w:~w failed.~n',[M,G]) ).
'$initialization'(G,after_load) :-
'$initialization'(G).
% ignore for now.
'$initialization'(G,restore).
'$exec_initialisation_goals' :-
nb_setval('$initialization_goals',on),
fail.
'$exec_initialisation_goals' :-
recorded('$blocking_code',_,R),
erase(R),
fail.
% system goals must be performed first
'$exec_initialisation_goals' :-
recorded('$system_initialisation',G,R),
erase(R),
G \= '$',
'$notrace'(G),
fail.
'$exec_initialisation_goals' :-
'$show_consult_level'(Level),
'$current_module'(M),
findall(
G,
(recorded('$initialisation',do(Level,G),R), erase(R), G\='$'),
LGs),
lists:member(G,LGs),
nb_getval('$system_mode', OldMode),
( OldMode == on -> '$exit_system_mode' ; true ),
% run initialization under user control (so allow debugging this stuff).
(
'$system_catch'('$oncenotrace'(M:G), M, Error, user:'$LoopError'(Error, top)),
fail
;
OldMode = on,
'$enter_system_mode',
fail
).
'$exec_initialisation_goals' :-
nb_setval('$initialization_goals',off).
'$include'(V, _) :- var(V), !,
'$do_error'(instantiation_error,include(V)).
'$include'([], _) :- !.
'$include'([F|Fs], Status) :- !,
'$include'(F, Status),
'$include'(Fs, Status).
'$include'(X, Status) :-
get_value('$lf_verbose',Verbosity),
'$find_in_path'(X,Y,include(X)),
nb_getval('$included_file',OY),
nb_setval('$included_file', Y),
'$current_module'(Mod),
H0 is heapused, '$cputime'(T0,_),
'$default_encoding'(Encoding),
( '$open'(Y, '$csult', Stream, 0, Encoding, X), !,
print_message(Verbosity, loading(including, Y)),
'$loop'(Stream,Status), '$close'(Stream)
;
'$do_error'(permission_error(input,stream,Y),include(X))
),
H is heapused-H0, '$cputime'(TF,_), T is TF-T0,
print_message(Verbosity, loaded(included, Y, Mod, T, H)),
nb_setval('$included_file',OY).
'$do_startup_reconsult'(X) :-
( '$access_yap_flags'(15, 0) ->
'$system_catch'(load_files(X, [silent(true)]),Module,Error,'$Error'(Error))
;
set_value('$verbose',off),
'$system_catch'(load_files(X, [silent(true),skip_unix_comments]),Module,_,fail)
;
true
),
!,
( '$access_yap_flags'(15, 0) -> true ; halt).
'$skip_unix_comments'(Stream) :-
'$peek'(Stream, 0'#), !, % 35 is ASCII for '#
'$get0_line_codes'(Stream, _),
'$skip_unix_comments'(Stream).
'$skip_unix_comments'(_).
source_file(FileName) :-
recorded('$lf_loaded','$lf_loaded'(FileName,Mod,_,_),_), Mod \= prolog.
source_file(Mod:Pred, FileName) :-
current_module(Mod),
Mod \= prolog,
'$current_predicate_no_modules'(Mod,_,Pred),
'$owned_by'(Pred, Mod, FileName).
'$owned_by'(T, Mod, FileName) :-
'$is_multifile'(T, Mod),
functor(T, Name, Arity),
setof(FileName, Ref^recorded('$multifile_defs','$defined'(FileName,Name,Arity,Mod), Ref), L),
lists:member(FileName, L).
'$owned_by'(T, Mod, FileName) :-
'$owner_file'(T, Mod, FileName).
source_location(FileName, Line) :-
prolog_load_context(file, FileName),
prolog_load_context(term_position,'$stream_position'(_, Line, _, _, _)).
prolog_load_context(_, _) :-
nb_getval('$consulting_file',[]), !, fail.
prolog_load_context(directory, DirName) :-
getcwd(DirName).
prolog_load_context(file, FileName) :-
nb_getval('$included_file',IncFileName),
( IncFileName = [] ->
nb_getval('$consulting_file',FileName),
FileName \= []
;
FileName = IncFileName
).
prolog_load_context(module, X) :-
'$current_module'(X).
prolog_load_context(source, FileName) :-
nb_getval('$consulting_file',FileName).
prolog_load_context(stream, Stream) :-
'$fetch_stream_alias'(Stream,'$loop_stream').
prolog_load_context(term_position, Position) :-
'$fetch_stream_alias'(Stream,'$loop_stream'),
stream_position(Stream, Position).
% if the file exports a module, then we can
% be imported from any module.
'$file_loaded'(Stream, M, Imports) :-
'$file_name'(Stream, F),
'$ensure_file_loaded'(F, M, Imports).
'$ensure_file_loaded'(F, M, Imports) :-
recorded('$module','$module'(F1,NM,P),_),
recorded('$lf_loaded','$lf_loaded'(F1,_,_,_),_),
'$same_file'(F1,F), !,
'$use_preds'(Imports,P, NM, M).
'$ensure_file_loaded'(F, M, _) :-
recorded('$lf_loaded','$lf_loaded'(F1,M,_,_),_),
'$same_file'(F1,F), !.
% if the file exports a module, then we can
% be imported from any module.
'$file_unchanged'(Stream, M, Imports) :-
'$file_name'(Stream, F),
'$ensure_file_unchanged'(F, M, Imports).
'$ensure_file_unchanged'(F, M, Imports) :-
recorded('$module','$module'(F1,NM,P),_),
recorded('$lf_loaded','$lf_loaded'(F1,_,Age,_),R),
'$same_file'(F1,F), !,
'$file_is_unchanged'(F, R, Age),
'$use_preds'(Imports, P, NM, M).
'$ensure_file_unchanged'(F, M, _) :-
recorded('$lf_loaded','$lf_loaded'(F1,M,Age,_),R),
'$same_file'(F1,F), !,
'$file_is_unchanged'(F, R, Age).
'$file_is_unchanged'(F, R, Age) :-
'$file_age'(F,CurrentAge),
((CurrentAge = Age ; Age = -1) -> true; erase(R), fail).
path(Path) :- findall(X,'$in_path'(X),Path).
'$in_path'(X) :- recorded('$path',Path,_),
atom_codes(Path,S),
( S = "" -> X = '.' ;
atom_codes(X,S) ).
add_to_path(New) :- add_to_path(New,last).
add_to_path(New,Pos) :-
atom(New), !,
'$check_path'(New,Str),
atom_codes(Path,Str),
'$add_to_path'(Path,Pos).
'$add_to_path'(New,_) :- recorded('$path',New,R), erase(R), fail.
'$add_to_path'(New,last) :- !, recordz('$path',New,_).
'$add_to_path'(New,first) :- recorda('$path',New,_).
remove_from_path(New) :- '$check_path'(New,Path),
recorded('$path',Path,R), erase(R).
'$check_path'(At,SAt) :- atom(At), !, atom_codes(At,S), '$check_path'(S,SAt).
'$check_path'([],[]).
'$check_path'([Ch],[Ch]) :- '$dir_separator'(Ch), !.
'$check_path'([Ch],[Ch,A]) :- !, integer(Ch), '$dir_separator'(A).
'$check_path'([N|S],[N|SN]) :- integer(N), '$check_path'(S,SN).
% add_multifile_predicate when we start consult
'$add_multifile'(Name,Arity,Module) :-
nb_getval('$consulting_file',File),
'$add_multifile'(File,Name,Arity,Module).
'$add_multifile'(File,Name,Arity,Module) :-
recorded('$multifile_defs','$defined'(File,Name,Arity,Module), _), !.
% print_message(warning,declaration((multifile Module:Name/Arity),ignored)).
'$add_multifile'(File,Name,Arity,Module) :-
recordz('$multifile_defs','$defined'(File,Name,Arity,Module),_), !,
fail.
'$add_multifile'(File,Name,Arity,Module) :-
recorded('$mf','$mf_clause'(File,Name,Arity,Module,Ref),R),
erase(R),
'$erase_clause'(Ref,Module),
fail.
'$add_multifile'(_,_,_,_).
% retract old multifile clauses for current file.
'$remove_multifile_clauses'(FileName) :-
recorded('$multifile_defs','$defined'(FileName,_,_,_),R1),
erase(R1),
fail.
'$remove_multifile_clauses'(FileName) :-
recorded('$mf','$mf_clause'(FileName,_,_,Module,Ref),R),
'$erase_clause'(Ref, Module),
erase(R),
fail.
'$remove_multifile_clauses'(_).
'$set_consulting_file'(user) :- !,
nb_setval('$consulting_file',user_input).
'$set_consulting_file'(user_input) :- !,
nb_setval('$consulting_file',user_input).
'$set_consulting_file'(Stream) :-
'$file_name'(Stream,F),
nb_setval('$consulting_file',F),
'$set_consulting_dir'(F).
%
% Use directory where file exists
%
'$set_consulting_dir'(F) :-
file_directory_name(F, Dir),
cd(Dir).
'$record_loaded'(Stream, M, Reconsult) :-
Stream \= user,
Stream \= user_input,
'$file_name'(Stream,F),
( recorded('$lf_loaded','$lf_loaded'(F,M,_,_),R), erase(R), fail ; true ),
'$file_age'(F,Age),
recorda('$lf_loaded','$lf_loaded'(F,M,Age,Reconsult),_),
fail.
'$record_loaded'(_, _, _).
%
% encoding stuff: what I believe SWI does.
%
% 8-bit binaries
'$valid_encoding'(octet, 0).
% 7-bit ASCII as America originally intended
'$valid_encoding'(ascii, 2).
% Ye europeaners made it 8 bits
'$valid_encoding'(iso_latin_1, 1).
% UTF-8: default 8 bits but 80 extends to 16bits
'$valid_encoding'(utf8, 8).
% UNICODE: 16 bits throughout, the way it was supposed to be!
'$valid_encoding'(unicode_be, 16).
'$valid_encoding'(unicode_le, 32).
% whatever the system tell us to do.
'$valid_encoding'(text, 4).
'$default_encoding'(DefCode) :- nonvar(DefCode), !,
'$encoding'('$stream'(0),DefCode),
'$encoding'('$stream'(1),DefCode),
'$encoding'('$stream'(2),DefCode),
set_value('$default_encoding',DefCode).
'$default_encoding'(DefCode) :-
get_value('$default_encoding',DefCode0),
( DefCode0 == [] ->
'$get_default_encoding'(DefCode)
;
DefCode = DefCode0
).
'$set_encoding'(V) :- var(V), !,
'$do_error'(instantiation_error, encoding(V)).
'$set_encoding'(EncAtom) :-
'$valid_encoding'(EncAtom, Enc), !,
'$fetch_stream_alias'(Stream,'$loop_stream'),
'$encoding'(Stream, Enc).
'$set_encoding'(EncAtom) :-
atom(EncAtom), !,
'$do_error'(domain_error(encoding,EncAtom),encoding(EncAtom)).
'$set_encoding'(EncAtom) :-
'$do_error'(type_error(atom,V),encoding(EncAtom)).
absolute_file_name(V,Out) :- var(V), !,
'$do_error'(instantiation_error, absolute_file_name(V, Out)).
absolute_file_name(user,user) :- !.
absolute_file_name(File0,File) :-
'$absolute_file_name'(File0,[access(none),file_type(txt),file_errors(fail),solutions(first)],File,absolute_file_name(File0,File)).
'$find_in_path'(F0,F,G) :-
'$absolute_file_name'(F0,[access(read),file_type(source),file_errors(fail),solutions(first)],F,G).
absolute_file_name(File,TrueFileName,Opts) :-
var(TrueFileName), !,
absolute_file_name(File,Opts,TrueFileName).
absolute_file_name(File,Opts,TrueFileName) :-
'$absolute_file_name'(File,Opts,TrueFileName,absolute_file_name(File,Opts,TrueFileName)).
'$absolute_file_name'(File,Opts,TrueFileName,G) :- var(File), !,
'$do_error'(instantiation_error, G).
'$absolute_file_name'(File,Opts,TrueFileName, G) :-
'$process_fn_opts'(Opts,Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,G),
FoundOne = a(false),
(
'$find_in_path'(File,opts(Extensions,RelTo,Type,Access,FErrors,Expand,Debug),TrueFileName,G),
(Solutions = first -> ! ; true),
nb_setarg(1, FoundOne, true)
;
FErrors = error, FoundOne = a(false) ->
'$do_error'(existence_error(file,File),G)
).
'$process_fn_opts'(V,_,_,_,_,_,_,_,_,G) :- var(V), !,
'$do_error'(instantiation_error, G).
'$process_fn_opts'([],[],_,source,none,error,first,false,false,_) :- !.
'$process_fn_opts'([Opt|Opts],Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,G) :- !,
'$process_fn_opt'(Opt,Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions0,RelTo0,Type0,Access0,FErrors0,Solutions0,Expand0,Debug0,G),
'$process_fn_opts'(Opts,Extensions0,RelTo0,Type0,Access0,FErrors0,Solutions0,Expand0,Debug0,G).
'$process_fn_opts'(Opts,Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,G) :- !,
'$do_error'(type_error(list,T),G).
'$process_fn_opt'(Opt,Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,G) :- var(Opt), !,
'$do_error'(instantiation_error, G).
'$process_fn_opt'(extensions(Extensions),Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,_,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,G) :- !,
'$check_fn_extensions'(Extensions,G).
'$process_fn_opt'(relative_to(RelTo),Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,_,Type,Access,FErrors,Solutions,Expand,Debug,G) :- !,
'$check_atom'(RelTo,G).
'$process_fn_opt'(access(Access),Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,RelTo,Type,_,FErrors,Solutions,Expand,Debug,G) :- !,
'$check_atom'(Access,G).
'$process_fn_opt'(file_type(Type),Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,RelTo,_,Access,FErrors,Solutions,Expand,Debug,G) :- !,
'$check_fn_type'(Type,G).
'$process_fn_opt'(file_errors(FErrors),Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,RelTo,Type,Access,_,Solutions,Expand,Debug,G) :- !,
'$check_fn_errors'(FErrors,G).
'$process_fn_opt'(solutions(Solutions),Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,RelTo,Type,Access,FErrors,_,Expand,Debug,G) :- !,
'$check_fn_solutions'(Solutions,G).
'$process_fn_opt'(expand(Expand),Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,RelTo,Type,Access,FErrors,Solutions,_,Debug,G) :- !,
'$check_true_false'(Expand,G).
'$process_fn_opt'(verbose_file_search(Debug),Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,_,G) :- !,
'$check_true_false'(Debug,G).
'$process_fn_opt'(Opt,Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,Extensions,RelTo,Type,Access,FErrors,Solutions,Expand,Debug,G) :- !,
'$do_error'(domain_error(file_name_option,T),G).
'$check_fn_extensions'(V,G) :- var(V), !,
'$do_error'(instantiation_error, G).
'$check_fn_extensions'([],_) :- !.
'$check_fn_extensions'([A|L],G) :- !,
'$check_atom'(A,G),
'$check_fn_extensions'(L,G).
'$check_fn_extensions'(T,G) :- !,
'$do_error'(type_error(list,T),G).
'$check_atom'(V,G) :- var(V), !,
'$do_error'(instantiation_error, G).
'$check_atom'(A,G) :- atom(A), !.
'$check_atom'(T,G) :- !,
'$do_error'(type_error(atom,T),G).
'$check_fn_type'(V,G) :- var(V), !,
'$do_error'(instantiation_error, G).
'$check_fn_type'(txt,_) :- !.
'$check_fn_type'(prolog,_) :- !.
'$check_fn_type'(source,_) :- !.
'$check_fn_type'(executable,_) :- !.
'$check_fn_type'(qlf,_) :- !.
'$check_fn_type'(directory,_) :- !.
'$check_fn_type'(T,G) :- atom(T), !,
'$do_error'(domain_error(file_type,T),G).
'$check_fn_type'(T,G) :- !,
'$do_error'(type_error(atom,T),G).
'$check_fn_errors'(V,G) :- var(V), !,
'$do_error'(instantiation_error, G).
'$check_fn_errors'(fail,_) :- !.
'$check_fn_errors'(error,_) :- !.
'$check_fn_errors'(T,G) :- atom(T), !,
'$do_error'(domain_error(file_errors,T),G).
'$check_fn_errors'(T,G) :- !,
'$do_error'(type_error(atom,T),G).
'$check_fn_solutions'(V,G) :- var(V), !,
'$do_error'(instantiation_error, G).
'$check_fn_solutions'(first,_) :- !.
'$check_fn_solutions'(all,_) :- !.
'$check_fn_solutions'(T,G) :- atom(T), !,
'$do_error'(domain_error(solutions,T),G).
'$check_fn_solutions'(T,G) :- !,
'$do_error'(type_error(atom,T),G).
'$check_true_false'(V,G) :- var(V), !,
'$do_error'(instantiation_error, G).
'$check_true_false'(true,_) :- !.
'$check_true_false'(false,_) :- !.
'$check_true_false'(T,G) :- atom(T), !,
'$do_error'(domain_error(boolean,T),G).
'$check_true_false'(T,G) :- !,
'$do_error'(type_error(atom,T),G).
% This sequence must be followed:
% user and user_input are special;
% library(F) must check library_directories
% T(F) must check file_search_path
% all must try search in path
'$find_in_path'(user,_,user_input, _) :- !.
'$find_in_path'(user_input,_,user_input, _) :- !.
'$find_in_path'(library(F0),_,_, _) :-
% make sure library_directory is open.
\+ clause(user:library_directory(_),_),
'$system_library_directories'(D),
assert(user:library_directory(D)),
fail.
'$find_in_path'(commons(F0),_,_, _) :-
% make sure library_directory is open.
\+ clause(user:commons_directory(_),_),
'$system_commons_directories'(D),
assert(user:commons_directory(D)),
fail.
'$find_in_path'(S, Opts, NewFile, Call) :-
S =.. [Name,File0], !,
'$dir_separator'(D),
'$cat_file_name'(File0,File),
atom_codes(A,[D]),
'$extend_path_directory'(Name, A, File, Opts, NewFile, Call).
'$find_in_path'(File0,Opts,NewFile,_) :-
'$cat_file_name'(File0,File), !,
'$add_path'(File,PFile),
'$get_abs_file'(PFile,Opts,AbsFile),
'$search_in_path'(AbsFile,Opts,NewFile).
'$find_in_path'(File,_,_,Call) :-
'$do_error'(domain_error(source_sink,File),Call).
% allow paths in File Name
'$cat_file_name'(File0,File) :-
atom(File0), !,
File = File0.
'$cat_file_name'(File0,File) :-
ground(File0),
charsio:open_mem_write_stream(Stream),
write(Stream, File0),
charsio:peek_mem_write_stream(Stream, [], L),
close(Stream),
atom_codes(File, L).
'$get_abs_file'(File,opts(_,D0,_,_,_,_,_),AbsFile) :-
operating_system_support:true_file_name(File,D0,AbsFile).
'$search_in_path'(File,opts(Extensions,_,Type,Access,_,_,_),F) :-
'$add_extensions'(Extensions, File, F0),
'$check_file'(F0, Type, Access, F).
'$search_in_path'(File,opts(_,_,Type,Access,_,_,_),F) :-
'$add_type_extensions'(Type, File, F0),
'$check_file'(F0, Type, Access, F).
'$check_file'(F, Type, none, F) :- !.
'$check_file'(F0, Type, Access, F0) :-
access_file(F0, Access),
(Type == directory
->
exists_directory(F0)
;
true
).
'$add_extensions'([Ext|_],File,F) :-
'$mk_sure_true_ext'(Ext,NExt),
atom_concat([File,NExt],F).
'$add_extensions'([_|Extensions],File,F) :-
'$add_extensions'(Extensions,File,F).
'$mk_sure_true_ext'(Ext,NExt) :-
atom_codes(Ext,[C|L]),
C \= 0'.,
!,
atom_codes(NExt,[0'.,C|L]).
'$mk_sure_true_ext'(Ext,Ext).
'$add_type_extensions'(Type,File,F) :-
'$type_extension'(Type,Ext),
atom_concat([File,Ext],F).
'$type_extension'(txt,'').
'$type_extension'(prolog,'.yap').
'$type_extension'(prolog,'.pl').
'$type_extension'(prolog,'').
'$type_extension'(source,'.yap').
'$type_extension'(source,'.pl').
'$type_extension'(source,'').
'$type_extension'(executable,Suffix) :- '$obj_suffix'(String), atom_codes(Suffix, String).
'$type_extension'(qlf,'.qlf').
'$type_extension'(qlf,'').
'$type_extension'(directory,'').
'$add_path'(File,File).
'$add_path'(File,PFile) :-
recorded('$path',Path,_),
atom_concat([Path,File],PFile).
'$system_library_directories'(Dir) :-
getenv('YAPSHAREDIR', Dir).
'$system_library_directories'(Dir) :-
getenv('YAPCOMMONSDIR', Dir).
'$system_library_directories'(Dir) :-
get_value(system_library_directory,Dir).
'$system_library_directories'(Dir) :-
get_value(prolog_commons_directory,Dir).
'$extend_path_directory'(Name, D, File, Opts, NewFile, Call) :-
'$notrace'(user:file_search_path(Name, Dir)),
'$extend_pathd'(Dir, D, File, Opts, NewFile, Call).
'$extend_pathd'(Dir, A, File, Opts, NewFile, Call) :-
atom(Dir), !,
atom_concat([Dir,A,File],NFile),
'$find_in_path'(NFile, Opts, NewFile, Goal), !.
'$extend_pathd'(Name, A, File, Opts, OFile, Goal) :-
nonvar(Name),
Name =.. [N,P0],
atom_concat([P0,A,File],NFile),
NewName =.. [N,NFile],
'$find_in_path'(NewName, Opts, OFile, Goal).
%
% This is complicated because of embedded ifs.
%
'$if'(_,top) :- !, fail.
'$if'(Goal,_) :-
nb_getval('$if_level',Level0),
Level is Level0 + 1,
nb_setval('$if_level',Level),
nb_getval('$endif',OldEndif),
nb_getval('$if_skip_mode',Mode),
nb_setval('$endif',elif(Level,OldEndif,Mode)),
fail.
% we are in skip mode, ignore....
'$if'(Goal,_) :-
nb_getval('$endif',elif(Level, OldEndif, skip)), !,
nb_setval('$endif',endif(Level, OldEndif, skip)).
% we are in non skip mode, check....
'$if'(Goal,_) :-
('$if_call'(Goal)
->
% we will execute this branch, and later enter skip
nb_getval('$endif',elif(Level,OldEndif,Mode)),
nb_setval('$endif',endif(Level,OldEndif,Mode))
;
% we are now in skip, but can start an elif.
nb_setval('$if_skip_mode',skip)
).
'$else'(top) :- !, fail.
'$else'(_) :-
nb_getval('$if_level',0), !,
'$do_error'(context_error(no_if),(:- else)).
% we have done an if, so just skip
'$else'(_) :-
nb_getval('$endif',endif(_,_,_)), !,
nb_setval('$if_skip_mode',skip).
% we can try the elif
'$else'(_) :-
nb_getval('$if_level',Level),
nb_getval('$endif',elif(Level,OldEndif,Mode)),
nb_setval('$endif',endif(Level,OldEndif,Mode)),
nb_setval('$if_skip_mode',run).
'$elif'(_,top) :- !, fail.
'$elif'(Goal,_) :-
nb_getval('$if_level',0),
'$do_error'(context_error(no_if),(:- elif(Goal))).
% we have done an if, so just skip
'$elif'(_,_) :-
nb_getval('$endif',endif(_,_,_)), !,
nb_setval('$if_skip_mode',skip).
% we can try the elif
'$elif'(Goal,_) :-
nb_getval('$if_level',Level),
nb_getval('$endif',elif(Level,OldEndif,Mode)),
('$if_call'(Goal)
->
% we will not skip, and we will not run any more branches.
nb_setval('$endif',endif(Level,OldEndif,Mode)),
nb_setval('$if_skip_mode',run)
;
% we will (keep) on skipping
nb_setval('$if_skip_mode',skip)
).
'$elif'(_,_).
'$endif'(top) :- !, fail.
'$endif'(_) :-
% unmmatched endif.
nb_getval('$if_level',0),
'$do_error'(context_error(no_if),(:- endif)).
'$endif'(_) :-
% back to where you belong.
nb_getval('$if_level',Level),
nb_getval('$endif',Endif),
Level0 is Level-1,
nb_setval('$if_level',Level0),
arg(2,Endif,OldEndif),
arg(3,Endif,OldMode),
nb_setval('$endif',OldEndif),
nb_setval('$if_skip_mode',OldMode).
'$if_call'(G) :-
catch('$eval_if'(G), E, (print_message(error, E), fail)).
'$eval_if'(Goal) :-
expand_term(Goal,TrueGoal),
once(TrueGoal).
'$if_directive'((:- if(_))).
'$if_directive'((:- else)).
'$if_directive'((:- elif(_))).
'$if_directive'((:- endif)).
'$comp_mode'(_OldCompMode, CompMode) :-
var(CompMode), !. % just do nothing.
'$comp_mode'(OldCompMode, assert_all) :-
'$fetch_comp_status'(OldCompMode),
nb_setval('$assert_all',on).
'$comp_mode'(OldCompMode, source) :-
'$fetch_comp_status'(OldCompMode),
'$set_yap_flags'(11,1).
'$comp_mode'(OldCompMode, compact) :-
'$fetch_comp_status'(OldCompMode),
'$set_yap_flags'(11,0).
'$fetch_comp_status'(assert_all) :-
nb_getval('$assert_all',on), !.
'$fetch_comp_status'(source) :-
'$access_yap_flags'(11,1).
'$fetch_comp_status'(compact).
make :-
recorded('$lf_loaded','$lf_loaded'(F1,M,_,reconsult),_),
'$load_files'(F1, [if(changed)],make),
fail.
make.
file_name_extension(A1,A2,F) :-
var(F),
nonvar(A1), nonvar(A2), !,
atom_codes(A2, S2),
(
S2 = [0'.|_] %'
;
A2 = ''
->
atom_concat(A1, A2, F)
;
atom_concat([A1, '.', A2], F)
).
file_name_extension(A1,A2,F) :-
var(F), !,
'$do_error'(instantiation_error,file_name_extension(A1,A2,F)).
file_name_extension(A1,A2,F) :-
nonvar(A2), !,
atom_codes(F, S),
atom_codes(A2, S2),
'$file_name_extension'(S, S1, E2),
(
S2 = [0'.|E2] %'
->
true
;
S2 = E2
),
atom_codes(A1, S1).
file_name_extension(A1,A2,F) :-
atom_codes(F, S),
'$file_name_extension'(S, S1, S2),
atom_codes(A2, S2),
atom_codes(A1, S1).
'$file_name_extension'(S, S1, S2) :-
lists:append(S1, [0'.|S2], S),
\+ lists:append(_, [0'.|_], S2), !.
'$file_name_extension'(S, S, []).
yap-6.2.2/pl/control.yap 000644 000765 000024 00000020572 11510774655 015077 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: control.yap *
* Last rev: 20/08/09 *
* mods: *
* comments: control predicates available in yap *
* *
*************************************************************************/
once(G) :- '$execute'(G), !.
forall(Cond, Action) :- \+((Cond, \+(Action))).
ignore(Goal) :- (Goal->true;true).
if(X,Y,Z) :-
yap_hacks:env_choice_point(CP0),
(
CP is '$last_choice_pt',
'$call'(X,CP,if(X,Y,Z),M),
'$execute'(X),
'$clean_ifcp'(CP),
'$call'(Y,CP,if(X,Y,Z),M)
;
'$call'(Z,CP,if(X,Y,Z),M)
).
call(X,A) :- '$execute'(X,A).
call(X,A1,A2) :- '$execute'(X,A1,A2).
call(X,A1,A2,A3) :- '$execute'(X,A1,A2,A3).
call(X,A1,A2,A3,A4) :- '$execute'(X,A1,A2,A3,A4).
call(X,A1,A2,A3,A4,A5) :- '$execute'(X,A1,A2,A3,A4,A5).
call(X,A1,A2,A3,A4,A5,A6) :- '$execute'(X,A1,A2,A3,A4,A5,A6).
call(X,A1,A2,A3,A4,A5,A6,A7) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7).
call(X,A1,A2,A3,A4,A5,A6,A7,A8) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8).
call(X,A1,A2,A3,A4,A5,A6,A7,A8,A9) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8,A9).
call(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10).
call(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) :- '$execute'(X,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11).
call_cleanup(Goal, Cleanup) :-
setup_call_catcher_cleanup(true, Goal, _Catcher, Cleanup).
call_cleanup(Goal, Catcher, Cleanup) :-
setup_call_catcher_cleanup(true, Goal, Catcher, Cleanup).
setup_call_cleanup(Setup, Goal, Cleanup) :-
setup_call_catcher_cleanup(Setup, Goal, _Catcher, Cleanup).
setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup) :-
yap_hacks:disable_interrupts,
'$check_goal_for_setup_call_cleanup'(Setup, setup_call_cleanup(Setup, Goal, Cleanup)),
catch('$do_setup'(Setup),Exception,'$handle_broken_setup'(Exception)),
'$check_goal_for_setup_call_cleanup'(Cleanup, setup_call_cleanup(Setup, Goal, Cleanup)),
'$safe_call_cleanup'(Goal,Cleanup,Catcher,Exception).
% make sure we don't lose interrupts if we get exceptions
% with setup.
'$handle_broken_setup'(Exception) :-
yap_hacks:enable_interrupts,
throw(Exception).
'$check_goal_for_setup_call_cleanup'(Goal, G) :-
strip_module(Goal, _, MG),
(
var(MG)
->
yap_hacks:enable_interrupts,
'$do_error'(instantiation_error,G)
;
true
).
% this is simple, do nothing
'$do_setup'(A:true) :- atom(A), !.
% this is tricky: please don't forget that interrupts are disabled at this point
% and that they will only be enabled after setting up Cleanup
'$do_setup'(Setup) :-
(
'$execute'(Setup),
% we don't need to care about enabling interrupts
!
;
% reenable interrupts if Setup failed
yap_hacks:enable_interrupts,
fail
).
'$cleanup_exception'(Exception, exception(Exception), Cleanup) :- !,
% whatever happens, let exception go through
catch('$clean_call'(_,Cleanup),_,true),
throw(Exception).
'$cleanup_exception'(Exception, _, _) :-
throw(Exception).
'$safe_call_cleanup'(Goal, Cleanup, Catcher, Exception) :-
yap_hacks:current_choice_point(MyCP1),
'$coroutining':freeze_goal(Catcher, '$clean_call'(Active, Cleanup)),
(
yap_hacks:trail_suspension_marker(Catcher),
yap_hacks:enable_interrupts,
yap_hacks:current_choice_point(CP0),
'$execute'(Goal),
% ensure environment for delayed variables in Goal
'$true',
yap_hacks:current_choice_point(CPF),
(
CP0 =:= CPF
->
Catcher = exit,
!
;
true
)
;
Catcher = fail,
fail
).
'$holds_true'.
% The first argument is used by JumpEnv to verify if a throw
% is going to be handled by the cleanup catcher. If it is so,
% clean_call will not be called from JumpToEnv.
'$clean_call'(_, Cleanup) :-
'$execute'(Cleanup), !.
'$clean_call'(_, _).
'$cc_check_throw' :-
nb_getval('$catch',Ball),
throw(Ball).
%%% The unknown predicate,
% informs about what the user wants to be done when
% there are no clauses for a certain predicate */
unknown(V0,V) :-
'$current_module'(M),
'$unknown'(V0,V,M).
% query mode
'$unknown'(V0,V,_) :- var(V), !,
'$ask_unknown_flag'(V),
V = V0.
% handle modules.
'$unknown'(V0,Mod:Handler,_) :-
'$unknown'(V0,Handler,Mod).
% check if we have one we like.
'$unknown'(_,New,Mod) :-
'$valid_unknown_handler'(New,Mod), fail.
% clean up previous unknown predicate handlers
'$unknown'(Old,New,Mod) :-
recorded('$unknown','$unknown'(_,MyOld),Ref), !,
erase(Ref),
'$cleanup_unknown_handler'(MyOld,Old),
'$new_unknown'(New, Mod).
% store the new one.
'$unknown'(fail,New,Mod) :-
'$new_unknown'(New, Mod).
'$valid_unknown_handler'(V,_) :-
var(V), !,
'$do_error'(instantiation_error,yap_flag(unknown,V)).
'$valid_unknown_handler'(fail,_) :- !.
'$valid_unknown_handler'(error,_) :- !.
'$valid_unknown_handler'(warning,_) :- !.
'$valid_unknown_handler'(S,M) :-
functor(S,_,1),
arg(1,S,A),
var(A),
\+ '$undefined'(S,M),
!.
'$valid_unknown_handler'(S,_) :-
'$do_error'(domain_error(flag_value,unknown+S),yap_flag(unknown,S)).
'$ask_unknown_flag'(Old) :-
recorded('$unknown','$unknown'(_,MyOld),_), !,
'$cleanup_unknown_handler'(MyOld,Old).
'$ask_unknown_flag'(fail).
'$cleanup_unknown_handler'('$unknown_error'(_),error) :- !.
'$cleanup_unknown_handler'('$unknown_warning'(_),warning) :- !.
'$cleanup_unknown_handler'(Handler, Handler).
'$new_unknown'(fail,_) :- !.
'$new_unknown'(error,_) :- !,
recorda('$unknown','$unknown'(P,'$unknown_error'(P)),_).
'$new_unknown'(warning,_) :- !,
recorda('$unknown','$unknown'(P,'$unknown_warning'(P)),_).
'$new_unknown'(X,M) :-
arg(1,X,A),
recorda('$unknown','$unknown'(A,M:X),_).
'$unknown_error'(Mod:Goal) :-
functor(Goal,Name,Arity),
'$program_continuation'(PMod,PName,PAr),
'$do_error'(existence_error(procedure,Name/Arity),context(Mod:Goal,PMod:PName/PAr)).
'$unknown_warning'(Mod:Goal) :-
functor(Goal,Name,Arity),
'$program_continuation'(PMod,PName,PAr),
print_message(error,error(existence_error(procedure,Name/Arity), context(Mod:Goal,PMod:PName/PAr))),
fail.
%%% Some "dirty" predicates
% Only efective if yap compiled with -DDEBUG
% this predicate shows the code produced by the compiler
'$show_code' :- '$debug'(0'f). %' just make emacs happy
grow_heap(X) :- '$grow_heap'(X).
grow_stack(X) :- '$grow_stack'(X).
%
% gc() expects to be called from "call". Make sure it has an
% environment to return to.
%
%garbage_collect :- save(dump), '$gc', save(dump2).
garbage_collect :-
'$gc'.
gc :-
yap_flag(gc,on).
nogc :-
yap_flag(gc,off).
garbage_collect_atoms :-
'$atom_gc'.
'$force_environment_for_gc'.
'$good_list_of_character_codes'(V) :- var(V), !.
'$good_list_of_character_codes'([]).
'$good_list_of_character_codes'([X|L]) :-
'$good_character_code'(X),
'$good_list_of_character_codes'(L).
'$good_character_code'(X) :- var(X), !.
'$good_character_code'(X) :- integer(X), X > -2, X < 256.
(initialization) :-
'$initialisation_goals'.
prolog_initialization(G) :- var(G), !,
'$do_error'(instantiation_error,initialization(G)).
prolog_initialization(T) :- callable(T), !,
'$assert_init'(T).
prolog_initialization(T) :-
'$do_error'(type_error(callable,T),initialization(T)).
'$assert_init'(T) :- recordz('$startup_goal',T,_), fail.
'$assert_init'(_).
version :- '$version'.
version(V) :- var(V), !,
'$do_error'(instantiation_error,version(V)).
version(T) :- atom(T), !, '$assert_version'(T).
version(T) :-
'$do_error'(type_error(atom,T),version(T)).
'$assert_version'(T) :- recordz('$version',T,_), fail.
'$assert_version'(_).
'$set_toplevel_hook'(_) :-
recorded('$toplevel_hooks',_,R),
erase(R),
fail.
'$set_toplevel_hook'(H) :-
recorda('$toplevel_hooks',H,_),
fail.
'$set_toplevel_hook'(_).
halt :-
print_message(informational, halt),
'$halt'(0).
halt(X) :-
'$halt'(X).
prolog_current_frame(Env) :-
Env is '$env'.
'$run_atom_goal'(GA) :-
'$current_module'(Module),
atom_codes(GA,Gs0),
'$add_dot_to_atom_goal'(Gs0,Gs),
charsio:open_mem_read_stream(Gs, Stream),
( '$system_catch'(read(Stream, G),Module,_,fail) ->
close(Stream)
;
close(Stream),
fail
),
'$system_catch'('$query'(once(G), []),Module,Error,user:'$Error'(Error)).
'$add_dot_to_atom_goal'([],[0'.]) :- !. %'
'$add_dot_to_atom_goal'([0'.],[0'.]) :- !.
'$add_dot_to_atom_goal'([C|Gs0],[C|Gs]) :-
'$add_dot_to_atom_goal'(Gs0,Gs).
yap-6.2.2/pl/corout.yap 000644 000765 000024 00000033177 11457004725 014731 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: corout.pl *
* Last rev: *
* mods: *
* comments: Coroutines implementation *
* *
*************************************************************************/
:- module('$coroutining',[
op(1150, fx, block)
%dif/2,
%when/2,
%block/1,
%wait/1,
%frozen/2
]).
attr_unify_hook(DelayList, _) :-
wake_delays(DelayList).
wake_delays([]).
wake_delays(Delay.List) :-
wake_delay(Delay),
wake_delays(List).
%
% Interface to attributed variables.
%
wake_delay(redo_dif(Done, X, Y)) :-
redo_dif(Done, X, Y).
wake_delay(redo_freeze(Done, V, Goal)) :-
redo_freeze(Done, V, Goal).
wake_delay(redo_eq(Done, X, Y, Goal)) :-
redo_eq(Done, X, Y, Goal, G).
wake_delay(redo_ground(Done, X, Goal)) :-
redo_ground(Done, X, Goal).
attribute_goals(Var) -->
{ get_attr(Var, '$coroutining', Delays) },
attgoal_for_delays(Delays, Var).
attgoal_for_delays([], V) --> [].
attgoal_for_delays([G|AllAtts], V) -->
attgoal_for_delay(G, V),
attgoal_for_delays(AllAtts, V).
attgoal_for_delay(redo_dif(Done, X, Y), V) -->
{ var(Done), first_att(dif(X,Y), V) }, !,
[prolog:dif(X,Y)].
attgoal_for_delay(redo_freeze(Done, V, Goal), V) -->
{ var(Done) }, !,
{ remove_when_declarations(Goal, NoWGoal) },
[ prolog:freeze(V,NoWGoal) ].
attgoal_for_delay(redo_eq(Done, X, Y, Goal), V) -->
{ var(Done), first_att(Goal, V) }, !,
[ prolog:when(X=Y,Goal) ].
attgoal_for_delay(redo_ground(Done, X, Goal), V) -->
{ var(Done) }, !,
[ prolog:when(ground(X),Goal) ].
attgoal_for_delay(_, V) --> [].
remove_when_declarations(when(Cond,Goal,_), when(Cond,NoWGoal)) :- !,
remove_when_declarations(Goal, NoWGoal).
remove_when_declarations(Goal, Goal).
%
% operators defined in this module:
%
prolog:freeze(V, G) :-
var(V), !,
freeze_goal(V,G).
prolog:freeze(_, G) :-
'$execute'(G).
freeze_goal(V,VG) :-
var(VG), !,
'$current_module'(M),
internal_freeze(V, redo_freeze(_Done,V,M:VG)).
freeze_goal(V,M:G) :- !,
internal_freeze(V, redo_freeze(_Done,V,M:G)).
freeze_goal(V,G) :-
'$current_module'(M),
internal_freeze(V, redo_freeze(_Done,V,M:G)).
%
%
% Dif is tricky because we need to wake up on the two variables being
% bound together, or on any variable of the term being bound to
% another. Also, the day YAP fully supports infinite rational trees,
% dif should work for them too. Hence, term comparison should not be
% implemented in Prolog.
%
% This is the way dif works. The '$can_unify' predicate does not know
% anything about dif semantics, it just compares two terms for
% equaility and is based on compare. If it succeeds without generating
% a list of variables, the terms are equal and dif fails. If it fails,
% dif succeeds.
%
% If it succeeds but it creates a list of variables, dif creates
% suspension records for all these variables on the '$redo_dif'(V,
% X, Y) goal. V is a flag that says whether dif has completed or not,
% X and Y are the original goals. Whenever one of these variables is
% bound, it calls '$redo_dif' again. '$redo_dif' will then check whether V
% was bound. If it was, dif has succeeded and redo_dif just
% exits. Otherwise, '$redo_dif' will call dif again to see what happened.
%
% Dif needs two extensions from the suspension engine:
%
% First, it needs
% for the engine to be careful when binding two suspended
% variables. Basically, in this case the engine must be sure to wake
% up one of the goals, as they may make dif fail. The way the engine
% does so is by searching the list of suspended variables, and search
% whether they share a common suspended goal. If they do, that
% suspended goal is added to the WokenList.
%
% Second, thanks to dif we may try to suspend on the same variable
% several times. dif calls a special version of freeze that checks
% whether that is in fact the case.
%
prolog:dif(X, Y) :-
'$can_unify'(X, Y, LVars), !,
LVars = [_|_],
dif_suspend_on_lvars(LVars, redo_dif(_Done, X, Y)).
prolog:dif(_, _).
dif_suspend_on_lvars([], _).
dif_suspend_on_lvars([H|T], G) :-
internal_freeze(H, G),
dif_suspend_on_lvars(T, G).
%
% This predicate is called whenever a variable dif was suspended on is
% bound. Note that dif may have already executed successfully.
%
% Three possible cases: dif has executed and Done is bound; we redo
% dif and the two terms either unify, hence we fail, or may unify, and
% we try to increase the number of suspensions; last, the two terms
% did not unify, we are done, so we succeed and bind the Done variable.
%
redo_dif(Done, _, _) :- nonvar(Done), !.
redo_dif(Done, X, Y) :-
'$can_unify'(X, Y, LVars), !,
LVars = [_|_],
dif_suspend_on_lvars(LVars, redo_dif(Done, X, Y)).
redo_dif('$done', _, _).
% If you called nonvar as condition for when, then you may find yourself
% here.
%
% someone else (that is Cond had ;) did the work, do nothing
%
redo_freeze(Done, _, _) :- nonvar(Done), !.
%
% We still have some more conditions: continue the analysis.
%
redo_freeze(Done, _, when(C, G, Done)) :- !,
when(C, G, Done).
%
% check if the variable was really bound
%
redo_freeze(Done, V, G) :- var(V), !,
internal_freeze(V, redo_freeze(Done,V,G)).
%
% I can't believe it: we're done and can actually execute our
% goal. Notice we have to say we are done, otherwise someone else in
% the disjunction might decide to wake up the goal themselves.
%
redo_freeze('$done', _, G) :-
'$execute'(G).
%
% eq is a combination of dif and freeze
redo_eq(Done, _, _, _, _) :- nonvar(Done), !.
redo_eq(_, X, Y, _, G) :-
'$can_unify'(X, Y, LVars),
LVars = [_|_], !,
dif_suspend_on_lvars(LVars, G).
redo_eq(Done, _, _, when(C, G, Done), _) :- !,
when(C, G, Done).
redo_eq('$done', _ ,_ , Goal, _) :-
'$execute'(Goal).
%
% ground is similar to freeze
redo_ground(Done, _, _) :- nonvar(Done), !.
redo_ground(Done, X, Goal) :-
'$non_ground'(X, Var), !,
internal_freeze(Var, redo_ground(Done, X, Goal)).
redo_ground(Done, _, when(C, G, Done)) :- !,
when(C, G, Done).
redo_ground('$done', _, Goal) :-
'$execute'(Goal).
%
% support for when/2 built-in
%
prolog:when(Conds,Goal) :-
'$current_module'(Mod),
prepare_goal_for_when(Goal, Mod, ModG),
when(Conds, ModG, Done, [], LG), !,
%write(vsc:freezing(LG,Done)),nl,
suspend_when_goals(LG, Done).
prolog:when(_,Goal) :-
'$execute'(Goal).
%
% support for when/2 like declaration.
%
%
% when will block on a conjunction or disjunction of nonvar, ground,
% ?=, where ?= is both terms being bound together
%
%
'$declare_when'(Cond, G) :-
generate_code_for_when(Cond, G, Code),
'$current_module'(Module),
'$$compile'(Code, Code, 5, Module), fail.
'$declare_when'(_,_).
%
% use a meta interpreter for now
%
generate_code_for_when(Conds, G,
( G :- when(Conds, ModG, Done, [], LG), !,
suspend_when_goals(LG, Done)) ) :-
'$current_module'(Mod),
prepare_goal_for_when(G, Mod, ModG).
%
% make sure we have module info for G!
%
prepare_goal_for_when(G, Mod, Mod:call(G)) :- var(G), !.
prepare_goal_for_when(M:G, _, M:G) :- !.
prepare_goal_for_when(G, Mod, Mod:G).
%
% now for the important bit
%
% Done is used to synchronise: when it is bound someone else did the
% goal and we can give up.
%
% when/5 and when_suspend succeds when there is need to suspend a goal
%
%
when(V, G, Done, LG0, LGF) :- var(V), !,
'$do_error'(instantiation_error,when(V,G)).
when(nonvar(V), G, Done, LG0, LGF) :-
when_suspend(nonvar(V), G, Done, LG0, LGF).
when(?=(X,Y), G, Done, LG0, LGF) :-
when_suspend(?=(X,Y), G, Done, LG0, LGF).
when(ground(T), G, Done, LG0, LGF) :-
when_suspend(ground(T), G, Done, LG0, LGF).
when((C1, C2), G, Done, LG0, LGF) :-
% leave it open to continue with when.
(
when(C1, when(C2, G, Done), Done, LG0, LGI)
->
LGI = LGF
;
% we solved C1, great, now we just have to solve C2!
when(C2, G, Done, LG0, LGF)
).
when((G1 ; G2), G, Done, LG0, LGF) :-
when(G1, G, Done, LG0, LGI),
when(G2, G, Done, LGI, LGF).
%
% Auxiliary predicate called from within a conjunction.
% Repeat basic code for when, as inserted in first clause for predicate.
%
when(_, _, Done) :-
nonvar(Done), !.
when(Cond, G, Done) :-
when(Cond, G, Done, [], LG),
!,
suspend_when_goals(LG, Done).
when(_, G, '$done') :-
'$execute'(G).
%
% Do something depending on the condition!
%
% some one else did the work.
%
when_suspend(_, _, Done, _, []) :- nonvar(Done), !.
%
% now for the serious stuff.
%
when_suspend(nonvar(V), G, Done, LG0, LGF) :-
try_freeze(V, G, Done, LG0, LGF).
when_suspend(?=(X,Y), G, Done, LG0, LGF) :-
try_eq(X, Y, G, Done, LG0, LGF).
when_suspend(ground(X), G, Done, LG0, LGF) :-
try_ground(X, G, Done, LG0, LGF).
try_freeze(V, G, Done, LG0, LGF) :-
var(V),
LGF = ['$coroutining':internal_freeze(V, redo_freeze(Done, V, G))|LG0].
try_eq(X, Y, G, Done, LG0, LGF) :-
'$can_unify'(X, Y, LVars), LVars = [_|_],
LGF = ['$coroutining':dif_suspend_on_lvars(LVars, redo_eq(Done, X, Y, G))|LG0].
try_ground(X, G, Done, LG0, LGF) :-
'$non_ground'(X, Var), % the C predicate that succeds if
% finding out the term is nonground
% and gives the first variable it
% finds. Notice that this predicate
% must know about svars.
LGF = ['$coroutining':internal_freeze(Var, redo_ground(Done, X, G))| LG0].
%
% When executing a when, if nobody succeeded, we need to create suspensions.
%
suspend_when_goals([], _).
suspend_when_goals(['$coroutining':internal_freeze(V, G)|Ls], Done) :-
var(Done), !,
internal_freeze(V, G),
suspend_when_goals(Ls, Done).
suspend_when_goals([dif_suspend_on_lvars(LVars, G)|LG], Done) :-
var(Done), !,
dif_suspend_on_lvars(LVars, G),
suspend_when_goals(LG, Done).
suspend_when_goals([_|_], _).
%
% Support for wait declarations on goals.
% Or we also use the more powerful, SICStus like, "block" declarations.
%
% block or wait declarations must precede the first clause.
%
%
% I am using the simplest solution now: I'll add an extra clause at
% the beginning of the procedure to do this work. This creates a
% choicepoint and make things a bit slower, but it's probably not as
% significant as the remaining overheads.
%
prolog:'$block'(Conds) :-
generate_blocking_code(Conds, _, Code),
'$current_module'(Module),
'$$compile'(Code, Code, 5, Module), fail.
prolog:'$block'(_).
generate_blocking_code(Conds, G, Code) :-
extract_head_for_block(Conds, G),
recorded('$blocking_code','$code'(G,OldConds),R), !,
erase(R),
functor(G, Na, Ar),
'$current_module'(M),
abolish(M:Na, Ar),
generate_blocking_code((Conds,OldConds), G, Code).
generate_blocking_code(Conds, G, (G :- (If, !, when(When, G)))) :-
extract_head_for_block(Conds, G),
recorda('$blocking_code','$code'(G,Conds),_),
generate_body_for_block(Conds, G, If, When).
%
% find out what we are blocking on.
%
extract_head_for_block((C1, _), G) :- !,
extract_head_for_block(C1, G).
extract_head_for_block(C, G) :-
functor(C, Na, Ar),
functor(G, Na, Ar).
%
% If we suspend on the conditions, we should continue
% execution. If we don't suspend we should fail so that we can take
% the next clause. To
% know what we have to do we just test how many variables we suspended
% on ;-).
%
%
% We generate code as follows:
%
% block a(-,-,?)
%
% (var(A1), var(A2) -> true ; fail), !, when((nonvar(A1);nonvar(A2)),G).
%
% block a(-,-,?), a(?,-, -)
%
% (var(A1), var(A2) -> true ; (var(A2), var(A3) -> true ; fail)), !,
% when(((nonvar(A1);nonvar(A2)),(nonvar(A2);nonvar(A3))),G).
generate_body_for_block((C1, C2), G, (Code1 -> true ; Code2), (WhenConds,OtherWhenConds)) :- !,
generate_for_cond_in_block(C1, G, Code1, WhenConds),
generate_body_for_block(C2, G, Code2, OtherWhenConds).
generate_body_for_block(C, G, (Code -> true ; fail), WhenConds) :-
generate_for_cond_in_block(C, G, Code, WhenConds).
generate_for_cond_in_block(C, G, Code, Whens) :-
C =.. [_|Args],
G =.. [_|GArgs],
fetch_out_variables_for_block(Args,GArgs,L0Vars),
add_blocking_vars(L0Vars, LVars),
generate_for_each_arg_in_block(LVars, Code, Whens).
add_blocking_vars([], [_]) :- !.
add_blocking_vars(LV, LV).
fetch_out_variables_for_block([], [], []).
fetch_out_variables_for_block(['?'|Args], [_|GArgs], LV) :-
fetch_out_variables_for_block(Args, GArgs, LV).
fetch_out_variables_for_block(['-'|Args], [GArg|GArgs],
[GArg|LV]) :-
fetch_out_variables_for_block(Args, GArgs, LV).
generate_for_each_arg_in_block([], false, true).
generate_for_each_arg_in_block([V], var(V), nonvar(V)) :- !.
generate_for_each_arg_in_block([V|L], (var(V),If), (nonvar(V);Whens)) :-
generate_for_each_arg_in_block(L, If, Whens).
%
% The wait declaration is a simpler and more efficient version of block.
%
prolog:'$wait'(Na/Ar) :-
functor(S, Na, Ar),
arg(1, S, A),
'$current_module'(M),
'$$compile'((S :- var(A), !, freeze(A, S)), (S :- var(A), !, freeze(A, S)), 5, M), fail.
prolog:'$wait'(_).
frozen(V, G) :- nonvar(V), !,
'$do_error'(uninstantiation_error(V),frozen(V,G)).
frozen(V, LG) :-
'$attributes':get_conj_from_attvars([V], LG).
%internal_freeze(V,G) :-
% attributes:get_att(V, 0, Gs), write(G+Gs),nl,fail.
internal_freeze(V,G) :-
update_att(V, G).
update_att(V, G) :-
attributes:get_module_atts(V, '$coroutining'(_,Gs)),
not_vmember(G, Gs), !,
attributes:put_module_atts(V, '$coroutining'(_,[G|Gs])).
update_att(V, G) :-
attributes:put_module_atts(V, '$coroutining'(_,[G])).
not_vmember(_, []).
not_vmember(V, [V1|DonesSoFar]) :-
V \== V1,
not_vmember(V, DonesSoFar).
first_att(T, V) :-
term_variables(T, Vs),
check_first_attvar(Vs, V).
check_first_attvar(V.Vs, V0) :- attvar(V), !, V == V0.
check_first_attvar(_.Vs, V0) :-
check_first_attvar(Vs, V0).
yap-6.2.2/pl/debug.yap 000755 000765 000024 00000066631 11476553440 014514 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: debug.pl *
* Last rev: *
* mods: *
* comments: YAP's debugger *
* *
*************************************************************************/
/*-----------------------------------------------------------------------------
Debugging / creating spy points
-----------------------------------------------------------------------------*/
:- op(900,fx,[spy,nospy]).
% First part : setting and reseting spy points
% $suspy does most of the work
'$suspy'(V,S,M) :- var(V) , !,
'$do_error'(instantiation_error,M:spy(V,S)).
'$suspy'((M:S),P,_) :- !,
'$suspy'(S,P,M).
'$suspy'([],_,_) :- !.
'$suspy'([F|L],S,M) :- !, ( '$suspy'(F,S,M) ; '$suspy'(L,S,M) ).
'$suspy'(F/N,S,M) :- !,
functor(T,F,N),
'$do_suspy'(S, F, N, T, M).
'$suspy'(A,S,M) :- atom(A), !,
'$suspy_predicates_by_name'(A,S,M).
'$suspy'(P,spy,M) :- !,
'$do_error'(domain_error(predicate_spec,P),spy(M:P)).
'$suspy'(P,nospy,M) :-
'$do_error'(domain_error(predicate_spec,P),nospy(M:P)).
'$suspy_predicates_by_name'(A,S,M) :-
% just check one such predicate exists
(
current_predicate(A,M:_)
->
M = EM,
A = NA
;
recorded('$import','$import'(EM,M,GA,_,A,_),_),
functor(GA,NA,_)
),
!,
'$do_suspy_predicates_by_name'(NA,S,EM).
'$suspy_predicates_by_name'(A,spy,M) :- !,
print_message(warning,no_match(spy(M:A))).
'$suspy_predicates_by_name'(A,nospy,M) :-
print_message(warning,no_match(nospy(M:A))).
'$do_suspy_predicates_by_name'(A,S,M) :-
current_predicate(A,M:T),
functor(T,A,N),
'$do_suspy'(S, A, N, T, M).
'$do_suspy_predicates_by_name'(A, S, M) :-
recorded('$import','$import'(EM,M,T0,_,A,N),_),
functor(T0,A0,N0),
'$do_suspy'(S, A0, N0, T, EM).
%
% protect against evil arguments.
%
'$do_suspy'(S, F, N, T, M) :-
recorded('$import','$import'(EM,M,T0,_,F,N),_), !,
functor(T0, F0, N0),
'$do_suspy'(S, F0, N0, T, EM).
'$do_suspy'(S, F, N, T, M) :-
'$undefined'(T,M), !,
( S = spy ->
print_message(warning,no_match(spy(M:F/N)))
;
print_message(warning,no_match(nospy(M:F/N)))
).
'$do_suspy'(S, F, N, T, M) :-
'$system_predicate'(T,M),
'$flags'(T,M,F,F),
F /\ 0x118dd080 =\= 0,
( S = spy ->
'$do_error'(permission_error(access,private_procedure,T),spy(M:F/N))
;
'$do_error'(permission_error(access,private_procedure,T),nospy(M:F/N))
).
'$do_suspy'(S, F, N, T, M) :-
'$undefined'(T,M), !,
( S = spy ->
print_message(warning,no_match(spy(M:F/N)))
;
print_message(warning,no_match(nospy(M:F/N)))
).
'$do_suspy'(S,F,N,T,M) :-
'$suspy2'(S,F,N,T,M).
'$suspy2'(spy,F,N,T,M) :-
recorded('$spy','$spy'(T,M),_), !,
print_message(informational,breakp(bp(debugger,plain,M:T,M:F/N,N),add,already)).
'$suspy2'(spy,F,N,T,M) :- !,
recorda('$spy','$spy'(T,M),_),
'$set_spy'(T,M),
print_message(informational,breakp(bp(debugger,plain,M:T,M:F/N,N),add,ok)).
'$suspy2'(nospy,F,N,T,M) :-
recorded('$spy','$spy'(T,M),R), !,
erase(R),
'$rm_spy'(T,M),
print_message(informational,breakp(bp(debugger,plain,M:T,M:F/N,N),remove,last)).
'$suspy2'(nospy,F,N,_,M) :-
print_message(informational,breakp(no,breakpoint_for,M:F/N)).
'$pred_being_spied'(G, M) :-
recorded('$spy','$spy'(G,M),_), !.
spy Spec :-
'$notrace'(prolog:debug_action_hook(spy(Spec))), !.
spy L :-
'$current_module'(M),
'$suspy'(L, spy, M), fail.
spy _ :- debug.
nospy Spec :-
'$notrace'(prolog:debug_action_hook(nospy(Spec))), !.
nospy L :-
'$current_module'(M),
'$suspy'(L, nospy, M), fail.
nospy _.
nospyall :-
'$notrace'(prolog:debug_action_hook(nospyall)), !.
nospyall :-
recorded('$spy','$spy'(T,M),_), functor(T,F,N), '$suspy'(F/N,nospy,M), fail.
nospyall.
% debug mode -> debug flag = 1
debug :-
( nb_getval('$spy_gn',L) -> true ; nb_setval('$spy_gn',1) ),
'$start_debugging'(on),
print_message(informational,debug(debug)).
'$start_debugging'(Mode) :-
(Mode == on ->
'$debug_on'(true)
;
'$debug_on'(false)
),
nb_setval('$debug_run',off),
nb_setval('$debug_jump',false).
nodebug :-
'$debug_on'(false),
nb_setval('$trace',off),
print_message(informational,debug(off)).
%
% remove any debugging info after an abort.
%
trace :-
nb_getval('$trace',on), !.
trace :-
nb_setval('$trace',on),
'$start_debugging'(on),
print_message(informational,debug(trace)),
'$creep'.
notrace :-
nodebug.
/*-----------------------------------------------------------------------------
leash
-----------------------------------------------------------------------------*/
leash(X) :- var(X),
'$do_error'(instantiation_error,leash(X)).
leash(X) :-
'$leashcode'(X,Code),
set_value('$leash',Code),
'$show_leash'(informational,Code), !.
leash(X) :-
'$do_error'(type_error(leash_mode,X),leash(X)).
'$show_leash'(Msg,0) :-
print_message(Msg,leash([])).
'$show_leash'(Msg,Code) :-
'$check_leash_bit'(Code,0x8,L3,call,LF),
'$check_leash_bit'(Code,0x4,L2,exit,L3),
'$check_leash_bit'(Code,0x2,L1,redo,L2),
'$check_leash_bit'(Code,0x1,[],fail,L1),
print_message(Msg,leash(LF)).
'$check_leash_bit'(Code,Bit,L0,_,L0) :- Bit /\ Code =:= 0, !.
'$check_leash_bit'(_,_,L0,Name,[Name|L0]).
'$leashcode'(full,0xf) :- !.
'$leashcode'(on,0xf) :- !.
'$leashcode'(half,0xb) :- !.
'$leashcode'(loose,0x8) :- !.
'$leashcode'(off,0x0) :- !.
'$leashcode'(none,0x0) :- !.
%'$leashcode'([L|M],Code) :- !, '$leashcode_list'([L|M],Code).
'$leashcode'([L|M],Code) :- !,
'$list2Code'([L|M],Code).
'$leashcode'(N,N) :- integer(N), N >= 0, N =< 0xf.
'$list2Code'(V,_) :- var(V), !,
'$do_error'(instantiation_error,leash(V)).
'$list2Code'([],0) :- !.
'$list2Code'([V|L],_) :- var(V), !,
'$do_error'(instantiation_error,leash([V|L])).
'$list2Code'([call|L],N) :- '$list2Code'(L,N1), N is 0x8 + N1.
'$list2Code'([exit|L],N) :- '$list2Code'(L,N1), N is 0x4 + N1.
'$list2Code'([redo|L],N) :- '$list2Code'(L,N1), N is 0x2 + N1.
'$list2Code'([fail|L],N) :- '$list2Code'(L,N1), N is 0x1 + N1.
/*-----------------------------------------------------------------------------
debugging
-----------------------------------------------------------------------------*/
debugging :-
prolog:debug_action_hook(nospyall), !.
debugging :-
( '$debug_on'(true) ->
print_message(help,debug(debug))
;
print_message(help,debug(off))
),
findall(M:(N/A),(recorded('$spy','$spy'(T,M),_),functor(T,N,A)),L),
print_message(help,breakpoints(L)),
get_value('$leash',Leash),
'$show_leash'(help,Leash).
/*-----------------------------------------------------------------------------
spy
-----------------------------------------------------------------------------*/
% ok, I may have a spy point for this goal, or not.
% if I do, I should check what mode I am in.
% Goal/Mode Have Spy Not Spied
% Creep Stop Stop
% Leap Stop Create CP
% Skip Create CP Create CP
% FastLeap Stop Ignore
% FastIgnore Ignore Ignore
% flag description initial possible values
% spy_gn goal number 1 1...
% spy_trace trace 0 0, 1
% spy_skip leap off Num (stop level)
% debug_prompt stop at spy points on on,off
% a flip-flop is also used
% when 1 spying is enabled *(the same as spy stop).
%'$spy'(G) :- write(user_error,'$spy'(G)), nl, fail.
%
% handle suspended goals
% take care with hidden goals.
%
% $spy may be called from user code, so be careful.
'$spy'([Mod|G]) :-
'$debug_on'(F), F = false, !,
'$execute_nonstop'(G,Mod).
'$spy'([Mod|G]) :-
nb_getval('$system_mode',on), !,
'$execute_nonstop'(G,Mod).
'$spy'([Mod|G]) :-
CP is '$last_choice_pt',
'$do_spy'(G, Mod, CP, no).
% last argument to do_spy says that we are at the end of a context. It
% is required to know whether we are controlled by the debugger.
'$do_spy'(V, M, CP, Flag) :- var(V), !, '$do_spy'(call(V), M, CP, Flag).
'$do_spy'(!, _, CP, _) :- !, '$$cut_by'(CP).
'$do_spy'('$cut_by'(M), _, _, _) :- !, '$$cut_by'(M).
'$do_spy'(true, _, _, _) :- !.
%'$do_spy'(fail, _, _, _) :- !, fail.
'$do_spy'(M:G, _, CP, CalledFromDebugger) :- !,
'$do_spy'(G, M, CP, CalledFromDebugger).
'$do_spy'((A,B), M, CP, CalledFromDebugger) :- !,
'$do_spy'(A, M, CP, yes),
'$do_spy'(B, M, CP, CalledFromDebugger).
'$do_spy'((T->A;B), M, CP, CalledFromDebugger) :- !,
( '$do_spy'(T, M, CP, yes) -> '$do_spy'(A, M, CP, yes)
;
'$do_spy'(B, M, CP, CalledFromDebugger)
).
'$do_spy'((T->A|B), M, CP, CalledFromDebugger) :- !,
( '$do_spy'(T, M, CP, yes) -> '$do_spy'(A, M, CP, yes)
;
'$do_spy'(B, M, CP, CalledFromDebugger)
).
'$do_spy'((T->A), M, CP, _) :- !,
( '$do_spy'(T, M, CP, yes) -> '$do_spy'(A, M, CP, yes) ).
'$do_spy'((A;B), M, CP, CalledFromDebugger) :- !,
(
'$do_spy'(A, M, CP, yes)
;
'$do_spy'(B, M, CP, CalledFromDebugger)
).
'$do_spy'((A|B), M, CP, CalledFromDebugger) :- !,
(
'$do_spy'(A, M, CP, yes)
;
'$do_spy'(B, M, CP, CalledFromDebugger)
).
'$do_spy'((\+G), M, CP, CalledFromDebugger) :- !,
\+ '$do_spy'(G, M, CP, CalledFromDebugger).
'$do_spy'((not(G)), M, CP, CalledFromDebugger) :- !,
\+ '$do_spy'(G, M, CP, CalledFromDebugger).
'$do_spy'(G, Module, _, CalledFromDebugger) :-
nb_getval('$spy_gn',L), /* get goal no. */
L1 is L+1, /* bump it */
nb_setval('$spy_gn',L1), /* and save it globaly */
b_getval('$spy_glist',History), /* get goal list */
b_setval('$spy_glist',[info(L,Module,G,_Retry,_Det,_HasFoundAnswers)|History]), /* and update it */
'$loop_spy'(L, G, Module, CalledFromDebugger). /* set creep on */
% we are skipping, so we can just call the goal,
% while leaving the minimal structure in place.
'$loop_spy'(GoalNumber, G, Module, CalledFromDebugger) :-
yap_hacks:current_choice_point(CP),
'$system_catch'('$loop_spy2'(GoalNumber, G, Module, CalledFromDebugger, CP),
Module, error(Event,Context),
'$loop_spy_event'(error(Event,Context), GoalNumber, G, Module, CalledFromDebugger)).
% handle weird things happening in the debugger.
'$loop_spy_event'('$pass'(Event), _, _, _, _) :- !,
throw(Event).
'$loop_spy_event'(error('$retry_spy'(G0),_), GoalNumber, G, Module, CalledFromDebugger) :-
G0 >= GoalNumber, !,
'$loop_spy'(GoalNumber, G, Module, CalledFromDebugger).
'$loop_spy_event'(error('$retry_spy'(GoalNumber),_), _, _, _, _) :- !,
throw(error('$retry_spy'(GoalNumber),[])).
'$loop_spy_event'(error('$fail_spy'(G0),_), GoalNumber, G, Module, CalledFromDebugger) :-
G0 >= GoalNumber, !,
'$loop_fail'(GoalNumber, G, Module, CalledFromDebugger).
'$loop_spy_event'(error('$fail_spy'(GoalNumber),_), _, _, _, _) :- !,
throw(error('$fail_spy'(GoalNumber),[])).
'$loop_spy_event'(error('$done_spy'(G0),_), GoalNumber, G, _, CalledFromDebugger) :-
G0 >= GoalNumber, !,
'$continue_debugging'(CalledFromDebugger).
'$loop_spy_event'(error('$done_spy'(GoalNumber),_), _, _, _, _) :- !,
throw(error('$done_spy'(GoalNumber),[])).
'$loop_spy_event'(Event, GoalNumber, G, Module, CalledFromDebugger) :-
'$debug_error'(Event),
'$system_catch'(
('$trace'(exception(Event),G,Module,GoalNumber,_),fail),
Module,
error(NewEvent,NewContext),
'$loop_spy_event'(error(NewEvent,NewContext), GoalNumber, G, Module, CalledFromDebugger)
).
'$debug_error'(Event) :-
'$Error'(Event), fail.
'$debug_error'(_).
% just fail here, don't really need to call debugger, the user knows what he
% wants to do
'$loop_fail'(_GoalNumber, _G, _Module, _CalledFromDebugger) :-
'$continue_debugging'(CalledFromDebugger),
fail.
% if we are in
'$loop_spy2'(GoalNumber, G0, Module, CalledFromDebugger, CP) :-
/* the following choice point is where the predicate is called */
(
'$is_metapredicate'(G0, Module)
->
'$meta_expansion'(G0,Module,Module,Module,G,[])
;
G = G0
),
b_getval('$spy_glist',[Info|_]), /* get goal list */
Info = info(_,_,_,Retry,Det,false),
(
/* call port */
'$enter_goal'(GoalNumber, G, Module),
'$spycall'(G, Module, CalledFromDebugger, Retry),
'$disable_docreep',
(
'$debugger_deterministic_goal'(G) ->
Det=true
;
Det=false
),
/* go execute the predicate */
(
Retry = false ->
/* found an answer, so it can redo */
nb_setarg(6, Info, true),
'$show_trace'(exit,G,Module,GoalNumber,Det), /* output message at exit */
/* exit port */
/* get rid of deterministic computations */
(
Det == true
->
'$$cut_by'(CP)
;
true
),
'$continue_debugging'(CalledFromDebugger)
;
/* backtracking from exit */
/* we get here when we want to redo a goal */
/* redo port */
'$disable_docreep',
(
arg(6, Info, true)
->
'$show_trace'(redo,G,Module,GoalNumber,_), /* inform user_error */
nb_setarg(6, Info, false)
;
true
),
'$continue_debugging'(CalledFromDebugger),
fail /* to backtrack to spycalls */
)
;
'$show_trace'(fail,G,Module,GoalNumber,_), /* inform at fail port */
'$continue_debugging'(CalledFromDebugger),
/* fail port */
fail
).
'$enter_goal'(GoalNumber, G, Module) :-
'$zip'(GoalNumber, G, Module), !.
'$enter_goal'(GoalNumber, G, Module) :-
'$trace'(call, G, Module, GoalNumber, _).
'$show_trace'(_, G, Module, GoalNumber,_) :-
'$zip'(GoalNumber, G, Module), !.
'$show_trace'(P,G,Module,GoalNumber,Deterministic) :-
'$trace'(P,G,Module,GoalNumber,Deterministic).
%
% skip a goal or a port
%
'$zip'(GoalNumber, G, Module) :-
nb_getval('$debug_run',StopPoint),
% zip mode off, we cannot zip
StopPoint \= off,
(
% skip spy points (eg, s).
StopPoint == spy
->
\+ '$pred_being_spied'(G, Module)
;
% skip goals (eg, l).
number(StopPoint)
->
StopPoint < GoalNumber
).
%
'$spycall'(G, M, _, _) :-
nb_getval('$debug_jump',true),
!,
'$execute_nonstop'(G,M).
'$spycall'(G, M, _, _) :-
'$system_predicate'(G,M),
\+ '$is_metapredicate'(G,M), !,
'$execute'(M:G).
'$spycall'(G, M, _, _) :-
'$system_module'(M), !,
'$execute'(M:G).
'$spycall'(G, M, _, _) :-
'$tabled_predicate'(G,M),
!,
'$continue_debugging'(no, '$execute_nonstop'(G,M)).
'$spycall'(G, M, CalledFromDebugger, InRedo) :-
'$flags'(G,M,F,F),
F /\ 0x18402000 =\= 0, !, % dynamic procedure, logical semantics, user-C, or source
% use the interpreter
CP is '$last_choice_pt',
'$clause'(G, M, Cl, _),
% I may backtrack to here from far away
'$disable_docreep',
( '$do_spy'(Cl, M, CP, CalledFromDebugger) ; InRedo = true ).
'$spycall'(G, M, CalledFromDebugger, InRedo) :-
'$undefined'(G, M), !,
'$find_goal_definition'(M, G, NM, Goal),
'$spycall'(Goal, NM, CalledFromDebugger, InRedo).
'$spycall'(G, M, _, InRedo) :-
% I lost control here.
CP is '$last_choice_pt',
'$static_clause'(G,M,_,R),
% I may backtrack to here from far away
'$disable_docreep',
(
'$continue_debugging'(no, '$execute_clause'(G, M, R, CP))
;
InRedo = true
).
'$tabled_predicate'(G,M) :-
'$flags'(G,M,F,F),
F /\ 0x00000040 =\= 0.
'$trace'(P,G,Module,L,Deterministic) :-
% at this point we are done with leap or skip
nb_setval('$debug_run',off),
% make sure we run this code outside debugging mode.
'$debug_on'(false),
repeat,
'$trace_msg'(P,G,Module,L,Deterministic),
(
'$unleashed'(P) ->
'$action'(10,P,L,G,Module,Debug),
put_code(user_error, 10)
;
write(user_error,' ? '), get0(user_input,C),
'$action'(C,P,L,G,Module,Debug)
),
(Debug = on
->
'$debug_on'(true)
;
Debug = zip
->
'$debug_on'(true)
;
'$debug_on'(false)
),
!.
'$trace_msg'(P,G,Module,L,Deterministic) :-
flush_output(user_output),
flush_output(user_error),
functor(P,P0,_),
(P = exit, Deterministic \= true -> Det = '?' ; Det = ' '),
('$pred_being_spied'(G,Module) -> CSPY = '*' ; CSPY = ' '),
% vsc: fix this
% ( SL = L -> SLL = '>' ; SLL = ' '),
SLL = ' ',
( Module\=prolog,
Module\=user
->
GW = Module:G
;
GW = G
),
format(user_error,'~a~a~a (~d) ~q:',[Det,CSPY,SLL,L,P0]),
'$debugger_write'(user_error,GW).
'$unleashed'(call) :- get_value('$leash',L), L /\ 2'1000 =:= 0. %'
'$unleashed'(exit) :- get_value('$leash',L), L /\ 2'0100 =:= 0. %'
'$unleashed'(redo) :- get_value('$leash',L), L /\ 2'0010 =:= 0. %'
'$unleashed'(fail) :- get_value('$leash',L), L /\ 2'0001 =:= 0. %'
% the same as fail.
'$unleashed'(exception(_)) :- get_value('$leash',L), L /\ 2'0001 =:= 0. %'
'$debugger_write'(Stream, G) :-
recorded('$print_options','$debugger'(OUT),_), !,
write_term(Stream, G, OUT).
'$debugger_write'(Stream, G) :-
writeq(Stream, G).
'$action'(13,P,CallNumber,G,Module,Zip) :- !, % newline creep
get0(user_input,C),
'$action'(C,P,CallNumber,G,Module,Zip).
%'$action'(10,_,_,_,_,on) :- % newline creep
% nb_setval('$debug_jump',false).
'$action'(10,_,_,_,_,on) :- !, % newline creep
nb_setval('$debug_jump',false).
'$action'(0'!,_,_,_,_,_) :- !, % ! 'g execute
read(user,G),
% don't allow yourself to be caught by creep.
'$debug_on'(OldDeb),
'$debug_on'(false),
( '$execute'(G) -> true ; true),
'$debug_on'(OldDeb),
% '$skipeol'(0'!), % '
fail.
'$action'(0'<,_,_,_,_,_) :- !, % <'Depth
'$new_deb_depth',
'$skipeol'(0'<),
fail.
'$action'(0'^,_,_,G,_,_) :- !, % '
'$print_deb_sterm'(G),
'$skipeol'(0'^),
fail.
'$action'(0'a,_,_,_,_,off) :- !, % 'a abort
'$skipeol'(0'a),
abort.
'$action'(0'b,_,_,_,_,_) :- !, % 'b break
'$skipeol'(0'b),
break,
fail.
'$action'(0'A,_,_,_,_,_) :- !, % 'b break
'$skipeol'(0'A),
'$show_choicepoint_stack',
fail.
'$action'(0'c,_,_,_,_,on) :- !, % 'c creep
'$skipeol'(0'c),
nb_setval('$debug_jump',false).
'$action'(0'e,_,_,_,_,_) :- !, % 'e exit
'$skipeol'(0'e),
halt.
'$action'(0'f,_,CallId,_,_,_) :- !, % 'f fail
'$scan_number'(0'f, CallId, GoalId), %'f
throw(error('$fail_spy'(GoalId),[])).
'$action'(0'h,_,_,_,_,_) :- !, % 'h help
'$action_help',
'$skipeol'(104),
fail.
'$action'(0'?,_,_,_,_,_) :- !, % '? help
'$action_help',
'$skipeol'(104),
fail.
'$action'(0'p,_,_,G,Module,_) :- !, % 'p print
((Module = prolog ; Module = user) ->
print(user_error,G), nl(user_error)
;
print(user_error,Module:G), nl(user_error)
),
'$skipeol'(0'p),
fail.
'$action'(0'd,_,_,G,Module,_) :- !, % 'd display
((Module = prolog ; Module = user) ->
display(user_error,G), nl(user_error)
;
display(user_error,Module:G), nl(user_error)
),
'$skipeol'(0'd),
fail.
'$action'(0'l,_,_,_,_,on) :- !, % 'l leap
'$skipeol'(0'l),
nb_setval('$debug_run',spy),
nb_setval('$debug_jump',false).
'$action'(0'z,_,_,_,_,zip) :- !, % 'z zip, fast leap
'$skipeol'(0'z), % 'z
nb_setval('$debug_run',spy),
nb_setval('$debug_jump',true).
% skip first call (for current goal),
% stop next time.
'$action'(0'k,_,_,_,_,zip) :- !, % 'k zip, fast leap
'$skipeol'(0'k), % '
nb_setval('$debug_run',spy),
nb_setval('$debug_jump',true).
% skip first call (for current goal),
% stop next time.
'$action'(0'n,_,_,_,_,off) :- !, % 'n nodebug
'$skipeol'(0'n), % '
% tell debugger never to stop.
nb_setval('$debug_run', -1),
nb_setval('$debug_jump',true),
nodebug.
'$action'(0'r,_,CallId,_,_,_) :- !, % 'r retry
'$scan_number'(0'r,CallId,ScanNumber), % '
'$debug_on'(true),
throw(error('$retry_spy'(ScanNumber),[])).
'$action'(0's,P,CallNumber,_,_,on) :- !, % 's skip
'$skipeol'(0's), % '
( (P=call; P=redo) ->
nb_setval('$debug_run',CallNumber),
nb_setval('$debug_jump',false)
;
'$ilgl'(0's) % '
).
'$action'(0't,P,CallNumber,_,_,zip) :- !, % 't fast skip
'$skipeol'(0't), % '
( (P=call; P=redo) ->
nb_setval('$debug_run',CallNumber),
nb_setval('$debug_jump',true)
;
'$ilgl'(0't) % '
).
'$action'(0'+,_,_,G,M,_) :- !, % '+ spy this
functor(G,F,N), spy(M:(F/N)),
'$skipeol'(0'+), % '
fail.
'$action'(0'-,_,_,G,M,_) :- !, % '- nospy this
functor(G,F,N), nospy(M:(F/N)),
'$skipeol'(0'-), % '
fail.
'$action'(0'g,_,_,_,_,_) :- !, % 'g ancestors
'$scan_number'(0'g,-1,HowMany), % '
'$show_ancestors'(HowMany),
fail.
'$action'(C,_,_,_,_,_) :-
'$skipeol'(C),
'$ilgl'(C),
fail.
'$continue_debugging'(yes).
% do not need to debug!
'$continue_debugging'(no) :-
'$creep'.
% if we are in the interpreter, don't need to care about forcing a trace, do we?
'$continue_debugging'(yes,G) :- !,
'$execute_dgoal'(G).
% do not need to debug!
'$continue_debugging'(_,G) :-
'nb_getval'('$debug_run',Zip),
(Zip == nodebug ; number(Zip) ; Zip = spy(_) ), !,
'$execute_dgoal'(G).
'$continue_debugging'(_,G) :-
'$execute_creep_dgoal'(G).
'$execute_dgoal'('$execute_nonstop'(G,M)) :-
'$execute_nonstop'(G,M).
'$execute_dgoal'('$execute_clause'(G, M, R, CP)) :-
'$execute_clause'(G, M, R, CP).
'$execute_creep_dgoal'('$execute_nonstop'(G,M)) :-
'$signal_creep',
'$execute_nonstop'(G,M).
'$execute_creep_dgoal'('$execute_clause'(G, M, R, CP)) :-
'$signal_creep',
'$execute_clause'(G, M, R, CP).
'$show_ancestors'(HowMany) :-
b_getval('$spy_glist',[_|History]),
(
History == []
->
print_message(help, ancestors([]))
;
'$show_ancestors'(History,HowMany),
nl(user_error)
).
'$show_ancestors'([],_).
'$show_ancestors'([_|_],0) :- !.
'$show_ancestors'([info(L,M,G,Retry,Det,_Exited)|History],HowMany) :-
'$show_ancestor'(L,M,G,Retry,Det,HowMany,HowMany1),
'$show_ancestors'(History,HowMany1).
% skip exit port, we're looking at true ancestors
'$show_ancestor'(_,_,_,_,Det,HowMany,HowMany) :-
nonvar(Det), !.
% look at retry
'$show_ancestor'(GoalNumber, M, G, Retry, _, HowMany, HowMany1) :-
nonvar(Retry), !,
HowMany1 is HowMany-1,
'$trace_msg'(redo, G, M, GoalNumber, _), nl(user_error).
'$show_ancestor'(GoalNumber, M, G, _, _, HowMany, HowMany1) :-
HowMany1 is HowMany-1,
'$trace_msg'(call, G, M, GoalNumber, _), nl(user_error).
'$action_help' :-
format(user_error,'newline creep a abort~n', []),
format(user_error,'c creep e exit~n', []),
format(user_error,'f Goal fail h help~n', []),
format(user_error,'l leap r Goal retry~n', []),
format(user_error,'s skip t fastskip~n', []),
format(user_error,'q quasiskip k quasileap~n', []),
format(user_error,'b break n no debug~n', []),
format(user_error,'p print d display~n', []),
format(user_error,' 0.
'$scan_number3'( C, Nb0, Nb) :-
C >= "0", C =< "9",
NbI is Nb0*10+(C-"0"),
get0(user, NC),
'$scan_number3'( NC, NbI, Nb).
'$print_deb_sterm'(G) :-
'$get_sterm_list'(L), !,
'$deb_get_sterm_in_g'(L,G,A),
recorda('$debug_sub_skel',L,_),
format(user_error,'~n~w~n~n',[A]).
'$print_deb_sterm'(_) :- '$skipeol'(94).
'$get_sterm_list'(L) :-
get0(user_input,C),
'$deb_inc_in_sterm_oldie'(C,L0,CN),
'$get_sterm_list'(L0,CN,0,L).
'$deb_inc_in_sterm_oldie'(94,L0,CN) :- !,
get0(user_input,CN),
( recorded('$debug_sub_skel',L0,_) -> true ;
CN = [] ).
'$deb_inc_in_sterm_oldie'(C,[],C).
'$get_sterm_list'(L0,C,N,L) :-
( C =:= "^", N =\= 0 -> get0(CN),
'$get_sterm_list'([N|L0],CN,0,L) ;
C >= "0", C =< "9" -> NN is 10*N+C-"0", get0(CN),
'$get_sterm_list'(L0,CN,NN,L);
C =:= 10 -> (N =:= 0 -> L = L0 ; L=[N|L0]) ).
'$deb_get_sterm_in_g'([],G,G).
'$deb_get_sterm_in_g'([H|T],G,A) :-
'$deb_get_sterm_in_g'(T,G,A1),
arg(H,A1,A).
'$new_deb_depth' :-
get0(user_input,C),
'$get_deb_depth'(C,D),
'$set_deb_depth'(D).
'$get_deb_depth'(10,10) :- !. % default depth is 0
'$get_deb_depth'(C,XF) :-
'$get_deb_depth_char_by_char'(C,0,XF).
'$get_deb_depth_char_by_char'(10,X,X) :- !.
'$get_deb_depth_char_by_char'(C,X0,XF) :-
C >= "0", C =< "9", !,
XI is X0*10+C-"0",
get0(user_input,NC),
'$get_deb_depth_char_by_char'(NC,XI,XF).
% reset when given garbage.
'$get_deb_depth_char_by_char'(C,_,10) :- '$skipeol'(C).
'$set_deb_depth'(D) :-
recorded('$print_options','$debugger'(L),R), !,
'$delete_if_there'(L, max_depth(_), LN),
erase(R),
recorda('$print_options','$debugger'([max_depth(D)|LN]),_).
'$set_deb_depth'(D) :-
recorda('$print_options','$debugger'([quoted(true),numbervars(true),portrayed(true),max_depth(D)]),_).
'$delete_if_there'([], _, []).
'$delete_if_there'([T|L], T, LN) :- !,
'$delete_if_there'(L, T, LN).
'$delete_if_there'([Q|L], T, [Q|LN]) :-
'$delete_if_there'(L, T, LN).
'$show_choicepoint_stack' :-
yap_hacks:current_choicepoints(Cps),
length(Cps,Level),
'$debug_show_cps'(Cps,Level).
'$debug_show_cps'([],_).
'$debug_show_cps'([C|Cps],Level) :-
'$debug_show_cp'(C, Level),
Level1 is Level-1,
'$debug_show_cps'(Cps, Level1).
'$debug_show_cp'(C, Level) :-
yap_hacks:choicepoint(C,_,Module,Name,Arity,Goal,_),
'$continue_debug_show_cp'(Module,Name,Arity,Goal,Level).
'$continue_debug_show_cp'(prolog,'$do_live',0,(_;_),Level) :- !,
format(user_error,' [~d] \'$toplevel\'',[Level]).
'$continue_debug_show_cp'(prolog,'$do_log_upd_clause',4,'$do_log_upd_clause'(_,_,Goal,_),Level) :- !,
format(user_error,' [~d] ',[Level]),
'$debugger_write'(user_error,Goal),
nl(user_error).
'$continue_debug_show_cp'(prolog,'$do_static_clause',5,'$do_static_clause'(_,_,Goal,_,_),Level) :- !,
format(user_error,' [~d] ',[Level]),
'$debugger_write'(user_error,Goal),
nl(user_error).
'$continue_debug_show_cp'(Module,Name,Arity,_,_) :-
functor(G0, Name, Arity),
'$hidden_predicate'(G0,Module),
!.
'$continue_debug_show_cp'(Module,Name,Arity,Goal,Level) :-
var(Goal), !,
format(user_error,' [~d] ~q:~q/~d~n',[Level,Module,Name,Arity]).
'$continue_debug_show_cp'(Module,Name,Arity,(V1;V2),Level) :-
var(V1), var(V2), !,
format(user_error,' [~d] ~q:~q/~d: ;/2~n',[Level,Module,Name,Arity]).
'$continue_debug_show_cp'(_,_,_,G,Level) :-
format(user_error,' [~d] ~q~n',[Level,G]).
'$debugger_deterministic_goal'(G) :-
yap_hacks:current_choicepoints(CPs0),
% $cps(CPs0),
'$debugger_skip_traces'(CPs0,CPs1),
'$debugger_skip_loop_spy2'(CPs1,CPs2),
'$debugger_skip_spycall'(CPs2,CPs3),
'$debugger_skip_loop_spy2'(CPs3,[Catch|_]),
yap_hacks:choicepoint(Catch,_,prolog,'$catch',3,'$catch'(_,'$loop_spy_event'(_,_,G,_,_),_),_).
'$cps'([CP|CPs]) :-
yap_hacks:choicepoint(CP,A,B,C,D,E,F),
write(A:B:C:D:E:F),nl,
'$cps'(CPs).
'$cps'([]).
'$debugger_skip_spycall'([CP|CPs],CPs1) :-
yap_hacks:choicepoint(CP,_,prolog,'$spycall',4,(_;_),_), !,
'$debugger_skip_spycall'(CPs,CPs1).
'$debugger_skip_spycall'(CPs,CPs).
'$debugger_skip_traces'([CP|CPs],CPs1) :-
yap_hacks:choicepoint(CP,_,prolog,'$trace',4,(_;_),_), !,
'$debugger_skip_traces'(CPs,CPs1).
'$debugger_skip_traces'(CPs,CPs).
'$debugger_skip_loop_spy2'([CP|CPs],CPs1) :-
yap_hacks:choicepoint(CP,_,prolog,'$loop_spy2',5,(_;_),_), !,
'$debugger_skip_loop_spy2'(CPs,CPs1).
'$debugger_skip_loop_spy2'(CPs,CPs).
yap-6.2.2/pl/depth_bound.yap 000644 000765 000024 00000001276 11457004725 015704 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: corout.pl *
* Last rev: *
* mods: *
* comments: Coroutines implementation *
* *
*************************************************************************/
%depth_bound_call(A,D) :-
%write(depth_bound_call(A,D)), nl, fail.
depth_bound_call(A,D) :-
'$execute_under_depth_limit'(A,D).
yap-6.2.2/pl/dialect.yap 000644 000765 000024 00000004147 11457004725 015016 0 ustar 00vsc staff 000000 000000 :- module(dialect,
[
exists_source/1,
source_exports/2
]).
prolog:'$expects_dialect'(yap) :- !,
eraseall('$dialect'),
recorda('$dialect',yap,_).
prolog:'$expects_dialect'(Dialect) :-
check_dialect(Dialect),
eraseall('$dialect'),
load_files(library(dialect/Dialect),[silent(true),if(not_loaded)]),
( current_predicate(Dialect:setup_dialect/0)
-> Dialect:setup_dialect
; true
),
recorda('$dialect',Dialect,_).
check_dialect(Dialect) :-
var(Dialect),!,
'$do_error'(instantiation_error,(:- dialect(Dialect))).
check_dialect(Dialect) :-
\+ atom(Dialect),!,
'$do_error'(type_error(Dialect),(:- dialect(Dialect))).
check_dialect(Dialect) :-
exists_source(library(dialect/Dialect)), !.
check_dialect(Dialect) :-
'$do_error'(domain_error(dialect,Dialect),(:- dialect(Dialect))).
%% exists_source(+Source) is semidet.
%
% True if Source (a term valid for load_files/2) exists. Fails
% without error if this is not the case. The predicate is intended
% to be used with :- if, as in the example below. See also
% source_exports/2.
%
% ==
% :- if(exists_source(library(error))).
% :- use_module_library(error).
% :- endif.
% ==
exists_source(Source) :-
exists_source(Source, _Path).
exists_source(Source, Path) :-
absolute_file_name(Source, Path,
[ file_type(prolog),
access(read),
file_errors(fail)
]).
%% source_exports(+Source, +Export) is semidet.
%% source_exports(+Source, -Export) is nondet.
%
% True if Source exports Export. Fails without error if this is
% not the case. See also exists_source/1.
%
% @tbd Should we also allow for source_exports(-Source, +Export)?
source_exports(Source, Export) :-
open_source(Source, In),
catch(call_cleanup(exports(In, Exports), close(In)), _, fail),
( ground(Export)
-> memberchk(Export, Exports)
; member(Export, Exports)
).
%% open_source(+Source, -In:stream) is semidet.
%
% Open a source location.
open_source(File, In) :-
exists_source(File, Path),
open(Path, read, In),
( peek_char(In, #)
-> skip(In, 10)
; true
).
exports(In, Exports) :-
read(In, Term),
Term = (:- module(_Name, Exports)).
yap-6.2.2/pl/directives.yap 000644 000765 000024 00000013147 11457004725 015552 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: directives.yap *
* Last rev: *
* mods: *
* comments: directing system execution *
* *
*************************************************************************/
'$all_directives'(_:G1) :- !,
'$all_directives'(G1).
'$all_directives'((G1,G2)) :- !,
'$all_directives'(G1),
'$all_directives'(G2).
'$all_directives'(G) :- !,
'$directive'(G).
'$directive'(block(_)).
'$directive'(char_conversion(_,_)).
'$directive'(compile(_)).
'$directive'(consult(_)).
'$directive'(discontiguous(_)).
'$directive'(dynamic(_)).
'$directive'(elif(_)).
'$directive'(else).
'$directive'(encoding(_)).
'$directive'(endif).
'$directive'(ensure_loaded(_)).
'$directive'(expects_dialect(_)).
'$directive'(if(_)).
'$directive'(include(_)).
'$directive'(initialization(_)).
'$directive'(initialization(_,_)).
'$directive'(meta_predicate(_)).
'$directive'(module(_,_)).
'$directive'(module(_,_,_)).
'$directive'(module_transparent(_)).
'$directive'(multifile(_)).
'$directive'(noprofile(_)).
'$directive'(parallel).
'$directive'(public(_)).
'$directive'(op(_,_,_)).
'$directive'(set_prolog_flag(_,_)).
'$directive'(reconsult(_)).
'$directive'(reexport(_)).
'$directive'(reexport(_,_)).
'$directive'(sequential).
'$directive'(sequential(_)).
'$directive'(thread_initialization(_)).
'$directive'(thread_local(_)).
'$directive'(uncutable(_)).
'$directive'(use_module(_)).
'$directive'(use_module(_,_)).
'$directive'(use_module(_,_,_)).
'$directive'(wait(_)).
'$exec_directives'((G1,G2), Mode, M) :- !,
'$exec_directives'(G1, Mode, M),
'$exec_directives'(G2, Mode, M).
'$exec_directives'(G, Mode, M) :-
'$exec_directive'(G, Mode, M).
'$exec_directive'(multifile(D), _, M) :-
'$system_catch'('$multifile'(D, M), M,
Error,
user:'$LoopError'(Error, top)).
'$exec_directive'(discontiguous(D), _, M) :-
'$discontiguous'(D,M).
'$exec_directive'(initialization(D), _, M) :-
'$initialization'(M:D).
'$exec_directive'(initialization(D,OPT), _, M) :-
'$initialization'(M:D, OPT).
'$exec_directive'(thread_initialization(D), _, M) :-
'$thread_initialization'(M:D).
'$exec_directive'(expects_dialect(D), _, _) :-
'$expects_dialect'(D).
'$exec_directive'(encoding(Enc), _, _) :-
'$set_encoding'(Enc).
'$exec_directive'(parallel, _, _) :-
'$parallel'.
'$exec_directive'(sequential, _, _) :-
'$sequential'.
'$exec_directive'(sequential(G), _, M) :-
'$sequential_directive'(G, M).
'$exec_directive'(parallel(G), _, M) :-
'$parallel_directive'(G, M).
'$exec_directive'(include(F), Status, _) :-
'$include'(F, Status).
'$exec_directive'(module(N,P), Status, _) :-
'$module'(Status,N,P).
'$exec_directive'(module(N,P,Op), Status, _) :-
'$module'(Status,N,P,Op).
'$exec_directive'(meta_predicate(P), _, M) :-
'$meta_predicate'(P, M).
'$exec_directive'(module_transparent(P), _, M) :-
'$module_transparent'(P, M).
'$exec_directive'(noprofile(P), _, M) :-
'$noprofile'(P, M).
'$exec_directive'(dynamic(P), _, M) :-
'$dynamic'(P, M).
'$exec_directive'(thread_local(P), _, M) :-
'$thread_local'(P, M).
'$exec_directive'(op(P,OPSEC,OP), _, _) :-
'$current_module'(M),
op(P,OPSEC,M:OP).
'$exec_directive'(set_prolog_flag(F,V), _, _) :-
set_prolog_flag(F,V).
'$exec_directive'(ensure_loaded(Fs), _, M) :-
'$load_files'(M:Fs, [if(changed)], ensure_loaded(Fs)).
'$exec_directive'(char_conversion(IN,OUT), _, _) :-
char_conversion(IN,OUT).
'$exec_directive'(public(P), _, M) :-
'$public'(P, M).
'$exec_directive'(compile(Fs), _, M) :-
'$load_files'(M:Fs, [], compile(Fs)).
'$exec_directive'(reconsult(Fs), _, M) :-
'$load_files'(M:Fs, [], reconsult(Fs)).
'$exec_directive'(consult(Fs), _, M) :-
'$consult'(Fs, M).
'$exec_directive'(use_module(F), _, M) :-
'$load_files'(M:F, [if(not_loaded)],use_module(F)).
'$exec_directive'(reexport(F), _, M) :-
'$reexport'(F, all, M).
'$exec_directive'(reexport(F,Spec), _, M) :-
'$reexport'(F, Spec, M).
'$exec_directive'(use_module(F,Is), _, M) :-
'$load_files'(M:F, [if(not_loaded),imports(Is)],use_module(F,Is)).
'$exec_directive'(use_module(Mod,F,Is), _, _) :-
'$use_module'(Mod,F,Is).
'$exec_directive'(block(BlockSpec), _, _) :-
'$block'(BlockSpec).
'$exec_directive'(wait(BlockSpec), _, _) :-
'$wait'(BlockSpec).
'$exec_directive'(table(PredSpec), _, M) :-
'$table'(PredSpec, M).
'$exec_directive'(uncutable(PredSpec), _, M) :-
'$uncutable'(PredSpec, M).
'$exec_directive'(if(Goal), Context, M) :-
'$if'(M:Goal, Context).
'$exec_directive'(else, Context, _) :-
'$else'(Context).
'$exec_directive'(elif(Goal), Context, M) :-
'$elif'(M:Goal, Context).
'$exec_directive'(endif, Context, _) :-
'$endif'(Context).
%
% allow users to define their own directives.
%
user_defined_directive(Dir,_) :-
'$directive'(Dir), !.
user_defined_directive(Dir,Action) :-
functor(Dir,Na,Ar),
functor(NDir,Na,Ar),
'$current_module'(M, prolog),
assert_static('$directive'(NDir)),
assert_static(('$exec_directive'(Dir, _, _) :- Action)),
'$current_module'(_, M).
'$thread_initialization'(M:D) :-
eraseall('$thread_initialization'),
recorda('$thread_initialization',M:D,_),
fail.
'$thread_initialization'(M:D) :-
'$initialization'(M:D).
yap-6.2.2/pl/eam.yap 000644 000765 000024 00000004321 11457004725 014145 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* BEAM extends the YAP Prolog system to support the EAM *
* *
* Copyright Ricardo Lopes and Universidade do Porto 2000-2006 *
* *
**************************************************************************
* *
* File: eam.yap *
* Last rev: 6/4/2006 *
* mods: *
* comments: Some utility predicates needed by BEAM *
* *
*************************************************************************/
eamtrans(A,A):- var(A),!.
eamtrans((A,B),(C,D)):- !, eamtrans(A,C),eamtrans(B,D).
eamtrans((X is Y) ,(skip_while_var(Vars), X is Y )):- !, '$variables_in_term'(Y,[],Vars).
eamtrans((X =\= Y),(skip_while_var(Vars), X =\= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X =:= Y),(skip_while_var(Vars), X =:= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X >= Y) ,(skip_while_var(Vars), X >= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X > Y) ,(skip_while_var(Vars), X > Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X < Y) ,(skip_while_var(Vars), X < Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X =< Y) ,(skip_while_var(Vars), X =< Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X @>= Y) ,(skip_while_var(Vars), X @>= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X @> Y) ,(skip_while_var(Vars), X @> Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X @< Y) ,(skip_while_var(Vars), X @< Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X @=< Y) ,(skip_while_var(Vars), X @=< Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X \= Y) ,(skip_while_var(Vars), X \= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans((X \== Y),(skip_while_var(Vars), X \== Y )):- !, '$variables_in_term'(X + Y,[],Vars).
eamtrans(B,B).
eamconsult(File):- eam, eam, %fails if eam is disable
assert((user:term_expansion((A :- B),(A :- C)):- eamtrans(B,C))),
eam, ( consult(File) ; true), eam,
abolish(user:term_expansion,2).
yap-6.2.2/pl/errors.yap 000644 000765 000024 00000023354 11457004725 014726 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: errors.yap *
* comments: error messages for YAP *
* *
* Last rev: $Date: 2008-07-22 23:34:50 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.89 2008/06/12 10:55:52 vsc
* fix syntax error messages
*
* Revision 1.88 2008/04/04 10:02:44 vsc
* implement thread_cancel using signals
* use duplicate_term instead of copy_term in throw: throw may lose
* reference to term.
*
* Revision 1.87 2008/03/17 12:08:28 vsc
* avoid silly message
*
* Revision 1.86 2008/02/23 01:32:31 vsc
* fix chr bootstrap.
*
* Revision 1.85 2008/02/22 15:08:37 vsc
* Big update to support more SICStus/SWI like message handling
* fix YAPSHAREDIR
* fix yap.tex (Bernd)
*
* Revision 1.84 2008/01/23 17:57:55 vsc
* valgrind it!
* enable atom garbage collection.
*
* Revision 1.83 2007/11/26 23:43:10 vsc
* fixes to support threads and assert correctly, even if inefficiently.
*
* Revision 1.82 2007/09/27 23:02:00 vsc
* encoding/1
*
* Revision 1.81 2007/09/27 15:25:34 vsc
* upgrade JPL
*
* Revision 1.80 2007/01/24 14:20:04 vsc
* Fix typos across code
* Change debugger to backtrack more alike byrd model
* Fix typo in debugger option f
*
* Revision 1.79 2006/12/13 16:10:26 vsc
* several debugger and CLP(BN) improvements.
*
* Revision 1.78 2006/05/22 16:12:01 tiagosoares
* MYDDAS: MYDDAS version boot message
*
* Revision 1.77 2006/04/10 19:24:52 vsc
* fix syntax error message handling
* improve redblack trees and use it to reimplement association lists and
* to have better implementation of several graph algorithms.
*
* Revision 1.76 2006/04/05 00:16:55 vsc
* Lots of fixes (check logfile for details
*
* Revision 1.75 2006/02/24 14:26:37 vsc
* fix informational_messages
*
* Revision 1.74 2006/01/26 19:20:00 vsc
* syntax error was giving the offset
*
* Revision 1.73 2006/01/20 04:35:28 vsc
*
* fix error message
*
* Revision 1.72 2005/11/23 13:24:00 vsc
* cleanups in OS interface predicates.
*
* Revision 1.71 2005/11/10 01:27:12 vsc
* fix debugger message for EOF input
* fix fix to setof
* fix profiler spewing out hidden atoms.
*
* Revision 1.70 2005/11/03 18:27:10 vsc
* fix quote
*
* Revision 1.69 2005/11/01 18:54:06 vsc
* small fixes
*
* Revision 1.68 2005/10/29 01:28:37 vsc
* make undefined more ISO compatible.
*
* Revision 1.67 2005/10/28 17:38:50 vsc
* sveral updates
*
* Revision 1.66 2005/10/18 17:04:43 vsc
* 5.1:
* - improvements to GC
* 2 generations
* generic speedups
* - new scheme for attvars
* - hProlog like interface also supported
* - SWI compatibility layer
* - extra predicates
* - global variables
* - moved to Prolog module
* - CLP(R) by Leslie De Koninck, Tom Schrijvers, Cristian Holzbaur, Bart
* Demoen and Jan Wielemacker
* - load_files/2
*
* from 5.0.1
*
* - WIN32 missing include files (untested)
* - -L trouble (my thanks to Takeyuchi Shiramoto-san)!
* - debugging of backtrable user-C preds would core dump.
* - redeclaring a C-predicate as Prolog core dumps.
* - badly protected YapInterface.h.
* - break/0 was failing at exit.
* - YAP_cut_fail and YAP_cut_succeed were different from manual.
* - tracing through data-bases could core dump.
* - cut could break on very large computations.
* - first pass at BigNum issues (reported by Roberto).
* - debugger could get go awol after fail port.
* - weird message on wrong debugger option.
*
* Revision 1.65 2005/05/25 21:43:33 vsc
* fix compiler bug in 1 << X, found by Nuno Fonseca.
* compiler internal errors get their own message.
*
* Revision 1.64 2005/05/25 18:18:02 vsc
* fix error handling
* configure should not allow max-memory and use-malloc at same time
* some extensions for jpl
*
* Revision 1.63 2005/04/20 20:06:26 vsc
* try to improve error handling and warnings from within consults.
*
* Revision 1.62 2005/04/07 17:55:05 ricroc
* Adding tabling support for mixed strategy evaluation (batched and local scheduling)
* UPDATE: compilation flags -DTABLING_BATCHED_SCHEDULING and -DTABLING_LOCAL_SCHEDULING removed. To support tabling use -DTABLING in the Makefile or --enable-tabling in configure.
* NEW: yap_flag(tabling_mode,MODE) changes the tabling execution mode of all tabled predicates to MODE (batched, local or default).
* NEW: tabling_mode(PRED,MODE) changes the default tabling execution mode of predicate PRED to MODE (batched or local).
*
* Revision 1.61 2005/02/21 16:50:21 vsc
* amd64 fixes
* library fixes
*
* Revision 1.60 2005/01/28 23:14:41 vsc
* move to Yap-4.5.7
* Fix clause size
*
* Revision 1.59 2005/01/13 05:47:27 vsc
* lgamma broke arithmetic optimisation
* integer_y has type y
* pass original source to checker (and maybe even use option in parser)
* use warning mechanism for checker messages.
*
* Revision 1.58 2004/11/19 21:32:53 vsc
* change abort so that it won't be caught by handlers.
*
* Revision 1.57 2004/10/27 15:56:34 vsc
* bug fixes on memory overflows and on clauses :- fail being ignored by clause.
*
* Revision 1.56 2004/10/04 18:56:20 vsc
* fixes for thread support
* fix indexing bug (serious)
*
* Revision 1.55 2004/09/17 19:34:53 vsc
* simplify frozen/2
*
* Revision 1.54 2004/07/22 21:32:22 vsc
* debugger fixes
* initial support for JPL
* bad calls to garbage collector and gc
* debugger fixes
*
* Revision 1.53 2004/06/23 17:24:20 vsc
* New comment-based message style
* Fix thread support (at least don't deadlock with oneself)
* small fixes for coroutining predicates
* force Yap to recover space in arrays of dbrefs
* use private predicates in debugger.
*
* Revision 1.52 2004/06/18 15:41:19 vsc
* fix extraneous line in yes/no messages
*
* Revision 1.51 2004/06/09 03:32:03 vsc
* fix bugs
*
* Revision 1.50 2004/04/27 16:21:25 vsc
* stupid bug
* *
* *
*************************************************************************/
'$do_error'(Type,Message) :-
'$current_stack'(local_sp(_,CP,Envs,CPs)),
throw(error(Type,[Message|local_sp(Message,CP,Envs,CPs)])).
'$Error'(E) :-
'$LoopError'(E,top).
'$LoopError'(_, _) :-
flush_output(user_output),
flush_output(user_error),
fail.
'$LoopError'(Error, Level) :- !,
'$process_error'(Error, Level),
fail.
'$LoopError'(_, _) :-
flush_all_streams,
fail.
'$process_error'('$abort', top) :- !,
print_message(informational,abort(user)).
'$process_error'('$abort', _) :- !,
throw('$abort').
'$process_error'(abort, top) :- !,
print_message(informational,abort(user)).
'$process_error'(abort, _) :- !,
throw(abort).
'$process_error'(error(thread_cancel(Id), G),top) :- !.
'$process_error'(error(thread_cancel(Id), G), _) :- !,
throw(error(thread_cancel(Id), G)).
'$process_error'(error(Msg, Where), _) :- !,
'$set_fpu_exceptions',
print_message(error,error(Msg, Where)).
'$process_error'(Throw, _) :-
print_message(error,error(unhandled_exception,Throw)).
message_to_string(Event, Message) :-
'$messages':generate_message(Event, Message, []).
print_message(force(_Severity), Msg) :- !,
print(user_error,Msg).
print_message(error, error(Msg,Info)) :- var(Info), !,
print_message(error, error(Msg, '')).
print_message(error, error(Msg,[Info|local_sp(P,CP,Envs,CPs)])) :- !,
recorda(sp_info,local_sp(P,CP,Envs,CPs),R),
print_message(error, error(Msg, Info)),
erase(R).
print_message(Severity, Msg) :-
nonvar(Severity), nonvar(Msg),
'$notrace'(user:portray_message(Severity, Msg)), !.
% This predicate has more hooks than a pirate ship!
print_message(Severity, Term) :-
(
(
'$oncenotrace'(user:generate_message_hook(Term, [], Lines)) ->
true
;
'$oncenotrace'(prolog:message(Term, Lines, [])) ->
true
;
'$messages':generate_message(Term, Lines, [])
)
-> ( nonvar(Term),
'$oncenotrace'(user:message_hook(Term, Severity, Lines))
-> !
; !, '$print_system_message'(Term, Severity, Lines)
)
).
print_message(silent, _) :- !.
print_message(_, error(syntax_error(syntax_error(_,between(_,L,_),_,_,_,_,StreamName)),_)) :- !,
format(user_error,'SYNTAX ERROR at ~a, close to ~d~n',[StreamName,L]).
print_message(_, loading(A, F)) :- !,
format(user_error,' % ~a ~a~n',[A,F]).
print_message(_, loaded(A, F, _, Time, Space)) :- !,
format(user_error,' % ~a ~a ~d bytes in ~d msecs~n',[F,A,Space,Time]).
print_message(_, Term) :-
format(user_error,'~q~n',[Term]).
% print_system_message(+Term, +Level, +Lines)
%
% Print the message if the user did not intecept the message.
% The first is used for errors and warnings that can be related
% to source-location. Note that syntax errors have their own
% source-location and should therefore not be handled this way.
'$print_system_message'(_, silent, _) :- !.
'$print_system_message'(_, informational, _) :-
current_prolog_flag(verbose, silent), !.
'$print_system_message'(_, banner, _) :-
current_prolog_flag(verbose, silent), !.
'$print_system_message'(Term, Level, Lines) :-
Term = error(syntax_error(syntax_error(_,_,_,_,_,_,_)),_), !,
flush_output(user_output),
flush_output(user_error),
'$messages':prefix(Level, LinePrefix, Stream, _, Lines), !,
% make sure we don't give a PC.
print_message_lines(Stream, LinePrefix, Lines).
'$print_system_message'(Term, Level, Lines) :-
'$messages':prefix(Level, LinePrefix, Stream, Prefix),
'$messages':file_location(Prefix, LinesF, Lines), !,
flush_output(user_output),
flush_output(user_error),
print_message_lines(Stream, LinePrefix, LinesF).
'$print_system_message'(Error, Level, Lines) :-
flush_output(user_output),
flush_output(user_error),
'$messages':prefix(Level, LinePrefix, Stream, LinesF, Lines), !,
print_message_lines(Stream, LinePrefix, LinesF).
yap-6.2.2/pl/eval.yap 000644 000765 000024 00000007456 11457004725 014346 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: eval.yap *
* Last rev: *
* mods: *
* comments: optimise disjunction handling *
* *
*************************************************************************/
%, portray_clause((H:-BF))
'$full_clause_optimisation'(H, M, B0, BF) :-
'$localise_vars_opt'(H, M, B0, BF), !.
% the idea here is to make global variables in disjunctions
% local.
'$localise_vars_opt'(H, M, (B1;B2), (NB1;NB2)) :-
'$variables_in_term'(H, [], LV),
'$localise_vars'(B1, M, NB1, LV, LV, []),
'$localise_disj_vars'(B2, M, NB2, LV, LV, []).
'$localise_disj_vars'((B;B2), M, (NB ; NB2), LV, LV0, LEqs) :- !,
'$localise_vars'(B, M, NB, LV, LV0, LEqs),
'$localise_disj_vars'(B2, M, NB2, LV, LV0, LEqs).
'$localise_disj_vars'(B2, M, NB, LV, LV0, LEqs) :-
'$localise_vars'(B2, M, NB, LV, LV0, LEqs).
'$localise_vars'((A->B), M, (A->NB), LV, LV0, LEqs) :-
'$safe_guard'(A, M), !,
'$variables_in_term'(A, LV, LV1),
'$localise_vars'(B, M, NB, LV1, LV0, LEqs).
'$localise_vars'((A;B), M, (NA;NB), LV1, LV0, LEqs) :- !,
'$localise_vars'(A, M, NA, LV1, LV0, LEqs),
'$localise_disj_vars'(B, M, NB, LV1, LV0, LEqs).
'$localise_vars'(((A,B),C), M, NG, LV, LV0, LEqs) :- !,
'$flatten_bd'((A,B),C,NB),
'$localise_vars'(NB, M, NG, LV, LV0, LEqs).
'$localise_vars'((!,B), M, (!,NB), LV, LV0, LEqs) :- !,
'$localise_vars'(B, M, NB, LV, LV0, LEqs).
'$localise_vars'((X=Y,B), M, (X=Y,NB1), LV, LV0, LEqs) :-
var(X), var(Y), !,
'$localise_vars'(B, M, NB1, LV, LV0, [X,Y|LEqs]).
'$localise_vars'((G,B), M, (G,NB1), LV, LV0, LEqs) :-
'$safe_builtin'(G, M), !,
'$variables_in_term'(G, LV, LV1),
'$add_extra_safe'(G, NLV0, LV0),
'$localise_vars'(B, M, NB1, LV1, NLV0, LEqs).
'$localise_vars'((G1,B1), _, O, LV, LV0, LEqs) :- !,
terms:variables_within_term(LV, B1, Commons),
terms:new_variables_in_term(LV, B1, New),
copy_term(Commons+New+LEqs+B1, NCommons+NNew+NLEqs+NB1),
NNew = New,
NLEqs = LEqs,
'$gen_equals'(Commons, NCommons, LV0, (G1,NB1), O).
'$localise_vars'(G, _, G, _, _, _).
'$gen_equals'([], [], _, O, O).
'$gen_equals'([V|Commons],[NV|NCommons], LV0, O, NO) :- V == NV, !,
'$gen_equals'(Commons,NCommons, LV0, O, NO).
'$gen_equals'([V|Commons],[NV|NCommons], LV0, O, OO) :-
'$vmember'(V,LV0),
OO = (V=NV,'$safe'(NV),NO),
'$gen_equals'(Commons,NCommons, LV0, O, NO).
'$gen_equals'([V|Commons],[NV|NCommons], LV0, O, OO) :-
OO = (V=NV,NO),
'$gen_equals'(Commons,NCommons, LV0, O, NO).
'$safe_guard'((A,B), M) :- !,
'$safe_guard'(A, M),
'$safe_guard'(B, M).
'$safe_guard'((A;B), M) :- !,
'$safe_guard'(A, M),
'$safe_guard'(B, M).
'$safe_guard'(A, M) :- !,
'$safe_builtin'(A, M).
'$safe_builtin'(G, Mod) :-
'$flags'(G, Mod, Fl, Fl),
Fl /\ 0x00008880 =\= 0.
'$vmember'(V,[V1|_]) :- V == V1, !.
'$vmember'(V,[_|LV0]) :-
'$vmember'(V,LV0).
'$flatten_bd'((A,B),R,NB) :- !,
'$flatten_bd'(B,R,R1),
'$flatten_bd'(A,R1,NB).
'$flatten_bd'(A,R,(A,R)).
'$add_extra_safe'('$plus'(_,_,V)) --> !, [V].
'$add_extra_safe'('$minus'(_,_,V)) --> !, [V].
'$add_extra_safe'('$times'(_,_,V)) --> !, [V].
'$add_extra_safe'('$div'(_,_,V)) --> !, [V].
'$add_extra_safe'('$and'(_,_,V)) --> !, [V].
'$add_extra_safe'('$or'(_,_,V)) --> !, [V].
'$add_extra_safe'('$sll'(_,_,V)) --> !, [V].
'$add_extra_safe'('$slr'(_,_,V)) --> !, [V].
'$add_extra_safe'(C=D,A,B) :-
!,
( compound(C) ->
'$variables_in_term'(C,E,A)
;
E=A
),
( compound(D) ->
'$variables_in_term'(D,B,E)
;
B=E
).
'$add_extra_safe'(_) --> [].
yap-6.2.2/pl/flags.yap 000644 000765 000024 00000104751 11557471336 014516 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: flags.yap *
* Last rev: *
* mods: *
* comments: controlling YAP *
* *
*************************************************************************/
yap_flag(V,Out) :-
'$user_defined_flag'(V,_,_,_),
(nonvar(V) ->
!
;
true
),
'$user_flag_value'(V, Out).
yap_flag(V,Out) :-
var(V), !,
'$show_yap_flag_opts'(V,Out).
% do or do not machine code
yap_flag(fast,V) :- var(V), !, get_value('$yap_optimise',V).
yap_flag(fast,on) :- set_value('$yap_optimise',true).
yap_flag(fast,off) :- !, set_value('$yap_optimise',false).
yap_flag(fast,X) :-
'$do_error'(domain_error(flag_value,fast+X),yap_flag(fast,X)).
% optimise code (same as fast)
yap_flag(optimise,V) :- var(V), !, get_value('$yap_optimise',V).
yap_flag(optimise,true) :- !, set_value('$yap_optimise',true).
yap_flag(optimise,false) :- !, set_value('$yap_optimise',false).
yap_flag(optimise,X) :-
'$do_error'(domain_error(flag_value,optimise+X),yap_flag(optimise,X)).
% do or do not machine code
yap_flag(autoload,V) :-
var(V), !,
( autoloader:autoload -> V = true ; V = false ).
yap_flag(autoload,true) :-
'$ensure_autoload',
assert(autoloader:autoload).
yap_flag(autoload,false) :-
retract(autoloader:autoload).
% do or do not machine code
yap_flag(argv,L) :- '$argv'(L).
% do or do not machine code
yap_flag(executable,L) :- '$executable'(L).
% hide/unhide atoms
yap_flag(hide,Atom) :- !, hide(Atom).
yap_flag(unhide,Atom) :- !, unhide(Atom).
% hide/unhide atoms
yap_flag(encoding,DefaultEncoding) :- var(DefaultEncoding), !,
'$default_encoding'(DefCode),
'$valid_encoding'(DefaultEncoding, DefCode).
yap_flag(encoding,Encoding) :-
'$valid_encoding'(Encoding, EncCode), !,
'$default_encoding'(EncCode).
yap_flag(encoding,Encoding) :-
'$do_error'(domain_error(io_mode,encoding(Encoding)),yap_flag(encoding,Encoding)).
% control garbage collection
yap_flag(gc,V) :-
var(V), !,
( get_value('$gc',[]) -> V = off ; V = on).
yap_flag(gc,on) :- !, set_value('$gc',true).
yap_flag(gc,off) :- !, set_value('$gc',[]).
yap_flag(gc_margin,N) :-
( var(N) ->
get_value('$gc_margin',N)
;
integer(N), N >0 ->
set_value('$gc_margin',N)
;
'$do_error'(domain_error(flag_value,gc_margin+X),yap_flag(gc_margin,X))
).
yap_flag(gc_trace,V) :-
var(V), !,
get_value('$gc_trace',N1),
get_value('$gc_verbose',N2),
get_value('$gc_very_verbose',N3),
'$yap_flag_show_gc_tracing'(N1, N2, N3, V).
yap_flag(gc_trace,on) :- !,
set_value('$gc_trace',true),
set_value('$gc_verbose',[]),
set_value('$gc_very_verbose',[]).
yap_flag(gc_trace,verbose) :- !,
set_value('$gc_trace',[]),
set_value('$gc_verbose',true),
set_value('$gc_very_verbose',[]).
yap_flag(gc_trace,very_verbose) :- !,
set_value('$gc_trace',[]),
set_value('$gc_verbose',true),
set_value('$gc_very_verbose',true).
yap_flag(gc_trace,off) :-
set_value('$gc_trace',[]),
set_value('$gc_verbose',[]),
set_value('$gc_very_verbose',[]).
yap_flag(syntax_errors, V) :- var(V), !,
'$get_read_error_handler'(V).
yap_flag(syntax_errors, Option) :-
'$set_read_error_handler'(Option).
% compatibility flag
yap_flag(enhanced,on) :- !, set_value('$enhanced',true).
yap_flag(enhanced,off) :- set_value('$enhanced',[]).
% compatibility flag
yap_flag(agc_margin,Margin) :-
'$agc_threshold'(Margin).
%
% SWI compatibility flag
%
yap_flag(generate_debug_info,X) :-
var(X), !,
'$access_yap_flags'(18,Options),
(Options =:= 0 -> X = false ; X = true ).
yap_flag(generate_debug_info,true) :- !,
'$enable_restore_flag_info'(generate_debug_info),
'$set_yap_flags'(18,1),
source.
yap_flag(generate_debug_info,false) :- !,
'$enable_restore_flag_info'(generate_debug_info),
'$set_yap_flags'(18,0),
no_source.
yap_flag(generate_debug_info,X) :-
'$do_error'(domain_error(flag_value,generate_debug_info+X),yap_flag(generate_debug_info,X)).
'$enable_restore_flag_info'(_) :-
nb_getval('$consulting_file',[]), !.
'$enable_restore_flag_info'(_) :-
nb_getval('$initialization_goals',on), !.
'$enable_restore_flag_info'(Flag) :-
'$show_consult_level'(Level1),
yap_flag(Flag, Info),
% it will be done after we leave the current consult level.
Level is Level1-1,
recorda('$initialisation',do(Level,yap_flag(Flag,Info)),_),
fail.
'$enable_restore_flag_info'(_).
%
% show state of $
%
yap_flag(dollar_as_lower_case,V) :-
var(V), !,
'$type_of_char'(36,T),
(T = 3 -> V = on ; V = off).
%
% make $a a legit atom
%
yap_flag(dollar_as_lower_case,on) :- !,
'$change_type_of_char'(36,3).
%
% force quoting of '$a'
%
yap_flag(dollar_as_lower_case,off) :-
'$change_type_of_char'(36,7).
yap_flag(call_counting,X) :- (var(X); X = on; X = off), !,
'$is_call_counted'(X).
yap_flag(open_shared_object,X) :-
var(X), !,
('$open_shared_objects' -> X = true ; X = false).
yap_flag(open_shared_object,X) :-
(X = true ; X = false), !,
'$do_error'(permission_error(modify,flag,open_shared_object),yap_flag(open_shared_object,X)).
yap_flag(open_shared_object,X) :-
'$do_error'(domain_error(flag_value,open_shared_object+X),yap_flag(open_shared_object,X)).
yap_flag(bounded,X) :-
var(X), !,
'$access_yap_flags'(0, X1),
'$transl_to_true_false'(X1,X).
yap_flag(bounded,X) :-
(X = true ; X = false), !,
'$do_error'(permission_error(modify,flag,bounded),yap_flag(bounded,X)).
yap_flag(bounded,X) :-
'$do_error'(domain_error(flag_value,bounded+X),yap_flag(bounded,X)).
% do or do not indexation
yap_flag(index,X) :- var(X),
'$access_yap_flags'(19, X1),
'$transl_to_index_mode'(X1,X), !.
yap_flag(index,X) :-
'$transl_to_index_mode'(X1,X), !,
'$set_yap_flags'(19,X1).
yap_flag(index,X) :-
'$do_error'(domain_error(flag_value,index+X),yap_flag(index,X)).
yap_flag(home,X) :-
'$yap_home'(X).
% should match definitions in Yap.h
'$transl_to_index_mode'(0, off).
'$transl_to_index_mode'(1, single).
'$transl_to_index_mode'(2, compact).
'$transl_to_index_mode'(3, multi).
'$transl_to_index_mode'(3, on). % default is multi argument indexing
'$transl_to_index_mode'(4, max).
% tabling mode
yap_flag(tabling_mode,Options) :-
var(Options), !,
'$access_yap_flags'(20,Options).
yap_flag(tabling_mode,[]) :- !,
yap_flag(tabling_mode,default).
yap_flag(tabling_mode,[HOption|TOption]) :- !,
yap_flag(tabling_mode,TOption),
yap_flag(tabling_mode,HOption).
yap_flag(tabling_mode,Option) :-
'$transl_to_yap_flag_tabling_mode'(Flag,Option), !,
'$set_yap_flags'(20,Flag).
yap_flag(tabling_mode,Options) :-
'$do_error'(domain_error(flag_value,tabling_mode+Options),yap_flag(tabling_mode,Options)).
% should match with code in stdpreds.c
'$transl_to_yap_flag_tabling_mode'(0,default).
'$transl_to_yap_flag_tabling_mode'(1,batched).
'$transl_to_yap_flag_tabling_mode'(2,local).
'$transl_to_yap_flag_tabling_mode'(3,exec_answers).
'$transl_to_yap_flag_tabling_mode'(4,load_answers).
'$transl_to_yap_flag_tabling_mode'(5,local_trie).
'$transl_to_yap_flag_tabling_mode'(6,global_trie).
yap_flag(informational_messages,X) :- var(X), !,
get_value('$verbose',X).
yap_flag(informational_messages,on) :- !,
set_value('$verbose',on),
'$set_yap_flags'(22,0).
yap_flag(informational_messages,off) :- !,
set_value('$verbose',off),
'$set_yap_flags'(22,1).
yap_flag(informational_messages,X) :-
'$do_error'(domain_error(flag_value,informational_messages+X),yap_flag(informational_messages,X)).
yap_flag(verbose,X) :- var(X), !,
get_value('$verbose',X0),
(X0 == on -> X = normal ; X = silent).
yap_flag(verbose,normal) :- !,
set_value('$verbose',on),
'$set_yap_flags'(22,0).
yap_flag(verbose,silent) :- !,
set_value('$verbose',off),
'$set_yap_flags'(22,1).
yap_flag(verbose,X) :-
'$do_error'(domain_error(flag_value,verbose+X),yap_flag(verbose,X)).
yap_flag(integer_rounding_function,X) :-
var(X), !,
'$access_yap_flags'(2, X1),
'$transl_to_rounding_function'(X1,X).
yap_flag(integer_rounding_function,X) :-
(X = down; X = toward_zero), !,
'$do_error'(permission_error(modify,flag,integer_rounding_function),yap_flag(integer_rounding_function,X)).
yap_flag(integer_rounding_function,X) :-
'$do_error'(domain_error(flag_value,integer_rounding_function+X),yap_flag(integer_rounding_function,X)).
yap_flag(max_arity,X) :-
var(X), !,
'$access_yap_flags'(1, X1),
'$transl_to_arity'(X1,X).
yap_flag(max_arity,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,max_arity),yap_flag(max_arity,X)).
yap_flag(max_arity,X) :-
'$do_error'(domain_error(flag_value,max_arity+X),yap_flag(max_arity,X)).
yap_flag(version,X) :-
var(X), !,
get_value('$version_name',X).
yap_flag(version,X) :-
'$do_error'(permission_error(modify,flag,version),yap_flag(version,X)).
yap_flag(version_data,X) :-
var(X), !,
'$get_version_codes'(Major,Minor,Patch),
X = yap(Major, Minor, Patch, _).
yap_flag(version_data,X) :-
'$do_error'(permission_error(modify,flag,version),yap_flag(version_data,X)).
'$get_version_codes'(Major,Minor,Patch) :-
get_value('$version_name',X),
atom_codes(X,[_,_,_,_|VersionTag]), %'
'$fetch_num_code'(VersionTag,0,Major,L1),
'$fetch_num_code'(L1,0,Minor,L2),
'$fetch_num_code'(L2,0,Patch,_).
'$fetch_num_code'([],Code,Code,[]).
'$fetch_num_code'([C|Cs],Code0,CodeF,L) :-
C >= 0'0, C =< 0'9, !,
CodeI is Code0*10+(C-0'0), %'
'$fetch_num_code'(Cs,CodeI,CodeF,L).
'$fetch_num_code'([_|Cs],Code,Code,Cs).
yap_flag(max_integer,X) :-
var(X), !,
'$access_yap_flags'(0, 1),
'$access_yap_flags'(3, X).
yap_flag(max_integer,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,max_integer),yap_flag(max_integer,X)).
yap_flag(max_integer,X) :-
'$do_error'(domain_error(flag_value,max_integer+X),yap_flag(max_integer,X)).
yap_flag(max_tagged_integer,X) :-
'$max_tagged_integer'(X), !.
yap_flag(max_tagged_integer,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,max_tagged_integer),yap_flag(max_tagged_integer,X)).
yap_flag(max_tagged_integer,X) :-
'$do_error'(domain_error(flag_value,max_tagged_integer+X),yap_flag(max_tagged_integer,X)).
yap_flag(min_integer,X) :-
var(X), !,
'$access_yap_flags'(0, 1),
'$access_yap_flags'(4, X).
yap_flag(min_integer,X) :-
integer(X), X < 0, !,
'$do_error'(permission_error(modify,flag,min_integer),yap_flag(min_integer,X)).
yap_flag(min_integer,X) :-
'$do_error'(domain_error(flag_value,min_integer+X),yap_flag(min_integer,X)).
yap_flag(min_tagged_integer,X) :-
'$min_tagged_integer'( X), !.
yap_flag(min_tagged_integer,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,min_tagged_integer),yap_flag(min_tagged_integer,X)).
yap_flag(min_tagged_integer,X) :-
'$do_error'(domain_error(flag_value,min_tagged_integer+X),yap_flag(min_tagged_integer,X)).
/* ISO Core Revision DTR: new float flags
yap_flag(float_mantissa_digits,X) :-
var(X), !,
?????
yap_flag(float_mantissa_digits,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,float_mantissa_digits),yap_flag(float_mantissa_digits,X)).
yap_flag(float_mantissa_digits,X) :-
'$do_error'(domain_error(flag_value,float_mantissa_digits+X),yap_flag(float_mantissa_digits,X)).
yap_flag(float_epsilon,X) :-
var(X), !,
?????
yap_flag(float_epsilon,X) :-
float(X), X > 0, !,
'$do_error'(permission_error(modify,flag,float_epsilon),yap_flag(float_epsilon,X)).
yap_flag(float_epsilon,X) :-
'$do_error'(domain_error(flag_value,float_epsilon+X),yap_flag(float_epsilon,X)).
yap_flag(float_min_exponent,X) :-
var(X), !,
?????
yap_flag(float_min_exponent,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,float_min_exponent),yap_flag(float_min_exponent,X)).
yap_flag(float_epsilon,X) :-
'$do_error'(domain_error(flag_value,float_min_exponent+X),yap_flag(float_min_exponent,X)).
yap_flag(float_max_exponent,X) :-
var(X), !,
?????
yap_flag(float_max_exponent,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,float_max_exponent),yap_flag(flo
at_max_exponent,X)).
yap_flag(float_max_exponent,X) :-
'$do_error'(domain_error(flag_value,float_max_exponent+X),yap_flag(float_max_exponent,X)).
*/
yap_flag(char_conversion,X) :-
var(X), !,
'$access_yap_flags'(5, X1),
'$transl_to_on_off'(X1,X).
yap_flag(char_conversion,X) :-
'$transl_to_on_off'(X1,X), !,
'$set_yap_flags'(5,X1),
( X1 = 1 ->
'$force_char_conversion'
;
'$disable_char_conversion'
).
yap_flag(char_conversion,X) :-
'$do_error'(domain_error(flag_value,char_conversion+X),yap_flag(char_conversion,X)).
yap_flag(double_quotes,X) :-
var(X), !,
'$access_yap_flags'(6, X1),
'$transl_to_trl_types'(X1,X).
yap_flag(double_quotes,X) :-
'$transl_to_trl_types'(X1,X), !,
'$set_yap_flags'(6,X1).
yap_flag(double_quotes,X) :-
'$do_error'(domain_error(flag_value,double_quotes+X),yap_flag(double_quotes,X)).
yap_flag(n_of_integer_keys_in_db,X) :-
var(X), !,
'$resize_int_keys'(X).
yap_flag(n_of_integer_keys_in_db,X) :- integer(X), X > 0, !,
'$resize_int_keys'(X).
yap_flag(n_of_integer_keys_in_db,X) :-
'$do_error'(domain_error(flag_value,n_of_integer_keys_in_db+X),yap_flag(n_of_integer_keys_in_db,X)).
yap_flag(n_of_integer_keys_in_bb,X) :-
var(X), !,
'$resize_bb_int_keys'(X).
yap_flag(n_of_integer_keys_in_bb,X) :- integer(X), X > 0, !,
'$resize_bb_int_keys'(X).
yap_flag(n_of_integer_keys_in_bb,X) :-
'$do_error'(domain_error(flag_value,n_of_integer_keys_in_bb+X),yap_flag(n_of_integer_keys_in_bb,X)).
yap_flag(profiling,X) :- (var(X); X = on; X = off), !,
'$is_profiled'(X).
yap_flag(strict_iso,OUT) :-
var(OUT), !,
'$access_yap_flags'(9,X),
'$transl_to_on_off'(X,OUT).
yap_flag(strict_iso,on) :- !,
yap_flag(language,iso),
'$transl_to_on_off'(X,on),
'$set_yap_flags'(9,X).
yap_flag(strict_iso,off) :- !,
'$transl_to_on_off'(X,off),
'$set_yap_flags'(9,X).
yap_flag(strict_iso,X) :-
'$do_error'(domain_error(flag_value,strict_iso+X),yap_flag(strict_iso,X)).
yap_flag(variable_names_may_end_with_quotes,OUT) :-
var(OUT), !,
'$access_yap_flags'(21,X),
'$transl_to_on_off'(X,OUT).
yap_flag(variable_names_may_end_with_quotes,on) :- !,
'$transl_to_on_off'(X,on),
'$set_yap_flags'(21,X).
yap_flag(variable_names_may_end_with_quotes,off) :- !,
'$transl_to_on_off'(X,off),
'$set_yap_flags'(21,X).
yap_flag(variable_names_may_end_with_quotes,X) :-
'$do_error'(domain_error(flag_value,strict_iso+X),yap_flag(strict_iso,X)).
yap_flag(language,X) :-
var(X), !,
'$access_yap_flags'(8, X1),
'$trans_to_lang_flag'(X1,X).
yap_flag(language,X) :-
'$trans_to_lang_flag'(N,X), !,
'$set_yap_flags'(8,N),
'$adjust_language'(X).
yap_flag(language,X) :-
'$do_error'(domain_error(flag_value,language+X),yap_flag(language,X)).
yap_flag(debug,X) :-
var(X), !,
('$debug_on'(true)
->
X = on
;
X = true
).
yap_flag(debug,X) :-
'$transl_to_on_off'(_,X), !,
(X = on -> debug ; nodebug).
yap_flag(debug,X) :-
'$do_error'(domain_error(flag_value,debug+X),yap_flag(debug,X)).
yap_flag(discontiguous_warnings,X) :-
var(X), !,
('$syntax_check_mode'(on,_), '$syntax_check_discontiguous'(on,_) ->
X = on
;
X = off
).
yap_flag(discontiguous_warnings,X) :-
'$transl_to_on_off'(_,X), !,
(X = on ->
'$syntax_check_mode'(_,on),
'$syntax_check_discontiguous'(_,on)
;
'$syntax_check_discontiguous'(_,off)).
yap_flag(discontiguous_warnings,X) :-
'$do_error'(domain_error(flag_value,discontiguous_warnings+X),yap_flag(discontiguous_warnings,X)).
yap_flag(redefine_warnings,X) :-
var(X), !,
('$syntax_check_mode'(on,_), '$syntax_check_multiple'(on,_) ->
X = on
;
X = off
).
yap_flag(redefine_warnings,X) :-
'$transl_to_on_off'(_,X), !,
(X = on ->
'$syntax_check_mode'(_,on),
'$syntax_check_multiple'(_,on)
;
'$syntax_check_multiple'(_,off)).
yap_flag(redefine_warnings,X) :-
'$do_error'(domain_error(flag_value,redefine_warnings+X),yap_flag(redefine_warnings,X)).
yap_flag(chr_toplevel_show_store,X) :-
var(X), !,
nb_getval('$chr_toplevel_show_store',X).
yap_flag(chr_toplevel_show_store,X) :-
(X = true ; X = false), !,
nb_setval('$chr_toplevel_show_store',X).
yap_flag(chr_toplevel_show_store,X) :-
'$do_error'(domain_error(flag_value,chr_toplevel_show_store+X),yap_flag(chr_toplevel_show_store,X)).
yap_flag(open_expands_filename,Expand) :-
var(Expand), !,
'$default_expand'(Expand).
yap_flag(open_expands_filename,Expand) :-
'$set_default_expand'(Expand).
yap_flag(single_var_warnings,X) :-
var(X), !,
('$syntax_check_mode'(on,_), '$syntax_check_single_var'(on,_) ->
X = on
;
X = off
).
yap_flag(single_var_warnings,X) :-
'$transl_to_on_off'(_,X), !,
(X = on ->
'$syntax_check_mode'(_,on),
'$syntax_check_single_var'(_,on)
;
'$syntax_check_single_var'(_,off)).
yap_flag(single_var_warnings,X) :-
'$do_error'(domain_error(flag_value,single_var_warnings+X),yap_flag(single_var_warnings,X)).
yap_flag(system_options,X) :-
'$system_options'(X).
'$system_options'(big_numbers) :-
'$has_bignums'.
'$system_options'(coroutining) :-
'$yap_has_coroutining'.
'$system_options'(depth_limit) :-
\+ '$undefined'(get_depth_limit(_), prolog).
'$system_options'(low_level_tracer) :-
\+ '$undefined'(start_low_level_trace, prolog).
'$system_options'(or_parallelism) :-
\+ '$undefined'('$c_yapor_on', prolog).
'$system_options'(rational_trees) :-
'$yap_has_rational_trees'.
'$system_options'(readline) :-
'$has_readline'.
'$system_options'(tabling) :-
\+ '$undefined'('$c_table'(_,_), prolog).
'$system_options'(threads) :-
\+ '$no_threads'.
'$system_options'(wam_profiler) :-
\+ '$undefined'(reset_op_counters, prolog).
yap_flag(unknown,X) :-
var(X), !,
unknown(X,_).
yap_flag(unknown,N) :-
unknown(_,N).
yap_flag(to_chars_mode,X) :-
var(X), !,
( '$access_yap_flags'(7,0) -> X = quintus ; X = iso ).
yap_flag(to_chars_mode,quintus) :- !,
'$set_yap_flags'(7,0).
yap_flag(to_chars_mode,iso) :- !,
'$set_yap_flags'(7,1).
yap_flag(to_chars_mode,X) :-
'$do_error'(domain_error(flag_value,to_chars_mode+X),yap_flag(to_chars_mode,X)).
yap_flag(character_escapes,X) :-
var(X), !,
'$access_yap_flags'(12,Y),
'$transl_to_character_escape_modes'(Y,X).
yap_flag(character_escapes,X) :- !,
'$transl_to_character_escape_modes'(Y,X), !,
'$set_yap_flags'(12,Y).
yap_flag(character_escapes,X) :-
'$do_error'(domain_error(flag_value,character_escapes+X),yap_flag(to_chars_mode,X)).
yap_flag(update_semantics,X) :-
var(X), !,
( '$log_upd'(I) -> '$convert_upd_sem'(I,X) ).
yap_flag(update_semantics,logical) :- !,
'$switch_log_upd'(1).
yap_flag(update_semantics,logical_assert) :- !,
'$switch_log_upd'(2).
yap_flag(update_semantics,immediate) :- !,
'$switch_log_upd'(0).
yap_flag(update_semantics,X) :-
'$do_error'(domain_error(flag_value,update_semantics+X),yap_flag(update_semantics,X)).
yap_flag(toplevel_hook,X) :-
var(X), !,
( recorded('$toplevel_hooks',G,_) -> G ; true ).
yap_flag(toplevel_hook,G) :- !,
'$set_toplevel_hook'(G).
yap_flag(unix,true) :-
'$unix', !.
yap_flag(unix,false).
yap_flag(windows,true) :-
'$win32', !.
yap_flag(windows,false).
yap_flag(shared_object_search_path,P) :-
'$ld_path'(P).
yap_flag(typein_module,X) :-
var(X), !,
'$current_module'(X).
yap_flag(typein_module,X) :-
module(X).
yap_flag(write_strings,OUT) :-
var(OUT), !,
'$access_yap_flags'(13,X),
'$transl_to_on_off'(X,OUT).
yap_flag(write_strings,on) :- !,
'$transl_to_on_off'(X,on),
'$set_yap_flags'(13,X).
yap_flag(write_strings,off) :- !,
'$transl_to_on_off'(X,off),
'$set_yap_flags'(13,X).
yap_flag(write_strings,X) :-
'$do_error'(domain_error(flag_value,write_strings+X),yap_flag(write_strings,X)).
yap_flag(prompt_alternatives_on,OUT) :-
var(OUT), !,
'$prompt_alternatives_on'(OUT).
yap_flag(prompt_alternatives_on,determinism) :- !,
'$purge_clauses'('$prompt_alternatives_on'(_),prolog),
'$compile'('$prompt_alternatives_on'(determinism),0,'$prompt_alternatives_on'(determinism),prolog).
yap_flag(prompt_alternatives_on,groundness) :- !,
'$purge_clauses'('$prompt_alternatives_on'(_),prolog),
'$compile'('$prompt_alternatives_on'(groundness),0,'$prompt_alternatives_on'(groundness),prolog).
yap_flag(prompt_alternatives_on,X) :-
'$do_error'(domain_error(flag_value,prompt_alternatives_on+X),yap_flag(prompt_alternatives_on,X)).
'$user_flags'(error).
yap_flag(user_flags,OUT) :-
var(OUT), !,
'$user_flags'(OUT).
yap_flag(user_flags,silent) :- !,
'$purge_clauses'('$user_flags'(_),prolog),
'$compile'('$user_flags'(silent),0,'$user_flags'(silent),prolog).
yap_flag(user_flags,warning) :- !,
'$purge_clauses'('$user_flags'(_),prolog),
'$compile'('$user_flags'(warning),0,'$user_flags'(warning),prolog).
yap_flag(user_flags,error) :- !,
'$purge_clauses'('$user_flags'(_),prolog),
'$compile'('$user_flags'(error),0,'$user_flags'(error),prolog).
yap_flag(user_flags,X) :-
'$do_error'(domain_error(flag_value,user_flags+X),yap_flag(user_flags,X)).
yap_flag(stack_dump_on_error,OUT) :-
var(OUT), !,
'$access_yap_flags'(17,X),
'$transl_to_on_off'(X,OUT).
yap_flag(stack_dump_on_error,on) :- !,
'$transl_to_on_off'(X,on),
'$set_yap_flags'(17,X).
yap_flag(stack_dump_on_error,off) :- !,
'$transl_to_on_off'(X,off),
'$set_yap_flags'(17,X).
yap_flag(stack_dump_on_error,X) :-
'$do_error'(domain_error(flag_value,stack_dump_on_error+X),yap_flag(stack_dump_on_error,X)).
yap_flag(user_input,OUT) :-
var(OUT), !,
'$flag_check_alias'(OUT, user_input).
yap_flag(user_input,Stream) :-
'$change_alias_to_stream'(user_input,Stream).
yap_flag(user_output,OUT) :-
var(OUT), !,
'$flag_check_alias'(OUT, user_output).
yap_flag(user_output,Stream) :-
'$change_alias_to_stream'(user_output,Stream).
yap_flag(user_error,OUT) :-
var(OUT), !,
'$flag_check_alias'(OUT, user_error).
yap_flag(user_error,Stream) :-
'$change_alias_to_stream'(user_error,Stream).
yap_flag(debugger_print_options,OUT) :-
var(OUT),
recorded('$print_options','$debugger'(OUT),_), !.
yap_flag(debugger_print_options,Opts) :- !,
'$check_io_opts'(Opts, yap_flag(debugger_print_options,Opts)),
recorda('$print_options','$debugger'(Opts),_).
:- recorda('$print_options','$debugger'([quoted(true),numbervars(true),portrayed(true),max_depth(10)]),_).
yap_flag(toplevel_print_options,OUT) :-
var(OUT),
recorded('$print_options','$toplevel'(OUT),_), !.
yap_flag(toplevel_print_options,Opts) :- !,
'$check_io_opts'(Opts, yap_flag(toplevel_print_options,Opts)),
recorda('$print_options','$toplevel'(Opts),_).
yap_flag(fileerrors,OUT) :-
var(OUT), !,
get_value(fileerrors,X0),
(X0 = [] -> X= 0 ; X = X0),
'$transl_to_on_off'(X,OUT).
yap_flag(fileerrors,on) :- !,
set_value(fileerrors,1).
yap_flag(fileerrors,off) :- !,
set_value(fileerrors,0).
yap_flag(fileerrors,X) :-
'$do_error'(domain_error(flag_value,fileerrors+X),yap_flag(fileerrors,X)).
:- recorda('$print_options','$toplevel'([quoted(true),numbervars(true),portrayed(true)]),_).
yap_flag(host_type,X) :-
'$host_type'(X).
yap_flag(verbose_load,X) :-
var(X), !,
( get_value('$lf_verbose',silent) -> X = false ; X = true ).
yap_flag(verbose_load,true) :- !,
set_value('$lf_verbose',informational).
yap_flag(verbose_load,false) :- !,
set_value('$lf_verbose',silent),
'$set_yap_flags'(7,1).
yap_flag(verbose_load,X) :-
'$do_error'(domain_error(flag_value,verbose_load+X),yap_flag(verbose_load,X)).
yap_flag(verbose_auto_load,X) :-
var(X), !,
( get_value('$verbose_auto_load',true) -> X = true ; X = false ).
yap_flag(verbose_auto_load,true) :- !,
set_value('$verbose_auto_load',true).
yap_flag(verbose_auto_load,false) :- !,
set_value('$verbose_auto_load',false),
'$set_yap_flags'(7,1).
yap_flag(verbose_auto_load,X) :-
'$do_error'(domain_error(flag_value,verbose_auto_load+X),yap_flag(verbose_auto_load,X)).
yap_flag(float_format,X) :-
var(X), !,
'$float_format'(X).
yap_flag(float_format,X) :-
atom(X), !,
'$float_format'(X).
yap_flag(float_format,X) :-
'$do_error'(type_error(atom,X),yap_flag(float_format,X)).
yap_flag(max_workers,X) :-
var(X), !,
'$max_workers'(X).
yap_flag(max_workers,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,max_workers),yap_flag(max_workers,X)).
yap_flag(max_workers,X) :-
'$do_error'(domain_error(flag_value,max_workers+X),yap_flag(max_workers,X)).
yap_flag(max_threads,X) :-
var(X), !,
'$max_threads'(X).
yap_flag(max_threads,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,max_threads),yap_flag(max_threads,X)).
yap_flag(max_threads,X) :-
'$do_error'(domain_error(flag_value,max_threads+X),yap_flag(max_threads,X)).
yap_flag(address_bits,X) :-
var(X), !,
'$address_bits'(X).
yap_flag(address_bits,X) :-
integer(X), X > 0, !,
'$do_error'(permission_error(modify,flag,address_bits),yap_flag(address_bits,X)).
yap_flag(address_bits,X) :-
'$do_error'(domain_error(flag_value,address_bits+X),yap_flag(address_bits,X)).
yap_flag(dialect,yap).
'$yap_system_flag'(address_bits).
'$yap_system_flag'(agc_margin).
'$yap_system_flag'(answer_format).
'$yap_system_flag'(argv).
'$yap_system_flag'(autoload).
'$yap_system_flag'(bounded).
'$yap_system_flag'(char_conversion).
'$yap_system_flag'(character_escapes).
'$yap_system_flag'(chr_toplevel_show_store).
'$yap_system_flag'(debug).
'$yap_system_flag'(debugger_print_options).
'$yap_system_flag'(dialect).
'$yap_system_flag'(discontiguous_warnings).
'$yap_system_flag'(dollar_as_lower_case).
'$yap_system_flag'(double_quotes).
'$yap_system_flag'(encoding).
'$yap_system_flag'(executable).
% V = fast ;
'$yap_system_flag'(fileerrors ).
'$yap_system_flag'(float_format).
% V = float_mantissa_digits ;
% V = float_epsilon ;
% V = float_min_exponent ;
% V = float_max_exponent ;
'$yap_system_flag'(gc ).
'$yap_system_flag'(gc_margin ).
'$yap_system_flag'(gc_trace ).
'$yap_system_flag'(generate_debug_info ).
% V = hide ;
'$yap_system_flag'(home ).
'$yap_system_flag'(host_type ).
'$yap_system_flag'(index).
'$yap_system_flag'(tabling_mode).
'$yap_system_flag'(informational_messages).
'$yap_system_flag'(integer_rounding_function).
'$yap_system_flag'(language).
'$yap_system_flag'(max_arity).
'$yap_system_flag'(max_integer).
'$yap_system_flag'(max_tagged_integer).
'$yap_system_flag'(max_workers).
'$yap_system_flag'(max_threads).
'$yap_system_flag'(min_integer).
'$yap_system_flag'(min_tagged_integer).
'$yap_system_flag'(n_of_integer_keys_in_db).
'$yap_system_flag'(open_expands_filename).
'$yap_system_flag'(open_shared_object).
'$yap_system_flag'(optimise).
'$yap_system_flag'(profiling).
'$yap_system_flag'(prompt_alternatives_on).
'$yap_system_flag'(redefine_warnings).
'$yap_system_flag'(shared_object_search_path).
'$yap_system_flag'(single_var_warnings).
'$yap_system_flag'(stack_dump_on_error).
'$yap_system_flag'(strict_iso).
'$yap_system_flag'(syntax_errors).
'$yap_system_flag'(system_options).
'$yap_system_flag'(to_chars_mode).
'$yap_system_flag'(toplevel_hook).
'$yap_system_flag'(toplevel_print_options).
'$yap_system_flag'(typein_module).
'$yap_system_flag'(unix).
'$yap_system_flag'(unknown).
'$yap_system_flag'(update_semantics).
'$yap_system_flag'(user_error).
'$yap_system_flag'(user_flags).
'$yap_system_flag'(user_input).
'$yap_system_flag'(user_output).
'$yap_system_flag'(variable_names_may_end_with_quotes).
'$yap_system_flag'(verbose).
'$yap_system_flag'(verbose_load).
'$yap_system_flag'(verbose_auto_load).
'$yap_system_flag'(version).
'$yap_system_flag'(version_data).
'$yap_system_flag'(windows).
'$yap_system_flag'(write_strings).
'$show_yap_flag_opts'(V,Out) :-
'$yap_system_flag'(V),
yap_flag(V, Out).
'$trans_to_lang_flag'(0,cprolog).
'$trans_to_lang_flag'(1,iso).
'$trans_to_lang_flag'(2,sicstus).
'$adjust_language'(cprolog) :-
% '$switch_log_upd'(0),
'$syntax_check_mode'(_,off),
'$syntax_check_single_var'(_,off),
'$syntax_check_discontiguous'(_,off),
'$syntax_check_multiple'(_,off),
'$set_yap_flags'(12,0), % disable character escapes.
'$set_yap_flags'(14,1),
'$set_fpu_exceptions',
unknown(_,fail).
'$adjust_language'(sicstus) :-
'$switch_log_upd'(1),
leash(full),
'$syntax_check_mode'(_,on),
'$syntax_check_single_var'(_,on),
'$syntax_check_discontiguous'(_,on),
'$syntax_check_multiple'(_,on),
'$transl_to_on_off'(X1,on),
'$set_yap_flags'(5,X1),
'$force_char_conversion',
'$set_yap_flags'(14,0),
% CHARACTER_ESCAPE
'$set_yap_flags'(12,1),
'$set_fpu_exceptions',
fileerrors,
unknown(_,error).
'$adjust_language'(iso) :-
'$switch_log_upd'(1),
'$syntax_check_mode'(_,on),
'$syntax_check_single_var'(_,on),
'$syntax_check_discontiguous'(_,on),
'$syntax_check_multiple'(_,on),
% YAP_TO_CHARS
'$set_yap_flags'(7,1),
fileerrors,
'$transl_to_on_off'(X1,on),
% CHAR_CONVERSION
'$set_yap_flags'(5,X1),
'$force_char_conversion',
% ALLOW_ASSERTING_STATIC
'$set_yap_flags'(14,0),
% CHARACTER_ESCAPE
'$set_yap_flags'(12,1),
'$set_fpu_exceptions',
unknown(_,error).
'$transl_to_character_escape_modes'(0,off) :- !.
'$transl_to_character_escape_modes'(0,cprolog).
'$transl_to_character_escape_modes'(2,on) :- !.
'$transl_to_character_escape_modes'(1,iso).
'$transl_to_character_escape_modes'(2,sicstus).
'$convert_upd_sem'(0,immediate).
'$convert_upd_sem'(1,logical).
'$convert_upd_sem'(2,logical_assert).
'$transl_to_true_false'(0,false).
'$transl_to_true_false'(1,true).
'$transl_to_on_off'(0,off).
'$transl_to_on_off'(1,on).
'$transl_to_arity'(X1,X) :- X1 < 0, !, X = unbounded.
'$transl_to_arity'(X,X).
'$transl_to_rounding_function'(0,toward_zero).
'$transl_to_rounding_function'(1,down).
'$transl_to_trl_types'(0,chars).
'$transl_to_trl_types'(1,codes).
'$transl_to_trl_types'(2,atom).
'$yap_flag_show_gc_tracing'(true, _, _, on) :- !.
'$yap_flag_show_gc_tracing'(_, true, _, verbose) :- !.
'$yap_flag_show_gc_tracing'(_, _, on, very_verbose) :- !.
'$yap_flag_show_gc_tracing'(_, _, _, off).
'$flag_check_alias'(OUT, Alias) :-
stream_property(OUT, alias(Alias)), !.
current_prolog_flag(V,Out) :-
var(V), !,
'$show_yap_flag_opts'(V,NOut),
NOut = Out.
current_prolog_flag(V,Out) :-
atom(V), !,
yap_flag(V,NOut),
NOut = Out.
current_prolog_flag(V,Out) :-
'$do_error'(type_error(atom,V),current_prolog_flag(V,Out)).
set_prolog_flag(F,V) :-
var(F), !,
'$do_error'(instantiation_error,set_prolog_flag(F,V)).
set_prolog_flag(F,V) :-
var(V), !,
'$do_error'(instantiation_error,set_prolog_flag(F,V)).
set_prolog_flag(F, Val) :-
prolog:'$user_defined_flag'(F,_,_,_), !,
yap_flag(F, Val).
set_prolog_flag(F,V) :-
\+ atom(F), !,
'$do_error'(type_error(atom,F),set_prolog_flag(F,V)).
set_prolog_flag(F, Val) :-
prolog:'$user_defined_flag'(F,_,_,_), !,
yap_flag(F, Val).
set_prolog_flag(F,V) :-
'$yap_system_flag'(F), !,
yap_flag(F,V).
set_prolog_flag(F,V) :-
'$user_flags'(UFlag),
(
UFlag = silent ->
create_prolog_flag(F, V, [])
;
UFlag = warning ->
print_message(warning,existence_error(prolog_flag, F)),
create_prolog_flag(F, V, [])
;
UFlag = error ->
'$do_error'(existence_error(prolog_flag, F),set_prolog_flag(F,V))
).
prolog_flag(F, Old, New) :-
var(F), !,
'$do_error'(instantiation_error,prolog_flag(F,Old,New)).
prolog_flag(F, Old, New) :-
current_prolog_flag(F, Old),
set_prolog_flag(F, New).
prolog_flag(F, Old) :-
current_prolog_flag(F, Old).
% if source_mode is on, then the source for the predicates
% is stored with the code
source_mode(Old,New) :-
'$access_yap_flags'(11,X),
'$transl_to_on_off'(X,Old),
'$transl_to_on_off'(XN,New),
'$set_yap_flags'(11,XN).
source :- '$set_yap_flags'(11,1).
no_source :- '$set_yap_flags'(11,0).
create_prolog_flag(Name, Value, Options) :-
'$check_flag_name'(Name, create_prolog_flag(Name, Value, Options)),
'$check_flag_options'(Options, Domain, RW, create_prolog_flag(Name, Value, Options)),
'$check_flag_value'(Value, Domain, create_prolog_flag(Name, Value, Options)),
retractall(prolog:'$user_defined_flag'(Name,_,_,_)),
assert(prolog:'$user_defined_flag'(Name,Domain,RW,Value)).
'$check_flag_name'(V, G) :-
var(V),
'$do_error'(instantiation_error,G).
'$check_flag_name'(Name, _) :-
atom(Name), !.
'$check_flag_name'(Name, G) :-
'$do_error'(type_error(atom),G).
'$check_flag_options'(O, _, _, G) :-
var(O),
'$do_error'(instantiation_error,G).
'$check_flag_options'([], _, read_write, _) :- !.
'$check_flag_options'([O1|Os], Domain, RW, G) :- !,
'$check_flag_optionsl'([O1|Os], Domain, RW, G).
'$check_flag_options'(O, _, _, G) :-
'$do_error'(type_error(list),G).
'$check_flag_optionsl'([], _, read_write, G).
'$check_flag_optionsl'([V|Os], Domain, RW, G) :-
var(V),
'$do_error'(instantiation_error,G).
'$check_flag_optionsl'([type(Type)|Os], Domain, RW, G) :- !,
'$check_flag_type'(Type, Domain, G),
'$check_flag_optionsl'(Os, _, RW, G).
'$check_flag_optionsl'([access(Access)|Os], Domain, RW, G) :- !,
'$check_flag_access'(Access, RW, G),
'$check_flag_optionsl'(Os, Domain, _, G).
'$check_flag_optionsl'(Os, Domain, RW, G) :-
'$do_error'(domain_error(create_prolog_flag,Os),G).
'$check_flag_type'(V, _, G) :-
var(V),
'$do_error'(instantiation_error,G).
'$check_flag_type'(boolean, boolean, _) :- !.
'$check_flag_type'(integer, integer, _) :- !.
'$check_flag_type'(float, float, _) :- !.
'$check_flag_type'(atom, atom, _) :- !.
'$check_flag_type'(term, term, _) :- !.
'$check_flag_type'(Atom, _, G) :-
'$do_error'(domain_error(create_prolog_flag_option(type),Atom),G).
'$check_flag_access'(V, _, G) :-
var(V),
'$do_error'(instantiation_error,G).
'$check_flag_access'(read_write, read_write, _) :- !.
'$check_flag_access'(read_only, read_only, _) :- !.
'$check_flag_type'(Atom, _, G) :-
'$do_error'(domain_error(create_prolog_flag_option(access),Atom),G).
'$user_flag_value'(F, Val) :-
var(Val), !,
'$user_defined_flag'(F,_,_,Val).
'$user_flag_value'(F, Val) :-
atomic(Val), !,
prolog:'$user_defined_flag'(F,Domain,RW,V0),
(
Val == V0
->
true
;
RW = read_only
->
'$do_error'(permission_error(modify,flag,F),yap_flag(F,Val))
;
'$check_flag_value'(Val, Domain, yap_flag(F,Val)),
retractall(prolog:'$user_defined_flag'(F,_,_,_)),
assert(prolog:'$user_defined_flag'(F,Domain,RW,Val))
).
'$user_flag_value'(F, Val) :-
'$do_error'(type_error(atomic,Val),yap_flag(F,Val)).
'$check_flag_value'(Value, _, G) :-
\+ ground(Value), !,
'$do_error'(instantiation_error,G).
'$check_flag_value'(Value, Domain, G) :-
var(Domain), !,
'$flag_domain_from_value'(Value, Domain).
'$check_flag_value'(_, term, _) :- !.
'$check_flag_value'(Value, atom, _) :-
atom(Value), !.
'$check_flag_value'(Value, integer, _) :-
integer(Value), !.
'$check_flag_value'(Value, float, _) :-
float(Value), !.
'$check_flag_value'(true, boolean, _) :- !.
'$check_flag_value'(false, boolean, _) :- !.
'$check_flag_value'(Value, Domain, G) :-
'$do_error'(domain_error(Domain,Value),G).
'$flag_domain_from_value'(true, boolean) :- !.
'$flag_domain_from_value'(false, boolean) :- !.
'$flag_domain_from_value'(Value, integer) :- integer(Value), !.
'$flag_domain_from_value'(Value, float) :- float(Value), !.
'$flag_domain_from_value'(Value, atom) :- atom(Value), !.
'$flag_domain_from_value'(_, term).
'$ensure_autoload' :-
load_files([library(autoloader),
autoloader:library('INDEX'),
swi:library('dialect/swi/INDEX')],
[silent(true),if(not_loaded)]).
yap-6.2.2/pl/grammar.yap 000644 000765 000024 00000010401 11457004725 015025 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: grammar.pl *
* Last rev: *
* mods: *
* comments: BNF grammar for Prolog *
* *
*************************************************************************/
% :- meta_predicate ^(?,0,?).
% ^(Xs, Goal, Xs) :- call(Goal).
% :- meta_predicate ^(?,1,?,?).
% ^(Xs0, Goal, Xs0, Xs) :- call(Goal, Xs).
/*
Variables X in grammar rule bodies are translated as
if phrase(X) had been written, where phrase/3 is obvious.
Also, phrase/2-3 check their first argument.
*/
'$translate_rule'((LP-->RP), (NH:-B)) :-
'$t_head'(LP, NH, NGs, S, SR, (LP-->RP)),
(var(NGs) ->
'$t_body'(RP, _, last, S, SR, B1)
;
'$t_body'((RP,{NGs}), _, last, S, SR, B1)
),
'$t_tidy'(B1, B).
'$t_head'(V, _, _, _, _, G0) :- var(V), !,
'$do_error'(instantiation_error,G0).
'$t_head'((H,List), NH, NGs, S, S1, G0) :- !,
'$t_hgoal'(H, NH, S, SR, G0),
'$t_hlist'(List, S1, SR, NGs, G0).
'$t_head'(H, NH, _, S, SR, G0) :-
'$t_hgoal'(H, NH, S, SR, G0).
'$t_hgoal'(V, _, _, _, G0) :- var(V), !,
'$do_error'(instantiation_error,G0).
'$t_hgoal'(M:H, M:NH, S, SR, G0) :- !,
'$t_hgoal'(H, NH, S, SR, G0).
'$t_hgoal'(H, NH, S, SR, _) :-
'$extend'([S,SR],H,NH).
'$t_hlist'(V, _, _, _, G0) :- var(V), !,
'$do_error'(instantiation_error,G0).
'$t_hlist'([], _, _, true, _).
'$t_hlist'([H], S0, SR, ('C'(SR,H,S0)), _) :- !.
'$t_hlist'([H|List], S0, SR, ('C'(SR,H,S1),G0), Goal) :- !,
'$t_hlist'(List, S0, S1, G0, Goal).
'$t_hlist'(T, _, _, _, Goal) :-
'$do_error'(type_error(list,T),Goal).
%
% Two extra variables:
% ToFill tells whether we need to explictly close the chain of
% variables.
% Last tells whether we are the ones who should close that chain.
%
'$t_body'(Var, filled_in, _, S, S1, phrase(Var,S,S1)) :-
var(Var),
!.
'$t_body'(!, to_fill, last, S, S1, (!, S1 = S)) :- !.
'$t_body'(!, _, _, S, S, !) :- !.
'$t_body'([], to_fill, last, S, S1, S1=S) :- !.
'$t_body'([], _, _, S, S, true) :- !.
'$t_body'([X], filled_in, _, S, SR, 'C'(S,X,SR)) :- !.
'$t_body'([X|R], filled_in, Last, S, SR, ('C'(S,X,SR1),RB)) :- !,
'$t_body'(R, filled_in, Last, SR1, SR, RB).
'$t_body'({T}, to_fill, last, S, S1, (T, S1=S)) :- !.
'$t_body'({T}, _, _, S, S, T) :- !.
'$t_body'((T,R), ToFill, Last, S, SR, (Tt,Rt)) :- !,
'$t_body'(T, ToFill, not_last, S, SR1, Tt),
'$t_body'(R, ToFill, Last, SR1, SR, Rt).
'$t_body'((T->R), ToFill, Last, S, SR, (Tt->Rt)) :- !,
'$t_body'(T, ToFill, not_last, S, SR1, Tt),
'$t_body'(R, ToFill, Last, SR1, SR, Rt).
'$t_body'(\+T, ToFill, _, S, SR, (Tt->fail ; S=SR)) :- !,
'$t_body'(T, ToFill, not_last, S, _, Tt).
'$t_body'((T;R), _ToFill, _, S, SR, (Tt;Rt)) :- !,
'$t_body'(T, _, last, S, SR, Tt),
'$t_body'(R, _, last, S, SR, Rt).
'$t_body'((T|R), _ToFill, _, S, SR, (Tt;Rt)) :- !,
'$t_body'(T, _, last, S, SR, Tt),
'$t_body'(R, _, last, S, SR, Rt).
'$t_body'(M:G, ToFill, Last, S, SR, M:NG) :- !,
'$t_body'(G, ToFill, Last, S, SR, NG).
'$t_body'(T, filled_in, _, S, SR, Tt) :-
'$extend'([S,SR], T, Tt).
'$extend'(More, OldT, NewT) :-
OldT =.. OldL,
lists:append(OldL, More, NewL),
NewT =.. NewL.
'$t_tidy'(P,P) :- var(P), !.
'$t_tidy'((P1;P2), (Q1;Q2)) :- !,
'$t_tidy'(P1, Q1),
'$t_tidy'(P2, Q2).
'$t_tidy'((P1->P2), (Q1->Q2)) :- !,
'$t_tidy'(P1, Q1),
'$t_tidy'(P2, Q2).
'$t_tidy'(((P1,P2),P3), Q) :-
'$t_tidy'((P1,(P2,P3)), Q).
'$t_tidy'((true,P1), Q1) :- !,
'$t_tidy'(P1, Q1).
'$t_tidy'((P1,true), Q1) :- !,
'$t_tidy'(P1, Q1).
'$t_tidy'((P1,P2), (Q1,Q2)) :- !,
'$t_tidy'(P1, Q1),
'$t_tidy'(P2, Q2).
'$t_tidy'(A, A).
'C'([X|S],X,S).
phrase(PhraseDef, WordList) :-
phrase(PhraseDef, WordList, []).
phrase(P, S0, S) :-
var(P), !,
'$do_error'(instantiation_error,phrase(P,S0,S)).
phrase(P, S0, S) :-
( primitive(P), \+ atom(P) ), !,
'$do_error'(type_error(callable,P),phrase(P,S0,S)).
phrase([], S0, S) :- !,
S0 = S.
phrase([H|T], S0, S) :- !,
lists:append([H|T], S, S0).
phrase(Phrase, S0, S) :-
'$t_body'(Phrase, _, last, S0, S, Goal), !,
'$execute'(Goal).
yap-6.2.2/pl/ground.yap 000644 000765 000024 00000003046 11457004725 014704 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: ground.pl *
* Last rev: *
* mods: *
* comments: Variables and ground *
* *
*************************************************************************/
/*
% grounds all free variables
% as terms of the form '$VAR'(N)
numbervars('$VAR'(M), M, N) :- !,
succ(M, N).
numbervars(Atomic, M, M) :-
atomic(Atomic), !.
numbervars(Term, M, N) :-
functor(Term, _, Arity),
'$numbervars'(0,Arity, Term, M, N).
'$numbervars'(A, A, _, N, N) :- !.
'$numbervars'(A,Arity, Term, M, N) :-
'$succ'(A,An),
arg(An, Term, Arg),
numbervars(Arg, M, K), !,
'$numbervars'(An, Arity, Term, K, N).
ground(Term) :-
nonvar(Term), % This term is not a variable,
functor(Term, _, Arity),
'$ground'(Arity, Term). % and none of its arguments are.
'$ground'(0, _) :- !.
'$ground'(N, Term) :-
'$predc'(N,M),
arg(N, Term, ArgN),
ground(ArgN),
'$ground'(M, Term).
*/
numbervars(Term, M, N) :-
'$variables_in_term'(Term, [], L),
'$numbermarked_vars'(L, M, N).
'$numbermarked_vars'([], M, M).
'$numbermarked_vars'([V|L], M, N) :-
attvar(V), !,
'$numbermarked_vars'(L, M, N).
'$numbermarked_vars'(['$VAR'(M)|L], M, N) :-
M1 is M+1,
'$numbermarked_vars'(L, M1, N).
yap-6.2.2/pl/hacks.yap 000644 000765 000024 00000016644 11457004725 014507 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: utilities for messing around in YAP internals. *
* comments: error messages for YAP *
* *
* Last rev: $Date: 2008-03-24 23:48:47 $,$Author: vsc $ *
* *
* *
*************************************************************************/
:- module('$hacks',
[display_stack_info/4,
display_stack_info/6,
display_pc/3,
code_location/3]).
prolog:'$stack_dump' :-
yap_hacks:current_choicepoints(CPs),
yap_hacks:current_continuations([Env|Envs]),
yap_hacks:continuation(Env,_,ContP,_),
length(CPs, LCPs),
length(Envs, LEnvs),
format(user_error,'~n~n~tStack Dump~t~40+~n~nAddress~tChoiceP~16+ Clause Goal~n',[LCPs,LEnvs]),
display_stack_info(CPs, Envs, 20, ContP, StackInfo, []),
run_formats(StackInfo, user_error).
run_formats([], _).
run_formats([Com-Args|StackInfo], Stream) :-
format(Stream, Com, Args),
run_formats(StackInfo, user_error).
display_stack_info(CPs,Envs,Lim,PC) :-
display_stack_info(CPs,Envs,Lim,CP,Lines,[]),
flush_output(user_output),
flush_output(user_error),
print_message_lines(user_error, '', Lines).
code_location(Info,Where,Location) :-
integer(Where) , !,
'$pred_for_code'(Where,Name,Arity,Mod,Clause),
construct_code(Clause,Name,Arity,Mod,Info,Location).
code_location(Info,_,Info).
construct_code(-1,Name,Arity,Mod,Where,Location) :- !,
number_codes(Arity,ArityCode),
atom_codes(ArityAtom,ArityCode),
atom_concat([Where,' at ',Mod,':',Name,'/',ArityAtom,' at indexing code'],Location).
construct_code(0,_,_,_,Location,Location) :- !.
construct_code(Cl,Name,Arity,Mod,Where,Location) :-
number_codes(Arity,ArityCode),
atom_codes(ArityAtom,ArityCode),
number_codes(Cl,ClCode),
atom_codes(ClAtom,ClCode),
atom_concat([Where,' at ',Mod,':',Name,'/',ArityAtom,' (clause ',ClAtom,')'],Location).
'$prepare_loc'(Info,Where,Location) :- integer(Where), !,
'$pred_for_code'(Where,Name,Arity,Mod,Clause),
'$construct_code'(Clause,Name,Arity,Mod,Info,Location).
'$prepare_loc'(Info,_,Info).
display_pc(PC) -->
{ integer(PC) },
{ '$pred_for_code'(PC,Name,Arity,Mod,Clause) },
pc_code(Clause,Name,Arity,Mod).
pc_code(-1,Name,Arity,Mod) --> !,
[ ' indexing code of ~a:~q/~d' - [Mod,Name,Arity] ].
pc_code(Cl,Name,Arity,Mod) -->
{ Cl > 0 },
[ ' clause ~d of ~a:~q/~d' - [Cl,Mod,Name,Arity] ].
display_stack_info(_,_,0,_) --> !.
display_stack_info([],[],_,_) --> [].
display_stack_info([CP|CPs],[],I,_) -->
show_lone_cp(CP),
{ I1 is I-1 },
display_stack_info(CPs,[],I1,_).
display_stack_info([],[Env|Envs],I,Cont) -->
show_env(Env, Cont, NCont),
{ I1 is I-1 },
display_stack_info([], Envs, I1, NCont).
display_stack_info([CP|LCPs],[Env|LEnvs],I,Cont) -->
{
yap_hacks:continuation(Env, _, NCont, CB),
I1 is I-1
},
( { CP == Env, CB < CP } ->
% if we follow choice-point and we cut to before choice-point
% we are the same goal
show_cp(CP, ''), %
display_stack_info(LCPs, LEnvs, I1, NCont)
;
{ CP > Env } ->
show_cp(CP, ' < '),
display_stack_info(LCPs,[Env|LEnvs],I1,Cont)
;
show_env(Env,Cont,NCont),
display_stack_info([CP|LCPs],LEnvs,I1,NCont)
).
show_cp(CP, Continuation) -->
{ yap_hacks:choicepoint(CP, Addr, Mod, Name, Arity, Goal, ClNo) },
( { Goal = (_;_) }
->
{ scratch_goal(Name,Arity,Mod,Caller) },
[ '0x~16r~t*~16+ ~d~16+ ~q ~n'-
[Addr, ClNo, Caller] ]
;
[ '0x~16r~t *~16+~a ~d~16+ ~q:' -
[Addr, Continuation, ClNo, Mod]]
),
{ prolog_flag( debugger_print_options, Opts) },
{clean_goal(Goal,Mod,G)},
['~@.~n' - write_term(G,Opts)].
show_env(Env,Cont,NCont) -->
{
yap_hacks:continuation(Env, Addr, NCont, _),
yap_hacks:cp_to_predicate(Cont, Mod, Name, Arity, ClId)
},
[ '0x~16r~t ~16+ ~d~16+ ~q:' -
[Addr, ClId, Mod] ],
{scratch_goal(Name, Arity, Mod, G)},
{ prolog_flag( debugger_print_options, Opts) },
['~@.~n' - write_term(G,Opts)].
clean_goal(G,Mod,NG) :-
beautify_hidden_goal(G,Mod,[NG],[]), !.
clean_goal(G,_,G).
scratch_goal(N,0,Mod,Mod:N) :-
!.
scratch_goal(N,A,Mod,NG) :-
list_of_qmarks(A,L),
G=..[N|L],
(
beautify_hidden_goal(G,Mod,[NG],[])
;
G = NG
),
!.
list_of_qmarks(0,[]) :- !.
list_of_qmarks(I,[?|L]) :-
I1 is I-1,
list_of_qmarks(I1,L).
beautify_hidden_goal('$yes_no'(G,Query), prolog) -->
!,
{ Call =.. [(?), G] },
[Call].
beautify_hidden_goal('$do_yes_no'(G,Mod), prolog) -->
[Mod:G].
beautify_hidden_goal('$query'(G,VarList), prolog) -->
[query(G,VarList)].
beautify_hidden_goal('$enter_top_level', prolog) -->
['TopLevel'].
% The user should never know these exist.
beautify_hidden_goal('$csult'(Files,Mod),prolog) -->
[reconsult(Mod:Files)].
beautify_hidden_goal('$use_module'(Files,Mod,Is),prolog) -->
[use_module(Mod,Files,Is)].
beautify_hidden_goal('$continue_with_command'(reconsult,V,P,G,Source),prolog) -->
['Assert'(G,V,P,Source)].
beautify_hidden_goal('$continue_with_command'(consult,V,P,G,Source),prolog) -->
['Assert'(G,V,P,Source)].
beautify_hidden_goal('$continue_with_command'(top,V,P,G,_),prolog) -->
['Query'(G,V,P)].
beautify_hidden_goal('$continue_with_command'(Command,V,P,G,Source),prolog) -->
['TopLevel'(Command,G,V,P,Source)].
beautify_hidden_goal('$spycall'(G,M,InControl,Redo),prolog) -->
['DebuggerCall'(M:G, InControl, Redo)].
beautify_hidden_goal('$do_spy'(Goal, Mod, CP, InControl),prolog) -->
['DebuggerCall'(Mod:Goal, InControl)].
beautify_hidden_goal('$system_catch'(G,Mod,Exc,Handler),prolog) -->
[catch(Mod:G, Exc, Handler)].
beautify_hidden_goal('$catch'(G,Exc,Handler),prolog) -->
[catch(G, Exc, Handler)].
beautify_hidden_goal('$execute_command'(Query,V,P,Option,Source),prolog) -->
[toplevel_query(Query, V, P, Option, Source)].
beautify_hidden_goal('$process_directive'(Gs,_,Mod),prolog) -->
[(:- Mod:Gs)].
beautify_hidden_goal('$loop'(Stream,Option),prolog) -->
[execute_load_file(Stream, consult=Option)].
beautify_hidden_goal('$load_files'(Files,Opts,?),prolog) -->
[load_files(Files,Opts)].
beautify_hidden_goal('$load_files'(_,_,Name),prolog) -->
[Name].
beautify_hidden_goal('$reconsult'(Files,Mod),prolog) -->
[reconsult(Mod:Files)].
beautify_hidden_goal('$undefp'([M|G]),prolog) -->
['CallUndefined'(Mod:G)].
beautify_hidden_goal('$undefp'(?),prolog) -->
['CallUndefined'(?:?)].
beautify_hidden_goal(repeat,prolog) -->
[repeat].
beautify_hidden_goal('$recorded_with_key'(A,B,C),prolog) -->
recorded(A,B,C).
beautify_hidden_goal('$findall_with_common_vars'(Templ,Gen,Answ),prolog) -->
[findall(Templ,Gen,Answ)].
beautify_hidden_goal('$bagof'(Templ,Gen,Answ),prolog) -->
[bagof(Templ,Gen,Answ)].
beautify_hidden_goal('$setof'(Templ,Gen,Answ),prolog) -->
[setof(Templ,Gen,Answ)].
beautify_hidden_goal('$findall'(T,G,S,A),prolog) -->
[findall(T,G,S,A)].
beautify_hidden_goal('$listing'(G,M,_Stream),prolog) -->
[listing(M:G)].
beautify_hidden_goal('$call'(G,CP,?,M),prolog) -->
[call(M:G)].
beautify_hidden_goal('$call'(G,CP,G0,M),prolog) -->
[call(M:G0)].
beautify_hidden_goal('$current_predicate'(M,Na,Ar),prolog) -->
[current_predicate(M,Na/Ar)].
beautify_hidden_goal('$current_predicate_for_atom'(M,Na,Ar),prolog) -->
[current_predicate(M,Na/Ar)].
beautify_hidden_goal('$list_clauses'(Stream,M,Pred),prolog) -->
[listing(M:Pred)].
yap-6.2.2/pl/init.yap 000644 000765 000024 00000010116 11572366532 014352 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: init.yap *
* Last rev: *
* mods: *
* comments: initializing the full prolog system *
* *
*************************************************************************/
% This is yap's init file
% should be consulted first step after booting
% These are pseudo declarations
% so that the user will get a redefining system predicate
fail :- fail.
false :- fail.
otherwise.
!.
(:- G) :- '$execute'(G), !.
(?- G) :- '$execute'(G).
'$$!'(CP) :- '$cut_by'(CP).
[] :- true.
:- set_value('$doindex',true).
% force having indexing code for throw.
:- '$handle_throw'(_,_,_), !.
:- bootstrap('errors.yap').
:- bootstrap('consult.yap').
:- [ 'utils.yap',
'control.yap',
'arith.yap',
'directives.yap',
'flags.yap'].
:- compile_expressions.
:- [
% lists is often used.
'lists.yap',
'yio.yap',
'debug.yap',
'checker.yap',
'depth_bound.yap',
'grammar.yap',
'ground.yap',
'listing.yap',
'preds.yap',
% modules must be after preds, otherwise we will have trouble
% with meta-predicate expansion being invoked
'modules.yap',
% must follow grammar
'eval.yap',
'signals.yap',
'profile.yap',
'callcount.yap',
'load_foreign.yap',
'save.yap',
'sockets.yap',
'sort.yap',
'setof.yap',
'statistics.yap',
'strict_iso.yap',
'tabling.yap',
'threads.yap',
'eam.yap',
'chtypes.yap',
'yapor.yap',
'udi.yap'].
:- dynamic prolog:'$user_defined_flag'/4.
:- dynamic prolog:'$parent_module'/2.
:- multifile prolog:debug_action_hook/1.
:- source.
:- no_source.
:- ['protect.yap'].
version(yap,[6,0]).
system_mode(verbose,on) :- set_value('$verbose',on).
system_mode(verbose,off) :- set_value('$verbose',off).
:- op(1150,fx,(mode)).
:- dynamic 'extensions_to_present_answer'/1.
:- ['arrays.yap'].
:- use_module('messages.yap').
:- use_module('hacks.yap').
:- use_module('attributes.yap').
:- use_module('corout.yap').
:- use_module('dialect.yap').
'$system_module'('$messages').
'$system_module'('$hacks').
'$system_module'('$attributes').
'$system_module'('$coroutining').
yap_hacks:cut_by(CP) :- '$$cut_by'(CP).
:- '$change_type_of_char'(36,7). % Make $ a symbol character
:- default_sequential(off).
:- multifile user:library_directory/1.
:- dynamic user:library_directory/1.
:- multifile user:commons_directory/1.
:- dynamic user:commons_directory/1.
:- recorda('$dialect',yap,_).
%
% cleanup ensure loaded and recover some data-base space.
%
:- ( recorded('$loaded','$loaded'(_,_,_),R), erase(R), fail ; true ).
:- dynamic autoloader:autoload/0.
:- set_value('$user_module',user), '$protect'.
:- style_check([]).
%
% moved this to init_gc in gc.c to separate the alpha
%
% :- yap_flag(gc,on).
% :- yap_flag(gc_trace,verbose).
:- system_mode(verbose,on).
:- multifile prolog:message/3.
:- dynamic prolog:message/3.
:- module(user).
:- multifile goal_expansion/3.
:- dynamic goal_expansion/3.
:- multifile goal_expansion/2.
:- dynamic goal_expansion/2.
:- multifile term_expansion/2.
:- dynamic term_expansion/2.
:- multifile file_search_path/2.
:- dynamic file_search_path/2.
:- multifile generate_message_hook/3.
:- dynamic generate_message_hook/3.
:- multifile swi:swi_predicate_table/4.
:- multifile user:message_hook/3.
:- dynamic user:message_hook/3.
:- multifile user:portray_message/2.
:- multifile user:exception/3.
:- dynamic user:exception/3.
file_search_path(library, Dir) :-
library_directory(Dir).
file_search_path(commons, Dir) :-
commons_directory(Dir0).
file_search_path(swi, Home) :-
current_prolog_flag(home, Home).
file_search_path(yap, Home) :-
current_prolog_flag(home, Home).
file_search_path(system, Dir) :-
prolog_flag(host_type, Dir).
file_search_path(foreign, yap('lib/Yap')).
:- yap_flag(unknown,fail).
yap-6.2.2/pl/listing.yap 000644 000765 000024 00000011624 11457004725 015060 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: listing.pl *
* Last rev: *
* mods: *
* comments: listing a prolog program *
* *
*************************************************************************/
/* listing : Listing clauses in the database
*/
listing :-
current_output(Stream),
'$current_module'(Mod),
'$current_predicate_no_modules'(Mod,_,Pred),
'$list_clauses'(Stream,Mod,Pred).
listing.
listing(V) :-
current_output(Stream),
'$current_module'(M),
'$listing'(V,M,Stream).
'$listing'(V,Mod,Stream) :- var(V), !,
'$current_predicate_no_modules'(Mod,_,Pred),
'$list_clauses'(Stream,Mod,Pred).
'$listing'(M:V,_,Stream) :- !,
'$listing'(V,M,Stream).
'$listing'([],_,_) :- !.
'$listing'([X|Rest], M, Stream) :-
!,
'$listing'(X, M, Stream),
'$listing'(Rest, M, Stream).
'$listing'(X, M, Stream) :-
'$funcspec'(X,Name,Arity),
'$current_predicate_no_modules'(M,Name,Pred),
functor(Pred,Name,Arity),
'$list_clauses'(Stream,M,Pred).
'$listing'(_,_,_).
'$funcspec'(Name/Arity,Name,Arity) :- !, atom(Name).
'$funcspec'(Name,Name,_) :- atom(Name), !.
'$funcspec'(Name,_,_) :-
'$do_error'(domain_error(predicate_spec,Name),listing(Name)).
'$list_clauses'(Stream, M, Pred) :-
'$flags'(Pred,M,Flags,Flags),
% has to be dynamic, source, or log update.
Flags /\ 0x08402000 =\= 0,
'$clause'(Pred, M, Body, _),
'$portray_clause'(Stream,(Pred:-Body)),
fail.
portray_clause(Stream, Clause) :-
copy_term_nat(Clause, CopiedClause),
'$portray_clause'(Stream, CopiedClause),
fail.
portray_clause(_, _).
portray_clause(Clause) :-
current_output(Stream),
copy_term_nat(Clause, CopiedClause),
'$portray_clause'(Stream, CopiedClause),
fail.
portray_clause(_).
'$portray_clause'(Stream, (Pred :- true)) :- !,
'$beautify_vars'(Pred),
writeq(Stream, Pred),
format(Stream, '.~n', []).
'$portray_clause'(Stream, (Pred:-Body)) :- !,
'$beautify_vars'((Pred:-Body)),
writeq(Stream, Pred),
format(Stream, ' :-', []),
'$write_body'(Body, 3, ',', Stream),
format(Stream, '.~n', []).
'$portray_clause'(Stream, Pred) :- !,
'$beautify_vars'(Pred),
writeq(Stream, Pred),
format(Stream, '.~n', []).
'$write_body'(X,I,T,Stream) :- var(X), !,
'$beforelit'(T,I,Stream),
writeq(Stream, '_').
'$write_body'((P,Q), I, T, Stream) :-
!,
'$write_body'(P,I,T, Stream),
put(Stream, 0',),
'$write_body'(Q,I,',',Stream).
'$write_body'((P->Q;S),I,_, Stream) :-
!,
format(Stream, '~n~*c(',[I,0' ]),
I1 is I+2,
'$write_body'(P,I1,'(',Stream),
format(Stream, ' ->',[]),
'$write_disj'((Q;S),I,I1,'->',Stream),
format(Stream, '~n~*c)',[I,0' ]).
'$write_body'((P->Q|S),I,_,Stream) :-
!,
format(Stream, '~n~*c(',[I,0' ]),
I1 is I+2,
'$write_body'(P,I,'(',Stream),
format(Stream, ' ->',[]),
'$write_disj'((Q|S),I,I1,'->',Stream),
format(Stream, '~n~*c)',[I,0' ]).
'$write_body'((P->Q),I,_,Stream) :-
!,
format(Stream, '~n~*c(',[I,0' ]),
I1 is I+2,
'$write_body'(P,I1,'(',Stream),
format(Stream, ' ->',[]),
'$write_body'(Q,I1,'->',Stream),
format(Stream, '~n~*c)',[I,0' ]).
'$write_body'((P;Q),I,_,Stream) :-
!,
format(Stream, '~n~*c(',[I,0' ]),
I1 is I+2,
'$write_disj'((P;Q),I,I1,'->',Stream),
format(Stream, '~n~*c)',[I,0' ]).
'$write_body'((P|Q),I,_,Stream) :-
!,
format(Stream, '~n~*c(',[I,0' ]),
I1 is I+2,
'$write_disj'((P|Q),I,I1,'->',Stream),
format(Stream, '~n~*c)',[I,0' ]).
'$write_body'(X,I,T,Stream) :-
'$beforelit'(T,I,Stream),
writeq(Stream,X).
'$write_disj'((Q;S),I0,I,C,Stream) :- !,
'$write_body'(Q,I,C,Stream),
format(Stream, '~n~*c;',[I0,0' ]),
'$write_disj'(S,I0,I,';',Stream).
'$write_disj'((Q|S),I0,I,C,Stream) :- !,
'$write_body'(Q,I,C,Stream),
format(Stream, '~n~*c|',[I0,0' ]),
'$write_disj'(S,I0,I,'|',Stream).
'$write_disj'(S,_,I,C,Stream) :-
'$write_body'(S,I,C,Stream).
'$beforelit'('(',_,Stream) :- !, format(Stream,' ',[]).
'$beforelit'(_,I,Stream) :- format(Stream,'~n~*c',[I,0' ]).
'$beautify_vars'(T) :-
'$list_get_vars'(T,[],L),
msort(L,SL),
'$list_transform'(SL,0).
'$list_get_vars'(V,L,[V|L] ) :- var(V), !.
'$list_get_vars'(Atomic, M, M) :-
primitive(Atomic), !.
'$list_get_vars'([Arg|Args], M, N) :- !,
'$list_get_vars'(Arg, M, K),
'$list_get_vars'(Args, K, N).
'$list_get_vars'(Term, M, N) :-
Term =.. [_|Args],
'$list_get_vars'(Args, M, N).
'$list_transform'([],_) :- !.
'$list_transform'([X,Y|L],M) :-
X == Y,
X = '$VAR'(M),
!,
N is M+1,
'$list_transform'(L,N).
'$list_transform'('$VAR'(-1).L,M) :- !,
'$list_transform'(L,M).
'$list_transform'(_.L,M) :-
'$list_transform'(L,M).
yap-6.2.2/pl/lists.yap 000644 000765 000024 00000001251 11457004725 014540 0 ustar 00vsc staff 000000 000000 % memberchk(+Element, +Set)
% means the same thing, but may only be used to test whether a known
% Element occurs in a known Set. In return for this limited use, it
% is more efficient when it is applicable.
lists:memberchk(X,[X|_]) :- !.
lists:memberchk(X,[_|L]) :-
lists:memberchk(X,L).
% member(?Element, ?Set)
% is true when Set is a list, and Element occurs in it. It may be used
% to test for an element or to enumerate all the elements by backtracking.
% Indeed, it may be used to generate the Set!
lists:member(X,[X|_]).
lists:member(X,[_|L]) :-
lists:member(X,L).
lists:append([], L, L).
lists:append([H|T], L, [H|R]) :-
lists:append(T, L, R).
yap-6.2.2/pl/load_foreign.yap 000644 000765 000024 00000010113 11457004725 016027 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: load_foreign.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: Utility predicates for load_foreign *
* *
*************************************************************************/
load_foreign_files(Objs,Libs,Entry) :-
'$check_objs_for_load_foreign_files'(Objs,NewObjs,load_foreign_files(Objs,Libs,Entry)),
'$check_libs_for_load_foreign_files'(Libs,NewLibs,load_foreign_files(Objs,Libs,Entry)),
'$check_entry_for_load_foreign_files'(Entry,load_foreign_files(Objs,Libs,Entry)),
'$load_foreign_files'(NewObjs,NewLibs,Entry).
'$check_objs_for_load_foreign_files'(V,_,G) :- var(V), !,
'$do_error'(instantiation_error,G).
'$check_objs_for_load_foreign_files'([],[],_) :- !.
'$check_objs_for_load_foreign_files'([Obj|Objs],[NObj|NewObjs],G) :- !,
'$check_obj_for_load_foreign_files'(Obj,NObj,G),
'$check_objs_for_load_foreign_files'(Objs,NewObjs,G).
'$check_objs_for_load_foreign_files'(Objs,_,G) :-
'$do_error'(type_error(list,Objs),G).
'$check_obj_for_load_foreign_files'(V,_,G) :- var(V), !,
'$do_error'(instantiation_error,G).
'$check_obj_for_load_foreign_files'(Obj,NewObj,_) :- atom(Obj), !,
atom_codes(Obj,ObjCodes),
'$process_obj_suffix'(ObjCodes,NewObjCodes),
atom_codes(NewObj,NewObjCodes).
'$check_obj_for_load_foreign_files'(Obj,_,G) :-
'$do_error'(type_error(atom,Obj),G).
'$check_libs_for_load_foreign_files'(V,_,G) :- var(V), !,
'$do_error'(instantiation_error,G).
'$check_libs_for_load_foreign_files'([],[],_) :- !.
'$check_libs_for_load_foreign_files'([Lib|Libs],[NLib|NLibs],G) :- !,
'$check_lib_for_load_foreign_files'(Lib,NLib,G),
'$check_libs_for_load_foreign_files'(Libs,NLibs,G).
'$check_libs_for_load_foreign_files'(Libs,_,G) :-
'$do_error'(type_error(list,Libs),G).
'$check_lib_for_load_foreign_files'(V,_,G) :- var(V), !,
'$do_error'(instantiation_error,G).
'$check_lib_for_load_foreign_files'(Lib,NLib,_) :- atom(Lib), !,
atom_codes(Lib,LibCodes),
'$process_obj_suffix'(LibCodes,NewLibCodes),
'$checklib_prefix'(NewLibCodes,FullLibCodes),
atom_codes(NLib,FullLibCodes).
'$check_lib_for_load_foreign_files'(Lib,_,G) :-
'$do_error'(type_error(atom,Lib),G).
'$process_obj_suffix'(ObjCodes,ObjCodes) :-
'$obj_suffix'(ObjSuffix),
lists:append(_,ObjSuffix,ObjCodes), !.
'$process_obj_suffix'(ObjCodes,NewObjCodes) :-
'$obj_suffix'(ObjSuffix),
lists:append(ObjCodes,ObjSuffix,NewObjCodes).
'$checklib_prefix'(Cs,Cs) :- '$rooted_path'(Cs), !.
'$checklib_prefix'([0'l,0'i,0'b|NewObjCodes],[0'l,0'i,0'b|NewObjCodes]) :- !.
'$checklib_prefix'(NewObjCodes,[0'l,0'i,0'b|NewObjCodes]).
'$rooted_path'([C|_]) :- '$dir_separator'(C), !.
% windows drive z:\
'$rooted_path'([_,0':,0'\\|_]) .
'$get_drive'([0':|_]) :- !.
'$get_drive'([0'\\|_]) :- !, fail.
'$get_drive'([_|L]) :-
'$get_drive'(L).
'$check_entry_for_load_foreign_files'(V,G) :- var(V), !,
'$do_error'(instantiation_error,G).
'$check_entry_for_load_foreign_files'(Entry,_) :- atom(Entry), !.
'$check_entry_for_load_foreign_files'(Entry,G) :-
'$do_error'(type_error(atom,Entry),G).
open_shared_object(File, Handle) :-
'$open_shared_object'(File, 0, Handle).
open_shared_object(File, Opts, Handle) :-
'$open_shared_opts'(Opts, open_shared_object(File, Opts, Handle), OptsI),
'$open_shared_object'(File, OptsI, Handle).
'$open_shared_opts'(Opts, G, OptsI) :-
var(Opts), !,
'$do_error'(instantiation_error,G).
'$open_shared_opts'([], _, 0) :- !.
'$open_shared_opts'(Opt.Opts, G, V) :-
'$open_shared_opts'(Opts, G, V0),
'$open_shared_opt'(Opt, G, OptV),
V0 is V \/ OptV.
'$open_shared_opt'(Opt, G, _) :-
var(Opt), !,
'$do_error'(instantiation_error,G).
'$open_shared_opt'(now, __, 1) :- !.
'$open_shared_opt'(global, __, 2) :- !.
'$open_shared_opt'(Opt, Goal, _) :-
'$do_error'(domain_error(open_shared_object_option,Opt),Goal).
yap-6.2.2/pl/messages.yap 000644 000765 000024 00000051433 11501531054 015206 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: utilities for displaying messages in YAP. *
* comments: error messages for YAP *
* *
* Last rev: $Date: 2008-07-16 10:58:59 $,$Author: vsc $ *
* *
* *
*************************************************************************/
:- module('$messages',
[system_message/4,
prefix/6,
prefix/5,
file_location/3]).
file_location(Prefix) -->
{
prolog_load_context(file, FileName)
},
{ '$start_line'(LN) },
file_position(FileName,LN,Prefix),
[ nl ].
file_position(user_input,LN,MsgCodes) -->
[ '~a (user_input:~d).' - [MsgCodes,LN] ].
file_position(FileName,LN,MsgCodes) -->
[ '~a (~a:~d).' - [MsgCodes,FileName,LN] ].
generate_message(halt) --> !,
['YAP execution halted'].
generate_message('$abort') --> !,
['YAP execution aborted'].
generate_message(abort(user)) --> !,
['YAP execution aborted'].
generate_message(loading(_,user)) --> !.
generate_message(loading(What,AbsoluteFileName)) --> !,
[ '~a ~a...' - [What, AbsoluteFileName] ].
generate_message(loaded(_,user,_,_,_)) --> !.
generate_message(loaded(included,AbsoluteFileName,Mod,Time,Space)) --> !,
[ '~a included in module ~a, ~d msec ~d bytes' - [AbsoluteFileName,Mod,Time,Space] ].
generate_message(loaded(What,AbsoluteFileName,Mod,Time,Space)) --> !,
[ '~a ~a in module ~a, ~d msec ~d bytes' - [What, AbsoluteFileName,Mod,Time,Space] ].
generate_message(prompt(BreakLevel,TraceDebug)) --> !,
( { BreakLevel =:= 0 } ->
(
{ var(TraceDebug) } ->
[]
;
[ '~a' - [TraceDebug] ]
)
;
(
{ var(TraceDebug) } ->
[ '~d' - [BreakLevel] ]
;
[ '~d ~a' - [BreakLevel, TraceDebug] ]
)
).
generate_message(debug) --> !,
[ debug ].
generate_message(trace) --> !,
[ trace ].
generate_message(M) -->
system_message(M),
stack_dump(M).
stack_dump(error(_,_)) -->
{ fail },
{ recorded(sp_info,local_sp(P,CP,Envs,CPs),_) },
{ Envs = [_|_] ; CPs = [_|_] }, !,
[nl],
'$hacks':display_stack_info(CPs, Envs, 20, CP).
stack_dump(_) --> [].
prolog_message(X,Y,Z) :-
system_message(X,Y,Z).
%message(loaded(Past,AbsoluteFileName,user,Msec,Bytes), Prefix, Suffix) :- !,
system_message(query(_QueryResult,_)) --> [].
system_message(format(Msg, Args)) -->
[Msg - Args].
system_message(ancestors([])) -->
[ 'There are no ancestors.' ].
system_message(breakp(bp(debugger,_,_,M:F/N,_),add,already)) -->
[ 'There is already a spy point on ~w:~w/~w.' - [M,F,N]].
system_message(breakp(bp(debugger,_,_,M:F/N,_),add,ok)) -->
[ 'Spy point set on ~w:~w/~w.' - [M,F,N] ].
system_message(breakp(bp(debugger,_,_,M:F/N,_),remove,last)) -->
[ 'Spy point on ~w:~w/~w removed.' - [M,F,N] ].
system_message(breakp(no,breakpoint_for,M:F/N)) -->
[ 'There is no spy point on ~w:~w/~w.' - [M,F,N]].
system_message(breakpoints([])) -->
[ 'There are no spy-points set.' ].
system_message(breakpoints(L)) -->
[ 'Spy-points set on:' ],
list_of_preds(L).
system_message(clauses_not_together(P)) -->
[ 'Discontiguous definition of ~q.' - [P] ].
system_message(debug(debug)) -->
[ 'Debug mode on.' ].
system_message(debug(off)) -->
[ 'Debug mode off.' ].
system_message(debug(trace)) -->
[ 'Trace mode on.' ].
system_message(declaration(Args,Action)) -->
[ 'declaration ~w ~w.' - [Args,Action] ].
system_message(defined_elsewhere(P,F)) -->
[ 'predicate ~q previously defined in file ~w' - [P,F] ].
system_message(import(Pred,To,From,private)) -->
[ 'Importing private predicate ~w:~w to ~w.' - [From,Pred,To] ].
system_message(leash([])) -->
[ 'No leashing.' ].
system_message(leash([A|B])) -->
[ 'Leashing set to ~w.' - [[A|B]] ].
system_message(no) -->
[ 'no' ].
system_message(no_match(P)) -->
[ 'No matching predicate for ~w.' - [P] ].
system_message(leash([A|B])) -->
[ 'Leashing set to ~w.' - [[A|B]] ].
system_message(existence_error(prolog_flag,F)) -->
[ 'Prolog Flag ~w: new Prolog flags must be created using create_prolog_flag/3.' - [F] ].
system_message(singletons([SV],P)) -->
[ 'Singleton variable ~s in ~q.' - [SV,P] ].
system_message(singletons(SVs,P)) -->
[ 'Singleton variables ~s in ~q.' - [SVsL, P] ],
{ svs(SVs,SVsL,[]) }.
system_message(trace_command(-1)) -->
[ 'EOF is not a valid debugger command.' ].
system_message(trace_command(C)) -->
[ '~c is not a valid debugger command.' - [C] ].
system_message(trace_help) -->
[ ' Please enter a valid debugger command (h for help).' ].
system_message(version(Version)) -->
[ '~a' - [Version] ].
system_message(myddas_version(Version)) -->
[ 'MYDDAS version ~a' - [Version] ].
system_message(yes) -->
[ 'yes' ].
system_message(error,error(Msg,Info)) -->
( { var(Msg) } ; { var(Info)} ), !,
['bad error ~w' - [error(Msg,Info)]].
system_message(error(consistency_error(Who),Where)) -->
[ 'CONSISTENCY ERROR (arguments not compatible with format)- ~w ~w' - [Who,Where] ].
system_message(error(context_error(Goal,Who),Where)) -->
[ 'CONTEXT ERROR- ~w: ~w appeared in ~w' - [Goal,Who,Where] ].
system_message(error(domain_error(DomainType,Opt), Where)) -->
[ 'DOMAIN ERROR- ~w: ' - Where],
domain_error(DomainType, Opt).
system_message(error(existence_error(prolog_flag,P), Where)) --> !,
[ 'EXISTENCE ERROR- ~w: prolog flag ~w is undefined' - [Where,P] ].
system_message(error(existence_error(procedure,P), context(Call,Parent))) --> !,
[ 'EXISTENCE ERROR- procedure ~w is undefined, called from context ~w~n Goal was ~w' - [P,Parent,Call] ].
system_message(error(existence_error(stream,Stream), Where)) -->
[ 'EXISTENCE ERROR- ~w: ~w not an open stream' - [Where,Stream] ].
system_message(error(existence_error(key,Key), Where)) -->
[ 'EXISTENCE ERROR- ~w: ~w not an existing key' - [Where,Key] ].
system_message(error(existence_error(thread,Thread), Where)) -->
[ 'EXISTENCE ERROR- ~w: ~w not a running thread' - [Where,Thread] ].
system_message(error(existence_error(variable,Var), Where)) -->
[ 'EXISTENCE ERROR- ~w: variable ~w does not exist' - [Where,Var] ].
system_message(error(existence_error(Name,F), W)) -->
{ object_name(Name, ObjName) },
[ 'EXISTENCE ERROR- ~w could not open ~a ~w' - [W,ObjName,F] ].
system_message(error(evaluation_error(int_overflow), Where)) -->
[ 'INTEGER OVERFLOW ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(float_overflow), Where)) -->
[ 'FLOATING POINT OVERFLOW ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(undefined), Where)) -->
[ 'UNDEFINED ARITHMETIC RESULT ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(underflow), Where)) -->
[ 'UNDERFLOW ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(float_underflow), Where)) -->
[ 'FLOATING POINT UNDERFLOW ERROR- ~w' - [Where] ].
system_message(error(evaluation_error(zero_divisor), Where)) -->
[ 'ZERO DIVISOR ERROR- ~w' - [Where] ].
system_message(error(instantiation_error, Where)) -->
[ 'INSTANTIATION ERROR- ~w: expected bound value' - [Where] ].
system_message(error(not_implemented(Type, What), Where)) -->
[ '~w not implemented- ~w' - [Type, What] ].
system_message(error(operating_system_error, Where)) -->
[ 'OPERATING SYSTEM ERROR- ~w' - [Where] ].
system_message(error(out_of_heap_error, Where)) -->
[ 'OUT OF DATABASE SPACE ERROR- ~w' - [Where] ].
system_message(error(out_of_stack_error, Where)) -->
[ 'OUT OF STACK SPACE ERROR- ~w' - [Where] ].
system_message(error(out_of_trail_error, Where)) -->
[ 'OUT OF TRAIL SPACE ERROR- ~w' - [Where] ].
system_message(error(out_of_attvars_error, Where)) -->
[ 'OUT OF STACK SPACE ERROR- ~w' - [Where] ].
system_message(error(out_of_auxspace_error, Where)) -->
[ 'OUT OF AUXILIARY STACK SPACE ERROR- ~w' - [Where] ].
system_message(error(permission_error(access,private_procedure,P), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot see clauses for ~w' - [Where,P] ].
system_message(error(permission_error(access,static_procedure,P), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot access static procedure ~w' - [Where,P] ].
system_message(error(permission_error(alias,new,P), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot create alias ~w' - [Where,P] ].
system_message(error(permission_error(create,Name,P), Where)) -->
{ object_name(Name, ObjName) },
[ 'PERMISSION ERROR- ~w: cannot create ~a ~w' - [Where,ObjName,P] ].
system_message(error(permission_error(input,binary_stream,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot read from binary stream ~w' - [Where,Stream] ].
system_message(error(permission_error(input,closed_stream,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: trying to read from closed stream ~w' - [Where,Stream] ].
system_message(error(permission_error(input,past_end_of_stream,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: past end of stream ~w' - [Where,Stream] ].
system_message(error(permission_error(input,stream,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot read from ~w' - [Where,Stream] ].
system_message(error(permission_error(input,text_stream,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot read from text stream ~w' - [Where,Stream] ].
system_message(error(permission_error(modify,dynamic_procedure,_), Where)) -->
[ 'PERMISSION ERROR- ~w: modifying a dynamic procedure' - [Where] ].
system_message(error(permission_error(modify,flag,W), _)) -->
[ 'PERMISSION ERROR- cannot modify flag ~w' - [W] ].
system_message(error(permission_error(modify,operator,W), Q)) -->
[ 'PERMISSION ERROR- ~w: cannot modify operator ~q' - [Q,W] ].
system_message(error(permission_error(modify,dynamic_procedure,F), Where)) -->
[ 'PERMISSION ERROR- ~w: modifying dynamic procedure ~w' - [Where,F] ].
system_message(error(permission_error(modify,static_procedure,F), Where)) -->
[ 'PERMISSION ERROR- ~w: modifying static procedure ~w' - [Where,F] ].
system_message(error(permission_error(modify,static_procedure_in_use,_), Where)) -->
[ 'PERMISSION ERROR- ~w: modifying a static procedure in use' - [Where] ].
system_message(error(permission_error(modify,table,P), _)) -->
[ 'PERMISSION ERROR- cannot table procedure ~w' - [P] ].
system_message(error(permission_error(module,redefined,Mod), Who)) -->
[ 'PERMISSION ERROR ~w- redefining module ~a in a different file' - [Who,Mod] ].
system_message(error(permission_error(open,source_sink,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot open file ~w' - [Where,Stream] ].
system_message(error(permission_error(output,binary_stream,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot write to binary stream ~w' - [Where,Stream] ].
system_message(error(permission_error(output,stream,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot write to ~w' - [Where,Stream] ].
system_message(error(permission_error(output,text_stream,Stream), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot write to text stream ~w' - [Where,Stream] ].
system_message(error(permission_error(resize,array,P), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot resize array ~w' - [Where,P] ].
system_message(error(permission_error(unlock,mutex,P), Where)) -->
[ 'PERMISSION ERROR- ~w: cannot unlock mutex ~w' - [Where,P] ].
system_message(error(representation_error(character), Where)) -->
[ 'REPRESENTATION ERROR- ~w: expected character' - [Where] ].
system_message(error(representation_error(character_code), Where)) -->
[ 'REPRESENTATION ERROR- ~w: expected character code' - [Where] ].
system_message(error(representation_error(max_arity), Where)) -->
[ 'REPRESENTATION ERROR- ~w: number too big' - [Where] ].
system_message(error(representation_error(variable), Where)) -->
[ 'REPRESENTATION ERROR- ~w: should be a variable' - [Where] ].
system_message(error(resource_error(code_space), Where)) -->
[ 'RESOURCE ERROR- not enough code space' - [Where] ].
system_message(error(resource_error(huge_int), Where)) -->
[ 'RESOURCE ERROR- too large an integer in absolute value' - [Where] ].
system_message(error(resource_error(memory), Where)) -->
[ 'RESOURCE ERROR- not enough virtual memory' - [Where] ].
system_message(error(resource_error(stack), Where)) -->
[ 'RESOURCE ERROR- not enough stack' - [Where] ].
system_message(error(resource_error(streams), Where)) -->
[ 'RESOURCE ERROR- could not find a free stream' - [Where] ].
system_message(error(resource_error(threads), Where)) -->
[ 'RESOURCE ERROR- too many open threads' - [Where] ].
system_message(error(resource_error(trail), Where)) -->
[ 'RESOURCE ERROR- not enough trail space' - [Where] ].
system_message(error(signal(SIG,_), _)) -->
[ 'UNEXPECTED SIGNAL: ~a' - [SIG] ].
system_message(error(syntax_error(syntax_error(G,0,Msg,[],0,0,File)), _)) -->
[ 'SYNTAX ERROR at "~a", goal ~q: ~a' - [File,G,Msg] ].
system_message(error(syntax_error(syntax_error(read(Term),_,_,Term,Pos,Start,File)), Where)) -->
['~w' - [Where]],
syntax_error_line(File, Start, Pos),
syntax_error_term(10, Pos, Term),
[ '.' ].
system_message(error(system_error, Where)) -->
[ 'SYSTEM ERROR- ~w' - [Where] ].
system_message(error(internal_compiler_error, Where)) -->
[ 'INTERNAL COMPILER ERROR- ~w' - [Where] ].
system_message(error(system_error(Message), Where)) -->
[ 'SYSTEM ERROR- ~w at ~w]' - [Message,Where] ].
system_message(error(timeout_error(T,Obj), _Where)) -->
[ 'TIMEOUT ERROR- operation ~w on object ~w' - [T,Obj] ].
system_message(error(type_error(T,_,Err,M), _Where)) -->
[ 'TYPE ERROR- ~w: expected ~w, got ~w' - [T,Err,M] ].
system_message(error(type_error(TE,W), Where)) -->
{ object_name(TE, M) }, !,
[ 'TYPE ERROR- ~w: expected ~a, got ~w' - [Where,M,W] ].
system_message(error(type_error(TE,W), Where)) -->
[ 'TYPE ERROR- ~w: expected ~q, got ~w' - [Where,TE,W] ].
system_message(error(unknown, Where)) -->
[ 'EXISTENCE ERROR- procedure ~w undefined' - [Where] ].
system_message(error(unhandled_exception,Throw)) -->
[ 'UNHANDLED EXCEPTION - message ~w unknown' - [Throw] ].
system_message(error(uninstantiation_error(TE), Where)) -->
[ 'UNINSTANTIATION ERROR - expected unbound term, got ~q' - [TE] ].
system_message(Messg) -->
[ '~q' - Messg ].
domain_error(array_overflow, Opt) --> !,
[ 'invalid static index ~w for array' - Opt ].
domain_error(array_type, Opt) --> !,
[ 'invalid static array type ~w' - Opt ].
domain_error(builtin_procedure, _) --> !,
[ 'non-iso built-in procedure' ].
domain_error(character_code_list, Opt) --> !,
[ 'invalid list of codes ~w' - [Opt] ].
domain_error(close_option, Opt) --> !,
[ 'invalid close option ~w' - [Opt] ].
domain_error(delete_file_option, Opt) --> !,
[ 'invalid list of options ~w' - [Opt] ].
domain_error(encoding, Opt) --> !,
[ 'invalid encoding ~w' - [Opt] ].
domain_error(flag_value, Opt) --> !,
[ 'invalid value ~w for flag ~w' - [Opt] ].
domain_error(io_mode, Opt) --> !,
[ 'invalid io mode ~w' - [Opt] ].
domain_error(mutable, Opt) --> !,
[ 'invalid id mutable ~w' - [Opt] ].
domain_error(module_decl_options, Opt) --> !,
[ 'expect module declaration options, found ~w' - [Opt] ].
domain_error(non_empty_list, Opt) --> !,
[ 'found empty list' - [Opt] ].
domain_error(not_less_than_zero, Opt) --> !,
[ 'number ~w less than zero' - [Opt] ].
domain_error(not_newline, Opt) --> !,
[ 'number ~w not newline' - [Opt] ].
domain_error(not_zero, Opt) --> !,
[ '~w is not allowed in the domain' - [Opt] ].
domain_error(operator_priority, Opt) --> !,
[ '~w invalid operator priority' - [Opt] ].
domain_error(operator_specifier, Opt) --> !,
[ 'invalid operator specifier ~w' - [Opt] ].
domain_error(out_of_range, Opt) --> !,
[ 'expression ~w is out of range' - [Opt] ].
domain_error(predicate_spec, Opt) --> !,
[ '~w invalid predicate specifier' - [Opt] ].
domain_error(radix, Opt) --> !,
[ 'invalid radix ~w' - [Opt] ].
vdomain_error(read_option, Opt) --> !,
[ '~w invalid option to read_term' - [Opt] ].
domain_error(semantics_indicatior, Opt) --> !,
[ '~w expected predicate indicator, got ~w' - [Opt] ].
domain_error(shift_count_overflow, Opt) --> !,
[ 'shift count overflow in ~w' - [Opt] ].
domain_error(source_sink, Opt) --> !,
[ '~w is not a source sink term' - [Opt] ].
domain_error(stream, Opt) --> !,
[ '~w is not a stream' - [Opt] ].
domain_error(stream_or_alias, Opt) --> !,
[ '~w is not a stream (or alias)' - [Opt] ].
domain_error(stream_encoding, Opt) --> !,
[ '~w is not a supported stream encoding' - [Opt] ].
domain_error(stream_position, Opt) --> !,
[ '~w is not a stream position' - [Opt] ].
domain_error(stream_property, Opt) --> !,
[ '~w is not a stream property' - [Opt] ].
domain_error(syntax_error_handler, Opt) --> !,
[ '~w is not a syntax error handler' - [Opt] ].
domain_error(table, Opt) --> !,
[ 'non-tabled procedure ~w' - [Opt] ].
domain_error(thread_create_option, Opt) --> !,
[ '~w is not a thread_create option' - [Opt] ].
domain_error(time_out_spec, Opt) --> !,
[ '~w is not valid specificatin for time_out' - [Opt] ].
domain_error(unimplemented_option, Opt) --> !,
[ '~w is not yet implemented' - [Opt] ].
domain_error(write_option, Opt) --> !,
[ '~w invalid write option' - [Opt] ].
domain_error(Domain, Opt) -->
[ '~w not a valid element for ~w' - [Opt,Domain] ].
object_name(array, array).
object_name(atom, atom).
object_name(atomic, atomic).
object_name(byte, byte).
object_name(callable, 'callable goal').
object_name(char, char).
object_name(character_code, 'character code').
object_name(compound, 'compound term').
object_name(db_reference, 'data base reference').
object_name(evaluable, 'evaluable term').
object_name(file, file).
object_name(float, float).
object_name(in_byte, byte).
object_name(in_character, character).
object_name(integer, integer).
object_name(key, 'database key').
object_name(leash_mode, 'leash mode').
object_name(library, library).
object_name(list, list).
object_name(message_queue, 'message queue').
object_name(mutex, mutex).
object_name(number, number).
object_name(operator, operator).
object_name(pointer, pointer).
object_name(predicate_indicator, 'predicate indicator').
object_name(source_sink, file).
object_name(unsigned_byte, 'unsigned byte').
object_name(unsigned_char, 'unsigned char').
object_name(variable, 'unbound variable').
svs([H]) --> !, H.
svs([H|L]) -->
H,
", ",
svs(L).
list_of_preds([]) --> [].
list_of_preds([P|L]) -->
['~q' - [P]],
list_of_preds(L).
syntax_error_line(File, Position,_) -->
[' at ~a, near line ~d:~n' - [File,Position]].
syntax_error_term(0,J,L) -->
['~n' ],
syntax_error_term(10,J,L).
syntax_error_term(_,0,L) --> !,
[ '~n<==== HERE ====>~n' ],
syntax_error_term(10,-1,L).
syntax_error_term(_,_,[]) --> !.
syntax_error_term(I,J,[T-_P|R]) -->
syntax_error_token(T),
{
I1 is I-1,
J1 is J-1
},
syntax_error_term(I1,J1,R).
syntax_error_token(atom(A)) --> !,
[ ' ~a' - [A] ].
syntax_error_token(number(N)) --> !,
[ ' ~w' - [N] ].
syntax_error_token(var(_,S,_)) --> !,
[ ' ~s' - [S] ].
syntax_error_token(string(S)) --> !,
[ ' ""~s"' - [S] ].
syntax_error_token('(') --> !,
[ '(' ].
syntax_error_token(')') --> !,
[ ' )' ].
syntax_error_token(',') --> !,
[ ' ,' ].
syntax_error_token(A) --> !,
[ ' ~a' - [A] ].
% print_message_lines(+Stream, +Prefix, +Lines)
%
% Quintus/SICStus/SWI compatibility predicate to print message lines
% using a prefix.
prolog:print_message_lines(_, _, []) :- !.
prolog:print_message_lines(S, P, [at_same_line|Lines]) :- !,
print_message_line(S, Lines, Rest),
prolog:print_message_lines(S, P, Rest).
prolog:print_message_lines(S, P-Opts, Lines) :- !,
atom_concat('~N', P, Prefix),
format(S, Prefix, Opts),
print_message_line(S, Lines, Rest),
prolog:print_message_lines(S, P-Opts, Rest).
prolog:print_message_lines(S, P, Lines) :-
atom_concat('~N', P, Prefix),
format(S, Prefix, []),
print_message_line(S, Lines, Rest),
prolog:print_message_lines(S, P, Rest).
print_message_line(S, [flush], []) :- !,
flush_output(S).
print_message_line(S, [], []) :- !,
nl(S).
print_message_line(S, [nl|T], T) :- !,
nl(S).
print_message_line(S, [Fmt-Args|T0], T) :- !,
format(S, Fmt, Args),
print_message_line(S, T0, T).
print_message_line(S, [Fmt|T0], T) :-
format(S, Fmt, []),
print_message_line(S, T0, T).
prefix(error, ' ', user_error, 'ERROR!! ').
prefix(warning, '% ', user_error, 'Warning: ').
prefix(help, '', user_error) --> [].
prefix(query, '', user_error) --> [].
prefix(debug, '', user_output) --> [].
prefix(warning, '% ', user_error) -->
{ thread_self(Id) },
( { Id == main }
-> [ 'Warning: ', nl ]
; ['Warning: [Thread ~d ]' - Id, nl ]
).
prefix(error, ' ', user_error) -->
{ recorded(sp_info,local_sp(P,_,_,_),_) },
{ thread_self(Id) },
( { Id == main }
-> [ 'ERROR at ' ]
; [ 'ERROR [Thread ~d ] at ' - Id ]
),
'$hacks':display_pc(P),
!,
[' !!', nl].
prefix(error, ' ', user_error) -->
{ thread_self(Id) },
( { Id == main }
-> [ 'ERROR!!', nl ]
; [ 'ERROR!! [Thread ~d ]' - Id, nl ]
).
prefix(banner, '', user_error) --> [].
prefix(informational, '~*|% '-[LC], user_error) -->
{ '$show_consult_level'(LC) }.
yap-6.2.2/pl/modules.yap 000644 000765 000024 00000060477 11501776364 015076 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: modules.pl *
* Last rev: *
* mods: *
* comments: module support *
* *
*************************************************************************/
% module handling
'$consulting_file_name'(Stream,F) :-
'$file_name'(Stream, F).
'$module'(_,N,P) :-
'$module_dec'(N,P).
'$module'(O,N,P,Opts) :- !,
'$module'(O,N,P),
'$process_module_decls_options'(Opts,module(Opts,N,P)).
'$process_module_decls_options'(Var,Mod) :-
var(Var), !,
'$do_error'(instantiation_error,Mod).
'$process_module_decls_options'([],_) :- !.
'$process_module_decls_options'([H|L],M) :- !,
'$process_module_decls_option'(H,M),
'$process_module_decls_options'(L,M).
'$process_module_decls_options'(T,M) :-
'$do_error'(type_error(list,T),M).
'$process_module_decls_option'(Var,M) :-
var(Var),
'$do_error'(instantiation_error,M).
'$process_module_decls_option'(At,_) :-
atom(At), !,
'$use_module'(At).
'$process_module_decls_option'(library(L),_) :- !,
'$use_module'(library(L)).
'$process_module_decls_option'(hidden(Bool),M) :- !,
'$process_hidden_module'(Bool, M).
'$process_module_decls_option'(Opt,M) :-
'$do_error'(domain_error(module_decl_options,Opt),M).
'$process_hidden_module'(TNew,M) :-
'$convert_true_off_mod3'(TNew, New, M),
source_mode(Old, New),
'$prepare_restore_hidden'(Old,New).
'$convert_true_off_mod3'(true, off, _).
'$convert_true_off_mod3'(false, on, _).
'$convert_true_off_mod3'(X, _, M) :-
'$do_error'(domain_error(module_decl_options,hidden(X)),M).
'$prepare_restore_hidden'(Old,Old) :- !.
'$prepare_restore_hidden'(Old,New) :-
recorda('$system_initialisation', source_mode(New,Old), _).
module(N) :-
var(N),
'$do_error'(instantiation_error,module(N)).
module(N) :-
atom(N), !,
% set it as current module.
'$current_module'(_,N).
module(N) :-
'$do_error'(type_error(atom,N),module(N)).
'$module_dec'(N,P) :-
'$current_module'(_,N),
nb_getval('$consulting_file',F),
'$add_module_on_file'(N, F, P).
'$add_module_on_file'(Mod, F, Exports) :-
recorded('$module','$module'(F0,Mod,_),R), !,
'$add_preexisting_module_on_file'(F, F0, Mod, Exports, R).
'$add_module_on_file'(Mod, F, Exports) :-
'$process_exports'(Exports,Mod,ExportedPreds),
recorda('$module','$module'(F,Mod,ExportedPreds),_).
'$process_exports'([],_,[]).
'$process_exports'([Name/Arity|Exports],Mod,[Name/Arity|ExportedPreds]):- !,
'$process_exports'(Exports,Mod,ExportedPreds).
'$process_exports'([Name//Arity|Exports],Mod,[Name/Arity2|ExportedPreds]):- !,
Arity2 is Arity+2,
'$process_exports'(Exports,Mod,ExportedPreds).
'$process_exports'([op(Prio,Assoc,Name)|Exports],Mod,ExportedPreds) :- !,
op(Prio,Assoc,prolog:Name),
'$process_exports'(Exports,Mod,ExportedPreds).
'$process_exports'([Trash|_],Mod,_) :-
'$do_error'(type_error(predicate_indicator,Trash),module(Mod,[Trash])).
% redefining a previously-defined file, no problem.
'$add_preexisting_module_on_file'(F, F, Mod, Exports, R) :- !,
erase(R),
( recorded('$import','$import'(Mod,_,_,_,_,_),R), erase(R), fail; true),
recorda('$module','$module'(F,Mod,Exports),_).
'$add_preexisting_module_on_file'(F,F0,Mod,Exports,R) :-
repeat,
format(user_error, "The module ~a is being redefined.~n Old file: ~a~n New file: ~a~nDo you really want to redefine it? (y or n)",[Mod,F0,F]),
'$mod_scan'(C), !,
( C is "y" ->
'$add_preexisting_module_on_file'(F, F, Mod, Exports, R)
;
'$do_error'(permission_error(module,redefined,Mod),module(Mod,Exports))
).
'$mod_scan'(C) :-
get0(C),
'$skipeol'(C),
(C is "y" ; C is "n").
'$import'([],_,_) :- !.
'$import'([N/K|L],M,T) :-
integer(K), atom(N), !,
'$do_import'(N, K, M, T),
'$import'(L,M,T).
'$import'([PS|L],_,_) :-
'$do_error'(domain_error(predicate_spec,PS),import([PS|L])).
% $use_preds(Imports,Publics,Mod,M)
'$use_preds'(Imports,Publics,Mod,M) :- var(Imports), !,
'$import'(Publics,Mod,M).
'$use_preds'(M:L,Publics,Mod,_) :-
'$use_preds'(L,Publics,Mod,M).
'$use_preds'([],_,_,_) :- !.
'$use_preds'([P|Ps],Publics,Mod,M) :- !,
'$use_preds'(P,Publics,Mod,M),
'$use_preds'(Ps,Publics,Mod,M).
'$use_preds'(N/K,Publics,M,Mod) :-
( lists:memberchk(N/K,Publics) -> true ;
print_message(warning,import(N/K,Mod,M,private))
),
'$do_import'(N, K, M, Mod).
'$do_import'(N, K, M, T) :-
functor(G,N,K),
'$follow_import_chain'(M,G,M0,G0),
functor(G0,N1,K),
( '$check_import'(M0,T,N1,K) ->
( T = user ->
( recordzifnot('$import','$import'(M0,user,G0,G,N,K),_) -> true ; true)
;
( recordaifnot('$import','$import'(M0,T,G0,G,N,K),_) -> true ; true )
)
;
true
).
'$follow_import_chain'(M,G,M0,G0) :-
recorded('$import','$import'(M1,M,G1,G,_,_),_), !,
'$follow_import_chain'(M1,G1,M0,G0).
'$follow_import_chain'(M,G,M,G).
'$check_import'(M,T,N,K) :-
recorded('$import','$import'(MI,T,_,_,N,K),R),
\+ '$module_produced by'(M,T,N,K), !,
format(user_error,"NAME CLASH: ~w was already imported to module ~w;~n",[MI:N/K,T]),
format(user_error," Do you want to import it from ~w ? [y or n] ",M),
repeat,
get0(C), '$skipeol'(C),
( C is "y" -> erase(R), !;
C is "n" -> !, fail;
format(user_error, ' Please answer with ''y'' or ''n'' ',[]), fail
).
'$check_import'(_,_,_,_).
'$module_produced by'(M,M0,N,K) :-
recorded('$import','$import'(M,M0,_,_,N,K),_), !.
'$module_produced by'(M,M0,N,K) :-
recorded('$import','$import'(MI,M0,G1,_,N,K),_),
functor(G1, N1, K1),
'$module_produced by'(M,MI,N1,K1).
% expand module names in a clause
% A1: Input Clause
% A2: Output Class to Compiler (lives in module HM)
% A3: Output Class to clause/2 and listing (lives in module HM)
%
% modules:
% A4: module for body of clause (this is the one used in looking up predicates)
% A5: context module (this is the current context
% A6: head module (this is the one used in compiling and accessing).
%
%
'$module_expansion'((H:-B),(H:-B1),(H:-BOO),M,HM) :- !,
'$is_mt'(M, H, B, IB, MM),
'$module_u_vars'(H,UVars,M), % collect head variables in
% expanded positions
'$module_expansion'(IB,B1,BO,M,MM,HM,UVars),
('$full_clause_optimisation'(H, M, BO, BOO) ->
true
;
BO = BOO
).
% do not expand bodyless clauses.
'$module_expansion'(H,H,H,_,_).
'$trace_module'(X) :-
telling(F),
tell('P0:debug'),
write(X),nl,
tell(F), fail.
'$trace_module'(_).
'$trace_module'(X,Y) :- X==Y, !.
'$trace_module'(X,Y) :-
telling(F),
tell('~/.dbg.modules'),
write('***************'), nl,
portray_clause(X),
portray_clause(Y),
tell(F),fail.
'$trace_module'(_,_).
% expand module names in a body
% args are:
% goals to expand
% code to pass to listing
% code to pass to compiler
% current module for looking up preds M
% default module DM
% head module HM
%
% to understand the differences, you can consider:
%
% a:(d:b(X) :- g:c(X), d(X), user:hello(X)).
%
% when we process meta-predicate c, HM=d, DM=a, BM=a, M=g and we should get:
%
% d:b(X) :- g:c(g:X), a:d(X), user:hello(X).
%
% on the other hand,
%
% a:(d:b(X) :- c(X), d(X), d:e(X)).
%
% will give
%
% d:b(X) :- a:c(a:X), a:d(X), e(X).
%
%
% head variables.
% goals or arguments/sub-arguments?
% I cannot use call here because of format/3
'$module_expansion'(V,NG,NG,_,MM,_,HVars) :-
var(V), !,
( '$not_in_vars'(V,HVars)
->
NG = call(MM:V)
;
NG = call(V)
).
'$module_expansion'((A,B),(A1,B1),(AO,BO),M,MM,HM,HVars) :- !,
'$module_expansion'(A,A1,AO,M,MM,HM,HVars),
'$module_expansion'(B,B1,BO,M,MM,HM,HVars).
'$module_expansion'((A;B),(A1;B1),(AO;BO),M,MM,HM,HVars) :- var(A), !,
'$module_expansion'(A,A1,AO,M,MM,HM,HVars),
'$module_expansion'(B,B1,BO,M,MM,HM,HVars).
'$module_expansion'((A*->B;C),(A1*->B1;C1),(yap_hacks:current_choicepoint(DCP),AO,yap_hacks:cut_at(DCP),BO; CO),M,MM,HM,HVars) :- !,
'$module_expansion'(A,A1,AOO,M,MM,HM,HVars),
'$clean_cuts'(AOO, AO),
'$module_expansion'(B,B1,BO,M,MM,HM,HVars),
'$module_expansion'(C,C1,CO,M,MM,HM,HVars).
'$module_expansion'((A;B),(A1;B1),(AO;BO),M,MM,HM,HVars) :- !,
'$module_expansion'(A,A1,AO,M,MM,HM,HVars),
'$module_expansion'(B,B1,BO,M,MM,HM,HVars).
'$module_expansion'((A|B),(A1|B1),(AO|BO),M,MM,HM,HVars) :- !,
'$module_expansion'(A,A1,AO,M,MM,HM,HVars),
'$module_expansion'(B,B1,BO,M,MM,HM,HVars).
'$module_expansion'((A->B),(A1->B1),(AO->BO),M,MM,HM,HVars) :- !,
'$module_expansion'(A,A1,AOO,M,MM,HM,HVars),
'$clean_cuts'(AOO, AO),
'$module_expansion'(B,B1,BO,M,MM,HM,HVars).
'$module_expansion'(\+A,\+A1,\+AO,M,MM,HM,HVars) :- !,
'$module_expansion'(A,A1,AO,M,MM,HM,HVars).
'$module_expansion'(not(A),not(A1),not(AO),M,MM,HM,HVars) :- !,
'$module_expansion'(A,A1,AO,M,MM,HM,HVars).
'$module_expansion'(true,true,true,_,_,_,_) :- !.
'$module_expansion'(fail,fail,fail,_,_,_,_) :- !.
'$module_expansion'(false,false,false,_,_,_,_) :- !.
% if I don't know what the module is, I cannot do anything to the goal,
% so I just put a call for later on.
'$module_expansion'(M:G,call(M:G),'$execute_wo_mod'(G,M),_,_,_,_) :- var(M), !.
'$module_expansion'(M:G,G1,GO,_,CM,_,HVars) :- !,
'$module_expansion'(G,G1,GO,M,M,HM,HVars).
'$module_expansion'(G, G1, GO, CurMod, MM, HM,HVars) :-
% is this imported from some other module M1?
'$imported_pred'(G, CurMod, GG, M1),
!,
'$module_expansion'(GG, G1, GO, M1, MM, HM,HVars).
'$module_expansion'(G, G1, GO, CurMod, MM, HM,HVars) :-
'$meta_expansion'(G, CurMod, MM, HM, GI, HVars), !,
'$complete_goal_expansion'(GI, CurMod, MM, HM, G1, GO, HVars).
'$module_expansion'(G, G1, GO, CurMod, MM, HM, HVars) :-
'$complete_goal_expansion'(G, CurMod, MM, HM, G1, GO, HVars).
expand_goal(G, G) :-
var(G), !.
expand_goal(M:G, M:NG) :-
'$do_expand'(G, M, NG), !.
expand_goal(G, NG) :-
'$current_module'(Mod),
'$do_expand'(G, M, NG), !.
expand_goal(G, G).
'$do_expand'(G, _, G) :- var(G), !.
'$do_expand'(M:G, CurMod, M:GI) :- !,
'$do_expand'(G, M, GI).
'$do_expand'(G, CurMod, GI) :-
(
'$pred_exists'(goal_expansion(G,GI), CurMod),
call(CurMod:goal_expansion(G, GI))
->
true
;
recorded('$dialect',swi,_),
system:goal_expansion(G, GI)
->
true
;
user:goal_expansion(G, CurMod, GI)
->
true
;
user:goal_expansion(G, GI)
), !.
'$do_expand'(G, CurMod, NG) :-
'$is_metapredicate'(G,CurMod), !,
functor(G, Name, Arity),
prolog:'$meta_predicate'(Name,CurMod,Arity,PredDef),
G =.. [Name|GArgs],
PredDef =.. [Name|GDefs],
'$expand_args'(GArgs, CurMod, GDefs, NGArgs),
NG =.. [Name|NGArgs].
'$expand_args'([], _, [], []).
'$expand_args'(A.GArgs, CurMod, 0.GDefs, NA.NGArgs) :-
'$do_expand'(A, CurMod, NA), !,
'$expand_args'(GArgs, CurMod, GDefs, NGArgs).
'$expand_args'(A.GArgs, CurMod, _.GDefs, A.NGArgs) :-
'$expand_args'(GArgs, CurMod, GDefs, NGArgs).
% args are:
% goal to expand
% current module for looking up pred
% current module for looking up pred
% current module from top-level clause
% goal to pass to listing
% goal to pass to compiler
% head variables.
'$complete_goal_expansion'(G, CurMod, MM, HM, G1, GO, HVars) :-
% '$pred_goal_expansion_on',
'$do_expand'(G, CurMod, GI),
GI \== G, !,
'$module_expansion'(GI, G1, GO, CurMod, MM, HM, HVars).
'$complete_goal_expansion'(G, M, CM, HM, G1, G2, HVars) :-
'$all_system_predicate'(G,M,ORIG), !,
% make built-in processing transparent.
'$match_mod'(G, M, ORIG, HM, G1),
'$c_built_in'(G1, M, Gi),
(Gi \== G1 ->
'$module_expansion'(Gi, G2, _, M, CM, HM, HVars)
;
G2 = G1
).
'$complete_goal_expansion'(G, GMod, _, HM, NG, NG, _) :-
'$match_mod'(G, GMod, GMod, HM, NG).
%'$match_mod'(G, GMod, GMod, NG) :- !,
% NG = G.
'$match_mod'(G, _, SM, _, G) :- SM == prolog, nonvar(G), \+ '$is_multifile'(G,SM), !. % prolog: needs no module info.
% same module as head, and body goal (I cannot get rid of qualifier before
% meta-call.
'$match_mod'(G, HMod, _, HM, G) :- HMod == HM, !.
'$match_mod'(G, GMod, _, _, GMod:G).
% be careful here not to generate an undefined exception.
'$imported_pred'(G, ImportingMod, G0, ExportingMod) :-
'$enter_undefp',
'$undefined'(G, ImportingMod),
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod),
ExportingMod \= ImportingMod, !,
'$exit_undefp'.
'$imported_pred'(G, ImportingMod, _, _) :-
'$exit_undefp',
fail.
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_),
'$continue_imported'(ExportingMod, ExportingModI, G0, G0I), !.
% SWI builtin
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
recorded('$dialect',Dialect,_),
Dialect \= yap,
functor(G, Name, Arity),
call(Dialect:index(Name,Arity,ExportingModI,_)), !,
'$continue_imported'(ExportingMod, ExportingModI, G0, G), !.
'$get_undefined_pred'(G, _ImportingMod, G0, ExportingMod) :-
autoloader:autoload,
autoloader:find_predicate(G,ExportingModI), !,
'$continue_imported'(ExportingMod, ExportingModI, G0, G), !.
'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :-
prolog:'$parent_module'(ImportingMod,ExportingModI),
'$continue_imported'(ExportingMod, ExportingModI, G0, G).
'$continue_imported'(Mod,Mod,Pred,Pred) :-
\+ '$undefined'(Pred, Mod), !.
'$continue_imported'(FM,Mod,FPred,Pred) :-
recorded('$import','$import'(IM,Mod,IPred,Pred,_,_),_), !,
'$continue_imported'(FM, IM, FPred, IPred).
'$continue_imported'(FM,Mod,FPred,Pred) :-
prolog:'$parent_module'(Mod,IM),
'$continue_imported'(FM, IM, FPred, Pred).
% module_transparent declaration
%
:- dynamic('$module_transparent'/4).
'$module_transparent'((P,Ps), M) :- !,
'$module_transparent'(P, M),
'$module_transparent'(Ps, M).
'$module_transparent'(M:D, _) :- !,
'$module_transparent'(D, M).
'$module_transparent'(F/N, M) :-
'$module_transparent'(F,M,N,_), !.
'$module_transparent'(F/N, M) :-
functor(P,F,N),
asserta(prolog:'$module_transparent'(F,M,N,P)),
'$flags'(P, M, Fl, Fl),
NFlags is Fl \/ 0x200004,
'$flags'(P, M, Fl, NFlags).
'$is_mt'(M, H0, B, (context_module(CM),B), CM) :-
'$module_transparent'(_, M, _, H), !.
'$is_mt'(M, _, B, B, M).
% meta_predicate declaration
% records $meta_predicate(SourceModule,Functor,Arity,Declaration)
% directive now meta_predicate Ps :- $meta_predicate(Ps).
:- dynamic('$meta_predicate'/4).
:- multifile '$meta_predicate'/4.
'$meta_predicate'(P, M) :-
var(P),
'$do_error'(instantiation_error,module(M)).
'$meta_predicate'((P,Ps), M) :- !,
'$meta_predicate'(P, M),
'$meta_predicate'(Ps, M).
'$meta_predicate'(M:D, _) :- !,
'$meta_predicate'(D, M).
'$meta_predicate'(P, M1) :-
'$install_meta_predicate'(P, M1).
'$install_meta_predicate'(P, M1) :-
functor(P,F,N),
( M1 = prolog -> M = _ ; M1 = M),
( retractall(prolog:'$meta_predicate'(F,M,N,_)), fail ; true),
asserta(prolog:'$meta_predicate'(F,M,N,P)),
'$flags'(P, M1, Fl, Fl),
NFlags is Fl \/ 0x200000,
'$flags'(P, M1, Fl, NFlags).
% return list of vars in expanded positions on the head of a clause.
%
% these variables should not be expanded by meta-calls in the body of the goal.
%
'$module_u_vars'(H,UVars,M) :-
functor(H,F,N),
'$meta_predicate'(F,M,N,D), !,
'$module_u_vars'(N,D,H,UVars).
'$module_u_vars'(_,[],_).
'$module_u_vars'(0,_,_,[]) :- !.
'$module_u_vars'(I,D,H,[Y|L]) :-
arg(I,D,X), ( X=':' ; integer(X)),
arg(I,H,Y), var(Y), !,
I1 is I-1,
'$module_u_vars'(I1,D,H,L).
'$module_u_vars'(I,D,H,L) :-
I1 is I-1,
'$module_u_vars'(I1,D,H,L).
% expand arguments of a meta-predicate
% $meta_expansion(ModuleWhereDefined,CurrentModule,Goal,ExpandedGoal,MetaVariables)
'$meta_expansion'(G,Mod,MP,HM,G1,HVars) :-
functor(G,F,N),
'$meta_predicate'(F,Mod,N,D), !,
% format(user_error,'[ ~w ',[G]),
functor(G1,F,N),
'$meta_expansion_loop'(N, D, G, G1, HVars, Mod, MP, HM).
% format(user_error,' gives ~w]`n',[G1]).
% expand argument
'$meta_expansion_loop'(0,_,_,_,_,_,_,_) :- !.
'$meta_expansion_loop'(I,D,G,NG,HVars,CurMod,M,HM) :-
arg(I,D,X), (X==':' ; integer(X)),
arg(I,G,A), '$do_expand'(A,HVars),
!,
arg(I,NG,M:A),
I1 is I-1,
'$meta_expansion_loop'(I1, D, G, NG, HVars, CurMod, M, HM).
'$meta_expansion_loop'(I, D, G, NG, HVars, CurMod, M, HM) :-
arg(I,G,A),
arg(I,NG,A),
I1 is I-1,
'$meta_expansion_loop'(I1, D, G, NG, HVars, CurMod, M, HM).
% check if an argument should be expanded
'$do_expand'(V,HVars) :- var(V), !, '$not_in_vars'(V,HVars).
'$do_expand'(_:_,_) :- !, fail.
'$do_expand'(_,_).
'$not_in_vars'(_,[]).
'$not_in_vars'(V,[X|L]) :- X\==V, '$not_in_vars'(V,L).
current_module(Mod) :-
'$all_current_modules'(Mod),
\+ '$system_module'(Mod).
current_module(Mod,TFN) :-
'$all_current_modules'(Mod),
( recorded('$module','$module'(TFN,Mod,_Publics),_) -> true ; TFN = user ).
source_module(Mod) :-
'$current_module'(Mod).
% comma has its own problems.
:- '$install_meta_predicate'((0,0), prolog).
:- meta_predicate
abolish(:),
abolish(:,+),
all(?,0,-),
assert(:),
assert(:,+),
assert_static(:),
asserta(:),
asserta(:,+),
asserta_static(:),
assertz(:),
assertz(:,+),
assertz_static(:),
bagof(?,0,-),
bb_get(:,-),
bb_put(:,+),
bb_delete(:,?),
bb_update(:,?,?),
call(0),
call(1,?),
call(2,?,?),
call(3,?,?,?),
call_with_args(0),
call_with_args(1,?),
call_with_args(2,?,?),
call_with_args(3,?,?,?),
call_with_args(4,?,?,?,?),
call_with_args(5,?,?,?,?,?),
call_with_args(6,?,?,?,?,?,?),
call_with_args(7,?,?,?,?,?,?,?),
call_with_args(8,?,?,?,?,?,?,?,?),
call_with_args(9,?,?,?,?,?,?,?,?,?),
call_cleanup(0,0),
call_cleanup(0,?,0),
call_residue(0,?),
call_residue_vars(0,?),
call_shared_object_function(:,+),
catch(0,?,0),
clause(:,?),
clause(:,?,?),
compile(:),
consult(:),
current_predicate(:),
current_predicate(?,:),
depth_bound_call(0,+),
discontiguous(:),
ensure_loaded(:),
findall(?,0,-),
findall(?,0,-,?),
forall(0,0),
format(+,:),
format(+,+,:),
freeze(?,0),
hide_predicate(:),
if(0,0,0),
ignore(0),
incore(0),
listing(:),
multifile(:),
nospy(:),
not(0),
once(0),
phrase(2,?),
phrase(2,?,+),
predicate_property(:,?),
predicate_statistics(:,-,-,-),
on_exception(+,0,0),
reconsult(:),
retract(:),
retract(:,?),
retractall(:),
reconsult(:),
setof(?,0,-),
setup_call_cleanup(0,0,0),
setup_call_catcher_cleanup(0,0,?,0),
spy(:),
unknown(+,:),
use_module(:),
use_module(:,?),
use_module(?,:,?),
when(+,0),
with_mutex(+,0),
with_output_to(?,0),
(0 -> 0),
(0 *-> 0),
(0 ; 0),
^(+,0),
\+ 0 .
%
% get rid of a module and of all predicates included in the module.
%
abolish_module(Mod) :-
recorded('$module','$module'(_,Mod,_),R), erase(R),
fail.
abolish_module(Mod) :-
recorded('$import','$import'(Mod,_,_,_,_,_),R), erase(R),
fail.
abolish_module(Mod) :-
'$current_predicate'(Mod,Na,Ar),
abolish(Mod:Na/Ar),
fail.
abolish_module(_).
'$reexport'(ModuleSource, Spec, Module) :-
nb_getval('$consulting_file',TopFile),
(
Spec == all
->
Goal = reexport(ModuleSource)
;
Goal = reexport(ModuleSource,Spec)
),
absolute_file_name(ModuleSource, File, [access(read),file_type(source),file_errors(fail),solutions(first)]),
'$load_files'(File, [if(not_loaded),imports([])], Goal),
recorded('$module', '$module'(FullFile, Mod, Exports),_),
atom_concat(File, _, FullFile), !,
'$convert_for_reexport'(Spec, Exports, Tab, MyExports, Goal),
'$add_to_imports'(Tab, Module, Mod),
recorded('$lf_loaded','$lf_loaded'(TopFile,TopModule,_,_),_),
recorded('$module', '$module'(CurrentFile, Module, ModExports), Ref),
erase(Ref),
lists:append(ModExports, MyExports, AllExports),
recorda('$module', '$module'(CurrentFile, Module, AllExports), _),
'$import'(MyExports, Module, TopModule).
'$convert_for_reexport'(all, Exports, Tab, MyExports, _) :-
'$simple_conversion'(Exports, Tab, MyExports).
'$convert_for_reexport'([P1|Ps], Exports, Tab, MyExports, Goal) :-
'$clean_conversion'([P1|Ps], Exports, Tab, MyExports, Goal).
'$convert_for_reexport'(except(List), Exports, Tab, MyExports, Goal) :-
'$neg_conversion'(Exports, List, Tab, MyExports, Goal).
'$simple_conversion'([], [], []).
'$simple_conversion'([P|Exports], [P-P|Tab], [P|MyExports]) :-
'$simple_conversion'(Exports, Tab, MyExports).
'$clean_conversion'([], _, [], [], _).
'$clean_conversion'([P1|Ps], List, [P1-P1|Tab], [P1|MyExports], Goal) :-
lists:memberchk(P1, List), !,
'$clean_conversion'(Ps, List, Tab, MyExports, Goal).
'$clean_conversion'([(N1/A1 as N2)|Ps], List, [N1/A1-N2/A1|Tab], [N2/A1|MyExports], Goal) :-
lists:memberchk(N1/A1, List), !,
'$clean_conversion'(Ps, List, Tab, MyExports, Goal).
'$clean_conversion'([P|_], _List, _, _, Goal) :-
'$do_error'(domain_error(module_reexport_predicates,P), Goal).
'$neg_conversion'([], _, [], [], _).
'$neg_conversion'([P1|Ps], List, Tab, MyExports, Goal) :-
lists:memberchk(P1, List), !,
'$neg_conversion'(Ps, List, Tab, MyExports, Goal).
'$neg_conversion'([N1/A1|Ps], List, [N1/A1-N2/A1|Tab], [N2/A1|MyExports], Goal) :-
lists:memberchk(N1/A1 as N2, List), !,
'$neg_conversion'(Ps, List, Tab, MyExports, Goal).
'$neg_conversion'([P|Ps], List, [P-P|Tab], [P|MyExports], Goal) :-
'$neg_conversion'(Ps, List, Tab, MyExports, Goal).
'$add_to_imports'([], _, _).
'$add_to_imports'([N0/K0-N1/K1|Tab], Mod, ModR) :-
functor(G,N0,K0),
G=..[N0|Args],
G1=..[N1|Args],
recordaifnot('$import','$import'(ModR,Mod,G,G1,N0,K0),_), !,
'$add_to_imports'(Tab, Mod, ModR).
% I assume the clause has been processed, so the
% var case is long gone! Yes :)
'$clean_cuts'(G,(yap_hacks:current_choicepoint(DCP),NG)) :-
'$conj_has_cuts'(G,DCP,NG,OK), OK == ok, !.
'$clean_cuts'(G,G).
'$conj_has_cuts'(V,_,V, _) :- var(V), !.
'$conj_has_cuts'(!,DCP,'$$cut_by'(DCP), ok) :- !.
'$conj_has_cuts'((G1,G2),DCP,(NG1,NG2), OK) :- !,
'$conj_has_cuts'(G1, DCP, NG1, OK),
'$conj_has_cuts'(G2, DCP, NG2, OK).
'$conj_has_cuts'((G1;G2),DCP,(NG1;NG2), OK) :- !,
'$conj_has_cuts'(G1, DCP, NG1, OK),
'$conj_has_cuts'(G2, DCP, NG2, OK).
'$conj_has_cuts'((G1->G2),DCP,(G1;NG2), OK) :- !,
% G1: the system must have done it already
'$conj_has_cuts'(G2, DCP, NG2, OK).
'$conj_has_cuts'((G1*->G2),DCP,(G1;NG2), OK) :- !,
% G1: the system must have done it already
'$conj_has_cuts'(G2, DCP, NG2, OK).
'$conj_has_cuts'(if(G1,G2,G3),DCP,if(G1,NG2,NG3), OK) :- !,
% G1: the system must have done it already
'$conj_has_cuts'(G2, DCP, NG2, OK),
'$conj_has_cuts'(G3, DCP, NG3, OK).
'$conj_has_cuts'(G,_,G, _).
set_base_module(ExportingModule) :-
var(ExportingModule),
'$do_error'(instantiation_error,set_base_module(ExportingModule)).
set_base_module(ExportingModule) :-
atom(ExportingModule), !,
'$current_module'(Mod),
retractall(prolog:'$parent_module'(Mod,_)),
asserta(prolog:'$parent_module'(Mod,ExportingModule)).
set_base_module(ExportingModule) :-
'$do_error'(type_error(atom,ExportingModule),set_base_module(ExportingModule)).
import_module(Mod, ImportModule) :-
var(Mod),
'$do_error'(instantiation_error,import_module(Mod, ImportModule)).
import_module(Mod, ImportModule) :-
atom(Mod), !,
prolog:'$parent_module'(Mod,ImportModule).
import_module(Mod, EM) :-
'$do_error'(type_error(atom,Mod),import_module(Mod, EM)).
add_import_module(Mod, ImportModule, Pos) :-
var(Mod),
'$do_error'(instantiation_error,add_import_module(Mod, ImportModule, Pos)).
add_import_module(Mod, ImportModule, Pos) :-
var(Pos),
'$do_error'(instantiation_error,add_import_module(Mod, ImportModule, Pos)).
add_import_module(Mod, ImportModule, start) :-
atom(Mod), !,
retractall(prolog:'$parent_module'(Mod,ImportModule)),
asserta(prolog:'$parent_module'(Mod,ImportModule)).
add_import_module(Mod, ImportModule, end) :-
atom(Mod), !,
retractall(prolog:'$parent_module'(Mod,ImportModule)),
assertz(prolog:'$parent_module'(Mod,ImportModule)).
add_import_module(Mod, ImportModule, Pos) :-
\+ atom(Mod), !,
'$do_error'(type_error(atom,Mod),add_import_module(Mod, ImportModule, Pos)).
add_import_module(Mod, ImportModule, Pos) :-
'$do_error'(domain_error(start_end,Pos),add_import_module(Mod, ImportModule, Pos)).
delete_import_module(Mod, ImportModule) :-
var(Mod),
'$do_error'(instantiation_error,delete_import_module(Mod, ImportModule)).
delete_import_module(Mod, ImportModule) :-
var(ImportModule),
'$do_error'(instantiation_error,delete_import_module(Mod, ImportModule)).
delete_import_module(Mod, ImportModule) :-
atom(Mod),
atom(ImportModule), !,
retractall(prolog:'$parent_module'(Mod,ImportModule)).
delete_import_module(Mod, ImportModule) :-
\+ atom(Mod), !,
'$do_error'(type_error(atom,Mod),delete_import_module(Mod, ImportModule)).
delete_import_module(Mod, ImportModule) :-
'$do_error'(type_error(atom,ImportModule),delete_import_module(Mod, ImportModule)).
yap-6.2.2/pl/preds.yap 000644 000765 000024 00000071250 11501531054 014513 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: preds.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: Predicate Manipulation for YAP *
* *
*************************************************************************/
% The next predicates are applicable only
% to dynamic code
asserta(Mod:C) :- !,
'$assert'(C,Mod,first,_,asserta(Mod:C)).
asserta(C) :-
'$current_module'(Mod),
'$assert'(C,Mod,first,_,asserta(C)).
assertz(Mod:C) :- !,
'$assert'(C,Mod,last,_,assertz(Mod:C)).
assertz(C) :-
'$current_module'(Mod),
'$assert'(C,Mod,last,_,assertz(C)).
assert(Mod:C) :- !,
'$assert'(C,Mod,last,_,assert(Mod:C)).
assert(C) :-
'$current_module'(Mod),
'$assert'(C,Mod,last,_,assert(C)).
'$assert'(V,Mod,_,_,_) :- var(V), !,
'$do_error'(instantiation_error,assert(Mod:V)).
'$assert'(V,Mod,_,_,_) :- var(Mod), !,
'$do_error'(instantiation_error,assert(Mod:V)).
'$assert'(I,Mod,_,_,_) :- number(I), !,
'$do_error'(type_error(callable,I),assert(Mod:I)).
'$assert'(M:C,_,Where,R,P) :- !,
'$assert'(C,M,Where,R,P).
'$assert'((H:-G),M1,Where,R,P) :- !,
'$assert_clause'(H, G, M1, Where, R, P).
'$assert'(H,M1,Where,R,_) :-
strip_module(M1:H, HM, H1),
'$assert_fact'(H1, HM, Where, R).
'$assert_clause'(H, _, _, _, _, P) :-
var(H), !, '$do_error'(instantiation_error,P).
'$assert_clause'(M1:C, G, M1, Where, R, P) :- !,
'$assert_clause2'(C, G, M1, Where, R, P).
'$assert_clause'(H, G, M1, Where, R, P) :- !,
'$assert_clause2'(H, G, M1, Where, R, P).
'$assert_fact'(H,Mod,Where,R) :-
'$is_log_updatable'(H, Mod), !,
'$compile_dynamic'(H, Where, H, Mod, R).
'$assert_fact'(H,Mod,Where,R) :-
( '$is_dynamic'(H, Mod) ->
'$assertat_d'(Where, H, true, H, Mod, R)
;
'$undefined'(H,Mod) ->
functor(H, Na, Ar),
'$dynamic'(Na/Ar, Mod),
'$assert_fact'(H,Mod,Where,R)
;
'$access_yap_flags'(14, 1) -> % I can assert over static facts in YAP mode
'$assert1'(Where,H,H,Mod,H)
;
functor(H, Na, Ar),
'$do_error'(permission_error(modify,static_procedure,Na/Ar),Mod:assert(H))
).
'$assert_clause2'(HI,BI,Mod,Where,R,P) :-
'$expand_clause'((HI :- BI),C0,C,Mod,HM),
'$assert_clause3'(C0,C,HM,Where,R,P).
'$assert_clause3'(C0,C,Mod,Where,R,P) :-
'$check_head_and_body'(C,H,B,P),
( '$is_log_updatable'(H, Mod) ->
'$compile_dynamic'((H :- B), Where, C0, Mod, R)
;
'$is_dynamic'(H, Mod) ->
'$assertat_d'(Where, H, B, C0, Mod, R)
;
'$undefined'(H,Mod) ->
functor(H, Na, Ar),
'$dynamic'(Na/Ar, Mod),
'$assert_clause3'(C0,C,Mod,Where,R,P)
;
'$access_yap_flags'(14, 1) -> % I can assert over static facts in YAP mode
'$assert1'(Where,C,C0,Mod,H)
;
functor(H, Na, Ar),
'$do_error'(permission_error(modify,static_procedure,Na/Ar),P)
).
'$assert_dynamic'(V,Mod,_,_,_) :- var(V), !,
'$do_error'(instantiation_error,assert(Mod:V)).
'$assert_dynamic'(M:C,_,Where,R,P) :- !,
'$assert_dynamic'(C,M,Where,R,P).
'$assert_dynamic'((H:-G),M1,Where,R,P) :-
var(H), !, '$do_error'(instantiation_error,P).
'$assert_dynamic'(CI,Mod,Where,R,P) :-
'$expand_clause'(CI,C0,C,Mod,HM),
'$assert_dynamic2'(C0,C,HM,Where,R,P).
'$assert_dynamic2'(C0,C,Mod,Where,R,P) :-
'$check_head_and_body'(C,H,B,P),
( '$is_log_updatable'(H, Mod) ->
'$compile_dynamic'(C, Where, C0, Mod, R)
;
'$is_dynamic'(H, Mod) ->
'$assertat_d'(Where,H,B,C0,Mod,R)
;
'$undefined'(H, Mod) ->
functor(H, Na, Ar),
'$dynamic'(Na/Ar, Mod),
'$assert_dynamic2'(C0,C,Mod,Where,R,P)
;
functor(H,Na,Ar),
'$do_error'(permission_error(modify,static_procedure,Na/Ar),P)
).
assert_static(Mod:C) :- !,
'$assert_static'(C,Mod,last,_,assert_static(Mod:C)).
assert_static(C) :-
'$current_module'(Mod),
'$assert_static'(C,Mod,last,_,assert_static(C)).
asserta_static(Mod:C) :- !,
'$assert_static'(C,Mod,first,_,asserta_static(Mod:C)).
asserta_static(C) :-
'$current_module'(Mod),
'$assert_static'(C,Mod,first,_,asserta_static(C)).
asserta_static(Mod:C) :- !,
'$assert_static'(C,Mod,last,_,assertz_static(Mod:C)).
assertz_static(C) :-
'$current_module'(Mod),
'$assert_static'(C,Mod,last,_,assertz_static(C)).
'$assert_static'(V,M,_,_,_) :- var(V), !,
'$do_error'(instantiation_error,assert(M:V)).
'$assert_static'(M:C,_,Where,R,P) :- !,
'$assert_static'(C,M,Where,R,P).
'$assert_static'((H:-G),M1,Where,R,P) :-
var(H), !, '$do_error'(instantiation_error,P).
'$assert_static'(CI,Mod,Where,R,P) :-
'$expand_clause'(CI,C0,C,Mod, HM),
'$check_head_and_body'(C,H,B,P),
( '$is_dynamic'(H, HM) ->
'$do_error'(permission_error(modify,dynamic_procedure,HM:Na/Ar),P)
;
'$undefined'(H,HM), get_value('$full_iso',true) ->
functor(H,Na,Ar), '$dynamic'(Na/Ar, HM), '$assertat_d'(Where,H,B,C0,HM,R)
;
'$assert1'(Where,C,C0,HM,H)
).
'$assertat_d'(first,Head,Body,C0,Mod,R) :- !,
'$compile_dynamic'((Head:-Body), first, C0, Mod, CR),
( get_value('$abol',true)
->
'$flags'(Head,Mod,Fl,Fl),
( Fl /\ 0x00400000 =\= 0 -> '$erase_source'(Head,Mod) ; true ),
( Fl /\ 0x20000000 =\= 0 -> '$check_multifile_pred'(Head,Mod,Fl) ; true )
;
true
),
'$head_and_body'(C0, H0, B0),
'$recordap'(Mod:Head,(H0 :- B0),R,CR),
( '$is_multifile'(Head, Mod) ->
nb_getval('$consulting_file',F),
functor(H0, Na, Ar),
recorda('$multifile_dynamic'(_,_,_), '$mf'(Na,Ar,Mod,F,R), _)
;
true
).
'$assertat_d'(last,Head,Body,C0,Mod,R) :-
'$compile_dynamic'((Head:-Body), last, C0, Mod, CR),
( get_value('$abol',true)
->
'$flags'(Head,Mod,Fl,Fl),
( Fl /\ 0x00400000 =\= 0 -> '$erase_source'(Head,Mod) ; true ),
( Fl /\ 0x20000000 =\= 0 -> '$check_multifile_pred'(Head,Mod,Fl) ; true )
;
true
),
'$head_and_body'(C0, H0, B0),
'$recordzp'(Mod:Head,(H0 :- B0),R,CR),
( '$is_multifile'(H0, Mod) ->
get_value('$consulting_file',F),
functor(H0, Na, Ar),
recordz('$multifile_dynamic'(_,_,_), '$mf'(Na,Ar,Mod,F,R), _)
;
true
).
'$assert1'(last,C,C0,Mod,_) :- '$compile'(C,0,C0,Mod).
'$assert1'(first,C,C0,Mod,_) :- '$compile'(C,2,C0,Mod).
'$assertz_dynamic'(X, C, C0, Mod) :- (X/\4)=:=0, !,
'$head_and_body'(C,H,B),
'$assertat_d'(last,H,B,C0,Mod,_).
'$assertz_dynamic'(X,C,C0,Mod) :-
'$head_and_body'(C,H,B),
functor(H,N,A),
('$check_if_reconsulted'(N,A) ->
true
;
(X/\8)=:=0 ->
'$inform_as_reconsulted'(N,A),
'$remove_all_d_clauses'(H,Mod)
;
true
),
'$assertat_d'(last,H,B,C0,Mod,_).
'$remove_all_d_clauses'(H,M) :-
'$is_multifile'(H, M), !,
functor(H, Na, A),
'$erase_all_mf_dynamic'(Na,A,M).
'$remove_all_d_clauses'(H,M) :-
'$recordedp'(M:H,_,R), erase(R), fail.
'$remove_all_d_clauses'(_,_).
'$erase_all_mf_dynamic'(Na,A,M) :-
get_value('$consulting_file',F),
recorded('$multifile_dynamic'(_,_,_), '$mf'(Na,A,M,F,R), R1),
erase(R1),
erase(R),
fail.
'$erase_all_mf_dynamic'(_,_,_).
asserta(M:C,R) :- !,
'$assert_dynamic'(C,M,first,R,asserta(M:C,R)).
asserta(C,R) :-
'$current_module'(M),
'$assert_dynamic'(C,M,first,R,asserta(C,R)).
assertz(M:C,R) :- !,
'$assert_dynamic'(C,M,last,R,assertz(M:C,R)).
assertz(C,R) :-
'$current_module'(M),
'$assert_dynamic'(C,M,last,R,assertz(C,R)).
assert(M:C,R) :- !,
'$assert_dynamic'(C,M,last,R,assert(M:C,R)).
assert(C,R) :-
'$current_module'(M),
'$assert_dynamic'(C,M,last,R,assert(C,R)).
clause(M:P,Q) :- !,
'$clause'(P,M,Q,_).
clause(V,Q) :-
'$current_module'(M),
'$clause'(V,M,Q,_).
clause(P,Q,R) :- var(P), !,
'$current_module'(M),
'$clause'(P,M,Q,R).
clause(M:P,Q,R) :- !,
'$clause'(P,M,Q,R).
clause(V,Q,R) :-
'$current_module'(M),
'$clause'(V,M,Q,R).
'$clause'(P,M,Q,R) :-
'$instance_module'(R,M0), !,
M0 = M,
instance(R,T),
( T = (H :- B) -> P = H, Q = B ; P=T, Q = true).
'$clause'(V,M,Q,R) :- var(V), !,
'$do_error'(instantiation_error,clause(M:V,Q,R)).
'$clause'(C,M,Q,R) :- number(C), !,
'$do_error'(type_error(callable,C),clause(M:C,Q,R)).
'$clause'(R,M,Q,R) :- db_reference(R), !,
'$do_error'(type_error(callable,R),clause(M:R,Q,R)).
'$clause'(M:P,_,Q,R) :- !,
'$clause'(P,M,Q,R).
'$clause'(P,M,Q,R) :-
'$is_source'(P, M), !,
'$static_clause'(P,M,Q,R).
'$clause'(P,M,Q,R) :-
'$is_log_updatable'(P, M), !,
'$log_update_clause'(P,M,Q,R).
'$clause'(P,M,Q,R) :-
'$some_recordedp'(M:P), !,
'$recordedp'(M:P,(P:-Q),R).
'$clause'(P,M,Q,R) :-
\+ '$undefined'(P,M),
( '$system_predicate'(P,M) -> true ;
'$number_of_clauses'(P,M,N), N > 0 ),
functor(P,Name,Arity),
'$do_error'(permission_error(access,private_procedure,Name/Arity),
clause(M:P,Q,R)).
% just create a choice-point
% the 6th argument marks the time-stamp.
'$do_log_upd_clause'(_,_,_,_,_,_).
'$do_log_upd_clause'(A,B,C,D,E,_) :-
'$continue_log_update_clause'(A,B,C,D,E).
'$do_log_upd_clause'(_,_,_,_,_,_).
:- '$do_log_upd_clause'(_,_,_,_,_,_), !.
'$do_log_upd_clause_erase'(_,_,_,_,_,_).
'$do_log_upd_clause_erase'(A,B,C,D,E,_) :-
'$continue_log_update_clause_erase'(A,B,C,D,E).
'$do_log_upd_clause_erase'(_,_,_,_,_,_).
:- '$do_log_upd_clause_erase'(_,_,_,_,_,_), !.
'$do_log_upd_clause0'(_,_,_,_,_,_).
'$do_log_upd_clause0'(A,B,C,D,_,_) :-
'$continue_log_update_clause'(A,B,C,D).
'$do_log_upd_clause0'(_,_,_,_,_,_).
:- '$do_log_upd_clause0'(_,_,_,_,_,_), !.
'$do_static_clause'(_,_,_,_,_).
'$do_static_clause'(A,B,C,D,E) :-
'$continue_static_clause'(A,B,C,D,E).
'$do_static_clause'(_,_,_,_,_).
:- '$do_static_clause'(_,_,_,_,_), !.
nth_clause(V,I,R) :- var(V), var(R), !,
'$do_error'(instantiation_error,nth_clause(V,I,R)).
nth_clause(M:V,I,R) :- !,
'$nth_clause'(V,M,I,R).
nth_clause(V,I,R) :-
'$current_module'(M),
'$nth_clause'(V,M,I,R).
'$nth_clause'(V,M,I,R) :- var(V), var(R), !,
'$do_error'(instantiation_error,M:nth_clause(V,I,R)).
'$nth_clause'(P1,_,I,R) :- nonvar(P1), P1 = M:P, !,
'$nth_clause'(P,M,I,R).
'$nth_clause'(P,M,I,R) :- nonvar(R), !,
'$nth_clause_ref'(P,M,I,R).
'$nth_clause'(C,M,I,R) :- number(C), !,
'$do_error'(type_error(callable,C),M:nth_clause(C,I,R)).
'$nth_clause'(R,M,I,R) :- db_reference(R), !,
'$do_error'(type_error(callable,R),M:nth_clause(R,I,R)).
'$nth_clause'(P,M,I,R) :-
( '$is_log_updatable'(P,M) ; '$is_source'(P,M) ), !,
'$p_nth_clause'(P,M,I,R).
'$nth_clause'(P,M,I,R) :-
'$is_dynamic'(P,M), !,
'$nth_instancep'(M:P,I,R).
'$nth_clause'(P,M,I,R) :-
( '$system_predicate'(P,M) -> true ;
'$number_of_clauses'(P,M,N), N > 0 ),
functor(P,Name,Arity),
'$do_error'(permission_error(access,private_procedure,Name/Arity),
nth_clause(M:P,I,R)).
'$nth_clause_ref'(Cl,M,I,R) :-
'$pred_for_code'(R, _, _, M1, I), I > 0, !,
instance(R, Cl),
M1 = M.
'$nth_clause_ref'(P,M,I,R) :-
'$nth_instancep'(M:P,I,R).
retract(M:C) :- !,
'$retract'(C,M).
retract(C) :-
'$current_module'(M),
'$retract'(C,M).
'$retract'(V,_) :- var(V), !,
'$do_error'(instantiation_error,retract(V)).
'$retract'(M:C,_) :- !,
'$retract'(C,M).
'$retract'(C,M) :-
'$check_head_and_body'(C,H,B,retract(M:C)), !,
'$flags'(H, M, F, F),
'$retract2'(F, H,M,B,_).
'$retract2'(F, H, M, B, R) :-
F /\ 0x08000000 =:= 0x08000000, !,
% '$is_log_updatable'(H, M), !,
'$log_update_clause'(H,M,B,R),
( F /\ 0x20000000 =:= 0x20000000, recorded('$mf','$mf_clause'(_,_,_,_,R),MR), erase(MR), fail ; true),
erase(R).
'$retract2'(F, H, M, B, R) :-
% '$is_dynamic'(H,M), !,
F /\ 0x00002000 =:= 0x00002000, !,
'$recordedp'(M:H,(H:-B),R),
( F /\ 0x20000000 =:= 0x20000000, recorded('$mf','$mf_clause'(_,_,_,_,MRef),MR), erase(MR), fail ; true),
erase(R).
'$retract2'(_, H,M,_,_) :-
'$undefined'(H,M), !,
functor(H,Na,Ar),
'$dynamic'(Na/Ar,M),
fail.
'$retract2'(_, H,M,B,_) :-
functor(H,Na,Ar),
'$do_error'(permission_error(modify,static_procedure,Na/Ar),retract(M:(H:-B))).
retract(M:C,R) :- !,
'$retract'(C,M,R).
retract(C,R) :-
'$current_module'(M),
'$retract'(C,M,R).
'$retract'(V,M,R) :- var(V), !,
'$do_error'(instantiation_error,retract(M:V,R)).
'$retract'(M:C,_,R) :- !,
'$retract'(C,M,R).
'$retract'(C, M, R) :-
'$check_head_and_body'(C,H,B,retract(C,R)),
db_reference(R), '$is_dynamic'(H,M), !,
instance(R,(H:-B)), erase(R).
'$retract'(C,M,R) :-
'$check_head_and_body'(C,H,B,retract(C,R)),
var(R), !,
'$retract2'(H, M, B, R).
'$retract'(C,M,_) :-
'$fetch_predicate_indicator_from_clause'(C, PI),
'$do_error'(permission_error(modify,static_procedure,PI),retract(M:C)).
'$fetch_predicate_indicator_from_clause'((C :- _), Na/Ar) :- !,
functor(C, Na, Ar).
'$fetch_predicate_indicator_from_clause'(C, Na/Ar) :-
functor(C, Na, Ar).
retractall(M:V) :- !,
'$retractall'(V,M).
retractall(V) :-
'$current_module'(M),
'$retractall'(V,M).
'$retractall'(V,M) :- var(V), !,
'$do_error'(instantiation_error,retract(M:V)).
'$retractall'(M:V,_) :- !,
'$retractall'(V,M).
'$retractall'(T,M) :-
(
'$is_log_updatable'(T, M) ->
( '$is_multifile'(T, M) ->
'$retractall_lu_mf'(T,M)
;
'$retractall_lu'(T,M)
)
;
'$undefined'(T,M) ->
functor(T,Na,Ar),
'$dynamic'(Na/Ar,M), !
;
'$is_dynamic'(T,M) ->
'$erase_all_clauses_for_dynamic'(T, M)
;
functor(T,Na,Ar),
'$do_error'(permission_error(modify,static_procedure,Na/Ar),retractall(T))
).
'$retractall_lu'(T,M) :-
'$log_update_clause'(T,M,_,R),
erase(R),
fail.
'$retractall_lu'(_,_).
'$retractall_lu_mf'(T,M) :-
'$log_update_clause'(T,M,_,R),
( recorded('$mf','$mf_clause'(_,_,_,_,R),MR), erase(MR), fail ; true),
erase(R),
fail.
'$retractall_lu_mf'(_,_).
'$erase_all_clauses_for_dynamic'(T, M) :-
'$recordedp'(M:T,(T :- _),R), erase(R), fail.
'$erase_all_clauses_for_dynamic'(T,M) :-
'$recordedp'(M:T,_,_), fail.
'$erase_all_clauses_for_dynamic'(_,_).
abolish(Mod:N,A) :- !,
'$abolish'(N,A,Mod).
abolish(N,A) :-
'$current_module'(Mod),
'$abolish'(N,A,Mod).
'$abolish'(N,A,M) :- var(N), !,
'$do_error'(instantiation_error,abolish(M:N,A)).
'$abolish'(N,A,M) :- var(A), !,
'$do_error'(instantiation_error,abolish(M:N,A)).
'$abolish'(N,A,M) :-
( recorded('$predicate_defs','$predicate_defs'(N,A,M,_),R) -> erase(R) ),
fail.
'$abolish'(N,A,M) :- functor(T,N,A),
( '$is_dynamic'(T, M) -> '$abolishd'(T,M) ;
/* else */ '$abolishs'(T,M) ).
abolish(V) :- var(V), !,
'$do_error'(instantiation_error,abolish(V)).
abolish(Mod:V) :- var(V), !,
'$do_error'(instantiation_error,abolish(M:V)).
abolish(M:X) :- !,
'$abolish'(X,M).
abolish(X) :-
'$current_module'(M),
'$abolish'(X,M).
'$abolish'(X,M) :-
'$access_yap_flags'(8, 2), !,
'$new_abolish'(X,M).
'$abolish'(X, M) :-
'$old_abolish'(X,M).
'$new_abolish'(V,M) :- var(V), !,
'$abolish_all'(M).
'$new_abolish'(A,M) :- atom(A), !,
'$abolish_all_atoms'(A,M).
'$new_abolish'(M:PS,_) :- !,
'$new_abolish'(PS,M).
'$new_abolish'(Na//Ar1, M) :-
integer(Ar1),
!,
Ar is Ar1+2,
'$new_abolish'(Na//Ar, M).
'$new_abolish'(Na/Ar, M) :-
functor(H, Na, Ar),
'$is_dynamic'(H, M), !,
'$abolishd'(H, M).
'$new_abolish'(Na/Ar, M) :- % succeed for undefined procedures.
functor(T, Na, Ar),
'$undefined'(T, M), !.
'$new_abolish'(Na/Ar, M) :-
'$do_error'(permission_error(modify,static_procedure,Na/Ar),abolish(M:Na/Ar)).
'$new_abolish'(T, M) :-
'$do_error'(type_error(predicate_indicator,T),abolish(M:T)).
'$abolish_all'(M) :-
'$current_predicate'(M,Na,Ar),
'$new_abolish'(Na/Ar, M),
fail.
'$abolish_all'(_).
'$abolish_all_atoms'(Na, M) :-
'$current_predicate_for_atom'(Na,M,Ar),
'$new_abolish'(Na/Ar, M),
fail.
'$abolish_all_atoms'(_,_).
'$check_error_in_predicate_indicator'(V, Msg) :-
var(V), !,
'$do_error'(instantiation_error, Msg).
'$check_error_in_predicate_indicator'(M:S, Msg) :- !,
'$check_error_in_module'(M, Msg),
'$check_error_in_predicate_indicator'(S, Msg).
'$check_error_in_predicate_indicator'(S, Msg) :-
S \= _/_,
S \= _//_, !,
'$do_error'(type_error(predicate_indicator,S), Msg).
'$check_error_in_predicate_indicator'(Na/_, Msg) :-
var(Na), !,
'$do_error'(instantiation_error, Msg).
'$check_error_in_predicate_indicator'(Na/_, Msg) :-
\+ atom(Na), !,
'$do_error'(type_error(atom,Na), Msg).
'$check_error_in_predicate_indicator'(_/Ar, Msg) :-
var(Ar), !,
'$do_error'(instantiation_error, Msg).
'$check_error_in_predicate_indicator'(_/Ar, Msg) :-
\+ integer(Ar), !,
'$do_error'(type_error(integer,Ar), Msg).
'$check_error_in_predicate_indicator'(_/Ar, Msg) :-
Ar < 0, !,
'$do_error'(domain_error(not_less_than_zero,Ar), Msg).
% not yet implemented!
%'$check_error_in_predicate_indicator'(Na/Ar, Msg) :-
% Ar < maxarity, !,
% '$do_error'(type_error(representation_error(max_arity),Ar), Msg).
'$check_error_in_module'(M, Msg) :-
var(M), !,
'$do_error'(instantiation_error, Msg).
'$check_error_in_module'(M, Msg) :-
\+ atom(M), !,
'$do_error'(type_error(atom,M), Msg).
'$old_abolish'(V,M) :- var(V), !,
( '$access_yap_flags'(8, 1) ->
'$do_error'(instantiation_error,abolish(M:V))
;
'$abolish_all_old'(M)
).
'$old_abolish'(N/A, M) :- !,
'$abolish'(N, A, M).
'$old_abolish'(A,M) :- atom(A), !,
( '$access_yap_flags'(8, 1) ->
'$do_error'(type_error(predicate_indicator,A),abolish(M:A))
;
'$abolish_all_atoms_old'(A,M)
).
'$old_abolish'(M:N,_) :- !,
'$old_abolish'(N,M).
'$old_abolish'([], _) :- !.
'$old_abolish'([H|T], M) :- !, '$old_abolish'(H, M), '$old_abolish'(T, M).
'$old_abolish'(T, M) :-
'$do_error'(type_error(predicate_indicator,T),abolish(M:T)).
'$abolish_all_old'(M) :-
'$current_predicate'(M, Na, Ar),
'$abolish'(Na, Ar, M),
fail.
'$abolish_all_old'(_).
'$abolish_all_atoms_old'(Na, M) :-
'$current_predicate_for_atom'(Na, M, Ar),
'$abolish'(Na, Ar, M),
fail.
'$abolish_all_atoms_old'(_,_).
'$abolishd'(T, M) :-
'$is_multifile'(T,M),
functor(T,Name,Arity),
recorded('$mf','$mf_clause'(_,Name,Arity,M,Ref),R),
erase(R),
erase(Ref),
fail.
'$abolishd'(T, M) :-
recorded('$import','$import'(_,M,_,T,_,_),R),
erase(R),
fail.
'$abolishd'(T, M) :-
'$purge_clauses'(T,M), fail.
'$abolishd'(T, M) :-
'$kill_dynamic'(T,M), fail.
'$abolishd'(_, _).
'$abolishs'(G, M) :- '$system_predicate'(G,M), !,
functor(G,Name,Arity),
'$do_error'(permission_error(modify,static_procedure,Name/Arity),abolish(M:G)).
'$abolishs'(G, Module) :-
'$access_yap_flags'(8, 2), % only do this in sicstus mode
'$undefined'(G, Module),
functor(G,Name,Arity),
print_message(warning,no_match(abolish(Module:Name/Arity))).
'$abolishs'(G, M) :-
'$is_multifile'(G,M), !,
functor(G,Name,Arity),
recorded('$mf','$mf_clause'(_,Name,Arity,M,Ref),R),
erase(R),
erase(Ref),
fail.
'$abolishs'(T, M) :-
recorded('$import','$import'(_,M,_,_,T,_,_),R),
erase(R),
fail.
'$abolishs'(G, M) :-
'$purge_clauses'(G, M), fail.
'$abolishs'(_, _).
%
% can only do as goal in YAP mode.
%
dynamic(X) :- '$access_yap_flags'(8, 0), !,
'$current_module'(M),
'$dynamic'(X, M).
dynamic(X) :-
'$do_error'(context_error(dynamic(X),declaration),query).
'$dynamic'(X,M) :- var(X), !,
'$do_error'(instantiation_error,dynamic(M:X)).
'$dynamic'(Mod:Spec,_) :- !,
'$dynamic'(Spec,Mod).
'$dynamic'([], _) :- !.
'$dynamic'([H|L], M) :- !, '$dynamic'(H, M), '$dynamic'(L, M).
'$dynamic'((A,B),M) :- !, '$dynamic'(A,M), '$dynamic'(B,M).
'$dynamic'(X,M) :-
'$dynamic2'(X,M).
'$dynamic2'(X, Mod) :- '$log_upd'(Stat), Stat\=0, !,
'$logical_updatable'(X, Mod).
'$dynamic2'(A//N1, Mod) :-
integer(N1),
N is N1+2,
'$dynamic2'(A/N, Mod).
'$dynamic2'(A/N, Mod) :-
integer(N), atom(A), !,
functor(T,A,N), '$flags'(T,Mod,F,F),
% LogUpd,BinaryTest,Safe,C,Dynamic,Compiled,Standard,Asm,
( F/\ 0x19D1FA80 =:= 0, '$undefined'(T,Mod) -> NF is F \/ 0x00002000, '$flags'(T, Mod, F, NF), '$mk_d'(T,Mod);
F /\ 0x00002000 =:= 0x00002000 -> '$mk_d'(T,Mod); % dynamic
F /\ 0x08000000 =:= 0x08000000 -> '$mk_d'(T,Mod) ; % LU
F /\ 0x00000400 =:= 0x00000400, '$undefined'(T,Mod) -> F1 is F /\ \(0x400), N1F is F1 \/ 0x00002000, NF is N1F /\ \(0x00400000), '$flags'(T,Mod,F,NF), '$mk_d'(T,Mod);
'$do_error'(permission_error(modify,static_procedure,A/N),dynamic(Mod:A/N))
).
'$dynamic2'(X,Mod) :-
'$do_error'(type_error(callable,X),dynamic(Mod:X)).
'$logical_updatable'(A//N,Mod) :- integer(N), !,
N1 is N+2,
'$logical_updatable'(A/N1,Mod).
'$logical_updatable'(A/N,Mod) :- integer(N), atom(A), !,
functor(T,A,N), '$flags'(T,Mod,F,F),
(
F/\ 0x19D1FA80 =:= 0, '$undefined'(T,Mod) -> NF is F \/ 0x08000400, '$flags'(T,Mod,F,NF), '$mk_d'(T,Mod);
F /\ 0x08000000 =:= 0x08000000 -> '$mk_d'(T,Mod) ; % LU
F /\ 0x00002000 =:= 0x00002000 -> '$mk_d'(T,Mod); % dynamic
F /\ 0x00000400 =:= 0x00000400 , '$undefined'(T,Mod) -> N1F is F \/ 0x08000000, NF is N1F /\ \(0x00400000), '$flags'(T,Mod,F,NF), '$mk_d'(T,Mod);
'$do_error'(permission_error(modify,static_procedure,A/N),dynamic(Mod:A/N))
).
'$logical_updatable'(X,Mod) :-
'$do_error'(type_error(callable,X),dynamic(Mod:X)).
dynamic_predicate(P,Sem) :-
'$bad_if_is_semantics'(Sem, dynamic(P,Sem)).
dynamic_predicate(P,Sem) :-
'$log_upd'(OldSem),
( Sem = logical -> '$switch_log_upd'(1) ; '$switch_log_upd'(0) ),
'$current_module'(M),
'$dynamic'(P, M),
'$switch_log_upd'(OldSem).
'$bad_if_is_semantics'(Sem, Goal) :-
var(Sem), !,
'$do_error'(instantiation_error,Goal).
'$bad_if_is_semantics'(Sem, Goal) :-
Sem \= immediate, Sem \= logical, !,
'$do_error'(domain_error(semantics_indicator,Sem),Goal).
'$expand_clause'((H:-B),C1,C2,Mod,HM) :- !,
strip_module(Mod:H, HM, H1),
'$module_expansion'((H1:-B), C1, C2, Mod, HM),
( get_value('$strict_iso',on) ->
'$check_iso_strict_clause'(C1)
;
true
).
'$expand_clause'(H,H1,H1,Mod,HM) :-
strip_module(Mod:H, HM, H1).
'$public'(X, _) :- var(X), !,
'$do_error'(instantiation_error,public(X)).
'$public'(Mod:Spec, _) :- !,
'$public'(Spec,Mod).
'$public'((A,B), M) :- !, '$public'(A,M), '$public'(B,M).
'$public'([],_) :- !.
'$public'([H|L], M) :- !, '$public'(H, M), '$public'(L, M).
'$public'(A//N1, Mod) :- integer(N1), !,
N is N1+2,
'$public'(A//N, Mod).
'$public'(A/N, Mod) :- integer(N), atom(A), !,
functor(T,A,N),
'$do_make_public'(T, Mod).
'$public'(X, Mod) :-
'$do_error'(type_error(callable,X),dynamic(Mod:X)).
'$do_make_public'(T, Mod) :-
'$is_dynamic'(T, Mod), !. % all dynamic predicates are public.
'$do_make_public'(T, Mod) :-
'$flags'(T,Mod,F,F),
NF is F\/0x00400000,
'$flags'(T,Mod,F,NF).
'$is_public'(T, Mod) :-
'$is_dynamic'(T, Mod), !. % all dynamic predicates are public.
'$is_public'(T, Mod) :-
'$flags'(T,Mod,F,F),
F\/0x00400000 =\= 0.
hide_predicate(V) :- var(V), !,
'$do_error'(instantiation_error,hide_predicate(V)).
hide_predicate(M:P) :- !,
'$hide_predicate2'(P, M).
hide_predicate(P) :-
'$current_module'(M),
'$hide_predicate2'(P, M).
'$hide_predicate2'(V, M) :- var(V), !,
'$do_error'(instantiation_error,hide_predicate(M:V)).
'$hide_predicate2'(N/A, M) :- !,
functor(S,N,A),
'$hide_predicate'(S, M) .
'$hide_predicate2'(PredDesc, M) :-
'$do_error'(type_error(predicate_indicator,PredDesc),hide_predicate(M:PredDesc)).
predicate_property(Pred,Prop) :- var(Pred), !,
'$current_module'(Mod),
'$predicate_property2'(Pred,Prop,Mod).
predicate_property(Mod:Pred,Prop) :- !,
'$predicate_property2'(Pred,Prop,Mod).
predicate_property(Pred,Prop) :-
'$current_module'(Mod),
'$predicate_property2'(Pred,Prop,Mod).
'$predicate_property2'(Pred,Prop,M) :- var(M), !,
'$all_current_modules'(M),
'$predicate_property2'(Pred,Prop,M).
'$predicate_property2'(Pred,Prop,M0) :- var(Pred), !,
(M = M0 ; M = prolog), % prolog mode is automatically incorporate in every other module
'$generate_all_preds_from_mod'(Pred, SourceMod, M),
'$predicate_property'(Pred,SourceMod,M,Prop).
'$predicate_property2'(M:Pred,Prop,_) :- !,
'$predicate_property2'(Pred,Prop,M).
'$predicate_property2'(Pred,Prop,Mod) :-
'$pred_exists'(Pred,Mod), !,
'$predicate_property'(Pred,Mod,Mod,Prop).
'$predicate_property2'(Pred,Prop,Mod) :-
'$imported_pred'(Pred, Mod, NPred, M),
(
Prop = imported_from(M)
;
'$predicate_property'(NPred,M,M,Prop),
Prop \= exported
).
'$generate_all_preds_from_mod'(Pred, M, M) :-
'$current_predicate'(M,Na,Ar),
'$ifunctor'(Pred,Na,Ar).
'$generate_all_preds_from_mod'(Pred, SourceMod, Mod) :-
recorded('$import','$import'(SourceMod,Mod,_,Pred,_,_),_).
'$predicate_property'(P,M,_,built_in) :-
'$system_predicate'(P,M).
'$predicate_property'(P,M,_,source) :-
'$flags'(P,M,F,F),
F /\ 0x00400000 =\= 0.
'$predicate_property'(P,M,_,tabled) :-
'$flags'(P,M,F,F),
F /\ 0x00000040 =\= 0.
'$predicate_property'(P,M,_,dynamic) :-
'$is_dynamic'(P,M).
'$predicate_property'(P,M,_,static) :-
\+ '$is_dynamic'(P,M),
\+ '$undefined'(P,M).
'$predicate_property'(P,M,_,meta_predicate(Q)) :-
functor(P,Na,Ar),
'$meta_predicate'(Na,M,Ar,Q).
'$predicate_property'(P,M,_,multifile) :-
'$is_multifile'(P,M).
'$predicate_property'(P,M,_,public) :-
'$is_public'(P,M).
'$predicate_property'(P,M,M,exported) :-
functor(P,N,A),
once(recorded('$module','$module'(_TFN,M,Publics),_)),
lists:memberchk(N/A,Publics).
'$predicate_property'(P,Mod,_,number_of_clauses(NCl)) :-
'$number_of_clauses'(P,Mod,NCl).
predicate_statistics(V,NCls,Sz,ISz) :- var(V), !,
'$do_error'(instantiation_error,predicate_statistics(V,NCls,Sz,ISz)).
predicate_statistics(M:P,NCls,Sz,ISz) :- !,
'$predicate_statistics'(P,M,NCls,Sz,ISz).
predicate_statistics(P,NCls,Sz,ISz) :-
'$current_module'(M),
'$predicate_statistics'(P,M,NCls,Sz,ISz).
'$predicate_statistics'(M:P,_,NCls,Sz,ISz) :- !,
'$predicate_statistics'(P,M,NCls,Sz,ISz).
'$predicate_statistics'(P,M,NCls,Sz,ISz) :-
'$is_log_updatable'(P, M), !,
'$lu_statistics'(P,NCls,Sz,ISz,M).
'$predicate_statistics'(P,M,_,_,_) :-
'$system_predicate'(P,M), !, fail.
'$predicate_statistics'(P,M,_,_,_) :-
'$undefined'(P,M), !, fail.
'$predicate_statistics'(P,M,NCls,Sz,ISz) :-
'$static_pred_statistics'(P,M,NCls,Sz,ISz).
predicate_erased_statistics(P,NCls,Sz,ISz) :-
current_predicate(_,P),
predicate_erased_statistics(P,NCls,Sz,ISz).
predicate_erased_statistics(M:P,NCls,Sz,ISz) :- !,
'$predicate_erased_statistics'(M:P,NCls,Sz,_,ISz).
predicate_erased_statistics(P,NCls,Sz,ISz) :-
'$current_module'(M),
'$predicate_erased_statistics'(M:P,NCls,Sz,_,ISz).
current_predicate(A,T) :-
'$current_predicate_inside'(A,T).
'$current_predicate_inside'(A,T) :-
var(T), !, % only for the predicate
'$current_module'(M),
'$current_predicate_no_modules'(M,A,T).
'$current_predicate_inside'(A,M:T) :- % module specified
var(M), !,
'$current_predicate_var'(A,M,T).
'$current_predicate_inside'(A,M:T) :- % module specified
nonvar(T),
!,
functor(T,A,_),
'$pred_exists'(T,M).
'$current_predicate_inside'(A,M:T) :- % module specified
!,
'$current_predicate_no_modules'(M,A,T).
'$current_predicate_inside'(A,T) :- % only for the predicate
'$current_module'(M),
'$current_predicate_no_modules'(M,A,T).
'$current_predicate_var'(A,M,T) :-
var(T), !,
current_module(M),
M \= prolog,
'$current_predicate_no_modules'(M,A,T).
'$current_predicate_var'(A,M,T) :-
functor(T,A,_),
current_module(M),
M \= prolog,
'$pred_exists'(T,M).
current_predicate(A) :-
'$current_predicate_inside'(A).
'$current_predicate_inside'(F) :-
var(F), !, % only for the predicate
'$current_module'(M),
'$current_predicate3'(M,F).
'$current_predicate_inside'(M:F) :- % module specified
var(M), !,
'$current_module'(M),
M \= prolog,
'$current_predicate3'(M,F).
'$current_predicate_inside'(M:F) :- % module specified
!,
'$current_predicate3'(M,F).
'$current_predicate_inside'(S) :- % only for the predicate
'$current_module'(M),
'$current_predicate3'(M,S).
system_predicate(A,P) :-
'$current_predicate_no_modules'(prolog,A,P),
\+ '$hidden'(A).
system_predicate(P) :-
'$current_module'(M),
'$system_predicate'(P,M).
'$current_predicate_no_modules'(M,A,T) :-
'$current_predicate'(M,A,Arity),
'$ifunctor'(T,A,Arity),
'$pred_exists'(T,M).
'$current_predicate3'(M,A/Arity) :-
nonvar(M),
nonvar(A),
nonvar(Arity), !,
'$ifunctor'(Pred,A,Arity),
'$pred_exists'(Pred,M).
'$current_predicate3'(M,A/Arity) :-
nonvar(A), nonvar(Arity), !,
(
'$current_predicate'(M,A,Arity)
->
'$ifunctor'(T,A,Arity),
'$pred_exists'(T,M)
% ;
% '$current_predicate'(prolog,A,Arity)
% ->
% functor(T,A,Arity),
% '$pred_exists'(T,M)
% ;
% recorded('$import','$import'(NM,M,G,T,A,Arity),_)
% ->
% '$pred_exists'(G,NM)
).
'$current_predicate3'(M,A/Arity) :- !,
(
'$current_predicate'(M,A,Arity),
'$ifunctor'(T,A,Arity),
'$pred_exists'(T,M)
% ;
% '$current_predicate'(prolog,A,Arity),
% functor(T,A,Arity),
% '$pred_exists'(T,M)
% ;
% recorded('$import','$import'(NM,M,G,T,A,Arity),_),
% functor(T,A,Arity),
% '$pred_exists'(G,NM)
).
'$current_predicate3'(M,BadSpec) :- % only for the predicate
'$do_error'(type_error(predicate_indicator,BadSpec),current_predicate(M:BadSpec)).
current_key(A,K) :-
'$current_predicate'(idb,A,Arity),
'$ifunctor'(K,A,Arity).
% do nothing for now.
'$noprofile'(_, _).
'$ifunctor'(Pred,Na,Ar) :-
(Ar > 0 ->
functor(Pred, Na, Ar)
;
Pred = Na
).
yap-6.2.2/pl/profile.yap 000644 000765 000024 00000011506 11465602162 015044 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: profile.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: Some profiling predicates available in yap *
* *
*************************************************************************/
% hook predicate, taken from SWI-Prolog, for converting possibly explicitly-
% qualified callable terms into an atom that can be used as a label for
% describing a predicate; used e.g. on the tick profiler defined below
:- multifile(user:prolog_predicate_name/2).
:- meta_predicate profile_data(:,+,-).
profile_data(M:D, Parm, Data) :-!,
(
var(M) ->
'$do_error'(instantiation_error,profile_data(M:D, Parm, Data))
;
'$profile_data'(D, Parm, Data, M)
).
profile_data(P, Parm, Data) :-
'$current_module'(M),
'$profile_data'(P, Parm, Data, M).
'$profile_data'(P, Parm, Data,M) :- var(P), !,
'$profile_data_for_var'(P, Parm, Data,M).
'$profile_data'(M:P, Parm, Data, _) :- !,
'$profile_data'(P, Parm, Data, M).
'$profile_data'(P, Parm, Data, M) :-
'$profile_data2'(P, Parm, Data, M).
'$profile_data2'(Na/Ar,Parm,Data, M) :-
functor(P, Na, Ar),
'$profile_info'(M, P, Stats),
'$profile_say'(Stats, Parm, Data).
'$profile_data_for_var'(Name/Arity, Parm, Data, M) :-
'$current_predicate'(M,Name,Arity),
functor(P,Name,Arity),
\+ '$hidden'(Name), % don't show hidden predicates.
'$profile_info'(M, P, Stats),
'$profile_say'(Stats, Parm, Data).
'$profile_say'('$profile'(Entries, _, _), calls, Entries).
'$profile_say'('$profile'(_, _, Backtracks), retries, Backtracks).
profile_reset :-
current_module(M),
'$current_predicate'(M,Na,Ar),
functor(P,Na,Ar),
'$profile_reset'(M, P),
fail.
profile_reset.
showprofres :-
showprofres(-1).
showprofres(A) :-
('$proftype'(offline) -> '$offline_showprofres' ; true),
('$profison' -> profoff, Stop = true ; Stop = false),
'$profglobs'(Tot,GCs,HGrows,SGrows,Mallocs,ProfOns),
% root node has no useful info.
'$get_all_profinfo'(0,[],ProfInfo0,0,_TotCode),
msort(ProfInfo0,ProfInfo),
'$get_ppreds'(ProfInfo,Preds0),
'$add_extras_prof'(GCs, HGrows, SGrows, Mallocs, Preds0, PredsI),
keysort(PredsI,Preds),
'$sum_alls'(Preds,0,Tot0),
Accounted is -Tot0,
(ProfOns == 0 ->
format(user_error,'~d ticks, ~d accounted for~n',[Tot,Accounted])
;
format(user_error,'~d ticks, ~d accounted for (~d overhead)~n',[Tot,Accounted,ProfOns])
),
A1 is A+1,
'$display_preds'(Preds, Tot, 0, 1, A1),
(Stop = true -> profon ; true).
/*
'$check_duplicates'([]).
'$check_duplicates'([A,A|ProfInfo]) :- !,
write(A),nl,
'$check_duplicates'(ProfInfo).
'$check_duplicates'([_|ProfInfo]) :-
'$check_duplicates'(ProfInfo).
*/
'$get_all_profinfo'([],L,L,Tot,Tot) :- !.
'$get_all_profinfo'(Node,L0,Lf,Tot0,Totf) :-
'$profnode'(Node,Clause,PredId,Count,Left,Right),
Tot1 is Tot0+Count,
'$get_all_profinfo'(Left,L0,Li,Tot1,Tot2),
'$get_all_profinfo'(Right,[gprof(PredId,Clause,Count)|Li],Lf,Tot2,Totf).
'$get_ppreds'([],[]).
'$get_ppreds'([gprof(0,_,0)|Cls],Ps) :- !,
'$get_ppreds'(Cls,Ps).
'$get_ppreds'([gprof(0,_,Count)|_],_) :- !,
'$do_error'(system_error,showprofres(gprof(0,_,Count))).
'$get_ppreds'([gprof(PProfInfo,_,Count0)|Cls],[Sum-(Mod:Name/Arity)|Ps]) :-
'$get_more_ppreds'(Cls,PProfInfo,Count0,NCls,Sum),
'$get_pred_pinfo'(PProfInfo,Mod,Name,Arity),
'$get_ppreds'(NCls,Ps).
'$get_more_ppreds'([gprof(PProfInfo,_,Count)|Cls],PProfInfo,Count0,NCls,Sum)
:- !,
Count1 is Count+Count0,
'$get_more_ppreds'(Cls,PProfInfo,Count1,NCls,Sum).
'$get_more_ppreds'(Cls, _, Sum, Cls, NSum) :- NSum is -Sum.
'$display_preds'(_, _, _, N, N) :- !.
'$display_preds'([], _, _, _, _).
'$display_preds'([NSum-P|Ps], Tot, SoFar, I, N) :-
Sum is -NSum,
Perc is (100*Sum)/Tot,
Next is SoFar+Sum,
NextP is (100*Next)/Tot,
( ( P = M:F/A ->
G = M:H
; P = F/A,
G = H
),
functor(H, F, A),
user:prolog_predicate_name(G, PL) ->
true
; PL = P
),
format(user_error,'~|~t~d.~7+ ~|~w:~t~d~50+ (~|~t~2f~6+%) |~|~t~2f~6+%|~n',[I,PL,Sum,Perc,NextP]),
I1 is I+1,
'$display_preds'(Ps,Tot,Next,I1, N).
'$sum_alls'([],Tot,Tot).
'$sum_alls'([C-_|Preds],Tot0,Tot) :-
TotI is C+Tot0,
'$sum_alls'(Preds,TotI,Tot).
'$add_extras_prof'(GCs, HGrows, SGrows, Mallocs, Preds0, PredsI) :-
'$add_extra_prof'(GCs, 'Garbage Collections',Preds0,Preds1),
'$add_extra_prof'(HGrows, 'Code Expansion',Preds1,Preds2),
'$add_extra_prof'(SGrows, 'Stack Expansion',Preds2,Preds3),
'$add_extra_prof'(Mallocs, 'Heap Allocation',Preds3,PredsI).
'$add_extra_prof'(0, _,Preds, Preds) :- !.
'$add_extra_prof'(Ticks, Name, Preds, [NTicks-Name|Preds]) :-
NTicks is -Ticks.
yap-6.2.2/pl/protect.yap 000644 000765 000024 00000002607 11457004725 015070 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: protect.yap *
* Last rev: *
* mods: *
* comments: protecting the system functions *
* *
*************************************************************************/
% This protects all code from further changes
% and also makes it impossible from some predicates to be seen
'$protect' :-
current_atom(Name),
atom_codes(Name,[0'$|_]),
'$hide_predicates'(Name),
'$hide'(Name).
'$protect' :-
'$hide_predicates'(bootstrap),
'$hide'(bootstrap).
'$protect'.
'$hide_predicates'(Name) :-
'$current_predicate_for_atom'(Name, prolog, P),
'$hide_predicate'(P,prolog),
fail.
'$hide_predicates'(_).
% hide all atoms who start by '$'
'$hide'('$VAR') :- !, fail. /* not $VAR */
'$hide'('$dbref') :- !, fail. /* not stream position */
'$hide'('$stream') :- !, fail. /* not $STREAM */
'$hide'('$stream_position') :- !, fail. /* not stream position */
'$hide'('$hacks') :- !, fail.
'$hide'('$source_location') :- !, fail.
'$hide'('$messages') :- !, fail.
'$hide'(Name) :- hide(Name), fail.
yap-6.2.2/pl/save.yap 000644 000765 000024 00000003727 11475020360 014343 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2010 *
* *
**************************************************************************
* *
* File: save.yap *
* Last rev: 11/29/10 *
* mods: *
* comments: Some utility predicates to support save/restore in yap *
* *
*************************************************************************/
%%% Saving and restoring a computation
save(A) :- save(A,_).
save(A,_) :- var(A), !,
'$do_error'(instantiation_error,save(A)).
save(A,OUT) :- atom(A), !, atom_codes(A,S), '$save'(S,OUT).
save(S,OUT) :- '$save'(S,OUT).
save_program(A) :- var(A), !,
'$do_error'(instantiation_error,save_program(A)).
save_program(A) :- atom(A), !,
atom_codes(A,S),
'$save_program2'(S, true).
save_program(S) :- '$save_program2'(S, true).
save_program(A, G) :- var(A), !,
'$do_error'(instantiation_error, save_program(A,G)).
save_program(A, G) :- var(G), !,
'$do_error'(instantiation_error, save_program(A,G)).
save_program(A, G) :- \+ callable(G), !,
'$do_error'(type_error(callable,G), save_program(A,G)).
save_program(A, G) :-
( atom(A) -> atom_codes(A,S) ; A = S),
'$save_program2'(S, G),
fail.
save_program(_,_).
'$save_program2'(S,G) :-
(
G == true
->
true
;
recorda('$restore_goal', G ,R)
),
(
'$undefined'(reload_foreign_libraries, shlib)
->
true
;
recorda('$reload_foreign_libraries', true, R1)
),
'$save_program'(S),
(
var(R1)
->
true
;
erase(R1)
),
(
var(R)
->
true
;
erase(R)
),
fail.
'$save_program2'(_,_).
restore(A) :- var(A), !,
'$do_error'(instantiation_error,restore(A)).
restore(A) :- atom(A), !, name(A,S), '$restore'(S).
restore(S) :- '$restore'(S).
yap-6.2.2/pl/setof.yap 000644 000765 000024 00000015044 11472461457 014535 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* 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 *
* *
**************************************************************************
* *
* File: setof.pl *
* Last rev: *
* mods: *
* comments: set predicates *
* *
*************************************************************************/
% The "existential quantifier" symbol is only significant to bagof
% and setof, which it stops binding the quantified variable.
% op(200, xfy, ^) is defined during bootstrap.
% this is used by the all predicate
:- op(50,xfx,same).
_^Goal :-
'$execute'(Goal).
% findall/3 is a simplified version of bagof which has an implicit
% existential quantifier on every variable.
findall(Template, Generator, Answers) :-
( '$partial_list_or_list'(Answers) ->
true
;
'$do_error'(type_error(list,Answers), findall(Template, Generator, Answers))
),
'$findall'(Template, Generator, [], Answers).
% If some answers have already been found
findall(Template, Generator, Answers, SoFar) :-
'$findall'(Template, Generator, SoFar, Answers).
% starts by calling the generator,
% and recording the answers
'$findall'(Template, Generator, SoFar, Answers) :-
nb:nb_queue(Ref),
(
'$execute'(Generator),
nb:nb_queue_enqueue(Ref, Template),
fail
;
nb:nb_queue_close(Ref, Answers, SoFar)
).
% findall_with_key is very similar to findall, but uses the SICStus
% algorithm to guarantee that variables will have the same names.
%
'$findall_with_common_vars'(Template, Generator, Answers) :-
nb:nb_queue(Ref),
(
'$execute'(Generator),
nb:nb_queue_enqueue(Ref, Template),
fail
;
nb:nb_queue_close(Ref, Answers, []),
'$collect_with_common_vars'(Answers, _)
).
'$collect_with_common_vars'([], _).
'$collect_with_common_vars'([Key-_|Answers], VarList) :-
'$variables_in_term'(Key, _, VarList),
'$collect_with_common_vars'(Answers, VarList).
% This is the setof predicate
setof(Template, Generator, Set) :-
( '$partial_list_or_list'(Set) ->
true
;
'$do_error'(type_error(list,Set), setof(Template, Generator, Set))
),
'$bagof'(Template, Generator, Bag),
'$sort'(Bag, Set).
% And this is bagof
% Either we have excess of variables
% and we need to find the solutions for each instantiation
% of these variables
bagof(Template, Generator, Bag) :-
( '$partial_list_or_list'(Bag) ->
true
;
'$do_error'(type_error(list,Bag), bagof(Template, Generator, Bag))
),
'$bagof'(Template, Generator, Bag).
'$bagof'(Template, Generator, Bag) :-
'$variables_in_term'(Template, [], TemplateV),
'$excess_vars'(Generator, StrippedGenerator, TemplateV, [], FreeVars),
( FreeVars \== [] ->
'$variables_in_term'(FreeVars, [], LFreeVars),
Key =.. ['$'|LFreeVars],
'$findall_with_common_vars'(Key-Template, StrippedGenerator, Bags0),
'$keysort'(Bags0, Bags),
'$pick'(Bags, Key, Bag)
;
'$findall'(Template, StrippedGenerator, [], Bag0),
Bag0 \== [],
Bag = Bag0
).
% picks a solution attending to the free variables
'$pick'([K-X|Bags], Key, Bag) :-
'$parade'(Bags, K, Bag1, Bags1),
'$decide'(Bags1, [X|Bag1], K, Key, Bag).
'$parade'([K-X|L1], Key, [X|B], L) :- K == Key, !,
'$parade'(L1, Key, B, L).
'$parade'(L, _, [], L).
%
% The first argument to decide gives if solutions still left;
% The second gives the solution currently found;
% The third gives the free variables that are supposed to be bound;
% The fourth gives the free variables being currently used.
% The fifth outputs the current solution.
%
'$decide'([], Bag, Key0, Key, Bag) :- !,
Key0=Key.
'$decide'(_, Bag, Key, Key, Bag).
'$decide'(Bags, _, _, Key, Bag) :-
'$pick'(Bags, Key, Bag).
%
% Detect free variables in the source term
%
'$excess_vars'(V, V, X, L0, L) :-
var(V),
!,
( '$doesnt_include'(X, V) -> L = [V|L0]
; L = L0
).
'$excess_vars'(A, A, _, L, L) :-
atomic(A), !.
'$excess_vars'(X^P, NP, Y, L0, L) :- !,
'$variables_in_term'(X+Y, [], NY),
'$excess_vars'(P, NP, NY, L0, L).
'$excess_vars'(setof(X,P,S), setof(X,P,S), Y, L0, L) :- !,
'$variables_in_term'(X+Y, [], NY),
'$excess_vars'((P,S), _, NY, L0, L).
'$excess_vars'(bagof(X,P,S), bagof(X,P,S), Y, L0, L) :- !,
'$variables_in_term'(X+Y, [], NY),
'$excess_vars'((P,S), _, NY, L0, L).
'$excess_vars'(findall(X,P,S), findall(X,P,S), Y, L0, L) :- !,
'$excess_vars'(S, _, Y, L0, L).
'$excess_vars'(findall(X,P,S0,S), findall(X,P,S0,S), Y, L0, L) :- !,
'$excess_vars'(S, _, Y, L0, L).
'$excess_vars'(\+G, \+G, _, L0, LF) :- !,
L0 = LF.
'$excess_vars'(_:G1, M:NG, Y, L0, LF) :- nonvar(G1), G1 = M:G, !,
'$excess_vars'(G, NG, Y, L0, LF).
'$excess_vars'(M:G, M:NG, Y, L0, LF) :- !,
'$excess_vars'(G, NG, Y, L0, LF).
'$excess_vars'(T, T, X, L0, L) :-
T =.. [_|LArgs],
'$recurse_for_excess_vars'(LArgs, X, L0, L).
'$recurse_for_excess_vars'([], _, L, L).
'$recurse_for_excess_vars'([T1|LArgs], X, L0, L) :-
'$excess_vars'(T1, _, X, L0, L1),
'$recurse_for_excess_vars'(LArgs, X, L1, L).
'$doesnt_include'([], _).
'$doesnt_include'([Y|L], X) :-
Y \== X,
'$doesnt_include'(L, X).
% as an alternative to setof you can use the predicate all(Term,Goal,Solutions)
% But this version of all does not allow for repeated answers
% if you want them use findall
all(T,G same X,S) :- !, all(T same X,G,Sx), '$$produce'(Sx,S,X).
all(T,G,S) :-
'$init_db_queue'(Ref),
( '$catch'(Error,'$clean_findall'(Ref,Error),_),
'$execute'(G),
'$db_enqueue'(Ref, T),
fail
;
'$$set'(S,Ref)
).
% $$set does its best to preserve space
'$$set'(S,R) :-
'$$build'(S0,_,R),
S0 = [_|_],
S = S0.
'$$build'(Ns,S0,R) :- '$db_dequeue'(R,X), !,
'$$build2'(Ns,S0,R,X).
'$$build'([],_,_).
'$$build2'([X|Ns],Hash,R,X) :-
'$$new'(Hash,X), !,
'$$build'(Ns,Hash,R).
'$$build2'(Ns,Hash,R,_) :-
'$$build'(Ns,Hash,R).
'$$new'(V,El) :- var(V), !, V = n(_,El,_).
'$$new'(n(R,El0,L),El) :-
compare(C,El0,El),
'$$new'(C,R,L,El).
'$$new'(=,_,_,_) :- !, fail.
'$$new'(<,R,_,El) :- '$$new'(R,El).
'$$new'(>,_,L,El) :- '$$new'(L,El).
'$$produce'([T1 same X1|Tn],S,X) :- '$$split'(Tn,T1,X1,S1,S2),
( S=[T1|S1], X=X1;
!, produce(S2,S,X) ).
'$$split'([],_,_,[],[]).
'$$split'([T same X|Tn],T,X,S1,S2) :- '$$split'(Tn,T,X,S1,S2).
'$$split'([T1 same X|Tn],T,X,[T1|S1],S2) :- '$$split'(Tn,T,X,S1,S2).
'$$split'([T1|Tn],T,X,S1,[T1|S2]) :- '$$split'(Tn,T,X,S1,S2).
'$partial_list_or_list'(V) :- var(V), !.
'$partial_list_or_list'([]) :- !.
'$partial_list_or_list'([_|B]) :- !,
'$partial_list_or_list'(B).
yap-6.2.2/pl/signals.yap 000644 000765 000024 00000017231 11503477665 015060 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: signals.pl *
* Last rev: *
* mods: *
* comments: signal handling in YAP *
* *
*************************************************************************/
:- meta_predicate on_signal(+,?,:), alarm(+,:,-).
'$creep'(G) :-
% get the first signal from the mask
'$first_signal'(Sig), !,
% process it
'$do_signal'(Sig, G).
'$creep'([M|G]) :-
% noise, just go on with our life.
'$execute'(M:G).
'$do_signal'(sig_wake_up, G) :-
'$awoken_goals'(LG),
% if more signals alive, set creep flag
'$continue_signals',
'$wake_up_goal'(G, LG).
% never creep on entering system mode!!!
% don't creep on meta-call.
'$do_signal'(sig_creep, [M|G]) :-
'$creep_allowed', !,
(
( G = '$notrace'(G0) ; G = '$oncenotrace'(G0) ; G = '$execute0'(G0,M) ; '$system_module'(M), G = G0 )
->
(
'$execute_nonstop'(G0,M),
'$signal_creep'
;
'$signal_creep',
fail
)
;
'$start_creep'([M|G])
).
%
'$do_signal'(sig_creep, [M|G]) :-
( G = '$notrace'(G0) ; G = '$oncenotrace'(G0) ; G = '$execute0'(G0,M) ; '$system_module'(M), G = G0 ),
!,
(
'$execute_nonstop'(G0,M),
'$signal_creep'
;
'$signal_creep',
fail
).
%
'$do_signal'(sig_creep, [M|G]) :-
'$signal_creep',
'$execute_nonstop'(G,M).
'$do_signal'(sig_delay_creep, [M|G]) :-
'$execute'(M:G),
'$creep'.
'$do_signal'(sig_iti, [M|G]) :-
'$thread_gfetch'(Goal),
% if more signals alive, set creep flag
'$continue_signals',
'$current_module'(M0),
'$execute0'(Goal,M0),
'$execute'(M:G).
'$do_signal'(sig_trace, [M|G]) :-
'$continue_signals',
trace,
'$execute'(M:G).
'$do_signal'(sig_debug, [M|G]) :-
'$continue_signals',
debug,
'$execute'(M:G).
'$do_signal'(sig_break, [M|G]) :-
'$continue_signals',
break,
'$execute0'(G,M).
'$do_signal'(sig_statistics, [M|G]) :-
'$continue_signals',
statistics,
'$execute0'(G,M).
% the next one should never be called...
'$do_signal'(fail, [_|_]) :-
fail.
'$do_signal'(sig_stack_dump, [M|G]) :-
'$continue_signals',
'$stack_dump',
'$execute0'(G,M).
% Unix signals
'$do_signal'(sig_alarm, G) :-
'$signal_handler'(sig_alarm, G).
'$do_signal'(sig_vtalarm, G) :-
'$signal_handler'(sig_vtalarm, G).
'$do_signal'(sig_hup, G) :-
'$signal_handler'(sig_hup, G).
'$do_signal'(sig_usr1, G) :-
'$signal_handler'(sig_usr1, G).
'$do_signal'(sig_usr2, G) :-
'$signal_handler'(sig_usr2, G).
'$do_signal'(sig_pipe, G) :-
'$signal_handler'(sig_pipe, G).
'$signal_handler'(Sig, [M|G]) :-
'$signal_do'(Sig, Goal),
% if more signals alive, set creep flag
'$continue_signals',
'$current_module'(M0),
'$execute0'((Goal,M:G),M0).
% '$execute0' should be ignored.
'$start_creep'([_|'$execute0'(G,M)]) :-
!,
'$start_creep'([M|G]).
% '$call'() is a complicated thing
'$start_creep'([M0|'$call'(G, CP, G0, M)]) :-
!,
'$creep',
'$execute_nonstop'('$call'(G, CP, G0, M),M0).
% donotrace: means do not trace! So,
% ignore and then put creep back for the continuation.
'$start_creep'([M0|'$notrace'(G)]) :-
!,
(
CP0 is '$last_choice_pt',
'$execute_nonstop'(G,M0),
CP1 is '$last_choice_pt',
% exit port: creep
'$creep',
(
% if deterministic just creep all you want.
CP0 = CP1 ->
!
;
% extra disjunction protects reentry into usergoal
(
% cannot cut here
true
;
% be sure to disable creep on redo port
'$disable_creep',
fail
)
)
;
% put it back again on fail
'$creep',
fail
).
'$start_creep'([M0|'$oncenotrace'(G)]) :-
!,
('$execute_nonstop'(G,M0),
CP1 is '$last_choice_pt',
% exit port: creep
'$creep',
!
;
% put it back again on fail
'$creep',
fail
).
% do not debug if we are not in debug mode.
'$start_creep'([Mod|G]) :-
'$debug_on'(DBON), DBON = false, !,
'$execute_nonstop'(G,Mod).
'$start_creep'([Mod|G]) :-
nb_getval('$system_mode',on), !,
'$execute_nonstop'(G,Mod).
% notice that the last signal to be processed must always be creep
'$start_creep'([_|'$cut_by'(CP)]) :- !,
'$$cut_by'(CP),
'$creep'.
'$start_creep'([_|true]) :- !,
'$creep'.
'$start_creep'([Mod|G]) :-
'$hidden_predicate'(G,Mod), !,
'$execute_nonstop'(G,Mod),
'$creep'.
% do not debug if we are zipping through.
'$start_creep'([Mod|G]) :-
nb_getval('$debug_run',Run),
Run \= off,
'$zip'(-1, G, Mod), !,
'$signal_creep',
'$execute_goal'(G, Mod).
'$start_creep'([Mod|G]) :-
CP is '$last_choice_pt',
'$do_spy'(G, Mod, CP, no).
'$execute_goal'(G, Mod) :-
(
'$is_metapredicate'(G, Mod)
->
'$meta_call'(G,Mod)
;
'$execute_nonstop'(G,Mod)
).
'$signal_do'(Sig, Goal) :-
recorded('$signal_handler', action(Sig,Goal), _), !.
'$signal_do'(Sig, Goal) :-
'$signal_def'(Sig, Goal).
% reconsult init files.
'$signal_def'(sig_hup, (( exists('~/.yaprc') -> [-'~/.yaprc'] ; true ),
( exists('~/.prologrc') -> [-'~/.prologrc'] ; true ),
( exists('~/prolog.ini') -> [-'~/prolog.ini'] ; true ))).
% die on signal default.
'$signal_def'(sig_usr1, throw(error(signal(usr1,[]),true))).
'$signal_def'(sig_usr2, throw(error(signal(usr2,[]),true))).
'$signal_def'(sig_pipe, throw(error(signal(pipe,[]),true))).
% ignore sig_alarm by default
'$signal_def'(sig_alarm, true).
'$signal'(sig_hup).
'$signal'(sig_usr1).
'$signal'(sig_usr2).
'$signal'(sig_pipe).
'$signal'(sig_alarm).
'$signal'(sig_vtalarm).
on_signal(Signal,OldAction,NewAction) :-
var(Signal), !,
(nonvar(OldAction) -> throw(error(instantiation_error,on_signal/3)) ; true),
'$signal'(Signal),
on_signal(Signal, OldAction, NewAction).
on_signal(Signal,OldAction,default) :-
'$reset_signal'(Signal, OldAction).
on_signal(Signal,OldAction,Action) :-
var(Action), !,
throw(error(system_error,'Somehow the meta_predicate declarations of on_signal are subverted!')).
on_signal(Signal,OldAction,Action) :-
Action = (_:Goal),
var(Goal), !,
'$check_signal'(Signal, OldAction),
Goal = OldAction.
on_signal(Signal,OldAction,Action) :-
'$reset_signal'(Signal, OldAction),
% 13211-2 speaks only about callable
( Action = M:Goal -> true ; throw(error(type_error(callable,Action),on_signal/3)) ),
% the following disagrees with 13211-2:6.7.1.4 which disagrees with 13211-1:7.12.2a
% but the following agrees with 13211-1:7.12.2a
( nonvar(M) -> true ; throw(error(instantiation_error,on_signal/3)) ),
( atom(M) -> true ; throw(error(type_error(callable,Action),on_signal/3)) ),
( nonvar(Goal) -> true ; throw(error(instantiation_error,on_signal/3)) ),
recordz('$signal_handler', action(Signal,Action), _).
'$reset_signal'(Signal, OldAction) :-
recorded('$signal_handler', action(Signal,OldAction), Ref), !,
erase(Ref).
'$reset_signal'(_, default).
'$check_signal'(Signal, OldAction) :-
recorded('$signal_handler', action(Signal,OldAction), _), !.
'$check_signal'(_, default).
alarm(Interval, Goal, Left) :-
Interval == 0, !,
'$alarm'(0, 0, Left0, _),
on_signal(sig_alarm, _, Goal),
Left = Left0.
alarm(Interval, Goal, Left) :-
integer(Interval), !,
on_signal(sig_alarm, _, Goal),
'$alarm'(Interval, 0, Left, _).
alarm(Number, Goal, Left) :-
float(Number), !,
Secs is integer(Number),
USecs is integer((Number-Secs)*1000000) mod 1000000,
on_signal(sig_alarm, _, Goal),
'$alarm'(Interval, 0, Left, _).
alarm(Interval.USecs, Goal, Left.LUSecs) :-
on_signal(sig_alarm, _, Goal),
'$alarm'(Interval, USecs, Left, LUSecs).
raise_exception(Ball) :- throw(Ball).
on_exception(Pat, G, H) :- catch(G, Pat, H).
read_sig :-
recorded('$signal_handler',X,_),
writeq(X),nl,
fail.
read_sig.
yap-6.2.2/pl/sockets.yap 000644 000765 000024 00000005451 11457004725 015063 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: sockets.yap *
* Last rev: *
* mods: *
* comments: Socket predicates *
* *
*************************************************************************/
socket(S,D) :-
socket(S, 'SOCK_STREAM', 0, D).
socket_accept(S,F) :-
socket_accept(S, _, F).
socket_select(Socks, OutSocks, TimeOut, Streams, OutStreams) :-
'$check_list_for_sockets'(Socks, socket_select(Socks, OutSocks, TimeOut, Streams, OutStreams)),
'$check_list_for_sockets'(Streams, socket_select(Socks, OutSocks, TimeOut, Streams, OutStreams)),
'$select_cp_fds'(Socks, Streams, Fds),
'$check_select_time'(TimeOut, Sec, USec, socket_select(Socks, OutSocks, TimeOut, Streams, OutStreams)),
'$socket_select'(Fds, Sec, USec, NFds),
'$cp_socket_fds'(Socks, NFds, OutSocks, NFdsS),
'$cp_stream_fds'(Streams, NFdsS, OutStreams).
/* check whether a list of options is valid */
'$check_list_for_sockets'(V,G) :- var(V), !,
'$do_error'(instantiation_error,G).
'$check_list_for_sockets'([],_) :- !.
'$check_list_for_sockets'([_|T],G) :- !,
'$check_list_for_sockets'(T,G).
'$check_list_for_sockets'(T,G) :-
'$do_error'(type_error(list,T),G).
'$select_cp_fds'([], Fds, Fds).
'$select_cp_fds'([_-Fd|L], Fds0, [Fd|Fds]) :-
'$select_cp_fds'(L, Fds0, Fds).
'$check_select_time'(V, _, _, Goal) :-
var(V), !,
'$do_error'(instantiation_error,Goal).
'$check_select_time'(off, -1, -1, _).
'$check_select_time'(Sec0:USec0, Sec, USec, _) :-
Sec is Sec0,
USec is USec0,
Sec >= 0, USec >= 0.
'$cp_socket_fds'([], Fds, [], Fds).
'$cp_socket_fds'([_|Scks], [[]|Fds], Out, StrFds) :- !,
'$cp_socket_fds'(Scks, Fds, Out, StrFds).
'$cp_socket_fds'([T-Socket|Scks], [Socket|Fds], [T-connection(Client,Stream)|Out], StrFds) :-
socket_accept(Socket, Client, Stream),
'$cp_socket_fds'(Scks, Fds, Out, StrFds).
'$cp_stream_fds'([], _, []).
'$cp_stream_fds'([_|Strs], [[]|Fds], Out) :- !,
'$cp_stream_fds'(Strs, Fds, Out).
'$cp_stream_fds'([Stream|Strs], [Stream|Fds], [Stream|Out]) :-
'$cp_stream_fds'(Strs, Fds, Out).
socket_buffering(Sock, Flag, InSize, OutSize) :-
var(OutSize), OutSize \= InSize, !,
'$do_error'(instantiation_error,socket_buffering(Sock, Flag, InSize, OutSize)).
socket_buffering(Sock, Flag, InSize, OutSize) :-
'$convert_sock_buff'(OutSize, OutNumb),
'$socket_buffering'(Sock, Flag, InNumb, OutNumb),
'$convert_sock_buff'(InSize, InNumb).
'$convert_sock_buff'(V, V) :- var(V), !.
'$convert_sock_buff'(unbuf, 1) :- !.
'$convert_sock_buff'(fullbuf, _).
yap-6.2.2/pl/sort.yap 000644 000765 000024 00000004717 11457004725 014403 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: sort.pl *
* Last rev: *
* mods: *
* comments: sorting in Prolog *
* *
*************************************************************************/
/* The three sorting routines are all variations of merge-sort, done by
bisecting the list, sorting the nearly equal halves, and merging the
results. The half-lists aren't actually constructed, the number of
elements is counted instead (which is why 'length' is in this file).
*/
% length of a list.
length(L,M) :- var(M), !, '$$_length1'(L,0,M).
length(L,M) :- '$$_length2'(M,L).
'$$_length1'([], M, M).
'$$_length1'([_|L], N, O) :-
M is N + 1,
'$$_length1'(L, M, O).
'$$_length2'(N, L) :-
( N =:= 0
->
L = []
;
N > 0,
N1 is N - 1,
L = [_|L1],
'$$_length2'(N1, L1)
).
sort(L,O) :-
'$sort'(L,O).
msort(L,O) :-
'$msort'(L,O).
keysort(L,O) :-
'$keysort'(L,O).
:- meta_predicate prolog:predsort(3,+,-).
%% predsort(:Compare, +List, -Sorted) is det.
%
% Sorts similar to sort/2, but determines the order of two terms
% by calling Compare(-Delta, +E1, +E2). This call must unify
% Delta with one of <, > or =. If built-in predicate compare/3 is
% used, the result is the same as sort/2. See also keysort/2.
predsort(P, L, R) :-
length(L, N),
predsort(P, N, L, _, R1), !,
R = R1.
predsort(P, 2, [X1, X2|L], L, R) :- !,
call(P, Delta, X1, X2),
sort2(Delta, X1, X2, R).
predsort(_, 1, [X|L], L, [X]) :- !.
predsort(_, 0, L, L, []) :- !.
predsort(P, N, L1, L3, R) :-
N1 is N // 2,
plus(N1, N2, N),
predsort(P, N1, L1, L2, R1),
predsort(P, N2, L2, L3, R2),
predmerge(P, R1, R2, R).
sort2(<, X1, X2, [X1, X2]).
sort2(=, X1, _, [X1]).
sort2(>, X1, X2, [X2, X1]).
predmerge(_, [], R, R) :- !.
predmerge(_, R, [], R) :- !.
predmerge(P, [H1|T1], [H2|T2], Result) :-
call(P, Delta, H1, H2),
predmerge(Delta, P, H1, H2, T1, T2, Result).
predmerge(>, P, H1, H2, T1, T2, [H2|R]) :-
predmerge(P, [H1|T1], T2, R).
predmerge(=, P, H1, _, T1, T2, [H1|R]) :-
predmerge(P, T1, T2, R).
predmerge(<, P, H1, H2, T1, T2, [H1|R]) :-
predmerge(P, T1, [H2|T2], R).
yap-6.2.2/pl/statistics.yap 000644 000765 000024 00000014761 11457004725 015606 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: statistics.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: statistics on Prolog status *
* *
*************************************************************************/
%%% User interface for statistics
statistics :-
'$runtime'(Runtime,_),
'$cputime'(CPUtime,_),
'$systime'(SYStime,_),
'$walltime'(Walltime,_),
'$statistics_heap_info'(HpSpa, HpInUse),
'$statistics_heap_max'(HpMax),
'$statistics_trail_info'(TrlSpa, TrlInUse),
'$statistics_trail_max'(TrlMax),
'$statistics_stacks_info'(StkSpa, GlobInU, LocInU),
'$statistics_global_max'(GlobMax),
'$statistics_local_max'(LocMax),
'$inform_heap_overflows'(NOfHO,TotHOTime),
'$inform_stack_overflows'(NOfSO,TotSOTime),
'$inform_trail_overflows'(NOfTO,TotTOTime),
'$inform_gc'(NOfGC,TotGCTime,TotGCSize),
'$inform_agc'(NOfAGC,TotAGCTime,TotAGCSize),
'$statistics'(Runtime,CPUtime,SYStime,Walltime,HpSpa,HpInUse,HpMax,TrlSpa, TrlInUse,TrlMax,StkSpa, GlobInU, LocInU,GlobMax,LocMax,NOfHO,TotHOTime,NOfSO,TotSOTime,NOfTO,TotTOTime,NOfGC,TotGCTime,TotGCSize,NOfAGC,TotAGCTime,TotAGCSize).
'$statistics'(Runtime,CPUtime,SYStime,Walltime,HpSpa,HpInUse,HpMax,TrlSpa, TrlInUse,_TrlMax,StkSpa, GlobInU, LocInU,GlobMax,LocMax,NOfHO,TotHOTime,NOfSO,TotSOTime,NOfTO,TotTOTime,NOfGC,TotGCTime,TotGCSize,NOfAGC,TotAGCTime,TotAGCSize) :-
TotalMemory is HpSpa+StkSpa+TrlSpa,
format(user_error,'memory (total)~t~d bytes~35+~n', [TotalMemory]),
format(user_error,' program space~t~d bytes~35+', [HpSpa]),
format(user_error,':~t ~d in use~19+', [HpInUse]),
HpFree is HpSpa-HpInUse,
format(user_error,',~t ~d free~19+~n', [HpFree]),
format(user_error,'~t ~d max~73+~n', [HpMax]),
format(user_error,' stack space~t~d bytes~35+', [StkSpa]),
StackInUse is GlobInU+LocInU,
format(user_error,':~t ~d in use~19+', [StackInUse]),
StackFree is StkSpa-StackInUse,
format(user_error,',~t ~d free~19+~n', [StackFree]),
format(user_error,' global stack:~t~35+', []),
format(user_error,' ~t ~d in use~19+', [GlobInU]),
format(user_error,',~t ~d max~19+~n', [GlobMax]),
format(user_error,' local stack:~t~35+', []),
format(user_error,' ~t ~d in use~19+', [LocInU]),
format(user_error,',~t ~d max~19+~n', [LocMax]),
format(user_error,' trail stack~t~d bytes~35+', [TrlSpa]),
format(user_error,':~t ~d in use~19+', [TrlInUse]),
TrlFree is TrlSpa-TrlInUse,
format(user_error,',~t ~d free~19+~n', [TrlFree]),
OvfTime is (TotHOTime+TotSOTime+TotTOTime)/1000,
format(user_error,'~n~t~3f~12+ sec. for ~w code, ~w stack, and ~w trail space overflows~n',
[OvfTime,NOfHO,NOfSO,NOfTO]),
TotGCTimeF is float(TotGCTime)/1000,
format(user_error,'~t~3f~12+ sec. for ~w garbage collections which collected ~d bytes~n',
[TotGCTimeF,NOfGC,TotGCSize]),
TotAGCTimeF is float(TotAGCTime)/1000,
format(user_error,'~t~3f~12+ sec. for ~w atom garbage collections which collected ~d bytes~n',
[TotAGCTimeF,NOfAGC,TotAGCSize]),
RTime is float(Runtime)/1000,
format(user_error,'~t~3f~12+ sec. runtime~n', [RTime]),
CPUTime is float(CPUtime)/1000,
format(user_error,'~t~3f~12+ sec. cputime~n', [CPUTime]),
SYSTime is float(SYStime)/1000,
format(user_error,'~t~3f~12+ sec. systime~n', [SYSTime]),
WallTime is float(Walltime)/1000,
format(user_error,'~t~3f~12+ sec. elapsed time~n~n', [WallTime]),
fail.
'$statistics'(_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_).
statistics(runtime,[T,L]) :-
'$runtime'(T,L).
statistics(cputime,[T,L]) :-
'$cputime'(T,L).
statistics(walltime,[T,L]) :-
'$walltime'(T,L).
statistics(threads,NT) :-
'$nof_threads'(NT).
statistics(threads_created,TC) :-
'$nof_threads_created'(TC).
statistics(thread_cputime,TR) :-
'$thread_runtime'(TR).
%statistics(core,[_]).
%statistics(memory,[_]).
statistics(heap,[Hp,HpF]) :-
'$statistics_heap_info'(HpM, Hp),
HpF is HpM-Hp.
statistics(program,Info) :-
statistics(heap,Info).
statistics(global_stack,[GlobInU,GlobFree]) :-
'$statistics_stacks_info'(StkSpa, GlobInU, LocInU),
GlobFree is StkSpa-GlobInU-LocInU.
statistics(local_stack,[LocInU,LocFree]) :-
'$statistics_stacks_info'(StkSpa, GlobInU, LocInU),
LocFree is StkSpa-GlobInU-LocInU.
statistics(trail,[TrlInUse,TrlFree]) :-
'$statistics_trail_info'(TrlSpa, TrlInUse),
TrlFree is TrlSpa-TrlInUse.
statistics(garbage_collection,[NOfGC,TotGCSize,TotGCTime]) :-
'$inform_gc'(NOfGC,TotGCTime,TotGCSize).
statistics(stack_shifts,[NOfHO,NOfSO,NOfTO]) :-
'$inform_heap_overflows'(NOfHO,_),
'$inform_stack_overflows'(NOfSO,_),
'$inform_trail_overflows'(NOfTO,_).
statistics(atoms,[NOf,SizeOf]) :-
'$statistics_atom_info'(NOf,SizeOf),
'$inform_stack_overflows'(NOfSO,_),
'$inform_trail_overflows'(NOfTO,_).
statistics(static_code,[ClauseSize, IndexSize, TreeIndexSize, ExtIndexSize, SWIndexSize]) :-
'$statistics_db_size'(ClauseSize, TreeIndexSize, ExtIndexSize, SWIndexSize),
IndexSize is TreeIndexSize+ ExtIndexSize+ SWIndexSize.
statistics(dynamic_code,[ClauseSize,IndexSize, TreeIndexSize, CPIndexSize, ExtIndexSize, SWIndexSize]) :-
'$statistics_lu_db_size'(ClauseSize, TreeIndexSize, CPIndexSize, ExtIndexSize, SWIndexSize),
IndexSize is TreeIndexSize+CPIndexSize+ ExtIndexSize+ SWIndexSize.
key_statistics(Key, NOfEntries, TotalSize) :-
key_statistics(Key, NOfEntries, ClSize, IndxSize),
TotalSize is ClSize+IndxSize.
%% time(:Goal)
%
% Time the execution of Goal. Possible choice-points of Goal are removed.
% Based on the SWI-Prolog definition minus reporting the number of inferences,
% which YAP does not currently supports
:- meta_predicate time(:).
time(Goal) :-
var(Goal),
'$do_error'(instantiation_error,time(Goal)).
time(_:Goal) :-
var(Goal),
'$do_error'(instantiation_error,time(Goal)).
time(Goal) :- \+ callable(Goal), !,
'$do_error'(type_error(callable,Goal),time(Goal)).
time(Goal) :-
statistics(walltime, _),
statistics(cputime, _),
( catch(Goal, E, true)
-> Result = yes
; Result = no
),
statistics(cputime, [_, Time]),
statistics(walltime, [_, Wall]),
( Time =:= 0
-> CPU = 'Inf'
; CPU is truncate(Time/Wall*100)
),
TimeSecs is Time/1000,
WallSecs is Wall/1000,
format(user_error,'% ~3f CPU in ~3f seconds (~|~t~w~3+% CPU)~n', [TimeSecs, WallSecs, CPU]),
( nonvar(E)
-> throw(E)
; Result == yes
).
yap-6.2.2/pl/strict_iso.yap 000644 000765 000024 00000013643 11457004725 015574 0 ustar 00vsc staff 000000 000000 '$iso_check_goal'(V,G) :-
var(V), !,
'$do_error'(instantiation_error,call(G)).
'$iso_check_goal'(V,G) :-
number(V), !,
'$do_error'(type_error(callable,V),G).
'$iso_check_goal'(_:G,G0) :- !,
'$iso_check_goal'(G,G0).
'$iso_check_goal'((G1,G2),G0) :- !,
'$iso_check_a_goal'(G1,(G1,G2),G0),
'$iso_check_a_goal'(G2,(G1,G2),G0).
'$iso_check_goal'((G1;G2),G0) :- !,
'$iso_check_a_goal'(G1,(G1;G2),G0),
'$iso_check_a_goal'(G2,(G1;G2),G0).
'$iso_check_goal'((G1->G2),G0) :- !,
'$iso_check_a_goal'(G1,(G1->G2),G0),
'$iso_check_a_goal'(G2,(G1->G2),G0).
'$iso_check_goal'(!,_) :- !.
'$iso_check_goal'((G1|G2),G0) :-
'$access_yap_flags'(9,1), !,
'$do_error'(domain_error(builtin_procedure,(G1|G2)), call(G0)).
'$iso_check_goal'((G1|G2),G0) :- !,
'$iso_check_a_goal'(G1,(G1|G2),G0),
'$iso_check_a_goal'(G2,(G1|G2),G0).
'$iso_check_goal'(G,G0) :-
'$access_yap_flags'(9,1),
'$system_predicate'(G,0),
(
'$iso_builtin'(G)
->
true
;
'$do_error'(domain_error(builtin_procedure,G), call(G0))
).
'$iso_check_goal'(_,_).
'$iso_check_a_goal'(V,_,G) :-
var(V), !,
'$do_error'(instantiation_error,call(G)).
'$iso_check_a_goal'(V,E,G) :-
number(V), !,
'$do_error'(type_error(callable,E),call(G)).
'$iso_check_a_goal'(_:G,E,G0) :- !,
'$iso_check_a_goal'(G,E,G0).
'$iso_check_a_goal'((G1,G2),E,G0) :- !,
'$iso_check_a_goal'(G1,E,G0),
'$iso_check_a_goal'(G2,E,G0).
'$iso_check_a_goal'((G1;G2),E,G0) :- !,
'$iso_check_a_goal'(G1,E,G0),
'$iso_check_a_goal'(G2,E,G0).
'$iso_check_a_goal'((G1->G2),E,G0) :- !,
'$iso_check_a_goal'(G1,E,G0),
'$iso_check_a_goal'(G2,E,G0).
'$iso_check_a_goal'(!,_,_) :- !.
'$iso_check_a_goal'((_|_),E,G0) :-
'$access_yap_flags'(9,1), !,
'$do_error'(domain_error(builtin_procedure,E), call(G0)).
'$iso_check_a_goal'((_|_),_,_) :- !.
'$iso_check_a_goal'(G,_,G0) :-
'$access_yap_flags'(9,1),
'$system_predicate'(G,0),
(
'$iso_builtin'(G)
->
true
;
'$do_error'(domain_error(builtin_procedure,G), call(G0))
).
'$iso_check_a_goal'(_,_,_).
'$check_iso_strict_clause'((_:-B)) :- !,
'$check_iso_strict_body'(B).
'$check_iso_strict_clause'(_).
'$check_iso_strict_body'((B1,B2)) :- !,
'$check_iso_strict_body'(B1),
'$check_iso_strict_body'(B2).
'$check_iso_strict_body'((B1;B2)) :- !,
'$check_iso_strict_body'(B1),
'$check_iso_strict_body'(B2).
'$check_iso_strict_body'((B1->B2)) :- !,
'$check_iso_strict_body'(B1),
'$check_iso_strict_body'(B2).
'$check_iso_strict_body'(B) :-
'$check_iso_strict_goal'(B).
'$check_iso_strict_goal'(G) :-
'$system_predicate'(G,0), !,
'$check_iso_system_goal'(G).
'$check_iso_strict_goal'(_).
'$check_iso_system_goal'(G) :-
'$iso_builtin'(G), !.
'$check_iso_system_goal'(G) :-
'$do_error'(domain_error(builtin_procedure,G), G).
'$iso_builtin'(abolish(_)).
'$iso_builtin'(arg(_,_,_)).
'$iso_builtin'(_=:=_).
'$iso_builtin'(_=\=_).
'$iso_builtin'(_>_).
'$iso_builtin'(_>=_).
'$iso_builtin'(_<_).
'$iso_builtin'(_=<_).
'$iso_builtin'(asserta(_)).
'$iso_builtin'(assertz(_)).
'$iso_builtin'(at_end_of_stream).
'$iso_builtin'(at_end_of_stream(_)).
'$iso_builtin'(atom(_)).
'$iso_builtin'(atom_chars(_,_)).
'$iso_builtin'(atom_codes(_,_)).
'$iso_builtin'(atom_concat(_,_,_)).
'$iso_builtin'(atom_length(_,_)).
'$iso_builtin'(atomic(_)).
'$iso_builtin'(bagof(_,_,_)).
'$iso_builtin'(call(_)).
'$iso_builtin'(catch(_,_,_)).
'$iso_builtin'(char_code(_,_)).
'$iso_builtin'(char_conversion(_,_)).
'$iso_builtin'(clause(_,_)).
'$iso_builtin'(close(_)).
'$iso_builtin'(close(_,_)).
'$iso_builtin'(compound(_)).
'$iso_builtin'((_,_)).
'$iso_builtin'(copy_term(_,_)).
'$iso_builtin'(current_char_conversion(_,_)).
'$iso_builtin'(current_input(_)).
'$iso_builtin'(current_op(_,_,_)).
'$iso_builtin'(current_output(_)).
'$iso_builtin'(current_predicate(_)).
'$iso_builtin'(current_prolog_flag(_,_)).
'$iso_builtin'(!).
'$iso_builtin'((_;_)).
'$iso_builtin'(fail).
'$iso_builtin'(findall(_,_,_)).
'$iso_builtin'(float(_)).
'$iso_builtin'(abort).
'$iso_builtin'(flush_output).
'$iso_builtin'(flush_output(_)).
'$iso_builtin'(functor(_,_,_)).
'$iso_builtin'(get_byte(_)).
'$iso_builtin'(get_byte(_,_)).
'$iso_builtin'(get_char(_)).
'$iso_builtin'(get_char(_,_)).
'$iso_builtin'(get_code(_)).
'$iso_builtin'(get_code(_,_)).
'$iso_builtin'(halt).
'$iso_builtin'(halt(_)).
'$iso_builtin'((_->_)).
'$iso_builtin'(integer(_)).
'$iso_builtin'(_ is _).
'$iso_builtin'(nl).
'$iso_builtin'(nl(_)).
'$iso_builtin'(nonvar(_)).
'$iso_builtin'(\+(_)).
'$iso_builtin'(number(_)).
'$iso_builtin'(number_chars(_,_)).
'$iso_builtin'(number_codes(_,_)).
'$iso_builtin'(once(_)).
'$iso_builtin'(op(_,_,_)).
'$iso_builtin'(open(_,_,_)).
'$iso_builtin'(open(_,_,_,_)).
'$iso_builtin'(peek_byte(_)).
'$iso_builtin'(peek_byte(_,_)).
'$iso_builtin'(peek_char(_)).
'$iso_builtin'(peek_char(_,_)).
'$iso_builtin'(peek_code(_)).
'$iso_builtin'(peek_code(_,_)).
'$iso_builtin'(put_byte(_)).
'$iso_builtin'(put_byte(_,_)).
'$iso_builtin'(put_char(_)).
'$iso_builtin'(put_char(_,_)).
'$iso_builtin'(put_code(_)).
'$iso_builtin'(put_code(_,_)).
'$iso_builtin'(read(_)).
'$iso_builtin'(read(_,_)).
'$iso_builtin'(read_term(_,_)).
'$iso_builtin'(read_term(_,_,_)).
'$iso_builtin'(repeat).
'$iso_builtin'(retract(_)).
'$iso_builtin'(set_input(_)).
'$iso_builtin'(set_output(_)).
'$iso_builtin'(set_prolog_flag(_,_)).
'$iso_builtin'(set_stream_position(_,_)).
'$iso_builtin'(setof(_,_,_)).
'$iso_builtin'(stream_property(_,_)).
'$iso_builtin'(sub_atom(_,_,_,_,_)).
'$iso_builtin'(_@>_).
'$iso_builtin'(_@>=_).
'$iso_builtin'(_==_).
'$iso_builtin'(_@<_).
'$iso_builtin'(_@=<_).
'$iso_builtin'(_\==_).
'$iso_builtin'(throw(_)).
'$iso_builtin'(true).
'$iso_builtin'(_\=_).
'$iso_builtin'(_=_).
'$iso_builtin'(unify_with_occurs_check(_,_)).
'$iso_builtin'(_384=.._385).
'$iso_builtin'(var(_)).
'$iso_builtin'(write(_)).
'$iso_builtin'(write(_,_)).
'$iso_builtin'(write_canonical(_)).
'$iso_builtin'(write_canonical(_,_)).
'$iso_builtin'(write_term(_,_)).
'$iso_builtin'(write_term(_,_,_)).
'$iso_builtin'(writeq(_)).
'$iso_builtin'(writeq(_,_)).
yap-6.2.2/pl/tabling.yap 000644 000765 000024 00000026230 11501242526 015017 0 ustar 00vsc staff 000000 000000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% 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 %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- meta_predicate
table(:),
is_tabled(:),
tabling_mode(:,?),
abolish_table(:),
show_table(:),
table_statistics(:),
table_statistics(:,:).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% table/1 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
table(Pred) :-
'$current_module'(Mod),
'$do_table'(Mod,Pred).
'$do_table'(Mod,Pred) :-
var(Pred), !,
'$do_error'(instantiation_error,table(Mod:Pred)).
'$do_table'(_,Mod:Pred) :- !,
'$do_table'(Mod,Pred).
'$do_table'(_,[]) :- !.
'$do_table'(Mod,[HPred|TPred]) :- !,
'$do_table'(Mod,HPred),
'$do_table'(Mod,TPred).
'$do_table'(Mod,(Pred1,Pred2)) :- !,
'$do_table'(Mod,Pred1),
'$do_table'(Mod,Pred2).
'$do_table'(Mod,PredName/PredArity) :-
atom(PredName),
integer(PredArity),
functor(PredFunctor,PredName,PredArity), !,
'$set_table'(Mod,PredFunctor).
'$do_table'(Mod,Pred) :-
'$do_error'(type_error(callable,Mod:Pred),table(Mod:Pred)).
'$set_table'(Mod,PredFunctor) :-
'$undefined'('$c_table'(_,_),prolog), !,
functor(PredFunctor, PredName, PredArity),
'$do_error'(resource_error(tabling,Mod:PredName/PredArity),table(Mod:PredName/PredArity)).
'$set_table'(Mod,PredFunctor) :-
'$undefined'(PredFunctor,Mod), !,
'$c_table'(Mod,PredFunctor).
'$set_table'(Mod,PredFunctor) :-
'$flags'(PredFunctor,Mod,Flags,Flags),
Flags /\ 0x1991F880 =:= 0,
'$c_table'(Mod,PredFunctor), !.
'$set_table'(Mod,PredFunctor) :-
functor(PredFunctor,PredName,PredArity),
'$do_error'(permission_error(modify,table,Mod:PredName/PredArity),table(Mod:PredName/PredArity)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% is_tabled/1 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
is_tabled(Pred) :-
'$current_module'(Mod),
'$do_is_tabled'(Mod,Pred).
'$do_is_tabled'(Mod,Pred) :-
var(Pred), !,
'$do_error'(instantiation_error,is_tabled(Mod:Pred)).
'$do_is_tabled'(_,Mod:Pred) :- !,
'$do_is_tabled'(Mod,Pred).
'$do_is_tabled'(_,[]) :- !.
'$do_is_tabled'(Mod,[HPred|TPred]) :- !,
'$do_is_tabled'(Mod,HPred),
'$do_is_tabled'(Mod,TPred).
'$do_is_tabled'(Mod,(Pred1,Pred2)) :- !,
'$do_is_tabled'(Mod,Pred1),
'$do_is_tabled'(Mod,Pred2).
'$do_is_tabled'(Mod,PredName/PredArity) :-
atom(PredName),
integer(PredArity),
functor(PredFunctor,PredName,PredArity),
'$flags'(PredFunctor,Mod,Flags,Flags), !,
Flags /\ 0x000040 =\= 0.
'$do_is_tabled'(Mod,Pred) :-
'$do_error'(type_error(callable,Mod:Pred),is_tabled(Mod:Pred)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% tabling_mode/2 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tabling_mode(Pred,Options) :-
'$current_module'(Mod),
'$do_tabling_mode'(Mod,Pred,Options).
'$do_tabling_mode'(Mod,Pred,Options) :-
var(Pred), !,
'$do_error'(instantiation_error,tabling_mode(Mod:Pred,Options)).
'$do_tabling_mode'(_,Mod:Pred,Options) :- !,
'$do_tabling_mode'(Mod,Pred,Options).
'$do_tabling_mode'(_,[],_) :- !.
'$do_tabling_mode'(Mod,[HPred|TPred],Options) :- !,
'$do_tabling_mode'(Mod,HPred,Options),
'$do_tabling_mode'(Mod,TPred,Options).
'$do_tabling_mode'(Mod,(Pred1,Pred2),Options) :- !,
'$do_tabling_mode'(Mod,Pred1,Options),
'$do_tabling_mode'(Mod,Pred2,Options).
'$do_tabling_mode'(Mod,PredName/PredArity,Options) :-
atom(PredName),
integer(PredArity),
functor(PredFunctor,PredName,PredArity),
'$flags'(PredFunctor,Mod,Flags,Flags), !,
(
Flags /\ 0x000040 =\= 0, !, '$set_tabling_mode'(Mod,PredFunctor,Options)
;
'$do_error'(domain_error(table,Mod:PredName/PredArity),tabling_mode(Mod:PredName/PredArity,Options))
).
'$do_tabling_mode'(Mod,Pred,Options) :-
'$do_error'(type_error(callable,Mod:Pred),tabling_mode(Mod:Pred,Options)).
'$set_tabling_mode'(Mod,PredFunctor,Options) :-
var(Options), !,
'$c_tabling_mode'(Mod,PredFunctor,Options).
'$set_tabling_mode'(_,_,[]) :- !.
'$set_tabling_mode'(Mod,PredFunctor,[HOption|TOption]) :- !,
'$set_tabling_mode'(Mod,PredFunctor,HOption),
'$set_tabling_mode'(Mod,PredFunctor,TOption).
'$set_tabling_mode'(Mod,PredFunctor,(Option1,Option2)) :- !,
'$set_tabling_mode'(Mod,PredFunctor,Option1),
'$set_tabling_mode'(Mod,PredFunctor,Option2).
'$set_tabling_mode'(Mod,PredFunctor,Option) :-
'$transl_to_pred_flag_tabling_mode'(Flag,Option), !,
'$c_tabling_mode'(Mod,PredFunctor,Flag).
'$set_tabling_mode'(Mod,PredFunctor,Options) :-
functor(PredFunctor,PredName,PredArity),
'$do_error'(domain_error(flag_value,tabling_mode+Options),tabling_mode(Mod:PredName/PredArity,Options)).
%% should match with code in OPTYap/opt.preds.c
'$transl_to_pred_flag_tabling_mode'(1,batched).
'$transl_to_pred_flag_tabling_mode'(2,local).
'$transl_to_pred_flag_tabling_mode'(3,exec_answers).
'$transl_to_pred_flag_tabling_mode'(4,load_answers).
'$transl_to_pred_flag_tabling_mode'(5,local_trie).
'$transl_to_pred_flag_tabling_mode'(6,global_trie).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% abolish_table/1 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
abolish_table(Pred) :-
'$current_module'(Mod),
'$do_abolish_table'(Mod,Pred).
'$do_abolish_table'(Mod,Pred) :-
var(Pred), !,
'$do_error'(instantiation_error,abolish_table(Mod:Pred)).
'$do_abolish_table'(_,Mod:Pred) :- !,
'$do_abolish_table'(Mod,Pred).
'$do_abolish_table'(_,[]) :- !.
'$do_abolish_table'(Mod,[HPred|TPred]) :- !,
'$do_abolish_table'(Mod,HPred),
'$do_abolish_table'(Mod,TPred).
'$do_abolish_table'(Mod,(Pred1,Pred2)) :- !,
'$do_abolish_table'(Mod,Pred1),
'$do_abolish_table'(Mod,Pred2).
'$do_abolish_table'(Mod,PredName/PredArity) :-
atom(PredName),
integer(PredArity),
functor(PredFunctor,PredName,PredArity),
'$flags'(PredFunctor,Mod,Flags,Flags), !,
(
Flags /\ 0x000040 =\= 0, !, '$c_abolish_table'(Mod,PredFunctor)
;
'$do_error'(domain_error(table,Mod:PredName/PredArity),abolish_table(Mod:PredName/PredArity))
).
'$do_abolish_table'(Mod,Pred) :-
'$do_error'(type_error(callable,Mod:Pred),abolish_table(Mod:Pred)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% show_table/1 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
show_table(Pred) :-
'$current_module'(Mod),
'$do_show_table'(Mod,Pred).
'$do_show_table'(Mod,Pred) :-
var(Pred), !,
'$do_error'(instantiation_error,show_table(Mod:Pred)).
'$do_show_table'(_,Mod:Pred) :- !,
'$do_show_table'(Mod,Pred).
'$do_show_table'(_,[]) :- !.
'$do_show_table'(Mod,[HPred|TPred]) :- !,
'$do_show_table'(Mod,HPred),
'$do_show_table'(Mod,TPred).
'$do_show_table'(Mod,(Pred1,Pred2)) :- !,
'$do_show_table'(Mod,Pred1),
'$do_show_table'(Mod,Pred2).
'$do_show_table'(Mod,PredName/PredArity) :-
atom(PredName),
integer(PredArity),
functor(PredFunctor,PredName,PredArity),
'$flags'(PredFunctor,Mod,Flags,Flags), !,
(
Flags /\ 0x000040 =\= 0, !, '$c_show_table'(Mod,PredFunctor)
;
'$do_error'(domain_error(table,Mod:PredName/PredArity),show_table(Mod:PredName/PredArity))
).
'$do_show_table'(Mod,Pred) :-
'$do_error'(type_error(callable,Mod:Pred),show_table(Mod:Pred)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% table_statistics/1 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
table_statistics(Pred) :-
'$current_module'(Mod),
'$do_table_statistics'(Mod,Pred).
'$do_table_statistics'(Mod,Pred) :-
var(Pred), !,
'$do_error'(instantiation_error,table_statistics(Mod:Pred)).
'$do_table_statistics'(_,Mod:Pred) :- !,
'$do_table_statistics'(Mod,Pred).
'$do_table_statistics'(_,[]) :- !.
'$do_table_statistics'(Mod,[HPred|TPred]) :- !,
'$do_table_statistics'(Mod,HPred),
'$do_table_statistics'(Mod,TPred).
'$do_table_statistics'(Mod,(Pred1,Pred2)) :- !,
'$do_table_statistics'(Mod,Pred1),
'$do_table_statistics'(Mod,Pred2).
'$do_table_statistics'(Mod,PredName/PredArity) :-
atom(PredName),
integer(PredArity),
functor(PredFunctor,PredName,PredArity),
'$flags'(PredFunctor,Mod,Flags,Flags), !,
(
Flags /\ 0x000040 =\= 0, !, '$c_table_statistics'(Mod,PredFunctor)
;
'$do_error'(domain_error(table,Mod:PredName/PredArity),table_statistics(Mod:PredName/PredArity))
).
'$do_table_statistics'(Mod,Pred) :-
'$do_error'(type_error(callable,Mod:Pred),table_statistics(Mod:Pred)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% tabling_statistics/2 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% should match with code in OPTYap/opt.preds.c
tabling_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
tabling_statistics(table_entries,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(1,BytesInUse,StructsInUse).
tabling_statistics(subgoal_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(2,BytesInUse,StructsInUse).
tabling_statistics(dependency_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(3,BytesInUse,StructsInUse).
tabling_statistics(subgoal_trie_nodes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(6,BytesInUse,StructsInUse).
tabling_statistics(answer_trie_nodes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(7,BytesInUse,StructsInUse).
tabling_statistics(subgoal_trie_hashes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(8,BytesInUse,StructsInUse).
tabling_statistics(answer_trie_hashes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(9,BytesInUse,StructsInUse).
tabling_statistics(global_trie_nodes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(10,BytesInUse,StructsInUse).
tabling_statistics(global_trie_hashes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(11,BytesInUse,StructsInUse).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
yap-6.2.2/pl/threads.yap 000644 000765 000024 00000073374 11457004725 015053 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: threads.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: support threads *
* *
*************************************************************************/
:- meta_predicate
thread_initialization(0),
thread_at_exit(0),
thread_create(0, -, :),
thread_create(0, -),
thread_create(0),
thread_signal(+, 0),
with_mutex(+, 0),
thread_signal(+,0),
volatile(:).
volatile(P) :- var(P),
throw(error(instantiation_error,volatile(P))).
volatile(M:P) :-
'$do_volatile'(P,M).
volatile((G1,G2)) :-
'$do_volatile'(G1),
'$do_volatile'(G2).
volatile(P) :-
'$current_module'(M),
'$do_volatile'(P,M).
'$do_volatile'(P,M) :- dynamic(M:P).
:- initialization('$init_thread0').
'$init_thread0' :-
recorda('$thread_alias', [0|main], _),
fail.
'$init_thread0' :-
'$no_threads', !.
'$init_thread0' :-
recorda('$thread_defaults', [0, 0, 0, false, true], _),
'$create_thread_mq'(0),
'$new_mutex'(Id),
assert_static(prolog:'$with_mutex_mutex'(Id)).
'$top_thread_goal'(G, Detached) :-
'$thread_self'(Id),
(Detached == true -> '$detach_thread'(Id) ; true),
'$current_module'(Module),
'$run_at_thread_start',
% always finish with a throw to make sure we clean stacks.
'$system_catch'((G -> throw('$thread_finished'(true)) ; throw('$thread_finished'(false))),Module,Exception,'$close_thread'(Exception,Detached)),
% force backtracking and handling exceptions
fail.
'$close_thread'(Status, Detached) :-
'$thread_zombie_self'(Id0), !,
'$record_thread_status'(Id0,Status),
'$run_at_thread_exit'(Id0),
'$erase_thread_info'(Id0).
% OK, we want to ensure atomicity here in case we get an exception while we
% are closing down the thread.
'$record_thread_status'(Id0,Stat) :- !,
'$mk_tstatus_key'(Id0, Key),
(recorded(Key, _, R), erase(R), fail
;
Stat = '$thread_finished'(Status) ->
recorda(Key, Status, _)
;
recorda(Key, exception(Stat), _)
).
thread_create(Goal) :-
G0 = thread_create(Goal),
'$check_callable'(Goal, G0),
'$thread_options'([detached(true)], [], Stack, Trail, System, Detached, AtExit, G0),
'$thread_new_tid'(Id),
% '$erase_thread_info'(Id), % this should not be here
'$create_thread_mq'(Id),
(
'$create_thread'(Goal, Stack, Trail, System, Detached, AtExit, Id)
->
true
;
'$mk_tstatus_key'(Id, Key),
recorda(Key, exception(resource_error(memory)),_)
).
thread_create(Goal, Id) :-
G0 = thread_create(Goal, Id),
'$check_callable'(Goal, G0),
( nonvar(Id) -> '$do_error'(uninstantiation_error(Id),G0) ; true ),
'$thread_options'([], [], Stack, Trail, System, Detached, AtExit, G0),
'$thread_new_tid'(Id),
% '$erase_thread_info'(Id), % this should not be here
'$create_thread_mq'(Id),
(
'$create_thread'(Goal, Stack, Trail, System, Detached, AtExit, Id)
->
true
;
'$mk_tstatus_key'(Id, Key),
recorda(Key, exception(resource_error(memory)),_)
).
thread_create(Goal, Id, Options) :-
G0 = thread_create(Goal, Id, Options),
'$check_callable'(Goal,G0),
( nonvar(Id) -> '$do_error'(uninstantiation_error(Id),G0) ; true ),
'$thread_options'(Options, Alias, Stack, Trail, System, Detached, AtExit, G0),
'$thread_new_tid'(Id),
% '$erase_thread_info'(Id), % this should not be here
'$record_alias_info'(Id, Alias),
'$create_thread_mq'(Id),
(
'$create_thread'(Goal, Stack, Trail, System, Detached, AtExit, Id)
->
true
;
'$mk_tstatus_key'(Id, Key),
recorda(Key, exception(resource_error(memory)),_)
).
'$erase_thread_info'(Id) :-
recorded('$thread_alias',[Id|_],R),
erase(R),
fail.
'$erase_thread_info'(Id) :-
recorded('$thread_exit_hook', [Id|_], R),
erase(R),
fail.
'$erase_thread_info'(Id) :-
recorded('$queue',q(Id,_,_,_,QKey),_),
'$empty_mqueue'(QKey),
fail.
'$erase_thread_info'(_).
'$thread_options'(Opts, Alias, Stack, Trail, System, Detached, AtExit, G) :-
strip_module(Opts, Mod, LOpts),
(
var(Opts)
->
'$do_error'(instantiation_error,G)
;
var(Mod)
->
'$do_error'(instantiation_error,G)
;
\+ atom(Mod)
->
'$do_error'(uninstantiation_error(Mod),G)
;
var(LOpts)
->
'$do_error'(instantiation_error,G)
;
'$thread_options'(LOpts, Alias, Stack, Trail, System, Detached, AtExit, Mod, G)
).
'$thread_options'([], _, Stack, Trail, System, Detached, AtExit, M, _) :-
recorded('$thread_defaults', [DefaultStack, DefaultTrail, DefaultSystem, DefaultDetached, DefaultAtExit], _),
( var(Stack) -> Stack = DefaultStack; true ),
( var(Trail) -> Trail = DefaultTrail; true ),
( var(System) -> System = DefaultSystem; true ),
( var(Detached) -> Detached = DefaultDetached; true ),
( var(AtExit) -> AtExit = DefaultAtExit; true ).
'$thread_options'([Opt|Opts], Alias, Stack, Trail, System, Detached, AtExit, M, G0) :-
'$thread_option'(Opt, Alias, Stack, Trail, System, Detached, AtExit, M, G0),
'$thread_options'(Opts, Alias, Stack, Trail, System, Detached, AtExit, M, G0).
'$thread_option'(Option, _, _, _, _, _, _, _, G0) :- var(Option), !,
'$do_error'(instantiation_error,G0).
'$thread_option'(alias(Alias), Alias, _, _, _, _, _, _, G0) :- !,
( \+ atom(Alias) -> '$do_error'(type_error(atom,Alias),G0) ; true ).
'$thread_option'(stack(Stack), _, Stack, _, _, _, _, _, G0) :- !,
( \+ integer(Stack) -> '$do_error'(type_error(integer,Stack),G0) ; true ).
'$thread_option'(trail(Trail), _, _, Trail, _, _, _, _, G0) :- !,
( \+ integer(Trail) -> '$do_error'(type_error(integer,Trail),G0) ; true ).
'$thread_option'(system(System), _, _, _, System, _, _, _, G0) :- !,
( \+ integer(System) -> '$do_error'(type_error(integer,System),G0) ; true ).
'$thread_option'(detached(Detached), _, _, _, _, Detached, _, _, G0) :- !,
( Detached \== true, Detached \== false -> '$do_error'(domain_error(thread_option,Detached+[true,false]),G0) ; true ).
'$thread_option'(at_exit(AtExit), _, _, _, _, _, AtExit, M, G0) :- !,
( \+ callable(AtExit) -> '$do_error'(type_error(callable,AtExit),G0) ; true ).
'$thread_option'(Option, _, _, _, _, _, _, _, G0) :-
'$do_error'(domain_error(thread_option,Option),G0).
'$record_alias_info'(_, Alias) :-
var(Alias), !.
'$record_alias_info'(_, Alias) :-
recorded('$thread_alias', [_|Alias], _), !,
'$do_error'(permission_error(create,thread,alias(Alias)), Goal).
'$record_alias_info'(Id, Alias) :-
recorda('$thread_alias', [Id|Alias], _).
% vsc: ?????
thread_defaults(Defaults) :-
nonvar(Defaults), !,
'$do_error'(uninstantion_error(Defaults), thread_defaults(Defaults)).
thread_defaults([stack(Stack), trail(Trail), system(System), detached(Detached), at_exit(AtExit)]) :-
recorded('$thread_defaults',[Stack, Trail, System, Detached, AtExit], _).
thread_default(Default) :-
var(Default), !,
recorded('$thread_defaults', Defaults, _),
'$thread_default'(Default, Defaults).
thread_default(stack(Stack)) :- !,
recorded('$thread_defaults',[Stack, _, _, _, _], _).
thread_default(trail(Trail)) :- !,
recorded('$thread_defaults',[_, Trail, _, _, _], _).
thread_default(system(System)) :- !,
recorded('$thread_defaults',[_, _, System, _, _], _).
thread_default(detached(Detached)) :- !,
recorded('$thread_defaults',[_, _, _, Detached, _], _).
thread_default(at_exit(AtExit)) :- !,
recorded('$thread_defaults',[_, _, _, _, AtExit], _).
thread_default(Default) :-
'$do_error'(type_error(thread_option,Default),thread_default(Default)).
'$thread_default'(stack(Stack), [Stack, _, _, _, _]).
'$thread_default'(trail(Trail), [_, Trail, _, _, _]).
'$thread_default'(stack(System), [_, _, System, _, _]).
'$thread_default'(detached(Detached), [_, _, _, Detached, _]).
'$thread_default'(at_exit(AtExit), [_, _, _, _, AtExit]).
thread_set_defaults(V) :- var(V), !,
'$do_error'(instantiation_error, thread_set_defaults(V)).
thread_set_defaults([Default| Defaults]) :- !,
'$thread_set_defaults'([Default| Defaults], thread_set_defaults([Default| Defaults])).
thread_set_defaults(T) :-
'$do_error'(type_error(list, T), thread_set_defaults(T)).
'$thread_set_defaults'([], _).
'$thread_set_defaults'([Default| Defaults], G) :- !,
'$thread_set_default'(Default, G),
'$thread_set_defaults'(Defaults, G).
thread_set_default(V) :- var(V), !,
'$do_error'(instantiation_error, thread_set_default(V)).
thread_set_default(Default) :-
'$thread_set_default'(Default, thread_set_default(Default)).
'$thread_set_default'(stack(Stack), G) :-
\+ integer(Stack), !,
'$do_error'(type_error(integer, Stack), G).
'$thread_set_default'(stack(Stack), G) :-
Stack < 0, !,
'$do_error'(domain_error(not_less_than_zero, Stack), G).
'$thread_set_default'(stack(Stack), _) :- !,
recorded('$thread_defaults', [_, Trail, System, Detached, AtExit], Ref),
erase(Ref),
recorda('$thread_defaults', [Stack, Trail, System, Detached, AtExit], _).
'$thread_set_default'(trail(Trail), G) :-
\+ integer(Trail), !,
'$do_error'(type_error(integer, Trail), G).
'$thread_set_default'(trail(Trail), G) :-
Trail < 0, !,
'$do_error'(domain_error(not_less_than_zero, Trail), G).
'$thread_set_default'(trail(Trail), _) :- !,
recorded('$thread_defaults', [Stack, _, System, Detached, AtExit], Ref),
erase(Ref),
recorda('$thread_defaults', [Stack, Trail, System, Detached, AtExit], _).
'$thread_set_default'(system(System), G) :-
\+ integer(System), !,
'$do_error'(type_error(integer, System), G).
'$thread_set_default'(system(System), G0) :-
System < 0, !,
'$do_error'(domain_error(not_less_than_zero, System), G0).
'$thread_set_default'(system(System), _) :- !,
recorded('$thread_defaults', [Stack, Trail, _, Detached, AtExit], Ref),
erase(Ref),
recorda('$thread_defaults', [Stack, Trail, System, Detached, AtExit], _).
'$thread_set_default'(detached(Detached), G) :-
Detached \== true, Detached \== false, !,
'$do_error'(type_error(boolean, Detached), G).
'$thread_set_default'(detached(Detached), _) :- !,
recorded('$thread_defaults', [Stack, Trail, System, _, AtExit], Ref),
erase(Ref),
recorda('$thread_defaults', [Stack, Trail, System, Detached, AtExit], _).
'$thread_set_default'(at_exit(AtExit), G) :-
\+ callable(AtExit), !,
'$do_error'(type_error(callable, AtExit), G).
'$thread_set_default'(at_exit(AtExit), _) :- !,
recorded('$thread_defaults', [Stack, Trail, System, Detached, _], Ref),
erase(Ref),
'$current_module'(M),
recorda('$thread_defaults', [Stack, Trail, System, Detached, M:AtExit], _).
'$thread_set_default'(Default, G) :-
'$do_error'(domain_error(thread_default, Default), G).
thread_self(Id) :-
nonvar(Id), \+ integer(Id), \+ atom(Id), !,
'$do_error'(domain_error(thread_or_alias, Id), thread_self(Id)).
thread_self(Id) :-
'$thread_self'(Id0),
'$thread_id_alias'(Id0, Id).
/* Exit status may be either true, false, exception(Term), or exited(Term) */
thread_join(Id, Status) :-
nonvar(Status), !,
'$do_error'(uninstantiation_error(Status),thread_join(Id, Status)).
thread_join(Id, Status) :-
'$check_thread_or_alias'(Id, thread_join(Id, Status)),
'$thread_id_alias'(Id0, Id),
'$thread_join'(Id0),
'$mk_tstatus_key'(Id0, Key),
recorded(Key, Status, R),
erase(R),
'$thread_destroy'(Id0).
thread_cancel(Id) :-
(Id == main; Id == 0), !,
'$do_error'(permission_error(cancel, thread, main), thread_cancel(Id)).
thread_cancel(Id) :-
thread_signal(Id, throw(error(thread_cancel(Id),thread_cancel(Id)))).
thread_detach(Id) :-
'$check_thread_or_alias'(Id, thread_detach(Id)),
'$thread_id_alias'(Id0, Id),
'$detach_thread'(Id0),
'$mk_tstatus_key'(Id0, Key),
( recorded(Key, _, _) ->
'$erase_thread_info'(Id0),
'$thread_destroy'(Id0)
;
'$thread_unlock'(Id0)
).
thread_exit(Term) :-
var(Term), !,
'$do_error'(instantiation_error, thread_exit(Term)).
thread_exit(Term) :-
'$close_thread'('$thread_finished'(exited(Term)), Detached).
'$run_at_thread_exit'(Id0) :-
'$thread_run_at_exit'(G, M),
catch(once(M:G), _, fail),
fail.
'$run_at_thread_exit'(Id0) :-
recorded('$thread_exit_hook',[Id0|Hook],R), erase(R),
catch(once(Hook),_,fail),
fail.
'$run_at_thread_exit'(_).
thread_at_exit(Goal) :-
'$check_callable'(Goal,thread_at_exit(Goal)),
'$thread_self'(Id0),
recordz('$thread_exit_hook',[Id0|Goal],_).
current_thread(Id, Status) :-
thread_property(Id, status(Status)).
'$thread_id_alias'(Id, Alias) :-
recorded('$thread_alias', [Id|Alias], _), !.
'$thread_id_alias'(Id, Id).
'$mutex_id_alias'(Id, Alias) :-
recorded('$mutex_alias', [Id|Alias], _), !.
'$mutex_id_alias'(Id, Id).
mutex_create(Mutex) :-
( atom(Mutex) ->
mutex_create(_, [alias(Mutex)])
; mutex_create(Mutex, [])
).
mutex_create(Id, Options) :-
nonvar(Id), !,
'$do_error'(uninstantiation_error(Id), mutex_create(Id, Options)).
mutex_create(Id, Options) :-
Goal = mutex_create(Id, Options),
'$mutex_options'(Options, Alias, Goal),
( atom(Alias) ->
( recorded('$mutex_alias',[_| Alias], _) ->
'$do_error'(permission_error(create, mutex, Alias), Goal)
; '$new_mutex'(Id),
recorda('$mutex_alias', [Id| Alias], _)
)
; '$new_mutex'(Id),
recorda('$mutex_alias', [Id| Id], _)
).
'$mutex_options'(Var, _, Goal) :-
var(Var), !,
'$do_error'(instantiation_error, Goal).
'$mutex_options'([], _, _) :- !.
'$mutex_options'([Option| Options], Alias, Goal) :- !,
'$mutex_option'(Option, Alias, Goal),
'$mutex_options'(Options, Alias, Goal).
'$mutex_options'(Options, _, Goal) :-
'$do_error'(type_error(list, Options), Goal).
'$mutex_option'(Var, _, Goal) :-
var(Var), !,
'$do_error'(instantiation_error, Goal).
'$mutex_option'(alias(Alias), Alias, Goal) :- !,
( atom(Alias) ->
true
; '$do_error'(type_error(atom, Alias), Goal)
).
'$mutex_option'(Option, _, Goal) :-
'$do_error'(domain_error(mutex_option, Option), Goal).
/*
mutex_create(V) :-
var(V), !,
'$new_mutex'(V),
recorda('$mutex_alias',[V|V],_).
mutex_create(A) :-
atom(A),
recorded('$mutex_alias',[_|A],_), !,
'$do_error'(permission_error(create,mutex,A),mutex_create(A)).
mutex_create(A) :-
atom(A), !,
'$new_mutex'(Id),
recorda('$mutex_alias',[Id|A],_).
mutex_create(V) :-
'$do_error'(type_error(atom,V),mutex_create(V)).
*/
mutex_destroy(Mutex) :-
'$check_mutex_or_alias'(Mutex, mutex_destroy(Mutex)),
'$mutex_id_alias'(Id, Mutex),
'$destroy_mutex'(Id),
'$erase_mutex_info'(Id).
'$erase_mutex_info'(Id) :-
recorded('$mutex_alias',[Id|_],R),
erase(R),
fail.
'$erase_mutex_info'(_).
mutex_lock(V) :-
var(V), !,
'$do_error'(instantiation_error,mutex_lock(V)).
mutex_lock(A) :-
recorded('$mutex_alias',[Id|A],_), !,
'$lock_mutex'(Id).
mutex_lock(A) :-
atom(A), !,
mutex_create(A),
mutex_lock(A).
mutex_lock(V) :-
'$do_error'(type_error(atom,V),mutex_lock(V)).
mutex_trylock(V) :-
var(V), !,
'$do_error'(instantiation_error,mutex_trylock(V)).
mutex_trylock(A) :-
recorded('$mutex_alias',[Id|A],_), !,
'$trylock_mutex'(Id).
mutex_trylock(A) :-
atom(A), !,
mutex_create(A),
mutex_trylock(A).
mutex_trylock(V) :-
'$do_error'(type_error(atom,V),mutex_trylock(V)).
mutex_unlock(Mutex) :-
'$check_mutex_or_alias'(Mutex, mutex_unlock(Mutex)),
'$mutex_id_alias'(Id, Mutex),
( '$unlock_mutex'(Id) ->
true
;
'$do_error'(permission_error(unlock,mutex,Mutex),mutex_unlock(Mutex))
).
mutex_unlock_all :-
'$thread_self'(Tid),
'$unlock_all_thread_mutexes'(Tid).
'$unlock_all_thread_mutexes'(Tid) :-
recorded('$mutex_alias',[Id|_],_),
'$mutex_info'(Id, NRefs, Tid),
NRefs > 0,
'$mutex_unlock_all'(Id),
fail.
'$unlock_all_thread_mutexes'(_).
'$mutex_unlock_all'(Id) :-
'$mutex_info'(Id, NRefs, _),
NRefs > 0,
'$unlock_mutex'(Id),
'$mutex_unlock_all'(Id).
with_mutex(M, G) :-
'$no_threads', !,
call(G).
with_mutex(M, G) :-
var(M), !,
'$do_error'(instantiation_error,with_mutex(M, G)).
with_mutex(M, G) :-
var(G), !,
'$do_error'(instantiation_error,with_mutex(M, G)).
with_mutex(M, G) :-
\+ callable(G), !,
'$do_error'(type_error(callable,G),with_mutex(M, G)).
with_mutex(M, G) :-
atom(M), !,
'$with_mutex_mutex'(WMId),
'$lock_mutex'(WMId),
( recorded('$mutex_alias',[Id|M],_) ->
true
; '$new_mutex'(Id),
recorda('$mutex_alias',[Id|M],_)
),
'$lock_mutex'(Id),
'$unlock_mutex'(WMId),
( catch('$execute'(G), E, ('$unlock_mutex'(Id), throw(E))) ->
'$unlock_mutex'(Id)
; '$unlock_mutex'(Id),
fail
).
with_mutex(M, G) :-
'$do_error'(type_error(atom,M),with_mutex(M, G)).
current_mutex(M, T, NRefs) :-
recorded('$mutex_alias',[Id|M],_),
'$mutex_info'(Id, NRefs, T).
mutex_property(Mutex, Prop) :-
( nonvar(Mutex) ->
'$check_mutex_or_alias'(Mutex, mutex_property(Mutex, Prop))
; recorded('$mutex_alias', [_|Mutex], _)
),
'$check_mutex_property'(Prop, mutex_property(Mutex, Prop)),
'$mutex_id_alias'(Id, Mutex),
'$mutex_property'(Id, Prop).
'$mutex_property'(Id, alias(Alias)) :-
recorded('$mutex_alias', [Id|Alias], _),
Id \= Alias.
'$mutex_property'(Id, status(Status)) :-
'$mutex_info'(Id, Count, HoldingThread),
( Count =:= 0 ->
Status = unlocked
; % Count > 0,
'$thread_id_alias'(HoldingThread, Alias),
once((Thread = Alias; Thread = HoldingThread)),
Status = locked(Thread, Count)
).
message_queue_create(Id, Options) :-
nonvar(Id), !,
'$do_error'(uninstantiation_error(Id), message_queue_create(Id, Options)).
message_queue_create(Id, Options) :-
var(Options), !,
'$do_error'(instantiation_error, message_queue_create(Id, Options)).
message_queue_create(Id, []) :- !,
'$do_msg_queue_create'(Id).
message_queue_create(Id, [alias(Alias)]) :-
var(Alias), !,
'$do_error'(instantiation_error, message_queue_create(Id, [alias(Alias)])).
message_queue_create(Id, [alias(Alias)]) :-
\+ atom(Alias), !,
'$do_error'(type_error(atom,Alias), message_queue_create(Id, [alias(Alias)])).
message_queue_create(Id, [alias(Alias)]) :- !,
'$new_mutex'(Mutex),
'$cond_create'(Cond),
( recorded('$queue', q(Alias,_,_,_,_), _) ->
'$do_error'(permission_error(create,queue,alias(Alias)),message_queue_create(Id, [alias(Alias)]))
; recorded('$thread_alias', [_|Alias], _) ->
'$do_error'(permission_error(create,queue,alias(Alias)),message_queue_create(Id, [alias(Alias)]))
; '$mq_new_id'(Id, NId, Key),
recorda('$queue',q(Alias,Mutex,Cond,NId,Key), _)
).
message_queue_create(Id, [Option| _]) :-
'$do_error'(domain_error(queue_option, Option), message_queue_create(Id, [Option| _])).
message_queue_create(Id, Options) :-
'$do_error'(type_error(list, Options), message_queue_create(Id, Options)).
message_queue_create(Id) :-
( var(Id) -> % ISO DTR
message_queue_create(Id, [])
; atom(Id) -> % old behavior
message_queue_create(_, [alias(Id)])
; '$do_error'(uninstantiation_error(Id), message_queue_create(Id))
).
'$do_msg_queue_create'(Id) :-
\+ recorded('$queue',q(Id,_,_,_,_), _),
'$new_mutex'(Mutex),
'$cond_create'(Cond),
'$mq_new_id'(Id, NId, Key),
recorda('$queue',q(Id,Mutex,Cond,NId,Key), _),
fail.
'$do_msg_queue_create'(_).
'$create_thread_mq'(TId) :-
\+ recorded('$queue',q(TId,_,_,_,_), _),
'$new_mutex'(Mutex),
'$cond_create'(Cond),
'$mq_new_id'(TId, TId, Key),
recorda('$queue', q(TId,Mutex,Cond,TId,Key), _),
fail.
% recover space
'$create_thread_mq'(_).
'$mq_new_id'(Id, Id, AtId) :-
integer(Id), !,
\+ recorded('$queue', q(_,_,_,Id,_), _),
'$init_db_queue'(AtId).
'$mq_new_id'(_, Id, AtId) :-
'$integers'(Id),
\+ recorded('$queue', q(_,_,_,Id,_), _),
!,
'$init_db_queue'(AtId).
'$integers'(-1).
'$integers'(I) :-
'$integers'(I1),
I is I1-1.
message_queue_destroy(Name) :-
var(Name), !,
'$do_error'(instantiation_error,message_queue_destroy(Name)).
message_queue_destroy(Name) :-
'$message_queue_destroy'(Name),
fail.
message_queue_destroy(_).
'$message_queue_destroy'(Queue) :-
recorded('$queue',q(Queue,Mutex,Cond,_,QKey),R), !,
'$clean_mqueue'(QKey),
'$cond_destroy'(Cond),
'$destroy_mutex'(Mutex),
erase(R).
'$message_queue_destroy'(Queue) :-
atomic(Queue), !,
'$do_error'(existence_error(message_queue,Queue),message_queue_destroy(Queue)).
'$message_queue_destroy'(Name) :-
'$do_error'(type_error(atom,Name),message_queue_destroy(Name)).
'$clean_mqueue'(Queue) :-
'$db_dequeue'(Queue),
fail.
'$clean_mqueue'(_).
'$empty_mqueue'(Queue) :-
'$db_dequeue_unlocked'(Queue),
fail.
'$empty_mqueue'(_).
message_queue_property(Id, Prop) :-
( nonvar(Id) ->
'$check_message_queue_or_alias'(Id, message_queue_property(Id, Prop))
; recorded('$queue', q(Id,_,_,_,_), _)
),
'$check_message_queue_property'(Prop, message_queue_property(Id, Prop)),
'$message_queue_id_alias'(Id0, Id),
'$message_queue_property'(Id0, Prop).
'$check_message_queue_or_alias'(Term, Goal) :-
var(Term), !,
'$do_error'(instantiation_error, Goal).
'$check_message_queue_or_alias'(Term, Goal) :-
\+ atom(Term),
Term \= '$message_queue'(_), !,
'$do_error'(domain_error(queue_or_alias, Term), Goal).
'$check_message_queue_or_alias'('$message_queue'(I), Goal) :-
\+ recorded('$queue', q(_,_,_,I,_), _), !,
'$do_error'(existence_error(queue, '$message_queue'(I)), Goal).
'$check_message_queue_or_alias'(Term, Goal) :-
atom(Term),
\+ recorded('$queue', q(Term,_,_,_,_), _), !,
'$do_error'(existence_error(queue, Term), Goal).
'$check_message_queue_or_alias'(_, _).
'$message_queue_id_alias'(Id, Alias) :-
recorded('$queue', q(Alias,_,_,Id,_), _), !.
'$message_queue_id_alias'(Id, Id).
'$check_message_queue_property'(Term, _) :-
var(Term), !.
'$check_message_queue_property'(alias(_), _) :- !.
'$check_message_queue_property'(size(_), _) :- !.
'$check_message_queue_property'(max_size(_), _) :- !.
'$check_message_queue_property'(Term, Goal) :-
'$do_error'(domain_error(queue_property, Term), Goal).
'$message_queue_property'(Id, alias(Alias)) :-
recorded('$queue', q(Alias,_,_,Id,_), _).
thread_send_message(Term) :-
'$thread_self'(Id),
thread_send_message(Id, Term).
thread_send_message(Queue, Term) :- var(Queue), !,
'$do_error'(instantiation_error,thread_send_message(Queue,Term)).
thread_send_message(Queue, Term) :-
recorded('$thread_alias',[Id|Queue],_), !,
thread_send_message(Id, Term).
thread_send_message(Queue, Term) :-
'$do_thread_send_message'(Queue, Term),
fail.
% release pointers
thread_send_message(_, _).
'$do_thread_send_message'(Queue, Term) :-
recorded('$queue',q(Queue,Mutex,Cond,_,Key),_), !,
'$lock_mutex'(Mutex),
'$db_enqueue_unlocked'(Key, Term),
% write(+Queue:Term),nl,
'$cond_signal'(Cond),
'$unlock_mutex'(Mutex).
'$do_thread_send_message'(Queue, Term) :-
'$do_error'(existence_error(queue,Queue),thread_send_message(Queue,Term)).
thread_get_message(Term) :-
'$thread_self'(Id),
thread_get_message(Id, Term).
thread_get_message(Queue, Term) :- var(Queue), !,
'$do_error'(instantiation_error,thread_get_message(Queue,Term)).
thread_get_message(Queue, Term) :-
recorded('$thread_alias',[Id|Queue],_), !,
thread_get_message(Id, Term).
thread_get_message(Queue, Term) :-
recorded('$queue',q(Queue,Mutex,Cond,_,Key),_), !,
'$lock_mutex'(Mutex),
% write(-Queue:Term),nl,
'$thread_get_message_loop'(Key, Term, Mutex, Cond).
thread_get_message(Queue, Term) :-
'$do_error'(existence_error(message_queue,Queue),thread_get_message(Queue,Term)).
'$thread_get_message_loop'(Key, Term, Mutex, _) :-
'$db_dequeue_unlocked'(Key, Term), !,
'$unlock_mutex'(Mutex).
'$thread_get_message_loop'(Key, Term, Mutex, Cond) :-
'$cond_wait'(Cond, Mutex),
'$thread_get_message_loop'(Key, Term, Mutex, Cond).
thread_peek_message(Term) :-
'$thread_self'(Id),
thread_peek_message(Id, Term).
thread_peek_message(Queue, Term) :- var(Queue), !,
'$do_error'(instantiation_error,thread_peek_message(Queue,Term)).
thread_peek_message(Queue, Term) :-
recorded('$thread_alias',[Id|Queue],_), !,
thread_peek_message(Id, Term).
thread_peek_message(Queue, Term) :-
recorded('$queue',q(Queue,Mutex,_,_,Key),_), !,
'$lock_mutex'(Mutex),
'$thread_peek_message2'(Key, Term, Mutex).
thread_peek_message(Queue, Term) :-
'$do_error'(existence_error(message_queue,Queue),thread_peek_message(Queue,Term)).
'$thread_peek_message2'(Key, Term, Mutex) :-
'$db_peek_queue'(Key, Term), !,
'$unlock_mutex'(Mutex).
'$thread_peek_message2'(_, _, Mutex) :-
'$unlock_mutex'(Mutex),
fail.
thread_local(X) :-
'$current_module'(M),
'$thread_local'(X,M).
'$thread_local'(X,M) :- var(X), !,
'$do_error'(instantiation_error,thread_local(M:X)).
'$thread_local'(Mod:Spec,_) :- !,
'$thread_local'(Spec,Mod).
'$thread_local'([], _) :- !.
'$thread_local'([H|L], M) :- !, '$thread_local'(H, M), '$thread_local'(L, M).
'$thread_local'((A,B),M) :- !, '$thread_local'(A,M), '$thread_local'(B,M).
'$thread_local'(X,M) :- !,
'$thread_local2'(X,M).
'$thread_local2'(A/N, Mod) :- integer(N), atom(A), !,
functor(T,A,N),
(Mod \= idb -> '$flags'(T,Mod,F,F) ; true),
( '$install_thread_local'(T,Mod) -> true ;
F /\ 0x08002000 =\= 0 -> '$do_error'(permission_error(modify,dynamic_procedure,A/N),thread_local(Mod:A/N)) ;
'$do_error'(permission_error(modify,static_procedure,A/N),thread_local(Mod:A/N))
).
'$thread_local2'(X,Mod) :-
'$do_error'(type_error(callable,X),thread_local(Mod:X)).
thread_sleep(Time) :-
var(Time), !,
'$do_error'(instantiation_error,thread_sleep(Time)).
thread_sleep(Time) :-
integer(Time), !,
( Time > 0 ->
'$thread_sleep'(Time,0,_,_)
; true
).
thread_sleep(Time) :-
float(Time), !,
( Time > 0.0 ->
STime is integer(float_integer_part(Time)),
NTime is integer(float_fractional_part(Time))*1000000000,
'$thread_sleep'(STime,NTime,_,_)
; true
).
thread_sleep(Time) :-
'$do_error'(type_error(number,Time),thread_sleep(Time)).
thread_signal(Id, Goal) :-
'$check_thread_or_alias'(Id, thread_signal(Id, Goal)),
'$check_callable'(Goal, thread_signal(Id, Goal)),
'$thread_id_alias'(Id0, Id),
( recorded('$thread_signal', [Id0| _], R), erase(R), fail
; true
),
recorda('$thread_signal', [Id0| Goal], _),
'$signal_thread'(Id0).
'$thread_gfetch'(G) :-
'$thread_self'(Id),
recorded('$thread_signal',[Id|G],R),
erase(R).
thread_property(Prop) :-
'$check_thread_property'(Prop, thread_property(Prop)),
'$thread_self'(Id),
'$thread_property'(Id, Prop).
thread_property(Id, Prop) :-
( nonvar(Id) ->
'$check_thread_or_alias'(Id, thread_property(Id, Prop))
; '$enumerate_threads'(Id)
),
'$check_thread_property'(Prop, thread_property(Id, Prop)),
'$thread_id_alias'(Id0, Id),
'$thread_property'(Id0, Prop).
'$enumerate_threads'(Id) :-
'$max_threads'(Max),
Max1 is Max-1,
'$between'(0,Max1,Id),
'$thread_stacks'(Id, _, _, _).
'$thread_property'(Id, alias(Alias)) :-
recorded('$thread_alias', [Id|Alias], _).
'$thread_property'(Id, status(Status)) :-
'$mk_tstatus_key'(Id, Key),
( recorded(Key, Exit, _) ->
Status = Exit
; Status = running
).
'$thread_property'(Id, detached(Detached)) :-
( '$thread_detached'(Id,Detached) -> true ; Detached = false ).
'$thread_property'(Id, at_exit(M:G)) :-
'$thread_run_at_exit'(G,M).
'$thread_property'(Id, InfoSize) :-
'$thread_stacks'(Id, Stack, Trail, System),
'$select_thread_property'(InfoSize, Stack, Trail, System).
'$select_thread_property'(stack(Stack), Stack, _, _).
'$select_thread_property'(trail(Trail), _, Trail, _).
'$select_thread_property'(system(System), _, _, System).
threads :-
format(user_error,'------------------------------------------------------------------------~n',[]),
format(user_error, '~t~a~48+~n', 'Thread Detached Status'),
format(user_error,'------------------------------------------------------------------------~n',[]),
thread_property(Id, detached(Detached)),
'$thread_property'(Id, status(Status)),
'$thread_id_alias'(Id, Alias),
format(user_error,'~t~q~30+~33|~w~42|~q~n', [Alias, Detached, Status]),
fail.
threads :-
format(user_error,'------------------------------------------------------------------------~n',[]).
'$check_thread_or_alias'(Term, Goal) :-
var(Term), !,
'$do_error'(instantiation_error, Goal).
'$check_thread_or_alias'(Term, Goal) :-
\+ integer(Term), \+ atom(Term), !,
'$do_error'(domain_error(thread_or_alias, Term), Goal).
'$check_thread_or_alias'(Term, Goal) :-
atom(Term), \+ recorded('$thread_alias',[_|Term],_), !,
'$do_error'(existence_error(thread, Term), Goal).
'$check_thread_or_alias'(Term, Goal) :-
integer(Term), \+ '$valid_thread'(Term), !,
'$do_error'(existence_error(thread, Term), Goal).
'$check_thread_or_alias'(_,_).
'$check_thread_property'(Term, _) :-
var(Term), !.
'$check_thread_property'(alias(_), _) :- !.
'$check_thread_property'(detached(_), _) :- !.
'$check_thread_property'(at_exit(_), _) :- !.
'$check_thread_property'(status(_), _) :- !.
'$check_thread_property'(stack(_), _) :- !.
'$check_thread_property'(trail(_), _) :- !.
'$check_thread_property'(system(_), _) :- !.
'$check_thread_property'(Term, Goal) :-
'$do_error'(domain_error(thread_property, Term), Goal).
'$check_mutex_or_alias'(Term, Goal) :-
var(Term), !,
'$do_error'(instantiation_error, Goal).
'$check_mutex_or_alias'(Term, Goal) :-
\+ integer(Term), \+ atom(Term), !,
'$do_error'(domain_error(mutex_or_alias, Term), Goal).
'$check_mutex_or_alias'(Term, Goal) :-
atom(Term), \+ recorded('$mutex_alias',[_|Term],_), !,
'$do_error'(existence_error(mutex, Term), Goal).
'$check_mutex_or_alias'(Term, Goal) :-
% integer(Term), \+ '$valid_mutex'(Term), !,
integer(Term), \+ recorded('$mutex_alias',[Term|_],_), !,
'$do_error'(existence_error(mutex, Term), Goal).
'$check_mutex_or_alias'(_,_).
'$check_mutex_property'(Term, _) :-
var(Term), !.
'$check_mutex_property'(alias(_), _) :- !.
'$check_mutex_property'(status(Status), Goal) :- !,
( var(Status) ->
true
; Status = unlocked ->
true
; Status = locked(_, _) ->
true
; '$do_error'(domain_error(mutex_property, status(Status)), Goal)
).
'$check_mutex_property'(Term, Goal) :-
'$do_error'(domain_error(mutex_property, Term), Goal).
'$mk_tstatus_key'(Id0, Key) :-
atomic_concat('$thread_exit_status__',Id0,Key).
yap-6.2.2/pl/udi.yap 000644 000765 000024 00000001307 11475020360 014156 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2010 *
* *
**************************************************************************
* *
* File: udi.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: support user defined indexing *
* *
*************************************************************************/
:- meta_predicate udi(:).
/******************
* udi/1 *
******************/
udi(Pred) :-
'$udi_init'(rtree, Pred).
yap-6.2.2/pl/utils.yap 000644 000765 000024 00000045377 11516311453 014556 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: utils.yap *
* Last rev: 8/2/88 *
* mods: *
* comments: Some utility predicates available in yap *
* *
*************************************************************************/
op(P,T,V) :-
'$check_op'(P,T,V,op(P,T,V)),
'$op'(P, T, V).
% just check the operator declarations for correctness.
'$check_op'(P,T,Op,G) :-
( var(P) ; var(T); var(Op)), !,
'$do_error'(instantiation_error,G).
'$check_op'(P,_,_,G) :-
\+ integer(P), !,
'$do_error'(type_error(integer,P),G).
'$check_op'(P,_,_,G) :-
P < 0, !,
'$do_error'(domain_error(operator_priority,P),G).
'$check_op'(P,_,_,G) :-
P > 1200, !,
'$do_error'(domain_error(operator_priority,P),G).
'$check_op'(_,T,_,G) :-
\+ atom(T), !,
'$do_error'(type_error(atom,P),G).
'$check_op'(_,T,_,G) :-
\+ '$associativity'(T), !,
'$do_error'(domain_error(operator_specifier,T),G).
'$check_op'(P,T,V,G) :-
'$check_module_for_op'(V, G, NV),
'$check_top_op'(P, T, NV, G).
'$check_top_op'(_, _, [], _).
'$check_top_op'(P, T, Op.NV, G) :- !,
'$check_ops'(P, T, Op.NV, G).
'$check_top_op'(P, T, V, G) :-
atom(V), !,
'$check_op_name'(P, T, V, G).
'$check_top_op'(P, T, V, G) :-
'$do_error'(type_error(atom,V),G).
'$associativity'(xfx).
'$associativity'(xfy).
'$associativity'(yfx).
'$associativity'(yfy).
'$associativity'(xf).
'$associativity'(yf).
'$associativity'(fx).
'$associativity'(fy).
'$check_module_for_op'(MOp, G, _) :-
var(MOp), !,
'$do_error'(instantiation_error,G).
'$check_module_for_op'(M:V, G, _) :-
var(M), !,
'$do_error'(instantiation_error,G).
'$check_module_for_op'(M:V, G, NV) :-
atom(M), !,
'$check_module_for_op'(V, G, NV).
'$check_module_for_op'(M:V, G, _) :- !,
'$do_error'(type_error(atom,P),G).
'$check_module_for_op'(V, G, V).
'$check_ops'(P, T, [], G) :- !.
'$check_ops'(P, T, Op.NV, G) :- !,
(
var(NV)
->
'$do_error'(instantiation_error,G)
;
'$check_module_for_op'(Op, G, NOp),
'$check_op_name'(P, T, NOp, G),
'$check_ops'(P, T, NV, G)
).
'$check_ops'(P, T, Ops, G) :-
'$do_error'(type_error(list,Ops),G).
'$check_op_name'(_,_,V,G) :-
var(V), !,
'$do_error'(instantiation_error,G).
'$check_op_name'(_,_,',',G) :- !,
'$do_error'(permission_error(modify,operator,','),G).
'$check_op_name'(_,_,'[]',G) :- !,
'$do_error'(permispsion_error(create,operator,'[]'),G).
'$check_op_name'(_,_,'{}',G) :- !,
'$do_error'(permission_error(create,operator,'{}'),G).
'$check_op_name'(P,T,'|',G) :-
(
integer(P),
P < 1001
;
atom_codes(T,[_,_])
), !,
'$do_error'(permission_error(create,operator,'|'),G).
'$check_op_name'(_,_,V,_) :-
atom(V), !.
'$check_op_name'(_,_,A,G) :-
'$do_error'(type_error(atom,A),G).
'$op'(P, T, ML) :-
strip_module(ML, M, [A|As]), !,
'$opl'(P, T, M, [A|As]).
'$op'(P, T, A) :-
'$op2'(P,T,A).
'$opl'(P, T, _, []).
'$opl'(P, T, M, [A|As]) :-
'$op2'(P, T, M:A),
'$opl'(P, T, M, As).
'$op2'(P,T,A) :-
atom(A), !,
'$opdec'(P,T,A,prolog).
'$op2'(P,T,A) :-
strip_module(A,M,N),
'$opdec'(P,T,N,M).
current_op(X,Y,V) :- var(V), !,
'$current_module'(M),
'$do_current_op'(X,Y,V,M).
current_op(X,Y,M:Z) :- !,
'$current_opm'(X,Y,Z,M).
current_op(X,Y,Z) :-
'$current_module'(M),
'$do_current_op'(X,Y,Z,M).
'$current_opm'(X,Y,Z,M) :-
nonvar(Y),
\+ '$associativity'(Y),
'$do_error'(domain_error(operator_specifier,Y),current_op(X,Y,M:Z)).
'$current_opm'(X,Y,Z,M) :-
var(Z), !,
'$do_current_op'(X,Y,Z,M).
'$current_opm'(X,Y,M:Z,_) :- !,
'$current_opm'(X,Y,Z,M).
'$current_opm'(X,Y,Z,M) :-
'$do_current_op'(X,Y,Z,M).
'$do_current_op'(X,Y,Z,M) :-
nonvar(Y),
\+ '$associativity'(Y),
'$do_error'(domain_error(operator_specifier,Y),current_op(X,Y,M:Z)).
'$do_current_op'(X,Y,Z,M) :-
atom(Z), !,
'$current_atom_op'(Z, M1, Prefix, Infix, Posfix),
( M1 = prolog -> true ; M1 = M ),
(
'$get_prefix'(Prefix, X, Y)
;
'$get_infix'(Infix, X, Y)
;
'$get_posfix'(Posfix, X, Y)
).
'$do_current_op'(X,Y,Z,M) :-
'$current_op'(Z, M1, Prefix, Infix, Posfix),
( M1 = prolog -> true ; M1 = M ),
(
'$get_prefix'(Prefix, X, Y)
;
'$get_infix'(Infix, X, Y)
;
'$get_posfix'(Posfix, X, Y)
).
'$get_prefix'(Prefix, X, Y) :-
Prefix > 0,
X is Prefix /\ 0xfff,
(
0x2000 /\ Prefix =:= 0x2000
->
Y = fx
;
Y = fy
).
'$get_infix'(Infix, X, Y) :-
Infix > 0,
X is Infix /\ 0xfff,
(
0x3000 /\ Infix =:= 0x3000
->
Y = xfx
;
0x1000 /\ Infix =:= 0x1000
->
Y = xfy
;
Y = yfx
).
'$get_posfix'(Posfix, X, Y) :-
Posfix > 0,
X is Posfix /\ 0xfff,
(
0x1000 /\ Posfix =:= 0x1000
->
Y = xf
;
Y = yf
).
%%% Operating System utilities
cd :-
cd('~').
ls :-
getcwd(X),
'$load_system_ls'(X,L),
'$do_print_files'(L).
'$load_system_ls'(X,L) :-
'$undefined'(directory_files(X, L), operating_system_support),
load_files(library(system),[silent(true)]),
fail.
'$load_system_ls'(X,L) :-
operating_system_support:directory_files(X, L).
'$do_print_files'([]) :-
nl.
'$do_print_files'([F| Fs]) :-
'$do_print_file'(F),
'$do_print_files'(Fs).
'$do_print_file'('.') :- !.
'$do_print_file'('..') :- !.
'$do_print_file'(F) :- atom_concat('.', _, F), !.
'$do_print_file'(F) :-
write(F), write(' ').
pwd :-
getcwd(X),
write(X), nl.
unix(V) :- var(V), !,
'$do_error'(instantiation_error,unix(V)).
unix(argv(L)) :- '$is_list_of_atoms'(L,L), !, '$argv'(L).
unix(argv(V)) :-
'$do_error'(type_error(atomic,V),unix(argv(V))).
unix(cd) :- cd('~').
unix(cd(V)) :- var(V), !,
'$do_error'(instantiation_error,unix(cd(V))).
unix(cd(A)) :- atomic(A), !, cd(A).
unix(cd(V)) :-
'$do_error'(type_error(atomic,V),unix(cd(V))).
unix(environ(X,Y)) :- '$do_environ'(X,Y).
unix(getcwd(X)) :- getcwd(X).
unix(shell(V)) :- var(V), !,
'$do_error'(instantiation_error,unix(shell(V))).
unix(shell(A)) :- atom(A), !, '$shell'(A).
unix(shell(V)) :-
'$do_error'(type_error(atomic,V),unix(shell(V))).
unix(system(V)) :- var(V), !,
'$do_error'(instantiation_error,unix(system(V))).
unix(system(A)) :- atom(A), !, system(A).
unix(system(V)) :-
'$do_error'(type_error(atom,V),unix(system(V))).
unix(shell) :- sh.
unix(putenv(X,Y)) :- '$putenv'(X,Y).
'$is_list_of_atoms'(V,_) :- var(V),!.
'$is_list_of_atoms'([],_) :- !.
'$is_list_of_atoms'([H|L],L0) :- !,
'$check_if_head_may_be_atom'(H,L0),
'$is_list_of_atoms'(L,L0).
'$is_list_of_atoms'(H,L0) :-
'$do_error'(type_error(list,H),unix(argv(L0))).
'$check_if_head_may_be_atom'(H,_) :-
var(H), !.
'$check_if_head_may_be_atom'(H,_) :-
atom(H), !.
'$check_if_head_may_be_atom'(H,L0) :-
'$do_error'(type_error(atom,H),unix(argv(L0))).
'$do_environ'(X, Y) :-
var(X), !,
'$do_error'(instantiation_error,unix(environ(X,Y))).
'$do_environ'(X, Y) :- atom(X), !,
'$getenv'(X,Y).
'$do_environ'(X, Y) :-
'$do_error'(type_error(atom,X),unix(environ(X,Y))).
putenv(Na,Val) :-
'$putenv'(Na,Val).
getenv(Na,Val) :-
'$getenv'(Na,Val).
%%% Saving and restoring a computation
save(A) :- save(A,_).
save(A,_) :- var(A), !,
'$do_error'(instantiation_error,save(A)).
save(A,OUT) :- atom(A), !, atom_codes(A,S), '$save'(S,OUT).
save(S,OUT) :- '$save'(S,OUT).
save_program(A) :- var(A), !,
'$do_error'(instantiation_error,save_program(A)).
save_program(A) :- atom(A), !,
atom_codes(A,S),
'$save_program2'(S, true).
save_program(S) :- '$save_program2'(S, true).
save_program(A, G) :- var(A), !,
'$do_error'(instantiation_error, save_program(A,G)).
save_program(A, G) :- var(G), !,
'$do_error'(instantiation_error, save_program(A,G)).
save_program(A, G) :- \+ callable(G), !,
'$do_error'(type_error(callable,G), save_program(A,G)).
save_program(A, G) :-
( atom(A) -> atom_codes(A,S) ; A = S),
'$save_program2'(S, G),
fail.
save_program(_,_).
'$save_program2'(S,G) :-
(
G == true
->
true
;
recorda('$restore_goal', G ,R)
),
(
'$undefined'(reload_foreign_libraries, shlib)
->
true
;
recorda('$reload_foreign_libraries', true, R1)
),
'$save_program'(S),
(
var(R1)
->
true
;
erase(R1)
),
(
var(R)
->
true
;
erase(R)
),
fail.
'$save_program2'(_,_).
restore(A) :- var(A), !,
'$do_error'(instantiation_error,restore(A)).
restore(A) :- atom(A), !, name(A,S), '$restore'(S).
restore(S) :- '$restore'(S).
prolog :-
'$live'.
%%% current ....
recordaifnot(K,T,R) :-
recorded(K,T,R), % force non-det binding to R.
'$still_variant'(R,T),
!,
fail.
recordaifnot(K,T,R) :-
recorda(K,T,R).
recordzifnot(K,T,R) :-
recorded(K,T,R),
'$still_variant'(R,T),
!,
fail.
recordzifnot(K,T,R) :-
recordz(K,T,R).
current_atom(A) :- % check
atom(A), !.
current_atom(A) :- % generate
'$current_atom'(A).
current_atom(A) :- % generate
'$current_wide_atom'(A).
atom_concat(X,Y,At) :-
(
nonvar(X), nonvar(Y)
->
atom_concat([X,Y],At)
;
atom(At) ->
'$atom_contact_split'(At,X,Y)
;
var(At) ->
'$do_error'(instantiation_error,atom_concat(X,Y,At))
;
'$do_error'(type_error(atom,At),atomic_concat(X,Y,At))
).
'$atom_contact_split'(At,X,Y) :-
nonvar(X), !,
atom_codes(At, Codes),
atom_codes(X, Xs),
lists:append(Xs,Ys,Codes),
atom_codes(Y, Ys).
'$atom_contact_split'(At,X,Y) :-
nonvar(Y), !,
atom_codes(At, Codes),
atom_codes(Y, Ys),
once(lists:append(Xs,Ys,Codes)),
atom_codes(X, Xs).
'$atom_contact_split'(At,X,Y) :-
atom_codes(At, Codes),
lists:append(Xs, Ys, Codes),
atom_codes(X, Xs),
atom_codes(Y, Ys).
atomic_list_concat(L,At) :-
atomic_concat(L, At).
atomic_list_concat(L, El, At) :-
var(El), !,
'$do_error'(instantiation_error,atom_list_concat(L,El,At)).
atomic_list_concat(L, El, At) :-
nonvar(L), !,
'$add_els'(L,El,LEl),
atomic_concat(LEl, At).
atomic_list_concat(L, El, At) :-
nonvar(At), !,
atom_codes(At, S),
atom_codes(El, [ElS]),
'$split_elements'(S, ElS, SubS),
'$atomify_list'(SubS, L).
'$add_els'([A,B|L],El,[A,El|NL]) :- !,
'$add_els'([B|L],El,NL).
'$add_els'(L,_,L).
'$split_elements'(E.S, E, SubS) :- !,
'$split_elements'(S, E, SubS).
'$split_elements'(E1.S, E, [E1|L].SubS) :- !,
'$split_elements'(S, E, L, SubS).
'$split_elements'([], _, []).
'$split_elements'([], _, [], []).
'$split_elements'(E.S, E, [], SubS) :- !,
'$split_elements'(S, E, SubS).
'$split_elements'(E1.S, E, E1.L, SubS) :-
'$split_elements'(S, E, L, SubS).
'$atomify_list'([], []).
'$atomify_list'(S.SubS, A.L) :-
atom_codes(A, S),
'$atomify_list'(SubS, L).
atomic_concat(X,Y,At) :-
(
nonvar(X), nonvar(Y)
->
atomic_concat([X,Y],At)
;
atom(At) ->
atom_length(At,Len),
'$atom_contact_split'(At,X,Y)
;
number(At) ->
'$number_contact_split'(At,X,Y)
;
var(At) ->
'$do_error'(instantiation_error,atomic_concat(X,Y,At))
;
'$do_error'(type_error(atomic,At),atomic_concat(X,Y,At))
).
'$number_contact_split'(At,X,Y) :-
nonvar(X), !,
number_codes(At, Codes),
name(X, Xs),
lists:append(Xs,Ys,Codes),
name(Y, Ys).
'$number_contact_split'(At,X,Y) :-
nonvar(Y), !,
number_codes(At, Codes),
name(Y, Ys),
once(lists:append(Xs,Ys,Codes)),
name(X, Xs).
'$number_contact_split'(At,X,Y) :-
number_codes(At, Codes),
lists:append(Xs, Ys, Codes),
name(X, Xs),
name(Y, Ys).
sub_atom(At, Bef, Size, After, SubAt) :-
% extract something from an atom
atom(At), integer(Bef), integer(Size), !,
'$sub_atom_extract'(At, Bef, Size, After, SubAt).
sub_atom(At, Bef, Size, After, SubAt) :-
% extract subatom from an atom
atom(At), atom(SubAt), !,
'$sub_atom_fetch'(At, Bef, Size, After, SubAt).
sub_atom(At, Bef, Size, After, SubAt) :-
atom(At), !,
atom_codes(At, Atl),
'$sub_atom2'(Bef, Atl, Size, After, SubAt, sub_atom(At, Bef, Size, After, SubAt)).
sub_atom(At, Bef, Size, After, SubAt) :-
var(At), !,
'$do_error'(instantiation_error,sub_atom(At, Bef, Size,After, SubAt)).
sub_atom(At, Bef, Size, After, SubAt) :-
\+ atom(At), !,
'$do_error'(type_error(atom,At),sub_atom(At, Bef, Size,After, SubAt)).
'$sub_atom2'(Bef, Atl, Size, After, SubAt, ErrorTerm) :-
var(Bef), !,
'$sub_atombv'(Bef, Size, After, SubAt, Atl, ErrorTerm).
'$sub_atom2'(Bef, Atl, Size, After, SubAt, ErrorTerm) :-
'$sub_atom_get_subchars'(Bef, Atl, NewAtl),
'$sub_atom3'(Size, After, SubAt, NewAtl, ErrorTerm).
% if SubAt is bound, the rest is deterministic.
'$sub_atom3'(Size, After, SubAt, Atl, ErrorTerm) :-
nonvar(SubAt), !,
'$sub_atom_needs_atom'(SubAt,ErrorTerm),
'$sub_atom_needs_int'(Size,ErrorTerm),
'$sub_atom_needs_int'(After,ErrorTerm),
atom_codes(SubAt,Atls),
'$$_length1'(Atls, 0, Size),
'$sub_atom_get_subchars_and_match'(Size, Atl, Atls, NAtl),
'$$_length1'(NAtl,0,After).
% SubAt is unbound, but Size is bound
'$sub_atom3'(Size, After, SubAt, Atl, ErrorTerm) :-
nonvar(Size), !,
'$sub_atom_needs_int'(Size,ErrorTerm),
'$sub_atom_needs_int'(After,ErrorTerm),
'$sub_atom_get_subchars_and_match'(Size, Atl, SubAts, NAtl),
'$$_length1'(NAtl,0,After),
atom_codes(SubAt,SubAts).
% SubAt and Size are unbound, but After is bound.
'$sub_atom3'(Size, After, SubAt, Atl, ErrorTerm) :-
nonvar(After), !,
'$sub_atom_needs_int'(After,ErrorTerm),
'$sub_atom_get_last_subchars'(Atl,SubAts,After,Total,Size),
Total >= After,
atom_codes(SubAt,SubAts).
% SubAt, Size, and After are unbound.
'$sub_atom3'(Size, After, SubAt, Atl, _) :-
'$$_length1'(Atl,0,Len),
'$sub_atom_split'(Atl,Len,SubAts,Size,_,After),
atom_codes(SubAt,SubAts).
% Bef is unbound, so we've got three hypothesis
% ok: in the best case we just try to find SubAt in the original atom.
'$sub_atombv'(Bef, Size, After, SubAt, Atl, ErrorTerm) :-
nonvar(SubAt), !,
'$sub_atom_needs_atom'(SubAt, ErrorTerm),
atom_codes(SubAt,SubAts),
'$sub_atom_search'(SubAts, Atl, 0, Bef, AfterS),
'$$_length1'(SubAts, 0, Size),
'$$_length1'(AfterS, 0, After).
% ok: in the second best case we just get rid of the tail
'$sub_atombv'(Bef, Size, After, SubAt, Atl, ErrorTerm) :-
nonvar(After), !,
'$sub_atom_needs_int'(After, ErrorTerm),
'$sub_atom_get_last_subchars'(Atl,SubAt0,After,Total,Size0),
Total >= After,
'$sub_atom_split'(SubAt0,Size0,_,Bef,SubAts,Size),
atom_codes(SubAt,SubAts).
% ok: just do everything
'$sub_atombv'(Bef, Size, After, SubAt, Atl, _) :-
'$$_length1'(Atl, 0, Len),
'$sub_atom_split'(Atl,Len,_,Bef,Atls2,Len2),
'$sub_atom_split'(Atls2,Len2,SubAts,Size,_,After),
atom_codes(SubAt,SubAts).
'$sub_atom_search'([], AfterS, BefSize, BefSize, AfterS).
'$sub_atom_search'([C|SubAts], [C|Atl], BefSize, BefSize, AfterS) :-
'$sub_atom_search2'(SubAts, Atl, AfterS).
'$sub_atom_search'([C|SubAts], [_|Atl], BefSize, BefSizeF, AfterS) :-
NBefSize is BefSize+1,
'$sub_atom_search'([C|SubAts], Atl, NBefSize, BefSizeF, AfterS).
'$sub_atom_search2'([], AfterS, AfterS).
'$sub_atom_search2'([C|SubAts], [C|Atl], AfterS) :-
'$sub_atom_search2'(SubAts, Atl, AfterS).
'$sub_atom_get_subchars'(0, Atl, Atl) :- !.
'$sub_atom_get_subchars'(I0, [_|Atl], NAtl) :-
I is I0-1,
'$sub_atom_get_subchars'(I, Atl, NAtl).
'$sub_atom_get_subchars'(0, Atl, [], Atl) :- !.
'$sub_atom_get_subchars'(I0, [C|Atl], [C|L], NAtl) :-
I is I0-1,
'$sub_atom_get_subchars'(I, Atl, L, NAtl).
'$sub_atom_get_subchars_and_match'(0, Atl, [], Atl) :- !.
'$sub_atom_get_subchars_and_match'(I0, [C|Atl], [C|Match], NAtl) :-
I is I0-1,
'$sub_atom_get_subchars_and_match'(I, Atl, Match, NAtl).
'$sub_atom_check_length'([],0).
'$sub_atom_check_length'([_|L],N1) :-
N1 > 0,
N is N1-1,
'$sub_atom_check_length'(L,N).
'$sub_atom_get_last_subchars'([],[],_,0,0).
'$sub_atom_get_last_subchars'([C|Atl],SubAt,After,Total,Size) :-
'$sub_atom_get_last_subchars'(Atl,SubAt0,After,Total0,Size0),
Total is Total0+1,
( Total > After ->
Size is Size0+1, SubAt = [C|SubAt0]
;
Size = Size0, SubAt = SubAt0
).
'$sub_atom_split'(Atl,After,[],0,Atl,After).
'$sub_atom_split'([C|Atl],Len,[C|Atls],Size,NAtl,After) :-
Len1 is Len-1,
'$sub_atom_split'(Atl,Len1,Atls,Size0,NAtl,After),
Size is Size0+1.
'$sub_atom_needs_int'(V,_) :- var(V), !.
'$sub_atom_needs_int'(I,_) :- integer(I), I >= 0, !.
'$sub_atom_needs_int'(I,ErrorTerm) :- integer(I), !,
'$do_error'(domain_error(not_less_than_zero,I),ErrorTerm).
'$sub_atom_needs_int'(I,ErrorTerm) :-
'$do_error'(type_error(integer,I),ErrorTerm).
'$sub_atom_needs_atom'(V,_) :- var(V), !.
'$sub_atom_needs_atom'(A,_) :- atom(A), !.
'$sub_atom_needs_atom'(A,ErrorTerm) :-
'$do_error'(type_error(atom,A),ErrorTerm).
'$singletons_in_term'(T,VL) :-
'$variables_in_term'(T,[],V10),
'$sort'(V10, V1),
'$non_singletons_in_term'(T,[],V20),
'$sort'(V20, V2),
'$subtract_lists_of_variables'(V2,V1,VL).
'$subtract_lists_of_variables'([],VL,VL).
'$subtract_lists_of_variables'([_|_],[],[]) :- !.
'$subtract_lists_of_variables'([V1|VL1],[V2|VL2],VL) :-
V1 == V2, !,
'$subtract_lists_of_variables'(VL1,VL2,VL).
'$subtract_lists_of_variables'([V1|VL1],[V2|VL2],[V2|VL]) :-
'$subtract_lists_of_variables'([V1|VL1],VL2,VL).
atom_to_term(Atom, Term, Bindings) :-
atom_codes(Atom, Chars),
charsio:open_mem_read_stream(Chars, Stream),
catch(read_term(Stream, T, [variable_names(Bindings)]),Error,'$handle_atom_to_term_error'(Stream, Error)),
close(Stream),
T = Term.
'$handle_atom_to_term_error'(Stream, Error) :-
close(Stream),
throw(Error).
term_to_atom(Term,Atom) :-
nonvar(Atom), !,
atom_codes(Atom,S),
charsio:read_from_chars(S,Term).
term_to_atom(Term,Atom) :-
charsio:write_to_chars(Term,S),
atom_codes(Atom,S).
%
% hack this here.
%
charsio:write_to_chars(Term, L0, OUT) :-
charsio:open_mem_write_stream(Stream),
prolog:write(Stream, Term),
charsio:peek_mem_write_stream(Stream, L0, O),
prolog:close(Stream),
O = OUT.
charsio:read_from_chars(Chars, Term) :-
charsio:open_mem_read_stream(Chars, Stream),
prolog:read(Stream, T),
prolog:close(Stream),
T = Term.
simple(V) :- var(V), !.
simple(A) :- atom(A), !.
simple(N) :- number(N).
callable(V) :- var(V), !, fail.
callable(V) :- atom(V), !.
callable(V) :- functor(V,_,Ar), Ar > 0.
nth_instance(Key,Index,Ref) :-
nonvar(Key), var(Index), var(Ref), !,
recorded(Key,_,Ref),
'$nth_instance'(_,Index,Ref).
nth_instance(Key,Index,Ref) :-
'$nth_instance'(Key,Index,Ref).
nth_instance(Key,Index,T,Ref) :-
nonvar(Key), var(Index), var(Ref), !,
recorded(Key,T,Ref),
'$nth_instance'(_,Index,Ref).
nth_instance(Key,Index,T,Ref) :-
'$nth_instance'(Key,Index,Ref),
instance(Ref,T).
nb_current(GlobalVariable, Val) :-
'$nb_current'(GlobalVariable),
nb_getval(GlobalVariable, Val).
'$getval_exception'(GlobalVariable, Val, Caller) :-
user:exception(undefined_global_variable, GlobalVariable, Action),
!,
(
Action == fail
->
fail
;
Action == retry
->
b_getval(GlobalVariable, Val)
;
Action == error
->
'$do_error'(existence_error(variable, GlobalVariable),Caller)
;
'$do_error'(type_error(atom, Action),Caller)
).
subsumes_term(A,B) :-
\+ \+ terms:subsumes(A,B).
yap-6.2.2/pl/yapor.yap 000644 000765 000024 00000022045 11457004725 014540 0 ustar 00vsc staff 000000 000000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% 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 %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
:- meta_predicate
or_statistics(:,:),
opt_statistics(:,:),
default_sequential(:).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% or_statistics/2 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% should match with code in OPTYap/opt.preds.c
or_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
or_statistics(or_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(4,BytesInUse,StructsInUse).
or_statistics(query_goal_solution_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(12,BytesInUse,StructsInUse).
or_statistics(query_goal_answer_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(13,BytesInUse,StructsInUse).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% opt_statistics/2 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% should match with code in OPTYap/opt.preds.c
opt_statistics(total_memory,[BytesInUse,BytesAllocated]) :-
'$c_get_optyap_statistics'(0,BytesInUse,BytesAllocated).
opt_statistics(table_entries,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(1,BytesInUse,StructsInUse).
opt_statistics(subgoal_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(2,BytesInUse,StructsInUse).
opt_statistics(dependency_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(3,BytesInUse,StructsInUse).
opt_statistics(or_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(4,BytesInUse,StructsInUse).
opt_statistics(suspension_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(5,BytesInUse,StructsInUse).
opt_statistics(subgoal_trie_nodes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(6,BytesInUse,StructsInUse).
opt_statistics(answer_trie_nodes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(7,BytesInUse,StructsInUse).
opt_statistics(subgoal_trie_hashes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(8,BytesInUse,StructsInUse).
opt_statistics(answer_trie_hashes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(9,BytesInUse,StructsInUse).
opt_statistics(global_trie_nodes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(10,BytesInUse,StructsInUse).
opt_statistics(global_trie_hashes,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(11,BytesInUse,StructsInUse).
opt_statistics(query_goal_solution_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(12,BytesInUse,StructsInUse).
opt_statistics(query_goal_answer_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(13,BytesInUse,StructsInUse).
opt_statistics(table_subgoal_solution_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(14,BytesInUse,StructsInUse).
opt_statistics(table_subgoal_answer_frames,[BytesInUse,StructsInUse]) :-
'$c_get_optyap_statistics'(15,BytesInUse,StructsInUse).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% default_sequential/1 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
default_sequential(X) :-
'$c_default_sequential'(X), !.
default_sequential(_).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $parallel_query/2 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'$parallel_query'(G,[]) :- !,
'$c_start_yapor',
'$execute'(G), !,
'$c_parallel_yes_answer'.
'$parallel_query'(G,V) :-
'$c_start_yapor',
'$execute'(G),
'$c_parallel_new_answer'(V).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $sequential/0 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'$sequential' :-
'$c_default_sequential'(X),
'$initialization'('$c_default_sequential'(X)),
'$c_default_sequential'(on).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $parallel/0 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'$parallel' :-
'$c_default_sequential'(X),
'$initialization'('$c_default_sequential'(X)),
'$c_default_sequential'(off).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $sequential_directive/2 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'$sequential_directive'(Pred,Mod) :-
var(Pred), !,
'$do_error'(instantiation_error,sequential(Mod:Pred)).
'$sequential_directive'(Mod:Pred,_) :- !,
'$sequential_directive'(Pred,Mod).
'$sequential_directive'((Pred1,Pred2),Mod) :- !,
'$sequential_directive'(Pred1,Mod),
'$sequential_directive'(Pred2,Mod).
'$sequential_directive'(PredName/PredArity,Mod) :-
atom(PredName), integer(PredArity),
functor(PredFunctor,PredName,PredArity), !,
'$flags'(PredFunctor,Mod,Flags,Flags),
(
Flags /\ 0x1991F880 =:= 0, !,
(
Flags /\ 0x00000020 =\= 0, !,
write(user_error, '[ Warning: '),
write(user_error, Mod:PredName/PredArity),
write(user_error, ' is already declared as sequential ]'),
nl(user_error)
;
NewFlags is Flags \/ 0x00000020,
'$flags'(PredFunctor,Mod,Flags,NewFlags)
)
;
write(user_error, '[ Error: '),
write(user_error, Mod:PredName/PredArity),
write(user_error, ' cannot be declared as sequential ]'),
nl(user_error),
fail
).
'$sequential_directive'(Pred,Mod) :-
'$do_error'(type_error(callable,Mod:Pred),sequential(Mod:Pred)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $parallel_directive/2 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'$parallel_directive'(Pred,Mod) :-
var(Pred), !,
'$do_error'(instantiation_error,parallel(Mod:Pred)).
'$parallel_directive'((Pred1,Pred2),Mod) :- !,
'$parallel_directive'(Pred1,Mod),
'$parallel_directive'(Pred2,Mod).
'$parallel_directive'(Mod:Pred,_) :- !,
'$parallel_directive'(Pred,Mod).
'$parallel_directive'(PredName/PredArity,Mod) :-
atom(PredName), integer(PredArity),
functor(PredFunctor,PredName,PredArity), !,
'$flags'(PredFunctor,Mod,Flags,Flags),
(
Flags /\ 0x1991F880 =:= 0, !,
(
Flags /\ 0x00000020 =:= 0, !,
write(user_error, '[ Warning: '),
write(user_error, Mod:PredName/PredArity),
write(user_error, ' is already declared as parallel ]'),
nl(user_error)
;
NewFlags is Flags /\ 0xffffffdf,
'$flags'(PredFunctor,Mod,Flags,NewFlags)
)
;
write(user_error, '[ Error: '),
write(user_error, Mod:PredName/PredArity),
write(user_error, ' cannot be declared as parallel ]'),
nl(user_error),
fail
).
'$parallel_directive'(Pred,Mod) :-
'$do_error'(type_error(callable,Mod:Pred),parallel(Mod:Pred)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% $parallelizable/1 %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'$parallelizable'(_) :-
nb_getval('$consulting_file',S), S\=[], !, fail.
'$parallelizable'((G1,G2)) :- !,
'$parallelizable'(G1),
'$parallelizable'(G2).
'$parallelizable'((G1;G2)) :- !,
'$parallelizable'(G1),
'$parallelizable'(G2).
'$parallelizable'((G1|G2)) :- !,
'$parallelizable'(G1),
'$parallelizable'(G2).
'$parallelizable'((G1->G2)) :- !,
'$parallelizable'(G1),
'$parallelizable'(G2).
'$parallelizable'([]) :- !, fail.
'$parallelizable'([_|_]) :- !, fail.
'$parallelizable'(consult(_)) :- !, fail.
'$parallelizable'(reconsult(_)) :- !, fail.
'$parallelizable'(compile(_)) :- !, fail.
'$parallelizable'(use_module(_)) :- !, fail.
'$parallelizable'(_).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
yap-6.2.2/pl/yio.yap 000644 000765 000024 00000112553 11501410005 014170 0 ustar 00vsc staff 000000 000000 /*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: yio.yap *
* Last rev: *
* mods: *
* comments: Input output predicates *
* *
*************************************************************************/
/* stream predicates */
open(Source,M,T) :- var(Source), !,
'$do_error'(instantiation_error,open(Source,M,T)).
open(Source,M,T) :- var(M), !,
'$do_error'(instantiation_error,open(Source,M,T)).
open(Source,M,T) :- nonvar(T), !,
'$do_error'(uninstantiation_error(T),open(Source,M,T)).
open(File0,Mode,Stream) :-
'$default_encoding'(Encoding),
'$default_expand'(Expansion),
'$expand_filename'(Expansion, File0, File),
'$open'(File, Mode, Stream, 16, Encoding, File0).
close(V) :- var(V), !,
'$do_error'(instantiation_error,close(V)).
close(File) :-
atom(File), !,
(
'$access_yap_flags'(8, 0),
current_stream(_,_,Stream),
'$user_file_name'(Stream,File)
->
'$close'(Stream)
;
'$close'(File)
).
close(Stream) :-
'$close'(Stream).
close(V,Opts) :- var(V), !,
'$do_error'(instantiation_error,close(V,Opts)).
close(S,Opts) :-
'$check_io_opts'(Opts,close(S,Opts)),
/* YAP ignores the force/1 flag */
close(S).
open(F,T,S,Opts) :-
'$check_io_opts'(Opts,open(F,T,S,Opts)),
'$process_open_opts'(Opts, 0, N, Aliases, E, BOM, Expand),
'$expand_filename'(Expand, F, NF),
'$open2'(NF, T, S, N, E, F),
'$process_bom'(S, BOM),
'$process_open_aliases'(Aliases,S).
'$expand_filename'(false, F, F) :- !.
'$expand_filename'(true, F, NF) :-
operating_system_support:true_file_name(F, NF).
'$open2'(Source,M,T,N,_,_) :- var(Source), !,
'$do_error'(instantiation_error,open(Source,M,T,N)).
'$open2'(Source,M,T,N,_,_) :- var(M), !,
'$do_error'(instantiation_error,open(Source,M,T,N)).
'$open2'(Source,M,T,N,_,_) :- nonvar(T), !,
'$do_error'(uninstantiation_error(T),open(Source,M,T,N)).
'$open2'(File, Mode, Stream, N, Encoding, F0) :-
'$open'(File, Mode, Stream, N, Encoding, F0).
'$process_bom'(S, BOM) :-
var(BOM), !, ( '$has_bom'(S) -> BOM = true ; BOM = false ).
'$process_bom'(_, _).
'$process_open_aliases'([],_).
'$process_open_aliases'([Alias|Aliases],S) :-
'$add_alias_to_stream'(Alias, S),
'$process_open_aliases'(Aliases,S).
'$process_open_opts'([], N, N, [], DefaultEncoding, [], DefaultExpand) :-
'$default_encoding'(DefaultEncoding),
'$default_expand'(DefaultExpand).
'$process_open_opts'([type(T)|L], N0, N, Aliases, Encoding, BOM, DefaultExpand) :-
'$value_open_opt'(T,type,I1,I2),
N1 is I1\/N0,
N2 is I2/\N1,
'$process_open_opts'(L,N2,N, Aliases, Encoding, BOM, DefaultExpand).
'$process_open_opts'([expand_filename(T)|L], N0, N, Aliases, Encoding, BOM, Expand) :-
'$valid_expand'(T, Expand),
'$process_open_opts'(L,N2,N, Aliases, Encoding, BOM, _).
'$process_open_opts'([reposition(T)|L], N0, N, Aliases, Encoding, BOM, DefaultExpand) :-
'$value_open_opt'(T,reposition,I1,I2),
N1 is I1\/N0,
N2 is I2/\N1,
'$process_open_opts'(L,N2,N, Aliases, Encoding, BOM, DefaultExpand).
'$process_open_opts'([encoding(Enc)|L], N0, N, Aliases, EncCode, BOM, DefaultExpand) :-
'$valid_encoding'(Enc, EncCode),
'$process_open_opts'(L, N0, N, Aliases, _, BOM, DefaultExpand).
'$process_open_opts'([representation_errors(Mode)|L], N0, N, Aliases, EncCode, BOM, DefaultExpand) :-
'$valid_reperrorhandler'(Mode, Flag),
NI is N0 \/ Flag,
'$process_open_opts'(L, NI, N, Aliases, EncCode, BOM, DefaultExpand).
'$process_open_opts'([bom(BOM)|L], N0, N, Aliases, EncCode, BOM, DefaultExpand) :-
(
var(BOM)
->
true
;
'$valid_bom'(BOM, Flag),
NI is N0 \/ Flag
),
'$process_open_opts'(L, NI, N, Aliases, EncCode, _, DefaultExpand).
'$process_open_opts'([eof_action(T)|L], N0, N, Aliases, Encoding, BOM, DefaultExpand) :-
'$value_open_opt'(T,eof_action,I1,I2),
N1 is I1\/N0,
N2 is I2/\N1,
'$process_open_opts'(L,N2,N, Aliases, Encoding, BOM, DefaultExpand).
'$process_open_opts'([alias(Alias)|L], N0, N, [Alias|Aliases], Encoding, BOM, DefaultExpand) :-
'$process_open_opts'(L,N0,N, Aliases, Encoding, BOM, DefaultExpand).
'$value_open_opt'(text,_,1,X) :- X is 0xffff-2. % default
'$value_open_opt'(binary,_,2, X) :- X is 0xffff-1.
'$value_open_opt'(true,_,4, X) :- X is 0xffff-8.
'$value_open_opt'(false,_,8, X) :- X is 0xffff-4.
'$value_open_opt'(error,_,16, X) :- X is 0xffff-0x0060.
'$value_open_opt'(eof_code,_,32, X) :- X is 0xffff-0x0050.
'$value_open_opt'(reset, _, 64, X) :- X is 0xffff-0x0030.
%128 -> use bom
%256 -> do not use bom
%512 -> do prolog on unrepresentable char
%1024 -> do XML on unrepresentable char
'$valid_bom'(true, 128).
'$valid_bom'(false, 256).
'$valid_reperrorhandler'(error, 0). % default.
'$valid_reperrorhandler'(prolog, 512).
'$valid_reperrorhandler'(xml, 1024).
'$valid_expand'(true, true).
'$valid_expand'(false, false).
/* check whether a list of options is valid */
'$check_io_opts'(V,G) :- var(V), !,
'$do_error'(instantiation_error,G).
'$check_io_opts'([],_) :- !.
'$check_io_opts'([H|_],G) :- var(H), !,
'$do_error'(instantiation_error,G).
'$check_io_opts'([Opt|T],G) :- !,
'$check_opt'(G,Opt,G),
'$check_io_opts'(T,G).
'$check_io_opts'(T,G) :-
'$do_error'(type_error(list,T),G).
'$check_opt'(close(_,_),Opt,G) :- !,
(Opt = force(X) ->
'$check_force_opt_arg'(X,G) ;
'$do_error'(domain_error(close_option,Opt),G)
).
'$check_opt'(open(_,_,_,_),Opt,G) :-
'$check_opt_open'(Opt, G).
'$check_opt'(read_term(_,_),Opt,G) :-
'$check_opt_read'(Opt, G).
'$check_opt'(stream_property(_,_),Opt,G) :-
'$check_opt_sp'(Opt, G).
'$check_opt'(write_term(_,_),Opt,G) :-
'$check_opt_write'(Opt, G).
'$check_opt'(yap_flag(_,_),Opt,G) :-
'$check_opt_write'(Opt, G).
'$check_opt_open'(type(T), G) :- !,
'$check_open_type_arg'(T, G).
'$check_opt_open'(reposition(T), G) :- !,
'$check_open_reposition_arg'(T, G).
'$check_opt_open'(alias(T), G) :- !,
'$check_open_alias_arg'(T, G).
'$check_opt_open'(eof_action(T), G) :- !,
'$check_open_eof_action_arg'(T, G).
'$check_opt_open'(encoding(T), G) :- !,
'$check_open_encoding'(T, G).
'$check_opt_open'(representation_errors(M), G) :- !,
'$check_open_representation_errors'(M, G).
'$check_opt_open'(bom(T), G) :- !,
'$check_open_bom_arg'(T, G).
'$check_opt_open'(A, G) :-
'$do_error'(domain_error(stream_option,A),G).
'$check_opt_read'(variables(_), _) :- !.
'$check_opt_read'(variable_names(_), _) :- !.
'$check_opt_read'(singletons(_), _) :- !.
'$check_opt_read'(syntax_errors(T), G) :- !,
'$check_read_syntax_errors_arg'(T, G).
'$check_opt_read'(term_position(_), _) :- !.
'$check_opt_read'(module(_), _) :- !.
'$check_opt_read'(A, G) :-
'$do_error'(domain_error(read_option,A),G).
'$check_opt_sp'(file_name(_), _) :- !.
'$check_opt_sp'(mode(_), _) :- !.
'$check_opt_sp'(input, _) :- !.
'$check_opt_sp'(output, _) :- !.
'$check_opt_sp'(alias(_), _) :- !.
'$check_opt_sp'(position(_), _) :- !.
'$check_opt_sp'(end_of_stream(_), _) :- !.
'$check_opt_sp'(eof_action(_), _) :- !.
'$check_opt_sp'(reposition(_), _) :- !.
'$check_opt_sp'(type(_), _) :- !.
'$check_opt_sp'(bom(_), _) :- !.
'$check_opt_sp'(encoding(_), _) :- !.
'$check_opt_sp'(representation_errors(_), _) :- !.
'$check_opt_sp'(A, G) :-
'$do_error'(domain_error(stream_property,A),G).
'$check_opt_write'(attributes(T), G) :- !,
'$check_write_attributes'(T, G).
'$check_opt_write'(cycles(T), G) :- !,
'$check_boolean'(T, write_option, cycles(T), G).
'$check_opt_write'(quoted(T), G) :- !,
'$check_boolean'(T, write_option, quoted(T), G).
'$check_opt_write'(ignore_ops(T), G) :- !,
'$check_boolean'(T, write_option, ignore_ops(T), G).
'$check_opt_write'(max_depth(T), G) :- !,
'$check_write_max_depth'(T, G).
'$check_opt_write'(numbervars(T), G) :- !,
'$check_boolean'(T, write_option, ignore_ops(T), G).
'$check_opt_write'(portrayed(T), G) :- !,
'$check_boolean'(T, write_option, portrayed(T), G).
'$check_opt_write'(portray(T), G) :- !,
'$check_boolean'(T, write_option, portray(T), G).
'$check_opt_write'(priority(T), G) :- !,
'$check_priority_arg'(T, G).
'$check_opt_write'(swi(T), G) :- !,
'$check_boolean'(T, write_option, swi(T), G).
'$check_opt_write'(A, G) :-
'$do_error'(domain_error(write_option,A),G).
%
% check force arg
%
'$check_force_opt_arg'(X,G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_force_opt_arg'(true,_) :- !.
'$check_force_opt_arg'(false,_) :- !.
'$check_force_opt_arg'(X,G) :-
'$do_error'(domain_error(close_option,force(X)),G).
'$check_open_type_arg'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_open_type_arg'(text,_) :- !.
'$check_open_type_arg'(binary,_) :- !.
'$check_open_opt_arg'(X,G) :-
'$do_error'(domain_error(io_mode,type(X)),G).
'$check_open_reposition_arg'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_open_reposition_arg'(true,_) :- !.
'$check_open_reposition_arg'(false,_) :- !.
'$check_open_reposition_arg'(X,G) :-
'$do_error'(domain_error(io_mode,reposition(X)),G).
'$check_open_bom_arg'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_open_bom_arg'(true,_) :- !.
'$check_open_bom_arg'(false,_) :- !.
'$check_open_bom_arg'(X,G) :-
'$do_error'(domain_error(io_mode,bom(X)),G).
'$check_open_alias_arg'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_open_alias_arg'(X,G) :- atom(X), !,
( '$check_if_valid_new_alias'(X), X \= user ->
true ;
'$do_error'(permission_error(open, source_sink, alias(X)),G)
).
'$check_open_alias_arg'(X,G) :-
'$do_error'(domain_error(io_mode,alias(X)),G).
'$check_open_eof_action_arg'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_open_eof_action_arg'(error,_) :- !.
'$check_open_eof_action_arg'(eof_code,_) :- !.
'$check_open_eof_action_arg'(reset,_) :- !.
'$check_open_eof_action_arg'(X,G) :-
'$do_error'(domain_error(io_mode,eof_action(X)),G).
'$check_open_encoding'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_open_encoding'(Encoding,_) :-
'$valid_encoding'(Encoding,_), !.
'$check_open_encoding'(Encoding,G) :-
'$do_error'(domain_error(io_mode,encoding(Encoding)),G).
'$check_open_representation_errors'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_open_representation_errors'(RepErrorHandler,_) :-
'$valid_reperrorhandler'(RepErrorHandler,_), !.
'$check_open_representation_errors'(Handler,G) :-
'$do_error'(domain_error(io_mode,representation_errors(Handler)),G).
'$check_read_syntax_errors_arg'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_read_syntax_errors_arg'(dec10,_) :- !.
'$check_read_syntax_errors_arg'(fail,_) :- !.
'$check_read_syntax_errors_arg'(error,_) :- !.
'$check_read_syntax_errors_arg'(quiet,_) :- !.
'$check_read_syntax_errors_arg'(X,G) :-
'$do_error'(domain_error(read_option,syntax_errors(X)),G).
'$check_write_attributes'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_write_attributes'(ignore,_) :- !.
'$check_write_attributes'(dots,_) :- !.
'$check_write_attributes'(write,_) :- !.
'$check_write_attributes'(portray,_) :- !.
'$check_write_attributes'(X,G) :-
'$do_error'(domain_error(write_option,attributes(X)),G).
'$check_boolean'(X, _, _, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_boolean'(true,_,_,_) :- !.
'$check_boolean'(false,_,_,_) :- !.
'$check_boolean'(X,B,T,G) :-
'$do_error'(domain_error(B,T),G).
'$check_write_max_depth'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_write_max_depth'(I,_) :- integer(I), I >= 0, !.
'$check_write_max_depth'(X,G) :-
'$do_error'(domain_error(write_option,max_depth(X)),G).
'$check_priority_arg'(X, G) :- var(X), !,
'$do_error'(instantiation_error,G).
'$check_priority_arg'(I,_) :- integer(I), I >= 0, I =< 1200, !.
'$check_priority_arg'(X,G) :-
'$do_error'(domain_error(write_option,priority(X)),G).
set_input(Stream) :-
'$set_input'(Stream).
set_output(Stream) :-
'$set_output'(Stream).
open_null_stream(S) :- '$open_null_stream'(S).
open_pipe_streams(P1,P2) :- '$open_pipe_stream'(P1, P2).
fileerrors :- set_value(fileerrors,1).
nofileerrors :- set_value(fileerrors,0).
exists(F) :- access_file(F,'$csult').
see(user) :- !, set_input(user_input).
see(F) :- var(F), !,
'$do_error'(instantiation_error,see(F)).
see(F) :- current_input(Stream),
'$user_file_name'(Stream,F).
see(F) :- current_stream(_,read,Stream), '$user_file_name'(Stream,F), !,
set_input(Stream).
see(Stream) :- '$stream'(Stream), current_stream(_,read,Stream), !,
set_input(Stream).
see(F) :- open(F,read,Stream), set_input(Stream).
seeing(File) :- current_input(Stream),
'$user_file_name'(Stream,NFile),
( '$user_file_name'(user_input,NFile) -> File = user ; NFile = File).
seen :- current_input(Stream), '$close'(Stream), set_input(user).
tell(user) :- !, set_output(user_output).
tell(F) :- var(F), !,
'$do_error'(instantiation_error,tell(F)).
tell(F) :- current_output(Stream),
'$user_file_name'(Stream,F), !.
tell(F) :- current_stream(_,write,Stream), '$user_file_name'(Stream, F), !,
set_output(Stream).
tell(Stream) :- '$stream'(Stream), current_stream(_,write,Stream), !,
set_output(Stream).
tell(F) :- open(F,write,Stream), set_output(Stream).
telling(File) :- current_output(Stream),
'$user_file_name'(Stream,NFile),
( '$user_file_name'(user_output,NFile) -> File = user ; File = NFile ).
told :- current_output(Stream), '$close'(Stream), set_output(user).
/* Term IO */
read(T) :-
'$read'(false,T,_,_,_,Err),
(nonvar(Err) ->
print_message(error,Err), fail
;
true
).
read(Stream,T) :-
'$read'(false,T,_,_,_,Err,Stream),
(nonvar(Err) ->
print_message(error,Err), fail
;
true
).
read_term(T, Options) :-
'$check_io_opts'(Options,read_term(T, Options)),
current_input(S),
'$preprocess_read_terms_options'(Options,Module),
'$read_vars'(S,T,Module,Pos,VL),
'$postprocess_read_terms_options'(Options, T, VL, Pos).
read_term(Stream, T, Options) :-
'$check_io_opts'(Options,read_term(T, Options)),
'$preprocess_read_terms_options'(Options,Module),
'$read_vars'(Stream,T,Module,Pos,VL),
'$postprocess_read_terms_options'(Options, T, VL, Pos).
%
% support flags to read
%
'$preprocess_read_terms_options'([],_).
'$preprocess_read_terms_options'([syntax_errors(NewVal)|L],Mod) :- !,
'$get_read_error_handler'(OldVal),
set_value('$read_term_error_handler', OldVal),
'$set_read_error_handler'(NewVal),
'$preprocess_read_terms_options'(L,Mod).
'$preprocess_read_terms_options'([module(Mod)|L],Mod) :- !,
'$preprocess_read_terms_options'(L,Mod).
'$preprocess_read_terms_options'([_|L],Mod) :-
'$preprocess_read_terms_options'(L,Mod).
'$postprocess_read_terms_options'([], _, _, _).
'$postprocess_read_terms_options'([H|Tail], T, VL, Pos) :- !,
'$postprocess_read_terms_option'(H, T, VL, Pos),
'$postprocess_read_terms_options_list'(Tail, T, VL, Pos).
'$postprocess_read_terms_options_list'([], _, _, _).
'$postprocess_read_terms_options_list'([H|Tail], T, VL, Pos) :-
'$postprocess_read_terms_option'(H, T, VL, Pos),
'$postprocess_read_terms_options_list'(Tail, T, VL, Pos).
'$postprocess_read_terms_option'(syntax_errors(_), _, _, _) :-
get_value('$read_term_error_handler', OldVal),
'$set_read_error_handler'(OldVal).
'$postprocess_read_terms_option'(variable_names(Vars), _, VL, _) :-
'$read_term_non_anonymous'(VL, Vars).
'$postprocess_read_terms_option'(singletons(Val), T, VL, _) :-
'$singletons_in_term'(T, Val1),
'$fetch_singleton_names'(Val1,VL,Val).
'$postprocess_read_terms_option'(variables(Val), T, _, _) :-
'$variables_in_term'(T, [], Val).
'$postprocess_read_terms_option'(term_position(Pos), _, _, Pos).
'$postprocess_read_terms_option'(module(_), _, _, _).
%'$postprocess_read_terms_option'(cycles(Val), _, _).
'$read_term_non_anonymous'([], []).
'$read_term_non_anonymous'([[S|V]|VL], [Name=V|Vars]) :-
atom_codes(Name,S),
'$read_term_non_anonymous'(VL, Vars).
% problem is what to do about _ singletons.
% no need to do ordering, the two lists already come ordered.
'$fetch_singleton_names'([], _, []).
'$fetch_singleton_names'([_|_], [], []) :- !.
'$fetch_singleton_names'([V1|Ss], [[Na|V2]|Ns], ONs) :-
V1 == V2, !,
'$add_singleton_if_no_underscore'(Na,V2,NSs,ONs),
'$fetch_singleton_names'(Ss, Ns, NSs).
'$fetch_singleton_names'([V1|Ss], [[_|V2]|Ns], NSs) :-
V1 @> V2, !,
'$fetch_singleton_names'([V1|Ss], Ns, NSs).
'$fetch_singleton_names'([_V1|Ss], Ns, NSs) :-
% V1 @> V2,
'$fetch_singleton_names'(Ss, Ns, NSs).
'$add_singleton_if_no_underscore'([95|_],_,NSs,NSs) :- !.
'$add_singleton_if_no_underscore'(Na,V2,NSs,[(Name=V2)|NSs]) :-
atom_codes(Name, Na).
nl(Stream) :- '$put'(Stream,10).
nl :- current_output(Stream), '$put'(Stream,10), fail.
nl.
/* meaning of flags for '$write' is
1 quote illegal atoms
2 ignore operator declarations
4 output '$VAR'(N) terms as A, B, C, ...
8 use portray(_)
flags are defined in yapio.h
*/
write(T) :- '$write'(4, T).
writeln(T) :-
'$write'(4, T),
nl.
write(Stream,T) :-
'$write'(Stream,4,T).
writeq(T) :- '$write'(5,T).
writeq(Stream,T) :-
'$write'(Stream,5,T),
fail.
writeq(_,_).
display(T) :- '$write'(2,T).
display(Stream,T) :-
'$write'(Stream,2,T),
fail.
display(_,_).
write_canonical(T) :- '$write'(3,T).
write_canonical(Stream,T) :-
'$write'(Stream,3,T),
fail.
write_canonical(_,_).
print(T) :- '$write'(12,T), fail.
print(_).
print(Stream,T) :-
'$write'(Stream,12,T),
fail.
print(_,_).
write_term(T,Opts) :-
'$check_io_opts'(Opts, write_term(T,Opts)),
'$process_wt_opts'(Opts, 0, Flag, Priority, Callbacks),
'$write_with_prio'(Flag, Priority, T),
'$process_wt_callbacks'(Callbacks),
fail.
write_term(_,_).
write_term(S, T, Opts) :-
'$check_io_opts'(Opts, write_term(T,Opts)),
'$process_wt_opts'(Opts, 0, Flag, Priority, Callbacks),
'$write_with_prio'(S, Flag, Priority, T),
'$process_wt_callbacks'(Callbacks),
fail.
write_term(_,_,_).
'$process_wt_opts'([], Flag, Flag, 1200, []).
'$process_wt_opts'([quoted(true)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 \/ 0x01,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([quoted(false)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 /\ \0x01,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([ignore_ops(true)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 \/ 0x02,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([ignore_ops(false)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 /\ \0x02,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([numbervars(true)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 \/ 0x04,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([numbervars(false)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 /\ \0x04,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([portrayed(true)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 \/ 0x08,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([portrayed(false)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 /\ \0x08,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([portray(true)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 \/ 0x08,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([portray(false)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 /\ \0x08,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([cycles(false)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 \/ 0x20,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([cycles(false)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 /\ \0x20,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([swi(true)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 \/ 0x40,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([swi(false)|Opts], Flag0, Flag, Priority, CallBacks) :-
FlagI is Flag0 /\ \0x40,
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([attributes(_)|Opts], Flag0, Flag, Priority, CallBacks) :-
'$process_wt_opts'(Opts, FlagI, Flag, Priority, CallBacks).
'$process_wt_opts'([priority(Priority)|Opts], Flag0, Flag, Priority, CallBacks) :-
'$process_wt_opts'(Opts, Flag0, Flag, _, CallBacks).
'$process_wt_opts'([max_depth(D)|Opts], Flag0, Flag, Priority, [max_depth(D1,D0,D2)|CallBacks]) :-
write_depth(D1,D0,D2),
D10 is D*10,
write_depth(D,D,D10),
'$process_wt_opts'(Opts, Flag0, Flag, Priority, CallBacks).
'$process_wt_callbacks'([]).
'$process_wt_callbacks'([max_depth(D1,D0,D2)|Cs]) :-
write_depth(D1,D0,D2),
'$process_wt_callbacks'(Cs).
format(T) :-
format(T, []).
/* interface to user portray */
'$portray'(T) :-
\+ '$undefined'(portray(_),user),
'$system_catch'(call(portray(T)),user,Error,user:'$Error'(Error)), !,
set_value('$portray',true), fail.
'$portray'(_) :- set_value('$portray',false), fail.
/* character I/O */
get(N) :- current_input(S), get(S,N).
get_byte(V) :-
\+ var(V), (\+ integer(V) ; V < -1 ; V > 256), !,
'$do_error'(type_error(in_byte,V),get_byte(V)).
get_byte(V) :-
current_input(S),
'$get_byte'(S,V).
get_byte(S,V) :-
\+ var(V), (\+ integer(V) ; V < -1 ; V > 256), !,
'$do_error'(type_error(in_byte,V),get_byte(S,V)).
get_byte(S,V) :-
'$get_byte'(S,V).
peek_byte(V) :-
\+ var(V), (\+ integer(V) ; V < -1 ; V > 256), !,
'$do_error'(type_error(in_byte,V),get_byte(V)).
peek_byte(V) :-
current_input(S),
'$peek_byte'(S,V).
peek_byte(S,V) :-
\+ var(V), (\+ integer(V) ; V < -1 ; V > 256), !,
'$do_error'(type_error(in_byte,V),get_byte(S,V)).
peek_byte(S,V) :-
'$peek_byte'(S,V).
get_char(V) :-
\+ var(V),
( atom(V) -> atom_codes(V,[_,_|_]), V \= end_of_file ; true ), !,
'$do_error'(type_error(in_character,V),get_char(V)).
get_char(V) :-
current_input(S),
get0(S,I),
( I = -1 -> V = end_of_file ; atom_codes(V,[I])).
get_char(S,V) :-
\+ var(V),
( atom(V) -> atom_codes(V,[_,_|_]), V \= end_of_file ; true ), !,
'$do_error'(type_error(in_character,V),get_char(S,V)).
get_char(S,V) :-
get0(S,I),
( I = -1 -> V = end_of_file ; atom_codes(V,[I])).
peek_char(V) :-
\+ var(V),
( atom(V) -> atom_codes(V,[_,_|_]), V \= end_of_file ; true ), !,
'$do_error'(type_error(in_character,V),get_char(V)).
peek_char(V) :-
current_input(S),
'$peek'(S,I),
( I = -1 -> V = end_of_file ; atom_codes(V,[I])).
peek_char(S,V) :-
\+ var(V),
( atom(V) -> atom_codes(V,[_,_|_]), V \= end_of_file ; true ), !,
'$do_error'(type_error(in_character,V),get_char(S,V)).
peek_char(S,V) :-
'$peek'(S,I),
( I = -1 -> V = end_of_file ; atom_codes(V,[I])).
get_code(S,V) :-
\+ var(V), (\+ integer(V)), !,
'$do_error'(type_error(in_character_code,V),get_code(S,V)).
get_code(S,V) :-
get0(S,V).
get_code(V) :-
\+ var(V), (\+ integer(V)), !,
'$do_error'(type_error(in_character_code,V),get_code(V)).
get_code(V) :-
current_input(S),
get0(S,V).
peek_code(S,V) :-
\+ var(V), (\+ integer(V)), !,
'$do_error'(type_error(in_character_code,V),get_code(S,V)).
peek_code(S,V) :-
'$peek'(S,V).
peek_code(V) :-
\+ var(V), (\+ integer(V)), !,
'$do_error'(type_error(in_character_code,V),get_code(V)).
peek_code(V) :-
current_input(S),
'$peek'(S,V).
put_byte(V) :- var(V), !,
'$do_error'(instantiation_error,put_byte(V)).
put_byte(V) :-
(\+ integer(V) ; V < 0 ; V > 256), !,
'$do_error'(type_error(byte,V),put_byte(V)).
put_byte(V) :-
current_output(S),
'$put_byte'(S,V).
put_byte(S,V) :- var(V), !,
'$do_error'(instantiation_error,put_byte(S,V)).
put_byte(S,V) :-
(\+ integer(V) ; V < 0 ; V > 256), !,
'$do_error'(type_error(byte,V),put_byte(S,V)).
put_byte(S,V) :-
'$put_byte'(S,V).
put_char(V) :- var(V), !,
'$do_error'(instantiation_error,put_char(V)).
put_char(V) :-
( atom(V) -> atom_codes(V,[_,_|_]) ; true ), !,
'$do_error'(type_error(character,V),put_char(V)).
put_char(V) :-
current_output(S),
atom_codes(V,[I]),
'$put'(S,I).
put_char(S,V) :- var(V), !,
'$do_error'(instantiation_error,put_char(S,V)).
put_char(S,V) :-
( atom(V) -> atom_codes(V,[_,_|_]) ; true ), !,
'$do_error'(type_error(character,V),put_char(S,V)).
put_char(S,V) :-
atom_codes(V,[I]),
'$put'(S,I).
put_code(V) :- var(V), !,
'$do_error'(instantiation_error,put_code(V)).
put_code(V) :-
(\+ integer(V)), !,
'$do_error'(type_error(character_code,V),put_code(V)).
put_code(V) :-
current_output(S),
'$put'(S,V).
put_code(S,V) :- var(V), !,
'$do_error'(instantiation_error,put_code(S,V)).
put_code(S,V) :-
(\+ integer(V)), !,
'$do_error'(type_error(character_code,V),put_code(S,V)).
put_code(S,V) :-
'$put'(S,V).
get0(N) :- current_input(S), get0(S,N).
put(N) :- current_output(S), N1 is N, '$put'(S,N1).
put(Stream,N) :- N1 is N, '$put'(Stream,N1).
skip(N) :- current_input(S), N1 is N, '$skip'(S,N1).
skip(Stream,N) :- N1 is N, '$skip'(Stream,N1).
'$tab'(N) :- N<1, !.
'$tab'(N) :- put(32), N1 is N-1, '$tab'(N1).
tab(N) :- '$tab'(N), fail.
tab(_).
'$tab'(_,N) :- N<1, !.
'$tab'(Stream,N) :- put(Stream,32), N1 is N-1, '$tab'(Stream,N1).
tab(Stream,N) :- '$tab'(Stream,N), fail.
tab(_,_).
ttyget(N) :- get(user_input,N).
ttyget0(N) :- get0(user_input,N).
ttyskip(N) :- N1 is N, '$skip'(user_input,N1).
ttyput(N) :- N1 is N, '$put'(user_output,N1).
ttynl :- nl(user_output).
ttyflush :- flush_output(user_output).
flush_output :-
current_output(Stream),
flush_output(Stream).
current_line_number(N) :-
current_input(Stream), '$current_line_number'(Stream,N).
current_line_number(user,N) :- !,
'$current_line_number'(user_input,N).
current_line_number(A,N) :-
atom(A),
current_stream(_,_,S), '$user_file_name'(S,A), !,
'$current_line_number'(S,N).
current_line_number(S,N) :-
'$current_line_number'(S,N).
line_count(Stream,N) :- current_line_number(Stream,N).
character_count(user,N) :- !,
'$character_count'(user_input,N).
character_count(A,N) :-
atom(A),
current_stream(_,_,S), '$user_file_name'(S,A), !,
'$character_count'(S,N).
character_count(S,N) :-
'$character_count'(S,N).
line_position(user,N) :- !,
'$line_position'(user_input,N).
line_position(A,N) :-
atom(A),
current_stream(_,_,S), '$user_file_name'(S,A), !,
'$line_position'(S,N).
line_position(S,N) :-
'$line_position'(S,N).
stream_position(user,N) :- !,
'$show_stream_position'(user_input,N).
stream_position(A,N) :-
atom(A),
'$current_stream'(_,_,S), '$user_file_name'(S,A), !,
'$show_stream_position'(S,N).
stream_position(S,N) :-
'$show_stream_position'(S,N).
stream_position(user,N,M) :- !,
'$stream_position'(user_input,N,M).
stream_position(A,N,M) :-
atom(A),
'$current_stream'(_,_,S), '$user_file_name'(S,A), !,
'$stream_position'(S,N,M).
stream_position(S,N,M) :-
'$stream_position'(S,N,M).
'$stream_position'(S,N,M) :-
var(M), !,
'$show_stream_position'(S,N),
M = N.
'$stream_position'(S,N,M) :-
'$show_stream_position'(S,N),
'$set_stream_position'(S,M).
set_stream_position(S,N) :- var(S), !,
'$do_error'(instantiation_error, set_stream_position(S, N)).
set_stream_position(user,N) :- !,
'$set_stream_position'(user_input,N).
set_stream_position(A,N) :-
atom(A),
'$current_stream'(_,_,S), '$user_file_name'(S,A), !,
'$set_stream_position'(S,N).
set_stream_position(S,N) :-
'$set_stream_position'(S,N).
stream_property(Stream, Prop) :- var(Prop), !,
(var(Stream) -> '$current_stream'(_,_,Stream) ; true),
'$generate_prop'(Prop),
'$stream_property'(Stream, Prop).
stream_property(Stream, Props) :- var(Stream), !,
'$current_stream'(_,_,Stream),
'$stream_property'(Stream, Props).
stream_property(Stream, Props) :-
'$current_stream'(_,_,Stream), !,
'$stream_property'(Stream, Props).
stream_property(Stream, Props) :-
'$do_error'(domain_error(stream,Stream),stream_property(Stream, Props)).
'$generate_prop'(file_name(_F)).
'$generate_prop'(mode(_M)).
'$generate_prop'(input).
'$generate_prop'(output).
'$generate_prop'(position(_P)).
%'$generate_prop'(end_of_stream(_E)).
'$generate_prop'(eof_action(_E)).
%'$generate_prop'(reposition(_R)).
'$generate_prop'(type(_T)).
'$generate_prop'(alias(_A)).
'$generate_prop'(bom(_B)).
'$generate_prop'(encoding(_E)).
'$generate_prop'(representation_errors(_E)).
'$stream_property'(Stream, Props) :-
var(Props), !,
'$do_error'(instantiation_error, stream_properties(Stream, Props)).
'$stream_property'(Stream, Props0) :-
'$check_stream_props'(Props0, Props),
'$check_io_opts'(Props, stream_property(Stream, Props)),
'$current_stream'(F,Mode,Stream),
'$process_stream_properties'(Props, Stream, F, Mode).
'$check_stream_props'([], []) :- !.
'$check_stream_props'([H|T], [H|T]) :- !.
'$check_stream_props'(Prop, [Prop]).
%
'$process_stream_properties'([], _, _, _).
'$process_stream_properties'([file_name(F)|Props], Stream, F, Mode) :-
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([mode(Mode)|Props], Stream, F, Mode) :-
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([input|Props], Stream, F, read) :-
'$process_stream_properties'(Props, Stream, F, read).
'$process_stream_properties'([output|Props], Stream, F, append) :-
'$process_stream_properties'(Props, Stream, F, append).
'$process_stream_properties'([output|Props], Stream, F, write) :-
'$process_stream_properties'(Props, Stream, F, write).
'$process_stream_properties'([position(P)|Props], Stream, F, Mode) :-
'$show_stream_position'(Stream,P),
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([encoding(Enc)|Props], Stream, F, Mode) :-
% make sure this runs first, with EncCode unbound.
'$encoding'(Stream, EncCode),
'$valid_encoding'(Enc, EncCode),
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([bom(B)|Props], Stream, F, Mode) :-
'$show_stream_bom'(Stream, B),
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([end_of_stream(P)|Props], Stream, F, Mode) :-
'$show_stream_eof'(Stream, P),
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([eof_action(P)|Props], Stream, F, Mode) :-
'$show_stream_flags'(Stream, Fl),
'$show_stream_eof_action'(Fl, P),
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([reposition(P)|Props], Stream, F, Mode) :-
'$show_stream_flags'(Stream, Fl),
'$show_stream_reposition'(Fl, P),
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([representation_errors(B)|Props], Stream, F, Mode) :-
'$stream_representation_error'(Stream, ErrorHandler),
'$valid_reperrorhandler'(B, ErrorHandler),
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([type(P)|Props], Stream, F, Mode) :-
'$show_stream_flags'(Stream, Fl),
'$show_stream_type'(Fl, P),
'$process_stream_properties'(Props, Stream, F, Mode).
'$process_stream_properties'([alias(Alias)|Props], Stream, F, Mode) :-
'$fetch_stream_alias'(Stream, Alias),
'$process_stream_properties'(Props, Stream, F, Mode).
'$show_stream_eof'(Stream, past) :-
'$past_eof'(Stream), !.
'$show_stream_eof'(Stream, at) :-
'$peek'(Stream,N), N = -1, !.
'$show_stream_eof'(_, not).
'$show_stream_eof_action'(Fl, error) :-
Fl /\ 0x0200 =:= 0x0200, !.
'$show_stream_eof_action'(Fl, reset) :-
Fl /\ 0x0400 =:= 0x0400, !.
'$show_stream_eof_action'(_, eof_code).
'$show_stream_reposition'(Fl, true) :-
Fl /\ 0x2000 =:= 0x2000, !.
'$show_stream_reposition'(_, false).
'$show_stream_bom'(Fl, true) :-
'$has_bom'(Fl), !.
'$show_stream_bom'(_, false).
'$show_stream_type'(Fl, binary) :-
Fl /\ 0x0100 =:= 0x0100, !.
'$show_stream_type'(_, text).
at_end_of_stream :-
current_input(S),
at_end_of_stream(S).
at_end_of_stream(S) :-
'$past_eof'(S), !.
at_end_of_stream(S) :-
'$peek'(S,N), N = -1.
at_end_of_line :-
current_input(S),
at_end_of_line(S).
at_end_of_line(S) :-
'$past_eof'(S), !.
at_end_of_line(S) :-
'$peek'(S,N), ( N = 10 -> true ; N = -1).
consult_depth(LV) :- '$show_consult_level'(LV).
current_char_conversion(X,Y) :-
var(X), !,
'$all_char_conversions'(List),
'$fetch_char_conversion'(List,X,Y).
current_char_conversion(X,Y) :-
'$current_char_conversion'(X,Y).
'$fetch_char_conversion'([X,Y|_],X,Y).
'$fetch_char_conversion'([_,_|List],X,Y) :-
'$fetch_char_conversion'(List,X,Y).
current_stream(File, Opts, Stream) :-
'$current_stream'(File, Opts, Stream).
'$extend_file_search_path'(P) :-
atom_codes(P,S),
'$env_separator'(ES),
'$split_for_path'(S,0'=,ES,Paths), %'
'$add_file_search_paths'(Paths).
'$split_for_path'([], _, _, []).
'$split_for_path'(S, S1, S2, [A1=A2|R]) :-
'$fetch_first_path'(S, S1, A1, SR1),
'$fetch_second_path'(SR1, S2, A2, SR),
'$split_for_path'(SR, S1, S2, R) .
'$fetch_first_path'([S1|SR],S1,[],SR) :- !.
'$fetch_first_path'([C|S],S1,[C|F],SR) :-
'$fetch_first_path'(S,S1,F,SR).
'$fetch_second_path'([],_,[],[]).
'$fetch_second_path'([S1|SR],S1,[],SR) :- !.
'$fetch_second_path'([C|S],S1,[C|A2],SR) :-
'$fetch_second_path'(S,S1,A2,SR).
'$add_file_search_paths'([]).
'$add_file_search_paths'([NS=DS|Paths]) :-
atom_codes(N,NS),
atom_codes(D,DS),
assert(user:file_search_path(N,D)),
'$add_file_search_paths'(Paths).
'$format@'(Goal,Out) :-
'$with_output_to_chars'(Goal, _, [], Out).
'$with_output_to_chars'(Goal, Stream, L0, Chars) :-
charsio:open_mem_write_stream(Stream),
current_output(SO),
set_output(Stream),
'$do_output_to_chars'(Goal, Stream, L0, Chars, SO).
'$do_output_to_chars'(Goal, Stream, L0, Chars, SO) :-
catch(Goal, Exception, '$handle_exception'(Exception,Stream,SO)),
!,
set_output(SO),
charsio:peek_mem_write_stream(Stream, L0, Chars),
close(Stream).
'$do_output_to_chars'(_Goal, Stream, _L0, _Chars, SO) :-
set_output(SO),
close(Stream),
fail.
sformat(String, Form, Args) :-
charsio:open_mem_write_stream(Stream),
format(Stream, Form, Args),
charsio:peek_mem_write_stream(Stream, [], String),
close(Stream).
'$handle_exception'(Exception, Stream, SO) :-
set_output(SO),
close(Stream),
throw(Exception).
write_depth(T,L) :- write_depth(T,L,_).
is_stream(S) :-
catch('$check_stream'(S), _, fail), !.
time_file(File, Time) :-
'$file_age'(File, Time).
stream_position_data(line_count, '$stream_position'(_,Data,_,_,_), Data).
stream_position_data(line_position, '$stream_position'(_,_,Data,_,_), Data).
%stream_position_data(char_count, '$stream_position'(Data,_,_,_,_), Data).
stream_position_data(byte_count, '$stream_position'(Data,_,_,_,_), Data).
'$default_expand'(Expand) :-
nb_getval('$open_expands_filename',Expand).
'$set_default_expand'(true) :- !,
nb_setval('$open_expands_filename',true).
'$set_default_expand'(false) :- !,
nb_setval('$open_expands_filename',false).
'$set_default_expand'(V) :- !,
'$do_error'(domain_error(flag_value,V),yap_flag(open_expands_file_name,X)).
prolog_file_name(File, PrologFileName) :-
var(File), !,
'$do_error'(instantiation_error, prolog_file_name(File, PrologFileName)).
prolog_file_name(user, Out) :- !, Out = user.
prolog_file_name(File, PrologFileName) :-
atom(File), !,
operating_system_support:true_file_name(File, PrologFileName).
prolog_file_name(File, PrologFileName) :-
'$do_error'(type_error(atom,T), prolog_file_name(File, PrologFileName)).
with_output_to(Output, Command) :-
setup_call_cleanup( '$setup_wot'(Output, Stream, OldStream, with_output_to(Output, Command)),
once(Command),
'$cleanup_wot'(Output, Stream, OldStream) ).
'$setup_wot'(Output, Stream, OldStream, Goal) :-
'$setup_wot'(Output, Stream, Goal),
current_output(OldStream),
set_output(Stream).
'$setup_wot'(Output, Stream, Goal) :-
var(Output), !,
'$do_error'(instantiation_error,Goal).
'$setup_wot'(atom(_Atom), Stream, _) :- !,
charsio:open_mem_write_stream(Stream).
'$setup_wot'(codes(_Codes), Stream, _) :- !,
charsio:open_mem_write_stream(Stream).
'$setup_wot'(codes(_Codes, _Tail), Stream, _) :- !,
charsio:open_mem_write_stream(Stream).
'$setup_wot'(chars(_Chars), Stream, _) :- !,
charsio:open_mem_write_stream(Stream).
'$setup_wot'(chars(_Chars, _Tail), Stream, _) :- !,
charsio:open_mem_write_stream(Stream).
'$setup_wot'(Stream, Stream, _) :-
'$stream'(Stream), !.
'$setup_wot'(Output, _, Goal) :-
'$do_error'(type_error(output,Output),Goal).
'$cleanup_wot'(Output, Stream, OldStream) :- !,
'$cleanup_wot'(Output, Stream),
set_output(OldStream).
'$cleanup_wot'(atom(Atom), Stream) :- !,
charsio:peek_mem_write_stream(Stream, [], String),
atom_codes(Atom, String),
close(Stream).
'$cleanup_wot'(codes(Codes), Stream) :- !,
charsio:peek_mem_write_stream(Stream, [], Codes),
close(Stream).
'$cleanup_wot'(codes(Codes, Tail), Stream) :- !,
charsio:peek_mem_write_stream(Stream, Tail, Codes),
close(Stream).
'$cleanup_wot'(chars(Chars), Stream) :- !,
charsio:peek_mem_write_stream(Stream, [], String),
'$codes_to_chars'([], String, Chars),
close(Stream).
'$cleanup_wot'(chars(Chars, Tail), Stream) :- !,
charsio:peek_mem_write_stream(Stream, Tail, String),
'$codes_to_chars'(Tail, String, Chars),
close(Stream).
'$cleanup_wot'(_, _).
'$codes_to_chars'(String0, String, String0) :- String0 == String, !.
'$codes_to_chars'(String0, [Code|String], [Char|Chars]) :-
atom_codes(Char, [Code]),
'$codes_to_chars'(String0, String, Chars).
prolog_to_os_filename(Prolog, OS) :-
'$undefined'(swi_prolog_to_os_filename(Prolog, OS), system),
'$current_module'(Old, system),
load_foreign_files([libplstream], [], initIO),
'$current_module'(system, Old),
fail.
prolog_to_os_filename(Prolog, OS) :-
system:swi_prolog_to_os_filename(Prolog, OS).
expand_file_name(Exp, Matches) :-
'$undefined'(swi_expand_file_name(Exp, Matches), system),
'$current_module'(Old, system),
load_foreign_files([libplstream], [], initIO),
'$current_module'(system, Old),
fail.
expand_file_name(Exp, Matches) :-
system:swi_expand_file_name(Exp, Matches).
yap-6.2.2/packages/chr/ 000755 000765 000024 00000000000 11702065320 014576 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/clib/ 000755 000765 000024 00000000000 11702065317 014741 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/CLPBN/ 000755 000765 000024 00000000000 11702065317 014666 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/clpqr/ 000755 000765 000024 00000000000 11702065317 015151 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/cplint/ 000755 000765 000024 00000000000 11702065317 015321 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/http/ 000755 000765 000024 00000000000 11702065317 015007 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/jpl/ 000755 000765 000024 00000000000 11702065317 014615 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/PLStream/ 000755 000765 000024 00000000000 11702065317 015517 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/plunit/ 000755 000765 000024 00000000000 11702065317 015343 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/ProbLog/ 000755 000765 000024 00000000000 11713767477 015416 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/pyswip/ 000755 000765 000024 00000000000 11702065316 015362 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/RDF/ 000755 000765 000024 00000000000 11702065316 014442 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/semweb/ 000755 000765 000024 00000000000 11702065316 015311 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/sgml/ 000755 000765 000024 00000000000 11702065316 014771 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/swi-minisat2/ 000755 000765 000024 00000000000 11702065316 016355 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/tai/ 000755 000765 000024 00000000000 11702065316 014604 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/udi/ 000755 000765 000024 00000000000 11702065316 014610 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/zlib/ 000755 000765 000024 00000000000 11702065316 014767 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/zlib/ChangeLog 000644 000765 000024 00000003431 11457004725 016546 0 ustar 00vsc staff 000000 000000 [Jul 21 2009]
* MODIFIED: Make initialization/1 ISO compliant
This patch is a modest cleanup to the implementation of '$load_file'/3
from init.pl and provides an ISO compatible implementation of
initialization/1. This executes the argument goal *after* loading the
file rather than when encountering the directive. Often this makes no
difference, but notably load_foreign_library/1 is an exception.
Therefore we added use_foreign_library/1,2 that act as a directive and
provides proper integration with saved-states automatically. Loading
code using initialization(load_foreign_library(...)) will load the
library immediately and issue a warning.
See initialization/1,2 for details and further hints for dealing with
possible compatibility problems.
[Mar 19 2009]
* CLEANUP: Removed all trailing whitespace from all source-files. This avoids many GIT (merge) warnings.
[Nov 4 2008]
* FIXED: Copy encoding parameters from parent stream.
[Sep 11 2008]
* PORT: Add AC_PREREQ to configure.h for systems that auto-select autoconf
versions. After tip by Ulrich Neumerkel.
[Aug 11 2008]
* INSTALL: Remove all configure files from the git repository
[Jan 23 2008]
* PORT: Bug#346: Allow overriding COFLAGS and CWFLAGS in package
configuration. Keri Harris.
Jul 28, 2007
* FIXED: Bug#300: memory loss when returning the stream fails. Keri Harris.
May 2, 2007
* FIXED: Compress (deflate) large amounts of data. Added test to ztest.pl.
Matt Lilley.
Apr 26, 2007
* FIXED: Allow passing compressed stream between threads. Matt Lilley.
Apr 23, 2007
* FIXED: Explicit handling of format option in reader.
* FIXED: handling of format(deflate) option.
Jan 1, 2007
* Bug#246: Fixed running tests. Keri Harris.
Dec 21, 2006
* Portability to MacOS
yap-6.2.2/packages/zlib/config.h.in 000644 000765 000024 00000005310 11457004725 017015 0 ustar 00vsc staff 000000 000000 /* config.h.in. Generated from configure.in by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
/* Define to 1 if you have and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if you have the header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the header file. */
#undef HAVE_ZLIB_H
/* Define to 1 if you have the header file. */
#undef HAVE_ZUTIL_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
#undef STACK_DIRECTION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define for multi-thread support */
#undef _REENTRANT
yap-6.2.2/packages/zlib/configure.in 000644 000765 000024 00000001470 11457004725 017306 0 ustar 00vsc staff 000000 000000 dnl Process this file with autoconf to produce a configure script.
AC_INIT(install-sh)
AC_PREREQ([2.50])
AC_CONFIG_HEADER(config.h)
AC_SUBST(TARGETS)
AC_SUBST(PLTARGETS)
m4_include([../ac_swi_c.m4])
AC_CHECK_HEADERS(zlib.h zutil.h)
AC_CHECK_LIB(z, zlibVersion,
LIBS="$LIBS -lz"
ZLIB=yes,
ZLIB=no)
if test "$ZLIB" = yes; then
TARGETS="zlib4pl.$SO"
PLTARGETS=zlib.pl
else
TARGETS=nolib
cat << EOF
##################################################################
# ERROR: Could not find library zlib (-lz). Dropped library(zlib)
# Library zlib is available from http://www.zlib.net/
# Most Unix/Linux distributions are shipped with binaries. Make
# sure to have the development library installed.
##################################################################
EOF
fi
AC_OUTPUT(Makefile)
yap-6.2.2/packages/zlib/Makefile.in 000644 000765 000024 00000007474 11507254050 017046 0 ustar 00vsc staff 000000 000000 ################################################################
# Makefile template for SWI-Prolog CLIB package
#
# This template is used by configure to create Makefile. See
# the file INSTALL for further installation instructions.
#
# License: LGPL
#
# Author: Jan Wielemaker (wielemak@science.uva.nl)
################################################################
.SUFFIXES: .tex .dvi .doc .pl
ifeq (@PROLOG_SYSTEM@,yap)
prefix = @prefix@
exec_prefix = @exec_prefix@
ROOTDIR = $(prefix)
EROOTDIR = @exec_prefix@
abs_top_builddir = @abs_top_builddir@
srcdir=@srcdir@
BINDIR = $(EROOTDIR)/bin
LIBDIR=@libdir@
YAPLIBDIR=@libdir@/Yap
SHAREDIR=$(ROOTDIR)/share/Yap
SHELL=@SHELL@
PL=@INSTALL_ENV@ $(DESTDIR)$(BINDIR)/yap $(DESTDIR)$(YAPLIBDIR)/startup.yss
EXDIR=$(YAPLIBDIR)/examples/http
LN_S=@LN_S@
#
#
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
CC=@CC@
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include @CPPFLAGS@
MKINDEX=true
LIBS=@ZLIBS@
SO=@SO@
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
CWD=$(PWD)
#
LD=@DO_SECOND_LD@ @SHLIB_LD@
LDFLAGS=@EXTRA_LIBS_FOR_SWIDLLS@ @LDFLAGS@
BINTARGET=$(DESTDIR)$(YAPLIBDIR)
PLTARGET=$(DESTDIR)$(SHAREDIR)
FINAL_BINTARGET=$(YAPLIBDIR)
FINAL_PLTARGET=$(SHAREDIR)
LIBPL= @ZLIB_PLTARGETS@
TARGETS= @ZLIB_TARGETS@
%.o: $(srcdir)/%.c
$(CC) -c $(CFLAGS) $< -o $@
else # SWI
PL=@PL@
PLBASE=@PLBASE@
PLARCH=@PLARCH@
PLINCL=@PLINCL@
PKGDOC=$(PLBASE)/doc/packages
PCEHOME=../xpce
CC=@CC@
COFLAGS=@COFLAGS@
CWFLAGS=@CWFLAGS@
CMFLAGS=@CMFLAGS@
CIFLAGS=
CFLAGS=$(COFLAGS) $(CWFLAGS) $(CMFLAGS) $(CIFLAGS) @DEFS@
LIBS=@LIBS@ @ZLIBS@
DOCTOTEX=$(PCEHOME)/bin/doc2tex
PLTOTEX=$(PCEHOME)/bin/pl2tex
DOC=zlib
TEX=$(DOC).tex
DVI=$(DOC).dvi
PDF=$(DOC).pdf
RUNTEX=../../man/runtex
LD=@LD@
LDFLAGS=@LDSOFLAGS@
LIBPL= @PLTARGETS@
TARGETS= @TARGETS@
endif
INSTALL=@INSTALL@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_DATA=@INSTALL_DATA@
ZOBJ= zlib4pl.o
all: $(TARGETS)
nolib::
@echo "WARNING: Could not find zlib library; skipped"
zlib4pl.@SO@: $(ZOBJ)
$(LD) $(LDFLAGS) -o $@ $(ZOBJ) $(LIBS)
install: $(TARGETS) $(LIBPL)
mkdir -p $(BINTARGET)
for f in $(TARGETS); do \
$(INSTALL_PROGRAM) $$f $(BINTARGET); \
done
mkdir -p $(PLTARGET)
for f in $(LIBPL); do \
$(INSTALL_DATA) $$f $(PLTARGET); \
done
$(PL) -f none -g make -t halt
ln-install::
$(MAKE) INSTALL_DATA="../ln-install" INSTALL_PROGRAM="../ln-install" install
rpm-install: install
html-install::
mkdir -p $(DESTDIR)$(PKGDOC)
$(INSTALL) -m 644 $(DOC).html $(DESTDIR)$(PKGDOC)
pdf-install::
mkdir -p $(DESTDIR)$(PKGDOC)
$(INSTALL) -m 644 $(DOC).pdf $(DESTDIR)$(PKGDOC)
uninstall::
(cd $(PLBASE)/lib/$(PLARCH) && rm -f $(TARGETS))
(cd $(PLBASE)/library && rm -f $(LIBPL))
$(PL) -f none -g make -t halt
################################################################
# Testing
################################################################
check::
$(PL) -q -f $(srcdir)/test_zlib.pl -g test_zlib,halt -t 'halt(1)'
################################################################
# Documentation
################################################################
pdf: $(PDF)
$(DVI): $(TEX)
$(RUNTEX) $(DOC)
$(PDF): $(TEX)
$(RUNTEX) --pdf $(DOC)
html: $(TEX)
latex2html $(DOC)
mv html/index.html $(DOC).html
rm -r html
$(TEX): $(DOCTOTEX)
.doc.tex:
$(DOCTOTEX) $*.doc > $*.tex
.pl.tex:
$(PLTOTEX) $*.pl > $*.tex
################################################################
# Clean
################################################################
clean:
rm -f $(ZOBJ) *~ *.o *% a.out core config.log
distclean: clean
rm -f $(TARGETS) config.cache config.h config.status Makefile
rm -f $(DOC).aux $(DOC).log $(DOC).out $(DOC).toc
rm -rf html
rm -rf autom4te.cache
yap-6.2.2/packages/zlib/Makefile.mak 000644 000765 000024 00000002611 11457004725 017202 0 ustar 00vsc staff 000000 000000 ################################################################
# Build the SWI-Prolog zlib package for MS-Windows
#
# Author: Jan Wielemaker
#
# Use:
# nmake /f Makefile.mak
# nmake /f Makefile.mak install
################################################################
PLHOME=..\..
!include $(PLHOME)\src\rules.mk
CFLAGS=$(CFLAGS) /D__SWI_PROLOG__
!IF "$(MD)" == "WIN64"
ZLIB=ZLIBWAPI
CFLAGS=$(CFLAGS) /DZLIB_WINAPI
!ELSE
ZLIB=ZLIB1
!ENDIF
OBJ= zlib4pl.obj
all: zlib4pl.dll
zlib4pl.dll: $(OBJ)
$(LD) /dll /out:$@ $(LDFLAGS) $(OBJ) $(ZLIB).lib $(PLLIB) $(LIBS)
!IF "$(CFG)" == "rt"
install: idll
!ELSE
install: idll ilib
!ENDIF
################################################################
# Testing
################################################################
check::
################################################################
# Installation
################################################################
idll::
copy "$(EXTRALIBDIR)\$(ZLIB).dll" "$(BINDIR)"
copy zlib4pl.dll "$(BINDIR)"
!IF "$(PDB)" == "true"
copy zlib4pl.pdb "$(BINDIR)"
!ENDIF
ilib::
copy zlib.pl "$(PLBASE)\library"
$(MAKEINDEX)
uninstall::
del "$(BINDIR)\zlib4pl.dll"
del "$(PLBASE)\library\zlib.pl"
$(MAKEINDEX)
html-install::
copy zlib.html "$(PKGDOC)"
xpce-install::
clean::
if exist *.obj del *.obj
if exist *~ del *~
distclean: clean
-DEL *.dll *.lib *.exp *.ilk *.pdb 2>nul
yap-6.2.2/packages/zlib/test_zlib.pl 000644 000765 000024 00000011153 11457004725 017330 0 ustar 00vsc staff 000000 000000 :- module(test_zlib,
[ test_zlib/0
]).
:- asserta(user:file_search_path(foreign, '.')).
:- asserta(user:file_search_path(foreign, '../clib')).
:- asserta(user:file_search_path(library, '.')).
:- asserta(user:file_search_path(library, '../plunit')).
:- asserta(user:file_search_path(library, '../clib')).
:- use_module(library(zlib)).
:- use_module(library(plunit)).
:- use_module(library(readutil)).
:- use_module(library(socket)).
:- use_module(library(debug)).
test_zlib :-
run_tests([ zlib
]).
:- begin_tests(zlib).
% gunzip: can we read a file compressed with gzip
test(gunzip,
[ setup(shell('gzip < test_zlib.pl > plunit-tmp.gz')),
cleanup(delete_file('plunit-tmp.gz'))
]) :-
gzopen('plunit-tmp.gz', read, ZIn),
call_cleanup(read_stream_to_codes(ZIn, Codes0), close(ZIn)),
this_read_file_to_codes('test_zlib.pl', Codes1),
Codes0 == Codes1.
% gzip: Can gunzip read our compressed file
test(gzip,
[ cleanup(delete_file('plunit-tmp.gz'))
]) :-
this_read_file_to_codes('test_zlib.pl', Codes),
gzopen('plunit-tmp.gz', write, ZOut),
format(ZOut, '~s', [Codes]),
close(ZOut),
this_read_file_to_codes(pipe('gunzip < plunit-tmp.gz'), Codes1),
Codes == Codes1.
% deflate: test read/write of deflate format
test(deflate,
[ cleanup(delete_file('plunit-tmp.z'))
]) :-
this_read_file_to_codes('test_zlib.pl', Codes),
system:swi_open('plunit-tmp.z', write, Out),
zopen(Out, ZOut, []),
format(ZOut, '~s', [Codes]),
close(ZOut),
system:swi_open('plunit-tmp.z', read, In),
zopen(In, ZIn, []),
read_stream_to_codes(ZIn, Codes1),
close(ZIn),
Codes == Codes1.
% zstream: test compressed stream flushing and processing
test(zstream, Exit == true) :-
server(Port),
debug(server, 'Server at ~w~n', [Port]),
client(Port),
thread_join(server, Exit).
server(Port) :-
tcp_socket(S),
tcp_bind(S, Port),
tcp_listen(S, 5),
tcp_open_socket(S, AcceptFd, _),
thread_create(process(AcceptFd), _, [alias(server)]).
process(AcceptFd) :-
tcp_accept(AcceptFd, S2, _Peer),
tcp_open_socket(S2, ZIn, ZOut),
zopen(ZIn, In, []),
zopen(ZOut, Out, []),
loop(In, Out),
read(In, X),
assertion(X==end_of_file),
close(In), close(Out).
loop(In, Out) :-
read(In, Term),
debug(server, 'Read ~w', [Term]),
( Term == quit
-> true
; format(Out, '~q.~n', [Term]),
flush_output(Out),
debug(server, 'Replied', [Term]),
loop(In, Out)
).
client(Port) :-
integer(Port), !,
client(localhost:Port).
client(Address) :-
tcp_socket(S),
tcp_connect(S, Address),
tcp_open_socket(S, ZIn, ZOut),
zopen(ZIn, In, []),
zopen(ZOut, Out, []),
process_client(In, Out),
close(Out),
read(In, X),
assertion(X==end_of_file),
close(In).
process_client(In, Out) :-
forall(between(0, 50, X),
( format(Out, '~q.~n', [X]),
flush_output(Out),
read(In, Term),
%put(user_error, .),
( X == Term
-> true
; format('Wrong reply~n'),
fail
)
)),
format(Out, 'quit.~n', []).
/*******************************
* BIG DATA *
*******************************/
test(big) :-
forall(between(1, 5, I),
( Max is 10**I,
big(_, Max))).
big(Port, N):-
tcp_socket(SockFd),
tcp_setopt(SockFd, reuseaddr),
tcp_bind(SockFd, Port),
tcp_listen(SockFd, 5),
thread_create(client_test(Port, N), Client, []),
tcp_accept(SockFd, ClientFd, _Peer),
tcp_open_socket(ClientFd, InStream, OutStream),
zopen(OutStream, ZOut, [close_parent(false), format(deflate)]),
send_data(1, N, ZOut),
close(InStream),
character_count(ZOut, RawCnt),
close(ZOut),
character_count(OutStream, CompressedCnt),
debug(zlib, 'compressed ~d into ~d bytes~n',
[RawCnt, CompressedCnt]),
close(OutStream),
tcp_close_socket(SockFd),
thread_join(Client, Status),
assertion(Status == true).
send_data(I, N, ZOut) :-
I =< N, !,
format(ZOut, '~d.~n', [I]),
I2 is I + 1,
send_data(I2, N, ZOut).
send_data(_, _, _).
client_test(Port, N) :-
tcp_socket(SockFd),
tcp_connect(SockFd, localhost:Port),
tcp_open_socket(SockFd, In, Out),
zopen(In, ZIn, [format(deflate)]),
get_data(ZIn, N),
close(ZIn),
close(Out).
get_data(ZIn, _) :-
debugging(data), !,
between(0, inf, X),
get_byte(ZIn, C),
( C == -1
-> !,
format('EOF at ~w~n', [X])
; put_byte(C),
fail
).
get_data(ZIn, N) :-
between(1, inf, X),
read(ZIn, Term),
( Term == end_of_file
-> !,
assertion(X =:= N + 1)
; assertion(Term == X),
fail
).
:- end_tests(zlib).
/*******************************
* UTIL *
*******************************/
this_read_file_to_codes(File, Codes) :-
system:swi_open(File, read, In),
call_cleanup(read_stream_to_codes(In, Codes), close(In)).
yap-6.2.2/packages/zlib/zlib.doc 000644 000765 000024 00000012637 11457004725 016433 0 ustar 00vsc staff 000000 000000 \documentclass[11pt]{article}
\usepackage{times}
\usepackage{pl}
\usepackage{html}
\sloppy
\makeindex
\onefile
\htmloutput{html} % Output directory
\htmlmainfile{index} % Main document file
\bodycolor{white} % Page colour
\begin{document}
\title{SWI-Prolog binding to zlib}
\author{Jan Wielemaker \\
HCS, \\
University of Amsterdam \\
The Netherlands \\
E-mail: \email{wielemak@science.uva.nl}}
\maketitle
\begin{abstract}
The library \pllib{zlib} provides a binding to the
\url[zlib]{http://www.zlib.net/} general purpose compression library.
The prolog library aims as seamlessly reading and writing files
compatible to the \program{gzip} program as well as compressed (network)
communication.
\end{abstract}
\pagebreak
\tableofcontents
\vfill
\vfill
\newpage
\section{Zlib and compression}
Zlib is a widespread library implementing the RFC1950 (zlib wrapper),
RFC1951 (deflate stream) and RFC1952 (gzip wrapper) compression
standards. The SWI-Prolog binding is a foreign library that creates a
compressed stream as a wrapper around a normal stream. Implemented this
way, it can perform a wide variety of tasks:
\begin{itemize}
\item Read/write gzip compatible files
\item Setup standard compressed stream communication
\item Realise in-memory compression or decompression
\item Deal with streams holding embedded compressed objects
\end{itemize}
The core predicate of the library is zopen/3. The remainder of the
functionality of \pllib{zlib} is defined in Prolog and can be used as a
starting point for other high-level primitives. See also \file{ztest.pl}
providing test and demo code. This file is part of the source
distribution.
Part of the functionality of this library can also be realised using
the pipe interface and the \program{gzip} program. For example, a
gziped file can also be opened in Prolog using the code below.
\begin{code}
...
open(pipe('gunzip < file.gz'), read, In),
...
\end{code}
The advantage of this library for such tasks is enhanced platform
independence and reduced time to open a file. Platform independence is
improved as we do not have to worry about availability of the
\program{gunzip} utility and we do not have to worry about shell and
filename quoting issues. While the above works well on most modern Unix
systems, it only works with special precautions on Windows.%
\footnote{Install gunzip, deal with Windows path-names, the
windows shell and quoting.}
The library becomes really valuable if we consider compressed network
communication. Here we get the stream from tcp_open_socket/3. The
library provides efficient creation of a compressed stream, as well as
support for flushing output through the standard Prolog flush_output/1
call.
\section{Predicate reference}
\begin{description}
\predicate{zopen}{3}{+Stream, -ZStream, +Options}
Creates \arg{ZStream}, providing compressed access to \arg{Stream}. If
an input stream is wrapped, it recognises a gzip or deflate header.
If an output stream is enabled, \arg{Options} define the desired wrapper
and compression level. Defined options on output streams are:
\begin{description}
\termitem{format}{+Format}
Either \const{deflate} (default) or \const{gzip}. The \const{deflate}
envelope is simple and short and is typically used for compressed
(network) communication. The \const{gzip} envelope is compatible to
the \program{gzip} program and intended to read/write compressed files.
\termitem{level}{+Level}
Number between 0 and 9, specifying the compression level, Higher levels
use more resources. Default is 6, generally believed to be a good
compromise between speed, memory requirement and compression.
\end{description}
Generic options are:
\begin{description}
\termitem{close_parent}{Bool}
If \const{true} (default), closing the compressed stream also closes
(and thus invalidates) the wrapped stream. If \const{false}, the wrapped
stream is \emph{not} closed. This can be used to read/write a compressed
ndata block as partial input/output on a stream.
\end{description}
\predicate{gzopen}{3}{+File, +Mode, -Stream}
Same as \exam{gzopen}{File, Mode, Stream, []}.
\predicate{gzopen}{4}{+File, +Mode, -Stream, +Options}
Open \program{gzip} compatible \arg{File} for reading or writing.
\end{description}
\section{Interaction with Prolog stream predicates}
Using flush_output/1 on a compressed stream causes a
\const{Z_SYNC_FLUSH} on the stream. Using close/1 on a compressed
stream causes a \const{Z_FINISH} on the stream. If the stream uses
the \const{gzip} format, a \program{gzip} compatible footer is
written to the stream. If \const{close_parent} is set (default)
the underlying stream is closed too. Otherwise it remains open
and the user can continue communication in non-compressed format
or reopen the stream for compression using zopen/3.
\section{Installation}
\subsection{Unix systems}
Installation on Unix system uses the commonly found {\em configure},
{\em make} and {\em make install} sequence. SWI-Prolog should be
installed before building this package. If SWI-Prolog is not installed
as \program{pl}, the environment variable \env{PL} must be set to the
name of the SWI-Prolog executable. Installation is now accomplished
using:
\begin{code}
% ./configure
% make
% make install
\end{code}
This installs the foreign libraries in \file{$PLBASE/lib/$PLARCH} and
the Prolog library files in \file{$PLBASE/library}, where
\file{$PLBASE} refers to the SWI-Prolog `home-directory'.
\printindex
\end{document}
yap-6.2.2/packages/zlib/zlib.pl 000644 000765 000024 00000005265 11457004725 016300 0 ustar 00vsc staff 000000 000000 /* $Id$
Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: wielemak@science.uva.nl
WWW: http://www.swi-prolog.org
Copyright (C): 1985-2006, University of Amsterdam
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
As a special exception, if you link this library with other files,
compiled with a Free Software compiler, to produce an executable, this
library does not by itself cause the resulting executable to be covered
by the GNU General Public License. This exception does not however
invalidate any other reasons why the executable file might be covered by
the GNU General Public License.
*/
:- module(zlib,
[ zopen/3, % +Stream, -ZStream, +Option
gzopen/3, % +File, +Mode, -Stream
gzopen/4 % +File, +Mode, -Stream, +Options
]).
:- use_module(library(shlib)).
:- use_module(library(error)).
:- expects_dialect(swi).
:- assert(system:swi_io).
/** Zlib wrapper for SWI-Prolog
Read/write compressed data based on the zlib library.
@author Jan Wielemaker
@see http://www.zlib.net/
@see http://www.swi-prolog.org/packages/zlib.html
*/
:- use_foreign_library(foreign(zlib4pl)).
%% gzopen(+File, +Mode, -Stream) is det.
%% gzopen(+File, +Mode, -Stream, +Options) is det.
%
% Open a file compatible with the gzip program. Note that if a
% file is opened in =append= mode, a second gzip image will be
% added to the end of the file.
%
% @tbd Later versions may actually append to an existing
% compressed file.
gzopen(File, Mode, Stream) :-
gzopen(File, Mode, Stream, []).
gzopen(File, Mode, Stream, Options) :-
must_be(oneof([read,write,append]), Mode),
zoptions(Options, ZOptions, OpenOptions),
open(File, Mode, Stream0, OpenOptions),
zopen(Stream0, Stream,
[ format(gzip),
close_parent(true)
| ZOptions
]).
zoptions([], [], []).
zoptions([H|T], [H|TZ], TO) :-
zoption(H), !,
zoptions(T, TZ, TO).
zoptions([H|T], TZ, [H|TO]) :-
zoptions(T, TZ, TO).
zoption(format(_)).
zoption(level(_)).
:- retract(system:swi_io).
yap-6.2.2/packages/zlib/zlib4pl.c 000644 000765 000024 00000045575 11457004725 016537 0 ustar 00vsc staff 000000 000000 /* $Id$
Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: wielemak@science.uva.nl
WWW: http://www.swi-prolog.org
Copyright (C): 2006, University of Amsterdam
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define O_DEBUG 1
#include
#include
#include
#include
#include
#include
#include
/* Some distributions do not include this ... */
#ifdef HAVE_ZUTIL_H
#include
#else
#include "zutil.h"
#endif
static functor_t FUNCTOR_error2; /* error(Formal, Context) */
static functor_t FUNCTOR_type_error2; /* type_error(Term, Expected) */
static functor_t FUNCTOR_domain_error2; /* domain_error(Term, Expected) */
static atom_t ATOM_format; /* format(Format) */
static atom_t ATOM_level; /* level(Int) */
static atom_t ATOM_close_parent; /* close_parent(Bool) */
static atom_t ATOM_gzip;
static atom_t ATOM_deflate;
static int debuglevel = 0;
#ifdef O_DEBUG
#define DEBUG(n, g) if ( debuglevel >= n ) g
#else
#define DEBUG(n, g) (void)0
#endif
/*******************************
* ERRORS *
*******************************/
static int
type_error(term_t actual, const char *expected)
{ term_t ex;
if ( (ex = PL_new_term_ref()) &&
PL_unify_term(ex,
PL_FUNCTOR, FUNCTOR_error2,
PL_FUNCTOR, FUNCTOR_type_error2,
PL_CHARS, expected,
PL_TERM, actual,
PL_VARIABLE) )
return PL_raise_exception(ex);
return FALSE;
}
static int
domain_error(term_t actual, const char *domain)
{ term_t ex;
if ( (ex = PL_new_term_ref()) &&
PL_unify_term(ex,
PL_FUNCTOR, FUNCTOR_error2,
PL_FUNCTOR, FUNCTOR_domain_error2,
PL_CHARS, domain,
PL_TERM, actual,
PL_VARIABLE) )
return PL_raise_exception(ex);
return FALSE;
}
static int
instantiation_error()
{ term_t ex;
if ( (ex = PL_new_term_ref()) &&
PL_unify_term(ex,
PL_FUNCTOR, FUNCTOR_error2,
PL_CHARS, "instantiation_error",
PL_VARIABLE) )
return PL_raise_exception(ex);
return FALSE;
}
static int
get_atom_ex(term_t t, atom_t *a)
{ if ( PL_get_atom(t, a) )
return TRUE;
return type_error(t, "atom");
}
static int
get_int_ex(term_t t, int *i)
{ if ( PL_get_integer(t, i) )
return TRUE;
return type_error(t, "integer");
}
static int
get_bool_ex(term_t t, int *i)
{ if ( PL_get_bool(t, i) )
return TRUE;
return type_error(t, "boolean");
}
/*******************************
* TYPES *
*******************************/
#define BUFSIZE SIO_BUFSIZE /* raw I/O buffer */
typedef enum
{ F_UNKNOWN = 0,
F_GZIP, /* gzip output */
F_GZIP_CRC, /* end of gzip output */
F_DEFLATE /* zlib data */
} zformat;
typedef struct z_context
{ IOSTREAM *stream; /* Original stream */
IOSTREAM *zstream; /* Compressed stream (I'm handle of) */
int close_parent; /* close parent on close */
int initialized; /* did inflateInit()? */
zformat format; /* current format */
uLong crc; /* CRC check */
z_stream zstate; /* Zlib state */
} z_context;
static z_context*
alloc_zcontext(IOSTREAM *s)
{ z_context *ctx = PL_malloc(sizeof(*ctx));
memset(ctx, 0, sizeof(*ctx));
ctx->stream = s;
ctx->close_parent = TRUE;
return ctx;
}
static void
free_zcontext(z_context *ctx)
{ if ( ctx->stream->upstream )
Sset_filter(ctx->stream, NULL);
else
PL_release_stream(ctx->stream);
PL_free(ctx);
}
/*******************************
* GZIP HEADER *
*******************************/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Code based on gzio.c from the zlib source distribution.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
/* gzip flag byte */
#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
#define COMMENT 0x10 /* bit 4 set: file comment present */
#define RESERVED 0xE0 /* bits 5..7: reserved */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
gz_skip_header() parses the gzip file-header. return
* If ok: pointer to first byte following header
* If not a gzip file: NULL
* If still ok, but incomplete: GZHDR_SHORT
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define HDR_SHORT ((Bytef*)-1) /* Header is incomplete */
#define SKIP_STRING \
{ while ( *in && avail > 0 ) \
in++, avail--; \
if ( avail > 0 ) \
in++, avail--; \
}
static Bytef *
gz_skip_header(z_context *ctx, Bytef *in, int avail)
{ int method; /* method byte */
int flags; /* flags byte */
int len;
if ( avail < 10 ) /* 2-byte magic, method, flags, */
return HDR_SHORT; /* time, xflags and OS code */
if ( in[0] != gz_magic[0] &&
in[1] != gz_magic[1] )
return NULL;
in += 2;
method = *in++;
flags = *in++;
if ( method != Z_DEFLATED || (flags & RESERVED ) != 0)
return NULL;
in += 6; /* Discard time, xflags and OS code */
avail -= 10;
if ((flags & EXTRA_FIELD) != 0)
{ /* skip the extra field */
len = *in++;
len += (*in++)<<8;
len &= 0xffff;
if ( avail > len )
{ in += len;
avail -= len;
} else
{ return HDR_SHORT;
}
}
if ((flags & ORIG_NAME) != 0)
{ /* skip the original file name */
SKIP_STRING
}
if ((flags & COMMENT) != 0)
{ /* skip the .gz file comment */
SKIP_STRING
}
if ((flags & HEAD_CRC) != 0)
{ /* skip the header crc */
in += 2;
avail -= 2;
}
if ( avail <= 0 )
return HDR_SHORT;
return in;
}
static int
write_ulong_lsb(IOSTREAM *s, unsigned long x)
{ Sputc((x) &0xff, s);
Sputc((x>>8) &0xff, s);
Sputc((x>>16)&0xff, s);
Sputc((x>>24)&0xff, s);
return Sferror(s) ? -1 : 0;
}
static int
write_gzip_header(z_context *ctx)
{ IOSTREAM *s = ctx->stream;
time_t stamp = time(NULL);
Sputc(gz_magic[0], s);
Sputc(gz_magic[1], s);
Sputc(Z_DEFLATED, s); /* method */
Sputc(0, s); /* flags */
write_ulong_lsb(s, (unsigned long)stamp); /* time stamp */
Sputc(0, s); /* xflags */
Sputc(OS_CODE, s); /* OS identifier */
return Sferror(s) ? FALSE : TRUE; /* TBD: Error */
}
static int
write_gzip_footer(z_context *ctx)
{ IOSTREAM *s = ctx->stream;
write_ulong_lsb(s, ctx->crc); /* CRC32 */
write_ulong_lsb(s, ctx->zstate.total_in); /* Total length */
return Sferror(s) ? -1 : 0;
}
static Bytef *
get_ulong_lsb(const Bytef *in, uLong *v)
{ *v = (in[0] |
in[1] << 8 |
in[2] << 16 |
in[3] << 24) & 0xffffffff;
return (Bytef*)in+4;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0: ok
-1: CRC/size error
-2: not enough data
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static int
gz_skip_footer(z_context *ctx)
{ if ( ctx->zstate.avail_in >= 8 )
{ uLong crc, size;
Bytef *in = ctx->zstate.next_in;
in = get_ulong_lsb(in, &crc);
in = get_ulong_lsb(in, &size);
ctx->zstate.next_in = in;
ctx->zstate.avail_in -= 8;
if ( crc != ctx->crc )
{ char msg[256];
Ssprintf(msg, "CRC error (%08lx != %08lx)", crc, ctx->crc);
Sseterr(ctx->zstream, SIO_FERR, msg);
return -1;
}
if ( size != ctx->zstate.total_out )
{ char msg[256];
Ssprintf(msg, "Size mismatch (%ld != %ld)", size, ctx->zstate.total_out);
Sseterr(ctx->zstream, SIO_FERR, msg);
return -1;
}
return 0;
}
return -2;
}
/*******************************
* GZ I/O *
*******************************/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
read_more() reads more data into the zstate buffer if deflating cannot
do anything with the available bytes. Note that S__fillbuf() can be
called with data in the buffer. It moves the remaining data to the start
of the stream buffer and tries to read more data into the stream.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static int
read_more(z_context *ctx)
{ int c;
ctx->stream->bufp = (char*)ctx->zstate.next_in;
ctx->stream->limitp = ctx->stream->bufp + ctx->zstate.avail_in;
if ( (c=S__fillbuf(ctx->stream)) != EOF )
{ Sungetc(c, ctx->stream);
ctx->zstate.next_in = (Bytef*)ctx->stream->bufp;
ctx->zstate.avail_in = (long)(ctx->stream->limitp - ctx->stream->bufp);
ctx->stream->bufp = ctx->stream->limitp;
return 0;
}
return -1;
}
static ssize_t /* inflate */
zread(void *handle, char *buf, size_t size)
{ z_context *ctx = handle;
int flush = Z_SYNC_FLUSH;
int rc;
if ( ctx->zstate.avail_in == 0 )
{ if ( Sfeof(ctx->stream) )
{ flush = Z_FINISH;
} else
{ ctx->zstate.next_in = (Bytef*)ctx->stream->bufp;
ctx->zstate.avail_in = (long)(ctx->stream->limitp - ctx->stream->bufp);
ctx->stream->bufp = ctx->stream->limitp; /* empty buffer */
}
}
DEBUG(1, Sdprintf("Processing %d bytes\n", ctx->zstate.avail_in));
ctx->zstate.next_out = (Bytef*)buf;
ctx->zstate.avail_out = (long)size;
if ( ctx->initialized == FALSE )
{ Bytef *p;
DEBUG(1, Sdprintf("Trying gzip header\n"));
if ( ctx->format == F_DEFLATE )
{ p = NULL;
} else
{ while( (p = gz_skip_header(ctx, ctx->zstate.next_in,
ctx->zstate.avail_in)) == HDR_SHORT )
{ int rc;
if ( (rc=read_more(ctx)) < 0 )
return -1;
}
}
if ( p )
{ long m = (int)(p - ctx->zstate.next_in);
ctx->format = F_GZIP;
DEBUG(1, Sdprintf("Skipped gzip header (%d bytes)\n", m));
ctx->zstate.next_in = p;
ctx->zstate.avail_in -= m;
/* init without header */
switch(inflateInit2(&ctx->zstate, -MAX_WBITS))
{ case Z_OK:
ctx->initialized = TRUE;
ctx->crc = crc32(0L, Z_NULL, 0);
DEBUG(1, Sdprintf("inflateInit2(): Z_OK\n"));
break;
case Z_MEM_ERROR: /* no memory */
case Z_VERSION_ERROR: /* bad library version */
PL_warning("ERROR: TBD");
return -1;
default:
assert(0);
return -1;
}
} else
{ switch(inflateInit(&ctx->zstate))
{ case Z_OK:
ctx->format = F_DEFLATE;
ctx->initialized = TRUE;
DEBUG(1, Sdprintf("inflateInit(): Z_OK\n"));
break;
case Z_MEM_ERROR: /* no memory */
case Z_VERSION_ERROR: /* bad library version */
PL_warning("ERROR: TBD");
return -1;
default:
assert(0);
return -1;
}
}
} else if ( ctx->format == F_GZIP_CRC )
{ int rc;
while( (rc=gz_skip_footer(ctx)) == -2 )
{ int rc2;
if ( (rc2=read_more(ctx)) < 0 )
return -1;
}
if ( rc == 0 )
{ int avail = ctx->zstate.avail_in;
/* copy back unprocessed bytes */
DEBUG(1, Sdprintf("GZIP footer ok; copying %d bytes back\n", avail));
memmove(ctx->stream->buffer, ctx->zstate.next_in, avail);
ctx->stream->bufp = ctx->stream->buffer;
ctx->stream->limitp = ctx->stream->bufp + avail;
return 0; /* EOF */
} else
{ DEBUG(1, Sdprintf("GZIP CRC/length error\n"));
return -1;
}
}
switch((rc=inflate(&ctx->zstate, Z_NO_FLUSH)))
{ case Z_OK:
case Z_STREAM_END:
{ long n = (long)(size - ctx->zstate.avail_out);
if ( ctx->format == F_GZIP && n > 0 )
ctx->crc = crc32(ctx->crc, (Bytef*)buf, n);
if ( rc == Z_STREAM_END )
{ DEBUG(1, Sdprintf("Z_STREAM_END: %d bytes\n", n));
if ( ctx->format == F_GZIP )
ctx->format = F_GZIP_CRC;
} else
{ DEBUG(1, Sdprintf("inflate(): Z_OK: %d bytes\n", n));
}
return n;
}
case Z_NEED_DICT:
DEBUG(1, Sdprintf("Z_NEED_DICT\n"));
break;
case Z_DATA_ERROR:
DEBUG(1, Sdprintf("Z_DATA_ERROR\n"));
break;
case Z_STREAM_ERROR:
DEBUG(1, Sdprintf("Z_STREAM_ERROR\n"));
break;
case Z_MEM_ERROR:
DEBUG(1, Sdprintf("Z_MEM_ERROR\n"));
break;
case Z_BUF_ERROR:
DEBUG(1, Sdprintf("Z_BUF_ERROR\n"));
break;
default:
DEBUG(1, Sdprintf("Inflate error: %d\n", rc));
}
if ( ctx->zstate.msg )
Sdprintf("ERROR: zread(): %s\n", ctx->zstate.msg);
return -1;
}
static ssize_t /* deflate */
zwrite4(void *handle, char *buf, size_t size, int flush)
{ z_context *ctx = handle;
Bytef buffer[SIO_BUFSIZE];
int rc;
int loops = 0;
ctx->zstate.next_in = (Bytef*)buf;
ctx->zstate.avail_in = (long)size;
if ( ctx->format == F_GZIP && size > 0 )
ctx->crc = crc32(ctx->crc, ctx->zstate.next_in, ctx->zstate.avail_in);
DEBUG(1, Sdprintf("Compressing %d bytes\n", ctx->zstate.avail_in));
do
{ loops++;
ctx->zstate.next_out = buffer;
ctx->zstate.avail_out = sizeof(buffer);
switch( (rc = deflate(&ctx->zstate, flush)) )
{ case Z_OK:
case Z_STREAM_END:
{ size_t n = sizeof(buffer) - ctx->zstate.avail_out;
DEBUG(1, Sdprintf("Compressed (%s) to %d bytes; left %d\n",
rc == Z_OK ? "Z_OK" : "Z_STREAM_END",
n, ctx->zstate.avail_in));
if ( Sfwrite(buffer, 1, n, ctx->stream) != n )
return -1;
break;
}
case Z_BUF_ERROR:
DEBUG(1, Sdprintf("zwrite4(): Z_BUF_ERROR\n"));
break;
case Z_STREAM_ERROR:
default:
Sdprintf("ERROR: zwrite(): %s\n", ctx->zstate.msg);
return -1;
}
} while ( ctx->zstate.avail_in > 0 ||
(flush != Z_NO_FLUSH && rc == Z_OK) );
if ( flush != Z_NO_FLUSH && Sflush(ctx->stream) < 0 )
return -1;
return size;
}
static ssize_t /* deflate */
zwrite(void *handle, char *buf, size_t size)
{ return zwrite4(handle, buf, size, Z_NO_FLUSH);
}
static int
zcontrol(void *handle, int op, void *data)
{ z_context *ctx = handle;
switch(op)
{ case SIO_FLUSHOUTPUT:
DEBUG(1, Sdprintf("Flushing output\n"));
return (int)zwrite4(handle, NULL, 0, Z_SYNC_FLUSH);
case SIO_SETENCODING:
return 0; /* allow switching encoding */
default:
if ( ctx->stream->functions->control )
return (*ctx->stream->functions->control)(ctx->stream->handle, op, data);
return -1;
}
}
static int
zclose(void *handle)
{ z_context *ctx = handle;
ssize_t rc;
DEBUG(1, Sdprintf("zclose() ...\n"));
if ( (ctx->stream->flags & SIO_INPUT) )
{ rc = inflateEnd(&ctx->zstate);
} else
{ rc = zwrite4(handle, NULL, 0, Z_FINISH); /* flush */
if ( rc == 0 && ctx->format == F_GZIP )
rc = write_gzip_footer(ctx);
if ( rc == 0 )
rc = deflateEnd(&ctx->zstate);
else
deflateEnd(&ctx->zstate);
}
switch(rc)
{ case Z_OK:
DEBUG(1, Sdprintf("%s(): Z_OK\n",
(ctx->stream->flags & SIO_INPUT) ? "inflateEnd"
: "deflateEnd"));
if ( ctx->close_parent )
{ IOSTREAM *parent = ctx->stream;
free_zcontext(ctx);
return Sclose(parent);
} else
{ free_zcontext(ctx);
return 0;
}
case Z_STREAM_ERROR: /* inconsistent state */
case Z_DATA_ERROR: /* premature end */
default:
if ( ctx->close_parent )
{ IOSTREAM *parent = ctx->stream;
free_zcontext(ctx);
Sclose(parent);
return -1;
}
free_zcontext(ctx);
return -1;
}
}
static IOFUNCTIONS zfunctions =
{ zread,
zwrite,
NULL, /* seek */
zclose,
zcontrol, /* zcontrol */
NULL, /* seek64 */
};
/*******************************
* PROLOG CONNECTION *
*******************************/
#define COPY_FLAGS (SIO_INPUT|SIO_OUTPUT| \
SIO_TEXT| \
SIO_REPXML|SIO_REPPL|\
SIO_RECORDPOS)
static foreign_t
pl_zopen(term_t org, term_t new, term_t options)
{ term_t tail = PL_copy_term_ref(options);
term_t head = PL_new_term_ref();
z_context *ctx;
zformat fmt = F_UNKNOWN;
int level = Z_DEFAULT_COMPRESSION;
IOSTREAM *s, *s2;
int close_parent = TRUE;
while(PL_get_list(tail, head, tail))
{ atom_t name;
int arity;
term_t arg = PL_new_term_ref();
if ( !PL_get_name_arity(head, &name, &arity) || arity != 1 )
return type_error(head, "option");
_PL_get_arg(1, head, arg);
if ( name == ATOM_format )
{ atom_t a;
if ( !get_atom_ex(arg, &a) )
return FALSE;
if ( a == ATOM_gzip )
fmt = F_GZIP;
else if ( a == ATOM_deflate )
fmt = F_DEFLATE;
else
return domain_error(arg, "compression_format");
} else if ( name == ATOM_level )
{ if ( !get_int_ex(arg, &level) )
return FALSE;
if ( level < 0 || level > 9 )
return domain_error(arg, "compression_level");
} else if ( name == ATOM_close_parent )
{ if ( !get_bool_ex(arg, &close_parent) )
return FALSE;
}
}
if ( !PL_get_nil(tail) )
return type_error(tail, "list");
if ( !PL_get_stream_handle(org, &s) )
return FALSE; /* Error */
ctx = alloc_zcontext(s);
ctx->close_parent = close_parent;
ctx->format = fmt;
if ( (s->flags & SIO_OUTPUT) )
{ int rc;
if ( fmt == F_GZIP )
{ if ( write_gzip_header(ctx) < 0 )
{ free_zcontext(ctx);
return FALSE;
}
rc = deflateInit2(&ctx->zstate, level, Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0);
} else
{ rc = deflateInit(&ctx->zstate, level);
}
if ( rc != Z_OK )
{ free_zcontext(ctx);
return FALSE; /* TBD: Error */
}
}
if ( !(s2 = Snew(ctx,
(s->flags©_FLAGS)|SIO_FBUF,
&zfunctions)) )
{ free_zcontext(ctx); /* no memory */
return FALSE;
}
s2->encoding = s->encoding;
ctx->zstream = s2;
Sset_filter(s, s2);
PL_release_stream(s);
if ( PL_unify_stream(new, s2) )
{ return TRUE;
} else
{ ctx->close_parent = FALSE;
Sclose(s2);
return instantiation_error();
}
}
#ifdef O_DEBUG
static foreign_t
zdebug(term_t level)
{ return PL_get_integer(level, &debuglevel);
}
#endif
/*******************************
* INSTALL *
*******************************/
#define MKFUNCTOR(name, arity) PL_new_functor(PL_new_atom(name), arity)
install_t
install_zlib4pl()
{ FUNCTOR_error2 = MKFUNCTOR("error", 2);
FUNCTOR_type_error2 = MKFUNCTOR("type_error", 2);
FUNCTOR_domain_error2 = MKFUNCTOR("domain_error", 2);
ATOM_format = PL_new_atom("format");
ATOM_level = PL_new_atom("level");
ATOM_close_parent = PL_new_atom("close_parent");
ATOM_gzip = PL_new_atom("gzip");
ATOM_deflate = PL_new_atom("deflate");
PL_register_foreign("zopen", 3, pl_zopen, 0);
#ifdef O_DEBUG
PL_register_foreign("zdebug", 1, zdebug, 0);
#endif
}
yap-6.2.2/packages/zlib/zutil.h 000644 000765 000024 00000015313 11457004725 016316 0 ustar 00vsc staff 000000 000000 /* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2005 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
subject to change. Applications should only use zlib.h.
*/
/* @(#) $Id$ */
#ifndef ZUTIL_H
#define ZUTIL_H
#define ZLIB_INTERNAL
#include "zlib.h"
#ifdef STDC
# ifndef _WIN32_WCE
# include
# endif
# include
# include
#endif
#ifdef NO_ERRNO_H
# ifdef _WIN32_WCE
/* The Microsoft C Run-Time Library for Windows CE doesn't have
* errno. We define it as a global variable to simplify porting.
* Its value is always 0 and should not be used. We rename it to
* avoid conflict with other libraries that use the same workaround.
*/
# define errno z_errno
# endif
extern int errno;
#else
# ifndef _WIN32_WCE
# include
# endif
#endif
#ifndef local
# define local static
#endif
/* compile with -Dlocal if your debugger can't find static symbols */
typedef unsigned char uch;
typedef uch FAR uchf;
typedef unsigned short ush;
typedef ush FAR ushf;
typedef unsigned long ulg;
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = (char*)ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
#ifndef DEF_WBITS
# define DEF_WBITS MAX_WBITS
#endif
/* default windowBits for decompression. MAX_WBITS is for compression only */
#if MAX_MEM_LEVEL >= 8
# define DEF_MEM_LEVEL 8
#else
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
#endif
/* default memLevel */
#define STORED_BLOCK 0
#define STATIC_TREES 1
#define DYN_TREES 2
/* The three kinds of block type */
#define MIN_MATCH 3
#define MAX_MATCH 258
/* The minimum and maximum match lengths */
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
/* target dependencies */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# define OS_CODE 0x00
# if defined(__TURBOC__) || defined(__BORLANDC__)
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
# else
# include
# endif
# else /* MSC or DJGPP */
# include
# endif
#endif
#ifdef AMIGA
# define OS_CODE 0x01
#endif
#if defined(VAXC) || defined(VMS)
# define OS_CODE 0x02
# define F_OPEN(name, mode) \
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
#endif
#if defined(ATARI) || defined(atarist)
# define OS_CODE 0x05
#endif
#ifdef OS2
# define OS_CODE 0x06
# ifdef M_I86
#include
# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include /* for fdopen */
# else
# ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif
#endif
#ifdef TOPS20
# define OS_CODE 0x0a
#endif
#ifdef WIN32
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
# define OS_CODE 0x0b
# endif
#endif
#ifdef __50SERIES /* Prime/PRIMOS */
# define OS_CODE 0x0f
#endif
#if defined(_BEOS_) || defined(RISCOS)
# define fdopen(fd,mode) NULL /* No fdopen() */
#endif
#if (defined(_MSC_VER) && (_MSC_VER > 600))
# if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED
# endif
# else
# define fdopen(fd,type) _fdopen(fd,type)
# endif
#endif
/* common defaults */
#ifndef OS_CODE
# define OS_CODE 0x03 /* assume Unix */
#endif
#ifndef F_OPEN
# define F_OPEN(name, mode) fopen((name), (mode))
#endif
/* functions */
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#if defined(__CYGWIN__)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#ifndef HAVE_VSNPRINTF
# ifdef MSDOS
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef __TURBOC__
# define NO_vsnprintf
# endif
# ifdef WIN32
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
# define vsnprintf _vsnprintf
# endif
# endif
# ifdef __SASC
# define NO_vsnprintf
# endif
#endif
#ifdef VMS
# define NO_vsnprintf
#endif
#if defined(pyr)
# define NO_MEMCPY
#endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
/* Use our own functions for small and medium model with MSC <= 5.0.
* You may have to use the same strategy for Borland C (untested).
* The __SC__ check is for Symantec.
*/
# define NO_MEMCPY
#endif
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
# define HAVE_MEMCPY
#endif
#ifdef HAVE_MEMCPY
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
# define zmemcpy _fmemcpy
# define zmemcmp _fmemcmp
# define zmemzero(dest, len) _fmemset(dest, 0, len)
# else
# define zmemcpy memcpy
# define zmemcmp memcmp
# define zmemzero(dest, len) memset(dest, 0, len)
# endif
#else
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len));
#endif
/* Diagnostic functions */
#ifdef DEBUG
# include
extern int z_verbose;
extern void z_error OF((char *m));
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
#else
# define Assert(cond,msg)
# define Trace(x)
# define Tracev(x)
# define Tracevv(x)
# define Tracec(c,x)
# define Tracecv(c,x)
#endif
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
void zcfree OF((voidpf opaque, voidpf ptr));
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
#endif /* ZUTIL_H */
yap-6.2.2/packages/udi/README 000644 000765 000024 00000000254 11457004725 015475 0 ustar 00vsc staff 000000 000000 This directory contains support for user defined indexers, currently:
- RTrees
For Examples and Tests proceed as follows:
git clone git://yap.dcc.fc.up.pt/udi-examples
yap-6.2.2/packages/udi/rtree.c 000644 000765 000024 00000026163 11457004725 016111 0 ustar 00vsc staff 000000 000000 #include
#include
#include
#include
#include
#include "rtree.h"
static node_t RTreeNewNode (void);
static void RTreeDestroyNode (node_t);
static void RTreeNodeInit (node_t);
static int RTreeSearchNode (node_t, rect_t, SearchHitCallback, void *);
static int RTreeInsertNode (node_t, int, rect_t,void *,node_t *);
static int RTreePickBranch (rect_t, node_t);
static int RTreeAddBranch(node_t, branch_t, node_t *);
static void RTreeSplitNode (node_t, branch_t, node_t *);
static void RTreePickSeeds(partition_t *, node_t, node_t);
static void RTreeNodeAddBranch(rect_t *, node_t, branch_t);
static void RTreePickNext(partition_t *, node_t, node_t);
static rect_t RTreeNodeCover(node_t);
static double RectArea (rect_t);
static rect_t RectCombine (rect_t, rect_t);
static int RectOverlap (rect_t, rect_t);
static void RectPrint (rect_t);
static partition_t PartitionNew (void);
static void PartitionPush (partition_t *, branch_t);
static branch_t PartitionPop (partition_t *);
static branch_t PartitionGet (partition_t *, int);
rtree_t RTreeNew (void)
{
rtree_t t;
t = RTreeNewNode();
t->level = 0; /*leaf*/
return t;
}
void RTreeDestroy (rtree_t t)
{
if (t)
RTreeDestroyNode (t);
}
static node_t RTreeNewNode (void)
{
node_t n;
n = (node_t) malloc (sizeof(*n));
assert(n);
RTreeNodeInit(n);
return n;
}
static void RTreeDestroyNode (node_t node)
{
int i;
if (node->level == 0) /* leaf level*/
{
for (i = 0; i < MAXCARD; i++)
if (node->branch[i].child)
;/* allow user free data*/
else
break;
}
else
{
for (i = 0; i < MAXCARD; i++)
if (node->branch[i].child)
RTreeDestroyNode (node->branch[i].child);
else
break;
}
free (node);
}
static void RTreeNodeInit (node_t n)
{
memset((void *) n,0, sizeof(*n));
n->level = -1;
}
int RTreeSearch (rtree_t t, rect_t s, SearchHitCallback f, void *arg)
{
assert(t);
return RTreeSearchNode(t,s,f,arg);
}
static int RTreeSearchNode (node_t n, rect_t s, SearchHitCallback f, void *arg)
{
int i;
int c = 0;
if (n->level > 0)
{
for (i = 0; i < MAXCARD; i++)
if (n->branch[i].child &&
RectOverlap (s,n->branch[i].mbr))
c += RTreeSearchNode ((node_t) n->branch[i].child, s, f, arg);
}
else
{
for (i = 0; i < MAXCARD; i++)
if (n->branch[i].child &&
RectOverlap (s,n->branch[i].mbr))
{
c ++;
if (f)
if ( !f(n->branch[i].mbr,n->branch[i].child,arg))
return c;
}
}
return c;
}
void RTreeInsert (rtree_t *t, rect_t r, void *data)
{
node_t n2;
node_t new_root;
branch_t b;
assert(t && *t);
if (RTreeInsertNode(*t, 0, r, data, &n2))
/* deal with root split */
{
new_root = RTreeNewNode();
new_root->level = (*t)->level + 1;
b.mbr = RTreeNodeCover(*t);
b.child = (void *) *t;
RTreeAddBranch(new_root, b, NULL);
b.mbr = RTreeNodeCover(n2);
b.child = (void *) n2;
RTreeAddBranch(new_root, b, NULL);
*t = new_root;
}
}
static int RTreeInsertNode (node_t n, int level,
rect_t r, void *data,
node_t *new_node)
{
int i;
node_t n2;
branch_t b;
assert(n && new_node);
assert(level >= 0 && level <= n->level);
if (n->level > level)
{
i = RTreePickBranch(r,n);
if (!RTreeInsertNode((node_t) n->branch[i].child, level,
r, data,&n2)) /* not split */
{
n->branch[i].mbr = RectCombine(r,n->branch[i].mbr);
return FALSE;
}
else /* node split */
{
n->branch[i].mbr = RTreeNodeCover(n->branch[i].child);
b.child = n2;
b.mbr = RTreeNodeCover(n2);
return RTreeAddBranch(n, b, new_node);
}
}
else /*insert level*/
{
b.mbr = r;
b.child = data;
return RTreeAddBranch(n, b, new_node);
}
}
static int RTreeAddBranch(node_t n, branch_t b, node_t *new_node)
{
int i;
assert(n);
if (n->count < MAXCARD) /*split not necessary*/
{
for (i = 0; i < MAXCARD; i++)
if (n->branch[i].child == NULL)
{
n->branch[i] = b;
n->count ++;
break;
}
return FALSE;
}
else /*needs to split*/
{
assert(new_node);
RTreeSplitNode (n, b, new_node);
return TRUE;
}
}
static int RTreePickBranch (rect_t r, node_t n)
{
int i;
double area;
double inc_area;
rect_t tmp;
int best_i;
double best_inc;
double best_i_area;
best_i = 0;
best_inc = DBL_MAX; /* double Max value */
best_i_area = DBL_MAX;
for (i = 0; i < MAXCARD; i++)
if (n->branch[i].child)
{
area = RectArea (n->branch[i].mbr);
tmp = RectCombine (r, n->branch[i].mbr);
inc_area = RectArea (tmp) - area;
if (inc_area < best_inc)
{
best_inc = inc_area;
best_i = i;
best_i_area = area;
}
else if (inc_area == best_inc && best_i_area > area)
{
best_inc = inc_area;
best_i = i;
best_i_area = area;
}
}
else
break;
return best_i;
}
static void RTreeSplitNode (node_t n, branch_t b, node_t *new_node)
{
partition_t p;
int level;
int i;
assert(n);
assert(new_node);
p = PartitionNew();
for (i = 0; i < MAXCARD; i ++)
PartitionPush(&p,n->branch[i]);
PartitionPush(&p,b);
level = n->level;
RTreeNodeInit(n);
n->level = level;
*new_node = RTreeNewNode();
(*new_node)->level = level;
RTreePickSeeds(&p, n, *new_node);
while (p.n)
if (n->count + p.n <= MINCARD)
/* first group (n) needs all entries */
RTreeNodeAddBranch(&(p.cover[0]), n, PartitionPop(&p));
else if ((*new_node)->count + p.n <= MINCARD)
/* second group (new_node) needs all entries */
RTreeNodeAddBranch(&(p.cover[1]), *new_node, PartitionPop(&p));
else
RTreePickNext(&p, n, *new_node);
}
static void RTreePickNext(partition_t *p, node_t n1, node_t n2)
/* linear version */
{
branch_t b;
double area[2], inc_area[2];
rect_t tmp;
b = PartitionPop(p);
area[0] = RectArea (p->cover[0]);
tmp = RectCombine (p->cover[0], b.mbr);
inc_area[0] = RectArea (tmp) - area[0];
area[1] = RectArea (p->cover[1]);
tmp = RectCombine (p->cover[1], b.mbr);
inc_area[1] = RectArea (tmp) - area[1];
if (inc_area[0] < inc_area[1] ||
(inc_area[0] == inc_area[1] && area[0] < area[1]))
RTreeNodeAddBranch(&(p->cover[0]),n1,b);
else
RTreeNodeAddBranch(&(p->cover[1]),n2,b);
}
static void RTreePickSeeds(partition_t *p, node_t n1, node_t n2)
/* puts in index 0 of each node the resulting entry, forming the two
groups
This is the linear version
*/
{
int dim,high, i;
int highestLow[NUMDIMS], lowestHigh[NUMDIMS];
double width[NUMDIMS];
int seed0, seed1;
double sep, best_sep;
assert(p->n == MAXCARD + 1);
for (dim = 0; dim < NUMDIMS; dim++)
{
high = dim + NUMDIMS;
highestLow[dim] = lowestHigh[dim] = 0;
for (i = 1; i < MAXCARD +1; i++)
{
if (p->buffer[i].mbr.coords[dim] >
p->buffer[highestLow[dim]].mbr.coords[dim])
highestLow[dim] = i;
if (p->buffer[i].mbr.coords[high] <
p->buffer[lowestHigh[dim]].mbr.coords[high])
lowestHigh[dim] = i;
}
width[dim] = p->cover_all.coords[high] - p->cover_all.coords[dim];
assert(width[dim] >= 0);
}
seed0 = lowestHigh[0];
seed1 = highestLow[0];
best_sep = 0;
for (dim = 0; dim < NUMDIMS; dim ++)
{
high = dim + NUMDIMS;
sep = (p->buffer[highestLow[dim]].mbr.coords[dim] -
p->buffer[lowestHigh[dim]].mbr.coords[high]) / width[dim];
if (sep > best_sep)
{
seed0 = lowestHigh[dim];
seed1 = highestLow[dim];
best_sep = sep;
}
}
/* assert (seed0 != seed1); */
if (seed0 > seed1)
{
RTreeNodeAddBranch(&(p->cover[0]),n1,PartitionGet(p,seed0));
RTreeNodeAddBranch(&(p->cover[1]),n2,PartitionGet(p,seed1));
}
else if (seed0 < seed1)
{
RTreeNodeAddBranch(&(p->cover[0]),n1,PartitionGet(p,seed1));
RTreeNodeAddBranch(&(p->cover[1]),n2,PartitionGet(p,seed0));
}
}
static void RTreeNodeAddBranch(rect_t *r, node_t n, branch_t b)
{
int i;
assert(n);
assert(n->count < MAXCARD);
for (i = 0; i < MAXCARD; i++)
if (n->branch[i].child == NULL)
{
n->branch[i] = b;
n->count ++;
break;
}
*r = RectCombine(*r,b.mbr);
}
void RTreePrint(node_t t)
{
int i;
/* printf("rtree([_,_,_,_,_]).\n"); */
printf("rtree(%p,%d,[",t,t->level);
for (i = 0; i < MAXCARD; i++)
{
if (t->branch[i].child != NULL)
{
printf("(%p,",t->branch[i].child);
RectPrint(t->branch[i].mbr);
printf(")");
}
else
{
printf("nil");
}
if (i < MAXCARD-1)
printf(",");
}
printf("]).\n");
if (t->level != 0)
for (i = 0; i < MAXCARD; i++)
if (t->branch[i].child != NULL)
RTreePrint((node_t) t->branch[i].child);
else
break;
}
/*
* Partition related
*/
static partition_t PartitionNew (void)
{
partition_t p;
memset((void *) &p,0, sizeof(p));
p.cover[0] = p.cover[1] = p.cover_all = RectInit();
return p;
}
static void PartitionPush (partition_t *p, branch_t b)
{
assert(p->n < MAXCARD + 1);
p->buffer[p->n] = b;
p->n ++;
p->cover_all = RectCombine(p->cover_all,b.mbr);
}
static branch_t PartitionPop (partition_t *p)
{
assert(p->n > 0);
p->n --;
return p->buffer[p->n];
}
static branch_t PartitionGet (partition_t *p, int n)
{
branch_t b;
assert (p->n > n);
b = p->buffer[n];
p->buffer[n] = PartitionPop(p);
return b;
}
/*
* Rect related
*/
rect_t RectInit (void)
{
rect_t r = {{DBL_MAX, DBL_MAX, DBL_MIN, DBL_MIN}};
return (r);
}
static double RectArea (rect_t r)
{
int i;
double area;
for (i = 0,area = 1; i < NUMDIMS; i++)
area *= r.coords[i+NUMDIMS] - r.coords[i];
/* area = (r.coords[1] - r.coords[0]) * */
/* (r.coords[3] - r.coords[2]); */
return area;
}
static rect_t RectCombine (rect_t r, rect_t s)
{
int i;
rect_t new_rect;
for (i = 0; i < NUMDIMS; i++)
{
new_rect.coords[i] = MIN(r.coords[i],s.coords[i]);
new_rect.coords[i+NUMDIMS] = MAX(r.coords[i+NUMDIMS],s.coords[i+NUMDIMS]);
}
return new_rect;
}
static int RectOverlap (rect_t r, rect_t s)
{
int i;
for (i = 0; i < NUMDIMS; i++)
if (r.coords[i] > s.coords[i + NUMDIMS] ||
s.coords[i] > r.coords[i + NUMDIMS])
return FALSE;
return TRUE;
}
static rect_t RTreeNodeCover(node_t n)
{
int i;
rect_t r = RectInit();
for (i = 0; i < MAXCARD; i++)
if (n->branch[i].child)
{
r = RectCombine (r, n->branch[i].mbr);
}
else
break;
return r;
}
static void RectPrint (rect_t r)
{
int i;
printf("[");
for (i = 0; i < 2*NUMDIMS; i++)
{
printf("%f",r.coords[i]);
if ( i < 2*NUMDIMS - 1)
printf(",");
}
printf("]");
}
yap-6.2.2/packages/udi/rtree.h 000644 000765 000024 00000002413 11457004725 016106 0 ustar 00vsc staff 000000 000000 #ifndef _RTREE_
#define _RTREE_
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE !FALSE
#endif
#define NUMDIMS 2 /* 2d */
struct Rect
{
double coords[2*NUMDIMS]; /* x1min, y1min, ... , x1max, y1max, ...*/
};
typedef struct Rect rect_t;
struct Branch
{
rect_t mbr;
void * child; /*void * so user can store whatever he needs, in case
of non-leaf ndes it stores the child-pointer*/
};
typedef struct Branch branch_t;
#define PGSIZE 196
#define MAXCARD (int)((PGSIZE-(2*sizeof(int)))/ sizeof(struct Branch))
#define MINCARD (MAXCARD / 2)
struct Node
{
int count;
int level;
branch_t branch[MAXCARD];
};
typedef struct Node * node_t;
typedef node_t rtree_t;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
/* CallBack to search function */
typedef int (*SearchHitCallback)(rect_t r, void *data, void *arg);
extern rtree_t RTreeNew (void);
extern void RTreeInsert (rtree_t *, rect_t, void *);
extern int RTreeSearch (rtree_t, rect_t, SearchHitCallback, void *);
extern void RTreeDestroy (rtree_t);
extern void RTreePrint(node_t);
extern rect_t RectInit (void);
struct Partition
{
branch_t buffer[MAXCARD+1];
int n;
rect_t cover_all;
rect_t cover[2];
};
typedef struct Partition partition_t;
#endif /* _RTREE_ */
yap-6.2.2/packages/udi/rtree_udi.c 000644 000765 000024 00000007251 11457004725 016747 0 ustar 00vsc staff 000000 000000 #include
#include
#include
#include
#include
#include "Yap.h"
#include "rtree.h"
#include "clause_list.h"
#include "rtree_udi_i.h"
#include "rtree_udi.h"
static int YAP_IsNumberTerm (Term term, YAP_Float *n)
{
if (YAP_IsIntTerm (term) != FALSE)
{
if (n != NULL)
*n = (YAP_Float) YAP_IntOfTerm (term);
return (TRUE);
}
if (YAP_IsFloatTerm (term) != FALSE)
{
if (n != NULL)
*n = YAP_FloatOfTerm (term);
return (TRUE);
}
return (FALSE);
}
static rect_t RectOfTerm (Term term)
{
YAP_Term tmp;
rect_t rect;
int i;
if (!YAP_IsPairTerm(term))
return (RectInit());
for (i = 0; YAP_IsPairTerm(term) && i < 4; i++)
{
tmp = YAP_HeadOfTerm (term);
if (!YAP_IsNumberTerm(tmp,&(rect.coords[i])))
return (RectInit());
term = YAP_TailOfTerm (term);
}
return (rect);
}
control_t *RtreeUdiInit (Term spec,
void * pred,
int arity){
control_t *control;
YAP_Term arg;
int i, c;
/* YAP_Term mod; */
/* spec = Yap_StripModule(spec, &mod); */
if (! YAP_IsApplTerm(spec))
return (NULL);
control = (control_t *) malloc (sizeof(*control));
assert(control);
memset((void *) control,0, sizeof(*control));
c = 0;
for (i = 1; i <= arity; i ++)
{
arg = YAP_ArgOfTerm(i,spec);
if (YAP_IsAtomTerm(arg)
&& strcmp("+",YAP_AtomName(YAP_AtomOfTerm(arg))) == 0)
{
(*control)[c].pred = pred;
(*control)[c++].arg = i;
}
}
/* for (i = 0; i < NARGS; i++)
printf("%d,%p\t",(*control)[i].arg,(*control)[i].tree);
printf("\n"); */
return control;
}
control_t *RtreeUdiInsert (Term term,control_t *control,void *clausule)
{
int i;
rect_t r;
assert(control);
for (i = 0; i < NARGS && (*control)[i].arg != 0 ; i++)
{
r = RectOfTerm(YAP_ArgOfTerm((*control)[i].arg,term));
if (!(*control)[i].tree)
(*control)[i].tree = RTreeNew();
RTreeInsert(&(*control)[i].tree,r,clausule);
}
/* printf("insert %p\n", clausule); */
return (control);
}
static int callback(rect_t r, void *data, void *arg)
{
callback_m_t x;
x = (callback_m_t) arg;
return Yap_ClauseListExtend(x->cl,data,x->pred);
}
/*ARGS ARE AVAILABLE*/
void *RtreeUdiSearch (control_t *control)
{
rect_t r;
int i;
struct ClauseList clauselist;
struct CallbackM cm;
callback_m_t c;
YAP_Term Constraints;
/*RTreePrint ((*control)[0].tree);*/
for (i = 0; i < NARGS && (*control)[i].arg != 0 ; i++)
if (YAP_IsAttVar(YAP_A((*control)[i].arg)))
{
/*get the constraits rect*/
Constraints = YAP_AttsOfVar(YAP_A((*control)[i].arg));
/* Yap_DebugPlWrite(Constraints); */
r = RectOfTerm(YAP_ArgOfTerm(2,Constraints));
c = &cm;
c->cl = Yap_ClauseListInit(&clauselist);
c->pred = (*control)[i].pred;
if (!c->cl)
return NULL; /*? or fail*/
RTreeSearch((*control)[i].tree, r, callback, c);
Yap_ClauseListClose(c->cl);
if (Yap_ClauseListCount(c->cl) == 0)
{
Yap_ClauseListDestroy(c->cl);
return Yap_FAILCODE();
}
if (Yap_ClauseListCount(c->cl) == 1)
{
return Yap_ClauseListToClause(c->cl);
}
return Yap_ClauseListCode(c->cl);
}
return NULL; /*YAP FALLBACK*/
}
int RtreeUdiDestroy(control_t *control)
{
int i;
assert(control);
for (i = 0; i < NARGS && (*control)[i].arg != 0; i++)
{
if ((*control)[i].tree)
RTreeDestroy((*control)[i].tree);
}
free(control);
control = NULL;
return TRUE;
}
yap-6.2.2/packages/udi/rtree_udi_i.h 000644 000765 000024 00000000442 11457004725 017257 0 ustar 00vsc staff 000000 000000 #ifndef _RTREE_UDI_I_
#define _RTREE_UDI_I_
#define NARGS 5
struct Control
{
int arg;
void *pred;
rtree_t tree;
};
typedef struct Control control_t[NARGS];
struct CallbackM
{
clause_list_t cl;
void * pred;
};
typedef struct CallbackM * callback_m_t;
#endif /* _RTREE_UDI_I_ */
yap-6.2.2/packages/tai/libtai/ 000755 000765 000024 00000000000 11702065316 016050 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/tai/Makefile.in 000755 000765 000024 00000002400 11507254050 016646 0 ustar 00vsc staff 000000 000000 #
# default base directory for YAP installation
# (EROOT for architecture-dependent files)
#
prefix = @prefix@
exec_prefix = @exec_prefix@
ROOTDIR = $(prefix)
EROOTDIR = @exec_prefix@
abs_top_builddir = @abs_top_builddir@
#
# where the binary should be
#
BINDIR = $(EROOTDIR)/bin
#
# where YAP should look for libraries
#
LIBDIR=@libdir@
YAPLIBDIR=@libdir@/Yap
#
#
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
CC=@CC@
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include -I$(srcdir)/../PLStream
#
#
# You shouldn't need to change what follows.
#
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
SHELL=/bin/sh
RANLIB=@RANLIB@
srcdir=@srcdir@
SO=@SO@
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
CWD=$(PWD)
#
OBJS=pl-tai.o
SOBJS=pl-tai.@SO@
#in some systems we just create a single object, in others we need to
# create a libray
all: $(SOBJS)
pl-tai.o: $(srcdir)/pl-tai.c
(cd libtai ; $(MAKE))
$(CC) -c $(CFLAGS) $(srcdir)/pl-tai.c -o pl-tai.o
@DO_SECOND_LD@pl-tai.@SO@: pl-tai.o
@DO_SECOND_LD@ @SHLIB_LD@ $(LDFLAGS) -o pl-tai.@SO@ pl-tai.o libtai/libtai.a @EXTRA_LIBS_FOR_SWIDLLS@
install: all
$(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(YAPLIBDIR)
clean:
rm -f *.o *~ $(OBJS) $(SOBJS) *.BAK
-(cd libtai && $(MAKE) clean)
yap-6.2.2/packages/tai/pl-tai.c 000755 000765 000024 00000054750 11457004725 016160 0 ustar 00vsc staff 000000 000000 /* $Id$
Part of SWI-Prolog
Author: Jan Wielemaker
E-mail: wielemak@science.uva.nl
WWW: http://www.swi-prolog.org
Copyright (C): 1985-2007, University of Amsterdam
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Solaris has asctime_r() with 3 arguments. Using _POSIX_PTHREAD_SEMANTICS
is supposed to give the POSIX standard one.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#if defined(__sun__) || defined(__sun)
#define _POSIX_PTHREAD_SEMANTICS 1
#endif
#include
#include "pl-incl.h"
#include "libtai/taia.h"
#include "libtai/caltime.h"
#include
#include
#if defined(__WINDOWS__) || defined (__CYGWIN__) || defined (__MINGW32__)
#define timezone _timezone
#ifndef _POSIX
#endif
#define localtime_r(_Time, _Tm) ({ struct tm *___tmp_tm = \
localtime((_Time)); \
if (___tmp_tm) { \
*(_Tm) = *___tmp_tm; \
___tmp_tm = (_Tm); \
} \
___tmp_tm; })
#define asctime_r(_Tm, _Buf) ({ char *___tmp_tm = asctime((_Tm)); \
if (___tmp_tm) \
___tmp_tm = \
strcpy((_Buf),___tmp_tm);\
___tmp_tm; })
#include
#else
extern char *tzname[2];
#ifdef HAVE_VAR_TIMEZONE
extern long timezone;
#endif
#endif
#define TAI_UTC_OFFSET LL(4611686018427387914)
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
struct ftm is a `floating' version of the system struct tm.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#define HAS_STAMP 0x0001
#define HAS_WYDAY 0x0002
typedef struct ftm
{ struct tm tm; /* System time structure */
double sec; /* float version of tm.tm_sec */
int utcoff; /* offset to UTC (seconds) */
atom_t tzname; /* Name of timezone */
int isdst; /* Daylight saving time */
double stamp; /* Time stamp (sec since 1970-1-1) */
int flags; /* Filled fields */
} ftm;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
tz_offset() returns the offset from UTC in seconds.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static void
do_tzset()
{ static int done = FALSE;
if ( !done )
{ tzset();
done = TRUE;
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POSIX provides the variable timezone, providing the offset of the
current timezone WEST of GMT in seconds. Some systems (FreeBSD) do not
provide that. Instead thet provide tm_gmtoff in struct tm, but this
value is EAST and includes the DST offset.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static int
tz_offset()
{
#if defined(HAVE_VAR_TIMEZONE) || _WIN64 || _WIN32
do_tzset();
return timezone;
#else
#ifdef HAVE_STRUCT_TIME_TM_GMTOFF
static int offset = -1;
if ( offset == -1 )
{ time_t t = time(NULL);
struct tm tm;
localtime_r(&t, &tm);
offset = -tm.tm_gmtoff;
if ( tm.tm_isdst > 0 )
offset += 3600;
/*Use to verify on systems where we know both. In Western Europe the
offset must be -3600, both in winter and summer.*/
/*Sdprintf("timezone offset = %d (must be %d)\n", offset, timezone);*/
}
return offset;
#else
#error "Do not know how to get timezone info"
#endif
#endif
}
static char *
tz_name(int dst)
{ dst = (dst != 0);
do_tzset();
return tzname[dst];
}
static atom_t
tz_name_as_atom(int dst)
{ static atom_t a[2];
dst = (dst != 0); /* 0 or 1 */
if ( !a[dst] )
{ wchar_t wbuf[256];
const char *str = tz_name(dst);
size_t n;
if ( (n = mbstowcs(wbuf, str, sizeof(wbuf)/sizeof(wbuf[0])-1)) != (size_t)-1 )
{ a[dst] = PL_new_atom_wchars(n, wbuf);
} else
{ a[dst] = PL_new_atom(str);
}
}
return a[dst];
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
unify_taia(): Unify a TAIA date as a Prolog double using the POSIX 1970
origin;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
static int
unify_taia(term_t t, struct taia *taia)
{ double d = (double)((int64_t)taia->sec.x - TAI_UTC_OFFSET);
d += taia->nano / 1e9;
return PL_unify_float(t, d);
}
*/
static int
get_taia(term_t t, struct taia *taia, double *seconds)
{ double d;
if ( PL_get_float(t, &d) )
{ double fp, ip;
if ( seconds )
*seconds = d;
fp = modf(d, &ip);
if ( fp < 0 )
{ fp += 1.0;
ip -= 1.0;
}
taia->sec.x = (int64_t)ip + TAI_UTC_OFFSET;
taia->nano = (long)(fp*1e9);
taia->atto = 0L;
return TRUE;
}
return FALSE;
}
static int
get_tz_arg(int i, term_t t, term_t a, atom_t *tz)
{ GET_LD
atom_t name;
_PL_get_arg(i, t, a);
if ( !PL_get_atom_ex(a, &name) )
fail;
if ( name != ATOM_minus )
*tz = name;
succeed;
}
static int
get_int_arg(int i, term_t t, term_t a, int *val)
{ GET_LD
_PL_get_arg(i, t, a);
return PL_get_integer_ex(a, val);
}
static int
get_float_arg(int i, term_t t, term_t a, double *val)
{ GET_LD
_PL_get_arg(i, t, a);
return PL_get_float_ex(a, val);
}
static int
get_bool_arg(int i, term_t t, term_t a, int *val)
{ GET_LD
atom_t name;
_PL_get_arg(i, t, a);
if ( PL_get_atom(a, &name) )
{ if ( name == ATOM_true )
{ *val = TRUE;
return TRUE;
} else if ( name == ATOM_false || name == ATOM_minus )
{ *val = FALSE;
return TRUE;
}
}
return PL_get_bool_ex(a, val); /* generate an error */
}
static int
get_ftm(term_t t, ftm *ftm)
{ GET_LD
if ( PL_is_functor(t, FUNCTOR_date9) )
{ term_t tmp = PL_new_term_ref();
memset(ftm, 0, sizeof(*ftm));
if ( get_int_arg (1, t, tmp, &ftm->tm.tm_year) &&
get_int_arg (2, t, tmp, &ftm->tm.tm_mon) &&
get_int_arg (3, t, tmp, &ftm->tm.tm_mday) &&
get_int_arg (4, t, tmp, &ftm->tm.tm_hour) &&
get_int_arg (5, t, tmp, &ftm->tm.tm_min) &&
get_float_arg(6, t, tmp, &ftm->sec) &&
get_int_arg (7, t, tmp, &ftm->utcoff) &&
get_tz_arg (8, t, tmp, &ftm->tzname) &&
get_bool_arg (9, t, tmp, &ftm->isdst) )
{ double fp, ip;
fixup:
fp = modf(ftm->sec, &ip);
if ( fp < 0.0 )
{ fp += 1.0;
ip -= 1.0;
}
ftm->tm.tm_sec = (int)ip;
ftm->tm.tm_year -= 1900; /* 1900 based */
ftm->tm.tm_mon--; /* 0-based */
succeed;
}
} else if ( PL_is_functor(t, FUNCTOR_date3) )
{ term_t tmp = PL_new_term_ref();
memset(ftm, 0, sizeof(*ftm));
if ( get_int_arg (1, t, tmp, &ftm->tm.tm_year) &&
get_int_arg (2, t, tmp, &ftm->tm.tm_mon) &&
get_int_arg (3, t, tmp, &ftm->tm.tm_mday) )
goto fixup;
}
fail;
}
/** void cal_ftm(ftm *ftm, int required)
compute missing fields from fmt
*/
void
cal_ftm(ftm *ftm, int required)
{ int missing = ftm->flags^required;
if ( missing ) /* we need something, so we always */
{ struct caltime ct; /* need the stamp */
struct tai tai;
ct.date.year = ftm->tm.tm_year+1900;
ct.date.month = ftm->tm.tm_mon+1;
ct.date.day = ftm->tm.tm_mday;
ct.hour = ftm->tm.tm_hour;
ct.minute = ftm->tm.tm_min;
ct.second = ftm->tm.tm_sec;
ct.offset = -ftm->utcoff / 60; /* TBD: make libtai speak seconds */
caltime_tai(&ct, &tai);
ftm->stamp = (double)((int64_t)tai.x - TAI_UTC_OFFSET);
ftm->stamp -= (double)ct.second;
ftm->stamp += ftm->sec;
ftm->flags |= HAS_STAMP;
if ( missing & HAS_WYDAY )
{ caltime_utc(&ct, &tai, &ftm->tm.tm_wday, &ftm->tm.tm_yday);
ftm->flags |= HAS_WYDAY;
}
}
}
static
PRED_IMPL("stamp_date_time", 3, stamp_date_time, 0)
{ PRED_LD
struct taia taia;
term_t compound = A2;
double argsec;
if ( get_taia(A1, &taia, &argsec) )
{ struct caltime ct;
int weekday, yearday;
double sec;
int utcoffset;
int done = FALSE;
atom_t alocal;
atom_t tzatom = ATOM_minus;
atom_t dstatom = ATOM_minus;
if ( PL_get_atom(A3, &alocal) )
{ if ( alocal == ATOM_local )
{ time_t unixt;
int64_t ut64;
struct tm tm;
utcoffset = tz_offset();
ut64 = taia.sec.x - TAI_UTC_OFFSET;
unixt = (time_t) ut64;
if ( (int64_t)unixt == ut64 )
{ double ip;
localtime_r(&unixt, &tm);
sec = (double)tm.tm_sec + modf(argsec, &ip);
ct.date.year = tm.tm_year+1900;
ct.date.month = tm.tm_mon+1;
ct.date.day = tm.tm_mday;
ct.hour = tm.tm_hour;
ct.minute = tm.tm_min;
tzatom = tz_name_as_atom(tm.tm_isdst);
if ( tm.tm_isdst > 0 )
{ utcoffset -= 3600;
dstatom = ATOM_true;
} else
{ dstatom = ATOM_false;
}
done = TRUE;
}
} else if ( alocal == ATOM_utc )
{ utcoffset = 0;
tzatom = alocal;
} else
{ return PL_error(NULL, 0, NULL, ERR_DOMAIN, ATOM_timezone, A3);
}
} else if ( !PL_get_integer_ex(A3, &utcoffset) )
{ fail;
}
if ( !done )
{ taia.sec.x -= utcoffset;
caltime_utc(&ct, &taia.sec, &weekday, &yearday);
sec = (double)ct.second+(double)taia.nano/1e9;
}
return PL_unify_term(compound,
PL_FUNCTOR, FUNCTOR_date9,
PL_LONG, ct.date.year,
PL_INT, ct.date.month,
PL_INT, ct.date.day,
PL_INT, ct.hour,
PL_INT, ct.minute,
PL_FLOAT, sec,
PL_INT, utcoffset,
PL_ATOM, tzatom,
PL_ATOM, dstatom);
}
/* time_stamp */
return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_float, A1);
}
static
PRED_IMPL("date_time_stamp", 2, date_time_stamp, 0)
{ ftm ftm;
if ( !get_ftm(A1, &ftm) )
fail;
cal_ftm(&ftm, HAS_STAMP);
return PL_unify_float(A2, ftm.stamp);
}
/*******************************
* GLIBC FUNCTIONS *
*******************************/
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
These functions support strftime() %g, %G and %V. Code is copied from
glibc 2.3.5. As Glibc is LGPL, there are no license issues.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#ifndef __isleap
/* Nonzero if YEAR is a leap year (every 4 years,
except every 100th isn't, and every 400th is). */
# define __isleap(year) \
((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
#endif
/* The number of days from the first day of the first ISO week of this
year to the year day YDAY with week day WDAY. ISO weeks start on
Monday; the first ISO week has the year's first Thursday. YDAY may
be as small as YDAY_MINIMUM. */
#define ISO_WEEK_START_WDAY 1 /* Monday */
#define ISO_WEEK1_WDAY 4 /* Thursday */
#define YDAY_MINIMUM (-366)
#ifdef __GNUC__
__inline__
#endif
static int
iso_week_days(int yday, int wday)
{ /* Add enough to the first operand of % to make it nonnegative. */
int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7;
return (yday
- (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7
+ ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY);
}
/*******************************
* ERRORS *
*******************************/
static int
fmt_domain_error(const char *key, int value)
{ GET_LD
term_t t = PL_new_term_ref();
PL_put_integer(t, value);
return PL_error(NULL, 0, NULL, ERR_DOMAIN, PL_new_atom(key), t);
}
static int
fmt_not_implemented(const char *key)
{ GET_LD
term_t t = PL_new_term_ref();
PL_put_atom_chars(t, key);
return PL_error(NULL, 0, NULL, ERR_EXISTENCE, PL_new_atom("format"), t);
}
/*******************************
* FORMATTING *
*******************************/
#define OUT1DIGIT(fd, val) \
{ Sputcode('0'+(val)%10, fd); \
}
#define OUT2DIGITS(fd, val) \
{ Sputcode('0'+((val)/10)%10, fd); \
Sputcode('0'+(val)%10, fd); \
}
#define OUT3DIGITS(fd, val) \
{ Sputcode('0'+((val)/100)%10, fd); \
Sputcode('0'+((val)/10)%10, fd); \
Sputcode('0'+(val)%10, fd); \
}
#define OUT2DIGITS_SPC(fd, val) \
{ Sputcode(((val)/10 == 0 ? ' ' : '0'+((val)/10)%10), fd); \
Sputcode('0'+(val)%10, fd); \
}
#define OUTNUMBER(fd, fmt, val) \
{ Sfprintf(fd, fmt, val); \
}
#define SUBFORMAT(f) \
{ format_time(fd, f, ftm, posix); \
}
#define OUTCHR(fd, c) \
{ Sputcode(c, fd); \
}
#define OUTSTR(str) \
{ Sfputs(str, fd); \
}
#define OUTSTRA(str) \
{ foutstra(str, fd); \
}
#define OUTATOM(a) \
{ writeAtomToStream(fd, a); \
}
static void
foutstra(const char *str, IOSTREAM *fd)
{ wchar_t wbuf[256];
size_t n;
if ( (n = mbstowcs(wbuf, str, sizeof(wbuf)/sizeof(wbuf[0])-1)) != (size_t)-1 )
{ wchar_t *p;
for(p=wbuf; n-- > 0; p++)
Sputcode(*p, fd);
}
}
static const char *abbred_weekday[] =
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
static const char *weekday[] =
{ "Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday" };
static const char *abbred_month[] =
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
static const char *month[] =
{ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
#define NOARG (-1)
static int
format_time(IOSTREAM *fd, const wchar_t *format, ftm *ftm, int posix)
{ wint_t c;
while((c = *format++))
{ int arg = NOARG;
switch(c)
{ case '%':
arg = NOARG;
fmt_next:
switch((c = *format++))
{ case 'a': /* %a: abbreviated weekday */
case 'A': /* %A: weekday */
case 'b': /* %b: abbreviated month */
case 'B': /* %B: month */
if ( posix )
{ const char *s;
cal_ftm(ftm, HAS_STAMP|HAS_WYDAY);
switch( c )
{ case 'a':
s = abbred_weekday[ftm->tm.tm_wday];
break;
case 'A':
s = weekday[ftm->tm.tm_wday];
break;
case 'b':
s = abbred_month[ftm->tm.tm_mon];
break;
case 'B':
s = month[ftm->tm.tm_mon];
break;
default:
s = NULL;
assert(0);
}
OUTSTR(s);
break;
}
/*FALLTHROUGH*/
case 'c': /* %c: default representation */
case 'p': /* %p: AM/PM (locale) */
case 'P': /* %P: am/pm (locale) */
case 'x': /* %x: date in locale */
case 'X': /* %X: time in locale */
case_b:
{ char fmt[3];
char buf[256];
size_t n;
fmt[0] = '%';
fmt[1] = (char)c;
fmt[2] = EOS;
cal_ftm(ftm, HAS_STAMP|HAS_WYDAY);
/* conversion is not thread-safe under locale switch */
n = strftime(buf, sizeof(buf), fmt, &ftm->tm);
OUTSTRA(buf);
break;
}
case 'C': /* (year/100) as a 2-digit int */
{ int year = ftm->tm.tm_year+1900;
if ( year >= 0 && year < 10000 )
{ int century = year/100;
OUT2DIGITS(fd, century);
} else
{ return fmt_domain_error("%C", year);
}
break;
}
case 'd': /* day of the month */
OUT2DIGITS(fd, ftm->tm.tm_mday);
break;
case 'D': /* %m/%d/%y */
SUBFORMAT(L"%m/%d/%y");
break;
case 'e': /* day of the month */
OUT2DIGITS_SPC(fd, ftm->tm.tm_mday);
break;
case 'E': /* alternative format */
return fmt_not_implemented("%E");
case 'F': /* ISO 8601 date format */
SUBFORMAT(L"%Y-%m-%d");
break;
case 'G':
case 'g':
case 'V':
{ int year, days;
cal_ftm(ftm, HAS_STAMP|HAS_WYDAY);
year = ftm->tm.tm_year+1900;
days = iso_week_days(ftm->tm.tm_yday, ftm->tm.tm_wday);
if ( days < 0 )
{ year--;
days = iso_week_days(ftm->tm.tm_yday + (365 + __isleap (year)),
ftm->tm.tm_wday);
} else
{ int d = iso_week_days(ftm->tm.tm_yday - (365 + __isleap (year)),
ftm->tm.tm_wday);
if (0 <= d)
{ /* This ISO week belongs to the next year. */
year++;
days = d;
}
}
switch(c)
{ case 'g':
OUT2DIGITS(fd, (year % 100 + 100) % 100);
break;
case 'G':
OUTNUMBER(fd, "%d", year);
break;
case 'V':
OUT2DIGITS(fd, days/7+1);
break;
}
break;
}
case 'h': /* Equivalent to %b. (SU) */
c = 'b';
goto case_b;
case 'H': /* 0..23 hours */
OUT2DIGITS(fd, ftm->tm.tm_hour);
break;
case 'I': /* 01..12 hours */
OUT2DIGITS(fd, (ftm->tm.tm_hour)%12);
break;
case 'j': /* yday (001..366) */
cal_ftm(ftm, HAS_WYDAY);
OUT3DIGITS(fd, ftm->tm.tm_yday+1);
break;
case 'k': /* 0..23 hours (leading space) */
OUT2DIGITS_SPC(fd, ftm->tm.tm_hour);
break;
case 'l': /* 1..12 hours (leading space) */
OUT2DIGITS_SPC(fd, (ftm->tm.tm_hour)%12);
break;
case 'm': /* 01..12 month */
OUT2DIGITS(fd, ftm->tm.tm_mon+1);
break;
case 'M': /* 00..59 minute */
OUT2DIGITS(fd, ftm->tm.tm_min);
break;
case 'n': /* newline */
OUTCHR(fd, '\n');
break;
case 'O':
return fmt_not_implemented("%O");
case 'r': /* The time in a.m./p.m. notation */
SUBFORMAT(L"%I:%M:%S %p"); /* TBD: :-separator locale handling */
break;
case 'R':
SUBFORMAT(L"%H:%M");
break;
case 'f': /* Microseconds */
{ int digits = (arg == NOARG ? 6 : arg);
if ( digits > 0 )
{ double ip;
char fmt[64];
cal_ftm(ftm, HAS_STAMP);
Ssprintf(fmt, "%%0%dlld", digits);
OUTNUMBER(fd, fmt, (long)(modf(ftm->stamp, &ip) *
pow(10, digits)));
}
break;
}
case 's': /* Seconds since 1970 */
cal_ftm(ftm, HAS_STAMP);
OUTNUMBER(fd, "%.0f", ftm->stamp);
break;
case 'S': /* Seconds */
OUT2DIGITS(fd, ftm->tm.tm_sec);
break;
case 't': /* tab */
OUTCHR(fd, '\t');
break;
case 'T':
SUBFORMAT(L"%H:%M:%S");
break;
case 'u': /* 1..7 weekday, mon=1 */
{ int wday;
cal_ftm(ftm, HAS_WYDAY);
wday = (ftm->tm.tm_wday - 1 + 7) % 7 + 1;
OUT1DIGIT(fd, wday);
break;
}
case 'U': /* 00..53 weeknumber */
{ int wk;
cal_ftm(ftm, HAS_WYDAY);
wk = (ftm->tm.tm_yday - (ftm->tm.tm_yday - ftm->tm.tm_wday + 7) % 7 + 7) / 7;
OUT2DIGITS(fd, wk);
break;
}
case 'w': /* 0..6 weekday */
cal_ftm(ftm, HAS_WYDAY);
OUT1DIGIT(fd, ftm->tm.tm_wday);
break;
case 'W': /* 00..53 monday-based week number */
{ int wk;
cal_ftm(ftm, HAS_WYDAY);
wk = (ftm->tm.tm_yday - (ftm->tm.tm_yday - ftm->tm.tm_wday + 8) % 7 + 7) / 7;
OUT2DIGITS(fd, wk);
break;
}
case 'y': /* 00..99 (year) */
OUT2DIGITS(fd, (ftm->tm.tm_year+1900) % 100);
break;
case 'Y': /* Year (decimal) */
OUTNUMBER(fd, "%d", ftm->tm.tm_year+1900);
break;
case 'z': /* Time-zone as offset */
{ int min = -ftm->utcoff/60;
if ( min >= 0 )
{ OUTCHR(fd, '+');
} else
{ min = -min;
OUTCHR(fd, '-');
}
OUT2DIGITS(fd, min/60);
OUT2DIGITS(fd, min%60);
break;
}
case 'Z': /* Time-zone as name */
if ( ftm->tzname )
{ OUTATOM(ftm->tzname);
} else
{ OUTSTRA(tz_name(ftm->tm.tm_isdst));
}
break;
case '+':
{ char buf[26];
cal_ftm(ftm, HAS_WYDAY);
asctime_r(&ftm->tm, buf);
buf[24] = EOS;
OUTSTRA(buf);
}
break;
case '%':
OUTCHR(fd, '%');
break;
default:
if ( isdigit(c) )
{ if ( arg == NOARG )
arg = c - '0';
else
arg = arg*10+(c-'0');
goto fmt_next;
}
}
break;
default:
OUTCHR(fd, c);
}
}
return TRUE;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
format_time(+Spec, +Format, +Stamp)
Issues:
* Localtime/DST
* Year is an int (not so bad)
* Portability
* Sub-second times
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
static foreign_t
pl_format_time(term_t out, term_t format, term_t time, int posix)
{ struct taia taia;
struct caltime ct;
struct ftm tb;
int weekday, yearday;
wchar_t *fmt;
time_t unixt;
int64_t ut64;
size_t fmtlen;
redir_context ctx;
if ( !PL_get_wchars(format, &fmtlen, &fmt,
CVT_ATOM|CVT_STRING|CVT_LIST|CVT_EXCEPTION) )
fail;
memset(&tb, 0, sizeof(tb));
if ( get_taia(time, &taia, &tb.stamp) )
{ double ip;
ut64 = taia.sec.x - TAI_UTC_OFFSET;
unixt = (time_t) ut64;
if ( (int64_t)unixt == ut64 )
{ tb.utcoff = tz_offset();
localtime_r(&unixt, &tb.tm);
tb.sec = (double)tb.tm.tm_sec + modf(tb.stamp, &ip);
if ( tb.tm.tm_isdst > 0 )
{ tb.utcoff -= 3600;
tb.isdst = TRUE;
}
tb.tzname = tz_name_as_atom(tb.tm.tm_isdst);
tb.flags = HAS_STAMP|HAS_WYDAY;
} else
{ caltime_utc(&ct, &taia.sec, &weekday, &yearday);
tb.tm.tm_sec = ct.second;
tb.tm.tm_min = ct.minute;
tb.tm.tm_hour = ct.hour;
tb.tm.tm_mday = ct.date.day;
tb.tm.tm_mon = ct.date.month - 1;
tb.tm.tm_year = ct.date.year - 1900;
tb.tm.tm_wday = weekday;
tb.tm.tm_yday = yearday;
tb.tzname = ATOM_utc;
tb.utcoff = 0;
}
} else if ( !get_ftm(time, &tb) )
{ return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_time, time);
}
if ( !setupOutputRedirect(out, &ctx, FALSE) )
fail;
if ( format_time(ctx.stream, fmt, &tb, posix) )
return closeOutputRedirect(&ctx); /* takes care of I/O errors */
discardOutputRedirect(&ctx);
fail;
}
static
PRED_IMPL("format_time", 3, format_time3, 0)
{ return pl_format_time(A1, A2, A3, FALSE);
}
static
PRED_IMPL("format_time", 4, format_time4, 0)
{ PRED_LD
int posix = FALSE;
atom_t locale;
if ( !PL_get_atom_ex(A4, &locale) )
return FALSE;
if ( locale == ATOM_posix )
posix = TRUE;
else
return PL_error(NULL, 0, NULL, ERR_DOMAIN, ATOM_locale, A4);
return pl_format_time(A1, A2, A3, posix);
}
/*******************************
* PUBLISH PREDICATES *
*******************************/
BeginPredDefs(tai)
PRED_DEF("stamp_date_time", 3, stamp_date_time, 0)
PRED_DEF("date_time_stamp", 2, date_time_stamp, 0)
PRED_DEF("format_time", 3, format_time3, 0)
PRED_DEF("format_time", 4, format_time4, 0)
PRED_DEF("swi_stamp_date_time", 3, stamp_date_time, 0)
PRED_DEF("swi_date_time_stamp", 2, date_time_stamp, 0)
PRED_DEF("swi_format_time", 3, format_time3, 0)
PRED_DEF("swi_format_time", 4, format_time4, 0)
EndPredDefs
#if _YAP_NOT_INSTALLED_
install_t
install(void)
{
PL_register_extensions(PL_predicates_from_tai);
}
#endif
yap-6.2.2/packages/tai/libtai/BLURB 000644 000765 000024 00000002561 11457004725 016651 0 ustar 00vsc staff 000000 000000 libtai is a library for storing and manipulating dates and times.
libtai supports two time scales: (1) TAI64, covering a few hundred
billion years with 1-second precision; (2) TAI64NA, covering the same
period with 1-attosecond precision. Both scales are defined in terms of
TAI, the current international real time standard.
libtai provides an internal format for TAI64, struct tai, designed for
fast time manipulations. The tai_pack() and tai_unpack() routines
convert between struct tai and a portable 8-byte TAI64 storage format.
libtai provides similar internal and external formats for TAI64NA.
libtai provides struct caldate to store dates in year-month-day form. It
can convert struct caldate, under the Gregorian calendar, to a modified
Julian day number for easy date arithmetic.
libtai provides struct caltime to store calendar dates and times along
with UTC offsets. It can convert from struct tai to struct caltime in
UTC, accounting for leap seconds, for accurate date and time display. It
can also convert back from struct caltime to struct tai for user input.
Its overall UTC-to-TAI conversion speed is 100x better than the usual
UNIX mktime() implementation.
This version of libtai requires a UNIX system with gettimeofday(). It
will be easy to port to other operating systems with compilers
supporting 64-bit arithmetic.
The libtai source code is in the public domain.
yap-6.2.2/packages/tai/libtai/caldate.3 000644 000765 000024 00000001631 11457004725 017536 0 ustar 00vsc staff 000000 000000 .TH caldate 3
.SH NAME
caldate \- calendar dates
.SH SYNTAX
.B #include
unsigned int \fBcaldate_fmt\fP(\fIs\fR,&\fIcd\fR);
.br
unsigned int \fBcaldate_scan\fP(\fIs\fR,&\fIcd\fR);
struct caldate \fIcd\fR;
.br
char *\fIs\fR;
.SH DESCRIPTION
A
.B struct caldate
value is a calendar date.
It has three components:
.BR year ,
.B month
(1...12),
and
.B day
(1...31).
.B caldate_fmt
prints
.I cd
in ISO style (yyyy-mm-dd)
into the character buffer
.IR s ,
without a terminating NUL.
It returns the number of characters printed.
.I s
may be zero;
then
.B caldate_fmt
returns the number of characters that would have been printed.
.B caldate_scan
reads a calendar date in ISO style
from the beginning of the character buffer
.I s
and puts it into
.IR cd .
It returns the number of characters read.
If
.I s
does not start with an ISO-style date,
.B caldate_scan
returns 0.
.SH "SEE ALSO"
caldate_mjd(3),
caltime(3)
yap-6.2.2/packages/tai/libtai/caldate.h 000644 000765 000024 00000000715 11457004725 017625 0 ustar 00vsc staff 000000 000000 #ifndef CALDATE_H
#define CALDATE_H
struct caldate {
long year;
int month;
int day;
} ;
extern unsigned int caldate_fmt(char *s, struct caldate *cd);
extern unsigned int caldate_scan(char *s, struct caldate *cd);
extern void caldate_frommjd(struct caldate *cd, int64_t day, int *pwday, int *pyday);
extern long caldate_mjd(struct caldate *cd);
extern void caldate_normalize(struct caldate *cd);
extern void caldate_easter(struct caldate *cd);
#endif
yap-6.2.2/packages/tai/libtai/caldate_fmjd.c 000644 000765 000024 00000002065 11457004725 020620 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "caldate.h"
void caldate_frommjd(struct caldate *cd, int64_t day, int *pwday, int *pyday)
{
long year;
long month;
int yday;
year = (long)(day / LL(146097));
day %= LL(146097);
day += LL(678881);
while (day >= LL(146097)) { day -= LL(146097); ++year; }
/* year * 146097 + day - 678881 is MJD; 0 <= day < 146097 */
/* 2000-03-01, MJD 51604, is year 5, day 0 */
if (pwday) *pwday = (int)((day + 3) % 7);
year *= 4;
if (day == LL(146096)) { year += 3; day = 36524L; }
else { year += (long)(day / LL(36524)); day %= LL(36524); }
year *= 25;
year += (long)(day / 1461);
day %= 1461;
year *= 4;
yday = (day < 306);
if (day == 1460) { year += 3; day = 365; }
else { year += (long)(day / 365); day %= 365; }
yday += (long)day;
day *= 10;
month = (long)((day + 5) / 306);
day = (day + 5) % 306;
day /= 10;
if (month >= 10) { yday -= 306; ++year; month -= 10; }
else { yday += 59; month += 2; }
cd->year = year;
cd->month = month + 1;
cd->day = (long)(day + 1);
if (pyday) *pyday = yday;
}
yap-6.2.2/packages/tai/libtai/caldate_fmt.c 000644 000765 000024 00000001075 11457004725 020466 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "caldate.h"
unsigned int caldate_fmt(char *s, struct caldate *cd)
{
long x;
int i = 0;
x = cd->year; if (x < 0) x = -x; do { ++i; x /= 10; } while(x);
if (s) {
x = cd->year;
if (x < 0) { x = -x; *s++ = '-'; }
s += i; do { *--s = '0' + (char)(x % 10); x /= 10; } while(x); s += i;
x = cd->month;
s[0] = '-'; s[2] = '0' + (char)(x % 10); x /= 10; s[1] = '0' + (char)(x % 10);
x = cd->day;
s[3] = '-'; s[5] = '0' + (char)(x % 10); x /= 10; s[4] = '0' + (char)(x % 10);
}
return (cd->year < 0) + i + 6;
}
yap-6.2.2/packages/tai/libtai/caldate_mjd.3 000644 000765 000024 00000004645 11457004725 020400 0 ustar 00vsc staff 000000 000000 .TH caldate_mjd 3
.SH NAME
caldate_mjd \- manipulate calendar dates
.SH SYNTAX
.B #include
void \fBcaldate_frommjd\fP(&\fIcd\fR,\fIday\fR,\fIweekday\fR,\fIyearday\fR);
.br
long \fBcaldate_mjd\fP(&\fIcd\fR);
.br
void \fBcaldate_normalize\fP(&\fIcd\fR);
void \fBcaldate_easter\fP(&\fIcd\fR);
struct caldate \fIcd\fR;
.br
long \fIday\fR;
.br
int *\fIweekday\fR;
.br
int *\fIyearday\fR;
.SH "BASIC CONVERSIONS"
Every calendar date has a
.I modified Julian day number\fR.
The day number increases by 1 every day.
Day number 0 is 17 November 1858.
Day number 51604 is 1 March 2000.
.B caldate_frommjd
puts into
.I cd
the date corresponding to the modified Julian day number
.IR day .
.B caldate_frommjd
also computes the day of the week (0 through 6)
and the day of the year (0 through 365).
It stores the day of the week in
.B *\fIweekday
if
.I weekday
is nonzero.
It stores the day of the year in
.B *\fIyearday
if
.I yearday
is nonzero.
.B caldate_mjd
returns the modified Julian day number corresponding to the date in
.IR cd .
.B caldate_mjd
accepts days outside the range 1 to 31,
referring to days before the beginning or after the end of the month.
It also accepts months outside the range 1 to 12,
referring to months before the beginning or after the end of the year.
.B caldate_normalize
calls
.B caldate_frommjd
with the result of
.BR caldate_mjd .
This means that it accepts out-of-range months and out-of-range days in
.IR cd ,
and puts a valid calendar date back into
.IR cd .
.SH "OTHER FUNCTIONS"
.B caldate_easter
reads the year from
.I cd
and then changes
.I cd
to the date of Easter in the same year.
.SH LIMITATIONS
The
.B caldate
routines currently support the Gregorian calendar,
which was defined in 1582 and adopted at different times
in different countries.
For earlier dates the
.B caldate
routines work with
``virtual Gregorian,''
defined mathematically by the 400-year Gregorian cycle
for years before 1582.
The Julian calendar is not supported.
The Gregorian calendar will be replaced by a new calendar
within a few thousand years.
The
.B caldate_frommjd
and
.B caldate_mjd
routines will be upgraded accordingly.
The current
.B caldate_frommjd
and
.B caldate_mjd
routines are not useful for dates far in the future.
Day numbers will overflow a 32-bit
.B long
sometime after the year 5000000;
all systems should upgrade to 64-bit
.BR long s
before then.
.B caldate_mjd
does not check for overflow.
.SH "SEE ALSO"
caldate(3)
yap-6.2.2/packages/tai/libtai/caldate_mjd.c 000644 000765 000024 00000001461 11457004725 020451 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "caldate.h"
static unsigned long times365[4] = { 0, 365, 730, 1095 } ;
static unsigned long times36524[4] = { 0, 36524UL, 73048UL, 109572UL } ;
static unsigned long montab[12] =
{ 0, 31, 61, 92, 122, 153, 184, 214, 245, 275, 306, 337 } ;
/* month length after february is (306 * m + 5) / 10 */
long caldate_mjd(struct caldate *cd)
{
long y;
long m;
long d;
d = cd->day - 678882L;
m = cd->month - 1;
y = cd->year;
d += 146097L * (y / 400);
y %= 400;
if (m >= 2) m -= 2; else { m += 10; --y; }
y += (m / 12);
m %= 12;
if (m < 0) { m += 12; --y; }
d += montab[m];
d += 146097L * (y / 400);
y %= 400;
if (y < 0) { y += 400; d -= 146097L; }
d += times365[y & 3];
y >>= 2;
d += 1461L * (y % 25);
y /= 25;
d += times36524[y & 3];
return d;
}
yap-6.2.2/packages/tai/libtai/caldate_norm.c 000644 000765 000024 00000000221 11457004725 020643 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "caldate.h"
void caldate_normalize(struct caldate *cd)
{
caldate_frommjd(cd,caldate_mjd(cd),(int *) 0,(int *) 0);
}
yap-6.2.2/packages/tai/libtai/caldate_scan.c 000644 000765 000024 00000001121 11457004725 020614 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "caldate.h"
unsigned int caldate_scan(char *s, struct caldate *cd)
{
int sign = 1;
char *t = s;
unsigned long z;
unsigned long c;
if (*t == '-') { ++t; sign = -1; }
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
cd->year = z * sign;
if (*t++ != '-') return 0;
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
cd->month = z;
if (*t++ != '-') return 0;
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
cd->day = z;
return (unsigned int)(t - s);
}
yap-6.2.2/packages/tai/libtai/caldate_ster.c 000644 000765 000024 00000000725 11457004725 020656 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "caldate.h"
void caldate_easter(struct caldate *cd)
{
long c;
long t;
long j;
long n;
long y;
y = cd->year;
c = (y / 100) + 1;
t = 210 - (((c * 3) / 4) % 210);
j = y % 19;
n = 57 - ((14 + j * 11 + (c * 8 + 5) / 25 + t) % 30);
if ((n == 56) && (j > 10)) --n;
if (n == 57) --n;
n -= ((((y % 28) * 5) / 4 + t + n + 2) % 7);
if (n < 32) { cd->month = 3; cd->day = n; }
else { cd->month = 4; cd->day = n - 31; }
}
yap-6.2.2/packages/tai/libtai/caltime.3 000644 000765 000024 00000002622 11457004725 017560 0 ustar 00vsc staff 000000 000000 .TH caltime 3
.SH NAME
caltime \- calendar dates and times
.SH SYNTAX
.B #include
unsigned int \fBcaltime_fmt\fP(\fIs\fR,&\fIct\fR);
.br
unsigned int \fBcaltime_scan\fP(\fIs\fR,&\fIct\fR);
struct caltime \fIct\fR;
.br
char *\fIs\fR;
.SH DESCRIPTION
A
.B struct caltime
value is a calendar date and time with an offset in minutes from UTC.
It has five components:
.B date
(a
.B struct caldate\fR),
.B hour
(0...23),
.B minute
(0...59),
.B second
(0...60),
and
.B offset
(-5999...5999).
For example,
a leap second occurred
on 30 June 1997 at 23:59:60 UTC.
The local time in New York was
30 June 1997 19:59:60 -0400.
This local time is represented inside a
.B struct caltime
with
.B date
containing 1997, 6, 30;
.B hour
19;
.B minute
59;
.B second
60;
and
.B offset
\-240
(4 hours).
.SH FORMATTING
.B caltime_fmt
prints
.I ct
in ISO style (yyyy-mm-dd hh:mm:ss +oooo)
into the character buffer
.IR s ,
without a terminating NUL.
It returns the number of characters printed.
.I s
may be zero;
then
.B caltime_fmt
returns the number of characters that would have been printed.
.B caltime_scan
reads a calendar date, time, and offset in ISO style
from the beginning of the character buffer
.I s
and puts them into
.IR ct .
It returns the number of characters read.
If
.I s
does not start with an ISO-style date and time (including offset),
.B caltime_scan
returns 0.
.SH "SEE ALSO"
caltime_tai(3),
caldate(3),
tai(3)
yap-6.2.2/packages/tai/libtai/caltime.h 000644 000765 000024 00000000665 11457004725 017652 0 ustar 00vsc staff 000000 000000 #ifndef CALTIME_H
#define CALTIME_H
#include "caldate.h"
struct caltime {
struct caldate date;
int hour;
int minute;
int second;
long offset;
} ;
extern void caltime_tai(struct caltime *ct, struct tai *t);
extern void caltime_utc(struct caltime *ct, struct tai *t, int *pwday, int *pyday);
extern unsigned int caltime_fmt(char *s, struct caltime *ct);
extern unsigned int caltime_scan(char *s, struct caltime *ct);
#endif
yap-6.2.2/packages/tai/libtai/caltime_fmt.c 000644 000765 000024 00000001542 11457004725 020506 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "caldate.h"
#include "caltime.h"
unsigned int caltime_fmt(char *s, struct caltime *ct)
{
unsigned int result;
long x;
result = caldate_fmt(s,&ct->date);
if (s) {
s += result;
x = ct->hour;
s[0] = ' ';
s[2] = '0' + (char)(x % 10); x /= 10;
s[1] = '0' + (char)(x % 10);
s += 3;
x = ct->minute;
s[0] = ':';
s[2] = '0' + (char)(x % 10); x /= 10;
s[1] = '0' + (char)(x % 10);
s += 3;
x = ct->second;
s[0] = ':';
s[2] = '0' + (char)(x % 10); x /= 10;
s[1] = '0' + (char)(x % 10);
s += 3;
s[0] = ' ';
x = ct->offset;
if (x < 0) { s[1] = '-'; x = -x; } else s[1] = '+';
s[5] = '0' + (char)(x % 10); x /= 10;
s[4] = '0' + (char)(x % 6); x /= 6;
s[3] = '0' + (char)(x % 10); x /= 10;
s[2] = '0' + (char)(x % 10);
}
return result + 15;
}
yap-6.2.2/packages/tai/libtai/caltime_scan.c 000644 000765 000024 00000002123 11457004725 020640 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "caltime.h"
unsigned int caltime_scan(char *s, struct caltime *ct)
{
char *t = s;
unsigned long z;
unsigned long c;
int sign;
t += caldate_scan(t,&ct->date);
while ((*t == ' ') || (*t == '\t') || (*t == 'T')) ++t;
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
ct->hour = z;
if (*t++ != ':') return 0;
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
ct->minute = z;
if (*t != ':')
ct->second = 0;
else {
++t;
z = 0; while ((c = (unsigned char) (*t - '0')) <= 9) { z = z * 10 + c; ++t; }
ct->second = z;
}
while ((*t == ' ') || (*t == '\t')) ++t;
if (*t == '+') sign = 1; else if (*t == '-') sign = -1; else return 0;
++t;
c = (unsigned char) (*t++ - '0'); if (c > 9) return 0; z = c;
c = (unsigned char) (*t++ - '0'); if (c > 9) return 0; z = z * 10 + c;
c = (unsigned char) (*t++ - '0'); if (c > 9) return 0; z = z * 6 + c;
c = (unsigned char) (*t++ - '0'); if (c > 9) return 0; z = z * 10 + c;
ct->offset = z * sign;
return (unsigned int)(t - s);
}
yap-6.2.2/packages/tai/libtai/caltime_tai.3 000644 000765 000024 00000002255 11457004725 020417 0 ustar 00vsc staff 000000 000000 .TH caltime 3
.SH NAME
caltime_tai \- convert calendar dates and times
.SH SYNTAX
.B #include
.br
.B #include
void \fBcaltime_tai\fP(&\fIct\fR,&\fIt\fR);
.br
void \fBcaltime_utc\fP(&\fIct\fR,&\fIt\fR,&\fIweekday\fR,&\fIyearday\fR);
struct caltime \fIct\fR;
.br
struct tai \fIt\fR;
.br
int *\fIweekday\fR;
.br
int *\fIyearday\fR;
.SH DESCRIPTION
.B caltime_tai
reads a date, time, and UTC offset from
.IR ct .
It puts the corresponding TAI64 label into
.IR t .
.B caltime_utc
reads a TAI64 label from
.IR t .
It puts the corresponding date and time into
.IR ct ,
with UTC offset 0.
.B caltime_utc
fills in
.I weekday
and
.I yearday
the same way as
.BR caldate_frommjd .
.SH LIMITATIONS
The sequence of TAI64 labels has been determined
for the next few hundred billion years.
The same is not true, however, for
calendar dates and times.
New leap seconds are added every year or two,
as discussed in
.BR leapsecs (3);
and the Gregorian calendar will change in a few thousand years,
as discussed in
.BR caldate_mjd (3).
This means that
.B caltime_tai
and
.B caltime_utc
are not useful for dates far in the future.
.SH "SEE ALSO"
caldate_mjd(3),
caltime(3),
tai(3),
leapsecs(3)
yap-6.2.2/packages/tai/libtai/caltime_tai.c 000644 000765 000024 00000000677 11457004725 020505 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "leapsecs.h"
#include "caldate.h"
#include "caltime.h"
/* XXX: breaks tai encapsulation */
void caltime_tai(struct caltime *ct, struct tai *t)
{
long day;
long s;
/* XXX: check for overflow? */
day = caldate_mjd(&ct->date);
s = ct->hour * 60 + ct->minute;
s = (s - ct->offset) * 60 + ct->second;
t->x = day * ULL(86400) + ULL(4611686014920671114) + (int64_t) s;
leapsecs_add(t,ct->second == 60);
}
yap-6.2.2/packages/tai/libtai/caltime_utc.c 000644 000765 000024 00000001106 11457004725 020507 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "leapsecs.h"
#include "caldate.h"
#include "caltime.h"
/* XXX: breaks tai encapsulation */
void caltime_utc(struct caltime *ct, struct tai *t, int *pwday, int *pyday)
{
struct tai t2 = *t;
uint64_t u;
int leap;
long s;
/* XXX: check for overfow? */
leap = leapsecs_sub(&t2);
u = t2.x;
u += 58486;
s = (long)(u % ULL(86400));
ct->second = (s % 60) + leap; s /= 60;
ct->minute = s % 60; s /= 60;
ct->hour = s;
u /= ULL(86400);
caldate_frommjd(&ct->date, (int64_t)u - LL(53375995543064), pwday, pyday);
ct->offset = 0;
}
yap-6.2.2/packages/tai/libtai/CHANGES 000644 000765 000024 00000000127 11457004725 017047 0 ustar 00vsc staff 000000 000000 19981013 libtai 0.60, alpha.
19970908 libtai 0.56, alpha.
19970730 libtai 0.50, alpha.
yap-6.2.2/packages/tai/libtai/check.c 000644 000765 000024 00000002212 11457004725 017272 0 ustar 00vsc staff 000000 000000 #include
#include
#include
#include "tai.h"
#include "leapsecs.h"
#include "caltime.h"
char line[100];
char *dayname[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } ;
char out[101];
char x[TAI_PACK];
int
main(int argc, char **argv)
{
struct tai t;
struct tai t2;
struct caltime ct;
struct caltime ct2;
int weekday;
int yearday;
int i;
double packerr;
if (leapsecs_init() == -1)
printf("unable to init leapsecs\n");
while (fgets(line,sizeof line,stdin))
if (!caltime_scan(line,&ct))
printf("unable to parse\n");
else {
caltime_tai(&ct,&t);
caltime_utc(&ct2,&t,&weekday,&yearday);
tai_pack(x,&t);
tai_unpack(x,&t2);
tai_sub(&t2,&t2,&t);
packerr = tai_approx(&t2);
for (i = 0;i < TAI_PACK;++i)
printf("%2.2lx",(unsigned long) (unsigned char) x[i]);
if (packerr)
printf(" packerr=%f",packerr);
printf(" %03d %s",yearday,dayname[weekday]);
if (caltime_fmt((char *) 0,&ct2) + 1 < sizeof out) {
out[caltime_fmt(out,&ct2)] = 0;
printf(" %s",out);
}
printf("\n");
}
exit(0);
}
yap-6.2.2/packages/tai/libtai/check.in 000644 000765 000024 00000002151 11457004725 017460 0 ustar 00vsc staff 000000 000000 -1000000-12-31 23:59:59 +0000
-999999-1-1 0:0:0 +0000
-1-12-31 23:59:59 +0000
0-1-1 0:0:0 +0000
1-1-1 1:1:1 +0000
1000-01-01 12:04:37 +0000
1799-12-31 23:59:59 +0000
1899-12-31 23:59:59 +0000
1900-01-01 00:00:00 +0000
1969-12-31 23:59:49 +0000
1969-12-31 23:59:50 +0000
1969-12-31 23:59:59 +0000
1970-01-01 00:00:00 +0000
1970-01-01 00:00:01 +0000
1972-06-30 23:59:58 +0000
1972-06-30 23:59:59 +0000
1972-06-30 23:59:60 +0000
1972-07-01 00:00:00 +0000
1972-07-01 00:00:01 +0000
1995-12-31 23:59:58 +0000
1995-12-31 23:59:59 +0000
1995-12-31 23:59:60 +0000
1996-01-01 00:00:00 +0000
1996-01-01 00:00:01 +0000
1996-01-01 00:00:02 +0000
1997-06-30 23:59:59 +0000
1997-06-30 23:59:60 +0000
1997-07-01 00:00:00 +0000
1997-07-30 08:57:43 +0000
1997-10-03 18:14:48 +0000
1999-09-09 09:09:09 +0000
1999-12-31 23:59:59 +0000
2000-01-01 00:00:00 +0000
2000-01-01 00:00:01 +0000
2000-02-28 23:59:59 +0000
2000-02-29 23:59:59 +0000
2000-03-01 00:00:00 +0000
2000-12-31 23:59:59 +0000
2100-01-01 17:42:15 +0000
2200-01-01 17:42:15 +0000
3000-01-01 17:42:15 +0000
10000-01-01 17:42:15 +0000
999999-12-31 23:59:59 +0000
1000000-1-1 0:0:0 +0000
yap-6.2.2/packages/tai/libtai/check.out 000644 000765 000024 00000004365 11457004725 017672 0 ustar 00vsc staff 000000 000000 3fffe33e1b840309 365 Sun -1000000-12-31 23:59:59 +0000
3fffe33e1b84030a 000 Mon -999999-01-01 00:00:00 +0000
3ffffff1868b8409 364 Fri -1-12-31 23:59:59 +0000
3ffffff1868b840a 000 Sat 0-01-01 00:00:00 +0000
3ffffff1886e1757 000 Mon 1-01-01 01:01:01 +0000
3ffffff8df7db65f 000 Wed 1000-01-01 12:04:37 +0000
3ffffffec03dbf89 364 Tue 1799-12-31 23:59:59 +0000
3fffffff7c558189 364 Sun 1899-12-31 23:59:59 +0000
3fffffff7c55818a 000 Mon 1900-01-01 00:00:00 +0000
3fffffffffffffff 364 Wed 1969-12-31 23:59:49 +0000
4000000000000000 364 Wed 1969-12-31 23:59:50 +0000
4000000000000009 364 Wed 1969-12-31 23:59:59 +0000
400000000000000a 000 Thu 1970-01-01 00:00:00 +0000
400000000000000b 000 Thu 1970-01-01 00:00:01 +0000
4000000004b25808 181 Fri 1972-06-30 23:59:58 +0000
4000000004b25809 181 Fri 1972-06-30 23:59:59 +0000
4000000004b2580a 181 Fri 1972-06-30 23:59:60 +0000
4000000004b2580b 182 Sat 1972-07-01 00:00:00 +0000
4000000004b2580c 182 Sat 1972-07-01 00:00:01 +0000
4000000030e7241b 364 Sun 1995-12-31 23:59:58 +0000
4000000030e7241c 364 Sun 1995-12-31 23:59:59 +0000
4000000030e7241d 364 Sun 1995-12-31 23:59:60 +0000
4000000030e7241e 000 Mon 1996-01-01 00:00:00 +0000
4000000030e7241f 000 Mon 1996-01-01 00:00:01 +0000
4000000030e72420 000 Mon 1996-01-01 00:00:02 +0000
4000000033b8489d 180 Mon 1997-06-30 23:59:59 +0000
4000000033b8489e 180 Mon 1997-06-30 23:59:60 +0000
4000000033b8489f 181 Tue 1997-07-01 00:00:00 +0000
4000000033df0226 210 Wed 1997-07-30 08:57:43 +0000
4000000034353637 275 Fri 1997-10-03 18:14:48 +0000
4000000037d77955 251 Thu 1999-09-09 09:09:09 +0000
40000000386d439f 364 Fri 1999-12-31 23:59:59 +0000
40000000386d43a0 000 Sat 2000-01-01 00:00:00 +0000
40000000386d43a1 000 Sat 2000-01-01 00:00:01 +0000
4000000038bb0c1f 058 Mon 2000-02-28 23:59:59 +0000
4000000038bc5d9f 059 Tue 2000-02-29 23:59:59 +0000
4000000038bc5da0 060 Wed 2000-03-01 00:00:00 +0000
400000003a4fc89f 365 Sun 2000-12-31 23:59:59 +0000
40000000f4875017 000 Fri 2100-01-01 17:42:15 +0000
40000001b09f1217 000 Wed 2200-01-01 17:42:15 +0000
40000007915fc517 000 Wed 3000-01-01 17:42:15 +0000
4000003afff53a97 000 Sat 10000-01-01 17:42:15 +0000
40001ca4f3758a1f 364 Fri 999999-12-31 23:59:59 +0000
40001ca4f3758a20 000 Sat 1000000-01-01 00:00:00 +0000
yap-6.2.2/packages/tai/libtai/easter.c 000644 000765 000024 00000001173 11457004725 017505 0 ustar 00vsc staff 000000 000000 #include
#include
#include "caldate.h"
char *dayname[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } ;
char out[101];
int
main(int argc, char **argv)
{
struct caldate cd;
long day;
int weekday;
int yearday;
while (*++argv) {
cd.year = atoi(*argv);
if (cd.year > 0) {
caldate_easter(&cd);
day = caldate_mjd(&cd);
caldate_frommjd(&cd,day,&weekday,&yearday);
if (caldate_fmt((char *) 0,&cd) + 1 >= sizeof out) exit(1);
out[caldate_fmt(out,&cd)] = 0;
printf("%s %s yearday %d mjd %ld\n", dayname[weekday], out, yearday, day);
}
}
exit(0);
}
yap-6.2.2/packages/tai/libtai/FILES 000644 000765 000024 00000001453 11457004725 016644 0 ustar 00vsc staff 000000 000000 BLURB
README
INSTALL
TODO
THANKS
CHANGES
FILES
VERSION
Makefile
leapsecs.txt
leapsecs.dat
leapsecs.c
check.in
check.out
check.c
easter.c
yearcal.c
nowutc.c
caldate.3
caldate_mjd.3
caldate.h
caldate_fmt.c
caldate_scan.c
caldate_mjd.c
caldate_fmjd.c
caldate_norm.c
caldate_ster.c
tai.3
tai_now.3
tai_pack.3
tai.h
tai_add.c
tai_now.c
tai_pack.c
tai_sub.c
tai_unpack.c
leapsecs.3
leapsecs.h
leapsecs_add.c
leapsecs_sub.c
leapsecs_init.c
leapsecs_read.c
caltime.3
caltime_tai.3
caltime.h
caltime_fmt.c
caltime_scan.c
caltime_tai.c
caltime_utc.c
taia.3
taia_now.3
taia_pack.3
taia.h
taia_add.c
taia_approx.c
taia_fmtfrac.c
taia_frac.c
taia_half.c
taia_less.c
taia_now.c
taia_pack.c
taia_sub.c
taia_tai.c
taia_unpack.c
conf-cc
conf-ld
find-systype.sh
make-compile.sh
make-load.sh
make-makelib.sh
trycpp.c
warn-auto.sh
yap-6.2.2/packages/tai/libtai/INSTALL 000644 000765 000024 00000003776 11457004725 017122 0 ustar 00vsc staff 000000 000000 Like any other piece of software (and information generally), libtai
comes with NO WARRANTY.
These are UNIX installation instructions; libtai has not yet been ported
to non-UNIX systems.
To compile the programs and format the man pages:
% make
Then, as root, enable leap second support:
# cp leapsecs.dat /etc/leapsecs.dat
# chmod 644 /etc/leapsecs.dat
To use another compiler, edit conf-cc and conf-ld.
There are five test programs here. The first is leapsecs, which creates
leapsecs.dat from leapsecs.txt. Try
% ./leapsecs < leapsecs.txt | cmp - leapsecs.dat
to make sure that there are no differences.
The second is check, which prints a variety of information about an
ISO-style input date. Try
% ./check < check.in | cmp - check.out
to make sure that your test results match mine. Note that the results
for future dates will change when more leap seconds are announced.
The third is easter, which prints the date of Easter in any given year.
Try
% ./easter 1997 1998 1999 2000 2001
and check the results against tables from some other source.
The fourth is yearcal, which prints a year-long calendar. Try
% ./yearcal 1997 | ul
and check the results against another calendar. (The days in January,
March, May, July, September, and November should show up in boldface.)
The fifth is nowutc, which prints the current time in UTC. Your system's
clock must be the number of seconds since 1970-01-01 00:00:10 TAI. This
is compatible with the interpretation of time_t in the Olson time
library with leap seconds enabled. Try
% env TZ=right/Etc/GMT date; ./nowutc
if your system has the Olson library.
The libtai code is in the public domain, so you can use it in your own
programs. But keep in mind that this is a very early release. Some of
the code hasn't been tested at all! caldate_mjd() and caldate_frommjd()
are based on previous code of mine; they need outside review. It would
be particularly helpful to systematically check my results against
independent results from someone else's code.
yap-6.2.2/packages/tai/libtai/leapsecs.3 000644 000765 000024 00000003511 11457004725 017737 0 ustar 00vsc staff 000000 000000 .TH leapsecs 3
.SH NAME
leapsecs \- handle UTC leap seconds
.SH SYNTAX
.B #include
int \fBleapsecs_sub\fP(&\fIt\fR);
.br
void \fBleapsecs_add\fP(&\fIt\fR,\fIhit\fR);
int \fBleapsecs_read\fP();
.br
int \fBleapsecs_init\fP();
struct tai \fIt\fR;
.br
int \fIhit\fR;
.SH DESCRIPTION
.B leapsecs_sub
changes a seconds-since-epoch count
into a non-leap-seconds-since-epoch count.
It interprets
.I t
as a TAI64 label,
subtracts from
.I t
the number of leap seconds that have occurred
before or at
.IR t ,
and places the result back into
.IR t .
.B leapsecs_sub
returns 1 if
.I t
was a leap second,
0 otherwise.
.B leapsecs_add
reverses the effect of
.BR leapsecs_sub .
.I hit
must be 1
for a leap second,
0 otherwise.
.SH "LEAP-SECOND TABLE"
The current implementation of
.B leapsecs_sub
and
.B leapsecs_add
uses a leap-second table read from disk.
.B leapsecs_read
reads the leap-second table from
.BR /etc/leapsecs.dat .
It returns 0 on success, -1 on error.
If
.B /etc/leapsecs.dat
does not exist,
.B leapsecs_read
treats it as an empty file.
.B leapsecs_init
is a one-time version of
.BR leapsecs_read .
Initially it is the same as
.BR leapsecs_read ;
however, once
.B leapsecs_read
returns 0,
.B leapsecs_init
will always return 0
without calling
.B leapsecs_read
again.
.B leapsecs_add
and
.B leapsecs_sub
call
.BR leapsecs_init .
.B WARNING:
If
.B leapsecs_init
returns failure,
.B leapsecs_add
and
.B leapsecs_sub
will proceed without a leap-second table.
For reliability,
all programs should call
.B leapsecs_init
at startup and check for errors.
.B WARNING:
New entries are added to the leap-second table on disk
every 12 to 18 months.
.B leapsecs_read
may be called repeatedly.
It leaves the old table alone on error.
For reliability,
all long-running programs should call
.B leapsecs_read
at least once every month.
.SH "SEE ALSO"
tai(3)
yap-6.2.2/packages/tai/libtai/leapsecs.c 000644 000765 000024 00000001115 11457004725 020015 0 ustar 00vsc staff 000000 000000 #include
#include
#include "tai.h"
#include "leapsecs.h"
#include "caldate.h"
/* XXX: breaks tai encapsulation */
/* XXX: output here has to be binary; DOS redirection uses ASCII */
char line[100];
int
main(int argc, char**argv)
{
struct caldate cd;
struct tai t;
char x[TAI_PACK];
long leaps = 0;
while (fgets(line,sizeof line,stdin))
if (line[0] == '+')
if (caldate_scan(line + 1,&cd)) {
t.x = (caldate_mjd(&cd) + 1) * 86400ULL + 4611686014920671114ULL + leaps++;
tai_pack(x,&t);
fwrite(x,TAI_PACK,1,stdout);
}
exit(0);
}
yap-6.2.2/packages/tai/libtai/leapsecs.dat 000644 000765 000024 00000000260 11457004725 020343 0 ustar 00vsc staff 000000 000000 @ ²X
@ ¤ì@ †Œ@ gS
@ H†Ž@
+@ ?@ ír‘@ Φ@ ŸÊ“@ €þ@ b1•@ %ê@ !Úå@ %ž˜@ 'Ñ@ *Põš@ ,2)@ .\œ@ 0ç$@ 3¸Hž@ 6Œ yap-6.2.2/packages/tai/libtai/leapsecs.h 000644 000765 000024 00000000471 11457004725 020026 0 ustar 00vsc staff 000000 000000 #ifndef LEAPSECS_H
#define LEAPSECS_H
extern int leapsecs_init(void);
extern int leapsecs_read(const char *file);
extern void leapsecs_add(struct tai *t, int hit);
extern int leapsecs_sub(struct tai *t);
#ifndef GLOBAL
#define GLOBAL extern
#endif
GLOBAL struct tai *leapsecs;
GLOBAL int leapsecs_num;
#endif
yap-6.2.2/packages/tai/libtai/leapsecs.txt 000644 000765 000024 00000001501 11457004725 020411 0 ustar 00vsc staff 000000 000000 # http://pobox.com/~djb/libtai/leapsecs.txt, version 1998-10-13
#
# Official sources:
# http://maia.usno.navy.mil/leapsec.html
# http://hpiers.obspm.fr/webiers/general/earthor/utc/UTC.html
#
# Dates must be listed in sorted order.
# + means a positive leap second, inserting 23:59:60 UTC.
# - means a negative leap second, skipping 23:59:59 UTC.
#
# Note for parsers: Negative leap seconds will probably never happen, but
# the year 10000 will happen. Please don't contribute to the Y10K problem.
#
# 1972-01-01 00:00:00 UTC was 1972-01-01 00:00:10 TAI.
#
+1972-06-30
+1972-12-31
+1973-12-31
+1974-12-31
+1975-12-31
+1976-12-31
+1977-12-31
+1978-12-31
+1979-12-31
+1981-06-30
+1982-06-30
+1983-06-30
+1985-06-30
+1987-12-31
+1989-12-31
+1990-12-31
+1992-06-30
+1993-06-30
+1994-06-30
+1995-12-31
+1997-06-30
+1998-12-31
+2005-12-31
yap-6.2.2/packages/tai/libtai/leapsecs_add.c 000644 000765 000024 00000000510 11457004725 020623 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "leapsecs.h"
/* XXX: breaks tai encapsulation */
void leapsecs_add(struct tai *t, int hit)
{
int i;
uint64_t u;
if (leapsecs_init() == -1) return;
u = t->x;
for (i = 0;i < leapsecs_num;++i) {
if (u < leapsecs[i].x) break;
if (!hit || (u > leapsecs[i].x)) ++u;
}
t->x = u;
}
yap-6.2.2/packages/tai/libtai/leapsecs_init.c 000644 000765 000024 00000000317 11457004725 021043 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "leapsecs.h"
static int flaginit = 0;
int leapsecs_init(void)
{
if (flaginit) return 0;
if (leapsecs_read("/etc/leapsecs.dat") == -1) return -1;
flaginit = 1;
return 0;
}
yap-6.2.2/packages/tai/libtai/leapsecs_read.c 000644 000765 000024 00000002027 11457004725 021013 0 ustar 00vsc staff 000000 000000 #include
#include
#include
#include
#include
#ifdef __WINDOWS__
#include
#else
#include
#endif
#include "tai.h"
#define GLOBAL
#include "leapsecs.h"
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef O_NDELAY
#define O_NDELAY 0
#endif
int leapsecs_read(const char *file)
{ int fd;
struct stat st;
struct tai *t;
int n;
int i;
struct tai u;
fd = open(file, O_RDONLY|O_NDELAY|O_BINARY);
if (fd == -1) {
if (errno != ENOENT) return -1;
if (leapsecs) free(leapsecs);
leapsecs = 0;
leapsecs_num = 0;
return 0;
}
if (fstat(fd,&st) == -1) { close(fd); return -1; }
t = (struct tai *) malloc(st.st_size);
if (!t) { close(fd); return -1; }
n = read(fd,(char *) t,st.st_size);
close(fd);
if (n != st.st_size) { free(t); return -1; }
n /= sizeof(struct tai);
for (i = 0;i < n;++i) {
tai_unpack((char *) &t[i],&u);
t[i] = u;
}
if (leapsecs) free(leapsecs);
leapsecs = t;
leapsecs_num = n;
return 0;
}
yap-6.2.2/packages/tai/libtai/leapsecs_sub.c 000644 000765 000024 00000000571 11457004725 020673 0 ustar 00vsc staff 000000 000000 #include "tai.h"
#include "leapsecs.h"
/* XXX: breaks tai encapsulation */
int leapsecs_sub(struct tai *t)
{
int i;
uint64_t u;
int s;
if (leapsecs_init() == -1) return 0;
u = t->x;
s = 0;
for (i = 0;i < leapsecs_num;++i) {
if (u < leapsecs[i].x) break;
++s;
if (u == leapsecs[i].x) { t->x = u - s; return 1; }
}
t->x = u - s;
return 0;
}
yap-6.2.2/packages/tai/libtai/Makefile.in 000644 000765 000024 00000004520 11465602162 020120 0 ustar 00vsc staff 000000 000000 ################################################################
# Makefile for the libtai
#
# Libtai by: D. J. Bernstein, djb@pobox.com
# This Makefile.in by: Jan Wielemaker, wielemak@science.uva.nl
#
# This makefile fits in the SWI-Prolog (www.swi-prolog.org)
# autconf setup.
################################################################
prefix=@prefix@
exec_prefix=@exec_prefix@
srcdir=@srcdir@
bindir=$(exec_prefix)/bin
PLBASE=$(prefix)/lib/@PL@-$(PLVERSION)
man_prefix=$(prefix)/man
mansec=1
lmansec=3
mandir=$(man_prefix)/man$(mansec)
lmandir=$(man_prefix)/man$(lmansec)
plmandir=$(PLBASE)/man
CC=@CC@
AR=@AR@
RANLIB=@RANLIB@
ifeq (@PROLOG_SYSTEM@,yap)
DEFS=@DEFS@ -D_YAP_NOT_INSTALLED_=1
CFLAGS= @SHLIB_CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../../.. -I$(srcdir)/../../include @CPPFLAGS@ @JAVAINCPATH@
else
COFLAGS=@COFLAGS@
CWFLAGS=@CWFLAGS@
CIFLAGS=@CIFLAGS@
CMFLAGS=@CMFLAGS@
CPFLAGS=
LDFLAGS=@LDFLAGS@ $(CPFLAGS)
CFLAGS= $(CWFLAGS) $(COFLAGS) $(CIFLAGS) $(CMFLAGS) $(CPFLAGS)
endif #YAP/SWI
INSTALL=@INSTALL@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
INSTALL_DATA=@INSTALL_DATA@
LIBOBJ= tai_add.o tai_now.o tai_pack.o \
tai_sub.o tai_unpack.o taia_add.o taia_approx.o \
taia_fmtfrac.o taia_frac.o taia_half.o taia_less.o \
taia_now.o taia_pack.o taia_sub.o taia_tai.o taia_unpack.o \
caldate_fmt.o caldate_scan.o caldate_fmjd.o caldate_mjd.o \
caldate_norm.o caldate_ster.o leapsecs_read.o \
leapsecs_init.o leapsecs_add.o leapsecs_sub.o caltime_fmt.o \
caltime_scan.o caltime_tai.o caltime_utc.o
PROG= easter check yearcal leapsecs nowutc
all: libtai.a
progs: $(PROG)
libtai.a: $(LIBOBJ)
rm -f $@
$(AR) cq $@ $(LIBOBJ)
$(RANLIB) $@
easter: easter.o libtai.a
$(CC) $(LDFLAGS) -o $@ easter.o -L. -ltai
check: check.o libtai.a
$(CC) $(LDFLAGS) -o $@ check.o -L. -ltai
yearcal: yearcal.o libtai.a
$(CC) $(LDFLAGS) -o $@ yearcal.o -L. -ltai
leapsecs: leapsecs.o libtai.a
$(CC) $(LDFLAGS) -o $@ leapsecs.o -L. -ltai
nowutc: nowutc.o libtai.a
$(CC) $(LDFLAGS) -o $@ nowutc.o -L. -ltai
%.o: $(srcdir)/%.c
$(CC) -c -I.. $(CFLAGS) $<
################################################################
# Cleanup
################################################################
clean:
rm -f *% *~ *.o *.gcda
profclean:
rm -f *.gcda
distclean: clean profclean
rm -f Makefile
rm -f $(PROG) libtai.a
yap-6.2.2/packages/tai/libtai/Makefile.mak 000644 000765 000024 00000002105 11457004725 020261 0 ustar 00vsc staff 000000 000000 ################################################################
# Makefile for libtai
#
# Author: Jan Wielemaker
# E-mail: wielemak@science.uva.nl
################################################################
!include ..\rules.mk
LIBOBJ= tai_add.obj tai_now.obj tai_pack.obj tai_sub.obj \
tai_unpack.obj taia_add.obj taia_approx.obj \
taia_fmtfrac.obj taia_frac.obj taia_half.obj taia_less.obj \
taia_now.obj taia_pack.obj taia_sub.obj taia_tai.obj \
taia_unpack.obj caldate_fmt.obj caldate_scan.obj \
caldate_fmjd.obj caldate_mjd.obj caldate_norm.obj \
caldate_ster.obj leapsecs_read.obj \
leapsecs_init.obj leapsecs_add.obj leapsecs_sub.obj \
caltime_fmt.obj caltime_scan.obj caltime_tai.obj \
caltime_utc.obj
all: tai.lib
tai.lib: $(LIBOBJ)
if exist $@ del $@
$(AR) /out:$@ /nologo $(LIBOBJ)
################################################################
# Cleanup
################################################################
clean::
if exist *.obj del *.obj
if exist *~ del *~
distclean: clean
-del tai.lib *.pdb 2>nul
yap-6.2.2/packages/tai/libtai/nowutc.c 000644 000765 000024 00000001170 11457004725 017536 0 ustar 00vsc staff 000000 000000 #include
#include
#include "tai.h"
#include "leapsecs.h"
#include "taia.h"
#include "caltime.h"
struct taia now;
struct tai sec;
struct caltime ct;
char x[TAIA_FMTFRAC];
int
main(int argc, char **argv)
{
if (leapsecs_init() == -1) {
fprintf(stderr,"utcnow: fatal: unable to init leapsecs\n");
exit(111);
}
taia_now(&now);
x[taia_fmtfrac(x,&now)] = 0;
taia_tai(&now,&sec);
caltime_utc(&ct,&sec,(int *) 0,(int *) 0);
printf("%ld-%02d-%02d %02d:%02d:%02d.%s\n"
,ct.date.year
,ct.date.month
,ct.date.day
,ct.hour
,ct.minute
,ct.second
,x
);
exit(0);
}
yap-6.2.2/packages/tai/libtai/README 000644 000765 000024 00000000412 11457004725 016731 0 ustar 00vsc staff 000000 000000 libtai 0.60, alpha.
19981013
Copyright 1998
D. J. Bernstein, djb@pobox.com
http://pobox.com/~djb/libtai.html
libtai is a library for storing and manipulating dates and times. See
BLURB for a more detailed advertisement.
INSTALL says how to set up and test libtai.
yap-6.2.2/packages/tai/libtai/tai.3 000644 000765 000024 00000002566 11457004725 016726 0 ustar 00vsc staff 000000 000000 .TH tai 3
.SH NAME
tai \- manipulate times with 1-second precision
.SH SYNTAX
.B #include
double \fBtai_approx\fP(&\fIt\fR);
int \fBtai_less\fP(&\fIa\fR,&\fIb\fR);
.br
void \fBtai_add\fP(&\fIt\fR,&\fIa\fR,&\fIb\fR);
.br
void \fBtai_sub\fP(&\fIt\fR,&\fIa\fR,&\fIb\fR);
struct tai \fIt\fR;
.br
struct tai \fIa\fR;
.br
struct tai \fIb\fR;
.SH DESCRIPTION
A
.B struct tai
stores an integer between 0 inclusive and 2^64 exclusive.
The format of
.B struct tai
is designed to speed up common operations;
applications should not look inside
.B struct tai\fR.
A
.B struct tai
variable is commonly used to store
a TAI64 label.
Each TAI64 label refers to one second of real time.
TAI64 labels span a period of
hundreds of billions of years.
See
.B http://pobox.com/~djb/proto/tai64.txt
for more information.
A
.B struct tai
variable may also be used to store
the numerical difference between two TAI64 labels.
.SH ARITHMETIC
.B tai_approx
returns a double-precision approximation to
.IR t .
The result of
.B tai_approx
is always nonnegative.
.B tai_less
returns 1 if
.I a
is smaller than
.IR b ,
0 otherwise.
.B tai_add
adds
.I a
and
.I b
modulo 2^64
and puts the result into
.IR t .
The inputs and outputs may overlap.
.B tai_sub
subtracts
.I b
from
.I a
modulo 2^64
and puts the result into
.IR t .
The inputs and outputs may overlap.
.SH "SEE ALSO"
tai_now(3),
tai_pack(3),
taia(3),
utc(3)
yap-6.2.2/packages/tai/libtai/tai.h 000755 000765 000024 00000001445 11457004725 017011 0 ustar 00vsc staff 000000 000000 #ifndef TAI_H
#define TAI_H
#ifdef __WINDOWS__
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include /* more portable than stdint.h */
#endif
#if defined(__WINDOWS__) && !defined(__GNUC__)
#define LL(x) x ## i64
#define ULL(x) x ## ui64
#else
#define LL(x) x ## LL
#define ULL(x) x ## ULL
#endif
struct tai {
uint64_t x;
} ;
extern void tai_now(struct tai *t);
/* JW: MSVC cannot convert unsigned to double :-( */
#define tai_approx(t) ((double) ((int64_t)(t)->x))
extern void tai_add(struct tai *t, struct tai *u, struct tai *v);
extern void tai_sub(struct tai *t, struct tai *u, struct tai *v);
#define tai_less(t,u) ((t)->x < (u)->x)
#define TAI_PACK 8
extern void tai_pack(char *s, struct tai *t);
extern void tai_unpack(char *s, struct tai *t);
#endif
yap-6.2.2/packages/tai/libtai/tai_add.c 000644 000765 000024 00000000146 11457004725 017606 0 ustar 00vsc staff 000000 000000 #include "tai.h"
void tai_add(struct tai *t, struct tai *u, struct tai *v)
{
t->x = u->x + v->x;
}
yap-6.2.2/packages/tai/libtai/tai_now.3 000644 000765 000024 00000001101 11457004725 017571 0 ustar 00vsc staff 000000 000000 .TH tai_now 3
.SH NAME
tai_now \- get current time, with 1-second precision
.SH SYNTAX
.B #include
void \fBtai_now\fP(&\fIt\fR);
struct tai \fIt\fR;
.SH DESCRIPTION
.B tai_now
puts the current time into
.IR t .
More precisely:
.B tai_now
puts into
.I t
its best guess as to the TAI64 label for the 1-second interval
that contains the current time.
.SH NOTES
This implementation of
.B tai_now
assumes that the
.B time_t
returned from the
.B time
function
represents the number of TAI seconds since
1970-01-01 00:00:10 TAI.
.SH "SEE ALSO"
tai(3),
taia_now(3),
time(3)
yap-6.2.2/packages/tai/libtai/tai_now.c 000644 000765 000024 00000000207 11457004725 017657 0 ustar 00vsc staff 000000 000000 #include
#include "tai.h"
void tai_now(struct tai *t)
{
t->x = ULL(4611686018427387914) + (uint64_t) time((time_t *) 0);
}
yap-6.2.2/packages/tai/libtai/tai_pack.3 000644 000765 000024 00000001112 11457004725 017706 0 ustar 00vsc staff 000000 000000 .TH tai_pack 3
.SH NAME
tai_pack \- convert TAI64 labels to external format
.SH SYNTAX
.B #include
void \fBtai_pack\fP(\fIbuf\fR,&\fIt\fR);
.br
void \fBtai_unpack\fP(\fIbuf\fR,&\fIt\fR);
char \fIbuf\fR[\fBTAI_PACK\fP];
.br
struct tai \fIt\fR;
.SH DESCRIPTION
.B tai_pack
converts a TAI64 label
from internal format in
.I t
to TAI64 format in
.IR buf .
.B tai_unpack
converts a TAI64 label
from TAI64 format in
.I buf
to internal format in
.IR t .
.B TAI_PACK
is 8.
See
.B http://pobox.com/~djb/proto/tai64.txt
for more information about TAI64 format.
.SH "SEE ALSO"
tai(3)
yap-6.2.2/packages/tai/libtai/tai_pack.c 000644 000765 000024 00000000571 11457004725 017776 0 ustar 00vsc staff 000000 000000 #include "tai.h"
void tai_pack(char *s, struct tai *t)
{
uint64_t x;
x = t->x;
/* JW: Cast to int need to get MSVC6 silent */
s[7] = (int)x & 255; x >>= 8;
s[6] = (int)x & 255; x >>= 8;
s[5] = (int)x & 255; x >>= 8;
s[4] = (int)x & 255; x >>= 8;
s[3] = (int)x & 255; x >>= 8;
s[2] = (int)x & 255; x >>= 8;
s[1] = (int)x & 255; x >>= 8;
s[0] = (int)x;
}
yap-6.2.2/packages/tai/libtai/tai_sub.c 000644 000765 000024 00000000146 11457004725 017647 0 ustar 00vsc staff 000000 000000 #include "tai.h"
void tai_sub(struct tai *t, struct tai *u, struct tai *v)
{
t->x = u->x - v->x;
}
yap-6.2.2/packages/tai/libtai/tai_unpack.c 000644 000765 000024 00000000577 11457004725 020347 0 ustar 00vsc staff 000000 000000 #include "tai.h"
void tai_unpack(char *s, struct tai *t)
{
uint64_t x;
x = (unsigned char) s[0];
x <<= 8; x += (unsigned char) s[1];
x <<= 8; x += (unsigned char) s[2];
x <<= 8; x += (unsigned char) s[3];
x <<= 8; x += (unsigned char) s[4];
x <<= 8; x += (unsigned char) s[5];
x <<= 8; x += (unsigned char) s[6];
x <<= 8; x += (unsigned char) s[7];
t->x = x;
}
yap-6.2.2/packages/tai/libtai/taia.3 000644 000765 000024 00000004660 11457004725 017064 0 ustar 00vsc staff 000000 000000 .TH taia 3
.SH NAME
taia \- manipulate times with 1-attosecond precision
.SH SYNTAX
.B #include
double \fBtaia_approx\fP(&\fIt\fR);
.br
double \fBtaia_frac\fP(&\fIt\fR);
.br
void \fBtaia_tai\fP(&\fIt\fR,&\fIsec\fR);
int \fBtaia_less\fP(&\fIa\fR,&\fIb\fR);
.br
void \fBtaia_add\fP(&\fIt\fR,&\fIa\fR,&\fIb\fR);
.br
void \fBtaia_sub\fP(&\fIt\fR,&\fIa\fR,&\fIb\fR);
.br
void \fBtaia_half\fP(&\fIt\fR,&\fIa\fR);
unsigned int \fBtaia_fmtfrac\fP(\fIs\fR,&\fIt\fR);
struct taia \fIt\fR;
.br
struct taia \fIa\fR;
.br
struct taia \fIb\fR;
.br
struct tai \fIsec\fR;
.br
char *\fIs\fR;
.SH DESCRIPTION
A
.B struct taia
stores an integer between 0 inclusive and 2^64x10^18 exclusive.
The format of
.B struct taia
is designed to speed up common operations;
applications should not look inside
.B struct taia\fR.
A
.B struct taia
variable is commonly used to store
a TAI64NA label.
Each TAI64NA label refers to one attosecond of real time;
see
.B http://pobox.com/~djb/proto/tai64.txt
for more information.
The integer in the
.B struct taia
is 10^18 times the second count,
plus 10^9 times the nanosecond count,
plus the attosecond count.
A
.B struct taia
variable may also be used to store
the numerical difference between two TAI64NA labels.
.SH ARITHMETIC
.B taia_approx
returns a double-precision approximation to
.IR t /10^18.
The result of
.B taia_approx
is always nonnegative.
.B taia_tai
places into
.I sec
the integer part of
.IR t /10^18.
.B taia_frac
returns a double-precision approximation to
the fraction part of
.IR t /10^18.
The result of
.B taia_frac
is always nonnegative.
.B taia_less
returns 1 if
.I a
is smaller than
.IR b ,
0 otherwise.
.B taia_add
adds
.I a
and
.I b
modulo 2^64x10^18
and puts the result into
.IR t .
The inputs and outputs may overlap.
.B taia_sub
subtracts
.I b
from
.I a
modulo 2^64x10^18
and puts the result into
.IR t .
The inputs and outputs may overlap.
.B taia_half
divides
.I a
by 2, rounding down,
and puts the result into
.IR t .
The input and output may overlap.
.SH "FORMATTING"
.B taia_fmtfrac
prints the remainder of
.IR t /10^18,
padded to exactly 18 digits,
into the character buffer
.IR s ,
without a terminating NUL.
It returns 18, the number of characters written.
.I s
may be zero;
then
.B taia_fmtfrac
returns 18 without printing anything.
The macro
.B TAIA_FMTFRAC
is defined as 19;
this is enough space for the output of
.B taia_fmtfrac
and a terminating NUL.
.SH "SEE ALSO"
taia_now(3),
taia_pack(3),
tai(3)
yap-6.2.2/packages/tai/libtai/taia.h 000644 000765 000024 00000001452 11457004725 017145 0 ustar 00vsc staff 000000 000000 #ifndef TAIA_H
#define TAIA_H
#include "tai.h"
struct taia {
struct tai sec;
unsigned long nano; /* 0...999999999 */
unsigned long atto; /* 0...999999999 */
} ;
extern void taia_tai(struct taia *ta, struct tai *t);
extern void taia_now(struct taia *t);
extern double taia_approx(struct taia *t);
extern double taia_frac(struct taia *t);
extern void taia_add(struct taia *t, struct taia *u, struct taia *v);
extern void taia_sub(struct taia *t, struct taia *u, struct taia *v);
extern void taia_half(struct taia *t, struct taia *u);
extern int taia_less(struct taia *t, struct taia *u);
#define TAIA_PACK 16
extern void taia_pack(char *s, struct taia *t);
extern void taia_unpack(char *s, struct taia *t);
#define TAIA_FMTFRAC 19
extern unsigned int taia_fmtfrac(char *s, struct taia *t);
#endif
yap-6.2.2/packages/tai/libtai/taia_add.c 000644 000765 000024 00000000571 11457004725 017751 0 ustar 00vsc staff 000000 000000 #include "taia.h"
/* XXX: breaks tai encapsulation */
void taia_add(struct taia *t, struct taia *u, struct taia *v)
{
t->sec.x = u->sec.x + v->sec.x;
t->nano = u->nano + v->nano;
t->atto = u->atto + v->atto;
if (t->atto > 999999999UL) {
t->atto -= 1000000000UL;
++t->nano;
}
if (t->nano > 999999999UL) {
t->nano -= 1000000000UL;
++t->sec.x;
}
}
yap-6.2.2/packages/tai/libtai/taia_approx.c 000644 000765 000024 00000000145 11457004725 020527 0 ustar 00vsc staff 000000 000000 #include "taia.h"
double taia_approx(struct taia *t)
{ return tai_approx(&t->sec) + taia_frac(t);
}
yap-6.2.2/packages/tai/libtai/taia_fmtfrac.c 000644 000765 000024 00000001565 11457004725 020647 0 ustar 00vsc staff 000000 000000 #include "taia.h"
unsigned int taia_fmtfrac(char *s, struct taia *t)
{
unsigned long x;
if (s) {
x = t->atto;
s[17] = '0' + (int)(x % 10); x /= 10;
s[16] = '0' + (int)(x % 10); x /= 10;
s[15] = '0' + (int)(x % 10); x /= 10;
s[14] = '0' + (int)(x % 10); x /= 10;
s[13] = '0' + (int)(x % 10); x /= 10;
s[12] = '0' + (int)(x % 10); x /= 10;
s[11] = '0' + (int)(x % 10); x /= 10;
s[10] = '0' + (int)(x % 10); x /= 10;
s[9] = '0' + (int)(x % 10);
x = t->nano;
s[8] = '0' + (int)(x % 10); x /= 10;
s[7] = '0' + (int)(x % 10); x /= 10;
s[6] = '0' + (int)(x % 10); x /= 10;
s[5] = '0' + (int)(x % 10); x /= 10;
s[4] = '0' + (int)(x % 10); x /= 10;
s[3] = '0' + (int)(x % 10); x /= 10;
s[2] = '0' + (int)(x % 10); x /= 10;
s[1] = '0' + (int)(x % 10); x /= 10;
s[0] = '0' + (int)(x % 10);
}
return 18;
}
yap-6.2.2/packages/tai/libtai/taia_frac.c 000644 000765 000024 00000000162 11457004725 020130 0 ustar 00vsc staff 000000 000000 #include "taia.h"
double taia_frac(struct taia *t)
{
return (t->atto * 0.000000001 + t->nano) * 0.000000001;
}
yap-6.2.2/packages/tai/libtai/taia_half.c 000644 000765 000024 00000000422 11457004725 020126 0 ustar 00vsc staff 000000 000000 #include "taia.h"
/* XXX: breaks tai encapsulation */
void taia_half(struct taia *t, struct taia *u)
{
t->atto = u->atto >> 1;
if (u->nano & 1) t->atto += 500000000UL;
t->nano = u->nano >> 1;
if (u->sec.x & 1) t->nano += 500000000UL;
t->sec.x = u->sec.x >> 1;
}
yap-6.2.2/packages/tai/libtai/taia_less.c 000644 000765 000024 00000000426 11457004725 020166 0 ustar 00vsc staff 000000 000000 #include "taia.h"
/* XXX: breaks tai encapsulation */
int taia_less(struct taia *t, struct taia *u)
{
if (t->sec.x < u->sec.x) return 1;
if (t->sec.x > u->sec.x) return 0;
if (t->nano < u->nano) return 1;
if (t->nano > u->nano) return 0;
return t->atto < u->atto;
}
yap-6.2.2/packages/tai/libtai/taia_now.3 000644 000765 000024 00000001135 11457004725 017741 0 ustar 00vsc staff 000000 000000 .TH taia_now 3
.SH NAME
taia_now \- get current time, with 1-attosecond precision
.SH SYNTAX
.B #include
void \fBtaia_now\fP(&\fIt\fR);
struct taia \fIt\fR;
.SH DESCRIPTION
.B taia_now
puts the current time into
.IR t .
More precisely:
.B taia_now
puts into
.I t
its best guess as to the TAI64NA label for the 1-attosecond interval
that contains the current time.
.SH NOTES
This implementation of
.B tai_now
assumes that the
.B struct timeval
returned from
.B gettimeofday
represents the number of TAI seconds since
1970-01-01 00:00:10 TAI.
.SH "SEE ALSO"
gettimeofday(2),
tai_now(3),
taia(3)
yap-6.2.2/packages/tai/libtai/taia_now.c 000644 000765 000024 00000002264 11457004725 020025 0 ustar 00vsc staff 000000 000000 #include
#ifdef __WINDOWS__
#define WINDOWS_LEAN_AND_MEAN 1
#include
#else
#include
#endif
#include "taia.h"
/* XXX: breaks tai encapsulation */
/*-------------------------------------------------------------------------
* The Microsoft Win32 API can return the current system time in "file
* timestamp" format, which is a 64-bit value representing the number of
* 100-nanosecond ticks since {AD1601-01-01 00:00:00 Z}.
* 11644473600 is seconds offset AD1601 to AD1970
*------------------------------------------------------------------------*/
void taia_now(struct taia *t)
{
#ifdef __WINDOWS__
FILETIME ft;
int64_t cns; /* 100ns ticks */
/* Get the current system time */
GetSystemTimeAsFileTime(&ft);
/* Convert to longtime_t form */
cns = ((int64_t)ft.dwHighDateTime << 32) + ft.dwLowDateTime;
t->sec.x = cns/10000000 - 11644473600 + ULL(4611686018427387914);
t->nano = (long)((cns % 10000000))*100;
t->atto = 0;
#else
struct timeval now;
gettimeofday(&now,(struct timezone *) 0);
t->sec.x = ULL(4611686018427387914) + (uint64_t) now.tv_sec;
t->nano = 1000 * now.tv_usec + 500;
t->atto = 0;
#endif
}
yap-6.2.2/packages/tai/libtai/taia_pack.3 000644 000765 000024 00000001142 11457004725 020052 0 ustar 00vsc staff 000000 000000 .TH taia_pack 3
.SH NAME
taia_pack \- convert TAI64NA labels to external format
.SH SYNTAX
.B #include
void \fBtaia_pack\fP(\fIbuf\fR,&\fIt\fR);
.br
void \fBtaia_unpack\fP(\fIbuf\fR,&\fIt\fR);
char \fIbuf\fR[\fBTAIA_PACK\fP];
.br
struct taia \fIt\fR;
.SH DESCRIPTION
.B taia_pack
converts a TAI64NA label
from internal format in
.I t
to TAI64NA format in
.IR buf .
.B taia_unpack
converts a TAI64NA label
from TAI64NA format in
.I buf
to internal format in
.IR t .
.B TAIA_PACK
is 16.
See
.B http://pobox.com/~djb/proto/tai64.txt
for more information about TAI64NA format.
.SH "SEE ALSO"
taia(3)
yap-6.2.2/packages/tai/libtai/taia_pack.c 000644 000765 000024 00000000565 11457004725 020142 0 ustar 00vsc staff 000000 000000 #include "taia.h"
void taia_pack(char *s, struct taia *t)
{
unsigned long x;
tai_pack(s,&t->sec);
s += 8;
x = t->atto;
s[7] = (int)x & 255; x >>= 8;
s[6] = (int)x & 255; x >>= 8;
s[5] = (int)x & 255; x >>= 8;
s[4] = (int)x;
x = t->nano;
s[3] = (int)x & 255; x >>= 8;
s[2] = (int)x & 255; x >>= 8;
s[1] = (int)x & 255; x >>= 8;
s[0] = (int)x;
}
yap-6.2.2/packages/tai/libtai/taia_sub.c 000644 000765 000024 00000000654 11457004725 020014 0 ustar 00vsc staff 000000 000000 #include "taia.h"
/* XXX: breaks tai encapsulation */
void taia_sub(struct taia *t, struct taia *u, struct taia *v)
{
unsigned long unano = u->nano;
unsigned long uatto = u->atto;
t->sec.x = u->sec.x - v->sec.x;
t->nano = unano - v->nano;
t->atto = uatto - v->atto;
if (t->atto > uatto) {
t->atto += 1000000000UL;
--t->nano;
}
if (t->nano > unano) {
t->nano += 1000000000UL;
--t->sec.x;
}
}
yap-6.2.2/packages/tai/libtai/taia_tai.c 000644 000765 000024 00000000125 11457004725 017771 0 ustar 00vsc staff 000000 000000 #include "taia.h"
void taia_tai(struct taia *ta, struct tai *t)
{
*t = ta->sec;
}
yap-6.2.2/packages/tai/libtai/taia_unpack.c 000644 000765 000024 00000000663 11457004725 020504 0 ustar 00vsc staff 000000 000000 #include "taia.h"
void taia_unpack(char *s, struct taia *t)
{
unsigned long x;
tai_unpack(s,&t->sec);
s += 8;
x = (unsigned char) s[4];
x <<= 8; x += (unsigned char) s[5];
x <<= 8; x += (unsigned char) s[6];
x <<= 8; x += (unsigned char) s[7];
t->atto = x;
x = (unsigned char) s[0];
x <<= 8; x += (unsigned char) s[1];
x <<= 8; x += (unsigned char) s[2];
x <<= 8; x += (unsigned char) s[3];
t->nano = x;
}
yap-6.2.2/packages/tai/libtai/THANKS 000644 000765 000024 00000000000 11457004725 016755 0 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/tai/libtai/TODO 000644 000765 000024 00000000246 11457004725 016546 0 ustar 00vsc staff 000000 000000 test caldate_mjd handling of weird days
test caldate_mjd handling of weird months
manually verify check.out
make 32-bit version?
test, test, test!
support time zones
yap-6.2.2/packages/tai/libtai/VERSION 000644 000765 000024 00000000014 11457004725 017117 0 ustar 00vsc staff 000000 000000 libtai 0.60
yap-6.2.2/packages/tai/libtai/yearcal.c 000644 000765 000024 00000002244 11457004725 017642 0 ustar 00vsc staff 000000 000000 #include
#include
#include "caldate.h"
char *montab[] = {
"January"
, "February"
, "March"
, "April"
, "May"
, "June"
, "July"
, "August"
, "September"
, "October"
, "November"
, "December"
} ;
int main(int argc, char **argv)
{
int year;
long daystart;
long dayend;
long day;
int weekday;
struct caldate cd;
while (*++argv) {
year = atoi(*argv);
cd.year = year;
cd.month = 1;
cd.day = 1;
daystart = caldate_mjd(&cd);
cd.year = year + 1;
dayend = caldate_mjd(&cd);
while ((daystart + 3) % 7) --daystart;
while ((dayend + 3) % 7) ++dayend;
for (day = daystart;day < dayend;++day) {
caldate_frommjd(&cd,day,&weekday,(int *) 0);
if (cd.year != year)
printf(" ");
else {
if (cd.month & 1)
if (cd.day < 10)
printf(" %d%c%d ",cd.day % 10,8,cd.day % 10);
else
printf("%d%c%d%d%c%d ",cd.day / 10,8,cd.day / 10,cd.day % 10,8,cd.day % 10);
else
printf("%2d ",cd.day);
if (weekday == 6) {
if ((cd.day >= 15) && (cd.day < 22))
printf(" %s %d\n",montab[cd.month - 1],year);
else
printf("\n");
}
}
}
printf("\n");
}
exit(0);
}
yap-6.2.2/packages/swi-minisat2/C/ 000755 000765 000024 00000000000 11702065316 016537 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/swi-minisat2/cnf.pl 000644 000765 000024 00000006337 11457004725 017475 0 ustar 00vsc staff 000000 000000
%%============================================================================
%% CNF.pl
%% Convertor of Boolean formulae to CNF
%% Copyright (c) 2006, Michael Codish, Vitaly Lagoon, and Peter J. Stuckey
%%
%% Permission is hereby granted, free of charge, to any person obtaining a
%% copy of this software and associated documentation files (the
%% "Software"), to deal in the Software without restriction, including
%% without limitation the rights to use, copy, modify, merge, publish,
%% distribute, sublicense, and/or sell copies of the Software, and to
%% permit persons to whom the Software is furnished to do so, subject to
%% the following conditions:
%%
%% The above copyright notice and this permission notice shall be included
%% in all copies or substantial portions of the Software.
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
%% OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
%% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
%% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
%% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
%% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
:- module(cnf,[cnf/2,cnf_dl/2]).
cnf(F,Cnf) :- cnf_dl(F,Cnf-[]).
cnf_dl(F,[[B]|Cnf1]-Cnf2) :- iff(F,+,B,Cnf2,Cnf1).
iff(V,_,B,Acc,Cnf) :- var(V), !, V=B, Cnf=Acc.
iff(1,_,B,Acc,Cnf) :- !, B=1, Cnf=Acc.
iff(0,_,B,Acc,Cnf) :- !, B=0, Cnf=Acc.
iff(-X,+,B,Acc,Cnf) :- !, iff(X,-,BX,Acc,Cnf), neglit(BX,B).
iff(-X,-,B,Acc,Cnf) :- !, iff(X,+,BX,Acc,Cnf), neglit(BX,B).
iff(-X,*,B,Acc,Cnf) :- !, iff(X,*,BX,Acc,Cnf), neglit(BX,B).
iff((X+Y),Polarity,B,Acc,Cnf) :- !,
iff(X,Polarity,BX,Acc,AccX),
iff(Y,Polarity,BY,AccX,AccXY),
(
Polarity == + -> Cnf = [[-B,BX,BY]|AccXY]
;
Polarity == - -> Cnf = [[B,-BX],[B,-BY]|AccXY]
;
Cnf = [[-B,BX,BY], [B,-BX], [B,-BY] | AccXY]
).
iff((X*Y),Polarity,B,Acc,Cnf) :- !,
iff(X,Polarity,BX,Acc,AccX),
iff(Y,Polarity,BY,AccX,AccXY),
(
Polarity == + -> Cnf = [[-B,BX],[-B,BY]|AccXY]
;
Polarity == - -> Cnf = [[B,-BX,-BY]|AccXY]
;
Cnf = [[B,-BX,-BY], [-B,BX], [-B,BY] | AccXY]
).
iff((X==Y),Polarity,B,Acc,Cnf) :- !,
iff(X,*,BX,Acc,AccX),
iff(Y,*,BY,AccX,AccXY),
(
Polarity == + -> Cnf = [[-BX,BY,-B],[BX,-BY,-B] | AccXY]
;
Polarity == - -> Cnf = [[-BX,-BY,B],[BX,BY,B] | AccXY]
;
Cnf = [[-BX,BY,-B],[BX,-BY,-B],[-BX,-BY,B],[BX,BY,B] | AccXY]
).
iff((X xor Y),Polarity,B,Acc,Cnf) :- !,
iff(X,*,BX,Acc,AccX),
iff(Y,*,BY,AccX,AccXY),
(
Polarity == + -> Cnf = [[-BX,-BY,-B],[BX,BY,-B] | AccXY]
;
Polarity == - -> Cnf = [[-BX,BY,B],[BX,-BY,B] | AccXY]
;
Cnf = [[-BX,BY,B],[BX,-BY,B],[-BX,-BY,-B],[BX,BY,-B] | AccXY]
).
iff((X->Y;Z),Polarity,B,Acc,Cnf) :- !,
iff(X,*,BX,Acc,AccX),
iff(Y,Polarity,BY,AccX,AccXY),
iff(Z,Polarity,BZ,AccXY,AccXYZ),
(
Polarity == + -> Cnf = [[-BX,BY,-B],[BX,BZ,-B],[BY,BZ,-B]|AccXYZ]
;
Polarity == - -> Cnf = [[-BX,-BY,B],[BX,-BZ,B],[-BY,-BZ,B]|AccXYZ]
;
Cnf = [[-BX,BY,-B], [BX,BZ,-B], [BY,BZ,-B],
[-BX,-BY,B], [BX,-BZ,B], [-BY,-BZ,B] | AccXYZ]
).
neglit(V,-V) :- var(V), !.
neglit(-V,V).
neglit(0,1).
neglit(1,0).
yap-6.2.2/packages/swi-minisat2/examples/ 000755 000765 000024 00000000000 11702065316 020173 5 ustar 00vsc staff 000000 000000 yap-6.2.2/packages/swi-minisat2/Makefile.in 000644 000765 000024 00000001646 11457004725 020435 0 ustar 00vsc staff 000000 000000 #
# default base directory for YAP installation
#
#
ROOTDIR = @prefix@
#
# where the binary should be
#
BINDIR = $(ROOTDIR)/bin
#
# where YAP should look for binary libraries
#
LIBDIR=@libdir@
YAPLIBDIR=@libdir@/Yap
#
# where YAP should look for architecture-independent Prolog libraries
#
SHAREDIR=$(ROOTDIR)/share
#
#
# You shouldn't need to change what follows.
#
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
srcdir=@srcdir@
YAP_EXTRAS=@YAP_EXTRAS@
PROGRAMS= \
$(srcdir)/cnf.pl \
$(srcdir)/minisat.pl
EXAMPLE_PROGRAMS= \
$(srcdir)/examples/adder.pl \
$(srcdir)/examples/pearl_examples.pl
install: $(PROGRAMS)
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap
mkdir -p $(DESTDIR)$(SHAREDIR)/Yap/minisat_examples
for p in $(PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap; done
for p in $(EXAMPLE_PROGRAMS); do $(INSTALL_DATA) $$p $(DESTDIR)$(SHAREDIR)/Yap/minisat_examples; done
clean:
yap-6.2.2/packages/swi-minisat2/minisat.pl 000644 000765 000024 00000017034 11457004725 020367 0 ustar 00vsc staff 000000 000000 %%============================================================================
%% The SWI-Prolog interface to MiniSat SAT solver
%% http://www.cs.chalmers.se/Cs/Research/FormalMethods/MiniSat/MiniSat.html
%%
%% Copyright (c) 2006, Michael Codish, Vitaly Lagoon, and Peter J. Stuckey
%%
%% Permission is hereby granted, free of charge, to any person obtaining a
%% copy of this software and associated documentation files (the
%% "Software"), to deal in the Software without restriction, including
%% without limitation the rights to use, copy, modify, merge, publish,
%% distribute, sublicense, and/or sell copies of the Software, and to
%% permit persons to whom the Software is furnished to do so, subject to
%% the following conditions:
%%
%% The above copyright notice and this permission notice shall be included
%% in all copies or substantial portions of the Software.
%%
%% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
%% OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
%% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
%% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
%% LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
%% OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
%% WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
:- module(minisat,[
solve/1,
sat/1,
sat_init/0,
sat_deinit/0,
sat_add_clauses/3,
sat_solve/1,
minimize/2,
maximize/2,
minimize_v1/2,
maximize_v1/2,
minimize_v2/2,
maximize_v2/2,
minimize_v3/2,
maximize_v3/2
]).
:- if(current_prolog_flag(dialect, yap)).
:- load_foreign_files(['pl-minisat'],[],install).
:- else.
:- use_module(library(shlib)).
:- load_foreign_library('pl-minisat.so',install).
:- endif.
:- dynamic tmp/1.
%%
%%
sat_init :-
minisat_new_solver, % - create the new solve
minisat_add_clause([-1]), % - add zero
minisat_add_clause([2]). % - add one
%%
%%
sat_deinit :-
minisat_delete_solver.
%%
%%
sat_add_clauses(Cs, Vs, MiniSat_Vs) :-
term_variables(Cs,CsVars),
\+ \+ (
bind2index(CsVars),
add_cnf_clauses(Cs),
asserta(tmp(Vs))
),
retract(tmp(MiniSat_Vs)).
add_cnf_clauses([]).
add_cnf_clauses([Cl|Cls]) :-
to_minisat(Cl,MiniSatCl),
minisat_add_clause(MiniSatCl),
add_cnf_clauses(Cls).
to_minisat([],[]).
to_minisat([L|Ls],[N|Ns]) :-
minisat_aux(L,N),
to_minisat(Ls,Ns).
minisat_aux(0,1) :- !.
minisat_aux(1,2) :- !.
minisat_aux(-(1),1) :- !.
minisat_aux(-(0),2) :- !.
minisat_aux(N,NN) :- NN is N.
bind2index(Vs) :-
minisat_nvars(N),
N1 is N+1,
bind2index_aux(Vs,N1).
bind2index_aux([],_N).
bind2index_aux([V|Ns],N) :-
var(V),
!,
V=N,
N1 is N+1, bind2index_aux(Ns,N1).
bind2index_aux([V|Ns],N) :-
integer(V),
bind2index_aux(Ns,N).
%%
%%
sat_solve(As) :-
to_minisat(As,MINISAT_As),
minisat_solve(MINISAT_As).
%%
%%
sat_get_values([],[]).
sat_get_values([SAT_V|SVs],[PL_V|PL_Vs]) :-
minisat_get_var_assignment(SAT_V,N),
( N<0 -> PL_V=0 ; PL_V=1),
sat_get_values(SVs,PL_Vs).
%%
%% sat(+CNF): succeds if CNF is satisfaiable, it does not bind the variables in CNF
%%
sat(CNF) :-
sat_init,
sat_add_clauses(CNF,_,_),
sat_solve([]),
sat_deinit,
!.
sat(_CNF) :-
sat_deinit,
!,
fail.
%%
%% solve(+CNF): like CNF/1 but bind the variables of CNF to the solution
%%
solve(CNF) :-
sat_init,
term_variables(CNF,CNF_Vs),
sat_add_clauses(CNF,CNF_Vs,SAT_Vs),
sat_solve([]),
sat_get_values(SAT_Vs,CNF_Vs),
sat_deinit,
!.
solve(_) :-
sat_deinit,
!,
fail.
%%
%%
%%
minimize(Vec,CNF) :- minimize_v1(Vec,CNF).
maximize(Vec,CNF) :- maximize_v1(Vec,CNF).
%%
%%
minimize_v1(Vec,CNF) :-
minimize_v1_aux(Vec,CNF),
sat(CNF).
minimize_v1_aux([],_CNF).
minimize_v1_aux([B|Bs],CNF) :-
minimize_v1_aux(Bs,CNF),
( (B=0, sat(CNF)) -> true ; B=1 ).
%%
%%
maximize_v1(Vec,CNF) :-
maximize_v1_aux(Vec,CNF),
sat(CNF).
maximize_v1_aux([],_CNF).
maximize_v1_aux([B|Bs],CNF) :-
maximize_v1_aux(Bs,CNF),
( (B=1, sat(CNF)) -> true ; B=0 ).
%%
%%
minimize_v2(Vec,CNF) :-
retractall(tmp(_)),
reverse(Vec,Vec_MSB),
term_variables(CNF,CNF_Vars),
sat_init,
sat_add_clauses(CNF,[Vec_MSB,CNF_Vars],[Vec_MSB_SVars,CNF_SVars]),
minimize_v2_loop(Vec_MSB_SVars),
sat_get_values(CNF_SVars,CNF_Vars),
sat_deinit,
!.
minimize_v2_loop([]) :-
sat_solve([]).
minimize_v2_loop([V|Vs]) :-
( sat_solve([-V]) ->
eliminate_prefix(Vs,0,New_Vs)
;
sat_add_clauses([[V]],_,_),
New_Vs=Vs
),
minimize_v2_loop(New_Vs).
%%
%%
maximize_v2(Vec,CNF) :-
reverse(Vec,Vec_MSB),
term_variables(CNF,CNF_Vars),
sat_init,
sat_add_clauses(CNF,[Vec_MSB,CNF_Vars],[Vec_MSB_SVars,CNF_SVars]),
maximize_v2_loop(Vec_MSB_SVars),
sat_get_values(CNF_SVars,CNF_Vars),
sat_deinit,
!.
maximize_v2_loop([]) :-
sat_solve([]).
maximize_v2_loop([V|Vs]) :-
( sat_solve([V]) ->
eliminate_prefix(Vs,1,New_Vs)
;
sat_add_clauses([[V]],_,_),
New_Vs=Vs
),
maximize_v2_loop(New_Vs).
%%
%%
minimize_v3(Vec,CNF) :-
retractall(tmp(_)),
term_variables(CNF,CNF_Vars),
sat_init,
sat_add_clauses(CNF,[Vec,CNF_Vars],[Vec_SVars,CNF_SVars]),
sat_solve([]),
sat_get_values(Vec_SVars,Curr_Min),
sat_get_values(CNF_SVars,Curr_Sol),
minimize_v3_loop(Vec_SVars,CNF_SVars,Curr_Min,Curr_Sol,Vec,CNF_Vars),
minisat_delete_solver,
!.
minimize_v3_loop(Vec,CNF_SVars,Last_Min,_Last_Sol,Final_Min,Final_Sol) :-
xs_gt_ys(Last_Min,Vec,CNF-[]),
sat_add_clauses(CNF,_,_),
sat_solve([]),
sat_get_values(Vec,Curr_Min),
sat_get_values(CNF_SVars,Curr_Sol),
!,
minimize_v3_loop(Vec,CNF_SVars,Curr_Min,Curr_Sol,Final_Min,Final_Sol).
minimize_v3_loop(_Vec,_CNF_SVars,Final_Min,Final_Sol,Final_Min,Final_Sol) :-
!.
%%
%%
maximize_v3(Vec,CNF) :-
retractall(tmp(_)),
term_variables(CNF,CNF_Vars),
sat_init,
sat_add_clauses(CNF,[Vec,CNF_Vars],[Vec_SVars,CNF_SVars]),
sat_solve([]),
sat_get_values(Vec_SVars,Curr_Max),
sat_get_values(CNF_SVars,Curr_Sol),
maximize_v3_loop(Vec_SVars,CNF_SVars,Curr_Max,Curr_Sol,Vec,CNF_Vars),
minisat_delete_solver,
!.
maximize_v3_loop(Vec,CNF_SVars,Last_Max,_Last_Sol,Final_Max,Final_Sol) :-
xs_gt_ys(Vec,Last_Max,CNF-[]),
sat_add_clauses(CNF,_,_),
sat_solve([]),
sat_get_values(Vec,Curr_Max),
sat_get_values(CNF_SVars,Curr_Sol),
!,
maximize_v3_loop(Vec,CNF_SVars,Curr_Max,Curr_Sol,Final_Max,Final_Sol).
maximize_v3_loop(_Vec,_CNF_SVars,Final_Max,Final_Sol,Final_Max,Final_Sol) :-
!.
%%
%%
eliminate_prefix([],_Bit,[]) :- !.
eliminate_prefix([V|Vs],Bit,New_Vs) :-
sat_get_values([V],[VVal]),
VVal = Bit,
( Bit = 0 -> sat_add_clauses([[-V]],_,_) ; sat_add_clauses([[V]],_,_) ),
!,
eliminate_prefix(Vs,Bit,New_Vs).
eliminate_prefix(Vs,Vs).
%%
%%
% B == (Xs = Ys)
xs_eq_ys([X],[Y],B,Cnf1-Cnf2) :-
!,
eq(X,Y,B,Cnf1-Cnf2).
xs_eq_ys([X|Xs],[Y|Ys],B,Cnf1-Cnf4) :-
eq(X,Y,B1,Cnf1-Cnf2),
xs_eq_ys(Xs,Ys,B2,Cnf2-Cnf3),
and(B1,B2,B,Cnf3-Cnf4).
%%
xs_gt_ys(Xs,Ys,[[B]|Cnf1]-Cnf2) :-
xs_gt_ys(Xs,Ys,B,Cnf1-Cnf2).
%%
%%
xs_gt_ys([X],[Y],B,Cnf1-Cnf2) :- !,
gt(X,Y,B,Cnf1-Cnf2).
xs_gt_ys(Xs,Ys,B, Cnf1-Cnf6) :-
split(Xs,LoXs,HiXs),
split(Ys,LoYs,HiYs),
xs_gt_ys(HiXs,HiYs,B1,Cnf1-Cnf2),
xs_eq_ys(HiXs,HiYs,B2,Cnf2-Cnf3),
xs_gt_ys(LoXs,LoYs,B3,Cnf3-Cnf4),
and(B2,B3,Tmp, Cnf4-Cnf5),
or(B1,Tmp,B,Cnf5-Cnf6).
% Z == X > Y (equivalently Z == X * -Y)
gt(X,Y,Z,[[Z,-X,Y],[-Z,X],[-Z,-Y]|Cnf]-Cnf).
% Z == (X == Y)
eq(X,Y,Z, [[-Z,-X,Y],[-Z,X,-Y],
[Z,X,Y],[Z,-X,-Y] | Cnf]-Cnf).
% Z == X or Y
or(X,Y,Z, [[Z,-X],[Z,-Y],[-Z,X,Y] | Cnf]-Cnf).
% Z == X and Y
and(X,Y,Z, [[Z,X,Y],[-Z,X],[-Z,Y] | Cnf]-Cnf).
%
split(Xs,As,Bs) :-
length(Xs,N), M is N // 2,
length(As,M), append(As,Bs,Xs).
yap-6.2.2/packages/swi-minisat2/README 000644 000765 000024 00000000265 11457004725 017244 0 ustar 00vsc staff 000000 000000 You need to put the file swi-minisat2.tgz in a directory where you want
the solver and the interface and then do:
% tar zxvf swi-minisat2.tgz
% ./configure.sh
% make
% make clean
yap-6.2.2/packages/swi-minisat2/README.YAP 000644 000765 000024 00000000725 11457004725 017675 0 ustar 00vsc staff 000000 000000 This is the minisat package as described in
Michael Codish, Vitaly Lagoon, Peter J. Stuckey: Logic programming
with satisfiability. TPLP 8(1): 121-128 (2008)
We thank the authors for kindly allowing us to use this package in YAP.
Please check the examples in $install/share/Yap/minisat/examples and
the TPLP paper to understand how the system can be used.
Last, please contact yap-users AT sf.net for any bugs first, as they
may have been caused by the YAP port.
yap-6.2.2/packages/swi-minisat2/examples/adder.pl 000644 000765 000024 00000001152 11457004725 021612 0 ustar 00vsc staff 000000 000000 :- module(adder,[sum/3]).
sum([B],[S],(S==B)).
sum([B1,B2|Bs],Sum,F1*F2*F3) :-
split([B1,B2|Bs],Xs,Ys),
sum(Xs,S1,F1), sum(Ys,S2,F2),add(S1,S2,Sum,F3).
split([],[],[]).
split([X],[X],[0]).
split([X,Y|XYs],[X|Xs],[Y|Ys]) :- split(XYs,Xs,Ys).
add([X|Xs],[Y|Ys],[Z|Zs],(Z==SumXY)*Sum) :-
halfadder(X,Y,SumXY,CarryXY),
adder(Xs,Ys,CarryXY,Zs,Sum).
adder([],[],Carry,[Z],Z==Carry).
adder([X|Xs],[Y|Ys],Carry,[Z|Zs],(Z==SumXY)*Rest) :-
fulladder(X,Y,Carry,SumXY,CarryXY),
adder(Xs,Ys,CarryXY,Zs,Rest).
fulladder(X, Y, C, (X xor Y xor C), (C->(X+Y);(X*Y)) ).
halfadder(X, Y, (X xor Y), X*Y ).
yap-6.2.2/packages/swi-minisat2/examples/pearl_examples.pl 000644 000765 000024 00000002330 11457004725 023533 0 ustar 00vsc staff 000000 000000
:- use_module(library(cnf)).
:- use_module(library(minisat)).
:- use_module(adder).
%% Example, pg3
%%
%% ?- cnf(X==Y,Cnf).
%% Cnf = [[T], [-X, Y, -T], [X, -Y, -T]]
%% ?- cnf((X*Y)+(-X*Z),Cnf).
%% Cnf = [[T], [-T, T1, T2], [-T2, -X],
%% [-T2, Z], [-T1, X], [-T1, Y]]
%% Example, pg4
%%
%% ?- sum([X+Y,X*Y,X==Y,X xor Y],[S1,S2,S3],Psi).
%% Psi = (T1==X+Y)*(T2==(X==Y))*(T3==T1 xor T2)*(T4==T1*T2)*(T5==X*Y)*
%% (T6==X xor Y)*(T7==T5 xor T6)* (T8==T5*T6)*(S1==T3 xor T7)*
%% (S2==T4 xor T8 xor (T3*T7))* (S3==(T3*T7->T4+T8;T4*T8))
%% Examples, pg6
%%
%% ?- cnf(X==Y,Cnf), solve(Cnf).
%% X=0, Y=0
%%
%% ?- cnf(X==Y,Cnf), sat(Cnf).
%% Yes
%%
%% ?- sum([X+Y,X*Y,X==Y,X xor Y],Sum,F), cnf(F,Cnf), solve(Cnf).
%% X = 0, Y = 0
%% Sum = [1, 0, 0]
%%
%% ?- sum([X+Y,X*Y,X==Y,X xor Y],[0,1,0],F), cnf(F,Cnf), solve(Cnf).
%% X = 0, Y = 1
%%
%% ?- sum([X+Y,X*Y,X==Y,X xor Y],Sum,F), cnf(F,Cnf),
%% maximize(Sum,Cnf), solve(Cnf).
%% Sum=[1,1,0]
%% X=1, Y=1
%% Figure 3, pg 6
%%
%% partialMaxSat(+,+).
partialMaxSat(Phi,Psi) :-
sum(Psi,Max,SumPsi), cnf(Phi*SumPsi,Cnf),
maximize(Max,Cnf), solve(Cnf).
%% Example, pg 7
%%
%% ?- partialMaxSat(X+Y,[X*Y,X==Y,X xor Y,-X+Y, -X, -Y, X]).
%% X = 1, Y = 1
yap-6.2.2/packages/swi-minisat2/C/Alg.h 000644 000765 000024 00000004026 11457004725 017421 0 ustar 00vsc staff 000000 000000 /*******************************************************************************************[Alg.h]
MiniSat -- Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************************************/
#ifndef Alg_h
#define Alg_h
//=================================================================================================
// Useful functions on vectors
#if 1
template
static inline void remove(V& ts, const T& t)
{
int j = 0;
for (; j < ts.size() && ts[j] != t; j++);
assert(j < ts.size());
for (; j < ts.size()-1; j++) ts[j] = ts[j+1];
ts.pop();
}
#else
template
static inline void remove(V& ts, const T& t)
{
int j = 0;
for (; j < ts.size() && ts[j] != t; j++);
assert(j < ts.size());
ts[j] = ts.last();
ts.pop();
}
#endif
template
static inline bool find(V& ts, const T& t)
{
int j = 0;
for (; j < ts.size() && ts[j] != t; j++);
return j < ts.size();
}
#endif
yap-6.2.2/packages/swi-minisat2/C/BasicHeap.h 000644 000765 000024 00000006714 11457004725 020543 0 ustar 00vsc staff 000000 000000 /******************************************************************************************[Heap.h]
MiniSat -- Copyright (c) 2003-2006, Niklas Een, Niklas Sorensson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
**************************************************************************************************/
#ifndef BasicHeap_h
#define BasicHeap_h
#include "Vec.h"
//=================================================================================================
// A heap implementation with support for decrease/increase key.
template