Boost logo

Boost-Commit :

From: hljin_at_[hidden]
Date: 2007-08-15 18:19:51


Author: hljin
Date: 2007-08-15 18:19:48 EDT (Wed, 15 Aug 2007)
New Revision: 38704
URL: http://svn.boost.org/trac/boost/changeset/38704

Log:
GIL: added runtime endian-ness detection routines: little_endian() and big_endian()
Text files modified:
   trunk/boost/gil/utilities.hpp | 9 +++++++++
   1 files changed, 9 insertions(+), 0 deletions(-)

Modified: trunk/boost/gil/utilities.hpp
==============================================================================
--- trunk/boost/gil/utilities.hpp (original)
+++ trunk/boost/gil/utilities.hpp 2007-08-15 18:19:48 EDT (Wed, 15 Aug 2007)
@@ -279,6 +279,15 @@
     right = tmp;
 }
 
+/// \brief Run-time detection of whether the underlying architecture is little endian
+inline bool little_endian() {
+ short tester = 0x0001;
+ return *(char*)&tester!=0;
+}
+/// \brief Run-time detection of whether the underlying architecture is big endian
+inline bool big_endian() {
+ return !little_endian();
+}
 
 } } // namespace boost::gil
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk