BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
Main Page
Related Pages
Classes
Files
File List
File Members
mem
page.h
Go to the documentation of this file.
1
// ============================================================================
2
// Project: Deductive Database
3
// Filename: page.h
4
// Purpose: A memory page
5
// Last Change: 03.08.2017
6
// Language: C++
7
// EMail: brass@informatik.uni-halle.de
8
// WWW: http://www.informatik.uni-halle.de/~brass/
9
// Address: Feldschloesschen 15, D-06120 Halle (Saale), GERMANY
10
// Copyright: (c) 2015-2017 by Stefan Brass
11
// License: See file "LICENSE" for copying conditions.
12
// Note: There is no warranty at all - this code may contain bugs.
13
// ============================================================================
14
15
22
//=============================================================================
23
// Include File Frame:
24
//=============================================================================
25
26
#ifndef PAGE_INCLUDED
27
#define PAGE_INCLUDED
28
29
30
//=============================================================================
31
// Used Types and Macros:
32
//=============================================================================
33
34
#ifndef VER_INCLUDED
35
#include "../base/ver.h"
36
#endif
37
38
#ifndef CHECK_INCLUDED
39
#include "../base/check.h"
40
#endif
41
42
43
//=============================================================================
44
// Basic Types and Macros for Memory Pages:
45
//=============================================================================
46
47
//-----------------------------------------------------------------------------
48
// Type of memory pages (pointer to start of VER_PAGESIZE bytes):
49
//-----------------------------------------------------------------------------
50
51
typedef
void
*page_t;
52
53
//-----------------------------------------------------------------------------
54
// Define null pointer:
55
//-----------------------------------------------------------------------------
56
57
#define PAGE_NULL (static_cast<page_t>(0))
58
59
//=============================================================================
60
// For Pages Used for Storing Objects of Only One Type:
61
//=============================================================================
62
63
//-----------------------------------------------------------------------------
64
// Size of a page in variables of a given type T:
65
//-----------------------------------------------------------------------------
66
67
#define PAGE_SIZE(TYPE) \
68
(VER_PAGESIZE/static_cast<int>(sizeof(TYPE)))
69
70
//=============================================================================
71
// For Pages Used for Storing Objects of Different Types:
72
//=============================================================================
73
74
//-----------------------------------------------------------------------------
75
// Union with maximal alignment requirements (unit for memory allocation):
76
//-----------------------------------------------------------------------------
77
78
union
page_u
{
79
int
i;
80
long
l;
81
double
d;
82
str_t
s;
83
void
*p;
84
VER_INT64
i64;
85
};
86
87
//-----------------------------------------------------------------------------
88
// Define pointer type:
89
//-----------------------------------------------------------------------------
90
91
typedef
union
page_u
*
page_u_t
;
92
93
//-----------------------------------------------------------------------------
94
// Define null pointer:
95
//-----------------------------------------------------------------------------
96
97
#define PAGE_U_NULL (static_cast<page_u_t>(0))
98
99
//-----------------------------------------------------------------------------
100
// Size of page units:
101
//-----------------------------------------------------------------------------
102
103
#define PAGE_UNIT_BYTES \
104
(static_cast<int>(sizeof(union page_u)))
105
106
//-----------------------------------------------------------------------------
107
// Size of a type in page units:
108
//-----------------------------------------------------------------------------
109
110
#define PAGE_UNITS(TYPE) \
111
((static_cast<int>(sizeof(TYPE))+PAGE_UNIT_BYTES-1) / PAGE_UNIT_BYTES)
112
113
//-----------------------------------------------------------------------------
114
// Size of memory page in units:
115
//-----------------------------------------------------------------------------
116
117
#define PAGE_SIZE_UNITS \
118
(VER_PAGESIZE / PAGE_UNIT_BYTES)
119
120
121
//=============================================================================
122
// Other macros:
123
//=============================================================================
124
125
//-----------------------------------------------------------------------------
126
// Translate number of pages to number of kilobytes:
127
//-----------------------------------------------------------------------------
128
129
#define PAGE_KB(NUM_PAGES) \
130
(static_cast<int>( \
131
(static_cast<long>(NUM_PAGES) * VER_PAGESIZE) / 1024))
132
133
//=============================================================================
134
// End of Include File:
135
//=============================================================================
136
137
#endif
138
str_t
const char * str_t
Definition:
str.h:41
VER_INT64
long long VER_INT64
Definition:
ver.h:818
page_u
Definition:
page.h:78
Generated by
1.8.10