From 35ed91e08e3aef3a0ae3ce103ac5ce96427d76ae Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 1 Feb 2019 13:19:47 +0100 Subject: [PATCH] Prepare int64 management --- CMakeLists.txt | 5 +++++ src/MEDCoupling/MCType.hxx | 5 ++++- src/MEDCoupling/MEDCouplingRefCountObject.cxx | 6 ++++++ src/MEDCoupling/MEDCouplingRefCountObject.hxx | 1 + src/MEDCoupling_Swig/MEDCouplingRefCountObject.i | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3139000fc..909692bc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,7 @@ OPTION(MEDCOUPLING_USE_MPI "(Use MPI containers) - For MED this triggers the bui OPTION(MEDCOUPLING_BUILD_TESTS "Build MED tests." ON) OPTION(MEDCOUPLING_BUILD_DOC "Build MED doc." ON) OPTION(MEDCOUPLING_BUILD_STATIC "Build MEDCoupling library in static mode." OFF) +OPTION(MEDCOUPLING_USE_64BIT_IDS "Size of IDs to refer cells and nodes. 32 bits when OFF (default), 64 bits when ON. Not implemented yet for 64 bits." OFF) IF(${MEDCOUPLING_USE_MPI}) SET(USE_METIS_NOT_PARMETIS OFF) ELSE() @@ -101,6 +102,10 @@ ENDIF() # Set list of prerequisites # ========================= +IF(MEDCOUPLING_USE_64BIT_IDS) + ADD_DEFINITIONS("-DMEDCOUPLING_USE_64BIT_IDS") +ENDIF(MEDCOUPLING_USE_64BIT_IDS) + IF(NOT MEDCOUPLING_MICROMED) FIND_PACKAGE(SalomeHDF5 REQUIRED) FIND_PACKAGE(SalomeMEDFile REQUIRED) diff --git a/src/MEDCoupling/MCType.hxx b/src/MEDCoupling/MCType.hxx index 2bb14a2f5..bd0c868cd 100644 --- a/src/MEDCoupling/MCType.hxx +++ b/src/MEDCoupling/MCType.hxx @@ -27,8 +27,11 @@ namespace MEDCoupling { using Int64 = std::int64_t; using Int32 = std::int32_t; +#ifndef MEDCOUPLING_USE_64BIT_IDS using mcIdType = std::int32_t; - +#else + using mcIdType = std::int64_t; +#endif inline mcIdType ToIdType(std::size_t val) { return mcIdType(val); } } diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.cxx b/src/MEDCoupling/MEDCouplingRefCountObject.cxx index da9e4ee66..394f4308f 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.cxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.cxx @@ -20,6 +20,7 @@ #include "MEDCouplingRefCountObject.hxx" #include "MEDCoupling_version.h" +#include "MCType.hxx" #include "InterpKernelException.hxx" @@ -53,6 +54,11 @@ int MEDCoupling::MEDCouplingSizeOfVoidStar() return 8*sizeof(std::size_t); } +std::size_t MEDCoupling::MEDCouplingSizeOfIDs() +{ + return 8*sizeof(mcIdType); +} + /*! * If true is returned it is a LittleEndian machine. * If false it is a BigEndian machine. diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx index 62e859c1c..ba2ebe5d6 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.hxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.hxx @@ -64,6 +64,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT int MEDCouplingVersion(); MEDCOUPLING_EXPORT void MEDCouplingVersionMajMinRel(int& maj, int& minor, int& releas); MEDCOUPLING_EXPORT int MEDCouplingSizeOfVoidStar(); + MEDCOUPLING_EXPORT std::size_t MEDCouplingSizeOfIDs(); MEDCOUPLING_EXPORT bool MEDCouplingByteOrder(); MEDCOUPLING_EXPORT const char *MEDCouplingByteOrderStr(); MEDCOUPLING_EXPORT bool IsCXX11Compiled(); diff --git a/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i b/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i index 218fafa4a..c79059dfb 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i +++ b/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i @@ -60,6 +60,7 @@ namespace MEDCoupling const char *MEDCouplingVersionStr(); int MEDCouplingVersion(); int MEDCouplingSizeOfVoidStar(); + int MEDCouplingSizeOfIDs(); bool MEDCouplingByteOrder(); const char *MEDCouplingByteOrderStr(); bool IsCXX11Compiled(); -- 2.39.2