nio4r 1.0.1 → 1.1.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: 47612304fa6cd2c81ad14e7bdb8af184ae90aea7
4
- data.tar.gz: 81e44434ea267b78ffd498726fa27752a348ec99
3
+ metadata.gz: 96d59635d5568ac28d3463cd275c144d164b2237
4
+ data.tar.gz: 05fec0902ed45c022b84a4ab5b7346b8d7f3e433
5
5
  SHA512:
6
- metadata.gz: 46832a57b9355a7ae7a52bb00fa8f6b545c4e0f40d1d9eaa5752628a7d6dccd06e577e57b41eaa2a7119474c64c51974aaa5503b24bf694a96a597eb20bbb2d8
7
- data.tar.gz: 0acbe1b4cb4bee3fb3125f0ac5104c7e5221c8c8cae5c6d766d87c5675859efa788f04ff0ac027be19de06da4c7c45d0a671a050b3d60c96b7f41ab4136eee90
6
+ metadata.gz: 1b90ca4d7cbcefe3bf6edc25670788f7c28bfd9839cb521f2a7517f0d6afa735e4abdcb9b417d1fdfb6cc530a01e6a8c63517652b4ba947a367669f13b5e3524
7
+ data.tar.gz: a0d543b2c2afc1c404a82c1c7cffc5ce8a9ae37d3c0df0d002d7d975ae5fbe26e29a47e16b59694c77bab76be2fe1928a3999fafb814fe2c83667fd207f5aa42
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.1.0 (2015-01-10)
2
+ ------------------
3
+ * Update to libev 4.19
4
+ * Do not call ev_io_stop on monitors if the loop is already closed
5
+
1
6
  1.0.1 (2014-09-01)
2
7
  ------------------
3
8
  * Fix C compiler warnings
data/README.md CHANGED
@@ -187,8 +187,8 @@ however this is not the case today.
187
187
  License
188
188
  -------
189
189
 
190
- Copyright (c) 2014 Tony Arcieri. Distributed under the MIT License. See
191
- LICENSE.txt for further details.
190
+ Copyright (c) 2011-2015 Tony Arcieri. Distributed under the MIT License.
191
+ See LICENSE.txt for further details.
192
192
 
193
- Includes libev 4.15. Copyright (C)2007-09 Marc Alexander Lehmann. Distributed
194
- under the BSD license. See ext/libev/LICENSE for details.
193
+ Includes libev 4.19. Copyright (c) 2009-2014 Marc Alexander Lehmann.
194
+ Distributed under the BSD license. See ext/libev/LICENSE for details.
@@ -11,7 +11,32 @@ TODO: store pid for each signal
11
11
  TODO: document file descriptor usage per loop
12
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
13
  TODO: embed watchers need updating when fd changes
14
- TODO: document portbaility requirements for atomic pointer access
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).
15
40
 
16
41
  4.15 Fri Mar 1 12:04:50 CET 2013
17
42
  - destroying a non-default loop would stop the global waitpid
@@ -41,7 +66,7 @@ TODO: document portbaility requirements for atomic pointer access
41
66
  - include sys/syscall.h instead of plain syscall.h.
42
67
  - check for io watcher loops in ev_verify, check for the most
43
68
  common reported usage bug in ev_io_start.
44
- - chose socket vs. WSASocket at compiletime using EV_USE_WSASOCKET.
69
+ - choose socket vs. WSASocket at compiletime using EV_USE_WSASOCKET.
45
70
  - always use WSASend/WSARecv directly on windows, hoping that this
46
71
  works in all cases (unlike read/write/send/recv...).
47
72
  - try to detect signals around a fork faster (test program by
@@ -50,7 +75,7 @@ TODO: document portbaility requirements for atomic pointer access
50
75
  - rename ev::embed::set to ev::embed::set_embed to avoid clashing
51
76
  the watcher base set (loop) method.
52
77
  - rewrite the async/signal pipe logic to always keep a valid fd, which
53
- simplifies (and hopefuly correctifies :) the race checking
78
+ simplifies (and hopefully correctifies :) the race checking
54
79
  on fork, at the cost of one extra fd.
55
80
  - add fat, msdos, jffs2, ramfs, ntfs and btrfs to the list of
56
81
  inotify-supporting filesystems.
@@ -252,7 +277,7 @@ TODO: document portbaility requirements for atomic pointer access
252
277
  - implement ev_suspend and ev_resume.
253
278
  - new EV_CUSTOM revents flag for use by applications.
254
279
  - add documentation section about priorities.
255
- - add a glossary to the dcoumentation.
280
+ - add a glossary to the documentation.
256
281
  - extend the ev_fork description slightly.
257
282
  - optimize a jump out of call_pending.
258
283
 
@@ -1,5 +1,5 @@
1
1
  All files in libev are
2
- Copyright (c)2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann.
2
+ Copyright (c)2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
5
5
  modification, are permitted provided that the following conditions are
@@ -14,7 +14,7 @@ ABOUT
14
14
  featureful. And also smaller. Yay.
15
15
 
16
16
  Some of the specialties of libev not commonly found elsewhere are:
17
-
17
+
18
18
  - extensive and detailed, readable documentation (not doxygen garbage).
19
19
  - fully supports fork, can detect fork in various ways and automatically
20
20
  re-arms kernel mechanisms that do not support fork.
@@ -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
@@ -111,7 +111,7 @@
111
111
  # undef EV_USE_POLL
112
112
  # define EV_USE_POLL 0
113
113
  # endif
114
-
114
+
115
115
  # if HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H
116
116
  # ifndef EV_USE_EPOLL
117
117
  # define EV_USE_EPOLL EV_FEATURE_BACKENDS
@@ -120,7 +120,7 @@
120
120
  # undef EV_USE_EPOLL
121
121
  # define EV_USE_EPOLL 0
122
122
  # endif
123
-
123
+
124
124
  # if HAVE_KQUEUE && HAVE_SYS_EVENT_H
125
125
  # ifndef EV_USE_KQUEUE
126
126
  # define EV_USE_KQUEUE EV_FEATURE_BACKENDS
@@ -129,7 +129,7 @@
129
129
  # undef EV_USE_KQUEUE
130
130
  # define EV_USE_KQUEUE 0
131
131
  # endif
132
-
132
+
133
133
  # if HAVE_PORT_H && HAVE_PORT_CREATE
134
134
  # ifndef EV_USE_PORT
135
135
  # define EV_USE_PORT EV_FEATURE_BACKENDS
@@ -165,7 +165,7 @@
165
165
  # undef EV_USE_EVENTFD
166
166
  # define EV_USE_EVENTFD 0
167
167
  # endif
168
-
168
+
169
169
  #endif
170
170
 
171
171
  #include <stdlib.h>
@@ -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
@@ -887,7 +946,7 @@ ecb_function_ uint8_t ecb_bitrev8 (uint8_t x) ecb_const;
887
946
  ecb_function_ uint8_t ecb_bitrev8 (uint8_t x)
888
947
  {
889
948
  return ( (x * 0x0802U & 0x22110U)
890
- | (x * 0x8020U & 0x88440U)) * 0x10101U >> 16;
949
+ | (x * 0x8020U & 0x88440U)) * 0x10101U >> 16;
891
950
  }
892
951
 
893
952
  ecb_function_ uint16_t ecb_bitrev16 (uint16_t x) ecb_const;
@@ -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
@@ -2017,7 +2111,7 @@ downheap (ANHE *heap, int N, int k)
2017
2111
 
2018
2112
  heap [k] = heap [c];
2019
2113
  ev_active (ANHE_w (heap [k])) = k;
2020
-
2114
+
2021
2115
  k = c;
2022
2116
  }
2023
2117
 
@@ -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 */
@@ -2437,7 +2531,7 @@ ev_supported_backends (void) EV_THROW
2437
2531
  if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL;
2438
2532
  if (EV_USE_POLL ) flags |= EVBACKEND_POLL;
2439
2533
  if (EV_USE_SELECT) flags |= EVBACKEND_SELECT;
2440
-
2534
+
2441
2535
  return flags;
2442
2536
  }
2443
2537
 
@@ -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
  }
@@ -3261,7 +3355,7 @@ VALUE ev_backend_poll(void *ptr)
3261
3355
  int
3262
3356
  ev_run (EV_P_ int flags)
3263
3357
  {
3264
- /* ########## NIO4R PATCHERY HO! ########## */
3358
+ /* ########## NIO4R PATCHERY HO! ########## */
3265
3359
  #if defined(HAVE_RB_THREAD_BLOCKING_REGION) || defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
3266
3360
  struct ev_poll_args poll_args;
3267
3361
  #endif
@@ -205,7 +205,7 @@ struct ev_loop;
205
205
  /*****************************************************************************/
206
206
 
207
207
  #define EV_VERSION_MAJOR 4
208
- #define EV_VERSION_MINOR 15
208
+ #define EV_VERSION_MINOR 19
209
209
 
210
210
  /* eventmask, revents, events... */
211
211
  enum {
@@ -658,8 +658,10 @@ EV_API_DECL void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval) EV_T
658
658
  /* advanced stuff for threading etc. support, see docs */
659
659
  EV_API_DECL void ev_set_userdata (EV_P_ void *data) EV_THROW;
660
660
  EV_API_DECL void *ev_userdata (EV_P) EV_THROW;
661
- EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ void (*invoke_pending_cb)(EV_P)) EV_THROW;
662
- EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P) EV_THROW) EV_THROW;
661
+ typedef void (*ev_loop_callback)(EV_P);
662
+ EV_API_DECL void ev_set_invoke_pending_cb (EV_P_ ev_loop_callback invoke_pending_cb) EV_THROW;
663
+ /* C++ doesn't allow the use of the ev_loop_callback typedef here, so we need to spell it out*/
664
+ EV_API_DECL void ev_set_loop_release_cb (EV_P_ void (*release)(EV_P) EV_THROW, void (*acquire)(EV_P) EV_THROW) EV_THROW;
663
665
 
664
666
  EV_API_DECL unsigned int ev_pending_count (EV_P) EV_THROW; /* number of pending events, if any */
665
667
  EV_API_DECL void ev_invoke_pending (EV_P); /* invoke all pending watchers */
@@ -730,7 +732,7 @@ EV_API_DECL void ev_resume (EV_P) EV_THROW;
730
732
  #endif
731
733
 
732
734
  /* stopping (enabling, adding) a watcher does nothing if it is already running */
733
- /* stopping (disabling, deleting) a watcher does nothing unless its already running */
735
+ /* stopping (disabling, deleting) a watcher does nothing unless it's already running */
734
736
  #if EV_PROTOTYPES
735
737
 
736
738
  /* feeds an event into a watcher as if the event actually occurred */
@@ -228,7 +228,10 @@ epoll_poll (EV_P_ ev_tstamp timeout)
228
228
  if (anfds [fd].emask & EV_EMASK_EPERM && events)
229
229
  fd_event (EV_A_ fd, events);
230
230
  else
231
- epoll_eperms [i] = epoll_eperms [--epoll_epermcnt];
231
+ {
232
+ epoll_eperms [i] = epoll_eperms [--epoll_epermcnt];
233
+ anfds [fd].emask = 0;
234
+ }
232
235
  }
233
236
  }
234
237
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libev kqueue backend
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-
@@ -90,7 +90,7 @@ poll_poll (EV_P_ ev_tstamp timeout)
90
90
  {
91
91
  struct pollfd *p;
92
92
  int res;
93
-
93
+
94
94
  EV_RELEASE_CB;
95
95
  res = poll (polls, pollcnt, timeout * 1e3);
96
96
  EV_ACQUIRE_CB;
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * loop member variable declarations
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-
@@ -194,9 +194,10 @@ VARx(unsigned int, loop_count) /* total number of loop iterations/blocks */
194
194
  VARx(unsigned int, loop_depth) /* #ev_run enters - #ev_run leaves */
195
195
 
196
196
  VARx(void *, userdata)
197
+ /* C++ doesn't support the ev_loop_callback typedef here. stinks. */
197
198
  VAR (release_cb, void (*release_cb)(EV_P) EV_THROW)
198
199
  VAR (acquire_cb, void (*acquire_cb)(EV_P) EV_THROW)
199
- VAR (invoke_cb , void (*invoke_cb) (EV_P))
200
+ VAR (invoke_cb , ev_loop_callback invoke_cb)
200
201
  #endif
201
202
 
202
203
  #undef VARx
@@ -127,10 +127,13 @@ static VALUE NIO_Monitor_close(int argc, VALUE *argv, VALUE self)
127
127
  selector = rb_ivar_get(self, rb_intern("selector"));
128
128
 
129
129
  if(selector != Qnil) {
130
- ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
130
+ /* if ev_loop is 0, it means that the loop has been stopped already (see NIO_Selector_shutdown)*/
131
+ if(monitor->selector->ev_loop != 0) {
132
+ ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
133
+ }
131
134
  monitor->selector = 0;
132
135
  rb_ivar_set(self, rb_intern("selector"), Qnil);
133
-
136
+
134
137
  /* Default value is true */
135
138
  if(deregister == Qtrue || deregister == Qnil) {
136
139
  rb_funcall(selector, rb_intern("deregister"), 1, rb_ivar_get(self, rb_intern("io")));
@@ -1,3 +1,3 @@
1
1
  module NIO
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -58,4 +58,12 @@ describe NIO::Monitor do
58
58
  expect(subject).to be_closed
59
59
  expect(selector.registered?(reader)).to be_falsey
60
60
  end
61
+
62
+ it "closes even if the selector has been shutdown" do
63
+ expect(subject).not_to be_closed
64
+ selector.close # forces shutdown
65
+ expect(subject).not_to be_closed
66
+ subject.close
67
+ expect(subject).to be_closed
68
+ end
61
69
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nio4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-01 00:00:00.000000000 Z
11
+ date: 2015-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.2.2
131
+ rubygems_version: 2.4.5
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: NIO provides a high performance selector API for monitoring IO objects
@@ -142,3 +142,4 @@ test_files:
142
142
  - spec/nio/selector_spec.rb
143
143
  - spec/spec_helper.rb
144
144
  - spec/support/selectable_examples.rb
145
+ has_rdoc: