You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by jb...@apache.org on 2005/06/11 01:46:22 UTC
svn commit: r190036 - in /xerces/c/branches/jberry/3.0-unstable: ./
src/xercesc/dom/impl/ src/xercesc/internal/ src/xercesc/util/
src/xercesc/util/Transcoders/Uniconv390/
Author: jberry
Date: Fri Jun 10 16:46:21 2005
New Revision: 190036
URL: http://svn.apache.org/viewcvs?rev=190036&view=rev
Log:
Eliminate need for a configuration-time check for endianness. That, once again,
is a problem where we want to generate multi-architecture binaries, since we
need to be able to configure once, and compile multiple times.
Generate a new bool XMLPlatformUtils::fgXMLChBigEndian. This is true if an
XMLCh is big endian. I changed all other references to the previous Xerces
endian flags ENDIANMODE_BIG and ENDIANMODE_LITTLE to use this runtime variable,
which is set algorithmically at platform init time.
Modified:
xerces/c/branches/jberry/3.0-unstable/configure.ac
xerces/c/branches/jberry/3.0-unstable/src/xercesc/dom/impl/DOMWriterImpl.cpp
xerces/c/branches/jberry/3.0-unstable/src/xercesc/internal/XMLReader.cpp
xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.cpp
xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.hpp
xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/TransService.cpp
xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/Transcoders/Uniconv390/Uniconv390TransService.cpp
Modified: xerces/c/branches/jberry/3.0-unstable/configure.ac
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/configure.ac?rev=190036&r1=190035&r2=190036&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/configure.ac (original)
+++ xerces/c/branches/jberry/3.0-unstable/configure.ac Fri Jun 10 16:46:21 2005
@@ -66,7 +66,6 @@
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
-AC_C_BIGENDIAN
AC_CHECK_SIZEOF(wchar_t)
AC_CHECK_TYPE(size_t)
@@ -121,8 +120,6 @@
XERCES_FILEMGR_SELECTION
XERCES_MUTEXMGR_SELECTION
XERCES_ATOMICOPMGR_SELECTION
-
-
######################################################
# Define some namespace-protected macros for use in the publicly visible
Modified: xerces/c/branches/jberry/3.0-unstable/src/xercesc/dom/impl/DOMWriterImpl.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/src/xercesc/dom/impl/DOMWriterImpl.cpp?rev=190036&r1=190035&r2=190036&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/src/xercesc/dom/impl/DOMWriterImpl.cpp (original)
+++ xerces/c/branches/jberry/3.0-unstable/src/xercesc/dom/impl/DOMWriterImpl.cpp Fri Jun 10 16:46:21 2005
@@ -1831,11 +1831,10 @@
(XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString6) == 0) ||
(XMLString::compareIStringASCII(fEncoding, XMLUni::fgUTF16EncodingString7) == 0) )
{
-#if defined(ENDIANMODE_LITTLE)
- fFormatter->writeBOM(BOM_utf16le, 2);
-#elif defined(ENDIANMODE_BIG)
+ if (XMLPlatformUtils::fgXMLChBigEndian)
fFormatter->writeBOM(BOM_utf16be, 2);
-#endif
+ else
+ fFormatter->writeBOM(BOM_utf16le, 2);
}
else if ((XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4LEncodingString) == 0) ||
(XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4LEncodingString2) == 0) )
@@ -1851,11 +1850,10 @@
(XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4EncodingString2) == 0) ||
(XMLString::compareIStringASCII(fEncoding, XMLUni::fgUCS4EncodingString3) == 0) )
{
-#if defined(ENDIANMODE_LITTLE)
- fFormatter->writeBOM(BOM_ucs4le, 4);
-#elif defined(ENDIANMODE_BIG)
- fFormatter->writeBOM(BOM_ucs4be, 4);
-#endif
+ if (XMLPlatformUtils::fgXMLChBigEndian)
+ fFormatter->writeBOM(BOM_ucs4be, 4);
+ else
+ fFormatter->writeBOM(BOM_ucs4le, 4);
}
return;
Modified: xerces/c/branches/jberry/3.0-unstable/src/xercesc/internal/XMLReader.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/src/xercesc/internal/XMLReader.cpp?rev=190036&r1=190035&r2=190036&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/src/xercesc/internal/XMLReader.cpp (original)
+++ xerces/c/branches/jberry/3.0-unstable/src/xercesc/internal/XMLReader.cpp Fri Jun 10 16:46:21 2005
@@ -1335,23 +1335,22 @@
// Assume not swapped
fSwapped = false;
- #if defined(ENDIANMODE_LITTLE)
-
- if ((fEncoding == XMLRecognizer::UTF_16B)
- || (fEncoding == XMLRecognizer::UCS_4B))
+ if (XMLPlatformUtils::fgXMLChBigEndian)
+ {
+ if ((fEncoding == XMLRecognizer::UTF_16L)
+ || (fEncoding == XMLRecognizer::UCS_4L))
{
fSwapped = true;
}
-
- #elif defined(ENDIANMODE_BIG)
-
- if ((fEncoding == XMLRecognizer::UTF_16L)
- || (fEncoding == XMLRecognizer::UCS_4L))
+ }
+ else
+ {
+ if ((fEncoding == XMLRecognizer::UTF_16B)
+ || (fEncoding == XMLRecognizer::UCS_4B))
{
fSwapped = true;
}
-
- #endif
+ }
}
Modified: xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.cpp?rev=190036&r1=190035&r2=190036&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.cpp (original)
+++ xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.cpp Fri Jun 10 16:46:21 2005
@@ -39,6 +39,8 @@
# include <sys/timeb.h>
#endif
+#include <assert.h>
+
#include <xercesc/util/Mutexes.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/RefVectorOf.hpp>
@@ -178,6 +180,8 @@
XMLMutex* XMLPlatformUtils::fgAtomicMutex = 0;
+bool XMLPlatformUtils::fgXMLChBigEndian = true;
+
// ---------------------------------------------------------------------------
// XMLPlatformUtils: Init/term methods
// ---------------------------------------------------------------------------
@@ -236,6 +240,16 @@
{
fgUserPanicHandler = panicHandler;
}
+
+
+ // Determine our endianness (with regard to a XMLCh 16-bit word)
+ assert(sizeof(XMLCh) == 2);
+ union {
+ XMLCh ch;
+ unsigned char ar[2];
+ } endianTest;
+ endianTest.ch = 0x0102;
+ fgXMLChBigEndian = (endianTest.ar[0] == 0x01);
// Initialize the platform-specific mutex file, and atomic op mgrs
Modified: xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.hpp?rev=190036&r1=190035&r2=190036&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.hpp (original)
+++ xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/PlatformUtils.hpp Fri Jun 10 16:46:21 2005
@@ -133,6 +133,9 @@
static XMLAtomicOpMgr* fgAtomicOpMgr;
static XMLMutex* fgAtomicMutex;
+
+ static bool fgXMLChBigEndian;
+
//@}
Modified: xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/TransService.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/TransService.cpp?rev=190036&r1=190035&r2=190036&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/TransService.cpp (original)
+++ xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/TransService.cpp Fri Jun 10 16:46:21 2005
@@ -277,11 +277,8 @@
//
// Add in our mappings for UTF-16 and UCS-4, little endian
//
- bool swapped = false;
+ bool swapped = XMLPlatformUtils::fgXMLChBigEndian;
- #if defined(ENDIANMODE_BIG)
- swapped = true;
- #endif
gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUTF16Transcoder>(XMLUni::fgUTF16LEncodingString, swapped), XMLRecognizer::UTF_16L);
gMappings->put
(
@@ -327,10 +324,8 @@
//
// Add in our mappings for UTF-16 and UCS-4, big endian
//
- swapped = false;
- #if defined(ENDIANMODE_LITTLE)
- swapped = true;
- #endif
+ swapped = !XMLPlatformUtils::fgXMLChBigEndian;
+
gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUTF16Transcoder>(XMLUni::fgUTF16BEncodingString, swapped), XMLRecognizer::UTF_16B);
gMappings->put
(
Modified: xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/Transcoders/Uniconv390/Uniconv390TransService.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/Transcoders/Uniconv390/Uniconv390TransService.cpp?rev=190036&r1=190035&r2=190036&view=diff
==============================================================================
--- xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/Transcoders/Uniconv390/Uniconv390TransService.cpp (original)
+++ xerces/c/branches/jberry/3.0-unstable/src/xercesc/util/Transcoders/Uniconv390/Uniconv390TransService.cpp Fri Jun 10 16:46:21 2005
@@ -560,11 +560,8 @@
//
// Add in our mappings for UTF-16 and UCS-4, little endian
//
- bool swapped = false;
+ bool swapped = XMLPlatformUtils::fgXMLChBigEndian;
- #if defined(ENDIANMODE_BIG)
- swapped = true;
- #endif
gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUTF16Transcoder>(XMLUni::fgUTF16LEncodingString, swapped), XMLRecognizer::UTF_16L);
gMappings->put
(
@@ -610,10 +607,8 @@
//
// Add in our mappings for UTF-16 and UCS-4, big endian
//
- swapped = false;
- #if defined(ENDIANMODE_LITTLE)
- swapped = true;
- #endif
+ swapped = !XMLPlatformUtils::fgXMLChBigEndian;
+
gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUTF16Transcoder>(XMLUni::fgUTF16BEncodingString, swapped), XMLRecognizer::UTF_16B);
gMappings->put
(
@@ -831,11 +826,8 @@
//
// Add in our mappings for UTF-16 and UCS-4, little endian
//
- bool swapped = false;
+ bool swapped = XMLPlatformUtils::fgXMLChBigEndian;
- #if defined(ENDIANMODE_BIG)
- swapped = true;
- #endif
gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUTF16Transcoder>(XMLUni::fgUTF16LEncodingString, swapped), XMLRecognizer::UTF_16L);
gMappings->put
(
@@ -881,10 +873,8 @@
//
// Add in our mappings for UTF-16 and UCS-4, big endian
//
- swapped = false;
- #if defined(ENDIANMODE_LITTLE)
- swapped = true;
- #endif
+ swapped = !XMLPlatformUtils::fgXMLChBigEndian;
+
gMappingsRecognizer->setElementAt(new EEndianNameMapFor<XMLUTF16Transcoder>(XMLUni::fgUTF16BEncodingString, swapped), XMLRecognizer::UTF_16B);
gMappings->put
(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org