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,118 @@
1
+ /*
2
+ * File: usocket.h
3
+ * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+ #ifndef _USOCKET_H
7
+ #define _USOCKET_H
8
+
9
+ #include "common/u/u.h"
10
+
11
+ #ifdef __cplusplus
12
+ extern "C"
13
+ {
14
+ #endif
15
+
16
+ #ifdef _WIN32
17
+ typedef SOCKET USOCKET;
18
+
19
+ #define U_INVALID_SOCKET INVALID_SOCKET
20
+ #define U_SOCKET_ERROR SOCKET_ERROR
21
+
22
+ #else
23
+ #include <sys/socket.h>
24
+
25
+ typedef int USOCKET;
26
+
27
+ #define U_INVALID_SOCKET (-1)
28
+ #define U_SOCKET_ERROR (-1)
29
+
30
+ #endif
31
+
32
+ // defines for fd_set
33
+ #define U_SSET fd_set
34
+ #define U_SSET_SIZE FD_SETSIZE
35
+
36
+ #define U_SSET_SET FD_SET
37
+ #define U_SSET_ISSET FD_ISSET
38
+ #define U_SSET_CLR FD_CLR
39
+ #define U_SSET_ZERO FD_ZERO
40
+
41
+ /* returns zero if succeeded
42
+ returns U_SOCKET_ERROR if failed */
43
+ int uSocketInit(sys_call_error_fun fun);
44
+
45
+ /* returns zero if succeeded
46
+ returns U_SOCKET_ERROR if failed */
47
+ int uSocketCleanup(sys_call_error_fun fun);
48
+
49
+ /* returns U_INVALID_SOCKET if failed */
50
+ USOCKET usocket(int af, int type, int protocol, sys_call_error_fun fun);
51
+
52
+ /* returns zero if succeeded
53
+ returns U_SOCKET_ERROR if failed */
54
+ int ubind_tcp(USOCKET s, int port, sys_call_error_fun fun);
55
+
56
+ /* returns zero if succeeded
57
+ returns U_SOCKET_ERROR if failed */
58
+ int uconnect_tcp(USOCKET s, int port, const char *hostname, sys_call_error_fun fun);
59
+
60
+ /* returns zero if succeeded
61
+ returns U_SOCKET_ERROR if failed */
62
+ int usetsockopt(USOCKET s, int level, int optname, const void* optval, unsigned int optlen, sys_call_error_fun fun);
63
+
64
+ /* returns zero if succeeded
65
+ returns U_SOCKET_ERROR if failed */
66
+ int ugetsockopt(USOCKET s, int level, int optname, void* optval, unsigned int optlen, sys_call_error_fun fun);
67
+
68
+ /* returns zero if succeeded
69
+ returns U_SOCKET_ERROR if failed */
70
+ int ulisten(USOCKET s, int backlog, sys_call_error_fun fun);
71
+
72
+ /* returns U_INVALID_SOCKET if failed */
73
+ USOCKET uaccept(USOCKET s, sys_call_error_fun fun);
74
+
75
+ /* return value indicates number of bytes received
76
+ returns zero if connection was gracefully closed
77
+ returns U_SOCKET_ERROR in the case of error */
78
+ int urecv(USOCKET s, char *buf, int len, sys_call_error_fun fun);
79
+
80
+ /* return value indicates number of bytes send
81
+ returns U_SOCKET_ERROR in the case of error */
82
+ int usend(USOCKET s, const char *buf, int len, sys_call_error_fun fun);
83
+
84
+ /* returns zero if succeeded
85
+ returns U_SOCKET_ERROR if failed */
86
+ int uclose_socket(USOCKET s, sys_call_error_fun fun);
87
+
88
+ /* returns zero if succeeded
89
+ returns U_SOCKET_ERROR if failed */
90
+ int ushutdown_close_socket(USOCKET s, sys_call_error_fun fun);
91
+
92
+ /* returns zero if succeeded
93
+ returns U_SOCKET_ERROR if failed */
94
+ int ushutdown_socket(USOCKET s, sys_call_error_fun fun);
95
+
96
+ /* returns 1 (number of sockets ready to recv) if there is data pending in network connection
97
+ returns 0 if timeout
98
+ returns U_SOCKET_ERROR if failed */
99
+ int uselect_read(USOCKET s, struct timeval *timeout, sys_call_error_fun fun);
100
+
101
+ /* returns number of sockets ready to recv if there is data pending in network connection
102
+ (s is changed and contains result of FD_ISSET)
103
+ returns 0 if timeout
104
+ returns U_SOCKET_ERROR if failed */
105
+ int uselect_read_arr(U_SSET *s, int maxfd, struct timeval *timeout, sys_call_error_fun fun);
106
+
107
+ /* retrieves the last socket error description */
108
+ const char *usocket_error_translator();
109
+
110
+ /* when connect has failed, utry_connect_again checks if it is reasonable to reconnect
111
+ returns 1 if it is reasonable, zero if it is not */
112
+ int utry_connect_again();
113
+
114
+ #ifdef __cplusplus
115
+ }
116
+ #endif
117
+
118
+ #endif
@@ -0,0 +1,57 @@
1
+ /*
2
+ * File: usystem.c
3
+ * Copyright (C) 2008 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+ #include "common/u/usystem.h"
7
+ #include "common/errdbg/d_printf.h"
8
+
9
+ /* returns 0 if succeeded
10
+ returns 1 if failed */
11
+ int uUname(U_UTSNAME* s, sys_call_error_fun fun)
12
+ {
13
+ #ifdef _WIN32
14
+ BOOL res, bIsWow64 = FALSE;
15
+ OSVERSIONINFOEX osvi;
16
+ LPFN_ISWOW64PROCESS fnIsWow64Process;
17
+
18
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
19
+
20
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
21
+
22
+ if((res = GetVersionEx ((OSVERSIONINFO *) &osvi)) == 0)
23
+ {
24
+ sys_call_error("GetVersionEX");
25
+ return 1;
26
+ }
27
+
28
+ sprintf(s->sysname, "Windows");
29
+ sprintf(s->release, "%lu.%lu.%lu", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.dwBuildNumber);
30
+ sprintf(s->version, "SP%u.%u", osvi.wServicePackMajor, osvi.wServicePackMinor);
31
+
32
+ fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"),"IsWow64Process");
33
+
34
+ if (NULL != fnIsWow64Process)
35
+ {
36
+ if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
37
+ {
38
+ sys_call_error("IsWow64Process");
39
+ return 1;
40
+ }
41
+ }
42
+
43
+ sprintf(s->machine, bIsWow64 ? "x64" : "x86");
44
+
45
+ return 0;
46
+ #else
47
+ int res = 0;
48
+ res = uname(s);
49
+ if(-1 == res)
50
+ {
51
+ sys_call_error("uname");
52
+ return 1;
53
+ }
54
+ return 0;
55
+ #endif
56
+ }
57
+
@@ -0,0 +1,46 @@
1
+ /*
2
+ * File: usystem.h
3
+ * Copyright (C) 2008 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+ #ifndef _USYSTEM_H
7
+ #define _USYSTEM_H
8
+
9
+ #include "common/u/u.h"
10
+
11
+
12
+ #ifdef _WIN32
13
+
14
+ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
15
+
16
+ typedef struct {
17
+ char sysname[128];
18
+ char release[128];
19
+ char version[128];
20
+ char machine[128];
21
+ } U_UTSNAME;
22
+
23
+ #else
24
+
25
+ #include <sys/utsname.h>
26
+ typedef struct utsname U_UTSNAME;
27
+
28
+ #endif /* _WIN32 */
29
+
30
+
31
+ #ifdef __cplusplus
32
+ extern "C"
33
+ {
34
+ #endif
35
+
36
+ /* returns 0 if succeeded
37
+ returns 1 if failed */
38
+ int uUname(U_UTSNAME* s, sys_call_error_fun fun);
39
+
40
+
41
+ #ifdef __cplusplus
42
+ }
43
+ #endif
44
+
45
+
46
+ #endif /* _USYSTEM_H */
@@ -0,0 +1,259 @@
1
+ /*
2
+ * File: uthread.cpp
3
+ * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
4
+ */
5
+
6
+
7
+ #include "common/errdbg/d_printf.h"
8
+ #include "common/u/uthread.h"
9
+
10
+
11
+ uResVal uCreateThread(
12
+ uThreadProc proc,
13
+ uArg arg,
14
+ UTHANDLE *id,
15
+ uStackSize size,
16
+ USECURITY_ATTRIBUTES* sa,
17
+ sys_call_error_fun fun
18
+ )
19
+ {
20
+ #ifdef _WIN32
21
+ DWORD threadId = 0;
22
+ HANDLE hndl = CreateThread(
23
+ sa,
24
+ size,
25
+ proc,
26
+ arg,
27
+ 0,
28
+ &threadId);
29
+ *id = hndl;
30
+ if (hndl != 0) return 0;
31
+ else
32
+ {
33
+ sys_call_error("CreateThread");
34
+ return (void*)-1;
35
+ }
36
+ #else
37
+ pthread_attr_t attr;
38
+ int set_res = 0;
39
+ set_res = pthread_attr_init(&attr);
40
+ if (set_res != 0)
41
+ {
42
+ sys_call_error("pthread_attr_init");
43
+ return set_res;
44
+ }
45
+ set_res = pthread_attr_setstacksize(&attr, size);
46
+ if (set_res != 0)
47
+ {
48
+ sys_call_error("pthread_attr_setstacksize");
49
+ return set_res;
50
+ }
51
+ pthread_t threadId = 0;
52
+ int res = pthread_create(
53
+ &threadId,
54
+ &attr,
55
+ proc,
56
+ arg);
57
+
58
+ if (res != 0) sys_call_error("pthread_create");
59
+
60
+ *id = threadId;
61
+ return res;
62
+ #endif
63
+ }
64
+
65
+ #ifdef _WIN32
66
+ #else
67
+ static void _suspend_thread_signal_handler(int signo, siginfo_t *info, void *cxt)
68
+ {
69
+ sys_call_error_fun fun=NULL;
70
+ d_printf1("suspend\n");
71
+ int sig = 0;
72
+ sigset_t signalSet;
73
+ if (sigfillset(&signalSet) == -1) sys_call_error("sigfillset");
74
+ if (sigwait(&signalSet, &sig) != 0) sys_call_error("sigwait");
75
+ }
76
+ static void _resume_thread_signal_handler(int signo, siginfo_t *info, void *cxt)
77
+ {
78
+ d_printf1("resume\n");
79
+ }
80
+ #endif
81
+
82
+ int uEnableSuspend(sys_call_error_fun fun)
83
+ {
84
+ #ifdef _WIN32
85
+ return 0;
86
+ #else
87
+ struct sigaction sigsegv_act;
88
+
89
+ memset(&sigsegv_act, '\0', sizeof(struct sigaction));
90
+ sigsegv_act.sa_sigaction = _suspend_thread_signal_handler;
91
+ sigsegv_act.sa_flags = SA_SIGINFO;
92
+ if (sigaction(SIGUSR1, &sigsegv_act, NULL) == -1)
93
+ {
94
+ sys_call_error("sigaction");
95
+ return 1;
96
+ }
97
+
98
+ memset(&sigsegv_act, '\0', sizeof(struct sigaction));
99
+ sigsegv_act.sa_sigaction = _resume_thread_signal_handler;
100
+ sigsegv_act.sa_flags = SA_SIGINFO;
101
+ if (sigaction(SIGUSR2, &sigsegv_act, NULL) == -1)
102
+ {
103
+ sys_call_error("sigaction");
104
+ return 1;
105
+ }
106
+
107
+ return 0;
108
+ #endif
109
+ }
110
+
111
+ int uSuspendThread(UTHANDLE id, sys_call_error_fun fun)
112
+ {
113
+ #ifdef _WIN32
114
+ if (SuspendThread(id) == -1)
115
+ {
116
+ sys_call_error("SuspendThread");
117
+ return 1;
118
+ }
119
+ else return 0;
120
+ #else
121
+ int res = pthread_kill(id, SIGUSR1);
122
+ if (res != 0) sys_call_error("pthread_kill");
123
+ return res;
124
+ #endif
125
+ }
126
+
127
+ int uResumeThread(UTHANDLE id, sys_call_error_fun fun)
128
+ {
129
+ #ifdef _WIN32
130
+ if (ResumeThread(id) == -1)
131
+ {
132
+ sys_call_error("ResumeThread");
133
+ return 1;
134
+ }
135
+ else return 0;
136
+ #else
137
+ int res = pthread_kill(id, SIGUSR2);
138
+ if (res != 0) sys_call_error("pthread_kill");
139
+ return res;
140
+ #endif
141
+ }
142
+
143
+ int uTerminateThread(UTHANDLE id, sys_call_error_fun fun)
144
+ {
145
+ #ifdef _WIN32
146
+ BOOL res = 0;
147
+ res = TerminateThread(id, 0);
148
+ if (res == 0)
149
+ {
150
+ sys_call_error("TerminateThread");
151
+ return 1;
152
+ }
153
+
154
+ return 0;
155
+ #else
156
+ int res = pthread_cancel(id);
157
+ if (res != 0) sys_call_error("pthread_cancel");
158
+ return res;
159
+ #endif
160
+ }
161
+
162
+ int uCloseThreadHandle(UTHANDLE id, sys_call_error_fun fun)
163
+ {
164
+ #ifdef _WIN32
165
+ BOOL res = 0;
166
+ res = CloseHandle(id);
167
+ if (res == 0)
168
+ {
169
+ sys_call_error("CloseHandle");
170
+ return 1;
171
+ }
172
+
173
+ return 0;
174
+ #else
175
+ return 0;
176
+ #endif
177
+ }
178
+
179
+ int uThreadJoin(UTHANDLE id, sys_call_error_fun fun)
180
+ {
181
+ #ifdef _WIN32
182
+ DWORD res = 0;
183
+ do {
184
+ res = WaitForSingleObjectEx(id, INFINITE, TRUE);
185
+ } while (res == WAIT_IO_COMPLETION);
186
+ if (res == WAIT_FAILED) sys_call_error("WaitForSingleObject");
187
+
188
+ if (res != WAIT_OBJECT_0) return 1;
189
+ else return 0;
190
+ #else
191
+ int res = pthread_join(id, NULL);
192
+ if (res != 0) sys_call_error("pthread_join");
193
+ return res;
194
+ #endif
195
+ }
196
+
197
+ void uExitThread(int rc, sys_call_error_fun fun)
198
+ {
199
+ #ifdef _WIN32
200
+ ExitThread(rc);
201
+ #else
202
+ pthread_exit((void*)rc);
203
+ #endif
204
+ }
205
+
206
+ UTHANDLE uGetCurrentThread(sys_call_error_fun fun)
207
+ {
208
+ #ifdef _WIN32
209
+ UTHANDLE result;
210
+
211
+ if (DuplicateHandle(GetCurrentProcess(),
212
+ GetCurrentThread(),
213
+ GetCurrentProcess(),
214
+ &result,
215
+ 0,
216
+ FALSE,
217
+ DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE) == 0)
218
+ sys_call_error("DuplicateHandle");
219
+
220
+ return result;
221
+ #else
222
+ return pthread_self();
223
+ #endif
224
+ }
225
+
226
+
227
+ int uThreadBlockAllSignals(sys_call_error_fun fun)
228
+ {
229
+ #ifdef _WIN32
230
+ return 0;
231
+ #else
232
+ sigset_t new_sigset, old_sigset;
233
+ if (sigfillset(&new_sigset) == -1)
234
+ {
235
+ sys_call_error("sigfillset");
236
+ return -1;
237
+ }
238
+ if (pthread_sigmask(SIG_SETMASK, &new_sigset, &old_sigset) == -1)
239
+ {
240
+ sys_call_error("pthread_sigmask");
241
+ return -1;
242
+ }
243
+ return 0;
244
+ #endif
245
+ }
246
+
247
+ /*
248
+ int uTime()
249
+ {
250
+ #ifdef _WIN32
251
+ time_t t;
252
+ time(&t);
253
+ return t;
254
+ #else
255
+ time_t t;
256
+ return time(&t);
257
+ #endif
258
+ }
259
+ */