sedna 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/{CHANGES → CHANGES.rdoc} +9 -0
  2. data/{README → README.rdoc} +23 -25
  3. data/Rakefile +32 -9
  4. data/ext/{extconf.rb → sedna/extconf.rb} +33 -21
  5. data/ext/{sedna.c → sedna/sedna.c} +48 -40
  6. data/test/sedna_test.rb +9 -9
  7. data/vendor/sedna/AUTHORS +18 -0
  8. data/vendor/sedna/COPYRIGHT +90 -0
  9. data/vendor/sedna/LICENSE +202 -0
  10. data/vendor/sedna/Makefile.include +423 -0
  11. data/vendor/sedna/Makefile.platform +31 -0
  12. data/vendor/sedna/depend.sed +48 -0
  13. data/vendor/sedna/driver/c/Makefile +98 -0
  14. data/vendor/sedna/driver/c/libsedna.c +1998 -0
  15. data/vendor/sedna/driver/c/libsedna.h +199 -0
  16. data/vendor/sedna/driver/c/sednamt.def +21 -0
  17. data/vendor/sedna/driver/c/sp_defs.h +186 -0
  18. data/vendor/sedna/kernel/common/FastXptrHash.cpp +101 -0
  19. data/vendor/sedna/kernel/common/IntHash.h +314 -0
  20. data/vendor/sedna/kernel/common/IntList.h +224 -0
  21. data/vendor/sedna/kernel/common/Makefile +30 -0
  22. data/vendor/sedna/kernel/common/SSMMsg.cpp +459 -0
  23. data/vendor/sedna/kernel/common/SSMMsg.h +142 -0
  24. data/vendor/sedna/kernel/common/XptrHash.h +435 -0
  25. data/vendor/sedna/kernel/common/argtable.c +972 -0
  26. data/vendor/sedna/kernel/common/argtable.h +896 -0
  27. data/vendor/sedna/kernel/common/base.cpp +339 -0
  28. data/vendor/sedna/kernel/common/base.h +226 -0
  29. data/vendor/sedna/kernel/common/bit_set.cpp +157 -0
  30. data/vendor/sedna/kernel/common/bit_set.h +55 -0
  31. data/vendor/sedna/kernel/common/commutil.h +67 -0
  32. data/vendor/sedna/kernel/common/config.h +62 -0
  33. data/vendor/sedna/kernel/common/counted_ptr.h +74 -0
  34. data/vendor/sedna/kernel/common/errdbg/ErrorCodes.java +1056 -0
  35. data/vendor/sedna/kernel/common/errdbg/Makefile +34 -0
  36. data/vendor/sedna/kernel/common/errdbg/assert.c +133 -0
  37. data/vendor/sedna/kernel/common/errdbg/d_printf.c +150 -0
  38. data/vendor/sedna/kernel/common/errdbg/d_printf.h +91 -0
  39. data/vendor/sedna/kernel/common/errdbg/error.codes +1743 -0
  40. data/vendor/sedna/kernel/common/errdbg/error_codes.c +531 -0
  41. data/vendor/sedna/kernel/common/errdbg/error_codes.h +549 -0
  42. data/vendor/sedna/kernel/common/errdbg/error_codes_scm.scm +527 -0
  43. data/vendor/sedna/kernel/common/errdbg/event_log.c +956 -0
  44. data/vendor/sedna/kernel/common/errdbg/event_log.h +226 -0
  45. data/vendor/sedna/kernel/common/errdbg/exceptions.cpp +155 -0
  46. data/vendor/sedna/kernel/common/errdbg/exceptions.h +559 -0
  47. data/vendor/sedna/kernel/common/errdbg/gen_error_codes +0 -0
  48. data/vendor/sedna/kernel/common/errdbg/gen_error_codes.c +345 -0
  49. data/vendor/sedna/kernel/common/gmm.cpp +192 -0
  50. data/vendor/sedna/kernel/common/gmm.h +29 -0
  51. data/vendor/sedna/kernel/common/ipc_ops.cpp +435 -0
  52. data/vendor/sedna/kernel/common/ipc_ops.h +51 -0
  53. data/vendor/sedna/kernel/common/lfsGlobals.h +12 -0
  54. data/vendor/sedna/kernel/common/lm_base.h +90 -0
  55. data/vendor/sedna/kernel/common/mmgr/Makefile +11 -0
  56. data/vendor/sedna/kernel/common/mmgr/aset.c +1185 -0
  57. data/vendor/sedna/kernel/common/mmgr/mcxt.c +741 -0
  58. data/vendor/sedna/kernel/common/mmgr/memnodes.h +70 -0
  59. data/vendor/sedna/kernel/common/mmgr/memutils.h +145 -0
  60. data/vendor/sedna/kernel/common/mmgr/se_alloc.h +321 -0
  61. data/vendor/sedna/kernel/common/mmgr/track.c +214 -0
  62. data/vendor/sedna/kernel/common/pping.cpp +672 -0
  63. data/vendor/sedna/kernel/common/pping.h +119 -0
  64. data/vendor/sedna/kernel/common/rcv_test.cpp +273 -0
  65. data/vendor/sedna/kernel/common/rcv_test.h +19 -0
  66. data/vendor/sedna/kernel/common/sedna.c +128 -0
  67. data/vendor/sedna/kernel/common/sedna.h +49 -0
  68. data/vendor/sedna/kernel/common/sedna_ef.h +52 -0
  69. data/vendor/sedna/kernel/common/sm_vmm_data.h +144 -0
  70. data/vendor/sedna/kernel/common/sp.c +93 -0
  71. data/vendor/sedna/kernel/common/sp.h +36 -0
  72. data/vendor/sedna/kernel/common/st/Makefile +20 -0
  73. data/vendor/sedna/kernel/common/st/os_linux/stacktrace.c +213 -0
  74. data/vendor/sedna/kernel/common/st/os_nt/stacktrace.c +338 -0
  75. data/vendor/sedna/kernel/common/st/os_other/stacktrace.c +39 -0
  76. data/vendor/sedna/kernel/common/st/stacktrace.h +72 -0
  77. data/vendor/sedna/kernel/common/st/stacktrfmt.c +64 -0
  78. data/vendor/sedna/kernel/common/tr_debug.cpp +112 -0
  79. data/vendor/sedna/kernel/common/tr_debug.h +22 -0
  80. data/vendor/sedna/kernel/common/u/Makefile +14 -0
  81. data/vendor/sedna/kernel/common/u/u.c +268 -0
  82. data/vendor/sedna/kernel/common/u/u.h +715 -0
  83. data/vendor/sedna/kernel/common/u/uatomic.h +12 -0
  84. data/vendor/sedna/kernel/common/u/udl.h +31 -0
  85. data/vendor/sedna/kernel/common/u/uevent.c +406 -0
  86. data/vendor/sedna/kernel/common/u/uevent.h +71 -0
  87. data/vendor/sedna/kernel/common/u/ugnames.cpp +330 -0
  88. data/vendor/sedna/kernel/common/u/ugnames.h +134 -0
  89. data/vendor/sedna/kernel/common/u/uhash_map.h +77 -0
  90. data/vendor/sedna/kernel/common/u/uhdd.c +1018 -0
  91. data/vendor/sedna/kernel/common/u/uhdd.h +206 -0
  92. data/vendor/sedna/kernel/common/u/ummap.cpp +268 -0
  93. data/vendor/sedna/kernel/common/u/ummap.h +60 -0
  94. data/vendor/sedna/kernel/common/u/umutex.c +145 -0
  95. data/vendor/sedna/kernel/common/u/umutex.h +65 -0
  96. data/vendor/sedna/kernel/common/u/upipe.cpp +244 -0
  97. data/vendor/sedna/kernel/common/u/upipe.h +74 -0
  98. data/vendor/sedna/kernel/common/u/uprocess.c +767 -0
  99. data/vendor/sedna/kernel/common/u/uprocess.h +91 -0
  100. data/vendor/sedna/kernel/common/u/usafesync.h +41 -0
  101. data/vendor/sedna/kernel/common/u/usecurity.c +150 -0
  102. data/vendor/sedna/kernel/common/u/usecurity.h +55 -0
  103. data/vendor/sedna/kernel/common/u/usem.c +891 -0
  104. data/vendor/sedna/kernel/common/u/usem.h +83 -0
  105. data/vendor/sedna/kernel/common/u/ushm.c +222 -0
  106. data/vendor/sedna/kernel/common/u/ushm.h +46 -0
  107. data/vendor/sedna/kernel/common/u/usocket.c +541 -0
  108. data/vendor/sedna/kernel/common/u/usocket.h +118 -0
  109. data/vendor/sedna/kernel/common/u/usystem.c +57 -0
  110. data/vendor/sedna/kernel/common/u/usystem.h +46 -0
  111. data/vendor/sedna/kernel/common/u/uthread.c +259 -0
  112. data/vendor/sedna/kernel/common/u/uthread.h +95 -0
  113. data/vendor/sedna/kernel/common/u/utime.c +65 -0
  114. data/vendor/sedna/kernel/common/u/utime.h +40 -0
  115. data/vendor/sedna/kernel/common/u/uutils.c +142 -0
  116. data/vendor/sedna/kernel/common/u/uutils.h +65 -0
  117. data/vendor/sedna/kernel/common/ugc.cpp +156 -0
  118. data/vendor/sedna/kernel/common/ugc.h +15 -0
  119. data/vendor/sedna/kernel/common/utils.cpp +156 -0
  120. data/vendor/sedna/kernel/common/utils.h +133 -0
  121. data/vendor/sedna/kernel/common/version.c +16 -0
  122. data/vendor/sedna/kernel/common/version.h +21 -0
  123. data/vendor/sedna/kernel/common/wustructures.h +18 -0
  124. data/vendor/sedna/kernel/common/wutypes.h +34 -0
  125. data/vendor/sedna/kernel/common/xptr.cpp +17 -0
  126. data/vendor/sedna/kernel/common/xptr.h +211 -0
  127. data/vendor/sedna/ver +1 -0
  128. metadata +142 -14
@@ -0,0 +1,95 @@
1
+ /*
2
+ * File: uthread.h
3
+ * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+
7
+ #ifndef UTHREAD_H
8
+ #define UTHREAD_H
9
+
10
+ #include "common/u/u.h"
11
+ #include "common/u/usecurity.h"
12
+
13
+
14
+ #ifdef _WIN32
15
+ #else
16
+ #include <pthread.h>
17
+ #endif
18
+
19
+
20
+ #ifdef _WIN32
21
+ #define U_THREAD_PROC(ProcName, arg) DWORD WINAPI ProcName(LPVOID arg)
22
+ #else
23
+ #define U_THREAD_PROC(ProcName, arg) void * ProcName(void* arg)
24
+ #endif
25
+
26
+ #define UEXITTHREAD_OK 0
27
+ #define UEXITTHREAD_FAIL (-1)
28
+
29
+
30
+ #ifdef _WIN32
31
+ typedef HANDLE uResVal;
32
+ typedef LPVOID uArg;
33
+ typedef HANDLE UTHANDLE;
34
+ typedef SIZE_T uStackSize;
35
+ typedef LPTHREAD_START_ROUTINE uThreadProc;
36
+ typedef DWORD UTID;
37
+
38
+ typedef volatile LONG uspinlock;
39
+ #else
40
+ typedef int uResVal;
41
+ typedef void* uArg;
42
+ typedef pthread_t UTHANDLE;
43
+ typedef size_t uStackSize;
44
+ typedef void* (*uThreadProc)(void*);
45
+ typedef int UTID;
46
+
47
+ #ifdef HAVE_SPINLOCKS
48
+ typedef pthread_spinlock_t uspinlock;
49
+ #endif
50
+ #endif
51
+
52
+ #ifdef _WIN32
53
+ #define uSpinInit(sl) ((*(sl) = FALSE), 0)
54
+ #define uSpinDestroy(sl) 0
55
+ #define uSpinLock(sl) while (InterlockedExchange(sl, TRUE) == TRUE) { Sleep(0); }
56
+ #define uSpinUnlock(sl) InterlockedExchange(sl, FALSE)
57
+ #else
58
+ #define uSpinInit(sl) pthread_spin_init(sl, 0)
59
+ #define uSpinDestroy(sl) pthread_spin_destroy(sl)
60
+ #define uSpinLock(sl) pthread_spin_lock(sl)
61
+ #define uSpinUnlock(sl) pthread_spin_unlock(sl)
62
+ #endif
63
+
64
+
65
+
66
+ #ifdef __cplusplus
67
+ extern "C" {
68
+ #endif
69
+
70
+ uResVal uCreateThread(
71
+ uThreadProc proc,
72
+ uArg arg,
73
+ UTHANDLE *id,
74
+ uStackSize size,
75
+ USECURITY_ATTRIBUTES* sa,
76
+ sys_call_error_fun fun
77
+ );
78
+
79
+ int uEnableSuspend(sys_call_error_fun fun);
80
+ int uSuspendThread(UTHANDLE id, sys_call_error_fun fun);
81
+ int uResumeThread(UTHANDLE id, sys_call_error_fun fun);
82
+ int uTerminateThread(UTHANDLE id, sys_call_error_fun fun);
83
+ int uCloseThreadHandle(UTHANDLE id, sys_call_error_fun fun);
84
+ int uThreadJoin(UTHANDLE id, sys_call_error_fun fun);
85
+ // use UEXITTHREAD_OK or UEXITTHREAD_FAIL as arguments to uExitThread
86
+ void uExitThread(int rc, sys_call_error_fun fun);
87
+ UTHANDLE uGetCurrentThread(sys_call_error_fun fun);
88
+ int uThreadBlockAllSignals(sys_call_error_fun fun);
89
+
90
+ #ifdef __cplusplus
91
+ }
92
+ #endif
93
+
94
+ #endif
95
+
@@ -0,0 +1,65 @@
1
+ /*
2
+ * File: utime.c
3
+ * Copyright (C) 2006 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+ #ifndef _UTIME_H
7
+ #define _UTIME_H
8
+
9
+ #include "common/u/utime.h"
10
+
11
+
12
+ utm getLocalTime()
13
+ {
14
+ utm retval;
15
+
16
+ //FIXME: Need to deal with daylight savings times
17
+ #ifdef _WIN32
18
+ SYSTEMTIME systime;
19
+ TIME_ZONE_INFORMATION tz_info;
20
+
21
+ GetLocalTime(&systime);
22
+ retval.utm_year = systime.wYear;
23
+ retval.utm_mon = systime.wMonth;
24
+ retval.utm_wday = systime.wDayOfWeek;
25
+ retval.utm_mday = systime.wDay;
26
+ retval.utm_hour = systime.wHour;
27
+ retval.utm_min = systime.wMinute;
28
+ retval.utm_sec = systime.wSecond;
29
+ retval.utm_millis = systime.wMilliseconds;
30
+
31
+ GetTimeZoneInformation(&tz_info);
32
+ retval.utm_gmtoff = -(tz_info.Bias + tz_info.DaylightBias)*60;
33
+ #else
34
+ // !!! Calling localtime is not thread safe (use localtime_r
35
+ // instead if you want thread safe code)
36
+ time_t t;
37
+ struct tm* tm_ptr;
38
+ time(&t);
39
+ tm_ptr = localtime(&t);
40
+ retval.utm_millis = 0;
41
+ retval.utm_sec = tm_ptr->tm_sec;
42
+ retval.utm_min = tm_ptr->tm_min;
43
+ retval.utm_hour = tm_ptr->tm_hour;
44
+ retval.utm_mday = tm_ptr->tm_mday;
45
+ retval.utm_mon = tm_ptr->tm_mon+1;
46
+ retval.utm_year = tm_ptr->tm_year+1900;
47
+ retval.utm_wday = tm_ptr->tm_wday;
48
+ retval.utm_yday = tm_ptr->tm_yday;
49
+ retval.utm_isdst = tm_ptr->tm_isdst;
50
+
51
+ #if defined(__cygwin__) || defined(SunOS)
52
+ retval.utm_zone = 0;
53
+ retval.utm_gmtoff = 0;
54
+ #else
55
+ retval.utm_zone = tm_ptr->tm_zone;
56
+ retval.utm_gmtoff = tm_ptr->tm_gmtoff;
57
+ #endif
58
+
59
+ #endif
60
+
61
+ return retval;
62
+ }
63
+
64
+ #endif /* _UTIME_H */
65
+
@@ -0,0 +1,40 @@
1
+ /*
2
+ * File: utime.h
3
+ * Copyright (C) 2006 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+ #ifndef UTIME_H
7
+ #define UTIME_H
8
+
9
+ #include "common/u/u.h"
10
+
11
+
12
+ // Define the time structure class in the spirit of extended POSIX tm
13
+ // structure
14
+ typedef struct {
15
+ /* ANSI standard fields */
16
+ int utm_millis; /* 0 to 1000 */
17
+ int utm_sec; /* 0 to 60 */
18
+ int utm_min; /* 0 to 59 */
19
+ int utm_hour; /* 0 to 23 */
20
+ int utm_mday; /* 1 to 31 */
21
+ int utm_mon; /* 0 to 11 */
22
+ int utm_year; /* year - 1900 */
23
+ int utm_wday; /* Sunday = 0 */
24
+ int utm_yday; /* 0 to 365 */
25
+ int utm_isdst;
26
+ /* >0 if Daylight Savings Time,
27
+ * 0 if Standard,
28
+ * <0 if unknown */
29
+ /* extensions to ANSI standard */
30
+ const char *utm_zone; /* time zone name */
31
+ long utm_gmtoff; /* offset from GMT */
32
+ } utm;
33
+
34
+
35
+ SE_EXTERN_C
36
+ utm getLocalTime();
37
+
38
+
39
+ #endif /* UTIME_H */
40
+
@@ -0,0 +1,142 @@
1
+ /*
2
+ * File: uutils.c
3
+ * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+
7
+ #include <stdlib.h>
8
+ #include "common/u/uutils.h"
9
+ #include "common/errdbg/d_printf.h"
10
+
11
+
12
+ #ifndef _WIN32
13
+
14
+ char *u_itoa(int value, char *str, int radix)
15
+ {
16
+ if (radix != 10)
17
+ {
18
+ d_printf1("radix in call to _ultoa has unsupported value\n");
19
+ return NULL;
20
+ }
21
+ sprintf(str, "%d", value);
22
+ return str;
23
+ }
24
+
25
+ char *u_ltoa(long value, char *str, int radix)
26
+ {
27
+ if (radix != 10)
28
+ {
29
+ d_printf1("radix in call to _ltoa has unsupported value\n");
30
+ return NULL;
31
+ }
32
+ sprintf(str, "%ld", value);
33
+ return str;
34
+ }
35
+
36
+ char *u_ultoa(unsigned long value, char *str, int radix)
37
+ {
38
+ if (radix != 10)
39
+ {
40
+ d_printf1("radix in call to _ultoa has unsupported value\n");
41
+ return NULL;
42
+ }
43
+ sprintf(str, "%lu", value);
44
+ return str;
45
+ }
46
+
47
+ char *u_i64toa(__int64 value, char *str, int radix)
48
+ {
49
+ if (radix != 10)
50
+ {
51
+ d_printf1("radix in call to _ultoa has unsupported value\n");
52
+ return NULL;
53
+ }
54
+ sprintf(str, "%lld", value);
55
+ return str;
56
+ }
57
+
58
+ char *u_ui64toa(__uint64 value, char *str, int radix)
59
+ {
60
+ if (radix != 10)
61
+ {
62
+ d_printf1("radix in call to _ui64toa has unsupported value\n");
63
+ return NULL;
64
+ }
65
+ sprintf(str, "%llu", value);
66
+ return str;
67
+ }
68
+
69
+ char *u_gcvt(double value, int digits, char *buf)
70
+ {
71
+ #ifdef HAVE_GCVT
72
+ return gcvt(value, digits, buf);
73
+ #else
74
+ sprintf(buf, "%.*E", digits, value);
75
+ return buf;
76
+ #endif
77
+ }
78
+
79
+ int _stricmp(const char *str1, const char *str2)
80
+ {
81
+ return strcasecmp(str1, str2);
82
+ }
83
+
84
+ int _strnicmp(const char *str1, const char *str2, size_t n)
85
+ {
86
+ return strncasecmp(str1, str2, n);
87
+ }
88
+
89
+ int _vsnprintf(char *str, size_t size, const char *format, va_list ap)
90
+ {
91
+ int res = vsnprintf(str, size, format, ap);
92
+ if (res >= size) return -1;
93
+ return res;
94
+ }
95
+
96
+ #endif /* _WIN32 */
97
+
98
+ void int2net_int(__int32 i, char *buf)
99
+ {
100
+ i = htonl(i);
101
+ memcpy(buf, (void*)&i, sizeof(__int32));
102
+ }
103
+
104
+ void net_int2int(__int32* i, const char *buf)
105
+ {
106
+ memcpy((void*)i, buf, sizeof(__int32));
107
+ *i = ntohl(*i);
108
+ }
109
+
110
+ char *int2c_str(int value, char *buf)
111
+ {
112
+ u_itoa(value, buf, 10);
113
+ return buf;
114
+ }
115
+
116
+ __int64 strto__int64(const char *nptr, char **endptr, int base)
117
+ {
118
+ #ifdef _WIN32
119
+ return _strtoi64(nptr, endptr, base);
120
+ #else
121
+ return strtoll(nptr, endptr, base);
122
+ #endif
123
+ }
124
+
125
+ __uint64 strto__uint64(const char *nptr, char **endptr, int base)
126
+ {
127
+ #ifdef _WIN32
128
+ return _strtoui64(nptr, endptr,base);
129
+ #else
130
+ return strtoull(nptr, endptr,base);
131
+ #endif
132
+ }
133
+
134
+ __int64 u_double2int64(double v)
135
+ {
136
+ __int64 res;
137
+ if(u_is_nan(v)) return 0;
138
+ if(u_is_neg_inf(v) || v < _I64_MIN) return _I64_MIN;
139
+ if(u_is_pos_inf(v) || v > _I64_MAX) return _I64_MAX;
140
+ res = (__int64)v;
141
+ return res;
142
+ }
@@ -0,0 +1,65 @@
1
+ /*
2
+ * File: uutils.h
3
+ * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+
7
+ #ifndef _UUTILS_H
8
+ #define _UUTILS_H
9
+
10
+
11
+ #include "common/u/u.h"
12
+
13
+ #ifndef _WIN32
14
+ #include <netinet/in.h>
15
+ #include <netinet/tcp.h>
16
+ #endif
17
+
18
+ #ifdef __cplusplus
19
+ extern "C"
20
+ {
21
+ #endif
22
+
23
+ #ifdef _WIN32
24
+ #define u_itoa _itoa
25
+ #define u_ltoa _ltoa
26
+ #define u_i64toa _i64toa
27
+ #define u_ui64toa _ui64toa
28
+ #define u_ultoa _ultoa
29
+ #define u_gcvt _gcvt
30
+ #else
31
+ char *u_itoa(int value, char *str, int radix);
32
+ char *u_ltoa(long value, char *str, int radix);
33
+ char *u_ultoa(unsigned long value, char *str, int radix);
34
+ char *u_i64toa(__int64 value, char *str, int radix);
35
+ char *u_ui64toa(__uint64 value, char *str, int radix);
36
+ char *u_gcvt(double value, int digits, char *buf);
37
+ int _stricmp(const char *str1, const char *str2);
38
+ int _strnicmp(const char *str1, const char *str2, size_t n);
39
+ int _vsnprintf(char *str, size_t size, const char *format, va_list ap);
40
+ #define _snprintf snprintf
41
+ #endif
42
+
43
+ void int2net_int(__int32 i, char *buf);
44
+ void net_int2int(__int32 *i, const char *buf);
45
+
46
+ /* buf length must not be less than 20 */
47
+ char *int2c_str(int value, char *buf);
48
+
49
+ __int64 strto__int64(const char *nptr, char **endptr, int base);
50
+ __uint64 strto__uint64(const char *nptr, char **endptr, int base);
51
+
52
+ /*
53
+ * (__int64)INF, (__int64)NaN is undefined behaviour and give different
54
+ * results on Win/Linux/Mac OS
55
+ * returns 0 if NaN
56
+ * __I64_MAX if +INF, or v > _I64_MAX
57
+ * __I64_MIN if -INF, or v < _I64_MIN
58
+ */
59
+ __int64 u_double2int64(double v);
60
+
61
+ #ifdef __cplusplus
62
+ }
63
+ #endif
64
+
65
+ #endif /* _UUTILS_H */
@@ -0,0 +1,156 @@
1
+ /*
2
+ * File: ugc.cpp
3
+ * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+ #include "common/sedna.h"
7
+
8
+ #include "common/ugc.h"
9
+ #include "common/base.h"
10
+ #include "common/u/ushm.h"
11
+ #include "common/u/usem.h"
12
+ #include "common/u/ummap.h"
13
+ #include "common/u/uevent.h"
14
+ #include "common/errdbg/d_printf.h"
15
+ #include "common/config.h"
16
+ #include "common/SSMMsg.h"
17
+
18
+
19
+
20
+ #define EVENT_CLEANUP(name) if (UEventOpen(&ev, name, __sys_call_error) == 0) \
21
+ { \
22
+ UEventCloseAndUnlink(&ev, __sys_call_error); \
23
+ d_printf1("Event cleanup : "#name"\n"); \
24
+ }
25
+
26
+ #define SEMAPHORE_CLEANUP(name) if (USemaphoreOpen(&sem, name, __sys_call_error) == 0) \
27
+ { \
28
+ USemaphoreRelease(sem, __sys_call_error); \
29
+ d_printf1("Semaphore cleanup : "#name"\n"); \
30
+ }
31
+
32
+ #define SHAREDMEM_CLEANUP(name, size) if (uOpenShMem(&shm, name, 0, __sys_call_error) == 0) \
33
+ { \
34
+ uReleaseShMem(shm, __sys_call_error); \
35
+ d_printf1("Shared memory cleanup: "#name"\n"); \
36
+ }
37
+
38
+ #define SEMAPHORE_CLEANUP2(name, name2) if (USemaphoreOpen(&sem, name, __sys_call_error) == 0) \
39
+ { \
40
+ USemaphoreRelease(sem, __sys_call_error); \
41
+ d_printf1("Semaphore cleanup : "#name2"\n"); \
42
+ }
43
+
44
+ #define SHAREDMEM_CLEANUP2(name, name2, size) if (uOpenShMem(&shm, name, 0, __sys_call_error) == 0) \
45
+ { \
46
+ uReleaseShMem(shm, __sys_call_error); \
47
+ d_printf1("Shared memory cleanup: "#name2"\n"); \
48
+ }
49
+
50
+ #define FILE_MAPPING_CLEANUP(name) if (!U_INVALID_FILEMAPPING(map = uOpenFileMapping(U_INVALID_FD, 0, name, __sys_call_error))) \
51
+ { \
52
+ uReleaseFileMapping(map, name, __sys_call_error); \
53
+ d_printf1("Filemapping cleanup : "#name"\n"); \
54
+ }
55
+
56
+
57
+
58
+ void gov_ugc(bool background_off_from_background_on, int os_primitives_bound)
59
+ {
60
+ #ifdef _WIN32
61
+ #else
62
+ USemaphore sem;
63
+ UShMem shm;
64
+ UMMap map;
65
+ char buf[1024];
66
+
67
+ if (background_off_from_background_on) return;
68
+
69
+ d_printf1("Starting CLEANUP\n");
70
+ SEMAPHORE_CLEANUP(CHARISMA_GOVERNOR_IS_READY);
71
+
72
+ SEMAPHORE_CLEANUP(SE_EVENT_LOG_SEMAPHORES_NAME);
73
+ SHAREDMEM_CLEANUP(SE_EVENT_LOG_SHARED_MEMORY_NAME, sizeof(event_log_msg));
74
+
75
+ SHAREDMEM_CLEANUP(GOVERNOR_SHARED_MEMORY_NAME, sizeof(gov_config_struct));
76
+ FILE_MAPPING_CLEANUP(SEDNA_GLOBAL_MEMORY_MAPPING);
77
+
78
+ /// releasing semaphores depending on sessions
79
+ for (int i = 0; i < MAX_SESSIONS_NUMBER; i++)
80
+ {
81
+ SEMAPHORE_CLEANUP2(SM_TO_VMM_CALLBACK_SEM1_BASE_STR(i, buf, 1024), SM_TO_VMM_CALLBACK_SEM1_BASE_STR);
82
+ SEMAPHORE_CLEANUP2(SM_TO_VMM_CALLBACK_SEM2_BASE_STR(i, buf, 1024), SM_TO_VMM_CALLBACK_SEM2_BASE_STR);
83
+ SEMAPHORE_CLEANUP2(SEDNA_TRANSACTION_LOCK(i, buf, 1024), SEDNA_TRANSACTION_LOCK);
84
+ }
85
+
86
+ d_printf1("CLEANUP completed\n\n");
87
+ #endif
88
+ }
89
+
90
+ void sm_ugc(bool background_off_from_background_on, int db_id, int os_primitives_bound)
91
+ {
92
+ #ifdef _WIN32
93
+ #else
94
+ USemaphore sem;
95
+ UShMem shm;
96
+ UMMap map;
97
+ UEvent ev;
98
+ char buf[1024];
99
+
100
+ if (background_off_from_background_on) return;
101
+
102
+ d_printf1("Starting CLEANUP\n");
103
+ SEMAPHORE_CLEANUP(CHARISMA_SM_WAIT_FOR_SHUTDOWN);
104
+ SEMAPHORE_CLEANUP(VMM_SM_SEMAPHORE_STR);
105
+ SEMAPHORE_CLEANUP(VMM_SM_EXCLUSIVE_MODE_SEM_STR);
106
+
107
+ SEMAPHORE_CLEANUP(CATALOG_NAMETABLE_SEMAPHORE_STR);
108
+ SEMAPHORE_CLEANUP(CATALOG_MASTER_SEMAPHORE_STR);
109
+
110
+ // SEMAPHORE_CLEANUP(METADATA_SEMAPHORE_STR);
111
+ // SEMAPHORE_CLEANUP(INDEX_SEMAPHORE_STR);
112
+ #ifdef SE_ENABLE_FTSEARCH
113
+ //SEMAPHORE_CLEANUP(FT_INDEX_SEMAPHORE_STR);
114
+ #endif
115
+ #ifdef SE_ENABLE_TRIGGERS
116
+ //SEMAPHORE_CLEANUP(TRIGGER_SEMAPHORE_STR);
117
+ #endif
118
+ SHAREDMEM_CLEANUP(CHARISMA_SM_CALLBACK_SHARED_MEMORY_NAME, 8);
119
+ SHAREDMEM_CLEANUP(CHARISMA_LOGICAL_LOG_SHARED_MEM_NAME, 0/*CHARISMA_LOGICAL_LOG_SHARED_MEM_SIZE*/);
120
+ SHAREDMEM_CLEANUP(SEDNA_LFS_SHARED_MEM_NAME, 0);
121
+ //SEMAPHORE_CLEANUP(CHARISMA_CHECKPOINT_SEM);
122
+ SEMAPHORE_CLEANUP(SEDNA_TRNS_FINISHED);
123
+ SEMAPHORE_CLEANUP(CHARISMA_LOGICAL_LOG_PROTECTION_SEM_NAME);
124
+ SEMAPHORE_CLEANUP(CHARISMA_DB_RECOVERED_BY_LOGICAL_LOG);
125
+ //SEMAPHORE_CLEANUP(CHARISMA_WAIT_FOR_CHECKPOINT);
126
+ SEMAPHORE_CLEANUP(SEDNA_CHECKPOINT_FINISHED_SEM);
127
+ SEMAPHORE_CLEANUP(SEDNA_LOCK_MANAGER_SEM);
128
+ SEMAPHORE_CLEANUP(SEDNA_LFS_SEM_NAME);
129
+
130
+ EVENT_CLEANUP(SNAPSHOT_CHECKPOINT_EVENT);
131
+ EVENT_CLEANUP(TRY_ADVANCE_SNAPSHOT_EVENT);
132
+
133
+ SHAREDMEM_CLEANUP(CHARISMA_LRU_STAMP_SHARED_MEMORY_NAME, 8);
134
+ SEMAPHORE_CLEANUP(CHARISMA_SYNC_TRN_IDS_TABLE);
135
+ //SEMAPHORE_CLEANUP(CHARISMA_SM_SMSD_ID);
136
+ SEMAPHORE_CLEANUP(CHARISMA_SM_IS_READY);
137
+
138
+ SSMMsg::ipc_cleanup(CHARISMA_SSMMSG_SM_ID(db_id, buf, 1024));
139
+
140
+ FILE_MAPPING_CLEANUP(CHARISMA_BUFFER_SHARED_MEMORY_NAME);
141
+
142
+
143
+ d_printf1("CLEANUP completed\n\n");
144
+
145
+ // std::string buf_dir = SEDNA_DATA + std::string("/data/") + db_name + std::string("_files/buf");
146
+ #endif
147
+ }
148
+
149
+ void cdb_ugc(int db_id, int os_primitives_bound)
150
+ {
151
+ #ifdef _WIN32
152
+ #else
153
+ sm_ugc(false, db_id, os_primitives_bound);
154
+ #endif
155
+ }
156
+