YAP 7.1.0
YapTerm.h
1/*************************************************************************
2* *
3* YAP Prolog %W% %G% *
4* Yap Prolog was developed at NCCUP - Universidade do Porto *
5* *
6* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
7* *
8**************************************************************************
9* *
10* File: Yap.h *
11* mods: *
12* comments: abstract type definitions for YAP *
13* version: $Id: Yap.h,v 1.38 2008-06-18 10:02:27 vsc Exp $ *
14*************************************************************************/
15
16#ifndef YAPTTERM_H
17
18#define YAPPTERM_H 1
19
20#ifndef YAP_H
21#include "YapTermConfig.h"
22#include "config.h"
23
24#endif
25
26#if HAVE_STDINT_H
27#include <stdint.h>
28#endif
29#if HAVE_INTTYPES_H
30#include <inttypes.h>
31#endif
32
33/* truth-values */
34/* stdbool defines the booleam type, bool,
35 and the constants false and true */
36#if HAVE_STDBOOL_H
37#include <stdbool.h>
38#else
39#ifndef true
40typedef int _Bool;
41#define bool _Bool;
42
43#define false 0
44#define true 1
45#endif
46#endif /* HAVE_STDBOOL_H */
47
48
49#define ALIGN_BY_TYPE(X, TYPE) \
50 (((CELL)(X) + (sizeof(TYPE) - 1)) & ~(sizeof(TYPE) - 1))
51
52#ifndef EXTERN
53#ifdef MSC_VER
54#define EXTERN
55#else
56#define EXTERN extern
57#endif
58#endif
59
60/* defines integer types Int and UInt (unsigned) with the same size as a ptr
61** and integer types Short and UShort with half the size of a ptr */
62
63#if defined(PRIdPTR)
64
65typedef intptr_t YAP_Int;
66typedef uintptr_t YAP_UInt;
67
68#elif defined(_WIN64)
69
70
71typedef int64_t YAP_Int;
72typedef uint64_t YAP_UInt;
73
74#elif defined(_WIN32)
75
76typedef int32_t YAP_Int;
77typedef uint32_t YAP_UInt;
78
79#elif SIZEOF_LONG_INT == SIZEOF_INT_P
80
81typedef long int YAP_Int;
82typedef unsigned long int YAP_UInt;
83
84#elif SIZEOF_INT == SIZEOF_INT_P
85
86typedef int YAP_Int;
87typedef unsigned int YAP_UInt;
88
89#else
90#error Yap require integer types of the same size as a pointer
91#endif
92
93/* */ typedef short int YAP_Short;
94/* */ typedef unsigned short int YAP_UShort;
95
96typedef YAP_UInt YAP_CELL;
97typedef YAP_UInt YAP_Term;
98
99/* Type definitions */
100
101
102#ifndef TRUE
103#define TRUE true
104#endif
105#ifndef FALSE
106#endif
107
108typedef bool YAP_Bool;
109#define FALSE false
110
111typedef YAP_Int YAP_handle_t;
112
113
114typedef double YAP_Float;
115
116typedef void *YAP_Atom;
117
118typedef void *YAP_Functor;
119
120#ifdef YAP_H
121
122typedef YAP_Int Int;
123typedef YAP_UInt UInt;
124typedef YAP_Short Short;
125typedef YAP_UShort UShort;
126
127typedef uint16_t BITS16;
128typedef int16_t SBITS16;
129typedef uint32_t BITS32;
130
131typedef YAP_CELL CELL;
132
133typedef YAP_Term Term;
134
135#define WordSize sizeof(BITS16)
136#define CellSize sizeof(CELL)
137#define SmallSize sizeof(SMALLUNSGN)
138
139typedef YAP_Int Int;
140typedef YAP_Float Float;
141typedef YAP_handle_t yhandle_t;
142
143#endif
144
145#include "YapError.h"
146
147#include "../os/encoding.h"
148
149typedef encoding_t YAP_encoding_t;
150
151#include "YapFormat.h"
152
153/*************************************************************************************************
154 type casting macros
155*************************************************************************************************/
156
157#if SIZEOF_INT < SIZEOF_INT_P
158#define SHORT_INTS 1
159#else
160#define SHORT_INTS 0
161#endif
162
163#ifdef __GNUC__
164typedef long long int YAP_LONG_LONG;
165typedef unsigned long long int YAP_ULONG_LONG;
166#else
167typedef long int YAP_LONG_LONG;
168typedef unsigned long int YAP_ULONG_LONG;
169#endif
170
171#define Unsigned(V) ((CELL)(V))
172#define Signed(V) ((Int)(V))
173
174#endif