1 From a3dac1c3cee169e52c7d644dd565235a1cd833e3 Mon Sep 17 00:00:00 2001
2 From: Brendan Heading <brendanheading@gmail.com>
3 Date: Wed, 22 Jul 2015 23:10:11 +0100
4 Subject: [PATCH] support for non-glibc libcs
6 Added a TEMP_FAILURE_RETRY macro. This is a glibcism provided by
7 glibc and uclibc, but missing from musl (& possibly other libcs).
9 Upstream-status: submitted (see https://sourceforge.net/p/acpid2/tickets/7/)
15 kacpimon/libnetlink.h | 2 ++
16 libc_compat.h | 40 ++++++++++++++++++++++++++++++++++++++++
21 10 files changed, 53 insertions(+)
22 create mode 100644 libc_compat.h
24 diff --git a/acpi_listen.c b/acpi_listen.c
25 index d0bc175..839e4f9 100644
30 #include "ud_socket.h"
32 +#include "libc_compat.h"
34 static int handle_cmdline(int *argc, char ***argv);
35 static char *read_line(int fd);
37 diff --git a/acpid.c b/acpid.c
38 index 23f1e58..8555c82 100644
42 #include "input_layer.h"
43 #include "inotify_handler.h"
45 +#include "libc_compat.h"
47 static int handle_cmdline(int *argc, char ***argv);
48 static void close_fds(void);
49 diff --git a/event.c b/event.c
50 index 324078f..3b069a2 100644
56 #include "ud_socket.h"
57 +#include "libc_compat.h"
61 * What is a rule? It's polymorphic, pretty much.
62 diff --git a/input_layer.c b/input_layer.c
63 index 9aa19c6..cbf8085 100644
68 #include "connection_list.h"
70 +#include "libc_compat.h"
72 #include "input_layer.h"
74 diff --git a/kacpimon/libnetlink.h b/kacpimon/libnetlink.h
75 index 6185cbc..0c61896 100644
76 --- a/kacpimon/libnetlink.h
77 +++ b/kacpimon/libnetlink.h
79 #include <linux/netlink.h>
80 #include <linux/rtnetlink.h>
82 +#include "libc_compat.h"
87 diff --git a/libc_compat.h b/libc_compat.h
89 index 0000000..39f2336
94 + * libc_compat.h - implement defs/macros missing from some libcs
96 + * Copyright (C) 1999-2000 Andrew Henroid
97 + * Copyright (C) 2001 Sun Microsystems
98 + * Portions Copyright (C) 2004 Tim Hockin (thockin@hockin.org)
100 + * This program is free software; you can redistribute it and/or modify
101 + * it under the terms of the GNU General Public License as published by
102 + * the Free Software Foundation; either version 2 of the License, or
103 + * (at your option) any later version.
105 + * This program is distributed in the hope that it will be useful,
106 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
107 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108 + * GNU General Public License for more details.
110 + * You should have received a copy of the GNU General Public License
111 + * along with this program; if not, write to the Free Software
112 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
115 +#ifndef LIBC_COMPAT_H__
116 +#define LIBC_COMPAT_H__
118 +/* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno'
119 + set to EINTR. This macro is present on glibc/uclibc but may not be in other cases. */
122 +#ifndef TEMP_FAILURE_RETRY
123 +#define TEMP_FAILURE_RETRY(expression) \
125 + ({ long int __result; \
126 + do __result = (long int) (expression); \
127 + while (__result == -1L && errno == EINTR); \
130 +#endif /* __GLIBC__ */
132 +#endif /* LIBC_COMPAT_H__ */
133 diff --git a/libnetlink.c b/libnetlink.c
134 index e61d417..cc7aedc 100644
141 +#include "libc_compat.h"
143 #include "libnetlink.h"
145 void rtnl_close(struct rtnl_handle *rth)
146 diff --git a/netlink.c b/netlink.c
147 index c64e878..27e3536 100644
151 #include "libnetlink.h"
152 #include "genetlink.h"
153 #include "acpi_genetlink.h"
154 +#include "libc_compat.h"
156 #include "acpi_ids.h"
157 #include "connection_list.h"
158 diff --git a/proc.c b/proc.c
159 index 5bb8fa2..f96b913 100644
165 #include "connection_list.h"
166 +#include "libc_compat.h"
170 diff --git a/ud_socket.c b/ud_socket.c
171 index 2790686..1790917 100644
177 #include "ud_socket.h"
178 +#include "libc_compat.h"
181 ud_create_socket(const char *name, mode_t socketmode)