0003-add-RISC-V-endian-detection.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. From d4717a38d2287c2f583fefb2a0ed273337a92bb6 Mon Sep 17 00:00:00 2001
  2. From: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
  3. Date: Mon, 11 Jan 2021 18:18:26 +0100
  4. Subject: [PATCH] msgpack/predef: add riscV support
  5. When the target CPU is riscV, msgpack is unable to detect endianness with a list of errors like:
  6. uhd/host/lib/deps/rpclib/include/rpc/msgpack/pack.hpp:190:2: error: #error msgpack-c supports only big endian and little endian
  7. 190 | #error msgpack-c supports only big endian and little endian
  8. | ^~~~~
  9. and with subsequent errors:
  10. uhd0/host/lib/deps/rpclib/include/rpc/msgpack/pack.hpp:236:46: error: there are no arguments to 'take8_8' that depend on a template parameter, so a declaration of 'take8_8' must be available [-fpermissive]
  11. 236 | char buf[2] = {static_cast<char>(0xccu), take8_8(d)};
  12. |
  13. This is due to a missing support for this architecture in msgpack.
  14. This patch adapt commit from https://github.com/boostorg/predef
  15. [backported from https://github.com/EttusResearch/uhd/pull/400]
  16. Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
  17. ---
  18. .../include/rpc/msgpack/predef/architecture.h | 1 +
  19. .../rpc/msgpack/predef/architecture/riscv.h | 48 +++++++++++++++++++
  20. .../include/rpc/msgpack/predef/other/endian.h | 3 +-
  21. 3 files changed, 51 insertions(+), 1 deletion(-)
  22. create mode 100644 host/lib/deps/rpclib/include/rpc/msgpack/predef/architecture/riscv.h
  23. diff --git a/host/lib/deps/rpclib/include/rpc/msgpack/predef/architecture.h b/host/lib/deps/rpclib/include/rpc/msgpack/predef/architecture.h
  24. index 4a0ce2749..1bd998c59 100644
  25. --- a/host/lib/deps/rpclib/include/rpc/msgpack/predef/architecture.h
  26. +++ b/host/lib/deps/rpclib/include/rpc/msgpack/predef/architecture.h
  27. @@ -18,6 +18,7 @@ http://www.boost.org/LICENSE_1_0.txt)
  28. #include <rpc/msgpack/predef/architecture/parisc.h>
  29. #include <rpc/msgpack/predef/architecture/ppc.h>
  30. #include <rpc/msgpack/predef/architecture/pyramid.h>
  31. +#include <rpc/msgpack/predef/architecture/riscv.h>
  32. #include <rpc/msgpack/predef/architecture/rs6k.h>
  33. #include <rpc/msgpack/predef/architecture/sparc.h>
  34. #include <rpc/msgpack/predef/architecture/superh.h>
  35. diff --git a/host/lib/deps/rpclib/include/rpc/msgpack/predef/architecture/riscv.h b/host/lib/deps/rpclib/include/rpc/msgpack/predef/architecture/riscv.h
  36. new file mode 100644
  37. index 000000000..8b819d77e
  38. --- /dev/null
  39. +++ b/host/lib/deps/rpclib/include/rpc/msgpack/predef/architecture/riscv.h
  40. @@ -0,0 +1,48 @@
  41. +/*
  42. +Copyright Andreas Schwab 2019
  43. +Distributed under the Boost Software License, Version 1.0.
  44. +(See accompanying file LICENSE_1_0.txt or copy at
  45. +http://www.boost.org/LICENSE_1_0.txt)
  46. +*/
  47. +
  48. +#ifndef BOOST_PREDEF_ARCHITECTURE_RISCV_H
  49. +#define BOOST_PREDEF_ARCHITECTURE_RISCV_H
  50. +
  51. +#include <boost/predef/version_number.h>
  52. +#include <boost/predef/make.h>
  53. +
  54. +/* tag::reference[]
  55. += `BOOST_ARCH_RISCV`
  56. +
  57. +http://en.wikipedia.org/wiki/RISC-V[RISC-V] architecture.
  58. +
  59. +[options="header"]
  60. +|===
  61. +| {predef_symbol} | {predef_version}
  62. +
  63. +| `+__riscv+` | {predef_detection}
  64. +|===
  65. +*/ // end::reference[]
  66. +
  67. +#define BOOST_ARCH_RISCV BOOST_VERSION_NUMBER_NOT_AVAILABLE
  68. +
  69. +#if defined(__riscv)
  70. +# undef BOOST_ARCH_RISCV
  71. +# define BOOST_ARCH_RISCV BOOST_VERSION_NUMBER_AVAILABLE
  72. +#endif
  73. +
  74. +#if BOOST_ARCH_RISCV
  75. +# define BOOST_ARCH_RISCV_AVAILABLE
  76. +#endif
  77. +
  78. +#if BOOST_ARCH_RISCV
  79. +# undef BOOST_ARCH_WORD_BITS_32
  80. +# define BOOST_ARCH_WORD_BITS_32 BOOST_VERSION_NUMBER_AVAILABLE
  81. +#endif
  82. +
  83. +#define BOOST_ARCH_RISCV_NAME "RISC-V"
  84. +
  85. +#endif
  86. +
  87. +#include <boost/predef/detail/test.h>
  88. +BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_RISCV,BOOST_ARCH_RISCV_NAME)
  89. diff --git a/host/lib/deps/rpclib/include/rpc/msgpack/predef/other/endian.h b/host/lib/deps/rpclib/include/rpc/msgpack/predef/other/endian.h
  90. index 3f367b3d4..a7c1fb4dc 100644
  91. --- a/host/lib/deps/rpclib/include/rpc/msgpack/predef/other/endian.h
  92. +++ b/host/lib/deps/rpclib/include/rpc/msgpack/predef/other/endian.h
  93. @@ -127,7 +127,8 @@ information and acquired knowledge:
  94. defined(__AARCH64EL__) || \
  95. defined(_MIPSEL) || \
  96. defined(__MIPSEL) || \
  97. - defined(__MIPSEL__)
  98. + defined(__MIPSEL__) || \
  99. + defined(__riscv)
  100. # undef MSGPACK_ENDIAN_LITTLE_BYTE
  101. # define MSGPACK_ENDIAN_LITTLE_BYTE MSGPACK_VERSION_NUMBER_AVAILABLE
  102. # endif
  103. --
  104. 2.26.2