blob: 148848d8d233669526a89cdf959f6dcba20f5bbf [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001From c22e90365d89346258394833cbcad03ff32b2e27 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 May 2015 20:56:00 -0700
4Subject: [PATCH weston] make error() portable
5
6error() is not posix but gnu extension so may not be available on all
7kind of systemsi e.g. musl.
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11Upstream-Status: Submitted
12
13 configure.ac | 2 ++
14 src/weston-error.h | 20 ++++++++++++++++++++
15 src/weston-launch.c | 2 +-
16 3 files changed, 23 insertions(+), 1 deletion(-)
17 create mode 100644 src/weston-error.h
18
19diff --git a/configure.ac b/configure.ac
20index 263fc22..f52cd62 100644
21--- a/configure.ac
22+++ b/configure.ac
23@@ -57,6 +57,8 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
24 [[#include <time.h>]])
25 AC_CHECK_HEADERS([execinfo.h])
26
27+AC_CHECK_HEADERS([error.h])
28+
29 AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
30
31 COMPOSITOR_MODULES="wayland-server >= 1.7.93 pixman-1 >= 0.25.2"
32diff --git a/src/weston-error.h b/src/weston-error.h
33new file mode 100644
34index 0000000..2089d02
35--- /dev/null
36+++ b/src/weston-error.h
37@@ -0,0 +1,20 @@
38+#ifndef _WESTON_ERROR_H
39+#define _WESTON_ERROR_H
40+
41+#if defined(HAVE_ERROR_H)
42+#include <error.h>
43+#else
44+#include <err.h>
45+#include <string.h>
46+#define _weston_error(S, E, F, ...) do { \
47+ if (E) \
48+ err(S, F ": %s", ##__VA_ARGS__, strerror(E)); \
49+ else \
50+ err(S, F, ##__VA_ARGS__); \
51+} while(0)
52+
53+#define error _weston_error
54+#endif
55+
56+#endif
57+
58diff --git a/src/weston-launch.c b/src/weston-launch.c
59index 10c66de..3e6d30a 100644
60--- a/src/weston-launch.c
61+++ b/src/weston-launch.c
62@@ -30,7 +30,6 @@
63 #include <poll.h>
64 #include <errno.h>
65
66-#include <error.h>
67 #include <getopt.h>
68
69 #include <sys/types.h>
70@@ -56,6 +55,7 @@
71 #endif
72
73 #include "weston-launch.h"
74+#include "weston-error.h"
75
76 #define DRM_MAJOR 226
77
78--
792.1.4
80