blob: fda37895c962fffe8fde05482dc65654b2f70d00 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001From 1c95f64aa342147387ce4b1b7269a5c8b34bd898 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 13 Jul 2017 09:01:04 -0700
4Subject: [PATCH] pypredict/lm: Define error API if platform does not have it
5
6error() API is not implemented across all libcs on linux
7e.g. musl does not provide it.
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 Onboard/pypredict/lm/lm.cpp | 1 -
12 Onboard/pypredict/lm/lm.h | 13 +++++++++++++
13 Onboard/pypredict/lm/lm_dynamic.cpp | 2 --
14 3 files changed, 13 insertions(+), 3 deletions(-)
15
16diff --git a/Onboard/pypredict/lm/lm.cpp b/Onboard/pypredict/lm/lm.cpp
17index 2e64296..37ae241 100644
18--- a/Onboard/pypredict/lm/lm.cpp
19+++ b/Onboard/pypredict/lm/lm.cpp
20@@ -19,7 +19,6 @@
21
22 #include <stdlib.h>
23 #include <stdio.h>
24-#include <error.h>
25 #include <algorithm>
26 #include <cmath>
27 #include <string>
28diff --git a/Onboard/pypredict/lm/lm.h b/Onboard/pypredict/lm/lm.h
29index ed4164a..b8b63ee 100644
30--- a/Onboard/pypredict/lm/lm.h
31+++ b/Onboard/pypredict/lm/lm.h
32@@ -32,6 +32,19 @@
33 #include <algorithm>
34 #include <string>
35
36+#if defined(HAVE_ERROR_H)
37+#include <error.h>
38+#else
39+#include <err.h>
40+#define _onboard_error(S, E, F, ...) do { \
41+ if (E) \
42+ err(S, F ": %s", ##__VA_ARGS__, strerror(E)); \
43+ else \
44+ err(S, F, ##__VA_ARGS__); \
45+} while(0)
46+
47+#define error _onboard_error
48+#endif
49
50 // break into debugger
51 // step twice to come back out of the raise() call into known code
52diff --git a/Onboard/pypredict/lm/lm_dynamic.cpp b/Onboard/pypredict/lm/lm_dynamic.cpp
53index 7c62824..e7c7f40 100644
54--- a/Onboard/pypredict/lm/lm_dynamic.cpp
55+++ b/Onboard/pypredict/lm/lm_dynamic.cpp
56@@ -17,8 +17,6 @@
57 * along with this program. If not, see <http://www.gnu.org/licenses/>.
58 */
59
60-#include <error.h>
61-
62 #include "lm_dynamic.h"
63
64 using namespace std;
65--
662.13.2
67