forked from motioneye-project/motioneyeos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0003-support-for-non-glibc-libcs.patch
184 lines (168 loc) · 4.98 KB
/
0003-support-for-non-glibc-libcs.patch
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
From a3dac1c3cee169e52c7d644dd565235a1cd833e3 Mon Sep 17 00:00:00 2001
From: Brendan Heading <[email protected]>
Date: Wed, 22 Jul 2015 23:10:11 +0100
Subject: [PATCH] support for non-glibc libcs
Added a TEMP_FAILURE_RETRY macro. This is a glibcism provided by
glibc and uclibc, but missing from musl (& possibly other libcs).
Upstream-status: submitted (see https://sourceforge.net/p/acpid2/tickets/7/)
---
acpi_listen.c | 2 ++
acpid.c | 1 +
event.c | 2 ++
input_layer.c | 1 +
kacpimon/libnetlink.h | 2 ++
libc_compat.h | 40 ++++++++++++++++++++++++++++++++++++++++
libnetlink.c | 2 ++
netlink.c | 1 +
proc.c | 1 +
ud_socket.c | 1 +
10 files changed, 53 insertions(+)
create mode 100644 libc_compat.h
diff --git a/acpi_listen.c b/acpi_listen.c
index d0bc175..839e4f9 100644
--- a/acpi_listen.c
+++ b/acpi_listen.c
@@ -39,6 +39,8 @@
#include "acpid.h"
#include "ud_socket.h"
+#include "libc_compat.h"
+
static int handle_cmdline(int *argc, char ***argv);
static char *read_line(int fd);
diff --git a/acpid.c b/acpid.c
index 23f1e58..8555c82 100644
--- a/acpid.c
+++ b/acpid.c
@@ -41,6 +41,7 @@
#include "input_layer.h"
#include "inotify_handler.h"
#include "netlink.h"
+#include "libc_compat.h"
static int handle_cmdline(int *argc, char ***argv);
static void close_fds(void);
diff --git a/event.c b/event.c
index 324078f..3b069a2 100644
--- a/event.c
+++ b/event.c
@@ -39,6 +39,8 @@
#include "log.h"
#include "sock.h"
#include "ud_socket.h"
+#include "libc_compat.h"
+
#include "event.h"
/*
* What is a rule? It's polymorphic, pretty much.
diff --git a/input_layer.c b/input_layer.c
index 9aa19c6..cbf8085 100644
--- a/input_layer.c
+++ b/input_layer.c
@@ -42,6 +42,7 @@
#include "log.h"
#include "connection_list.h"
#include "event.h"
+#include "libc_compat.h"
#include "input_layer.h"
diff --git a/kacpimon/libnetlink.h b/kacpimon/libnetlink.h
index 6185cbc..0c61896 100644
--- a/kacpimon/libnetlink.h
+++ b/kacpimon/libnetlink.h
@@ -7,6 +7,8 @@
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+#include "libc_compat.h"
+
struct rtnl_handle
{
int fd;
diff --git a/libc_compat.h b/libc_compat.h
new file mode 100644
index 0000000..39f2336
--- /dev/null
+++ b/libc_compat.h
@@ -0,0 +1,40 @@
+/*
+ * libc_compat.h - implement defs/macros missing from some libcs
+ *
+ * Copyright (C) 1999-2000 Andrew Henroid
+ * Copyright (C) 2001 Sun Microsystems
+ * Portions Copyright (C) 2004 Tim Hockin ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef LIBC_COMPAT_H__
+#define LIBC_COMPAT_H__
+
+/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
+ set to EINTR. This macro is present on glibc/uclibc but may not be in other cases. */
+
+#ifndef ____GLIBC__
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(expression) \
+ (__extension__ \
+ ({ long int __result; \
+ do __result = (long int) (expression); \
+ while (__result == -1L && errno == EINTR); \
+ __result; }))
+#endif
+#endif /* __GLIBC__ */
+
+#endif /* LIBC_COMPAT_H__ */
diff --git a/libnetlink.c b/libnetlink.c
index e61d417..cc7aedc 100644
--- a/libnetlink.c
+++ b/libnetlink.c
@@ -24,6 +24,8 @@
#include <time.h>
#include <sys/uio.h>
+#include "libc_compat.h"
+
#include "libnetlink.h"
void rtnl_close(struct rtnl_handle *rth)
diff --git a/netlink.c b/netlink.c
index c64e878..27e3536 100644
--- a/netlink.c
+++ b/netlink.c
@@ -41,6 +41,7 @@
#include "libnetlink.h"
#include "genetlink.h"
#include "acpi_genetlink.h"
+#include "libc_compat.h"
#include "acpi_ids.h"
#include "connection_list.h"
diff --git a/proc.c b/proc.c
index 5bb8fa2..f96b913 100644
--- a/proc.c
+++ b/proc.c
@@ -31,6 +31,7 @@
#include "log.h"
#include "event.h"
#include "connection_list.h"
+#include "libc_compat.h"
#include "proc.h"
diff --git a/ud_socket.c b/ud_socket.c
index 2790686..1790917 100644
--- a/ud_socket.c
+++ b/ud_socket.c
@@ -21,6 +21,7 @@
#include "acpid.h"
#include "log.h"
#include "ud_socket.h"
+#include "libc_compat.h"
int
ud_create_socket(const char *name, mode_t socketmode)
--
2.4.3