blob: e2213aca60cc4d9f48c85902c2f8cbf5aacb3c90 [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
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013 configure.ac | 2 ++
14 libweston/weston-error.h | 20 ++++++++++++++++++++
15 libweston/weston-launch.c | 2 +-
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016 3 files changed, 23 insertions(+), 1 deletion(-)
17 create mode 100644 src/weston-error.h
18
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019--- a/configure.ac
20+++ b/configure.ac
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021@@ -60,6 +60,8 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 [[#include <time.h>]])
23 AC_CHECK_HEADERS([execinfo.h])
24
25+AC_CHECK_HEADERS([error.h])
26+
27 AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
28
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029 COMPOSITOR_MODULES="wayland-server >= $WAYLAND_PREREQ_VERSION pixman-1 >= 0.25.2"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030--- /dev/null
Brad Bishop6e60e8b2018-02-01 10:27:11 -050031+++ b/libweston/weston-error.h
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032@@ -0,0 +1,20 @@
33+#ifndef _WESTON_ERROR_H
34+#define _WESTON_ERROR_H
35+
36+#if defined(HAVE_ERROR_H)
37+#include <error.h>
38+#else
39+#include <err.h>
40+#include <string.h>
41+#define _weston_error(S, E, F, ...) do { \
42+ if (E) \
43+ err(S, F ": %s", ##__VA_ARGS__, strerror(E)); \
44+ else \
45+ err(S, F, ##__VA_ARGS__); \
46+} while(0)
47+
48+#define error _weston_error
49+#endif
50+
51+#endif
52+
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053--- a/libweston/weston-launch.c
54+++ b/libweston/weston-launch.c
55@@ -33,7 +33,6 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056 #include <poll.h>
57 #include <errno.h>
58
59-#include <error.h>
60 #include <getopt.h>
61
62 #include <sys/types.h>
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063@@ -59,6 +58,7 @@
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064 #endif
65
66 #include "weston-launch.h"
67+#include "weston-error.h"
68
69 #define DRM_MAJOR 226
70