summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/wayland/weston/0001-make-error-portable.patch
blob: acea9dbc31256f8fb0c118d3ca412258878e6957 (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
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
From c4677e155736062e75687f1a655732c8902e912b Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 29 May 2015 20:56:00 -0700
Subject: [PATCH] make error() portable

error() is not posix but gnu extension so may not be available on all
kind of systemsi e.g. musl.

Upstream-Status: Submitted

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Ming Liu <ming.liu@toradex.com>
---
 libweston/weston-error.h  | 20 ++++++++++++++++++++
 libweston/weston-launch.c |  2 +-
 meson.build               |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 libweston/weston-error.h

diff --git a/libweston/weston-error.h b/libweston/weston-error.h
new file mode 100644
index 0000000..2089d02
--- /dev/null
+++ b/libweston/weston-error.h
@@ -0,0 +1,20 @@
+#ifndef _WESTON_ERROR_H
+#define _WESTON_ERROR_H
+
+#if defined(HAVE_ERROR_H)
+#include <error.h>
+#else
+#include <err.h>
+#include <string.h>
+#define _weston_error(S, E, F, ...) do { \
+	if (E) \
+		err(S, F ": %s", ##__VA_ARGS__, strerror(E)); \
+	else \
+		err(S, F, ##__VA_ARGS__); \
+} while(0)
+
+#define error _weston_error
+#endif
+
+#endif
+
diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
index bf73e0d..9064439 100644
--- a/libweston/weston-launch.c
+++ b/libweston/weston-launch.c
@@ -33,7 +33,6 @@
 #include <poll.h>
 #include <errno.h>
 
-#include <error.h>
 #include <getopt.h>
 
 #include <sys/types.h>
@@ -59,6 +58,7 @@
 #endif
 
 #include "weston-launch.h"
+#include "weston-error.h"
 
 #define DRM_MAJOR 226
 
diff --git a/meson.build b/meson.build
index 2155b7b..baa52d9 100644
--- a/meson.build
+++ b/meson.build
@@ -94,6 +94,7 @@ foreach func : optional_libc_funcs
 endforeach
 
 optional_system_headers = [
+	'error.h',
 	'linux/sync_file.h'
 ]
 foreach hdr : optional_system_headers
-- 
2.7.4