aboutsummaryrefslogtreecommitdiffstats
path: root/testing/usb-moded/fix-musl-incompatibility.patch
blob: 336f7573531e7394f1f2eb297224fe871e85c2cb (plain)
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
Has been merged upstream already. https://git.sailfishos.org/mer-core/usb-moded/merge_requests/57

From 6d19366c5c9fff70c0337e1288b33c6834e3374c Mon Sep 17 00:00:00 2001
From: Bart Ribbers <bribbers@disroot.org>
Date: Wed, 25 Mar 2020 12:48:55 +0100
Subject: [PATCH] Define TEMP_FAILURE_RETRY on non-glibc systems

This makes it work for example on Musl systems
---
 src/usb_moded-modesetting.h | 10 ++++++++++
 src/usb_moded-sigpipe.h     | 10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/src/usb_moded-modesetting.h b/src/usb_moded-modesetting.h
index 95e345a..92cceab 100644
--- a/src/usb_moded-modesetting.h
+++ b/src/usb_moded-modesetting.h
@@ -57,4 +57,14 @@ void modesetting_quit              (void);
 # define write_to_file(path,text)\
      modesetting_write_to_file_real(__FILE__,__LINE__,__FUNCTION__,(path),(text))
 
+/* Used to retry syscalls that can return EINTR. Taken from bionic unistd.h */
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(exp) ({         \
+    __typeof__(exp) _rc;                   \
+    do {                                   \
+        _rc = (exp);                       \
+    } while (_rc == -1 && errno == EINTR); \
+    _rc; })
+#endif
+
 #endif /* USB_MODED_MODESETTING_H_ */
diff --git a/src/usb_moded-sigpipe.h b/src/usb_moded-sigpipe.h
index 095863d..fcea271 100644
--- a/src/usb_moded-sigpipe.h
+++ b/src/usb_moded-sigpipe.h
@@ -37,4 +37,14 @@
 
 bool sigpipe_init(void);
 
+/* Used to retry syscalls that can return EINTR. Taken from Bionic unistd.h */
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(exp) ({         \
+    __typeof__(exp) _rc;                   \
+    do {                                   \
+        _rc = (exp);                       \
+    } while (_rc == -1 && errno == EINTR); \
+    _rc; })
+#endif
+
 #endif /* USB_MODED_SIGPIPE_H_ */
-- 
2.23.0