[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] certi/libHLA HLAbuffer.cc HLAbuffer.hh
From: |
certi-cvs |
Subject: |
[certi-cvs] certi/libHLA HLAbuffer.cc HLAbuffer.hh |
Date: |
Wed, 19 Nov 2008 10:25:06 +0000 |
CVSROOT: /sources/certi
Module name: certi
Changes by: Petr Gotthard <gotthardp> 08/11/19 10:25:06
Modified files:
libHLA : HLAbuffer.cc HLAbuffer.hh
Log message:
Implemented __assert_endianess to verify that libHLA is used correctly.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/HLAbuffer.cc?cvsroot=certi&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/HLAbuffer.hh?cvsroot=certi&r1=1.5&r2=1.6
Patches:
Index: HLAbuffer.cc
===================================================================
RCS file: /sources/certi/certi/libHLA/HLAbuffer.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- HLAbuffer.cc 2 Aug 2008 14:03:14 -0000 1.1
+++ HLAbuffer.cc 19 Nov 2008 10:25:03 -0000 1.2
@@ -11,7 +11,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// $Id: HLAbuffer.cc,v 1.1 2008/08/02 14:03:14 gotthardp Exp $
+// $Id: HLAbuffer.cc,v 1.2 2008/11/19 10:25:03 gotthardp Exp $
// ----------------------------------------------------------------------------
#include "HLAbuffer.hh"
@@ -24,6 +24,26 @@
__HLAbuffer::BufferList __HLAbuffer::gBuffers;
+const bool
+__HLAbuffer::__is_big_endian()
+{
+#ifdef HOST_IS_BIG_ENDIAN
+ return true;
+#else
+ return false;
+#endif
+}
+
+const bool
+__HLAbuffer::__is_little_endian()
+{
+#ifdef HOST_IS_BIG_ENDIAN
+ return false;
+#else
+ return true;
+#endif
+}
+
//! Print the physical data buffer (for debugging purposes only)
std::ostream& __print_buffer(std::ostream& stream, const void *buffer, size_t
length)
{
@@ -62,5 +82,5 @@
} // namespace libhla
-// $Id: HLAbuffer.cc,v 1.1 2008/08/02 14:03:14 gotthardp Exp $
+// $Id: HLAbuffer.cc,v 1.2 2008/11/19 10:25:03 gotthardp Exp $
Index: HLAbuffer.hh
===================================================================
RCS file: /sources/certi/certi/libHLA/HLAbuffer.hh,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- HLAbuffer.hh 18 Nov 2008 10:21:34 -0000 1.5
+++ HLAbuffer.hh 19 Nov 2008 10:25:05 -0000 1.6
@@ -11,7 +11,7 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// $Id: HLAbuffer.hh,v 1.5 2008/11/18 10:21:34 erk Exp $
+// $Id: HLAbuffer.hh,v 1.6 2008/11/19 10:25:05 gotthardp Exp $
// ----------------------------------------------------------------------------
#ifndef _HLATYPES_BUFFER_HH
@@ -64,6 +64,21 @@
typedef std::map<char*,__HLAbuffer*> BufferList;
static BufferList gBuffers;
+ // used to verify that user set correct endianess
+ static const bool __is_big_endian();
+ static const bool __is_little_endian();
+
+ void __assert_endianess()
+ {
+#ifdef HOST_IS_BIG_ENDIAN
+ if (!__is_big_endian())
+ throw std::runtime_error("compile without -DHOST_IS_BIG_ENDIAN");
+#else
+ if (!__is_little_endian())
+ throw std::runtime_error("compile with -DHOST_IS_BIG_ENDIAN");
+#endif
+ }
+
public:
char *mBegin;
size_t mCapacity;
@@ -76,6 +91,7 @@
__HLAbuffer(size_t capacity)
: mUserAllocated(false), mShakeThat(NULL)
{
+ __assert_endianess();
// exponential growth: capacity *= 1.5
mCapacity = (size_t)(capacity*1.5);
mBegin = (char*)calloc(1, mCapacity);
@@ -86,6 +102,7 @@
__HLAbuffer(void *begin, size_t capacity)
: mBegin((char*)begin), mCapacity(capacity), mUserAllocated(true),
mShakeThat(NULL)
{
+ __assert_endianess();
// store "this" to a global table
gBuffers[mBegin + mCapacity] = this;
}
@@ -165,5 +182,5 @@
#endif // _HLATYPES_BUFFER_HH
-// $Id: HLAbuffer.hh,v 1.5 2008/11/18 10:21:34 erk Exp $
+// $Id: HLAbuffer.hh,v 1.6 2008/11/19 10:25:05 gotthardp Exp $
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [certi-cvs] certi/libHLA HLAbuffer.cc HLAbuffer.hh,
certi-cvs <=