mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Cleanup endian support (closes #271)
- Place common code under OSspecific. By including "endian.H", either one of WM_BIG_ENDIAN or WM_LITTLE_ENDIAN will be defined. Provides inline 32-bit and 64-bit byte swap routines that can be used/re-used elsewhere. The inplace memory swaps currently used by the VTK output are left for the moment pending further cleanup of that code.
This commit is contained in:
@ -25,31 +25,7 @@ License
|
||||
|
||||
#include "writeFuns.H"
|
||||
#include "vtkTopo.H"
|
||||
|
||||
#if defined(__mips)
|
||||
#include <standards.h>
|
||||
#include <sys/endian.h>
|
||||
#endif
|
||||
|
||||
// MacOSX
|
||||
#ifdef __DARWIN_BYTE_ORDER
|
||||
#if __DARWIN_BYTE_ORDER==__DARWIN_BIG_ENDIAN
|
||||
#undef LITTLE_ENDIAN
|
||||
#else
|
||||
#undef BIG_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LITTLE_ENDIAN) \
|
||||
|| defined(_LITTLE_ENDIAN) \
|
||||
|| defined(__LITTLE_ENDIAN)
|
||||
#define LITTLEENDIAN 1
|
||||
#elif defined(BIG_ENDIAN) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN)
|
||||
#undef LITTLEENDIAN
|
||||
#else
|
||||
#error "Cannot find LITTLE_ENDIAN or BIG_ENDIAN symbol defined."
|
||||
#error "Please add to compilation options"
|
||||
#endif
|
||||
#include "endian.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -85,7 +61,7 @@ void Foam::writeFuns::write
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
#ifdef LITTLEENDIAN
|
||||
#ifdef WM_LITTLE_ENDIAN
|
||||
swapWords(fField.size(), reinterpret_cast<label*>(fField.begin()));
|
||||
#endif
|
||||
os.write
|
||||
@ -138,7 +114,7 @@ void Foam::writeFuns::write
|
||||
{
|
||||
if (binary)
|
||||
{
|
||||
#ifdef LITTLEENDIAN
|
||||
#ifdef WM_LITTLE_ENDIAN
|
||||
swapWords(elems.size(), reinterpret_cast<label*>(elems.begin()));
|
||||
#endif
|
||||
os.write
|
||||
|
||||
Reference in New Issue
Block a user