isomorfeus-ferret 0.12.2 → 0.12.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +612 -612
- data/README.md +80 -44
- data/ext/isomorfeus_ferret_ext/bm_hash.c +9 -6
- data/ext/isomorfeus_ferret_ext/bm_micro_string.c +4 -2
- data/ext/isomorfeus_ferret_ext/frb_search.c +14 -2
- data/ext/isomorfeus_ferret_ext/frb_store.c +34 -5
- data/ext/isomorfeus_ferret_ext/frt_posh.h +11 -19
- data/ext/isomorfeus_ferret_ext/frt_q_parser.c +1844 -1911
- data/ext/isomorfeus_ferret_ext/frt_q_phrase.c +12 -15
- data/ext/isomorfeus_ferret_ext/frt_scanner.c +1 -0
- data/ext/isomorfeus_ferret_ext/frt_scanner_mb.c +1 -0
- data/ext/isomorfeus_ferret_ext/frt_scanner_utf8.c +1 -0
- data/ext/isomorfeus_ferret_ext/frt_search.h +1 -1
- data/ext/isomorfeus_ferret_ext/libstemmer.c +14 -11
- data/ext/isomorfeus_ferret_ext/libstemmer.h +4 -9
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.c +1167 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_basque.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.c +1433 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_catalan.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.c +120 -143
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_danish.h +1 -2
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.c +217 -237
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_dutch.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.c +377 -432
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_english.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.c +298 -342
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_finnish.h +1 -2
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.c +530 -524
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_french.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.c +201 -214
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_german.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_hungarian.c +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.c +394 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_indonesian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.c +457 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_irish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.c +396 -439
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_italian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.c +104 -128
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_norwegian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.c +242 -273
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_porter.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.c +406 -461
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_portuguese.h +1 -2
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.c +405 -456
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_spanish.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.c +108 -126
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_1_swedish.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.c +849 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_hungarian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.c +373 -405
- data/ext/isomorfeus_ferret_ext/stem_ISO_8859_2_romanian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.c +288 -305
- data/ext/isomorfeus_ferret_ext/stem_KOI8_R_russian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_arabic.c +1651 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_arabic.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_armenian.c +546 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_armenian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_basque.c +1171 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_basque.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_catalan.c +1436 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_catalan.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_danish.c +121 -141
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_danish.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_dutch.c +221 -241
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_dutch.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_english.c +381 -431
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_english.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_finnish.c +300 -345
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_finnish.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_french.c +518 -511
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_french.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_german.c +201 -209
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_german.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_greek.c +3660 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_greek.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_hindi.c +309 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_hindi.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_hungarian.c +306 -671
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_hungarian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_indonesian.c +394 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_indonesian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_irish.c +457 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_irish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_italian.c +400 -442
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_italian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_lithuanian.c +824 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_lithuanian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_nepali.c +408 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_nepali.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_norwegian.c +105 -127
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_norwegian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_porter.c +245 -276
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_porter.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_portuguese.c +409 -464
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_portuguese.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_romanian.c +376 -408
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_romanian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_russian.c +272 -287
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_russian.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_serbian.c +6530 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_serbian.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_spanish.c +407 -458
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_spanish.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_swedish.c +110 -125
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_swedish.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_tamil.c +1865 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_tamil.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_turkish.c +698 -806
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_turkish.h +1 -1
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_yiddish.c +1220 -0
- data/ext/isomorfeus_ferret_ext/stem_UTF_8_yiddish.h +6 -0
- data/ext/isomorfeus_ferret_ext/stem_api.c +1 -9
- data/ext/isomorfeus_ferret_ext/stem_api.h +1 -3
- data/ext/isomorfeus_ferret_ext/stem_header.h +30 -26
- data/ext/isomorfeus_ferret_ext/stem_modules.h +113 -26
- data/ext/isomorfeus_ferret_ext/stem_modules.txt +18 -5
- data/ext/isomorfeus_ferret_ext/stem_utilities.c +167 -132
- data/ext/isomorfeus_ferret_ext/test.c +7 -1
- data/ext/isomorfeus_ferret_ext/test_search.c +0 -1
- data/lib/isomorfeus/ferret/index/index.rb +1 -1
- data/lib/isomorfeus/ferret/version.rb +1 -1
- metadata +43 -7
- data/ext/isomorfeus_ferret_ext/q_parser.y +0 -1366
data/README.md
CHANGED
@@ -1,44 +1,80 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
https://github.com/isomorfeus/isomorfeus-ferret/blob/master/
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
https://github.com/isomorfeus/isomorfeus-ferret/blob/master/
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
-
|
42
|
-
-
|
43
|
-
|
44
|
-
|
1
|
+
<h1 align="center">
|
2
|
+
<img src="https://github.com/isomorfeus/isomorfeus-ferret/blob/master/Logo.png?raw=true" align="center" width="216" height="234" />
|
3
|
+
<br/>
|
4
|
+
Isomorfeus Ferret<br/>
|
5
|
+
</h1>
|
6
|
+
|
7
|
+
Convenient and well performing document store, indexing and search.
|
8
|
+
|
9
|
+
### Community and Support
|
10
|
+
At the [Isomorfeus Framework Project](https://isomorfeus.com)
|
11
|
+
|
12
|
+
## About this project
|
13
|
+
|
14
|
+
Isomorfeus-Ferret is a revived version of the original ferret gem created by Dave Balmain.
|
15
|
+
During revival many things havbe been fixed, now all tests pass, no crashes and it
|
16
|
+
successfully compiles and runs with rubys >3. Its no longer a goal to have
|
17
|
+
a c library available, but instead the usage is meant as ruby gem with a c extension only.
|
18
|
+
|
19
|
+
It should work on *nixes and *nuxes and also works on Windows.
|
20
|
+
|
21
|
+
However, the revival is still fresh and although it appears to be working, issues have to be expected.
|
22
|
+
|
23
|
+
## Documentation
|
24
|
+
|
25
|
+
The documentations is currently scattered throughout the repo.
|
26
|
+
|
27
|
+
For a quick start its best to read:
|
28
|
+
https://github.com/isomorfeus/isomorfeus-ferret/blob/master/TUTORIAL.md
|
29
|
+
|
30
|
+
Further:
|
31
|
+
https://github.com/isomorfeus/isomorfeus-ferret/blob/master/lib/isomorfeus/ferret/index/index.rb
|
32
|
+
https://github.com/isomorfeus/isomorfeus-ferret/blob/master/lib/isomorfeus/ferret/document.rb
|
33
|
+
|
34
|
+
The query language and parser are documented here:
|
35
|
+
https://github.com/isomorfeus/isomorfeus-ferret/blob/master/ext/isomorfeus_ferret_ext/frb_qparser.c
|
36
|
+
|
37
|
+
Examples can be found in the 'test' directory or in 'misc/ferret_vs_lucene'.
|
38
|
+
|
39
|
+
## Running Specs
|
40
|
+
|
41
|
+
- clone repo
|
42
|
+
- bundle install
|
43
|
+
- rake units
|
44
|
+
- rake thread_safety
|
45
|
+
|
46
|
+
Ensure your locale is set to C.UTF-8, because the internal c tests don't know how to handle localized output.
|
47
|
+
|
48
|
+
## Benchmarks
|
49
|
+
|
50
|
+
- clone repo
|
51
|
+
- bundle install
|
52
|
+
- rake ferret_vs_lucene
|
53
|
+
|
54
|
+
A recent Java JDK must be installed to compile and run lucene benchmarks.
|
55
|
+
|
56
|
+
Results on Linux:
|
57
|
+
```
|
58
|
+
Ferret:
|
59
|
+
Indexing Secs: 7.36 Docs: 19043, 2587 docs/s
|
60
|
+
Searching took: 0.3366296s for 8000 queries
|
61
|
+
thats 23765 q/s
|
62
|
+
|
63
|
+
Lucene:
|
64
|
+
Indexing Secs: 4.22 Docs: 19043, 4516 docs/s
|
65
|
+
Searching took: 1.48s for 8000 queries
|
66
|
+
thats 5420 q/s
|
67
|
+
---------------------------------------------------
|
68
|
+
Lucene 9.0.0 0b18b3b965cedaf5eb129aa41243a44c83ca826d - jpountz - 2021-12-01 14:23:49
|
69
|
+
JVM 17.0.1 (Private Build)
|
70
|
+
```
|
71
|
+
|
72
|
+
## Future
|
73
|
+
|
74
|
+
Lots of things to do:
|
75
|
+
- Bring documentation in order in a docs directory
|
76
|
+
- Review code (especially for memory/stack issues, typical c issues)
|
77
|
+
- Take care of ruby GVL and threading
|
78
|
+
- See todo directory: https://github.com/isomorfeus/isomorfeus-ferret/tree/master/misc/todo
|
79
|
+
|
80
|
+
Any help, support much appreciated!
|
@@ -7,20 +7,21 @@
|
|
7
7
|
static void ferret_hash()
|
8
8
|
{
|
9
9
|
int i;
|
10
|
+
void *res = NULL;
|
10
11
|
for (i = 0; i < N; i++) {
|
11
12
|
FrtHash *h = frt_h_new_str(NULL, NULL);
|
12
13
|
const char **word;
|
13
14
|
char buf[100];
|
14
|
-
long res;
|
15
15
|
for (word = WORD_LIST; *word; word++) {
|
16
16
|
frt_h_set(h, *word, (void *)1);
|
17
17
|
}
|
18
18
|
for (word = WORD_LIST; *word; word++) {
|
19
19
|
strcpy(buf, *word);
|
20
|
-
res =
|
20
|
+
res = frt_h_get(h, buf);
|
21
21
|
}
|
22
22
|
frt_h_destroy(h);
|
23
23
|
}
|
24
|
+
(void)res;
|
24
25
|
}
|
25
26
|
|
26
27
|
BENCH(hash_implementations)
|
@@ -31,18 +32,19 @@ BENCH(hash_implementations)
|
|
31
32
|
static void standard_hash()
|
32
33
|
{
|
33
34
|
int i;
|
35
|
+
void *res = NULL;
|
34
36
|
for (i = 0; i < N; i++) {
|
35
37
|
FrtHash *h = frt_h_new_str(NULL, NULL);
|
36
38
|
const char **word;
|
37
39
|
char buf[100];
|
38
|
-
long res;
|
39
40
|
for (word = WORD_LIST; *word; word++) {
|
40
41
|
frt_h_set(h, *word, (void *)1);
|
41
42
|
strcpy(buf, *word);
|
42
|
-
res =
|
43
|
+
res = frt_h_get(h, buf);
|
43
44
|
}
|
44
45
|
frt_h_destroy(h);
|
45
46
|
}
|
47
|
+
(void)res;
|
46
48
|
}
|
47
49
|
|
48
50
|
#define PERTURB_SHIFT 5
|
@@ -96,19 +98,20 @@ static FrtHashEntry *h_lookup_str(FrtHash *ht, register const void *key)
|
|
96
98
|
static void string_hash()
|
97
99
|
{
|
98
100
|
int i;
|
101
|
+
void *res = NULL;
|
99
102
|
for (i = 0; i < N; i++) {
|
100
103
|
FrtHash *h = frt_h_new_str(NULL, NULL);
|
101
104
|
const char **word;
|
102
105
|
char buf[100];
|
103
|
-
long res;
|
104
106
|
h->lookup_i = &h_lookup_str;
|
105
107
|
for (word = WORD_LIST; *word; word++) {
|
106
108
|
frt_h_set(h, *word, (void *)1);
|
107
109
|
strcpy(buf, *word);
|
108
|
-
res =
|
110
|
+
res = frt_h_get(h, buf);
|
109
111
|
}
|
110
112
|
frt_h_destroy(h);
|
111
113
|
}
|
114
|
+
(void)res;
|
112
115
|
}
|
113
116
|
|
114
117
|
BENCH(specialized_string_hash)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
static void do_strcmp()
|
7
7
|
{
|
8
|
-
char **word;
|
8
|
+
const char **word;
|
9
9
|
char buf[100];
|
10
10
|
int res, i;
|
11
11
|
|
@@ -15,11 +15,12 @@ static void do_strcmp()
|
|
15
15
|
memcpy(buf, *word, len+1);
|
16
16
|
res = strcmp(buf, *word);
|
17
17
|
}
|
18
|
+
(void)res;
|
18
19
|
}
|
19
20
|
|
20
21
|
static void do_strncmp()
|
21
22
|
{
|
22
|
-
char **word;
|
23
|
+
const char **word;
|
23
24
|
char buf[100];
|
24
25
|
int res, i;
|
25
26
|
|
@@ -29,6 +30,7 @@ static void do_strncmp()
|
|
29
30
|
memcpy(buf, *word, len+1);
|
30
31
|
res = strncmp(buf, *word, len + 1);
|
31
32
|
}
|
33
|
+
(void)res;
|
32
34
|
}
|
33
35
|
|
34
36
|
BENCH(strcmp_when_length_is_known)
|
@@ -2651,6 +2651,9 @@ frb_sea_search_internal(FrtQuery *query, VALUE roptions, FrtSearcher *sea)
|
|
2651
2651
|
FrtPostFilter post_filter_holder;
|
2652
2652
|
FrtPostFilter *post_filter = NULL;
|
2653
2653
|
|
2654
|
+
int ex_code = 0;
|
2655
|
+
const char *msg = NULL;
|
2656
|
+
|
2654
2657
|
if (Qnil != roptions) {
|
2655
2658
|
if (Qnil != (rval = rb_hash_aref(roptions, sym_offset))) {
|
2656
2659
|
offset = FIX2INT(rval);
|
@@ -2701,8 +2704,17 @@ frb_sea_search_internal(FrtQuery *query, VALUE roptions, FrtSearcher *sea)
|
|
2701
2704
|
}
|
2702
2705
|
}
|
2703
2706
|
|
2704
|
-
|
2705
|
-
|
2707
|
+
FRT_TRY
|
2708
|
+
td = sea->search(sea, query, offset, limit, filter, sort, post_filter, 0);
|
2709
|
+
if (filter) frt_filt_deref(filter);
|
2710
|
+
default:
|
2711
|
+
ex_code = xcontext.excode;
|
2712
|
+
msg = xcontext.msg;
|
2713
|
+
FRT_HANDLED();
|
2714
|
+
FRT_XENDTRY
|
2715
|
+
|
2716
|
+
if (ex_code && msg) { frb_raise(ex_code, msg); }
|
2717
|
+
|
2706
2718
|
return td;
|
2707
2719
|
}
|
2708
2720
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
#include "frt_store.h"
|
2
2
|
#include "isomorfeus_ferret.h"
|
3
|
+
#include <time.h>
|
3
4
|
|
4
5
|
static ID id_ref_cnt;
|
5
6
|
VALUE cLock;
|
@@ -70,13 +71,26 @@ frb_lock_obtain(int argc, VALUE *argv, VALUE self)
|
|
70
71
|
int timeout = 1;
|
71
72
|
FrtLock *lock;
|
72
73
|
GET_LOCK(lock, self);
|
74
|
+
bool got_lock = false;
|
75
|
+
bool got_timeout = false;
|
76
|
+
time_t end_t;
|
73
77
|
|
74
78
|
if (rb_scan_args(argc, argv, "01", &rtimeout) > 0) {
|
75
79
|
timeout = FIX2INT(rtimeout);
|
76
80
|
}
|
77
|
-
|
78
|
-
(
|
79
|
-
|
81
|
+
end_t = time(NULL) + timeout;
|
82
|
+
if (lock->obtain(lock)) {
|
83
|
+
got_lock = true;
|
84
|
+
}
|
85
|
+
while (!got_lock && !got_timeout) {
|
86
|
+
frt_micro_sleep(10000);
|
87
|
+
if (lock->obtain(lock)) {
|
88
|
+
got_lock = true;
|
89
|
+
} else if (time(NULL) >= end_t) {
|
90
|
+
got_timeout = true;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
if (!got_lock) {
|
80
94
|
rb_raise(cLockError, "could not obtain lock: #%s", lock->name);
|
81
95
|
}
|
82
96
|
return Qtrue;
|
@@ -103,11 +117,26 @@ frb_lock_while_locked(int argc, VALUE *argv, VALUE self)
|
|
103
117
|
int timeout = 1;
|
104
118
|
FrtLock *lock;
|
105
119
|
GET_LOCK(lock, self);
|
120
|
+
bool got_lock = false;
|
121
|
+
bool got_timeout = false;
|
122
|
+
time_t end_t;
|
123
|
+
|
106
124
|
if (rb_scan_args(argc, argv, "01", &rtimeout) > 0) {
|
107
125
|
timeout = FIX2INT(rtimeout);
|
108
126
|
}
|
109
|
-
(
|
110
|
-
if (
|
127
|
+
end_t = time(NULL) + timeout;
|
128
|
+
if (lock->obtain(lock)) {
|
129
|
+
got_lock = true;
|
130
|
+
}
|
131
|
+
while (!got_lock && !got_timeout) {
|
132
|
+
frt_micro_sleep(10000);
|
133
|
+
if (lock->obtain(lock)) {
|
134
|
+
got_lock = true;
|
135
|
+
} else if (time(NULL) >= end_t) {
|
136
|
+
got_timeout = true;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
if (!got_lock) {
|
111
140
|
rb_raise(cLockError, "could not obtain lock: #%s", lock->name);
|
112
141
|
}
|
113
142
|
rb_yield(Qnil);
|
@@ -236,7 +236,11 @@ Metrowerks:
|
|
236
236
|
#endif
|
237
237
|
|
238
238
|
#if defined __GNUC__
|
239
|
-
#
|
239
|
+
# if defined __MINGW32__
|
240
|
+
# define POSH_COMPILER_STRING "MingW Gnu GCC"
|
241
|
+
# else
|
242
|
+
# define POSH_COMPILER_STRING "Gnu GCC"
|
243
|
+
# endif
|
240
244
|
# define POSH_COMPILER_GCC 1
|
241
245
|
#endif
|
242
246
|
|
@@ -307,9 +311,13 @@ Metrowerks:
|
|
307
311
|
|
308
312
|
#if defined __MINGW32__
|
309
313
|
# define POSH_OS_MINGW 1
|
310
|
-
# define POSH_OS_STRING "MinGW"
|
311
314
|
# if defined _WIN64
|
312
315
|
# define POSH_OS_WIN64 1
|
316
|
+
# define POSH_OS_STRING "Win64"
|
317
|
+
# elif defined _WIN32
|
318
|
+
# define POSH_OS_STRING "Win32"
|
319
|
+
# else
|
320
|
+
# define POSH_OS_STRING "MinGW"
|
313
321
|
# endif
|
314
322
|
#endif
|
315
323
|
|
@@ -474,7 +482,7 @@ Metrowerks:
|
|
474
482
|
# define POSH_CPU_SPARC 1
|
475
483
|
#endif
|
476
484
|
|
477
|
-
#if defined ARM || defined __arm__ || defined _ARM || __aarch64__
|
485
|
+
#if defined ARM || defined __arm__ || defined _ARM || defined __aarch64__
|
478
486
|
# define POSH_CPU_STRONGARM 1
|
479
487
|
# define POSH_CPU_STRING "ARM"
|
480
488
|
#endif
|
@@ -690,16 +698,6 @@ typedef unsigned long long posh_u64_t;
|
|
690
698
|
# define POSH_I64_PRINTF_PREFIX "ll"
|
691
699
|
#endif
|
692
700
|
|
693
|
-
/* hack */
|
694
|
-
#ifdef __MINGW32__
|
695
|
-
#undef POSH_I64
|
696
|
-
#undef POSH_U64
|
697
|
-
#undef POSH_I64_PRINTF_PREFIX
|
698
|
-
#define POSH_I64( x ) ((posh_i64_t)x)
|
699
|
-
#define POSH_U64( x ) ((posh_u64_t)x)
|
700
|
-
#define POSH_I64_PRINTF_PREFIX "I64"
|
701
|
-
#endif
|
702
|
-
|
703
701
|
/** Minimum value for a 64-bit signed integer */
|
704
702
|
#define POSH_I64_MIN POSH_I64(0x8000000000000000)
|
705
703
|
/** Maximum value for a 64-bit signed integer */
|
@@ -965,9 +963,3 @@ extern posh_i64_t POSH_ReadI64FromBig( const void *src );
|
|
965
963
|
# endif /* POSH_64BIT_INTEGER */
|
966
964
|
|
967
965
|
#endif
|
968
|
-
|
969
|
-
#ifdef __cplusplus
|
970
|
-
}
|
971
|
-
#endif
|
972
|
-
|
973
|
-
|