File: linux-udev.patch

package info (click to toggle)
qtwebengine-opensource-src 5.7.1+dfsg-6.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,028,096 kB
  • ctags: 1,436,736
  • sloc: cpp: 5,960,176; ansic: 3,477,727; asm: 395,492; python: 320,633; sh: 96,504; perl: 69,449; xml: 42,977; makefile: 28,408; objc: 9,962; yacc: 9,847; tcl: 5,430; lex: 2,259; ruby: 1,053; lisp: 522; awk: 497; pascal: 310; cs: 249; sed: 53
file content (209 lines) | stat: -rw-r--r-- 6,787 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
Index: third_party/libusb/src/libusb/os/linux_udev.cc
diff --git a/third_party/libusb/src/libusb/os/linux_udev.c b/third_party/libusb/src/libusb/os/linux_udev.cc
similarity index 83%
rename from third_party/libusb/src/libusb/os/linux_udev.c
rename to third_party/libusb/src/libusb/os/linux_udev.cc
index 99ac943410557de1a5cdd54082932db972040c2c..1b51ce44f4973c39b906d472b2a0cab51f987d3c 100644
--- a/third_party/libusb/src/libusb/os/linux_udev.c
+++ b/third_party/libusb/src/libusb/os/linux_udev.cc
@@ -37,11 +37,14 @@
 #include <sys/utsname.h>
 #include <sys/socket.h>
 #include <unistd.h>
-#include <libudev.h>
 
+extern "C" {
 #include "libusb.h"
 #include "libusbi.h"
 #include "linux_usbfs.h"
+}
+
+#include "device/udev_linux/udev.h"
 
 /* udev context */
 static struct udev *udev_ctx = NULL;
@@ -58,30 +61,30 @@ int linux_udev_start_event_monitor(void)
 	int r;
 
 	assert(udev_ctx == NULL);
-	udev_ctx = udev_new();
+	udev_ctx = device::udev_new();
 	if (!udev_ctx) {
 		usbi_err(NULL, "could not create udev context");
 		return LIBUSB_ERROR_OTHER;
 	}
 
-	udev_monitor = udev_monitor_new_from_netlink(udev_ctx, "udev");
+	udev_monitor = device::udev_monitor_new_from_netlink(udev_ctx, "udev");
 	if (!udev_monitor) {
 		usbi_err(NULL, "could not initialize udev monitor");
 		goto err_free_ctx;
 	}
 
-	r = udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "usb", 0);
+	r = device::udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "usb", 0);
 	if (r) {
 		usbi_err(NULL, "could not initialize udev monitor filter for \"usb\" subsystem");
 		goto err_free_monitor;
 	}
 
-	if (udev_monitor_enable_receiving(udev_monitor)) {
+	if (device::udev_monitor_enable_receiving(udev_monitor)) {
 		usbi_err(NULL, "failed to enable the udev monitor");
 		goto err_free_monitor;
 	}
 
-	udev_monitor_fd = udev_monitor_get_fd(udev_monitor);
+	udev_monitor_fd = device::udev_monitor_get_fd(udev_monitor);
 
 	/* Some older versions of udev are not non-blocking by default,
 	 * so make sure this is set */
@@ -114,11 +117,11 @@ err_close_pipe:
 	close(udev_control_pipe[0]);
 	close(udev_control_pipe[1]);
 err_free_monitor:
-	udev_monitor_unref(udev_monitor);
+	device::udev_monitor_unref(udev_monitor);
 	udev_monitor = NULL;
 	udev_monitor_fd = -1;
 err_free_ctx:
-	udev_unref(udev_ctx);
+	device::udev_unref(udev_ctx);
 	udev_ctx = NULL;
 	return LIBUSB_ERROR_OTHER;
 }
@@ -141,12 +144,12 @@ int linux_udev_stop_event_monitor(void)
 	pthread_join(linux_event_thread, NULL);
 
 	/* Release the udev monitor */
-	udev_monitor_unref(udev_monitor);
+	device::udev_monitor_unref(udev_monitor);
 	udev_monitor = NULL;
 	udev_monitor_fd = -1;
 
 	/* Clean up the udev context */
-	udev_unref(udev_ctx);
+	device::udev_unref(udev_ctx);
 	udev_ctx = NULL;
 
 	/* close and reset control pipe */
@@ -183,7 +186,7 @@ static void *linux_udev_event_thread_main(void *arg)
 		}
 		if (fds[1].revents & POLLIN) {
 			usbi_mutex_static_lock(&linux_hotplug_lock);
-			udev_dev = udev_monitor_receive_device(udev_monitor);
+			udev_dev = device::udev_monitor_receive_device(udev_monitor);
 			if (udev_dev)
 				udev_hotplug_event(udev_dev);
 			usbi_mutex_static_unlock(&linux_hotplug_lock);
@@ -200,12 +203,12 @@ static int udev_device_info(struct libusb_context *ctx, int detached,
 			    uint8_t *devaddr, const char **sys_name) {
 	const char *dev_node;
 
-	dev_node = udev_device_get_devnode(udev_dev);
+	dev_node = device::udev_device_get_devnode(udev_dev);
 	if (!dev_node) {
 		return LIBUSB_ERROR_OTHER;
 	}
 
-	*sys_name = udev_device_get_sysname(udev_dev);
+	*sys_name = device::udev_device_get_sysname(udev_dev);
 	if (!*sys_name) {
 		return LIBUSB_ERROR_OTHER;
 	}
@@ -223,7 +226,7 @@ static void udev_hotplug_event(struct udev_device* udev_dev)
 	int r;
 
 	do {
-		udev_action = udev_device_get_action(udev_dev);
+		udev_action = device::udev_device_get_action(udev_dev);
 		if (!udev_action) {
 			break;
 		}
@@ -246,7 +249,7 @@ static void udev_hotplug_event(struct udev_device* udev_dev)
 		}
 	} while (0);
 
-	udev_device_unref(udev_dev);
+	device::udev_device_unref(udev_dev);
 }
 
 int linux_udev_scan_devices(struct libusb_context *ctx)
@@ -259,33 +262,33 @@ int linux_udev_scan_devices(struct libusb_context *ctx)
 
 	assert(udev_ctx != NULL);
 
-	enumerator = udev_enumerate_new(udev_ctx);
+	enumerator = device::udev_enumerate_new(udev_ctx);
 	if (NULL == enumerator) {
 		usbi_err(ctx, "error creating udev enumerator");
 		return LIBUSB_ERROR_OTHER;
 	}
 
-	udev_enumerate_add_match_subsystem(enumerator, "usb");
-	udev_enumerate_scan_devices(enumerator);
-	devices = udev_enumerate_get_list_entry(enumerator);
+	device::udev_enumerate_add_match_subsystem(enumerator, "usb");
+	device::udev_enumerate_scan_devices(enumerator);
+	devices = device::udev_enumerate_get_list_entry(enumerator);
 
 	udev_list_entry_foreach(entry, devices) {
-		const char *path = udev_list_entry_get_name(entry);
+		const char *path = device::udev_list_entry_get_name(entry);
 		uint8_t busnum = 0, devaddr = 0;
 
-		udev_dev = udev_device_new_from_syspath(udev_ctx, path);
+		udev_dev = device::udev_device_new_from_syspath(udev_ctx, path);
 
 		r = udev_device_info(ctx, 0, udev_dev, &busnum, &devaddr, &sys_name);
 		if (r) {
-			udev_device_unref(udev_dev);
+			device::udev_device_unref(udev_dev);
 			continue;
 		}
 
 		linux_enumerate_device(ctx, busnum, devaddr, sys_name);
-		udev_device_unref(udev_dev);
+		device::udev_device_unref(udev_dev);
 	}
 
-	udev_enumerate_unref(enumerator);
+	device::udev_enumerate_unref(enumerator);
 
 	return LIBUSB_SUCCESS;
 }
@@ -296,7 +299,7 @@ void linux_udev_hotplug_poll(void)
 
 	usbi_mutex_static_lock(&linux_hotplug_lock);
 	do {
-		udev_dev = udev_monitor_receive_device(udev_monitor);
+		udev_dev = device::udev_monitor_receive_device(udev_monitor);
 		if (udev_dev) {
 			usbi_dbg("Handling hotplug event from hotplug_poll");
 			udev_hotplug_event(udev_dev);
Index: third_party/libusb/src/libusb/os/linux_usbfs.h
diff --git a/third_party/libusb/src/libusb/os/linux_usbfs.h b/third_party/libusb/src/libusb/os/linux_usbfs.h
index 1f5b191f4a745937efe52695d7dbaa949a15df08..eedeaaf3654f22ecaac9fd1332d32b2855450bce 100644
--- a/third_party/libusb/src/libusb/os/linux_usbfs.h
+++ b/third_party/libusb/src/libusb/os/linux_usbfs.h
@@ -159,10 +159,20 @@ struct usbfs_disconnect_claim {
 extern usbi_mutex_static_t linux_hotplug_lock;
 
 #if defined(HAVE_LIBUDEV)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 int linux_udev_start_event_monitor(void);
 int linux_udev_stop_event_monitor(void);
 int linux_udev_scan_devices(struct libusb_context *ctx);
 void linux_udev_hotplug_poll(void);
+
+#ifdef __cplusplus
+}
+#endif
+
 #else
 int linux_netlink_start_event_monitor(void);
 int linux_netlink_stop_event_monitor(void);