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

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

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>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/46322
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
---
M src/dev/virtio/base.hh
M src/sim/byteswap.hh
2 files changed, 21 insertions(+), 8 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/dev/virtio/base.hh b/src/dev/virtio/base.hh
index 350e510..6eeb4a4 100644
--- a/src/dev/virtio/base.hh
+++ b/src/dev/virtio/base.hh
@@ -68,17 +68,18 @@
  * of byte swapping.
  */

-
-static inline vring_used_elem
-swap_byte(vring_used_elem v)
+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;
 }

-static inline vring_desc
-swap_byte(vring_desc 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);
diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh
index 30e63d1..82282ec 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,12 @@

 #include <type_traits>

+#include "base/types.hh"
+#include "enums/ByteOrder.hh"
+
+struct vring_used_elem;
+struct vring_desc;
+
// These functions actually perform the swapping for parameters of various bit
 // lengths.
 inline uint64_t
@@ -135,6 +138,15 @@
     return x;
 }

+// Make the function visible in case we need to declare a version of it for
+// other types
+template <typename T>
+std::enable_if_t<std::is_same<T, vring_used_elem>::value, T>
+swap_byte(T v);
+template <typename T>
+std::enable_if_t<std::is_same<T, vring_desc>::value, T>
+swap_byte(T v);
+
 template <typename T, size_t N>
 inline std::array<T, N>
 swap_byte(std::array<T, N> a)

--
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: 5
Gerrit-Owner: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Matt Sinclair <mattdsincl...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
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