Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From c22e90365d89346258394833cbcad03ff32b2e27 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Fri, 29 May 2015 20:56:00 -0700 |
| 4 | Subject: [PATCH weston] make error() portable |
| 5 | |
| 6 | error() is not posix but gnu extension so may not be available on all |
| 7 | kind of systemsi e.g. musl. |
| 8 | |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | --- |
| 11 | Upstream-Status: Submitted |
| 12 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 13 | configure.ac | 2 ++ |
| 14 | libweston/weston-error.h | 20 ++++++++++++++++++++ |
| 15 | libweston/weston-launch.c | 2 +- |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | 3 files changed, 23 insertions(+), 1 deletion(-) |
| 17 | create mode 100644 src/weston-error.h |
| 18 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | --- a/configure.ac |
| 20 | +++ b/configure.ac |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 21 | @@ -60,6 +60,8 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[], |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 22 | [[#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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 29 | COMPOSITOR_MODULES="wayland-server >= $WAYLAND_PREREQ_VERSION pixman-1 >= 0.25.2" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | --- /dev/null |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 31 | +++ b/libweston/weston-error.h |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | @@ -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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 53 | --- a/libweston/weston-launch.c |
| 54 | +++ b/libweston/weston-launch.c |
| 55 | @@ -33,7 +33,6 @@ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | #include <poll.h> |
| 57 | #include <errno.h> |
| 58 | |
| 59 | -#include <error.h> |
| 60 | #include <getopt.h> |
| 61 | |
| 62 | #include <sys/types.h> |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 63 | @@ -59,6 +58,7 @@ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 64 | #endif |
| 65 | |
| 66 | #include "weston-launch.h" |
| 67 | +#include "weston-error.h" |
| 68 | |
| 69 | #define DRM_MAJOR 226 |
| 70 | |