Different versions of SLP can be built by setting
#define
-switches in this include file:
#define VER_UNIX
VER_UNIX
should be defined if this program
is built under a UNIX operating system.
I tested it with gcc under Solaris.
If VER_UNIX
is defined,
VER_SIGNAL
will also be selected,
and VER_IOSTREAM
will not be selected
(see below).
VER_UNIX
can also be defined in the makefile
(on the compiler command line):
The code in ver.h
checks whether
VER_UNIX
or VER_WINDOWS
are already defined before the setting in ver.h
is executed.
#define VER_WINDOWS
VER_WINDOWS
should be defined if this program
is built under a Windows-style operating system.
I tested it with Visual C++ 6.0 under Windows Me.
Currently,
VER_WINDOWS
is simply the negation of
VER_UNIX
.
So VER_SIGNAL
will not be selected,
and VER_IOSTREAM
will be selected
(see below).
Having an explicit symbol for the negation is also important
for the possibility to select VER_UNIX
or
VER_WINDOWS
on the command line.
The setting in ver.h
is only the default
if none of the two symbols is already defined.
#define VER_CGI
VER_CGI
is defined,
the module in_file checks
that the file name consists of at most 8 characters,
which must all be letters.
Also, the directory VER_CGI_EXDIR
is placed in front of the file name which the user has specified.
#define VER_CGI_EXDIR
"/home/sbrass/public_html/slp/ex/"
VER_CGI_EXDIR
simply is a prefix
to the user-specified filename.
So it normally contains
a slash /
at the end.
Currently,
VER_CGI_EXDIR
is defined in the makefile
for the UNIX version,
not in ver.h
.
#define VER_DEBUG
VER_DEBUG
is defined,
the run-time assertion checks in check.h
are activated.
In addition many classes define a method valid()
which checks invariants of the data structure.
Also,
many classes get a member Magic
which contains a magic number to identify objects of that class.
If VER_DEBUG
is not defined,
the compiled binary program is a bit smaller
and runs slightly faster.
So at least before performance comparisons with other
logic programming systems,
SLP should be compiled without VER_DEBUG
set.
static const int VER_MAX_HEAD_LIT = 256;
static const int VER_MAX_BODY_LIT = 256;
static const int VER_MAX_NEG_SIZE = 256;
static const int VER_MAX_COND_NEG = 256;
static const long VER_MAX_COMPAR = 2147483647L;
static const int VER_MAX_VARS = 256;
static const int VER_MAX_ARGS = 256;
static const int VER_BITS_PER_BYTE = 8;
nint.h
to check that the negation number corresponds to a bit
in nint_t
(unsigned long
).
I know that it is defined as CHAR_BITS
in limits.h
,
but I didn't want to include limits.h
in too many files for a constant that is anyway everywhere the same.
static const int VER_MAX_CRIT_NEG = 32;
sizeof(unsigned long) * VER_BITS_PER_BYTE
,
since an unsigned long
value is used as bitmap
(it contains a 1-bit for the true default negations).
Because all possible interpretations must be considered,
this does not seem a big restriction.
However,
one only would have to exchange the module nint.h
to remove this restriction.
static const int VER_BACKTRACK_POINTS = 256;
#define VER_SIGNAL
VER_SIGNAL
and VER_DEBUG
are defined,
the procedure check_init
(see the check module)
defines signal handlers for SIGSEGV
,
SIGBUS
and SIGFPE
.
These are three common runtime errors.
If SLP is runs as CGI-program,
one normally gets no information if it crashes
(maybe "internal server error").
With VER_SIGNAL and VER_DEBUG set,
one gets at least the information that an exception happened in SLP
(and which kind of exception).
In Visual C++,
SIGBUS
is not defined,
and the documentation says that SIGSEGV
is not generated under Windows NT
- it is only defined for compatibility.
Also, the signal handler should not use the functions
of the stdio library,
and should not generate any system call.
So it is anyway not very useful.
Therefore,
VER_SIGNAL
is currently only supported under UNIX.
It is automatically defined in ver.h
if VER_UNIX
is defined.
#define VER_IOSTREAM
fstream.h
in the module in_file.
Since I couldn't change the system include file,
I decided not to use it and to use directly the UNIX
system calls like open
and read
.
A small bonus is that this version probably runs a bit faster.
But later I used Visual C++ under Windows,
and the UNIX system calls are not supported there.
But at least there fstream.h
generates no warnings,
so I chose standard stream IO under windows.
VER_IOSTREAM
selects the stream input in
the module in_file.
Other modules already use stream IO,
because there I needed only iostream.h
which did not generate warnings.
VER_IOSTREAM
is automatically defined
in ver.h
if VER_WINDOWS
is defined.
It is possible to defined VER_IOSTREAM
also under UNIX.
#define VER_CS_ISO
VER_CS_ISO
is defined,
the ISO Latin 8859/1 character set is used.
Accented national characters like äöü can then
be used in identifiers (predicate and constant names).
If neither VER_CS_ISO
nor VER_CS_MSDOS
is defined,
on the Standard ASCII character set is supported.
If VER_UNIX
is defined,
VER_CS_ISO
automatically gets defined
in ver.h
.
#define VER_CS_MSDOS
VER_WINDOWS
is set.