remove autopush support and make it a no-op
[kgio.git] / ext / kgio / kgio.h
bloba3f2f6613e73c3c9eb2c1f41a752df59099f612d
1 #ifndef KGIO_H
2 #define KGIO_H
4 #include <ruby.h>
5 #ifdef HAVE_RUBY_IO_H
6 # include <ruby/io.h>
7 #else
8 # include <rubyio.h>
9 #endif
10 #ifdef HAVE_RUBY_THREAD_H
11 # include <ruby/thread.h>
12 #endif
13 #include <errno.h>
14 #include <sys/types.h>
15 #include <sys/socket.h>
16 #include <sys/un.h>
17 #include <netinet/in.h>
18 #include <fcntl.h>
19 #include <unistd.h>
20 #include <arpa/inet.h>
21 #include <assert.h>
22 #include <netdb.h>
24 #include "ancient_ruby.h"
26 void init_kgio_wait(void);
27 void init_kgio_read(void);
28 void init_kgio_write(void);
29 void init_kgio_writev(void);
30 void init_kgio_accept(void);
31 void init_kgio_connect(void);
32 void init_kgio_poll(void);
33 void init_kgio_tryopen(void);
35 VALUE kgio_call_wait_writable(VALUE io);
36 VALUE kgio_call_wait_readable(VALUE io);
37 #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) && defined(HAVE_RUBY_THREAD_H)
38 # define KGIO_WITHOUT_GVL(fn,data1,ubf,data2) \
39 rb_thread_call_without_gvl((fn),(data1),(ubf),(data2))
40 #elif defined(HAVE_RB_THREAD_BLOCKING_REGION)
41 typedef VALUE(*kgio_blocking_fn_t)(void*);
42 # define KGIO_WITHOUT_GVL(fn,data1,ubf,data2) \
43 rb_thread_blocking_region((kgio_blocking_fn_t)(fn),(data1),(ubf),(data2))
44 #endif /* HAVE_RB_THREAD_CALL_WITHOUT_GVL || HAVE_RB_THREAD_BLOCKING_REGION */
46 #if defined(KGIO_WITHOUT_GVL) && defined(HAVE_POLL)
47 # define USE_KGIO_POLL
48 #endif /* USE_KGIO_POLL */
50 #ifndef HAVE_RB_UPDATE_MAX_FD
51 # define rb_update_max_fd(fd) for (;0;)
52 #endif
55 * 2012/12/13 - Linux 3.7 was released on 2012/12/10 with TFO.
56 * Headers distributed with glibc will take some time to catch up and
57 * be officially released. Most GNU/Linux distros will take a few months
58 * to a year longer. "Enterprise" distros will probably take 5-7 years.
59 * So keep these until 2017 at least...
61 #ifdef __linux__
62 # ifndef MSG_FASTOPEN
63 # define MSG_FASTOPEN 0x20000000 /* for clients */
64 # endif
65 # ifndef TCP_FASTOPEN
66 # define TCP_FASTOPEN 23 /* for listeners */
67 # endif
68 /* we _may_ have TFO support */
69 # define KGIO_TFO_MAYBE (1)
70 #else /* rely entirely on standard system headers */
71 # define KGIO_TFO_MAYBE (0)
72 #endif
74 extern unsigned kgio_tfo;
75 NORETURN(void kgio_raise_empty_bt(VALUE, const char *));
76 NORETURN(void kgio_wr_sys_fail(const char *));
77 NORETURN(void kgio_rd_sys_fail(const char *));
80 * we know MSG_DONTWAIT works properly on all stream sockets under Linux
81 * we can define this macro for other platforms as people care and
82 * notice.
84 # if defined(__linux__)
85 # define USE_MSG_DONTWAIT
86 # endif
88 /* prefer rb_str_subseq because we don't use negative offsets */
89 #ifndef HAVE_RB_STR_SUBSEQ
90 #define MY_STR_SUBSEQ(str,beg,len) rb_str_substr((str),(beg),(len))
91 #else
92 #define MY_STR_SUBSEQ(str,beg,len) rb_str_subseq((str),(beg),(len))
93 #endif
95 #endif /* KGIO_H */