ext/digest/murmurhash/murmurhash.h in digest-murmurhash-0.3.0 vs ext/digest/murmurhash/murmurhash.h in digest-murmurhash-1.0.0
- old
+ new
@@ -8,71 +8,39 @@
// Other compilers
#else // defined(_MSC_VER)
# define BIG_CONSTANT(x) (x##LLU)
#endif // !defined(_MSC_VER)
-#define DEFAULT_SEED "\x00\x00\x00\x00\x00\x00\x00\x00"
-#define MURMURHASH_MAGIC 0x5bd1e995
-#define MURMURHASH_MAGIC64A BIG_CONSTANT(0xc6a4a7935bd1e995)
-#if INTEGER_PACK_LITTLE_ENDIAN
-# define ASSINE_BY_ENDIAN_32(digest, h) do { \
- (digest)[3] = (h) >> 24; \
- (digest)[2] = (h) >> 16; \
- (digest)[1] = (h) >> 8; \
- (digest)[0] = (h); \
-} while (0)
-# define ASSINE_BY_ENDIAN_64(digest, h) do { \
- (digest)[7] = (h) >> 56; \
- (digest)[6] = (h) >> 48; \
- (digest)[5] = (h) >> 40; \
- (digest)[4] = (h) >> 32; \
- (digest)[3] = (h) >> 24; \
- (digest)[2] = (h) >> 16; \
- (digest)[1] = (h) >> 8; \
- (digest)[0] = (h); \
-} while (0)
+#ifdef DYNAMIC_ENDIAN
+ /* for universal binary of NEXTSTEP and MacOS X */
+ /* useless since autoconf 2.63? */
+ static int
+ is_bigendian(void)
+ {
+ static int init = 0;
+ static int endian_value;
+ char *p;
+
+ if (init) return endian_value;
+ init = 1;
+ p = (char*)&init;
+ return endian_value = p[0] ? 0 : 1;
+ }
+# define BIGENDIAN_P() (is_bigendian())
+#elif defined(WORDS_BIGENDIAN)
+# define BIGENDIAN_P() 1
#else
-# define ASSINE_BY_ENDIAN_32(digest, h) do { \
- (digest)[0] = (h) >> 24; \
- (digest)[1] = (h) >> 16; \
- (digest)[2] = (h) >> 8; \
- (digest)[3] = (h); \
-} while (0)
-# define ASSINE_BY_ENDIAN_64(digest, h) do { \
- (digest)[0] = (h) >> 56; \
- (digest)[1] = (h) >> 48; \
- (digest)[2] = (h) >> 40; \
- (digest)[3] = (h) >> 32; \
- (digest)[4] = (h) >> 24; \
- (digest)[5] = (h) >> 16; \
- (digest)[6] = (h) >> 8; \
- (digest)[7] = (h); \
-} while (0)
+# define BIGENDIAN_P() 0
#endif
-/* should be same type structure to digest/stringbuffer */
-typedef struct {
- char* buffer;
- char* p;
- size_t memsize;
-} buffer_t;
+#define MURMURHASH_MAGIC 0x5bd1e995
+#define MURMURHASH_MAGIC64A BIG_CONSTANT(0xc6a4a7935bd1e995)
-#define MURMURHASH(self, name) \
- buffer_t* name; \
- Data_Get_Struct(self, buffer_t, name); \
- if (name == NULL) { \
- rb_raise(rb_eArgError, "NULL found for " # name " when shouldn't be.'"); \
- }
+void assign_by_endian_32(uint8_t *digest, uint64_t h);
+void assign_by_endian_64(uint8_t *digest, uint64_t h);
-VALUE murmur_seed_get32(VALUE self);
-VALUE murmur_seed_get64(VALUE self);
-
-extern ID id_seed, id_DEFAULT_SEED;
-
uint32_t _murmur_finish32(VALUE self, uint32_t (*process)(const char *, uint32_t, uint32_t));
uint64_t _murmur_finish64(VALUE self, uint64_t (*process)(const char *, uint32_t, uint64_t));
uint32_t _murmur_s_digest32(int argc, VALUE *argv, VALUE klass, uint32_t (*process)(const char *, uint32_t, uint32_t));
uint64_t _murmur_s_digest64(int argc, VALUE *argv, VALUE klass, uint64_t (*process)(const char *, uint32_t, uint64_t));
-VALUE hexencode_str_new(VALUE str_digest);
#endif /* ifndef MURMURHASH_INCLUDED */
-