diff --git a/applications/test/sysInfo/Test-sysInfo.C b/applications/test/sysInfo/Test-sysInfo.C
index ba5006024c..f4aa4c6633 100644
--- a/applications/test/sysInfo/Test-sysInfo.C
+++ b/applications/test/sysInfo/Test-sysInfo.C
@@ -24,14 +24,16 @@ License
along with OpenFOAM. If not, see .
Application
+ Test-sysInfo
Description
+ Simple output of endian and system-information
\*---------------------------------------------------------------------------*/
#include "profilingSysInfo.H"
#include "IOstreams.H"
-#include "endian.H"
+#include "foamEndian.H" // For run-time tests
#include "cpuInfo.H"
using namespace Foam;
diff --git a/src/OpenFOAM/compat/endian.H b/src/OpenFOAM/compat/endian.H
new file mode 100644
index 0000000000..d173f7cc3d
--- /dev/null
+++ b/src/OpenFOAM/compat/endian.H
@@ -0,0 +1,11 @@
+// ************************************************************************* //
+// Compatibility include
+
+#ifndef FoamCompat_endian_H
+#define FoamCompat_endian_H
+
+#include "foamEndian.H"
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/global/foamConfig.Cver b/src/OpenFOAM/global/foamConfig.Cver
index 3e090540f2..b78a514078 100644
--- a/src/OpenFOAM/global/foamConfig.Cver
+++ b/src/OpenFOAM/global/foamConfig.Cver
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
- Copyright (C) 2018-2020 OpenCFD Ltd.
+ Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -32,7 +32,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "foamVersion.H"
-#include "endian.H"
+#include "foamEndianFwd.H" // For big/little endian defines
#include "labelFwd.H"
#include "scalarFwd.H"
diff --git a/src/OpenFOAM/include/foamVersion.H b/src/OpenFOAM/include/foamVersion.H
index c2bbed5329..8e9e478dad 100644
--- a/src/OpenFOAM/include/foamVersion.H
+++ b/src/OpenFOAM/include/foamVersion.H
@@ -50,8 +50,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
-#ifndef foamVersion_H
-#define foamVersion_H
+#ifndef Foam_foamVersion_H
+#define Foam_foamVersion_H
#include
#include
diff --git a/src/OpenFOAM/primitives/endian/endian.H b/src/OpenFOAM/primitives/endian/foamEndian.H
similarity index 71%
rename from src/OpenFOAM/primitives/endian/endian.H
rename to src/OpenFOAM/primitives/endian/foamEndian.H
index 11da40d344..0cf18e0f28 100644
--- a/src/OpenFOAM/primitives/endian/endian.H
+++ b/src/OpenFOAM/primitives/endian/foamEndian.H
@@ -23,41 +23,22 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
-Description
- Help with architecture-specific aspects.
+Class
+ Foam::endian
- Defines WM_BIG_ENDIAN or WM_LITTLE_ENDIAN as well as providing a
- few runtime methods. Primarily used as a namespace, but defined as
- a class to allow pTraits specialization.
+Description
+ Help with architecture-specific aspects, primarily used
+ as a namespace, but defined as a class to allow pTraits specialization.
SourceFiles
- endianI.H
+ foamEndianI.H
\*---------------------------------------------------------------------------*/
-#ifndef Foam_endian_H
-#define Foam_endian_H
+#ifndef Foam_foamEndian_H
+#define Foam_foamEndian_H
-#include
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#ifdef __BYTE_ORDER__
- // Clang, Gcc, Icc, Pgi
- #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
- #define WM_LITTLE_ENDIAN
- #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
- #define WM_BIG_ENDIAN
- #else
- #error "__BYTE_ORDER__ is not BIG or LITTLE endian"
- #endif
-#endif
-
-// Could downgrade to a warning, but then user always needs runtime check.
-#if !defined(WM_BIG_ENDIAN) && !defined(WM_LITTLE_ENDIAN)
- #error "Cannot determine BIG or LITTLE endian."
- #error "Please add to compilation options"
-#endif
+#include "foamEndianFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -74,6 +55,15 @@ public:
// Public Methods
+ // FUTURE?
+ // #if defined (WM_BIG_ENDIAN)
+ // //- The endian name as a string
+ // static constexpr const char* name() noexcept { return "MSB"; }
+ // #else
+ // //- The endian name as a string
+ // static constexpr const char* name() noexcept { return "LSB"; }
+ // #endif
+
//- Runtime check for big endian.
inline static bool isBig() noexcept;
@@ -94,7 +84,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-#include "endianI.H"
+#include "foamEndianI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/primitives/endian/foamEndianFwd.H b/src/OpenFOAM/primitives/endian/foamEndianFwd.H
new file mode 100644
index 0000000000..5af713127c
--- /dev/null
+++ b/src/OpenFOAM/primitives/endian/foamEndianFwd.H
@@ -0,0 +1,71 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | www.openfoam.com
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+ Copyright (C) 2016-2023 OpenCFD Ltd.
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM. If not, see .
+
+Description
+ Define WM_BIG_ENDIAN or WM_LITTLE_ENDIAN
+ and forward declare Foam::endian class.
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef Foam_foamEndianFwd_H
+#define Foam_foamEndianFwd_H
+
+#include
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#ifdef __BYTE_ORDER__
+ // Clang, Gcc, Icc, Pgi
+ #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
+ #define WM_LITTLE_ENDIAN
+ #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+ #define WM_BIG_ENDIAN
+ #else
+ #error "__BYTE_ORDER__ is not BIG or LITTLE endian"
+ #endif
+#endif
+
+// Could downgrade to a warning, but then user always needs runtime check.
+#if !defined(WM_BIG_ENDIAN) && !defined(WM_LITTLE_ENDIAN)
+ #error "Cannot determine BIG or LITTLE endian."
+ #error "Please add to compilation options"
+#endif
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+class endian;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/endian/endianI.H b/src/OpenFOAM/primitives/endian/foamEndianI.H
similarity index 100%
rename from src/OpenFOAM/primitives/endian/endianI.H
rename to src/OpenFOAM/primitives/endian/foamEndianI.H
diff --git a/src/OpenFOAM/primitives/hashes/Hash/Hasher.C b/src/OpenFOAM/primitives/hashes/Hash/Hasher.C
index a3bce4fa83..536816e699 100644
--- a/src/OpenFOAM/primitives/hashes/Hash/Hasher.C
+++ b/src/OpenFOAM/primitives/hashes/Hash/Hasher.C
@@ -29,7 +29,7 @@ Description
#include "Hasher.H"
#include "HasherInt.H"
-#include "endian.H"
+#include "foamEndianFwd.H" // For big/little endian defines
// Left-rotate a 32-bit value and carry by nBits
#define bitRotateLeft(x, nBits) (((x) << (nBits)) | ((x) >> (32 - (nBits))))
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C
index 3f89bb4760..622b00dc42 100644
--- a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C
@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
- Copyright (C) 2019 OpenCFD Ltd.
+ Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -37,8 +37,8 @@ Description
\*---------------------------------------------------------------------------*/
#include "SHA1.H"
-#include "endian.H"
#include "IOstreams.H"
+#include "foamEndian.H" // For byte swapping
#include
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
diff --git a/src/fileFormats/gltf/foamGltfObject.C b/src/fileFormats/gltf/foamGltfObject.C
index 4290e606ce..ffcdd124f4 100644
--- a/src/fileFormats/gltf/foamGltfObject.C
+++ b/src/fileFormats/gltf/foamGltfObject.C
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
- Copyright (C) 2021 OpenCFD Ltd.
+ Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -26,7 +26,7 @@ License
\*---------------------------------------------------------------------------*/
#include "foamGltfObject.H"
-#include "endian.H"
+#include "foamEndianFwd.H" // For big/little endian defines
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/base/foamVtkPTraits.C b/src/fileFormats/vtk/base/foamVtkPTraits.C
index b2e0fc4fef..c312caa9cc 100644
--- a/src/fileFormats/vtk/base/foamVtkPTraits.C
+++ b/src/fileFormats/vtk/base/foamVtkPTraits.C
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
- Copyright (C) 2016-2018 OpenCFD Ltd.
+ Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -26,7 +26,7 @@ License
\*---------------------------------------------------------------------------*/
#include "foamVtkPTraits.H"
-#include "endian.H"
+#include "foamEndianFwd.H" // For big/little endian defines
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
diff --git a/src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.C b/src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.C
index 77ea735550..883e847791 100644
--- a/src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.C
+++ b/src/fileFormats/vtk/format/foamVtkLegacyRawFormatter.C
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
- Copyright (C) 2016-2018 OpenCFD Ltd.
+ Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@@ -27,7 +27,7 @@ License
#include "foamVtkLegacyRawFormatter.H"
#include "foamVtkOutputOptions.H"
-#include "endian.H"
+#include "foamEndian.H" // For byte swapping
#include
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //