io-event-machty 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/ext/IO_Event.bundle +0 -0
- data/ext/Makefile +268 -0
- data/ext/event.o +0 -0
- data/ext/extconf.h +10 -0
- data/ext/extconf.rb +64 -0
- data/ext/interrupt.o +0 -0
- data/ext/io/event/event.c +52 -0
- data/ext/io/event/event.h +39 -0
- data/ext/io/event/interrupt.c +108 -0
- data/ext/io/event/interrupt.h +47 -0
- data/ext/io/event/selector/epoll.c +657 -0
- data/ext/io/event/selector/epoll.h +27 -0
- data/ext/io/event/selector/kqueue.c +742 -0
- data/ext/io/event/selector/kqueue.h +27 -0
- data/ext/io/event/selector/pidfd.c +36 -0
- data/ext/io/event/selector/selector.c +294 -0
- data/ext/io/event/selector/selector.h +130 -0
- data/ext/io/event/selector/uring.c +722 -0
- data/ext/io/event/selector/uring.h +27 -0
- data/ext/kqueue.o +0 -0
- data/ext/mkmf.log +273 -0
- data/ext/selector.o +0 -0
- data/lib/io/event/debug/selector.rb +161 -0
- data/lib/io/event/interrupt.rb +57 -0
- data/lib/io/event/selector/select.rb +270 -0
- data/lib/io/event/selector.rb +54 -0
- data/lib/io/event/version.rb +23 -0
- data/lib/io/event.rb +29 -0
- metadata +127 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
// Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
//
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
8
|
+
// furnished to do so, subject to the following conditions:
|
9
|
+
//
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
11
|
+
// all copies or substantial portions of the Software.
|
12
|
+
//
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
// THE SOFTWARE.
|
20
|
+
|
21
|
+
#pragma once
|
22
|
+
|
23
|
+
#include <ruby.h>
|
24
|
+
|
25
|
+
#define IO_EVENT_SELECTOR_URING
|
26
|
+
|
27
|
+
void Init_IO_Event_Selector_URing(VALUE IO_Event_Selector);
|
data/ext/kqueue.o
ADDED
Binary file
|
data/ext/mkmf.log
ADDED
@@ -0,0 +1,273 @@
|
|
1
|
+
have_func: checking for rb_ext_ractor_safe()... -------------------- yes
|
2
|
+
|
3
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
4
|
+
checked program was:
|
5
|
+
/* begin */
|
6
|
+
1: #include "ruby.h"
|
7
|
+
2:
|
8
|
+
3: int main(int argc, char **argv)
|
9
|
+
4: {
|
10
|
+
5: return !!argv[argc];
|
11
|
+
6: }
|
12
|
+
/* end */
|
13
|
+
|
14
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
15
|
+
checked program was:
|
16
|
+
/* begin */
|
17
|
+
1: #include "ruby.h"
|
18
|
+
2:
|
19
|
+
3: /*top*/
|
20
|
+
4: extern int t(void);
|
21
|
+
5: int main(int argc, char **argv)
|
22
|
+
6: {
|
23
|
+
7: if (argc > 1000000) {
|
24
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
25
|
+
9: printf("%d", (*tp)());
|
26
|
+
10: }
|
27
|
+
11:
|
28
|
+
12: return !!argv[argc];
|
29
|
+
13: }
|
30
|
+
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_ext_ractor_safe; return !p; }
|
31
|
+
/* end */
|
32
|
+
|
33
|
+
--------------------
|
34
|
+
|
35
|
+
have_func: checking for &rb_fiber_transfer()... -------------------- yes
|
36
|
+
|
37
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
38
|
+
checked program was:
|
39
|
+
/* begin */
|
40
|
+
1: #include "ruby.h"
|
41
|
+
2:
|
42
|
+
3: /*top*/
|
43
|
+
4: extern int t(void);
|
44
|
+
5: int main(int argc, char **argv)
|
45
|
+
6: {
|
46
|
+
7: if (argc > 1000000) {
|
47
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
48
|
+
9: printf("%d", (*tp)());
|
49
|
+
10: }
|
50
|
+
11:
|
51
|
+
12: return !!argv[argc];
|
52
|
+
13: }
|
53
|
+
14: int t(void) { const volatile void *volatile p; p = (const volatile void *)&rb_fiber_transfer; return !p; }
|
54
|
+
/* end */
|
55
|
+
|
56
|
+
--------------------
|
57
|
+
|
58
|
+
have_library: checking for -luring... -------------------- no
|
59
|
+
|
60
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc -luring "
|
61
|
+
ld: library not found for -luring
|
62
|
+
clang: error: linker command failed with exit code 1 (use -v to see invocation)
|
63
|
+
checked program was:
|
64
|
+
/* begin */
|
65
|
+
1: #include "ruby.h"
|
66
|
+
2:
|
67
|
+
3: /*top*/
|
68
|
+
4: extern int t(void);
|
69
|
+
5: int main(int argc, char **argv)
|
70
|
+
6: {
|
71
|
+
7: if (argc > 1000000) {
|
72
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
73
|
+
9: printf("%d", (*tp)());
|
74
|
+
10: }
|
75
|
+
11:
|
76
|
+
12: return !!argv[argc];
|
77
|
+
13: }
|
78
|
+
14:
|
79
|
+
15: int t(void) { ; return 0; }
|
80
|
+
/* end */
|
81
|
+
|
82
|
+
--------------------
|
83
|
+
|
84
|
+
have_header: checking for sys/epoll.h... -------------------- no
|
85
|
+
|
86
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 -c conftest.c"
|
87
|
+
conftest.c:3:10: fatal error: 'sys/epoll.h' file not found
|
88
|
+
#include <sys/epoll.h>
|
89
|
+
^~~~~~~~~~~~~
|
90
|
+
1 error generated.
|
91
|
+
checked program was:
|
92
|
+
/* begin */
|
93
|
+
1: #include "ruby.h"
|
94
|
+
2:
|
95
|
+
3: #include <sys/epoll.h>
|
96
|
+
/* end */
|
97
|
+
|
98
|
+
--------------------
|
99
|
+
|
100
|
+
have_header: checking for sys/event.h... -------------------- yes
|
101
|
+
|
102
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 -c conftest.c"
|
103
|
+
checked program was:
|
104
|
+
/* begin */
|
105
|
+
1: #include "ruby.h"
|
106
|
+
2:
|
107
|
+
3: #include <sys/event.h>
|
108
|
+
/* end */
|
109
|
+
|
110
|
+
--------------------
|
111
|
+
|
112
|
+
have_header: checking for sys/eventfd.h... -------------------- no
|
113
|
+
|
114
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 -c conftest.c"
|
115
|
+
conftest.c:3:10: fatal error: 'sys/eventfd.h' file not found
|
116
|
+
#include <sys/eventfd.h>
|
117
|
+
^~~~~~~~~~~~~~~
|
118
|
+
1 error generated.
|
119
|
+
checked program was:
|
120
|
+
/* begin */
|
121
|
+
1: #include "ruby.h"
|
122
|
+
2:
|
123
|
+
3: #include <sys/eventfd.h>
|
124
|
+
/* end */
|
125
|
+
|
126
|
+
--------------------
|
127
|
+
|
128
|
+
have_func: checking for rb_io_descriptor()... -------------------- yes
|
129
|
+
|
130
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
131
|
+
conftest.c:14:57: error: use of undeclared identifier 'rb_io_descriptor'
|
132
|
+
int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_io_descriptor; return !p; }
|
133
|
+
^
|
134
|
+
1 error generated.
|
135
|
+
checked program was:
|
136
|
+
/* begin */
|
137
|
+
1: #include "ruby.h"
|
138
|
+
2:
|
139
|
+
3: /*top*/
|
140
|
+
4: extern int t(void);
|
141
|
+
5: int main(int argc, char **argv)
|
142
|
+
6: {
|
143
|
+
7: if (argc > 1000000) {
|
144
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
145
|
+
9: printf("%d", (*tp)());
|
146
|
+
10: }
|
147
|
+
11:
|
148
|
+
12: return !!argv[argc];
|
149
|
+
13: }
|
150
|
+
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_io_descriptor; return !p; }
|
151
|
+
/* end */
|
152
|
+
|
153
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
154
|
+
checked program was:
|
155
|
+
/* begin */
|
156
|
+
1: #include "ruby.h"
|
157
|
+
2:
|
158
|
+
3: /*top*/
|
159
|
+
4: extern int t(void);
|
160
|
+
5: int main(int argc, char **argv)
|
161
|
+
6: {
|
162
|
+
7: if (argc > 1000000) {
|
163
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
164
|
+
9: printf("%d", (*tp)());
|
165
|
+
10: }
|
166
|
+
11:
|
167
|
+
12: return !!argv[argc];
|
168
|
+
13: }
|
169
|
+
14: extern void rb_io_descriptor();
|
170
|
+
15: int t(void) { rb_io_descriptor(); return 0; }
|
171
|
+
/* end */
|
172
|
+
|
173
|
+
--------------------
|
174
|
+
|
175
|
+
have_func: checking for &rb_process_status_wait()... -------------------- no
|
176
|
+
|
177
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
178
|
+
conftest.c:14:76: error: use of undeclared identifier 'rb_process_status_wait'
|
179
|
+
int t(void) { const volatile void *volatile p; p = (const volatile void *)&rb_process_status_wait; return !p; }
|
180
|
+
^
|
181
|
+
1 error generated.
|
182
|
+
checked program was:
|
183
|
+
/* begin */
|
184
|
+
1: #include "ruby.h"
|
185
|
+
2:
|
186
|
+
3: /*top*/
|
187
|
+
4: extern int t(void);
|
188
|
+
5: int main(int argc, char **argv)
|
189
|
+
6: {
|
190
|
+
7: if (argc > 1000000) {
|
191
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
192
|
+
9: printf("%d", (*tp)());
|
193
|
+
10: }
|
194
|
+
11:
|
195
|
+
12: return !!argv[argc];
|
196
|
+
13: }
|
197
|
+
14: int t(void) { const volatile void *volatile p; p = (const volatile void *)&rb_process_status_wait; return !p; }
|
198
|
+
/* end */
|
199
|
+
|
200
|
+
--------------------
|
201
|
+
|
202
|
+
have_func: checking for rb_fiber_current()... -------------------- yes
|
203
|
+
|
204
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
205
|
+
checked program was:
|
206
|
+
/* begin */
|
207
|
+
1: #include "ruby.h"
|
208
|
+
2:
|
209
|
+
3: /*top*/
|
210
|
+
4: extern int t(void);
|
211
|
+
5: int main(int argc, char **argv)
|
212
|
+
6: {
|
213
|
+
7: if (argc > 1000000) {
|
214
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
215
|
+
9: printf("%d", (*tp)());
|
216
|
+
10: }
|
217
|
+
11:
|
218
|
+
12: return !!argv[argc];
|
219
|
+
13: }
|
220
|
+
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_fiber_current; return !p; }
|
221
|
+
/* end */
|
222
|
+
|
223
|
+
--------------------
|
224
|
+
|
225
|
+
have_func: checking for &rb_fiber_raise()... -------------------- yes
|
226
|
+
|
227
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -o conftest -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 conftest.c -L. -L/Users/machty/.rubies/ruby-3.1.0/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib -lruby.3.1-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
228
|
+
checked program was:
|
229
|
+
/* begin */
|
230
|
+
1: #include "ruby.h"
|
231
|
+
2:
|
232
|
+
3: /*top*/
|
233
|
+
4: extern int t(void);
|
234
|
+
5: int main(int argc, char **argv)
|
235
|
+
6: {
|
236
|
+
7: if (argc > 1000000) {
|
237
|
+
8: int (* volatile tp)(void)=(int (*)(void))&t;
|
238
|
+
9: printf("%d", (*tp)());
|
239
|
+
10: }
|
240
|
+
11:
|
241
|
+
12: return !!argv[argc];
|
242
|
+
13: }
|
243
|
+
14: int t(void) { const volatile void *volatile p; p = (const volatile void *)&rb_fiber_raise; return !p; }
|
244
|
+
/* end */
|
245
|
+
|
246
|
+
--------------------
|
247
|
+
|
248
|
+
have_header: checking for ruby/io/buffer.h... -------------------- yes
|
249
|
+
|
250
|
+
DYLD_FALLBACK_LIBRARY_PATH=.:/Users/machty/.rubies/ruby-3.1.0/lib "clang -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/x86_64-darwin20 -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0/ruby/backward -I/Users/machty/.rubies/ruby-3.1.0/include/ruby-3.1.0 -I. -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -fdeclspec -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens -Wundef -pipe -Wall -std=c99 -c conftest.c"
|
251
|
+
checked program was:
|
252
|
+
/* begin */
|
253
|
+
1: #include "ruby.h"
|
254
|
+
2:
|
255
|
+
3: #include <ruby/io/buffer.h>
|
256
|
+
/* end */
|
257
|
+
|
258
|
+
--------------------
|
259
|
+
|
260
|
+
extconf.h is:
|
261
|
+
/* begin */
|
262
|
+
1: #ifndef EXTCONF_H
|
263
|
+
2: #define EXTCONF_H
|
264
|
+
3: #define HAVE_RB_EXT_RACTOR_SAFE 1
|
265
|
+
4: #define HAVE__RB_FIBER_TRANSFER 1
|
266
|
+
5: #define HAVE_SYS_EVENT_H 1
|
267
|
+
6: #define HAVE_RB_IO_DESCRIPTOR 1
|
268
|
+
7: #define HAVE_RB_FIBER_CURRENT 1
|
269
|
+
8: #define HAVE__RB_FIBER_RAISE 1
|
270
|
+
9: #define HAVE_RUBY_IO_BUFFER_H 1
|
271
|
+
10: #endif
|
272
|
+
/* end */
|
273
|
+
|
data/ext/selector.o
ADDED
Binary file
|
@@ -0,0 +1,161 @@
|
|
1
|
+
# Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
module IO::Event
|
22
|
+
module Debug
|
23
|
+
# Enforces the selector interface and delegates operations to a wrapped selector instance.
|
24
|
+
class Selector
|
25
|
+
def initialize(selector)
|
26
|
+
@selector = selector
|
27
|
+
|
28
|
+
@readable = {}
|
29
|
+
@writable = {}
|
30
|
+
@priority = {}
|
31
|
+
|
32
|
+
unless Fiber.current == selector.loop
|
33
|
+
Kernel::raise "Selector must be initialized on event loop fiber!"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def wakeup
|
38
|
+
@selector.wakeup
|
39
|
+
end
|
40
|
+
|
41
|
+
def close
|
42
|
+
if @selector.nil?
|
43
|
+
Kernel::raise "Selector already closed!"
|
44
|
+
end
|
45
|
+
|
46
|
+
@selector.close
|
47
|
+
@selector = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def transfer(fiber, *arguments)
|
51
|
+
@selector.transfer(fiber, *arguments)
|
52
|
+
end
|
53
|
+
|
54
|
+
def transfer(*arguments)
|
55
|
+
@selector.transfer(*arguments)
|
56
|
+
end
|
57
|
+
|
58
|
+
def resume(*arguments)
|
59
|
+
@selector.resume(*arguments)
|
60
|
+
end
|
61
|
+
|
62
|
+
def yield
|
63
|
+
@selector.yield
|
64
|
+
end
|
65
|
+
|
66
|
+
def push(fiber)
|
67
|
+
@selector.push(fiber)
|
68
|
+
end
|
69
|
+
|
70
|
+
def raise(fiber, *arguments)
|
71
|
+
@selector.raise(fiber, *arguments)
|
72
|
+
end
|
73
|
+
|
74
|
+
def ready?
|
75
|
+
@selector.ready?
|
76
|
+
end
|
77
|
+
|
78
|
+
def process_wait(*arguments)
|
79
|
+
@selector.process_wait(*arguments)
|
80
|
+
end
|
81
|
+
|
82
|
+
def io_wait(fiber, io, events)
|
83
|
+
register_readable(fiber, io, events)
|
84
|
+
end
|
85
|
+
|
86
|
+
if IO.const_defined?(:Buffer)
|
87
|
+
def io_read(fiber, io, buffer, length)
|
88
|
+
@selector.io_read(fiber, io, buffer, length)
|
89
|
+
end
|
90
|
+
|
91
|
+
def io_write(fiber, io, buffer, length)
|
92
|
+
@selector.io_write(fiber, io, buffer, length)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def select(duration = nil)
|
97
|
+
unless Fiber.current == @selector.loop
|
98
|
+
Kernel::raise "Selector must be run on event loop fiber!"
|
99
|
+
end
|
100
|
+
|
101
|
+
@selector.select(duration)
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def register_readable(fiber, io, events)
|
107
|
+
if (events & IO::READABLE) > 0
|
108
|
+
if @readable.key?(io)
|
109
|
+
Kernel::raise "Cannot wait for #{io} to become readable from multiple fibers."
|
110
|
+
end
|
111
|
+
|
112
|
+
begin
|
113
|
+
@readable[io] = fiber
|
114
|
+
|
115
|
+
register_writable(fiber, io, events)
|
116
|
+
ensure
|
117
|
+
@readable.delete(io)
|
118
|
+
end
|
119
|
+
else
|
120
|
+
register_writable(fiber, io, events)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def register_writable(fiber, io, events)
|
125
|
+
if (events & IO::WRITABLE) > 0
|
126
|
+
if @writable.key?(io)
|
127
|
+
Kernel::raise "Cannot wait for #{io} to become writable from multiple fibers."
|
128
|
+
end
|
129
|
+
|
130
|
+
begin
|
131
|
+
@writable[io] = fiber
|
132
|
+
|
133
|
+
register_priority(fiber, io, events)
|
134
|
+
ensure
|
135
|
+
@writable.delete(io)
|
136
|
+
end
|
137
|
+
else
|
138
|
+
register_priority(fiber, io, events)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def register_priority(fiber, io, events)
|
143
|
+
if (events & IO::PRIORITY) > 0
|
144
|
+
if @priority.key?(io)
|
145
|
+
Kernel::raise "Cannot wait for #{io} to become priority from multiple fibers."
|
146
|
+
end
|
147
|
+
|
148
|
+
begin
|
149
|
+
@priority[io] = fiber
|
150
|
+
|
151
|
+
@selector.io_wait(fiber, io, events)
|
152
|
+
ensure
|
153
|
+
@priority.delete(io)
|
154
|
+
end
|
155
|
+
else
|
156
|
+
@selector.io_wait(fiber, io, events)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
module IO::Event
|
22
|
+
# A thread safe synchronisation primative.
|
23
|
+
class Interrupt
|
24
|
+
def self.attach(selector)
|
25
|
+
self.new(selector)
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(selector)
|
29
|
+
@selector = selector
|
30
|
+
@input, @output = ::IO.pipe
|
31
|
+
|
32
|
+
@fiber = Fiber.new do
|
33
|
+
while true
|
34
|
+
if @selector.io_wait(@fiber, @input, IO::READABLE)
|
35
|
+
@input.read_nonblock(1)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
@fiber.transfer
|
41
|
+
end
|
42
|
+
|
43
|
+
# Send a sigle byte interrupt.
|
44
|
+
def signal
|
45
|
+
@output.write('.')
|
46
|
+
@output.flush
|
47
|
+
end
|
48
|
+
|
49
|
+
def close
|
50
|
+
@input.close
|
51
|
+
@output.close
|
52
|
+
# @fiber.raise(::Interrupt)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private_constant :Interrupt
|
57
|
+
end
|