eventmachine 1.0.0.beta.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.gitignore +16 -0
  2. data/Gemfile +1 -0
  3. data/README +81 -0
  4. data/Rakefile +11 -0
  5. data/docs/COPYING +60 -0
  6. data/docs/ChangeLog +211 -0
  7. data/docs/DEFERRABLES +246 -0
  8. data/docs/EPOLL +141 -0
  9. data/docs/GNU +281 -0
  10. data/docs/INSTALL +13 -0
  11. data/docs/KEYBOARD +42 -0
  12. data/docs/LEGAL +25 -0
  13. data/docs/LIGHTWEIGHT_CONCURRENCY +130 -0
  14. data/docs/PURE_RUBY +75 -0
  15. data/docs/RELEASE_NOTES +94 -0
  16. data/docs/SMTP +4 -0
  17. data/docs/SPAWNED_PROCESSES +148 -0
  18. data/docs/TODO +8 -0
  19. data/eventmachine.gemspec +33 -0
  20. data/examples/ex_channel.rb +43 -0
  21. data/examples/ex_queue.rb +2 -0
  22. data/examples/ex_tick_loop_array.rb +15 -0
  23. data/examples/ex_tick_loop_counter.rb +32 -0
  24. data/examples/helper.rb +2 -0
  25. data/ext/binder.cpp +124 -0
  26. data/ext/binder.h +46 -0
  27. data/ext/cmain.cpp +838 -0
  28. data/ext/ed.cpp +1884 -0
  29. data/ext/ed.h +418 -0
  30. data/ext/em.cpp +2348 -0
  31. data/ext/em.h +228 -0
  32. data/ext/eventmachine.h +123 -0
  33. data/ext/extconf.rb +157 -0
  34. data/ext/fastfilereader/extconf.rb +85 -0
  35. data/ext/fastfilereader/mapper.cpp +214 -0
  36. data/ext/fastfilereader/mapper.h +59 -0
  37. data/ext/fastfilereader/rubymain.cpp +127 -0
  38. data/ext/kb.cpp +79 -0
  39. data/ext/page.cpp +107 -0
  40. data/ext/page.h +51 -0
  41. data/ext/pipe.cpp +347 -0
  42. data/ext/project.h +155 -0
  43. data/ext/rubymain.cpp +1200 -0
  44. data/ext/ssl.cpp +460 -0
  45. data/ext/ssl.h +94 -0
  46. data/java/.classpath +8 -0
  47. data/java/.project +17 -0
  48. data/java/src/com/rubyeventmachine/EmReactor.java +571 -0
  49. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  50. data/java/src/com/rubyeventmachine/EventableChannel.java +69 -0
  51. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -0
  52. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -0
  53. data/lib/em/buftok.rb +138 -0
  54. data/lib/em/callback.rb +26 -0
  55. data/lib/em/channel.rb +57 -0
  56. data/lib/em/connection.rb +569 -0
  57. data/lib/em/deferrable.rb +206 -0
  58. data/lib/em/file_watch.rb +54 -0
  59. data/lib/em/future.rb +61 -0
  60. data/lib/em/iterator.rb +270 -0
  61. data/lib/em/messages.rb +66 -0
  62. data/lib/em/process_watch.rb +44 -0
  63. data/lib/em/processes.rb +119 -0
  64. data/lib/em/protocols.rb +36 -0
  65. data/lib/em/protocols/header_and_content.rb +138 -0
  66. data/lib/em/protocols/httpclient.rb +268 -0
  67. data/lib/em/protocols/httpclient2.rb +590 -0
  68. data/lib/em/protocols/line_and_text.rb +125 -0
  69. data/lib/em/protocols/line_protocol.rb +28 -0
  70. data/lib/em/protocols/linetext2.rb +161 -0
  71. data/lib/em/protocols/memcache.rb +323 -0
  72. data/lib/em/protocols/object_protocol.rb +45 -0
  73. data/lib/em/protocols/postgres3.rb +247 -0
  74. data/lib/em/protocols/saslauth.rb +175 -0
  75. data/lib/em/protocols/smtpclient.rb +357 -0
  76. data/lib/em/protocols/smtpserver.rb +640 -0
  77. data/lib/em/protocols/socks4.rb +66 -0
  78. data/lib/em/protocols/stomp.rb +200 -0
  79. data/lib/em/protocols/tcptest.rb +53 -0
  80. data/lib/em/pure_ruby.rb +1013 -0
  81. data/lib/em/queue.rb +62 -0
  82. data/lib/em/spawnable.rb +85 -0
  83. data/lib/em/streamer.rb +130 -0
  84. data/lib/em/tick_loop.rb +85 -0
  85. data/lib/em/timers.rb +57 -0
  86. data/lib/em/version.rb +3 -0
  87. data/lib/eventmachine.rb +1548 -0
  88. data/lib/jeventmachine.rb +258 -0
  89. data/lib/rubyeventmachine.rb +2 -0
  90. data/setup.rb +1585 -0
  91. data/tasks/cpp.rake_example +77 -0
  92. data/tasks/doc.rake +30 -0
  93. data/tasks/package.rake +85 -0
  94. data/tasks/test.rake +6 -0
  95. data/tests/client.crt +31 -0
  96. data/tests/client.key +51 -0
  97. data/tests/test_attach.rb +136 -0
  98. data/tests/test_basic.rb +249 -0
  99. data/tests/test_channel.rb +64 -0
  100. data/tests/test_connection_count.rb +35 -0
  101. data/tests/test_defer.rb +49 -0
  102. data/tests/test_deferrable.rb +35 -0
  103. data/tests/test_epoll.rb +160 -0
  104. data/tests/test_error_handler.rb +35 -0
  105. data/tests/test_errors.rb +82 -0
  106. data/tests/test_exc.rb +55 -0
  107. data/tests/test_file_watch.rb +49 -0
  108. data/tests/test_futures.rb +198 -0
  109. data/tests/test_get_sock_opt.rb +30 -0
  110. data/tests/test_handler_check.rb +37 -0
  111. data/tests/test_hc.rb +190 -0
  112. data/tests/test_httpclient.rb +227 -0
  113. data/tests/test_httpclient2.rb +154 -0
  114. data/tests/test_inactivity_timeout.rb +50 -0
  115. data/tests/test_kb.rb +60 -0
  116. data/tests/test_ltp.rb +190 -0
  117. data/tests/test_ltp2.rb +317 -0
  118. data/tests/test_next_tick.rb +133 -0
  119. data/tests/test_object_protocol.rb +37 -0
  120. data/tests/test_pause.rb +70 -0
  121. data/tests/test_pending_connect_timeout.rb +48 -0
  122. data/tests/test_process_watch.rb +50 -0
  123. data/tests/test_processes.rb +128 -0
  124. data/tests/test_proxy_connection.rb +144 -0
  125. data/tests/test_pure.rb +134 -0
  126. data/tests/test_queue.rb +44 -0
  127. data/tests/test_running.rb +42 -0
  128. data/tests/test_sasl.rb +72 -0
  129. data/tests/test_send_file.rb +251 -0
  130. data/tests/test_servers.rb +76 -0
  131. data/tests/test_smtpclient.rb +83 -0
  132. data/tests/test_smtpserver.rb +85 -0
  133. data/tests/test_spawn.rb +322 -0
  134. data/tests/test_ssl_args.rb +79 -0
  135. data/tests/test_ssl_methods.rb +50 -0
  136. data/tests/test_ssl_verify.rb +82 -0
  137. data/tests/test_tick_loop.rb +59 -0
  138. data/tests/test_timers.rb +160 -0
  139. data/tests/test_ud.rb +36 -0
  140. data/tests/testem.rb +31 -0
  141. metadata +240 -0
@@ -0,0 +1,228 @@
1
+ /*****************************************************************************
2
+
3
+ $Id$
4
+
5
+ File: em.h
6
+ Date: 06Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+ #ifndef __EventMachine__H_
21
+ #define __EventMachine__H_
22
+
23
+ #ifdef BUILD_FOR_RUBY
24
+ #include <ruby.h>
25
+ #define EmSelect rb_thread_select
26
+
27
+ #if defined(HAVE_RBTRAP)
28
+ #include <rubysig.h>
29
+ #elif defined(HAVE_RB_THREAD_CHECK_INTS)
30
+ extern "C" {
31
+ void rb_enable_interrupt(void);
32
+ void rb_disable_interrupt(void);
33
+ }
34
+
35
+ #define TRAP_BEG rb_enable_interrupt()
36
+ #define TRAP_END do { rb_disable_interrupt(); rb_thread_check_ints(); } while(0)
37
+ #else
38
+ #define TRAP_BEG
39
+ #define TRAP_END
40
+ #endif
41
+
42
+ // 1.9.0 compat
43
+ #ifndef RUBY_UBF_IO
44
+ #define RUBY_UBF_IO RB_UBF_DFL
45
+ #endif
46
+ #else
47
+ #define EmSelect select
48
+ #endif
49
+
50
+ class EventableDescriptor;
51
+ class InotifyDescriptor;
52
+
53
+
54
+ /********************
55
+ class EventMachine_t
56
+ ********************/
57
+
58
+ class EventMachine_t
59
+ {
60
+ public:
61
+ static int GetMaxTimerCount();
62
+ static void SetMaxTimerCount (int);
63
+
64
+ public:
65
+ EventMachine_t (EMCallback);
66
+ virtual ~EventMachine_t();
67
+
68
+ void Run();
69
+ void ScheduleHalt();
70
+ void SignalLoopBreaker();
71
+ const unsigned long InstallOneshotTimer (int);
72
+ const unsigned long ConnectToServer (const char *, int, const char *, int);
73
+ const unsigned long ConnectToUnixServer (const char *);
74
+
75
+ const unsigned long CreateTcpServer (const char *, int);
76
+ const unsigned long OpenDatagramSocket (const char *, int);
77
+ const unsigned long CreateUnixDomainServer (const char*);
78
+ const unsigned long OpenKeyboard();
79
+ //const char *Popen (const char*, const char*);
80
+ const unsigned long Socketpair (char* const*);
81
+
82
+ void Add (EventableDescriptor*);
83
+ void Modify (EventableDescriptor*);
84
+
85
+ const unsigned long AttachFD (int, bool);
86
+ int DetachFD (EventableDescriptor*);
87
+
88
+ void ArmKqueueWriter (EventableDescriptor*);
89
+ void ArmKqueueReader (EventableDescriptor*);
90
+
91
+ void SetTimerQuantum (int);
92
+ static void SetuidString (const char*);
93
+ static int SetRlimitNofile (int);
94
+
95
+ pid_t SubprocessPid;
96
+ int SubprocessExitStatus;
97
+
98
+ int GetConnectionCount();
99
+ float GetHeartbeatInterval();
100
+ int SetHeartbeatInterval(float);
101
+
102
+ const unsigned long WatchFile (const char*);
103
+ void UnwatchFile (int);
104
+ void UnwatchFile (const unsigned long);
105
+
106
+ #ifdef HAVE_KQUEUE
107
+ void _HandleKqueueFileEvent (struct kevent*);
108
+ void _RegisterKqueueFileEvent(int);
109
+ #endif
110
+
111
+ const unsigned long WatchPid (int);
112
+ void UnwatchPid (int);
113
+ void UnwatchPid (const unsigned long);
114
+
115
+ #ifdef HAVE_KQUEUE
116
+ void _HandleKqueuePidEvent (struct kevent*);
117
+ #endif
118
+
119
+ uint64_t GetCurrentLoopTime() { return MyCurrentLoopTime; }
120
+
121
+ // Temporary:
122
+ void _UseEpoll();
123
+ void _UseKqueue();
124
+
125
+ bool UsingKqueue() { return bKqueue; }
126
+ bool UsingEpoll() { return bEpoll; }
127
+
128
+ void QueueHeartbeat(EventableDescriptor*);
129
+ void ClearHeartbeat(uint64_t);
130
+
131
+ uint64_t GetRealTime();
132
+
133
+ private:
134
+ bool _RunOnce();
135
+ bool _RunTimers();
136
+ void _UpdateTime();
137
+ void _AddNewDescriptors();
138
+ void _ModifyDescriptors();
139
+ void _InitializeLoopBreaker();
140
+ void _CleanupSockets();
141
+
142
+ bool _RunSelectOnce();
143
+ bool _RunEpollOnce();
144
+ bool _RunKqueueOnce();
145
+
146
+ void _ModifyEpollEvent (EventableDescriptor*);
147
+ void _DispatchHeartbeats();
148
+ timeval _TimeTilNextEvent();
149
+ void _CleanBadDescriptors();
150
+
151
+ public:
152
+ void _ReadLoopBreaker();
153
+ void _ReadInotifyEvents();
154
+
155
+ private:
156
+ enum {
157
+ MaxEpollDescriptors = 64*1024,
158
+ MaxEvents = 4096
159
+ };
160
+ int HeartbeatInterval;
161
+ EMCallback EventCallback;
162
+
163
+ class Timer_t: public Bindable_t {
164
+ };
165
+
166
+ multimap<uint64_t, Timer_t> Timers;
167
+ multimap<uint64_t, EventableDescriptor*> Heartbeats;
168
+ map<int, Bindable_t*> Files;
169
+ map<int, Bindable_t*> Pids;
170
+ vector<EventableDescriptor*> Descriptors;
171
+ vector<EventableDescriptor*> NewDescriptors;
172
+ set<EventableDescriptor*> ModifiedDescriptors;
173
+
174
+ uint64_t NextHeartbeatTime;
175
+
176
+ int LoopBreakerReader;
177
+ int LoopBreakerWriter;
178
+ #ifdef OS_WIN32
179
+ struct sockaddr_in LoopBreakerTarget;
180
+ #endif
181
+
182
+ timeval Quantum;
183
+
184
+ uint64_t MyCurrentLoopTime;
185
+
186
+ #ifdef OS_WIN32
187
+ unsigned TickCountTickover;
188
+ unsigned LastTickCount;
189
+ #endif
190
+
191
+ private:
192
+ bool bTerminateSignalReceived;
193
+
194
+ bool bEpoll;
195
+ int epfd; // Epoll file-descriptor
196
+ #ifdef HAVE_EPOLL
197
+ struct epoll_event epoll_events [MaxEvents];
198
+ #endif
199
+
200
+ bool bKqueue;
201
+ int kqfd; // Kqueue file-descriptor
202
+ #ifdef HAVE_KQUEUE
203
+ struct kevent Karray [MaxEvents];
204
+ #endif
205
+
206
+ InotifyDescriptor *inotify; // pollable descriptor for our inotify instance
207
+ };
208
+
209
+
210
+ /*******************
211
+ struct SelectData_t
212
+ *******************/
213
+
214
+ struct SelectData_t
215
+ {
216
+ SelectData_t();
217
+
218
+ int _Select();
219
+
220
+ int maxsocket;
221
+ fd_set fdreads;
222
+ fd_set fdwrites;
223
+ fd_set fderrors;
224
+ timeval tv;
225
+ int nSockets;
226
+ };
227
+
228
+ #endif // __EventMachine__H_
@@ -0,0 +1,123 @@
1
+ /*****************************************************************************
2
+
3
+ $Id$
4
+
5
+ File: eventmachine.h
6
+ Date: 15Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+ #ifndef __EVMA_EventMachine__H_
21
+ #define __EVMA_EventMachine__H_
22
+
23
+ #if __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ enum { // Event names
28
+ EM_TIMER_FIRED = 100,
29
+ EM_CONNECTION_READ = 101,
30
+ EM_CONNECTION_UNBOUND = 102,
31
+ EM_CONNECTION_ACCEPTED = 103,
32
+ EM_CONNECTION_COMPLETED = 104,
33
+ EM_LOOPBREAK_SIGNAL = 105,
34
+ EM_CONNECTION_NOTIFY_READABLE = 106,
35
+ EM_CONNECTION_NOTIFY_WRITABLE = 107,
36
+ EM_SSL_HANDSHAKE_COMPLETED = 108,
37
+ EM_SSL_VERIFY = 109,
38
+ EM_PROXY_TARGET_UNBOUND = 110,
39
+ EM_PROXY_COMPLETED = 111
40
+
41
+ };
42
+
43
+ void evma_initialize_library (EMCallback);
44
+ void evma_run_machine();
45
+ void evma_release_library();
46
+ const unsigned long evma_install_oneshot_timer (int seconds);
47
+ const unsigned long evma_connect_to_server (const char *bind_addr, int bind_port, const char *server, int port);
48
+ const unsigned long evma_connect_to_unix_server (const char *server);
49
+
50
+ const unsigned long evma_attach_fd (int file_descriptor, int watch_mode);
51
+ int evma_detach_fd (const unsigned long binding);
52
+ int evma_get_file_descriptor (const unsigned long binding);
53
+ int evma_is_notify_readable (const unsigned long binding);
54
+ void evma_set_notify_readable (const unsigned long binding, int mode);
55
+ int evma_is_notify_writable (const unsigned long binding);
56
+ void evma_set_notify_writable (const unsigned long binding, int mode);
57
+
58
+ int evma_pause(const unsigned long binding);
59
+ int evma_is_paused(const unsigned long binding);
60
+ int evma_resume(const unsigned long binding);
61
+
62
+ void evma_stop_tcp_server (const unsigned long signature);
63
+ const unsigned long evma_create_tcp_server (const char *address, int port);
64
+ const unsigned long evma_create_unix_domain_server (const char *filename);
65
+ const unsigned long evma_open_datagram_socket (const char *server, int port);
66
+ const unsigned long evma_open_keyboard();
67
+ void evma_set_tls_parms (const unsigned long binding, const char *privatekey_filename, const char *certchain_filenane, int verify_peer);
68
+ void evma_start_tls (const unsigned long binding);
69
+
70
+ #ifdef WITH_SSL
71
+ X509 *evma_get_peer_cert (const unsigned long binding);
72
+ void evma_accept_ssl_peer (const unsigned long binding);
73
+ #endif
74
+
75
+ int evma_get_peername (const unsigned long binding, struct sockaddr*);
76
+ int evma_get_sockname (const unsigned long binding, struct sockaddr*);
77
+ int evma_get_subprocess_pid (const unsigned long binding, pid_t*);
78
+ int evma_get_subprocess_status (const unsigned long binding, int*);
79
+ int evma_get_connection_count();
80
+ int evma_send_data_to_connection (const unsigned long binding, const char *data, int data_length);
81
+ int evma_send_datagram (const unsigned long binding, const char *data, int data_length, const char *address, int port);
82
+ float evma_get_comm_inactivity_timeout (const unsigned long binding);
83
+ int evma_set_comm_inactivity_timeout (const unsigned long binding, float value);
84
+ float evma_get_pending_connect_timeout (const unsigned long binding);
85
+ int evma_set_pending_connect_timeout (const unsigned long binding, float value);
86
+ int evma_get_outbound_data_size (const unsigned long binding);
87
+ int evma_send_file_data_to_connection (const unsigned long binding, const char *filename);
88
+
89
+ void evma_close_connection (const unsigned long binding, int after_writing);
90
+ int evma_report_connection_error_status (const unsigned long binding);
91
+ void evma_signal_loopbreak();
92
+ void evma_set_timer_quantum (int);
93
+ int evma_get_max_timer_count();
94
+ void evma_set_max_timer_count (int);
95
+ void evma_setuid_string (const char *username);
96
+ void evma_stop_machine();
97
+ float evma_get_heartbeat_interval();
98
+ int evma_set_heartbeat_interval(float);
99
+
100
+ const unsigned long evma_popen (char * const*cmd_strings);
101
+
102
+ const unsigned long evma_watch_filename (const char *fname);
103
+ void evma_unwatch_filename (const unsigned long);
104
+
105
+ const unsigned long evma_watch_pid (int);
106
+ void evma_unwatch_pid (const unsigned long);
107
+
108
+ void evma_start_proxy(const unsigned long, const unsigned long, const unsigned long, const unsigned long);
109
+ void evma_stop_proxy(const unsigned long);
110
+
111
+ int evma_set_rlimit_nofile (int n_files);
112
+
113
+ void evma_set_epoll (int use);
114
+ void evma_set_kqueue (int use);
115
+
116
+ uint64_t evma_get_current_loop_time();
117
+ #if __cplusplus
118
+ }
119
+ #endif
120
+
121
+
122
+ #endif // __EventMachine__H_
123
+
@@ -0,0 +1,157 @@
1
+ require 'fileutils'
2
+ require 'mkmf'
3
+
4
+ def check_libs libs = [], fatal = false
5
+ libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) }
6
+ end
7
+
8
+ def check_heads heads = [], fatal = false
9
+ heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
10
+ end
11
+
12
+ def add_define(name)
13
+ $defs.push("-D#{name}")
14
+ end
15
+
16
+ ##
17
+ # OpenSSL:
18
+
19
+ # override append_library, so it actually appends (instead of prepending)
20
+ # this fixes issues with linking ssl, since libcrypto depends on symbols in libssl
21
+ def append_library(libs, lib)
22
+ libs + " " + format(LIBARG, lib)
23
+ end
24
+
25
+ def manual_ssl_config
26
+ ssl_libs_heads_args = {
27
+ :unix => [%w[ssl crypto], %w[openssl/ssl.h openssl/err.h]],
28
+ :mswin => [%w[ssleay32 libeay32], %w[openssl/ssl.h openssl/err.h]],
29
+ }
30
+
31
+ dc_flags = ['ssl']
32
+ dc_flags += ["#{ENV['OPENSSL']}/include", ENV['OPENSSL']] if /linux/ =~ RUBY_PLATFORM and ENV['OPENSSL']
33
+
34
+ libs, heads = case RUBY_PLATFORM
35
+ when /mswin/ ; ssl_libs_heads_args[:mswin]
36
+ else ssl_libs_heads_args[:unix]
37
+ end
38
+ dir_config(*dc_flags)
39
+ check_libs(libs) and check_heads(heads)
40
+ end
41
+
42
+ if ENV['CROSS_COMPILING']
43
+ openssl_dir = File.expand_path("~/.rake-compiler/builds/openssl-1.0.0a/")
44
+ if File.exists?(openssl_dir)
45
+ FileUtils.mkdir_p Dir.pwd+"/openssl/"
46
+ FileUtils.cp Dir[openssl_dir+"/include/openssl/*.h"], Dir.pwd+"/openssl/", :verbose => true
47
+ FileUtils.cp Dir[openssl_dir+"/lib*.a"], Dir.pwd, :verbose => true
48
+ $INCFLAGS << " -I#{Dir.pwd}" # for the openssl headers
49
+ else
50
+ STDERR.puts
51
+ STDERR.puts "**************************************************************************************"
52
+ STDERR.puts "**** Cross-compiled OpenSSL not found"
53
+ STDERR.puts "**** Run: hg clone http://bitbucket.org/ged/ruby-pg && cd ruby-pg && rake openssl_libs"
54
+ STDERR.puts "**************************************************************************************"
55
+ STDERR.puts
56
+ end
57
+ end
58
+
59
+ # Try to use pkg_config first, fixes #73
60
+ if pkg_config('openssl') || manual_ssl_config
61
+ add_define "WITH_SSL"
62
+ else
63
+ add_define "WITHOUT_SSL"
64
+ end
65
+
66
+ add_define 'BUILD_FOR_RUBY'
67
+ add_define 'HAVE_RBTRAP' if have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h'])
68
+ add_define "HAVE_TBR" if have_func('rb_thread_blocking_region')# and have_macro('RUBY_UBF_IO', 'ruby.h')
69
+ add_define "HAVE_INOTIFY" if inotify = have_func('inotify_init', 'sys/inotify.h')
70
+ add_define "HAVE_OLD_INOTIFY" if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h')
71
+ add_define 'HAVE_WRITEV' if have_func('writev', 'sys/uio.h')
72
+
73
+ have_func('rb_thread_check_ints')
74
+ have_func('rb_time_new')
75
+
76
+ # Minor platform details between *nix and Windows:
77
+
78
+ if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/
79
+ GNU_CHAIN = $1 == 'mingw'
80
+ OS_WIN32 = true
81
+ add_define "OS_WIN32"
82
+ else
83
+ GNU_CHAIN = true
84
+ OS_UNIX = true
85
+ add_define 'OS_UNIX'
86
+
87
+ add_define "HAVE_KQUEUE" if have_header("sys/event.h") and have_header("sys/queue.h")
88
+ end
89
+
90
+ # Main platform invariances:
91
+
92
+ case RUBY_PLATFORM
93
+ when /mswin32/, /mingw32/, /bccwin32/
94
+ check_heads(%w[windows.h winsock.h], true)
95
+ check_libs(%w[kernel32 rpcrt4 gdi32], true)
96
+
97
+ if GNU_CHAIN
98
+ CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++"
99
+ else
100
+ $defs.push "-EHs"
101
+ $defs.push "-GR"
102
+ end
103
+
104
+ when /solaris/
105
+ add_define 'OS_SOLARIS8'
106
+ check_libs(%w[nsl socket], true)
107
+
108
+ if CONFIG['CC'] == 'cc' and `cc -flags 2>&1` =~ /Sun/ # detect SUNWspro compiler
109
+ # SUN CHAIN
110
+ add_define 'CC_SUNWspro'
111
+ $preload = ["\nCXX = CC"] # hack a CXX= line into the makefile
112
+ $CFLAGS = CONFIG['CFLAGS'] = "-KPIC"
113
+ CONFIG['CCDLFLAGS'] = "-KPIC"
114
+ CONFIG['LDSHARED'] = "$(CXX) -G -KPIC -lCstd"
115
+ else
116
+ # GNU CHAIN
117
+ # on Unix we need a g++ link, not gcc.
118
+ CONFIG['LDSHARED'] = "$(CXX) -shared"
119
+ end
120
+
121
+ when /openbsd/
122
+ # OpenBSD branch contributed by Guillaume Sellier.
123
+
124
+ # on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs
125
+ CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC"
126
+ CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC"
127
+
128
+ when /darwin/
129
+ # on Unix we need a g++ link, not gcc.
130
+ # Ff line contributed by Daniel Harple.
131
+ CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')
132
+
133
+ when /linux/
134
+ add_define 'HAVE_EPOLL' if have_func('epoll_create', 'sys/epoll.h')
135
+
136
+ # on Unix we need a g++ link, not gcc.
137
+ CONFIG['LDSHARED'] = "$(CXX) -shared"
138
+
139
+ when /aix/
140
+ CONFIG['LDSHARED'] = "$(CXX) -shared -Wl,-G -Wl,-brtl"
141
+
142
+ else
143
+ # on Unix we need a g++ link, not gcc.
144
+ CONFIG['LDSHARED'] = "$(CXX) -shared"
145
+ end
146
+
147
+
148
+ # solaris c++ compiler doesn't have make_pair()
149
+ TRY_LINK.sub!('$(CC)', '$(CXX)')
150
+ add_define 'HAVE_MAKE_PAIR' if try_link(<<SRC, '-lstdc++')
151
+ #include <utility>
152
+ using namespace std;
153
+ int main(){ pair<int,int> tuple = make_pair(1,2); }
154
+ SRC
155
+ TRY_LINK.sub!('$(CXX)', '$(CC)')
156
+
157
+ create_makefile "rubyeventmachine"