00-Fix-build-with-musl.patch 1.8 KB

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