sedna 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGES → CHANGES.rdoc} +9 -0
- data/{README → README.rdoc} +23 -25
- data/Rakefile +32 -9
- data/ext/{extconf.rb → sedna/extconf.rb} +33 -21
- data/ext/{sedna.c → sedna/sedna.c} +48 -40
- data/test/sedna_test.rb +9 -9
- data/vendor/sedna/AUTHORS +18 -0
- data/vendor/sedna/COPYRIGHT +90 -0
- data/vendor/sedna/LICENSE +202 -0
- data/vendor/sedna/Makefile.include +423 -0
- data/vendor/sedna/Makefile.platform +31 -0
- data/vendor/sedna/depend.sed +48 -0
- data/vendor/sedna/driver/c/Makefile +98 -0
- data/vendor/sedna/driver/c/libsedna.c +1998 -0
- data/vendor/sedna/driver/c/libsedna.h +199 -0
- data/vendor/sedna/driver/c/sednamt.def +21 -0
- data/vendor/sedna/driver/c/sp_defs.h +186 -0
- data/vendor/sedna/kernel/common/FastXptrHash.cpp +101 -0
- data/vendor/sedna/kernel/common/IntHash.h +314 -0
- data/vendor/sedna/kernel/common/IntList.h +224 -0
- data/vendor/sedna/kernel/common/Makefile +30 -0
- data/vendor/sedna/kernel/common/SSMMsg.cpp +459 -0
- data/vendor/sedna/kernel/common/SSMMsg.h +142 -0
- data/vendor/sedna/kernel/common/XptrHash.h +435 -0
- data/vendor/sedna/kernel/common/argtable.c +972 -0
- data/vendor/sedna/kernel/common/argtable.h +896 -0
- data/vendor/sedna/kernel/common/base.cpp +339 -0
- data/vendor/sedna/kernel/common/base.h +226 -0
- data/vendor/sedna/kernel/common/bit_set.cpp +157 -0
- data/vendor/sedna/kernel/common/bit_set.h +55 -0
- data/vendor/sedna/kernel/common/commutil.h +67 -0
- data/vendor/sedna/kernel/common/config.h +62 -0
- data/vendor/sedna/kernel/common/counted_ptr.h +74 -0
- data/vendor/sedna/kernel/common/errdbg/ErrorCodes.java +1056 -0
- data/vendor/sedna/kernel/common/errdbg/Makefile +34 -0
- data/vendor/sedna/kernel/common/errdbg/assert.c +133 -0
- data/vendor/sedna/kernel/common/errdbg/d_printf.c +150 -0
- data/vendor/sedna/kernel/common/errdbg/d_printf.h +91 -0
- data/vendor/sedna/kernel/common/errdbg/error.codes +1743 -0
- data/vendor/sedna/kernel/common/errdbg/error_codes.c +531 -0
- data/vendor/sedna/kernel/common/errdbg/error_codes.h +549 -0
- data/vendor/sedna/kernel/common/errdbg/error_codes_scm.scm +527 -0
- data/vendor/sedna/kernel/common/errdbg/event_log.c +956 -0
- data/vendor/sedna/kernel/common/errdbg/event_log.h +226 -0
- data/vendor/sedna/kernel/common/errdbg/exceptions.cpp +155 -0
- data/vendor/sedna/kernel/common/errdbg/exceptions.h +559 -0
- data/vendor/sedna/kernel/common/errdbg/gen_error_codes +0 -0
- data/vendor/sedna/kernel/common/errdbg/gen_error_codes.c +345 -0
- data/vendor/sedna/kernel/common/gmm.cpp +192 -0
- data/vendor/sedna/kernel/common/gmm.h +29 -0
- data/vendor/sedna/kernel/common/ipc_ops.cpp +435 -0
- data/vendor/sedna/kernel/common/ipc_ops.h +51 -0
- data/vendor/sedna/kernel/common/lfsGlobals.h +12 -0
- data/vendor/sedna/kernel/common/lm_base.h +90 -0
- data/vendor/sedna/kernel/common/mmgr/Makefile +11 -0
- data/vendor/sedna/kernel/common/mmgr/aset.c +1185 -0
- data/vendor/sedna/kernel/common/mmgr/mcxt.c +741 -0
- data/vendor/sedna/kernel/common/mmgr/memnodes.h +70 -0
- data/vendor/sedna/kernel/common/mmgr/memutils.h +145 -0
- data/vendor/sedna/kernel/common/mmgr/se_alloc.h +321 -0
- data/vendor/sedna/kernel/common/mmgr/track.c +214 -0
- data/vendor/sedna/kernel/common/pping.cpp +672 -0
- data/vendor/sedna/kernel/common/pping.h +119 -0
- data/vendor/sedna/kernel/common/rcv_test.cpp +273 -0
- data/vendor/sedna/kernel/common/rcv_test.h +19 -0
- data/vendor/sedna/kernel/common/sedna.c +128 -0
- data/vendor/sedna/kernel/common/sedna.h +49 -0
- data/vendor/sedna/kernel/common/sedna_ef.h +52 -0
- data/vendor/sedna/kernel/common/sm_vmm_data.h +144 -0
- data/vendor/sedna/kernel/common/sp.c +93 -0
- data/vendor/sedna/kernel/common/sp.h +36 -0
- data/vendor/sedna/kernel/common/st/Makefile +20 -0
- data/vendor/sedna/kernel/common/st/os_linux/stacktrace.c +213 -0
- data/vendor/sedna/kernel/common/st/os_nt/stacktrace.c +338 -0
- data/vendor/sedna/kernel/common/st/os_other/stacktrace.c +39 -0
- data/vendor/sedna/kernel/common/st/stacktrace.h +72 -0
- data/vendor/sedna/kernel/common/st/stacktrfmt.c +64 -0
- data/vendor/sedna/kernel/common/tr_debug.cpp +112 -0
- data/vendor/sedna/kernel/common/tr_debug.h +22 -0
- data/vendor/sedna/kernel/common/u/Makefile +14 -0
- data/vendor/sedna/kernel/common/u/u.c +268 -0
- data/vendor/sedna/kernel/common/u/u.h +715 -0
- data/vendor/sedna/kernel/common/u/uatomic.h +12 -0
- data/vendor/sedna/kernel/common/u/udl.h +31 -0
- data/vendor/sedna/kernel/common/u/uevent.c +406 -0
- data/vendor/sedna/kernel/common/u/uevent.h +71 -0
- data/vendor/sedna/kernel/common/u/ugnames.cpp +330 -0
- data/vendor/sedna/kernel/common/u/ugnames.h +134 -0
- data/vendor/sedna/kernel/common/u/uhash_map.h +77 -0
- data/vendor/sedna/kernel/common/u/uhdd.c +1018 -0
- data/vendor/sedna/kernel/common/u/uhdd.h +206 -0
- data/vendor/sedna/kernel/common/u/ummap.cpp +268 -0
- data/vendor/sedna/kernel/common/u/ummap.h +60 -0
- data/vendor/sedna/kernel/common/u/umutex.c +145 -0
- data/vendor/sedna/kernel/common/u/umutex.h +65 -0
- data/vendor/sedna/kernel/common/u/upipe.cpp +244 -0
- data/vendor/sedna/kernel/common/u/upipe.h +74 -0
- data/vendor/sedna/kernel/common/u/uprocess.c +767 -0
- data/vendor/sedna/kernel/common/u/uprocess.h +91 -0
- data/vendor/sedna/kernel/common/u/usafesync.h +41 -0
- data/vendor/sedna/kernel/common/u/usecurity.c +150 -0
- data/vendor/sedna/kernel/common/u/usecurity.h +55 -0
- data/vendor/sedna/kernel/common/u/usem.c +891 -0
- data/vendor/sedna/kernel/common/u/usem.h +83 -0
- data/vendor/sedna/kernel/common/u/ushm.c +222 -0
- data/vendor/sedna/kernel/common/u/ushm.h +46 -0
- data/vendor/sedna/kernel/common/u/usocket.c +541 -0
- data/vendor/sedna/kernel/common/u/usocket.h +118 -0
- data/vendor/sedna/kernel/common/u/usystem.c +57 -0
- data/vendor/sedna/kernel/common/u/usystem.h +46 -0
- data/vendor/sedna/kernel/common/u/uthread.c +259 -0
- data/vendor/sedna/kernel/common/u/uthread.h +95 -0
- data/vendor/sedna/kernel/common/u/utime.c +65 -0
- data/vendor/sedna/kernel/common/u/utime.h +40 -0
- data/vendor/sedna/kernel/common/u/uutils.c +142 -0
- data/vendor/sedna/kernel/common/u/uutils.h +65 -0
- data/vendor/sedna/kernel/common/ugc.cpp +156 -0
- data/vendor/sedna/kernel/common/ugc.h +15 -0
- data/vendor/sedna/kernel/common/utils.cpp +156 -0
- data/vendor/sedna/kernel/common/utils.h +133 -0
- data/vendor/sedna/kernel/common/version.c +16 -0
- data/vendor/sedna/kernel/common/version.h +21 -0
- data/vendor/sedna/kernel/common/wustructures.h +18 -0
- data/vendor/sedna/kernel/common/wutypes.h +34 -0
- data/vendor/sedna/kernel/common/xptr.cpp +17 -0
- data/vendor/sedna/kernel/common/xptr.h +211 -0
- data/vendor/sedna/ver +1 -0
- metadata +142 -14
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* File: ugc.h
|
3
|
+
* Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
|
4
|
+
*/
|
5
|
+
|
6
|
+
#ifndef _UGC_H
|
7
|
+
#define _UGC_H
|
8
|
+
|
9
|
+
void gov_ugc(bool background_off_from_background_on, int os_primitives_bound);
|
10
|
+
|
11
|
+
void sm_ugc(bool background_off_from_background_on, int db_id, int os_primitives_bound);
|
12
|
+
|
13
|
+
void cdb_ugc(int db_id, int os_primitives_bound);
|
14
|
+
|
15
|
+
#endif
|
@@ -0,0 +1,156 @@
|
|
1
|
+
/*
|
2
|
+
* File: utils.cpp
|
3
|
+
* Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include <math.h>
|
7
|
+
|
8
|
+
#include "common/sedna.h"
|
9
|
+
|
10
|
+
#include "common/utils.h"
|
11
|
+
#include "common/u/uutils.h"
|
12
|
+
#include "common/errdbg/d_printf.h"
|
13
|
+
#include "common/u/uhdd.h"
|
14
|
+
|
15
|
+
#ifndef _WIN32
|
16
|
+
#include <strings.h>
|
17
|
+
#endif
|
18
|
+
|
19
|
+
|
20
|
+
using namespace std;
|
21
|
+
|
22
|
+
string int2string(__int64 value)
|
23
|
+
{
|
24
|
+
char buf[20];
|
25
|
+
u_i64toa(value, buf, 10);
|
26
|
+
return string(buf);
|
27
|
+
}
|
28
|
+
|
29
|
+
string to_string(u_timeb t)
|
30
|
+
{
|
31
|
+
char buf[80];
|
32
|
+
sprintf(buf, "%d.%03ld", (int)t.time, t.millitm);
|
33
|
+
return string(buf);
|
34
|
+
}
|
35
|
+
|
36
|
+
double power(double a, double b)
|
37
|
+
{
|
38
|
+
return exp(b * log(a));
|
39
|
+
}
|
40
|
+
|
41
|
+
#ifndef _WIN32
|
42
|
+
int _isnan(double x)
|
43
|
+
{
|
44
|
+
return isnan(x);
|
45
|
+
}
|
46
|
+
#endif
|
47
|
+
|
48
|
+
void elim_disturb(void *base, size_t num, size_t width, compare_fun compare)
|
49
|
+
{
|
50
|
+
int pos = -1;
|
51
|
+
bool growing = true;
|
52
|
+
int i = 0;
|
53
|
+
for (i = 0; i < (int)num - 1; i++)
|
54
|
+
if (compare((char*)base + i * width, (char*)base + (i + 1) * width) > 0)
|
55
|
+
{
|
56
|
+
if (i + 2 < (int)num)
|
57
|
+
{
|
58
|
+
if (compare((char*)base + i * width, (char*)base + (i + 2) * width) > 0)
|
59
|
+
pos = i;
|
60
|
+
else { pos = i + 1; growing = false; }
|
61
|
+
}
|
62
|
+
else { pos = i + 1; growing = false; }
|
63
|
+
|
64
|
+
break;
|
65
|
+
}
|
66
|
+
|
67
|
+
if (pos == -1) return;
|
68
|
+
|
69
|
+
char * tmp = se_new char[width];
|
70
|
+
|
71
|
+
if (growing)
|
72
|
+
{
|
73
|
+
for (i = pos; i < (int)num - 1; i++)
|
74
|
+
if (compare((char*)base + i * width, (char*)base + (i + 1) * width) > 0)
|
75
|
+
{
|
76
|
+
/* swap*/
|
77
|
+
memcpy(tmp, (char*)base + i * width, width);
|
78
|
+
memcpy((char*)base + i * width, (char*)base + (i + 1) * width, width);
|
79
|
+
memcpy((char*)base + (i + 1) * width, tmp, width);
|
80
|
+
}
|
81
|
+
else break;
|
82
|
+
}
|
83
|
+
else
|
84
|
+
{
|
85
|
+
for (i = pos; i > 0; i--)
|
86
|
+
if (compare((char*)base + (i - 1) * width, (char*)base + i * width) > 0)
|
87
|
+
{
|
88
|
+
/* swap*/
|
89
|
+
memcpy(tmp, (char*)base + i * width, width);
|
90
|
+
memcpy((char*)base + i * width, (char*)base + (i - 1) * width, width);
|
91
|
+
memcpy((char*)base + (i - 1) * width, tmp, width);
|
92
|
+
}
|
93
|
+
else break;
|
94
|
+
}
|
95
|
+
|
96
|
+
delete [] tmp;
|
97
|
+
}
|
98
|
+
|
99
|
+
void elim_disturb2(void *base, size_t num, size_t width, compare_fun compare)
|
100
|
+
{
|
101
|
+
int lb = 0, rb = 0, med = 0;
|
102
|
+
int pos = 0, cmp = 0;
|
103
|
+
|
104
|
+
lb = 1;
|
105
|
+
rb = num;
|
106
|
+
|
107
|
+
if (num == 1) return;
|
108
|
+
|
109
|
+
while (true)
|
110
|
+
{
|
111
|
+
if (rb - lb == 1)
|
112
|
+
{
|
113
|
+
if (compare(base, (char*)base + lb * width) <= 0) pos = lb;
|
114
|
+
else
|
115
|
+
{
|
116
|
+
if (compare(base, (char*)base + rb * width) <= 0) pos = rb;
|
117
|
+
else pos = rb + 1;
|
118
|
+
}
|
119
|
+
break;
|
120
|
+
}
|
121
|
+
|
122
|
+
med = (rb + lb) / 2;
|
123
|
+
cmp = compare(base, (char*)base + med * width);
|
124
|
+
|
125
|
+
if (cmp < 0) rb = med;
|
126
|
+
else
|
127
|
+
if (cmp > 0) lb = med;
|
128
|
+
else
|
129
|
+
{
|
130
|
+
pos = med;
|
131
|
+
break;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
if (pos == 1) return;
|
136
|
+
|
137
|
+
/* swap*/
|
138
|
+
char * tmp = se_new char[width];
|
139
|
+
|
140
|
+
memcpy(tmp, base, width);
|
141
|
+
memmove(base, (char*)base + width, width * (pos - 1));
|
142
|
+
memcpy((char*)base + width * (pos - 1), tmp, width);
|
143
|
+
|
144
|
+
delete [] tmp;
|
145
|
+
}
|
146
|
+
|
147
|
+
std::string trim(const std::string& str)
|
148
|
+
{
|
149
|
+
std::string::size_type start = str.find_first_not_of(" \n\t\r");
|
150
|
+
std::string::size_type end = str.find_last_not_of(" \n\t\r");
|
151
|
+
if (start == std::string::npos || end == std::string::npos)
|
152
|
+
return "";
|
153
|
+
return str.substr(start, end - start + 1);
|
154
|
+
}
|
155
|
+
|
156
|
+
|
@@ -0,0 +1,133 @@
|
|
1
|
+
/*
|
2
|
+
* File: utils.h
|
3
|
+
* Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
#ifndef __UTILS_H
|
8
|
+
#define __UTILS_H
|
9
|
+
|
10
|
+
#include <string>
|
11
|
+
#include <vector>
|
12
|
+
|
13
|
+
#include "common/sedna.h"
|
14
|
+
|
15
|
+
|
16
|
+
#define MBS2PAGES(s) ((int64_t) (s) * (int64_t)0x100000 / (int64_t) PAGE_SIZE)
|
17
|
+
#define PAGES2MBS(s) ((int64_t) (s) * (int64_t)PAGE_SIZE / (int64_t) 0x100000)
|
18
|
+
|
19
|
+
|
20
|
+
std::string int2string(__int64 value);
|
21
|
+
|
22
|
+
/* datatypes and functions to with time (time in sec + time in millisec)*/
|
23
|
+
#ifndef _WIN32
|
24
|
+
struct _timeb
|
25
|
+
{
|
26
|
+
long time;
|
27
|
+
long millitm;
|
28
|
+
int timezone;
|
29
|
+
int dstflag;
|
30
|
+
};
|
31
|
+
#endif
|
32
|
+
|
33
|
+
typedef _timeb u_timeb;
|
34
|
+
|
35
|
+
#ifdef _WIN32
|
36
|
+
inline void u_ftime(u_timeb *t) {_ftime((t)); }
|
37
|
+
#else
|
38
|
+
inline void u_ftime(u_timeb *t)
|
39
|
+
{
|
40
|
+
struct timeval tv;
|
41
|
+
struct timezone tz;
|
42
|
+
/* ftime() is obsolete in FreeBSD 6.2 and higher */
|
43
|
+
gettimeofday(&tv, &tz);
|
44
|
+
t->time = tv.tv_sec;
|
45
|
+
t->millitm = tv.tv_usec/1000;
|
46
|
+
t->dstflag = tz.tz_dsttime;
|
47
|
+
t->timezone = tz.tz_minuteswest;
|
48
|
+
}
|
49
|
+
#endif /* _WIN32 */
|
50
|
+
|
51
|
+
|
52
|
+
inline void u_timeb_init(u_timeb *t)
|
53
|
+
{
|
54
|
+
t->time = 0;
|
55
|
+
t->millitm = 0;
|
56
|
+
t->timezone = 0;
|
57
|
+
t->dstflag = 0;
|
58
|
+
}
|
59
|
+
|
60
|
+
inline u_timeb operator- (const u_timeb& t1, const u_timeb& t2)
|
61
|
+
{
|
62
|
+
u_timeb t;
|
63
|
+
if (t2.millitm > t1.millitm) {
|
64
|
+
t.time = t1.time - t2.time - 1;
|
65
|
+
t.millitm = 1000 - t2.millitm + t1.millitm;
|
66
|
+
}
|
67
|
+
else {
|
68
|
+
t.time = t1.time - t2.time;
|
69
|
+
t.millitm = t1.millitm - t2.millitm;
|
70
|
+
}
|
71
|
+
t.dstflag = t1.dstflag;
|
72
|
+
t.timezone = t1.timezone;
|
73
|
+
return t;
|
74
|
+
}
|
75
|
+
|
76
|
+
inline u_timeb operator+ (const u_timeb& t1, const u_timeb& t2)
|
77
|
+
{
|
78
|
+
u_timeb t;
|
79
|
+
t.millitm = t1.millitm + t2.millitm;
|
80
|
+
t.time = t1.time + t2.time;
|
81
|
+
if(t.millitm > 1000) { t.time++; t.millitm-=1000; }
|
82
|
+
t.dstflag = t1.dstflag;
|
83
|
+
t.timezone = t1.timezone;
|
84
|
+
return t;
|
85
|
+
}
|
86
|
+
|
87
|
+
std::string to_string(u_timeb t);
|
88
|
+
|
89
|
+
double power(double a, double b);
|
90
|
+
|
91
|
+
#ifndef _WIN32
|
92
|
+
int _isnan(double x);
|
93
|
+
#endif
|
94
|
+
|
95
|
+
template<class T>
|
96
|
+
std::vector<T> vector_concat(const std::vector<T>& v1, const std::vector<T> &v2)
|
97
|
+
{
|
98
|
+
std::vector<T> res;
|
99
|
+
|
100
|
+
res.reserve(v1.size() + v2.size());
|
101
|
+
|
102
|
+
typename std::vector<T>::const_iterator it;
|
103
|
+
for (it = v1.begin(); it != v1.end(); it++) res.push_back(*it);
|
104
|
+
for (it = v2.begin(); it != v2.end(); it++) res.push_back(*it);
|
105
|
+
|
106
|
+
return res;
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
/* function is used for eliminating disturbance from sorted array*/
|
111
|
+
/* parameters are like parameters for qsort*/
|
112
|
+
#ifdef _WIN32
|
113
|
+
typedef int (__cdecl *compare_fun)(const void* elem1, const void* elem2);
|
114
|
+
#else
|
115
|
+
typedef int (*compare_fun)(const void* elem1, const void* elem2);
|
116
|
+
#endif
|
117
|
+
void elim_disturb(void *base, size_t num, size_t width, compare_fun compare);
|
118
|
+
void elim_disturb2(void *base, size_t num, size_t width, compare_fun compare);
|
119
|
+
|
120
|
+
std::string trim(const std::string& str);
|
121
|
+
|
122
|
+
/// Intented to be used with strcmp and memcmp
|
123
|
+
/// res = memcmp(ptr1, ptr2)
|
124
|
+
/// return sign(res)
|
125
|
+
/// In such a way we will guarantee -1 and 1 values.
|
126
|
+
inline int sign(int i)
|
127
|
+
{
|
128
|
+
if (i > 0) return 1;
|
129
|
+
if (i < 0) return -1;
|
130
|
+
return i;
|
131
|
+
}
|
132
|
+
|
133
|
+
#endif /* __UTILS_H */
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/*
|
2
|
+
* File: version.c
|
3
|
+
* Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
#include "common/sedna.h"
|
8
|
+
|
9
|
+
void print_version_and_copyright(const char *prog_name)
|
10
|
+
{
|
11
|
+
const char* ver = SEDNA_VERSION;
|
12
|
+
const char* build = SEDNA_BUILD;
|
13
|
+
fprintf(stdout, "%s Version %s.%s\n", prog_name, ver, build);
|
14
|
+
fprintf(stdout, "Copyright (C) 2004-2009 ISP RAS and others. All rights reserved.\n");
|
15
|
+
fprintf(stdout, "See file COPYRIGHT provided with the distribution.\n");
|
16
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/*
|
2
|
+
* File: version.h
|
3
|
+
* Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
#ifndef _VERSION_H
|
8
|
+
#define _VERSION_H
|
9
|
+
|
10
|
+
#ifdef __cplusplus
|
11
|
+
extern "C" {
|
12
|
+
#endif
|
13
|
+
|
14
|
+
void print_version_and_copyright(const char *prog_name);
|
15
|
+
|
16
|
+
#ifdef __cplusplus
|
17
|
+
}
|
18
|
+
#endif
|
19
|
+
|
20
|
+
#endif
|
21
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#if (_MSC_VER > 1000)
|
2
|
+
#pragma once
|
3
|
+
#endif
|
4
|
+
|
5
|
+
#ifndef WUSTRUCTURES_INCLUDED
|
6
|
+
#define WUSTRUCTURES_INCLUDED
|
7
|
+
|
8
|
+
#include "wutypes.h"
|
9
|
+
|
10
|
+
#define VE_VERSIONS_COUNT 4
|
11
|
+
|
12
|
+
struct VersionsHeader
|
13
|
+
{
|
14
|
+
XPTR xptr[VE_VERSIONS_COUNT];
|
15
|
+
TIMESTAMP creatorTs[VE_VERSIONS_COUNT];
|
16
|
+
};
|
17
|
+
|
18
|
+
#endif
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#include <stdint.h>
|
2
|
+
|
3
|
+
#ifdef _MSC_VER
|
4
|
+
#pragma once
|
5
|
+
#endif
|
6
|
+
|
7
|
+
#ifndef WUTYPES_INCLUDED
|
8
|
+
#define WUTYPES_INCLUDED
|
9
|
+
|
10
|
+
typedef uint64_t XPTR, LXPTR;
|
11
|
+
typedef uint64_t TIMESTAMP;
|
12
|
+
typedef void *TICKET;
|
13
|
+
|
14
|
+
|
15
|
+
/* [TIMESTAMP_MIN, TIMESTAMP_MAX] is the range of valid timestamps; values outside this
|
16
|
+
range have the special interpretation. One of the special timestamp values is
|
17
|
+
INVALID_TIMESTAMP. Other "special" values may have a module-specific meaning
|
18
|
+
or may be used internally for some purposes. */
|
19
|
+
#define TIMESTAMP_MIN UINT64_C(0x0000000000010000)
|
20
|
+
#define TIMESTAMP_MAX UINT64_C(0xFFFFFFFFFFFF0000)
|
21
|
+
|
22
|
+
inline
|
23
|
+
static
|
24
|
+
bool IsValidTimestamp(TIMESTAMP ts)
|
25
|
+
{
|
26
|
+
return ts>=TIMESTAMP_MIN && ts<=TIMESTAMP_MAX;
|
27
|
+
}
|
28
|
+
|
29
|
+
/* INVALID_TIMESTAMP is the greatest possible value for the variable of TIMESTAMP type */
|
30
|
+
#define INVALID_TIMESTAMP UINT64_C(0xFFFFFFFFFFFFFFFF)
|
31
|
+
|
32
|
+
#define INVALID_TICKET NULL
|
33
|
+
|
34
|
+
#endif
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/*
|
2
|
+
* File: xptr.cpp
|
3
|
+
* Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
#include "common/sedna.h"
|
8
|
+
|
9
|
+
#include "common/xptr.h"
|
10
|
+
#include "common/errdbg/d_printf.h"
|
11
|
+
|
12
|
+
void xptr::print() const
|
13
|
+
{
|
14
|
+
d_printf3("(layer, addr) = (%d, 0x%x)\n", (int)layer, (unsigned int)addr);
|
15
|
+
}
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,211 @@
|
|
1
|
+
/*
|
2
|
+
* File: xptr.h
|
3
|
+
* Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
|
4
|
+
*/
|
5
|
+
|
6
|
+
|
7
|
+
#ifndef __XPTR_H
|
8
|
+
#define __XPTR_H
|
9
|
+
|
10
|
+
#include "common/sedna.h"
|
11
|
+
#include "common/base.h"
|
12
|
+
|
13
|
+
#ifndef NULL
|
14
|
+
#define NULL_WAS_NOT_DEFINED
|
15
|
+
#define NULL 0
|
16
|
+
#endif
|
17
|
+
|
18
|
+
// File incapsulates xptr notion. It has been written for 32-bit architecture
|
19
|
+
// but with the goal to be easyly ported to 64-bit architecture
|
20
|
+
|
21
|
+
#define TMP_LAYER_STARTS_WITH 0x40000000
|
22
|
+
#define INVALID_LAYER 0xFFFFFFFF
|
23
|
+
|
24
|
+
// user this macros when you want obtain pointer in terms of process' virtual
|
25
|
+
// address space
|
26
|
+
#define XADDR(p) ((p).addr)
|
27
|
+
#define CONSTRUCT_XPTR(l, a) (xptr(l, a))
|
28
|
+
#define BLOCKXPTR(a) cxptr(a.layer,(void*)((__uint32)((a).addr) & PAGE_BIT_MASK))
|
29
|
+
|
30
|
+
#define ADDR2XPTR(a) cxptr(*(t_layer*)(((__uint32)(a)) & PAGE_BIT_MASK), \
|
31
|
+
(void*)(*(__uint32*)((((__uint32)(a)) & PAGE_BIT_MASK) + sizeof(t_layer)) + (((__uint32)(a)) & PAGE_REVERSE_BIT_MASK)))
|
32
|
+
#define TEST_XPTR(p) (*(t_layer*)((__uint32)((p).addr) & PAGE_BIT_MASK) == (p).layer)
|
33
|
+
//#define TEST_XPTR(p) ((* (xptr *) XADDR(p)) == p)
|
34
|
+
#define ALIGN_ADDR(a) ((void*)((__uint32)(a) & PAGE_BIT_MASK))
|
35
|
+
#define LAYERS_EQUAL(a, p) (*(t_layer*)((__uint32)(a) & PAGE_BIT_MASK) == ((p).layer))
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
#define IS_TMP_BLOCK(p) ((p).layer >= TMP_LAYER_STARTS_WITH)
|
40
|
+
#define IS_DATA_BLOCK(p) ((p).layer < TMP_LAYER_STARTS_WITH)
|
41
|
+
|
42
|
+
#define IS_TMP_BLOCK_LP(ptr) (((vmm_sm_blk_hdr*)(ptr))->p.layer >= TMP_LAYER_STARTS_WITH)
|
43
|
+
#define IS_DATA_BLOCK_LP(ptr) (((vmm_sm_blk_hdr*)(ptr))->p.layer < TMP_LAYER_STARTS_WITH)
|
44
|
+
|
45
|
+
//struct vmm_sm_blk_hdr;
|
46
|
+
|
47
|
+
/* type for layer */
|
48
|
+
typedef int t_layer;
|
49
|
+
|
50
|
+
union uint64_lh_t { struct uint64_lh { uint32_t l; uint32_t h; } lh; uint64_t v; };
|
51
|
+
|
52
|
+
/* Struct for Extended Virtual Address Space Pointer */
|
53
|
+
struct xptr
|
54
|
+
{
|
55
|
+
t_layer layer;
|
56
|
+
void * addr;
|
57
|
+
|
58
|
+
inline uint64_t to_logical_int() const {
|
59
|
+
union uint64_lh_t v = * (uint64_lh_t *) this;
|
60
|
+
#ifndef BIG_ENDIAN_ORDER
|
61
|
+
uint32_t x = v.lh.l;
|
62
|
+
v.lh.l = v.lh.h;
|
63
|
+
v.lh.h = x;
|
64
|
+
#endif
|
65
|
+
return v.v;
|
66
|
+
};
|
67
|
+
|
68
|
+
inline uint64_t to_uint64() const { return * (uint64_t *) this; };
|
69
|
+
inline void from_uint64(const uint64_t x) const { (* (uint64_t *) this) = x; };
|
70
|
+
|
71
|
+
xptr &operator +=(int n)
|
72
|
+
{
|
73
|
+
addr = (char*)(addr) + n;
|
74
|
+
|
75
|
+
if ((unsigned int)addr >= LAYER_ADDRESS_SPACE_BOUNDARY_INT)
|
76
|
+
{
|
77
|
+
layer++;
|
78
|
+
addr = (void*)((int)addr - LAYER_ADDRESS_SPACE_SIZE);
|
79
|
+
}
|
80
|
+
|
81
|
+
return *this;
|
82
|
+
}
|
83
|
+
xptr &operator -=(int n)
|
84
|
+
{
|
85
|
+
addr = (char*)(addr) - n;
|
86
|
+
|
87
|
+
if ((unsigned int)addr < LAYER_ADDRESS_SPACE_START_ADDR_INT)
|
88
|
+
{
|
89
|
+
layer--;
|
90
|
+
addr = (void*)((int)addr + LAYER_ADDRESS_SPACE_SIZE);
|
91
|
+
}
|
92
|
+
|
93
|
+
return *this;
|
94
|
+
}
|
95
|
+
|
96
|
+
void print() const;
|
97
|
+
void clear() { layer = 0; addr = NULL; }
|
98
|
+
};
|
99
|
+
|
100
|
+
inline xptr uint64_to_xptr(const uint64_t x) {
|
101
|
+
xptr p;
|
102
|
+
p.from_uint64(x);
|
103
|
+
return p;
|
104
|
+
};
|
105
|
+
|
106
|
+
inline xptr cxptr(t_layer l, void * a) {
|
107
|
+
xptr p = {l, a};
|
108
|
+
return p;
|
109
|
+
}
|
110
|
+
|
111
|
+
inline xptr operator+(const xptr &p, int n)
|
112
|
+
{
|
113
|
+
xptr new_p(p);
|
114
|
+
new_p.addr = (char*)(p.addr) + n;
|
115
|
+
|
116
|
+
if ((unsigned int)(new_p.addr) >= LAYER_ADDRESS_SPACE_BOUNDARY_INT)
|
117
|
+
{
|
118
|
+
new_p.layer++;
|
119
|
+
new_p.addr = (void*)((int)(new_p.addr) - LAYER_ADDRESS_SPACE_SIZE);
|
120
|
+
}
|
121
|
+
|
122
|
+
return new_p;
|
123
|
+
}
|
124
|
+
|
125
|
+
inline xptr operator-(const xptr &p, int n)
|
126
|
+
{
|
127
|
+
xptr new_p(p);
|
128
|
+
new_p.addr = (char*)(p.addr) - n;
|
129
|
+
|
130
|
+
if ((unsigned int)(new_p.addr) < LAYER_ADDRESS_SPACE_START_ADDR_INT)
|
131
|
+
{
|
132
|
+
new_p.layer--;
|
133
|
+
new_p.addr = (void*)((int)(new_p.addr) + LAYER_ADDRESS_SPACE_SIZE);
|
134
|
+
}
|
135
|
+
|
136
|
+
return new_p;
|
137
|
+
}
|
138
|
+
|
139
|
+
inline __uint32 operator-(const xptr &p1, const xptr &p2)
|
140
|
+
{
|
141
|
+
if (p1.layer != p2.layer) throw USER_EXCEPTION2(SE1003, "Bad paramters in xptr operator-(const xptr &p1, const xptr &p2)");
|
142
|
+
return (__uint32)(p1.addr) - (__uint32)(p2.addr);
|
143
|
+
}
|
144
|
+
|
145
|
+
inline bool operator==(const xptr &p1, const xptr &p2)
|
146
|
+
{
|
147
|
+
return p1.addr == p2.addr && (p1.addr == NULL || p1.layer == p2.layer);
|
148
|
+
}
|
149
|
+
|
150
|
+
inline bool operator!=(const xptr &p1, const xptr &p2)
|
151
|
+
{
|
152
|
+
return !(p1 == p2);
|
153
|
+
}
|
154
|
+
|
155
|
+
inline bool operator<(const xptr &p1, const xptr &p2)
|
156
|
+
{
|
157
|
+
return (p1.layer != p2.layer ? p1.layer < p2.layer : (__uint32)(p1.addr) < (__uint32)(p2.addr));
|
158
|
+
}
|
159
|
+
|
160
|
+
inline xptr block_xptr(const xptr &p)
|
161
|
+
{
|
162
|
+
return cxptr(p.layer, (void*)((__uint32)(p.addr) & PAGE_BIT_MASK));
|
163
|
+
}
|
164
|
+
|
165
|
+
inline xptr addr2xptr(const void * p)
|
166
|
+
{
|
167
|
+
U_ASSERT(((xptr *) (((uint32_t) p ) & PAGE_BIT_MASK))->addr == (void *) (((uint32_t) p ) & PAGE_BIT_MASK));
|
168
|
+
return cxptr(* (t_layer*) (((uint32_t) p) & PAGE_BIT_MASK), const_cast<void *>(p));
|
169
|
+
}
|
170
|
+
|
171
|
+
inline void shed_state(xptr &p)
|
172
|
+
{
|
173
|
+
p.layer = 0;
|
174
|
+
p.addr = NULL;
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
inline int xptr_compare(const xptr& p1, const xptr& p2)
|
179
|
+
{
|
180
|
+
if (p1.addr == NULL && p2.addr == NULL) return 0;
|
181
|
+
if (p1.addr == NULL) return 1;
|
182
|
+
if (p2.addr == NULL) return -1;
|
183
|
+
|
184
|
+
if(p1.layer != p2.layer)
|
185
|
+
{
|
186
|
+
return p1.layer < p2.layer ? -1 : 1;
|
187
|
+
}
|
188
|
+
else
|
189
|
+
{
|
190
|
+
if((__uint32)(p1.addr) < (__uint32)(p2.addr)) return -1;
|
191
|
+
else if((__uint32)(p1.addr) == (__uint32)(p2.addr)) return 0;
|
192
|
+
return 1;
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
inline bool same_block(const xptr& a, const xptr& b) {
|
197
|
+
return (BLOCKXPTR(a) == BLOCKXPTR(b));
|
198
|
+
}
|
199
|
+
|
200
|
+
inline bool isTmpBlock(const xptr &p) { return p.layer >= TMP_LAYER_STARTS_WITH; };
|
201
|
+
|
202
|
+
/* NULL for xpointers */
|
203
|
+
const xptr XNULL = {};
|
204
|
+
|
205
|
+
#ifdef NULL_WAS_NOT_DEFINED
|
206
|
+
#undef NULL
|
207
|
+
#endif
|
208
|
+
|
209
|
+
#endif
|
210
|
+
|
211
|
+
|