Use uint32/64/_t instead of Hash32/64_t hash
authorPeter D. Barnes, Jr. <barnes26@llnl.gov>
Tue, 13 Nov 2012 16:41:46 -0800
branchhash
changeset 9936 51de54536ee3
parent 9935 1aef526650a3
child 9937 afe5f01d019b
Use uint32/64/_t instead of Hash32/64_t
doc/manual/source/hash-functions.rst
src/core/model/hash-fnv.cc
src/core/model/hash-fnv.h
src/core/model/hash-function.cc
src/core/model/hash-function.h
src/core/model/hash-murmur3.cc
src/core/model/hash-murmur3.h
src/core/model/hash.h
src/core/test/hash-test-suite.cc
src/lte/model/lte-radio-bearer-tag.cc
src/lte/model/lte-radio-bearer-tag.h
src/lte/model/lte-rlc-um.cc
src/lte/model/lte-rlc-um.h
--- a/doc/manual/source/hash-functions.rst	Tue Nov 13 16:41:15 2012 -0800
+++ b/doc/manual/source/hash-functions.rst	Tue Nov 13 16:41:46 2012 -0800
@@ -27,16 +27,12 @@
   char * buffer = ...
   size_t buffer_size = ...
   
-  Hash32_t  buffer_hash = Hash32 ( buffer, buffer_size);
+  uint32_t  buffer_hash = Hash32 ( buffer, buffer_size);
 
   std::string s;
-  Hash32_t  string_hash = Hash32 (s);
+  uint32_t  string_hash = Hash32 (s);
 
-The ``Hash32_t`` type (just an ``uint32_t``) is a reminder that
-hash values are opaque.
-
-Equivalent functions and ``Hash64_t`` type are defined for 64-bit hash
-values.
+Equivalent functions are defined for 64-bit hash values.
 
 Incremental Hashing
 *******************
@@ -62,7 +58,7 @@
 	buffer = <get next buffer>;
 	hasher (buffer, buffer_size);
     }
-  Hash32_t combined_hash = hasher.GetHash32 ();
+  uint32_t combined_hash = hasher.GetHash32 ();
 
 By default ``Hasher`` preserves internal state to enable incremental
 hashing.  If you want to reuse a ``Hasher`` object (for example
@@ -106,8 +102,8 @@
 For this to compile, your ``hashf`` has to match one of the function pointer
 signatures::
 
-  typedef Hash::Hash32_t (*Hash32Function_ptr) (const char *, const size_t);
-  typedef Hash::Hash64_t (*Hash64Function_ptr) (const char *, const size_t);
+  typedef uint32_t (*Hash32Function_ptr) (const char *, const size_t);
+  typedef uint64_t (*Hash64Function_ptr) (const char *, const size_t);
 
 
 Sources for Hash Functions
--- a/src/core/model/hash-fnv.cc	Tue Nov 13 16:41:15 2012 -0800
+++ b/src/core/model/hash-fnv.cc	Tue Nov 13 16:41:46 2012 -0800
@@ -734,7 +734,7 @@
   clear ();
 }
 
-Hash32_t
+uint32_t
 Fnv1a::GetHash32  (const char * buffer, const size_t size)
 {
   m_hash32 =
@@ -742,7 +742,7 @@
   return m_hash32;
 }
 
-Hash64_t
+uint64_t
 Fnv1a::GetHash64  (const char * buffer, const size_t size)
 {
   m_hash64 =
--- a/src/core/model/hash-fnv.h	Tue Nov 13 16:41:15 2012 -0800
+++ b/src/core/model/hash-fnv.h	Tue Nov 13 16:41:46 2012 -0800
@@ -65,7 +65,7 @@
    * \param [in] size length of the buffer, in bytes
    * \return 32-bit hash of the buffer
    */
-  Hash32_t  GetHash32  (const char * buffer, const size_t size);
+  uint32_t  GetHash32  (const char * buffer, const size_t size);
   /**
    * Compute 64-bit hash of a byte buffer.
    *
@@ -80,7 +80,7 @@
    * \param [in] size length of the buffer, in bytes
    * \return 64-bit hash of the buffer
    */
-  Hash64_t  GetHash64  (const char * buffer, const size_t size);
+  uint64_t  GetHash64  (const char * buffer, const size_t size);
   /**
    * Restore initial state
    */
--- a/src/core/model/hash-function.cc	Tue Nov 13 16:41:15 2012 -0800
+++ b/src/core/model/hash-function.cc	Tue Nov 13 16:41:46 2012 -0800
@@ -28,7 +28,7 @@
 
 namespace Hash {
 
-Hash64_t
+uint64_t
 Implementation::GetHash64  (const char * buffer, const size_t size)
 {
   NS_LOG_WARN ("64-bit hash requested, only 32-bit implementation available");
--- a/src/core/model/hash-function.h	Tue Nov 13 16:41:15 2012 -0800
+++ b/src/core/model/hash-function.h	Tue Nov 13 16:41:46 2012 -0800
@@ -30,8 +30,8 @@
  *
  * Hash value opaque types
  */
-typedef uint32_t Hash32_t;
-typedef uint64_t Hash64_t;
+typedef uint32_t uint32_t;
+typedef uint64_t uint64_t;
 
 namespace Hash {
 
@@ -57,7 +57,7 @@
    * \param [in] size length of the buffer, in bytes
    * \return 32-bit hash of the buffer
    */
-  virtual Hash32_t  GetHash32  (const char * buffer, const size_t size) = 0;
+  virtual uint32_t  GetHash32  (const char * buffer, const size_t size) = 0;
   /**
    * Compute 64-bit hash of a byte buffer.
    *
@@ -74,7 +74,7 @@
    * \param [in] size length of the buffer, in bytes
    * \return 64-bit hash of the buffer
    */
-  virtual Hash64_t  GetHash64  (const char * buffer, const size_t size);
+  virtual uint64_t  GetHash64  (const char * buffer, const size_t size);
   /**
    * Restore initial state
    */
@@ -103,8 +103,8 @@
  *
  * See Hash32Implementation<> or Hash64Implementation<>
  */
-typedef Hash32_t (*Hash32Function_ptr) (const char *, const size_t);
-typedef Hash64_t (*Hash64Function_ptr) (const char *, const size_t);
+typedef uint32_t (*Hash32Function_ptr) (const char *, const size_t);
+typedef uint64_t (*Hash64Function_ptr) (const char *, const size_t);
 
 namespace Function {
 
@@ -117,7 +117,7 @@
 {
 public:
   Hash32 (Hash32Function_ptr hp) : m_fp (hp) { };
-  Hash32_t GetHash32 (const char * buffer, const size_t size)
+  uint32_t GetHash32 (const char * buffer, const size_t size)
   {
     return (*m_fp) (buffer, size);
   }
@@ -135,14 +135,14 @@
 {
 public:
   Hash64 (Hash64Function_ptr hp) : m_fp (hp) { };
-  Hash64_t GetHash64 (const char * buffer, const size_t size)
+  uint64_t GetHash64 (const char * buffer, const size_t size)
   {
     return (*m_fp) (buffer, size);
   }
-  Hash32_t GetHash32 (const char * buffer, const size_t size)
+  uint32_t GetHash32 (const char * buffer, const size_t size)
   {
-    Hash64_t hash = GetHash64 (buffer, size);
-    return *(Hash32_t *)(void *)(&hash);
+    uint64_t hash = GetHash64 (buffer, size);
+    return *(uint32_t *)(void *)(&hash);
   }
   void clear () { };
 private:
--- a/src/core/model/hash-murmur3.cc	Tue Nov 13 16:41:15 2012 -0800
+++ b/src/core/model/hash-murmur3.cc	Tue Nov 13 16:41:46 2012 -0800
@@ -430,27 +430,27 @@
   clear ();
 }
 
-Hash32_t
+uint32_t
 Murmur3::GetHash32  (const char * buffer, const size_t size)
 {
   using namespace Murmur3Implementation;
 
   MurmurHash3_x86_32_incr (buffer, size, m_hash32, (void *) & m_hash32);
   m_size32 += size;
-  Hash32_t hash;
+  uint32_t hash;
   MurmurHash3_x86_32_fin  (m_size32, m_hash32, (void *) & hash);
 
   return hash;
 }
 
-Hash64_t
+uint64_t
 Murmur3::GetHash64  (const char * buffer, const size_t size)
 {
   using namespace Murmur3Implementation;
   MurmurHash3_x86_128_incr (buffer, size,
                             (uint32_t *)(void *)m_hash64, (void *)(m_hash64));
   m_size64 += size;
-  Hash64_t hash[2];
+  uint64_t hash[2];
   MurmurHash3_x86_128_fin (m_size64,
                            (uint32_t*)(void *)m_hash64, (void *)hash);
   return hash[0];
--- a/src/core/model/hash-murmur3.h	Tue Nov 13 16:41:15 2012 -0800
+++ b/src/core/model/hash-murmur3.h	Tue Nov 13 16:41:46 2012 -0800
@@ -65,7 +65,7 @@
    * \param [in] size length of the buffer, in bytes
    * \return 32-bit hash of the buffer
    */
-  Hash32_t  GetHash32  (const char * buffer, const size_t size);
+  uint32_t  GetHash32  (const char * buffer, const size_t size);
   /**
    * Compute 64-bit hash of a byte buffer.
    *
@@ -80,7 +80,7 @@
    * \param [in] size length of the buffer, in bytes
    * \return 64-bit hash of the buffer
    */
-  Hash64_t  GetHash64  (const char * buffer, const size_t size);
+  uint64_t  GetHash64  (const char * buffer, const size_t size);
   /**
    * Restore initial state
    */
@@ -97,7 +97,7 @@
   {
     SEED = 0x8BADF00D  // Ate bad food
   };
-  /@{
+  //@{
   /**
    * Cache last hash value, and total bytes hashed,
    * for incremental hashing
--- a/src/core/model/hash.h	Tue Nov 13 16:41:15 2012 -0800
+++ b/src/core/model/hash.h	Tue Nov 13 16:41:46 2012 -0800
@@ -26,7 +26,7 @@
 #include "assert.h"
 #include "ptr.h"
 
-#include "hash-function.h"  // typedef ns3::Hash32_t, ns3::Hash64_t
+#include "hash-function.h"  // typedef ns3::uint32_t, ns3::uint64_t
 #include "hash-murmur3.h"
 #include "hash-fnv.h"
 
@@ -50,7 +50,7 @@
  *  The choice of hash function can be made at construction by
  *    \code
  *    Hasher hasher = Hasher ( Create<Hash::Function::Fnv1a> () );
- *    Hash32_t hash = Hasher.GetHash32 (data);
+ *    uint32_t hash = Hasher.GetHash32 (data);
  *    \endcode
  *
  *  The available implementations are documented in group hash.
@@ -96,7 +96,7 @@
    * \param [in] size length of the buffer, in bytes
    * \return 32-bit hash of the buffer
    */
-  Hash32_t  GetHash32  (const char * buffer, const size_t size);
+  uint32_t  GetHash32  (const char * buffer, const size_t size);
   /**
    * Compute 64-bit hash of a byte buffer
    *
@@ -111,7 +111,7 @@
    * \param [in] size length of the buffer, in bytes
    * \return 64-bit hash of the buffer
    */
-  Hash64_t  GetHash64  (const char * buffer, const size_t size);
+  uint64_t  GetHash64  (const char * buffer, const size_t size);
 
   /**
    * Compute 32-bit hash of a string
@@ -126,7 +126,7 @@
    * \param [in] s string to hash
    * \return 32-bit hash of the string
    */
-  Hash32_t  GetHash32  (const std::string s);
+  uint32_t  GetHash32  (const std::string s);
   /**
    * Compute 64-bit hash of a string
    *
@@ -140,7 +140,7 @@
    * \param [in] s string to hash
    * \return 64-bit hash of the string
    */
-  Hash64_t  GetHash64  (const std::string s);
+  uint64_t  GetHash64  (const std::string s);
   /**
    * Restore initial state
    *
@@ -166,7 +166,7 @@
  * \param [in] size length of the buffer, in bytes
  * \return 32-bit hash of the buffer
  */
-Hash32_t Hash32 (const char * buffer, const size_t size);
+uint32_t Hash32 (const char * buffer, const size_t size);
 /**
  * \ingroup hash
  *
@@ -176,7 +176,7 @@
  * \param [in] size length of the buffer, in bytes
  * \return 64-bit hash of the buffer
  */
-Hash64_t Hash64 (const char * buffer, const size_t size);
+uint64_t Hash64 (const char * buffer, const size_t size);
 
 /**
  * \ingroup hash
@@ -186,7 +186,7 @@
  * \param [in] s string to hash
  * \return 32-bit hash of the string
  */
-Hash32_t Hash32 (const std::string s);
+uint32_t Hash32 (const std::string s);
 /**
  * \ingroup hash
  *
@@ -195,7 +195,7 @@
  * \param [in] s string to hash
  * \return 64-bit hash of the string
  */
-Hash64_t Hash64 (const std::string s);
+uint64_t Hash64 (const std::string s);
 
 }  // namespace ns3
 
@@ -211,7 +211,7 @@
 */
 
 inline
-Hash32_t
+uint32_t
 Hasher::GetHash32  (const char * buffer, const size_t size)
 {
   NS_ASSERT (m_impl != 0);
@@ -219,7 +219,7 @@
 }
 
 inline
-Hash64_t
+uint64_t
 Hasher::GetHash64  (const char * buffer, const size_t size)
 {
   NS_ASSERT (m_impl != 0);
@@ -227,7 +227,7 @@
 }
 
 inline
-Hash32_t
+uint32_t
 Hasher::GetHash32  (const std::string s)
 {
   NS_ASSERT (m_impl != 0);
@@ -235,7 +235,7 @@
 }
 
 inline
-Hash64_t
+uint64_t
 Hasher::GetHash64  (const std::string s)
 {
   NS_ASSERT (m_impl != 0);
@@ -248,28 +248,28 @@
 */
 
 inline
-Hash32_t
+uint32_t
 Hash32 (const char * buffer, const size_t size)
 {
   return Hasher ().GetHash32 (buffer, size);
 }
 
 inline
-Hash64_t
+uint64_t
 Hash64 (const char * buffer, const size_t size)
 {
   return Hasher ().GetHash64 (buffer, size);
 }
 
 inline
-Hash32_t
+uint32_t
 Hash32 (const std::string s)
 {
   return Hasher ().GetHash32 (s);
 }
 
 inline
-Hash64_t
+uint64_t
 Hash64 (const std::string s)
 {
   return Hasher ().GetHash64 (s);
--- a/src/core/test/hash-test-suite.cc	Tue Nov 13 16:41:15 2012 -0800
+++ b/src/core/test/hash-test-suite.cc	Tue Nov 13 16:41:46 2012 -0800
@@ -32,13 +32,13 @@
   HashTestCase (const std::string name);
   virtual ~HashTestCase ();
 protected:
-  void Check ( const std::string hashName, const Hash32_t hash);
-  void Check ( const std::string hashName, const Hash64_t hash);
+  void Check ( const std::string hashName, const uint32_t hash);
+  void Check ( const std::string hashName, const uint64_t hash);
   std::string key;
-  Hash32_t hash32Reference;
-  Hash64_t hash64Reference;
+  uint32_t hash32Reference;
+  uint64_t hash64Reference;
 private:
-  void Check ( const std::string hashName, const int bits, const Hash64_t hash);
+  void Check ( const std::string hashName, const int bits, const uint64_t hash);
   virtual void DoRun (void);
 };  // class HashTestCase
 
@@ -53,23 +53,23 @@
 }
 
 void
-HashTestCase::Check ( const std::string hashName, const Hash32_t hash)
+HashTestCase::Check ( const std::string hashName, const uint32_t hash)
 {
   Check (hashName, 32, hash);
 }
 
 void
-HashTestCase::Check ( const std::string hashName, const Hash64_t hash)
+HashTestCase::Check ( const std::string hashName, const uint64_t hash)
 {
   Check (hashName, 64, hash);
 }
 
 void
-HashTestCase::Check ( std::string hashName, int bits, Hash64_t hash)
+HashTestCase::Check ( std::string hashName, int bits, uint64_t hash)
 {
   int w;
   std::string type;
-  Hash64_t hashRef;
+  uint64_t hashRef;
 
   if (bits == 32)
     {
@@ -231,19 +231,19 @@
 }
 
 // Hash32FunctionPtr
-Hash32_t
+uint32_t
 gnu_sum32 (const char * buffer, const size_t size)
 {
-  Hash32_t h = gnu_sum (buffer, size);
-  return (Hash32_t)( (h << 16) + h);
+  uint32_t h = gnu_sum (buffer, size);
+  return (uint32_t)( (h << 16) + h);
 }
 
 // Hash64FunctionPtr
-Hash64_t
+uint64_t
 gnu_sum64 (const char * buffer, const size_t size)
 {
-  Hash64_t h = gnu_sum32 (buffer, size);
-  return (Hash64_t)( (h << 32) + h);
+  uint64_t h = gnu_sum32 (buffer, size);
+  return (uint64_t)( (h << 32) + h);
 }
 
 class Hash32FunctionPtrTestCase : public HashTestCase