eventmachine 0.12.8-x86-mswin32-60 → 0.12.10-x86-mswin32-60
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.
- data/.gitignore +14 -13
- data/Rakefile +374 -264
- data/eventmachine.gemspec +4 -5
- data/ext/binder.cpp +125 -126
- data/ext/binder.h +46 -48
- data/ext/cmain.cpp +184 -42
- data/ext/cplusplus.cpp +202 -202
- data/ext/ed.cpp +242 -81
- data/ext/ed.h +39 -22
- data/ext/em.cpp +127 -108
- data/ext/em.h +27 -18
- data/ext/emwin.cpp +3 -3
- data/ext/eventmachine.h +49 -38
- data/ext/eventmachine_cpp.h +96 -96
- data/ext/extconf.rb +147 -132
- data/ext/fastfilereader/extconf.rb +82 -76
- data/ext/project.h +151 -140
- data/ext/rubymain.cpp +222 -103
- data/ext/ssl.cpp +460 -460
- data/ext/ssl.h +94 -94
- data/java/src/com/rubyeventmachine/EmReactor.java +570 -423
- data/java/src/com/rubyeventmachine/EventableChannel.java +69 -57
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -171
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -244
- data/java/src/com/rubyeventmachine/{Application.java → application/Application.java} +194 -200
- data/java/src/com/rubyeventmachine/{Connection.java → application/Connection.java} +74 -74
- data/java/src/com/rubyeventmachine/{ConnectionFactory.java → application/ConnectionFactory.java} +36 -36
- data/java/src/com/rubyeventmachine/{DefaultConnectionFactory.java → application/DefaultConnectionFactory.java} +46 -46
- data/java/src/com/rubyeventmachine/{PeriodicTimer.java → application/PeriodicTimer.java} +38 -38
- data/java/src/com/rubyeventmachine/{Timer.java → application/Timer.java} +54 -54
- data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +109 -108
- data/java/src/com/rubyeventmachine/tests/ConnectTest.java +148 -146
- data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -53
- data/java/src/com/rubyeventmachine/tests/TestServers.java +75 -74
- data/java/src/com/rubyeventmachine/tests/TestTimers.java +90 -89
- data/lib/em/connection.rb +71 -12
- data/lib/em/deferrable.rb +191 -186
- data/lib/em/protocols.rb +36 -35
- data/lib/em/protocols/httpclient2.rb +590 -582
- data/lib/em/protocols/line_and_text.rb +125 -126
- data/lib/em/protocols/linetext2.rb +161 -160
- data/lib/em/protocols/object_protocol.rb +45 -39
- data/lib/em/protocols/smtpclient.rb +357 -331
- data/lib/em/protocols/socks4.rb +66 -0
- data/lib/em/queue.rb +60 -60
- data/lib/em/timers.rb +56 -55
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +125 -169
- data/lib/jeventmachine.rb +257 -142
- data/tasks/{cpp.rake → cpp.rake_example} +76 -76
- data/tests/test_attach.rb +125 -100
- data/tests/test_basic.rb +1 -2
- data/tests/test_connection_count.rb +34 -44
- data/tests/test_epoll.rb +0 -2
- data/tests/test_get_sock_opt.rb +30 -0
- data/tests/test_httpclient2.rb +3 -3
- data/tests/test_inactivity_timeout.rb +21 -1
- data/tests/test_ltp.rb +182 -188
- data/tests/test_next_tick.rb +0 -2
- data/tests/test_pause.rb +70 -0
- data/tests/test_pending_connect_timeout.rb +48 -0
- data/tests/test_ssl_args.rb +78 -67
- data/tests/test_timers.rb +162 -141
- metadata +13 -11
- data/tasks/project.rake +0 -79
- data/tasks/tests.rake +0 -193
data/ext/em.h
CHANGED
@@ -34,8 +34,16 @@ See the file COPYING for complete licensing information.
|
|
34
34
|
#include <ruby.h>
|
35
35
|
#define EmSelect rb_thread_select
|
36
36
|
|
37
|
-
#
|
37
|
+
#if defined(HAVE_RBTRAP)
|
38
38
|
#include <rubysig.h>
|
39
|
+
#elif defined(HAVE_RB_THREAD_CHECK_INTS)
|
40
|
+
extern "C" {
|
41
|
+
void rb_enable_interrupt(void);
|
42
|
+
void rb_disable_interrupt(void);
|
43
|
+
}
|
44
|
+
|
45
|
+
#define TRAP_BEG rb_enable_interrupt()
|
46
|
+
#define TRAP_END do { rb_disable_interrupt(); rb_thread_check_ints(); } while(0)
|
39
47
|
#else
|
40
48
|
#define TRAP_BEG
|
41
49
|
#define TRAP_END
|
@@ -74,28 +82,28 @@ class EventMachine_t
|
|
74
82
|
static void SetMaxTimerCount (int);
|
75
83
|
|
76
84
|
public:
|
77
|
-
EventMachine_t (void(*event_callback)(const
|
85
|
+
EventMachine_t (void(*event_callback)(const unsigned long, int, const char*, const unsigned long));
|
78
86
|
virtual ~EventMachine_t();
|
79
87
|
|
80
88
|
void Run();
|
81
89
|
void ScheduleHalt();
|
82
90
|
void SignalLoopBreaker();
|
83
|
-
const
|
84
|
-
const
|
85
|
-
const
|
86
|
-
|
87
|
-
const
|
88
|
-
const
|
89
|
-
const
|
90
|
-
const
|
91
|
-
const
|
91
|
+
const unsigned long InstallOneshotTimer (int);
|
92
|
+
const unsigned long ConnectToServer (const char *, int, const char *, int);
|
93
|
+
const unsigned long ConnectToUnixServer (const char *);
|
94
|
+
|
95
|
+
const unsigned long CreateTcpServer (const char *, int);
|
96
|
+
const unsigned long OpenDatagramSocket (const char *, int);
|
97
|
+
const unsigned long CreateUnixDomainServer (const char*);
|
98
|
+
const unsigned long _OpenFileForWriting (const char*);
|
99
|
+
const unsigned long OpenKeyboard();
|
92
100
|
//const char *Popen (const char*, const char*);
|
93
|
-
const
|
101
|
+
const unsigned long Socketpair (char* const*);
|
94
102
|
|
95
103
|
void Add (EventableDescriptor*);
|
96
104
|
void Modify (EventableDescriptor*);
|
97
105
|
|
98
|
-
const
|
106
|
+
const unsigned long AttachFD (int, bool);
|
99
107
|
int DetachFD (EventableDescriptor*);
|
100
108
|
|
101
109
|
void ArmKqueueWriter (EventableDescriptor*);
|
@@ -112,18 +120,18 @@ class EventMachine_t
|
|
112
120
|
float GetHeartbeatInterval();
|
113
121
|
int SetHeartbeatInterval(float);
|
114
122
|
|
115
|
-
const
|
123
|
+
const unsigned long WatchFile (const char*);
|
116
124
|
void UnwatchFile (int);
|
117
|
-
void UnwatchFile (const
|
125
|
+
void UnwatchFile (const unsigned long);
|
118
126
|
|
119
127
|
#ifdef HAVE_KQUEUE
|
120
128
|
void _HandleKqueueFileEvent (struct kevent*);
|
121
129
|
void _RegisterKqueueFileEvent(int);
|
122
130
|
#endif
|
123
131
|
|
124
|
-
const
|
132
|
+
const unsigned long WatchPid (int);
|
125
133
|
void UnwatchPid (int);
|
126
|
-
void UnwatchPid (const
|
134
|
+
void UnwatchPid (const unsigned long);
|
127
135
|
|
128
136
|
#ifdef HAVE_KQUEUE
|
129
137
|
void _HandleKqueuePidEvent (struct kevent*);
|
@@ -160,7 +168,7 @@ class EventMachine_t
|
|
160
168
|
MaxEvents = 4096
|
161
169
|
};
|
162
170
|
int HeartbeatInterval;
|
163
|
-
void (*EventCallback)(const
|
171
|
+
void (*EventCallback)(const unsigned long, int, const char*, const unsigned long);
|
164
172
|
|
165
173
|
class Timer_t: public Bindable_t {
|
166
174
|
};
|
@@ -212,6 +220,7 @@ struct SelectData_t
|
|
212
220
|
int maxsocket;
|
213
221
|
fd_set fdreads;
|
214
222
|
fd_set fdwrites;
|
223
|
+
fd_set fderrors;
|
215
224
|
timeval tv;
|
216
225
|
int nSockets;
|
217
226
|
};
|
data/ext/emwin.cpp
CHANGED
@@ -138,7 +138,7 @@ bool EventMachine_t::_RunTimers()
|
|
138
138
|
if (i->first > gCurrentLoopTime)
|
139
139
|
break;
|
140
140
|
if (EventCallback)
|
141
|
-
(*EventCallback) (
|
141
|
+
(*EventCallback) (NULL, EM_TIMER_FIRED, NULL, i->second.GetBinding());
|
142
142
|
Timers.erase (i);
|
143
143
|
}
|
144
144
|
return true;
|
@@ -158,7 +158,7 @@ const char *EventMachine_t::InstallOneshotTimer (int seconds)
|
|
158
158
|
|
159
159
|
Timer_t t;
|
160
160
|
Timers.insert (make_pair (time(NULL) + seconds, t));
|
161
|
-
return t.GetBinding()
|
161
|
+
return t.GetBinding();
|
162
162
|
}
|
163
163
|
|
164
164
|
|
@@ -230,7 +230,7 @@ const char *EventMachine_t::CreateTcpServer (const char *server, int port)
|
|
230
230
|
if (!ad)
|
231
231
|
throw std::runtime_error ("unable to allocate acceptor");
|
232
232
|
Add (ad);
|
233
|
-
output_binding = ad->GetBinding()
|
233
|
+
output_binding = ad->GetBinding();
|
234
234
|
|
235
235
|
CreateIoCompletionPort ((HANDLE)sd_accept, Iocp, NULL, 0);
|
236
236
|
SOCKET sd = socket (AF_INET, SOCK_STREAM, 0);
|
data/ext/eventmachine.h
CHANGED
@@ -39,43 +39,54 @@ extern "C" {
|
|
39
39
|
|
40
40
|
};
|
41
41
|
|
42
|
-
void evma_initialize_library (void(*)(const
|
42
|
+
void evma_initialize_library (void(*)(const unsigned long, int, const char*, const unsigned long));
|
43
43
|
void evma_run_machine();
|
44
44
|
void evma_release_library();
|
45
|
-
const
|
46
|
-
const
|
47
|
-
const
|
48
|
-
|
49
|
-
const
|
50
|
-
int evma_detach_fd (const
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
45
|
+
const unsigned long evma_install_oneshot_timer (int seconds);
|
46
|
+
const unsigned long evma_connect_to_server (const char *bind_addr, int bind_port, const char *server, int port);
|
47
|
+
const unsigned long evma_connect_to_unix_server (const char *server);
|
48
|
+
|
49
|
+
const unsigned long evma_attach_fd (int file_descriptor, int watch_mode);
|
50
|
+
int evma_detach_fd (const unsigned long binding);
|
51
|
+
int evma_get_file_descriptor (const unsigned long binding);
|
52
|
+
int evma_is_notify_readable (const unsigned long binding);
|
53
|
+
void evma_set_notify_readable (const unsigned long binding, int mode);
|
54
|
+
int evma_is_notify_writable (const unsigned long binding);
|
55
|
+
void evma_set_notify_writable (const unsigned long binding, int mode);
|
56
|
+
|
57
|
+
int evma_pause(const unsigned long binding);
|
58
|
+
int evma_is_paused(const unsigned long binding);
|
59
|
+
int evma_resume(const unsigned long binding);
|
60
|
+
|
61
|
+
void evma_stop_tcp_server (const unsigned long signature);
|
62
|
+
const unsigned long evma_create_tcp_server (const char *address, int port);
|
63
|
+
const unsigned long evma_create_unix_domain_server (const char *filename);
|
64
|
+
const unsigned long evma_open_datagram_socket (const char *server, int port);
|
65
|
+
const unsigned long evma_open_keyboard();
|
66
|
+
void evma_set_tls_parms (const unsigned long binding, const char *privatekey_filename, const char *certchain_filenane, int verify_peer);
|
67
|
+
void evma_start_tls (const unsigned long binding);
|
59
68
|
|
60
69
|
#ifdef WITH_SSL
|
61
|
-
X509 *evma_get_peer_cert (const
|
62
|
-
void evma_accept_ssl_peer (const
|
70
|
+
X509 *evma_get_peer_cert (const unsigned long binding);
|
71
|
+
void evma_accept_ssl_peer (const unsigned long binding);
|
63
72
|
#endif
|
64
73
|
|
65
|
-
int evma_get_peername (const
|
66
|
-
int evma_get_sockname (const
|
67
|
-
int evma_get_subprocess_pid (const
|
68
|
-
int evma_get_subprocess_status (const
|
74
|
+
int evma_get_peername (const unsigned long binding, struct sockaddr*);
|
75
|
+
int evma_get_sockname (const unsigned long binding, struct sockaddr*);
|
76
|
+
int evma_get_subprocess_pid (const unsigned long binding, pid_t*);
|
77
|
+
int evma_get_subprocess_status (const unsigned long binding, int*);
|
69
78
|
int evma_get_connection_count();
|
70
|
-
int evma_send_data_to_connection (const
|
71
|
-
int evma_send_datagram (const
|
72
|
-
float evma_get_comm_inactivity_timeout (const
|
73
|
-
int evma_set_comm_inactivity_timeout (const
|
74
|
-
|
75
|
-
int
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
int evma_send_data_to_connection (const unsigned long binding, const char *data, int data_length);
|
80
|
+
int evma_send_datagram (const unsigned long binding, const char *data, int data_length, const char *address, int port);
|
81
|
+
float evma_get_comm_inactivity_timeout (const unsigned long binding);
|
82
|
+
int evma_set_comm_inactivity_timeout (const unsigned long binding, float value);
|
83
|
+
float evma_get_pending_connect_timeout (const unsigned long binding);
|
84
|
+
int evma_set_pending_connect_timeout (const unsigned long binding, float value);
|
85
|
+
int evma_get_outbound_data_size (const unsigned long binding);
|
86
|
+
int evma_send_file_data_to_connection (const unsigned long binding, const char *filename);
|
87
|
+
|
88
|
+
void evma_close_connection (const unsigned long binding, int after_writing);
|
89
|
+
int evma_report_connection_error_status (const unsigned long binding);
|
79
90
|
void evma_signal_loopbreak();
|
80
91
|
void evma_set_timer_quantum (int);
|
81
92
|
int evma_get_max_timer_count();
|
@@ -85,17 +96,17 @@ extern "C" {
|
|
85
96
|
float evma_get_heartbeat_interval();
|
86
97
|
int evma_set_heartbeat_interval(float);
|
87
98
|
|
88
|
-
const
|
89
|
-
const
|
99
|
+
const unsigned long evma__write_file (const char *filename);
|
100
|
+
const unsigned long evma_popen (char * const*cmd_strings);
|
90
101
|
|
91
|
-
const
|
92
|
-
void evma_unwatch_filename (const
|
102
|
+
const unsigned long evma_watch_filename (const char *fname);
|
103
|
+
void evma_unwatch_filename (const unsigned long);
|
93
104
|
|
94
|
-
const
|
95
|
-
void evma_unwatch_pid (const
|
105
|
+
const unsigned long evma_watch_pid (int);
|
106
|
+
void evma_unwatch_pid (const unsigned long);
|
96
107
|
|
97
|
-
void evma_start_proxy(const
|
98
|
-
void evma_stop_proxy(const
|
108
|
+
void evma_start_proxy(const unsigned long, const unsigned long, const unsigned long);
|
109
|
+
void evma_stop_proxy(const unsigned long);
|
99
110
|
|
100
111
|
int evma_set_rlimit_nofile (int n_files);
|
101
112
|
|
data/ext/eventmachine_cpp.h
CHANGED
@@ -1,96 +1,96 @@
|
|
1
|
-
/*****************************************************************************
|
2
|
-
|
3
|
-
$Id$
|
4
|
-
|
5
|
-
File: eventmachine_cpp.h
|
6
|
-
Date: 27Jul07
|
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
|
-
|
21
|
-
#ifndef __EVMA_EventmachineCpp__H_
|
22
|
-
#define __EVMA_EventmachineCpp__H_
|
23
|
-
|
24
|
-
|
25
|
-
// This material is only for directly integrating EM into C++ programs.
|
26
|
-
|
27
|
-
namespace EM {
|
28
|
-
|
29
|
-
void Callback (const
|
30
|
-
void Run (void(*)(void));
|
31
|
-
void AddTimer (int, void(*)());
|
32
|
-
void StopReactor();
|
33
|
-
|
34
|
-
/***************
|
35
|
-
class Eventable
|
36
|
-
***************/
|
37
|
-
|
38
|
-
class Eventable {
|
39
|
-
public:
|
40
|
-
Eventable() {}
|
41
|
-
virtual ~Eventable() {}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
// Called by the framework
|
46
|
-
virtual void ReceiveData (const char *data, int length) {}
|
47
|
-
virtual void ConnectionCompleted() {}
|
48
|
-
virtual void Accept (const
|
49
|
-
virtual void Unbind() {}
|
50
|
-
virtual void PostInit() {}
|
51
|
-
virtual void SslHandshakeCompleted() {}
|
52
|
-
|
53
|
-
void StopReactor() {EM::StopReactor();}
|
54
|
-
};
|
55
|
-
|
56
|
-
/****************
|
57
|
-
class Connection
|
58
|
-
****************/
|
59
|
-
|
60
|
-
class Connection: public Eventable {
|
61
|
-
public:
|
62
|
-
Connection() {}
|
63
|
-
virtual ~Connection() {}
|
64
|
-
|
65
|
-
virtual void Connect (const char*, int);
|
66
|
-
virtual void BindConnect (const char *, int, const char*, int);
|
67
|
-
|
68
|
-
void SendData (const char *data);
|
69
|
-
void SendData (const char *data, int length);
|
70
|
-
void Close (bool afterWriting);
|
71
|
-
};
|
72
|
-
|
73
|
-
|
74
|
-
/**************
|
75
|
-
class Acceptor
|
76
|
-
**************/
|
77
|
-
|
78
|
-
class Acceptor: public Eventable {
|
79
|
-
public:
|
80
|
-
Acceptor() {PostInit();}
|
81
|
-
virtual ~Acceptor() {}
|
82
|
-
|
83
|
-
void Start (const char*, int);
|
84
|
-
void Accept (const
|
85
|
-
|
86
|
-
virtual Connection *MakeConnection() {return new Connection();}
|
87
|
-
};
|
88
|
-
|
89
|
-
|
90
|
-
};
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
#endif // __EVMA_EventmachineCpp__H_
|
1
|
+
/*****************************************************************************
|
2
|
+
|
3
|
+
$Id$
|
4
|
+
|
5
|
+
File: eventmachine_cpp.h
|
6
|
+
Date: 27Jul07
|
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
|
+
|
21
|
+
#ifndef __EVMA_EventmachineCpp__H_
|
22
|
+
#define __EVMA_EventmachineCpp__H_
|
23
|
+
|
24
|
+
|
25
|
+
// This material is only for directly integrating EM into C++ programs.
|
26
|
+
|
27
|
+
namespace EM {
|
28
|
+
|
29
|
+
void Callback (const unsigned long sig, int event, const char *data, const unsigned long length);
|
30
|
+
void Run (void(*)(void));
|
31
|
+
void AddTimer (int, void(*)());
|
32
|
+
void StopReactor();
|
33
|
+
|
34
|
+
/***************
|
35
|
+
class Eventable
|
36
|
+
***************/
|
37
|
+
|
38
|
+
class Eventable {
|
39
|
+
public:
|
40
|
+
Eventable() {}
|
41
|
+
virtual ~Eventable() {}
|
42
|
+
|
43
|
+
unsigned long Signature;
|
44
|
+
|
45
|
+
// Called by the framework
|
46
|
+
virtual void ReceiveData (const char *data, int length) {}
|
47
|
+
virtual void ConnectionCompleted() {}
|
48
|
+
virtual void Accept (const unsigned long) {}
|
49
|
+
virtual void Unbind() {}
|
50
|
+
virtual void PostInit() {}
|
51
|
+
virtual void SslHandshakeCompleted() {}
|
52
|
+
|
53
|
+
void StopReactor() {EM::StopReactor();}
|
54
|
+
};
|
55
|
+
|
56
|
+
/****************
|
57
|
+
class Connection
|
58
|
+
****************/
|
59
|
+
|
60
|
+
class Connection: public Eventable {
|
61
|
+
public:
|
62
|
+
Connection() {}
|
63
|
+
virtual ~Connection() {}
|
64
|
+
|
65
|
+
virtual void Connect (const char*, int);
|
66
|
+
virtual void BindConnect (const char *, int, const char*, int);
|
67
|
+
|
68
|
+
void SendData (const char *data);
|
69
|
+
void SendData (const char *data, int length);
|
70
|
+
void Close (bool afterWriting);
|
71
|
+
};
|
72
|
+
|
73
|
+
|
74
|
+
/**************
|
75
|
+
class Acceptor
|
76
|
+
**************/
|
77
|
+
|
78
|
+
class Acceptor: public Eventable {
|
79
|
+
public:
|
80
|
+
Acceptor() {PostInit();}
|
81
|
+
virtual ~Acceptor() {}
|
82
|
+
|
83
|
+
void Start (const char*, int);
|
84
|
+
void Accept (const unsigned long);
|
85
|
+
|
86
|
+
virtual Connection *MakeConnection() {return new Connection();}
|
87
|
+
};
|
88
|
+
|
89
|
+
|
90
|
+
};
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
#endif // __EVMA_EventmachineCpp__H_
|
data/ext/extconf.rb
CHANGED
@@ -1,133 +1,148 @@
|
|
1
|
-
require 'mkmf'
|
2
|
-
|
3
|
-
def check_libs libs = [], fatal = false
|
4
|
-
libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) }
|
5
|
-
end
|
6
|
-
|
7
|
-
def check_heads heads = [], fatal = false
|
8
|
-
heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
|
9
|
-
end
|
10
|
-
|
11
|
-
def add_define(name)
|
12
|
-
$defs.push("-D#{name}")
|
13
|
-
end
|
14
|
-
|
15
|
-
add_define 'BUILD_FOR_RUBY'
|
16
|
-
add_define 'HAVE_RBTRAP' if have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h'])
|
17
|
-
add_define "HAVE_TBR" if have_func('rb_thread_blocking_region')# and have_macro('RUBY_UBF_IO', 'ruby.h')
|
18
|
-
add_define "HAVE_INOTIFY" if inotify = have_func('inotify_init', 'sys/inotify.h')
|
19
|
-
add_define "HAVE_OLD_INOTIFY" if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h')
|
20
|
-
add_define 'HAVE_WRITEV' if have_func('writev', 'sys/uio.h')
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
add_define
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
$
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
add_define 'OS_SOLARIS8'
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
CONFIG['
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
#
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
#
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
def check_libs libs = [], fatal = false
|
4
|
+
libs.all? { |lib| have_library(lib) || (abort("could not find library: #{lib}") if fatal) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def check_heads heads = [], fatal = false
|
8
|
+
heads.all? { |head| have_header(head) || (abort("could not find header: #{head}") if fatal)}
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_define(name)
|
12
|
+
$defs.push("-D#{name}")
|
13
|
+
end
|
14
|
+
|
15
|
+
add_define 'BUILD_FOR_RUBY'
|
16
|
+
add_define 'HAVE_RBTRAP' if have_var('rb_trap_immediate', ['ruby.h', 'rubysig.h'])
|
17
|
+
add_define "HAVE_TBR" if have_func('rb_thread_blocking_region')# and have_macro('RUBY_UBF_IO', 'ruby.h')
|
18
|
+
add_define "HAVE_INOTIFY" if inotify = have_func('inotify_init', 'sys/inotify.h')
|
19
|
+
add_define "HAVE_OLD_INOTIFY" if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h')
|
20
|
+
add_define 'HAVE_WRITEV' if have_func('writev', 'sys/uio.h')
|
21
|
+
have_func('rb_thread_check_ints')
|
22
|
+
have_func('rb_time_new')
|
23
|
+
|
24
|
+
# Minor platform details between *nix and Windows:
|
25
|
+
|
26
|
+
if RUBY_PLATFORM =~ /(mswin|mingw|bccwin)/
|
27
|
+
GNU_CHAIN = $1 == 'mingw'
|
28
|
+
OS_WIN32 = true
|
29
|
+
add_define "OS_WIN32"
|
30
|
+
else
|
31
|
+
GNU_CHAIN = true
|
32
|
+
OS_UNIX = true
|
33
|
+
add_define 'OS_UNIX'
|
34
|
+
|
35
|
+
add_define "HAVE_KQUEUE" if have_header("sys/event.h") and have_header("sys/queue.h")
|
36
|
+
end
|
37
|
+
|
38
|
+
# Main platform invariances:
|
39
|
+
|
40
|
+
case RUBY_PLATFORM
|
41
|
+
when /mswin32/, /mingw32/, /bccwin32/
|
42
|
+
check_heads(%w[windows.h winsock.h], true)
|
43
|
+
check_libs(%w[kernel32 rpcrt4 gdi32], true)
|
44
|
+
|
45
|
+
if GNU_CHAIN
|
46
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++"
|
47
|
+
else
|
48
|
+
$defs.push "-EHs"
|
49
|
+
$defs.push "-GR"
|
50
|
+
end
|
51
|
+
|
52
|
+
when /solaris/
|
53
|
+
add_define 'OS_SOLARIS8'
|
54
|
+
check_libs(%w[nsl socket], true)
|
55
|
+
|
56
|
+
# Patch by Tim Pease, fixes SUNWspro compile problems.
|
57
|
+
if CONFIG['CC'] == 'cc'
|
58
|
+
# SUN CHAIN
|
59
|
+
$CFLAGS = CONFIG['CFLAGS'] = "-KPIC -G"
|
60
|
+
CONFIG['CCDLFLAGS'] = "-KPIC"
|
61
|
+
else
|
62
|
+
# GNU CHAIN
|
63
|
+
# on Unix we need a g++ link, not gcc.
|
64
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
65
|
+
end
|
66
|
+
|
67
|
+
when /openbsd/
|
68
|
+
# OpenBSD branch contributed by Guillaume Sellier.
|
69
|
+
|
70
|
+
# on Unix we need a g++ link, not gcc. On OpenBSD, linking against libstdc++ have to be explicitly done for shared libs
|
71
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared -lstdc++ -fPIC"
|
72
|
+
CONFIG['LDSHAREDXX'] = "$(CXX) -shared -lstdc++ -fPIC"
|
73
|
+
|
74
|
+
when /darwin/
|
75
|
+
# on Unix we need a g++ link, not gcc.
|
76
|
+
# Ff line contributed by Daniel Harple.
|
77
|
+
CONFIG['LDSHARED'] = "$(CXX) " + CONFIG['LDSHARED'].split[1..-1].join(' ')
|
78
|
+
|
79
|
+
when /linux/
|
80
|
+
add_define 'HAVE_EPOLL' if have_func('epoll_create', 'sys/epoll.h')
|
81
|
+
|
82
|
+
# Original epoll test is inadequate because 2.4 kernels have the header
|
83
|
+
# but not the code.
|
84
|
+
# add_define 'HAVE_EPOLL' if have_header('sys/epoll.h')
|
85
|
+
# if have_header('sys/epoll.h')
|
86
|
+
# File.open("hasEpollTest.c", "w") {|f|
|
87
|
+
# f.puts "#include <sys/epoll.h>"
|
88
|
+
# f.puts "int main() { epoll_create(1024); return 0;}"
|
89
|
+
# }
|
90
|
+
# (e = system( "gcc hasEpollTest.c -o hasEpollTest " )) and (e = $?.to_i)
|
91
|
+
# `rm -f hasEpollTest.c hasEpollTest`
|
92
|
+
# add_define 'HAVE_EPOLL' if e == 0
|
93
|
+
# end
|
94
|
+
|
95
|
+
# on Unix we need a g++ link, not gcc.
|
96
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
97
|
+
|
98
|
+
when /aix/
|
99
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared -Wl,-G -Wl,-brtl"
|
100
|
+
|
101
|
+
else
|
102
|
+
# on Unix we need a g++ link, not gcc.
|
103
|
+
CONFIG['LDSHARED'] = "$(CXX) -shared"
|
104
|
+
end
|
105
|
+
|
106
|
+
# OpenSSL:
|
107
|
+
|
108
|
+
def manual_ssl_config
|
109
|
+
ssl_libs_heads_args = {
|
110
|
+
:unix => [%w[ssl crypto], %w[openssl/ssl.h openssl/err.h]],
|
111
|
+
:darwin => [%w[ssl crypto C], %w[openssl/ssl.h openssl/err.h]],
|
112
|
+
# openbsd and linux:
|
113
|
+
:crypto_hack => [%w[crypto ssl crypto], %w[openssl/ssl.h openssl/err.h]],
|
114
|
+
:mswin => [%w[ssleay32 libeay32], %w[openssl/ssl.h openssl/err.h]],
|
115
|
+
}
|
116
|
+
|
117
|
+
dc_flags = ['ssl']
|
118
|
+
dc_flags += ["#{ENV['OPENSSL']}/include", ENV['OPENSSL']] if /linux/ =~ RUBY_PLATFORM
|
119
|
+
|
120
|
+
libs, heads = case RUBY_PLATFORM
|
121
|
+
when /mswin/ ; ssl_libs_heads_args[:mswin]
|
122
|
+
when /mingw/ ; ssl_libs_heads_args[:unix]
|
123
|
+
when /darwin/ ; ssl_libs_heads_args[:darwin]
|
124
|
+
when /openbsd/ ; ssl_libs_heads_args[:crypto_hack]
|
125
|
+
when /linux/ ; ssl_libs_heads_args[:crypto_hack]
|
126
|
+
else ssl_libs_heads_args[:unix]
|
127
|
+
end
|
128
|
+
dir_config(*dc_flags)
|
129
|
+
check_libs(libs) and check_heads(heads)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Try to use pkg_config first, fixes #73
|
133
|
+
if pkg_config('openssl') || manual_ssl_config
|
134
|
+
add_define "WITH_SSL"
|
135
|
+
else
|
136
|
+
add_define "WITHOUT_SSL"
|
137
|
+
end
|
138
|
+
|
139
|
+
# solaris c++ compiler doesn't have make_pair()
|
140
|
+
TRY_LINK.sub!('$(CC)', '$(CXX)')
|
141
|
+
add_define 'HAVE_MAKE_PAIR' if try_link(<<SRC, '-lstdc++')
|
142
|
+
#include <utility>
|
143
|
+
using namespace std;
|
144
|
+
int main(){ pair<int,int> tuple = make_pair(1,2); }
|
145
|
+
SRC
|
146
|
+
TRY_LINK.sub!('$(CXX)', '$(CC)')
|
147
|
+
|
133
148
|
create_makefile "rubyeventmachine"
|