Daniel Carvalho has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/46322 )

Change subject: RFC,dev,sim: Fix compiler not finding specialized byte_swap
......................................................................

RFC,dev,sim: Fix compiler not finding specialized byte_swap

The specialized version of byte_swap cannot be found by
the compiler. As a temporary workaround to get the major
patch going, move the specialization to the base header
file.

Change-Id: I7d2bfc1c29b70042860ae06cdc043c0490cd8916
Signed-off-by: Daniel R. Carvalho <oda...@yahoo.com.br>
---
M src/dev/virtio/base.hh
M src/sim/byteswap.hh
2 files changed, 40 insertions(+), 37 deletions(-)



diff --git a/src/dev/virtio/base.hh b/src/dev/virtio/base.hh
index 350e510..074f085 100644
--- a/src/dev/virtio/base.hh
+++ b/src/dev/virtio/base.hh
@@ -55,40 +55,6 @@

 class VirtQueue;

-/** @{
- * @name VirtIO endian conversion helpers
- *
- * VirtIO prior to version 1.0 (legacy versions) normally send values
- * to the host in the guest systems native byte order. This is going
- * to change in version 1.0 which mandates little endian. We currently
- * only support the legacy version of VirtIO (the new and shiny
- * standard is still in a draft state and not implemented by the
- * kernel). Once we support the new standard, we should negotiate the
- * VirtIO version with the guest and automatically use the right type
- * of byte swapping.
- */
-
-
-static inline vring_used_elem
-swap_byte(vring_used_elem v)
-{
-    v.id = swap_byte(v.id);
-    v.len = swap_byte(v.len);
-    return v;
-}
-
-static inline vring_desc
-swap_byte(vring_desc v)
-{
-    v.addr = swap_byte(v.addr);
-    v.len = swap_byte(v.len);
-    v.flags = swap_byte(v.flags);
-    v.next = swap_byte(v.next);
-    return v;
-}
-
-/** @} */
-
 /**
  * VirtIO descriptor (chain) wrapper
  *
diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh
index 30e63d1..fd07e0c 100644
--- a/src/sim/byteswap.hh
+++ b/src/sim/byteswap.hh
@@ -33,9 +33,6 @@
 #ifndef __SIM_BYTE_SWAP_HH__
 #define __SIM_BYTE_SWAP_HH__

-#include "base/types.hh"
-#include "enums/ByteOrder.hh"
-
 // This lets us figure out what the byte order of the host system is
 #if defined(__linux__)
 #include <endian.h>
@@ -55,6 +52,10 @@

 #include <type_traits>

+#include "base/types.hh"
+#include "dev/virtio/virtio_ring.h"
+#include "enums/ByteOrder.hh"
+
// These functions actually perform the swapping for parameters of various bit
 // lengths.
 inline uint64_t
@@ -144,6 +145,42 @@
     return a;
 }

+/** @{
+ * @name VirtIO endian conversion helpers
+ *
+ * VirtIO prior to version 1.0 (legacy versions) normally send values
+ * to the host in the guest systems native byte order. This is going
+ * to change in version 1.0 which mandates little endian. We currently
+ * only support the legacy version of VirtIO (the new and shiny
+ * standard is still in a draft state and not implemented by the
+ * kernel). Once we support the new standard, we should negotiate the
+ * VirtIO version with the guest and automatically use the right type
+ * of byte swapping.
+ */
+
+
+template <typename T>
+inline std::enable_if_t<std::is_same<T, vring_used_elem>::value, T>
+swap_byte(T v)
+{
+    v.id = swap_byte(v.id);
+    v.len = swap_byte(v.len);
+    return v;
+}
+
+template <typename T>
+inline std::enable_if_t<std::is_same<T, vring_desc>::value, T>
+swap_byte(T v)
+{
+    v.addr = swap_byte(v.addr);
+    v.len = swap_byte(v.len);
+    v.flags = swap_byte(v.flags);
+    v.next = swap_byte(v.next);
+    return v;
+}
+
+/** @} */
+
 //The conversion functions with fixed endianness on both ends don't need to
 //be in a namespace
 template <typename T> inline T betole(T value) {return swap_byte(value);}

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/46322
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7d2bfc1c29b70042860ae06cdc043c0490cd8916
Gerrit-Change-Number: 46322
Gerrit-PatchSet: 1
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to