Skip to content

Commit

Permalink
Fix bugs for win envs
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimes committed Oct 28, 2017
1 parent 3567113 commit 13c06fa
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions mmh3module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ mmh3_hash(PyObject *self, PyObject *args, PyObject *keywds)
Py_ssize_t target_str_len;
uint32_t seed = 0;
int32_t result[1];
uint32_t t = 0;
long long_result = 0;
int is_signed = 1;
unsigned long long t2 = 0;;

static char *kwlist[] = {(char *)"key", (char *)"seed",
(char *)"signed", NULL};

#ifndef defined(_MSC_VER)
#ifndef _MSC_VER
static uint64_t mask[] = {0x0ffffffff, 0xffffffffffffffff};
#endif

Expand All @@ -63,6 +61,7 @@ mmh3_hash(PyObject *self, PyObject *args, PyObject *keywds)
#endif

/* for standard envs */
long_result = result[0] & mask[is_signed];
return PyLong_FromLong(long_result);
}

Expand All @@ -72,14 +71,13 @@ mmh3_hash_from_buffer(PyObject *self, PyObject *args, PyObject *keywds)
Py_buffer target_buf;
uint32_t seed = 0;
int32_t result[1];
unsigned int t = 0;
long long_result = 0;
int is_signed = 1;

static char *kwlist[] = {(char *)"key", (char *)"seed",
(char *)"signed", NULL};

#ifndef defined(_MSC_VER)
#ifndef _MSC_VER
static uint64_t mask[] = {0x0ffffffff, 0xffffffffffffffff};
#endif

Expand All @@ -90,7 +88,6 @@ mmh3_hash_from_buffer(PyObject *self, PyObject *args, PyObject *keywds)

MurmurHash3_x86_32(target_buf.buf, target_buf.len, seed, result);


/* for Windows envs */
#if defined(_MSC_VER)
long_result = result[0];
Expand All @@ -103,11 +100,7 @@ mmh3_hash_from_buffer(PyObject *self, PyObject *args, PyObject *keywds)

/* for standard envs */
long_result = result[0] & mask[is_signed];
#if PY_MAJOR_VERSION >= 3
return PyLong_FromLong(long_result);
#else
return PyInt_FromLong(long_result);
#endif
}

static PyObject *
Expand Down

0 comments on commit 13c06fa

Please sign in to comment.