cool.io 1.2.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edacf8d3fa674b299e42ade38405b993f5e89de3
4
- data.tar.gz: d4d3745f78319c94a7a8780408bc636036315b67
3
+ metadata.gz: 94010c895806ae23b7ac77b906979c31937463f3
4
+ data.tar.gz: a73e0f356ee9764a3dd8a3a56c29a187a8ab0693
5
5
  SHA512:
6
- metadata.gz: 1d870e50cec23dbcd03d8216b42c0b5cebfa4176d2d14b84d8b852478ad632d06464c87c3859c0e5838eeee7a44bceb03f4b79ee151a897b96d49fdbb8b680fc
7
- data.tar.gz: 3f4bd75c9720813861d33fec20e26bee7adb421667de536b8d3aa5333372c35cf5c4afa94abb3a0740d412040f0a8dcb2b94d29ad7f81b73a07d4bb503f738e1
6
+ metadata.gz: e48dd879dd3a8c76408cbf8569e7fefbf329360cc5b7e95a8f1aeaab2ac647cc9e89d4840fa6b8c86c9eb3cad372f57169303911592914751de1cc94e258569e
7
+ data.tar.gz: 1408f73b5abfcf72c6ca5c153aa9f1b72ac7bc1ed549235435c839883c0c8aa00ea375495a7e450f0803a8f75dc8b3212bfa9973509cc3003b27ddbe46d59451
data/.travis.yml CHANGED
@@ -2,8 +2,9 @@ language: ruby
2
2
 
3
3
  rvm:
4
4
  - 1.9.3
5
- - 2.0.0
5
+ - 2.0
6
6
  - 2.1
7
+ - 2.2
7
8
  - ruby-head
8
9
  - rbx
9
10
 
data/CHANGES.md CHANGED
@@ -1,3 +1,12 @@
1
+ 1.3.0
2
+ -----
3
+
4
+ * Block evaluation doesn't change self for keeping consistency with Ruby block
5
+ * Remove EventMachine emulation module
6
+ * Remove HttpClient
7
+ * DSL syntax is no longer available by default. Need to require 'cool.io/dsl' in user code
8
+ * Update libev to 4.19
9
+
1
10
  1.2.4
2
11
  -----
3
12
 
data/Rakefile CHANGED
@@ -36,26 +36,11 @@ Rake::ExtensionTask.new('iobuffer_ext', spec) do |ext|
36
36
  configure_cross_compilation(ext)
37
37
  end
38
38
 
39
- Rake::ExtensionTask.new('http11_client', spec) do |ext|
40
- ext.ext_dir = 'ext/http11_client'
41
- configure_cross_compilation(ext)
42
- end
43
-
44
39
  Rake::ExtensionTask.new('cool.io_ext', spec) do |ext|
45
40
  ext.ext_dir = 'ext/cool.io'
46
41
  configure_cross_compilation(ext)
47
42
  end
48
43
 
49
- # Rebuild parser Ragel
50
- task :http11_parser do
51
- Dir.chdir "ext/http11_client" do
52
- target = "http11_parser.c"
53
- File.unlink target if File.exist? target
54
- sh "ragel http11_parser.rl | rlgen-cd -G2 -o #{target}"
55
- raise "Failed to build C source" unless File.exist? target
56
- end
57
- end
58
-
59
44
  # adapted from http://flavoriffic.blogspot.com/2009/06/easily-valgrind-gdb-your-ruby-c.html
60
45
  def specs_command
61
46
  require "find"
data/cool.io.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.homepage = "http://coolio.github.com"
16
16
  s.summary = "A cool framework for doing high performance I/O in Ruby"
17
17
  s.description = "Cool.io provides a high performance event framework for Ruby which uses the libev C library"
18
- s.extensions = ["ext/cool.io/extconf.rb", "ext/http11_client/extconf.rb", "ext/iobuffer/extconf.rb"]
18
+ s.extensions = ["ext/cool.io/extconf.rb", "ext/iobuffer/extconf.rb"]
19
19
 
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -0,0 +1,24 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'rubygems'
4
+ require 'cool.io'
5
+
6
+ ADDR = '127.0.0.1'
7
+ PORT = 4321
8
+
9
+ event_loop = Cool.io::Loop.default
10
+ server = Cool.io::TCPServer.new(ADDR, PORT) do |connection|
11
+ puts "#{connection.remote_addr}:#{connection.remote_port} connected"
12
+
13
+ connection.on_close do
14
+ puts "#{connection.remote_addr}:#{connection.remote_port} disconnected"
15
+ end
16
+
17
+ connection.on_read do |data|
18
+ connection.write data
19
+ end
20
+ end
21
+ server.attach(event_loop)
22
+
23
+ puts "Echo server listening on #{ADDR}:#{PORT}"
24
+ event_loop.run
data/ext/libev/Changes CHANGED
@@ -1,5 +1,119 @@
1
1
  Revision history for libev, a high-performance and full-featured event loop.
2
2
 
3
+ TODO: ev_loop_wakeup
4
+ TODO: EV_STANDALONE == NO_HASSEL (do not use clock_gettime in ev_standalone)
5
+ TODO: faq, process a thing in each iteration
6
+ TODO: dbeugging tips, ev_verify, ev_init twice
7
+ TODO: ev_break for immediate exit (EVBREAK_NOW?)
8
+ TODO: ev_feed_child_event
9
+ TODO: document the special problem of signals around fork.
10
+ TODO: store pid for each signal
11
+ TODO: document file descriptor usage per loop
12
+ TODO: store loop pid_t and compare isndie signal handler,store 1 for same, 2 for differign pid, clean up in loop_fork
13
+ TODO: embed watchers need updating when fd changes
14
+ TODO: document portability requirements for atomic pointer access
15
+ TODO: possible cb aliasing?
16
+ TODO: document requirements for function pointers and calling conventions.
17
+
18
+ 4.19 Thu Sep 25 08:18:25 CEST 2014
19
+ - ev.h wasn't valid C++ anymore, which tripped compilers other than
20
+ clang, msvc or gcc (analyzed by Raphael 'kena' Poss). Unfortunately,
21
+ C++ doesn't support typedefs for function pointers fully, so the affected
22
+ declarations have to spell out the types each time.
23
+ - when not using autoconf, tighten the check for clock_gettime and related
24
+ functionality.
25
+
26
+ 4.18 Fri Sep 5 17:55:26 CEST 2014
27
+ - events on files were not always generated properly with the
28
+ epoll backend (testcase by Assaf Inbal).
29
+ - mark event pipe fd as cloexec after a fork (analyzed by Sami Farin).
30
+ - (ecb) support m68k, m88k and sh (patch by Miod Vallat).
31
+ - use a reasonable fallback for EV_NSIG instead of erroring out
32
+ when we can't detect the signal set size.
33
+ - in the absence of autoconf, do not use the clock syscall
34
+ on glibc >= 2.17 (avoids the syscall AND -lrt on systems
35
+ doing clock_gettime in userspace).
36
+ - ensure extern "C" function pointers are used for externally-visible
37
+ loop callbacks (not watcher callbacks yet).
38
+ - (ecb) work around memory barriers and volatile apparently both being
39
+ broken in visual studio 2008 and later (analysed and patch by Nicolas Noble).
40
+
41
+ 4.15 Fri Mar 1 12:04:50 CET 2013
42
+ - destroying a non-default loop would stop the global waitpid
43
+ watcher (Denis Bilenko).
44
+ - queueing pending watchers of higher priority from a watcher now invokes
45
+ them in a timely fashion (reported by Denis Bilenko).
46
+ - add throw() to all libev functions that cannot throw exceptions, for
47
+ further code size decrease when compiling for C++.
48
+ - add throw () to callbacks that must not throw exceptions (allocator,
49
+ syserr, loop acquire/release, periodic reschedule cbs).
50
+ - fix event_base_loop return code, add event_get_callback, event_base_new,
51
+ event_base_get_method calls to improve libevent 1.x emulation and add
52
+ some libevent 2.x functionality (based on a patch by Jeff Davey).
53
+ - add more memory fences to fix a bug reported by Jeff Davey. Better
54
+ be overfenced than underprotected.
55
+ - ev_run now returns a boolean status (true meaning watchers are
56
+ still active).
57
+ - ev_once: undef EV_ERROR in ev_kqueue.c, to avoid clashing with
58
+ libev's EV_ERROR (reported by 191919).
59
+ - (ecb) add memory fence support for xlC (Darin McBride).
60
+ - (ecb) add memory fence support for gcc-mips (Anton Kirilov).
61
+ - (ecb) add memory fence support for gcc-alpha (Christian Weisgerber).
62
+ - work around some kernels losing file descriptors by leaking
63
+ the kqueue descriptor in the child.
64
+ - work around linux inotify not reporting IN_ATTRIB changes for directories
65
+ in many cases.
66
+ - include sys/syscall.h instead of plain syscall.h.
67
+ - check for io watcher loops in ev_verify, check for the most
68
+ common reported usage bug in ev_io_start.
69
+ - choose socket vs. WSASocket at compiletime using EV_USE_WSASOCKET.
70
+ - always use WSASend/WSARecv directly on windows, hoping that this
71
+ works in all cases (unlike read/write/send/recv...).
72
+ - try to detect signals around a fork faster (test program by
73
+ Denis Bilenko).
74
+ - work around recent glibc versions that leak memory in realloc.
75
+ - rename ev::embed::set to ev::embed::set_embed to avoid clashing
76
+ the watcher base set (loop) method.
77
+ - rewrite the async/signal pipe logic to always keep a valid fd, which
78
+ simplifies (and hopefully correctifies :) the race checking
79
+ on fork, at the cost of one extra fd.
80
+ - add fat, msdos, jffs2, ramfs, ntfs and btrfs to the list of
81
+ inotify-supporting filesystems.
82
+ - move orig_CFLAGS assignment to after AC_INIT, as newer autoconf
83
+ versions ignore it before
84
+ (https://bugzilla.redhat.com/show_bug.cgi?id=908096).
85
+ - add some untested android support.
86
+ - enum expressions must be of type int (reported by Juan Pablo L).
87
+
88
+ 4.11 Sat Feb 4 19:52:39 CET 2012
89
+ - INCOMPATIBLE CHANGE: ev_timer_again now clears the pending status, as
90
+ was documented already, but not implemented in the repeating case.
91
+ - new compiletime symbols: EV_NO_SMP and EV_NO_THREADS.
92
+ - fix a race where the workaround against the epoll fork bugs
93
+ caused signals to not be handled anymore.
94
+ - correct backend_fudge for most backends, and implement a windows
95
+ specific workaround to avoid looping because we call both
96
+ select and Sleep, both with different time resolutions.
97
+ - document range and guarantees of ev_sleep.
98
+ - document reasonable ranges for periodics interval and offset.
99
+ - rename backend_fudge to backend_mintime to avoid future confusion :)
100
+ - change the default periodic reschedule function to hopefully be more
101
+ exact and correct even in corner cases or in the far future.
102
+ - do not rely on -lm anymore: use it when available but use our
103
+ own floor () if it is missing. This should make it easier to embed,
104
+ as no external libraries are required.
105
+ - strategically import macros from libecb and mark rarely-used functions
106
+ as cache-cold (saving almost 2k code size on typical amd64 setups).
107
+ - add Symbols.ev and Symbols.event files, that were missing.
108
+ - fix backend_mintime value for epoll (was 1/1024, is 1/1000 now).
109
+ - fix #3 "be smart about timeouts" to not "deadlock" when
110
+ timeout == now, also improve the section overall.
111
+ - avoid "AVOIDING FINISHING BEFORE RETURNING" idiom.
112
+ - support new EV_API_STATIC mode to make all libev symbols
113
+ static.
114
+ - supply default CFLAGS of -g -O3 with gcc when original CFLAGS
115
+ were empty.
116
+
3
117
  4.04 Wed Feb 16 09:01:51 CET 2011
4
118
  - fix two problems in the native win32 backend, where reuse of fd's
5
119
  with different underlying handles caused handles not to be removed
@@ -94,7 +208,7 @@ Revision history for libev, a high-performance and full-featured event loop.
94
208
  that this is a race condition regardless of EV_SIGNALFD.
95
209
  - backport inotify code to C89.
96
210
  - inotify file descriptors could leak into child processes.
97
- - ev_stat watchers could keep an errornous extra ref on the loop,
211
+ - ev_stat watchers could keep an erroneous extra ref on the loop,
98
212
  preventing exit when unregistering all watchers (testcases
99
213
  provided by ry@tinyclouds.org).
100
214
  - implement EV_WIN32_HANDLE_TO_FD and EV_WIN32_CLOSE_FD configuration
@@ -162,8 +276,8 @@ Revision history for libev, a high-performance and full-featured event loop.
162
276
  Malek Hadj-Ali).
163
277
  - implement ev_suspend and ev_resume.
164
278
  - new EV_CUSTOM revents flag for use by applications.
165
- - add documentation section about priorites.
166
- - add a glossary to the dcoumentation.
279
+ - add documentation section about priorities.
280
+ - add a glossary to the documentation.
167
281
  - extend the ev_fork description slightly.
168
282
  - optimize a jump out of call_pending.
169
283
 
data/ext/libev/LICENSE CHANGED
@@ -1,4 +1,5 @@
1
- All files in libev are Copyright (C)2007,2008,2009 Marc Alexander Lehmann.
1
+ All files in libev are
2
+ Copyright (c)2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann.
2
3
 
3
4
  Redistribution and use in source and binary forms, with or without
4
5
  modification, are permitted provided that the following conditions are
data/ext/libev/README CHANGED
@@ -24,23 +24,23 @@ ABOUT
24
24
  - relative timers/timeouts (handle time jumps).
25
25
  - fast intra-thread communication between multiple
26
26
  event loops (with optional fast linux eventfd backend).
27
- - extremely easy to embed.
28
- - very small codebase, no bloated library.
27
+ - extremely easy to embed (fully documented, no dependencies,
28
+ autoconf supported but optional).
29
+ - very small codebase, no bloated library, simple code.
29
30
  - fully extensible by being able to plug into the event loop,
30
31
  integrate other event loops, integrate other event loop users.
31
32
  - very little memory use (small watchers, small event loop data).
32
33
  - optional C++ interface allowing method and function callbacks
33
34
  at no extra memory or runtime overhead.
34
35
  - optional Perl interface with similar characteristics (capable
35
- of running Glib/Gtk2 on libev, interfaces with Net::SNMP and
36
- libadns).
36
+ of running Glib/Gtk2 on libev).
37
37
  - support for other languages (multiple C++ interfaces, D, Ruby,
38
38
  Python) available from third-parties.
39
39
 
40
- Examples of programs that embed libev: the EV perl module,
41
- rxvt-unicode, gvpe (GNU Virtual Private Ethernet), the Deliantra MMORPG
42
- server (http://www.deliantra.net/), Rubinius (a next-generation Ruby
43
- VM), the Ebb web server, the Rev event toolkit.
40
+ Examples of programs that embed libev: the EV perl module, node.js,
41
+ auditd, rxvt-unicode, gvpe (GNU Virtual Private Ethernet), the
42
+ Deliantra MMORPG server (http://www.deliantra.net/), Rubinius (a
43
+ next-generation Ruby VM), the Ebb web server, the Rev event toolkit.
44
44
 
45
45
 
46
46
  CONTRIBUTORS
data/ext/libev/ev.c CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libev event processing core, watcher management
3
3
  *
4
- * Copyright (c) 2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann <libev@schmorp.de>
4
+ * Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann <libev@schmorp.de>
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without modifica-
@@ -49,11 +49,11 @@
49
49
  # include "config.h"
50
50
  # endif
51
51
 
52
- #if HAVE_FLOOR
53
- # ifndef EV_USE_FLOOR
54
- # define EV_USE_FLOOR 1
52
+ # if HAVE_FLOOR
53
+ # ifndef EV_USE_FLOOR
54
+ # define EV_USE_FLOOR 1
55
+ # endif
55
56
  # endif
56
- #endif
57
57
 
58
58
  # if HAVE_CLOCK_SYSCALL
59
59
  # ifndef EV_USE_CLOCK_SYSCALL
@@ -247,10 +247,7 @@
247
247
  #elif defined _sys_nsig
248
248
  # define EV_NSIG (_sys_nsig) /* Solaris 2.5 */
249
249
  #else
250
- # error "unable to find value for NSIG, please report"
251
- /* to make it compile regardless, just remove the above line, */
252
- /* but consider reporting it, too! :) */
253
- # define EV_NSIG 65
250
+ # define EV_NSIG (8 * sizeof (sigset_t) + 1)
254
251
  #endif
255
252
 
256
253
  #ifndef EV_USE_FLOOR
@@ -258,13 +255,22 @@
258
255
  #endif
259
256
 
260
257
  #ifndef EV_USE_CLOCK_SYSCALL
261
- # if __linux && __GLIBC__ >= 2
258
+ # if __linux && __GLIBC__ == 2 && __GLIBC_MINOR__ < 17
262
259
  # define EV_USE_CLOCK_SYSCALL EV_FEATURE_OS
263
260
  # else
264
261
  # define EV_USE_CLOCK_SYSCALL 0
265
262
  # endif
266
263
  #endif
267
264
 
265
+ #if !(_POSIX_TIMERS > 0)
266
+ # ifndef EV_USE_MONOTONIC
267
+ # define EV_USE_MONOTONIC 0
268
+ # endif
269
+ # ifndef EV_USE_REALTIME
270
+ # define EV_USE_REALTIME 0
271
+ # endif
272
+ #endif
273
+
268
274
  #ifndef EV_USE_MONOTONIC
269
275
  # if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
270
276
  # define EV_USE_MONOTONIC EV_FEATURE_OS
@@ -491,7 +497,7 @@ struct signalfd_siginfo
491
497
  /*
492
498
  * libecb - http://software.schmorp.de/pkg/libecb
493
499
  *
494
- * Copyright (©) 2009-2012 Marc Alexander Lehmann <libecb@schmorp.de>
500
+ * Copyright (©) 2009-2014 Marc Alexander Lehmann <libecb@schmorp.de>
495
501
  * Copyright (©) 2011 Emanuele Giaquinta
496
502
  * All rights reserved.
497
503
  *
@@ -515,6 +521,17 @@ struct signalfd_siginfo
515
521
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
516
522
  * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
517
523
  * OF THE POSSIBILITY OF SUCH DAMAGE.
524
+ *
525
+ * Alternatively, the contents of this file may be used under the terms of
526
+ * the GNU General Public License ("GPL") version 2 or any later version,
527
+ * in which case the provisions of the GPL are applicable instead of
528
+ * the above. If you wish to allow the use of your version of this file
529
+ * only under the terms of the GPL and not to allow others to use your
530
+ * version of this file under the BSD license, indicate your decision
531
+ * by deleting the provisions above and replace them with the notice
532
+ * and other provisions required by the GPL. If you do not delete the
533
+ * provisions above, a recipient may use your version of this file under
534
+ * either the BSD or the GPL.
518
535
  */
519
536
 
520
537
  #ifndef ECB_H
@@ -556,8 +573,8 @@ struct signalfd_siginfo
556
573
  #endif
557
574
 
558
575
  /* work around x32 idiocy by defining proper macros */
559
- #if __x86_64 || _M_AMD64
560
- #if __ILP32
576
+ #if __amd64 || __x86_64 || _M_AMD64 || _M_X64
577
+ #if _ILP32
561
578
  #define ECB_AMD64_X32 1
562
579
  #else
563
580
  #define ECB_AMD64 1
@@ -579,12 +596,20 @@ struct signalfd_siginfo
579
596
  #endif
580
597
  #endif
581
598
 
582
- #define ECB_C (__STDC__+0) /* this assumes that __STDC__ is either empty or a number */
583
- #define ECB_C99 (__STDC_VERSION__ >= 199901L)
584
- #define ECB_C11 (__STDC_VERSION__ >= 201112L)
585
599
  #define ECB_CPP (__cplusplus+0)
586
600
  #define ECB_CPP11 (__cplusplus >= 201103L)
587
601
 
602
+ #if ECB_CPP
603
+ #define ECB_C 0
604
+ #define ECB_STDC_VERSION 0
605
+ #else
606
+ #define ECB_C 1
607
+ #define ECB_STDC_VERSION __STDC_VERSION__
608
+ #endif
609
+
610
+ #define ECB_C99 (ECB_STDC_VERSION >= 199901L)
611
+ #define ECB_C11 (ECB_STDC_VERSION >= 201112L)
612
+
588
613
  #if ECB_CPP
589
614
  #define ECB_EXTERN_C extern "C"
590
615
  #define ECB_EXTERN_C_BEG ECB_EXTERN_C {
@@ -626,14 +651,18 @@ struct signalfd_siginfo
626
651
  #elif defined __ARM_ARCH_7__ || defined __ARM_ARCH_7A__ \
627
652
  || defined __ARM_ARCH_7M__ || defined __ARM_ARCH_7R__
628
653
  #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb" : : : "memory")
629
- #elif __sparc || __sparc__
654
+ #elif __aarch64__
655
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dmb ish" : : : "memory")
656
+ #elif (__sparc || __sparc__) && !__sparcv8
630
657
  #define ECB_MEMORY_FENCE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory")
631
658
  #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory")
632
659
  #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore")
633
660
  #elif defined __s390__ || defined __s390x__
634
661
  #define ECB_MEMORY_FENCE __asm__ __volatile__ ("bcr 15,0" : : : "memory")
635
662
  #elif defined __mips__
636
- #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory")
663
+ /* GNU/Linux emulates sync on mips1 architectures, so we force its use */
664
+ /* anybody else who still uses mips1 is supposed to send in their version, with detection code. */
665
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ (".set mips2; sync; .set mips0" : : : "memory")
637
666
  #elif defined __alpha__
638
667
  #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mb" : : : "memory")
639
668
  #elif defined __hppa__
@@ -641,6 +670,12 @@ struct signalfd_siginfo
641
670
  #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("")
642
671
  #elif defined __ia64__
643
672
  #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mf" : : : "memory")
673
+ #elif defined __m68k__
674
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory")
675
+ #elif defined __m88k__
676
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("tb1 0,%%r0,128" : : : "memory")
677
+ #elif defined __sh__
678
+ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory")
644
679
  #endif
645
680
  #endif
646
681
  #endif
@@ -649,6 +684,8 @@ struct signalfd_siginfo
649
684
  #if ECB_GCC_VERSION(4,7)
650
685
  /* see comment below (stdatomic.h) about the C11 memory model. */
651
686
  #define ECB_MEMORY_FENCE __atomic_thread_fence (__ATOMIC_SEQ_CST)
687
+ #define ECB_MEMORY_FENCE_ACQUIRE __atomic_thread_fence (__ATOMIC_ACQUIRE)
688
+ #define ECB_MEMORY_FENCE_RELEASE __atomic_thread_fence (__ATOMIC_RELEASE)
652
689
 
653
690
  /* The __has_feature syntax from clang is so misdesigned that we cannot use it
654
691
  * without risking compile time errors with other compilers. We *could*
@@ -657,10 +694,18 @@ struct signalfd_siginfo
657
694
  * #elif defined __clang && __has_feature (cxx_atomic)
658
695
  * // see comment below (stdatomic.h) about the C11 memory model.
659
696
  * #define ECB_MEMORY_FENCE __c11_atomic_thread_fence (__ATOMIC_SEQ_CST)
697
+ * #define ECB_MEMORY_FENCE_ACQUIRE __c11_atomic_thread_fence (__ATOMIC_ACQUIRE)
698
+ * #define ECB_MEMORY_FENCE_RELEASE __c11_atomic_thread_fence (__ATOMIC_RELEASE)
660
699
  */
661
700
 
662
701
  #elif ECB_GCC_VERSION(4,4) || defined __INTEL_COMPILER || defined __clang__
663
702
  #define ECB_MEMORY_FENCE __sync_synchronize ()
703
+ #elif _MSC_VER >= 1500 /* VC++ 2008 */
704
+ /* apparently, microsoft broke all the memory barrier stuff in Visual Studio 2008... */
705
+ #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier)
706
+ #define ECB_MEMORY_FENCE _ReadWriteBarrier (); MemoryBarrier()
707
+ #define ECB_MEMORY_FENCE_ACQUIRE _ReadWriteBarrier (); MemoryBarrier() /* according to msdn, _ReadBarrier is not a load fence */
708
+ #define ECB_MEMORY_FENCE_RELEASE _WriteBarrier (); MemoryBarrier()
664
709
  #elif _MSC_VER >= 1400 /* VC++ 2005 */
665
710
  #pragma intrinsic(_ReadBarrier,_WriteBarrier,_ReadWriteBarrier)
666
711
  #define ECB_MEMORY_FENCE _ReadWriteBarrier ()
@@ -690,6 +735,8 @@ struct signalfd_siginfo
690
735
  /* for most usages, or gcc and clang have a bug */
691
736
  /* I *currently* lean towards the latter, and inefficiently implement */
692
737
  /* all three of ecb's fences as a seq_cst fence */
738
+ /* Update, gcc-4.8 generates mfence for all c++ fences, but nothing */
739
+ /* for all __atomic_thread_fence's except seq_cst */
693
740
  #define ECB_MEMORY_FENCE atomic_thread_fence (memory_order_seq_cst)
694
741
  #endif
695
742
  #endif
@@ -756,6 +803,11 @@ typedef int ecb_bool;
756
803
  #define ecb_prefetch(addr,rw,locality) __builtin_prefetch (addr, rw, locality)
757
804
  #else
758
805
  #define ecb_attribute(attrlist)
806
+
807
+ /* possible C11 impl for integral types
808
+ typedef struct ecb_is_constant_struct ecb_is_constant_struct;
809
+ #define ecb_is_constant(expr) _Generic ((1 ? (struct ecb_is_constant_struct *)0 : (void *)((expr) - (expr)), ecb_is_constant_struct *: 0, default: 1)) */
810
+
759
811
  #define ecb_is_constant(expr) 0
760
812
  #define ecb_expect(expr,value) (expr)
761
813
  #define ecb_prefetch(addr,rw,locality)
@@ -768,11 +820,18 @@ typedef int ecb_bool;
768
820
  #define ecb_decltype(x) __typeof(x)
769
821
  #endif
770
822
 
823
+ #if _MSC_VER >= 1300
824
+ #define ecb_deprecated __declspec(deprecated)
825
+ #else
826
+ #define ecb_deprecated ecb_attribute ((__deprecated__))
827
+ #endif
828
+
771
829
  #define ecb_noinline ecb_attribute ((__noinline__))
772
830
  #define ecb_unused ecb_attribute ((__unused__))
773
831
  #define ecb_const ecb_attribute ((__const__))
774
832
  #define ecb_pure ecb_attribute ((__pure__))
775
833
 
834
+ /* http://msdn.microsoft.com/en-us/library/k6ktzx3s.aspx __declspec(noreturn) */
776
835
  #if ECB_C11
777
836
  #define ecb_noreturn _Noreturn
778
837
  #else
@@ -1051,22 +1110,57 @@ ecb_inline ecb_bool ecb_little_endian (void) { return ecb_byteorder_helper () ==
1051
1110
  || __i386 || __i386__ \
1052
1111
  || __amd64 || __amd64__ || __x86_64 || __x86_64__ \
1053
1112
  || __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ \
1054
- || defined __arm__ && defined __ARM_EABI__ \
1055
1113
  || defined __s390__ || defined __s390x__ \
1056
1114
  || defined __mips__ \
1057
1115
  || defined __alpha__ \
1058
1116
  || defined __hppa__ \
1059
1117
  || defined __ia64__ \
1060
- || defined _M_IX86 || defined _M_AMD64 || defined _M_IA64
1118
+ || defined __m68k__ \
1119
+ || defined __m88k__ \
1120
+ || defined __sh__ \
1121
+ || defined _M_IX86 || defined _M_AMD64 || defined _M_IA64 \
1122
+ || (defined __arm__ && (defined __ARM_EABI__ || defined __EABI__ || defined __VFP_FP__ || defined _WIN32_WCE || defined __ANDROID__)) \
1123
+ || defined __aarch64__
1061
1124
  #define ECB_STDFP 1
1062
1125
  #include <string.h> /* for memcpy */
1063
1126
  #else
1064
1127
  #define ECB_STDFP 0
1065
- #include <math.h> /* for frexp*, ldexp* */
1066
1128
  #endif
1067
1129
 
1068
1130
  #ifndef ECB_NO_LIBM
1069
1131
 
1132
+ #include <math.h> /* for frexp*, ldexp*, INFINITY, NAN */
1133
+
1134
+ /* only the oldest of old doesn't have this one. solaris. */
1135
+ #ifdef INFINITY
1136
+ #define ECB_INFINITY INFINITY
1137
+ #else
1138
+ #define ECB_INFINITY HUGE_VAL
1139
+ #endif
1140
+
1141
+ #ifdef NAN
1142
+ #define ECB_NAN NAN
1143
+ #else
1144
+ #define ECB_NAN ECB_INFINITY
1145
+ #endif
1146
+
1147
+ /* converts an ieee half/binary16 to a float */
1148
+ ecb_function_ float ecb_binary16_to_float (uint16_t x) ecb_const;
1149
+ ecb_function_ float
1150
+ ecb_binary16_to_float (uint16_t x)
1151
+ {
1152
+ int e = (x >> 10) & 0x1f;
1153
+ int m = x & 0x3ff;
1154
+ float r;
1155
+
1156
+ if (!e ) r = ldexpf (m , -24);
1157
+ else if (e != 31) r = ldexpf (m + 0x400, e - 25);
1158
+ else if (m ) r = ECB_NAN;
1159
+ else r = ECB_INFINITY;
1160
+
1161
+ return x & 0x8000 ? -r : r;
1162
+ }
1163
+
1070
1164
  /* convert a float to ieee single/binary32 */
1071
1165
  ecb_function_ uint32_t ecb_float_to_binary32 (float x) ecb_const;
1072
1166
  ecb_function_ uint32_t
@@ -2110,8 +2204,6 @@ evpipe_init (EV_P)
2110
2204
  fd_intern (fds [0]);
2111
2205
  }
2112
2206
 
2113
- fd_intern (fds [1]);
2114
-
2115
2207
  evpipe [0] = fds [0];
2116
2208
 
2117
2209
  if (evpipe [1] < 0)
@@ -2127,6 +2219,8 @@ evpipe_init (EV_P)
2127
2219
  close (fds [1]);
2128
2220
  }
2129
2221
 
2222
+ fd_intern (evpipe [1]);
2223
+
2130
2224
  ev_io_set (&pipe_w, evpipe [0] < 0 ? evpipe [1] : evpipe [0], EV_READ);
2131
2225
  ev_io_start (EV_A_ &pipe_w);
2132
2226
  ev_unref (EV_A); /* watcher should not keep loop alive */
@@ -2519,7 +2613,7 @@ ev_userdata (EV_P) EV_THROW
2519
2613
  }
2520
2614
 
2521
2615
  void
2522
- ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P)) EV_THROW
2616
+ ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW
2523
2617
  {
2524
2618
  invoke_cb = invoke_pending_cb;
2525
2619
  }