From 6c6826bb7d401f518d80c17734b33316ed60fc6a Mon Sep 17 00:00:00 2001 From: Cody Permann Date: Wed, 9 Oct 2013 15:50:18 -0600 Subject: [PATCH] Make LIBMESH_USE_64BIT_XDR work! --- src/mesh/xdr_io.C | 5 ++-- src/utils/xdr_cxx.C | 57 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/mesh/xdr_io.C b/src/mesh/xdr_io.C index 8864aa74790..35a45b77be6 100644 --- a/src/mesh/xdr_io.C +++ b/src/mesh/xdr_io.C @@ -41,6 +41,7 @@ namespace libMesh { +//#define LIBMESH_USE_64BIT_XDR #ifdef LIBMESH_USE_64BIT_XDR typedef uint64_t xdr_id_type; #else @@ -908,8 +909,8 @@ void XdrIO::read_serialized_connectivity (Xdr &io, const dof_id_type n_elem) int level=-1; - for (xdr_id_type blk=0, first_elem=0, last_elem=0, n_elem_at_level=0, n_processed_at_level=0; - last_elem() { return (xdrproc_t)(xdr_long); } template <> xdrproc_t xdr_translator() { return (xdrproc_t)(xdr_u_long); } +template <> +xdrproc_t xdr_translator() { return (xdrproc_t)(xdr_u_longlong_t); } + template <> xdrproc_t xdr_translator() { return (xdrproc_t)(xdr_short); } @@ -683,12 +686,24 @@ void Xdr::data_stream (T *val, const unsigned int len, const unsigned int line_b libmesh_assert (this->is_open()); - - xdr_vector(xdrs, - (char*) val, - len, - sizeof(unsigned int), - (xdrproc_t) xdr_u_int); + size_t size_of_type = sizeof(T); + + if (size_of_type <= 4) // 32-bit types + { + xdr_vector(xdrs, + (char*) val, + len, + size_of_type, + (xdrproc_t) xdr_u_int); + } + else // 64-bit types + { + xdr_vector(xdrs, + (char*) val, + len, + size_of_type, + (xdrproc_t) xdr_u_hyper); + } #else @@ -710,12 +725,27 @@ void Xdr::data_stream (T *val, const unsigned int len, const unsigned int line_b libmesh_assert (this->is_open()); - if (len > 0) - xdr_vector(xdrs, - (char*) val, - len, - sizeof(unsigned int), - (xdrproc_t) xdr_u_int); + size_t size_of_type = sizeof(T); + + if (size_of_type <= 4) // 32-bit types + { + if (len > 0) + xdr_vector(xdrs, + (char*) val, + len, + size_of_type, + (xdrproc_t) xdr_u_int); + } + else // 64-bit types + { + if (len > 0) + xdr_vector(xdrs, + (char*) val, + len, + size_of_type, + (xdrproc_t) xdr_u_hyper); + + } #else @@ -1401,6 +1431,7 @@ template void Xdr::data (unsigned int&, template void Xdr::data (unsigned short int&, const char*); template void Xdr::data (short int&, const char*); template void Xdr::data (unsigned long int&, const char*); +template void Xdr::data (unsigned long long&, const char*); template void Xdr::data (long int&, const char*); template void Xdr::data (char&, const char*); template void Xdr::data (signed char&, const char*); @@ -1418,6 +1449,7 @@ template void Xdr::data > (std::vector > (std::vector&, const char*); template void Xdr::data > (std::vector&, const char*); template void Xdr::data > (std::vector&, const char*); +template void Xdr::data > (std::vector&, const char*); template void Xdr::data > (std::vector&, const char*); template void Xdr::data > (std::vector&, const char*); template void Xdr::data > (std::vector&, const char*); @@ -1431,6 +1463,7 @@ template void Xdr::data_stream (int *val, con template void Xdr::data_stream (unsigned short int *val, const unsigned int len, const unsigned int line_break); template void Xdr::data_stream (unsigned int *val, const unsigned int len, const unsigned int line_break); template void Xdr::data_stream (unsigned long int *val, const unsigned int len, const unsigned int line_break); +template void Xdr::data_stream (unsigned long long *val, const unsigned int len, const unsigned int line_break); } // namespace libMesh