Lines 1-4
Link Here
|
1 |
--- tests/os-wrappers-test.c.orig 2016-10-22 16:23:10 UTC |
1 |
--- tests/os-wrappers-test.c.orig 2017-08-08 18:20:52 UTC |
2 |
+++ tests/os-wrappers-test.c |
2 |
+++ tests/os-wrappers-test.c |
3 |
@@ -26,6 +26,8 @@ |
3 |
@@ -26,6 +26,8 @@ |
4 |
|
4 |
|
Lines 9-55
Link Here
|
9 |
#include <stdlib.h> |
9 |
#include <stdlib.h> |
10 |
#include <stdint.h> |
10 |
#include <stdint.h> |
11 |
#include <assert.h> |
11 |
#include <assert.h> |
12 |
@@ -38,7 +40,13 @@ |
12 |
@@ -73,10 +75,12 @@ socket(int domain, int type, int protocol) |
13 |
#include <stdarg.h> |
|
|
14 |
#include <fcntl.h> |
15 |
#include <stdio.h> |
16 |
+ |
17 |
+#ifdef HAVE_SYS_EPOLL_H |
18 |
#include <sys/epoll.h> |
19 |
+#elif HAVE_SYS_EVENT_H |
20 |
+#include <sys/event.h> |
21 |
+#include <sys/types.h> |
22 |
+#endif |
23 |
|
24 |
#include "wayland-private.h" |
25 |
#include "test-runner.h" |
26 |
@@ -55,8 +63,13 @@ static int wrapped_calls_fcntl; |
27 |
static ssize_t (*real_recvmsg)(int, struct msghdr *, int); |
28 |
static int wrapped_calls_recvmsg; |
29 |
|
30 |
+#ifdef HAVE_SYS_EPOLL_H |
31 |
static int (*real_epoll_create1)(int); |
32 |
static int wrapped_calls_epoll_create1; |
33 |
+#elif HAVE_SYS_EVENT_H |
34 |
+static int (*real_kqueue)(void); |
35 |
+static int wrapped_calls_kqueue; |
36 |
+#endif |
37 |
|
38 |
static void |
39 |
init_fallbacks(int do_fallbacks) |
40 |
@@ -65,7 +78,11 @@ init_fallbacks(int do_fallbacks) |
41 |
real_socket = dlsym(RTLD_NEXT, "socket"); |
42 |
real_fcntl = dlsym(RTLD_NEXT, "fcntl"); |
43 |
real_recvmsg = dlsym(RTLD_NEXT, "recvmsg"); |
44 |
+#ifdef HAVE_SYS_EPOLL_H |
45 |
real_epoll_create1 = dlsym(RTLD_NEXT, "epoll_create1"); |
46 |
+#elif HAVE_SYS_EVENT_H |
47 |
+ real_kqueue = dlsym(RTLD_NEXT, "kqueue"); |
48 |
+#endif |
49 |
} |
50 |
|
51 |
__attribute__ ((visibility("default"))) int |
52 |
@@ -73,10 +90,12 @@ socket(int domain, int type, int protoco |
53 |
{ |
13 |
{ |
54 |
wrapped_calls_socket++; |
14 |
wrapped_calls_socket++; |
55 |
|
15 |
|
Lines 62-68
Link Here
|
62 |
|
22 |
|
63 |
return real_socket(domain, type, protocol); |
23 |
return real_socket(domain, type, protocol); |
64 |
} |
24 |
} |
65 |
@@ -89,10 +108,12 @@ fcntl(int fd, int cmd, ...) |
25 |
@@ -89,10 +93,12 @@ fcntl(int fd, int cmd, ...) |
66 |
|
26 |
|
67 |
wrapped_calls_fcntl++; |
27 |
wrapped_calls_fcntl++; |
68 |
|
28 |
|
Lines 75-81
Link Here
|
75 |
|
35 |
|
76 |
va_start(ap, cmd); |
36 |
va_start(ap, cmd); |
77 |
arg = va_arg(ap, void*); |
37 |
arg = va_arg(ap, void*); |
78 |
@@ -106,14 +127,17 @@ recvmsg(int sockfd, struct msghdr *msg, |
38 |
@@ -106,10 +112,12 @@ recvmsg(int sockfd, struct msghdr *msg, int flags) |
79 |
{ |
39 |
{ |
80 |
wrapped_calls_recvmsg++; |
40 |
wrapped_calls_recvmsg++; |
81 |
|
41 |
|
Lines 88-115
Link Here
|
88 |
|
48 |
|
89 |
return real_recvmsg(sockfd, msg, flags); |
49 |
return real_recvmsg(sockfd, msg, flags); |
90 |
} |
50 |
} |
91 |
|
51 |
@@ -156,12 +164,14 @@ TEST(os_wrappers_socket_cloexec) |
92 |
+#ifdef HAVE_SYS_EPOLL_H |
|
|
93 |
__attribute__ ((visibility("default"))) int |
94 |
epoll_create1(int flags) |
95 |
{ |
96 |
@@ -127,6 +151,15 @@ epoll_create1(int flags) |
97 |
|
98 |
return real_epoll_create1(flags); |
99 |
} |
100 |
+#elif HAVE_SYS_EVENT_H |
101 |
+__attribute__ ((visibility("default"))) int |
102 |
+kqueue(void) |
103 |
+{ |
104 |
+ wrapped_calls_kqueue++; |
105 |
+ |
106 |
+ return real_kqueue(); |
107 |
+} |
108 |
+#endif |
109 |
|
110 |
static void |
111 |
do_os_wrappers_socket_cloexec(int n) |
112 |
@@ -156,12 +189,14 @@ TEST(os_wrappers_socket_cloexec) |
113 |
do_os_wrappers_socket_cloexec(0); |
52 |
do_os_wrappers_socket_cloexec(0); |
114 |
} |
53 |
} |
115 |
|
54 |
|
Lines 124-130
Link Here
|
124 |
|
63 |
|
125 |
static void |
64 |
static void |
126 |
do_os_wrappers_dupfd_cloexec(int n) |
65 |
do_os_wrappers_dupfd_cloexec(int n) |
127 |
@@ -195,11 +230,13 @@ TEST(os_wrappers_dupfd_cloexec) |
66 |
@@ -195,11 +205,13 @@ TEST(os_wrappers_dupfd_cloexec) |
128 |
do_os_wrappers_dupfd_cloexec(0); |
67 |
do_os_wrappers_dupfd_cloexec(0); |
129 |
} |
68 |
} |
130 |
|
69 |
|
Lines 138-144
Link Here
|
138 |
|
77 |
|
139 |
struct marshal_data { |
78 |
struct marshal_data { |
140 |
struct wl_connection *read_connection; |
79 |
struct wl_connection *read_connection; |
141 |
@@ -218,8 +255,7 @@ struct marshal_data { |
80 |
@@ -218,8 +230,7 @@ struct marshal_data { |
142 |
static void |
81 |
static void |
143 |
setup_marshal_data(struct marshal_data *data) |
82 |
setup_marshal_data(struct marshal_data *data) |
144 |
{ |
83 |
{ |
Lines 148-154
Link Here
|
148 |
|
87 |
|
149 |
data->read_connection = wl_connection_create(data->s[0]); |
88 |
data->read_connection = wl_connection_create(data->s[0]); |
150 |
assert(data->read_connection); |
89 |
assert(data->read_connection); |
151 |
@@ -328,11 +364,13 @@ TEST(os_wrappers_recvmsg_cloexec) |
90 |
@@ -328,11 +339,13 @@ TEST(os_wrappers_recvmsg_cloexec) |
152 |
do_os_wrappers_recvmsg_cloexec(0); |
91 |
do_os_wrappers_recvmsg_cloexec(0); |
153 |
} |
92 |
} |
154 |
|
93 |
|
Lines 162-185
Link Here
|
162 |
|
101 |
|
163 |
static void |
102 |
static void |
164 |
do_os_wrappers_epoll_create_cloexec(int n) |
103 |
do_os_wrappers_epoll_create_cloexec(int n) |
165 |
@@ -342,12 +380,20 @@ do_os_wrappers_epoll_create_cloexec(int |
|
|
166 |
|
167 |
nr_fds = count_open_fds(); |
168 |
|
169 |
+#ifdef HAVE_SYS_EPOLL_H |
170 |
fd = wl_os_epoll_create_cloexec(); |
171 |
+#elif HAVE_SYS_EVENT_H |
172 |
+ fd = wl_os_kqueue_create_cloexec(); |
173 |
+#endif |
174 |
assert(fd >= 0); |
175 |
|
176 |
#ifdef EPOLL_CLOEXEC |
177 |
+#ifdef HAVE_SYS_EPOLL_H |
178 |
assert(wrapped_calls_epoll_create1 == n); |
179 |
#else |
180 |
+ assert(wrapped_calls_kqueue == n); |
181 |
+#endif |
182 |
+#else |
183 |
printf("No epoll_create1.\n"); |
184 |
#endif |
185 |
|