Skip to content

Commit

Permalink
Fix build with MSVC / Bullseye, ilanschnell#129
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-rogers-sndk committed Jun 14, 2021
1 parent 77b4a45 commit 608a4f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGE_LOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
2021-XX-XX 2.1.3:
-------------------

* Fix building with MSVC / Bullseye, #129

2021-06-13 2.1.2:
-------------------
Expand Down
14 changes: 10 additions & 4 deletions bitarray/bitarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ typedef struct {
#define BITMASK(endian, i) \
(((char) 1) << ((endian) == ENDIAN_LITTLE ? ((i) % 8) : (7 - (i) % 8)))

#ifdef _MSC_VER
#define INLINE __inline
#else
#define INLINE inline
#endif

/* ------------ low level access to bits in bitarrayobject ------------- */

#ifndef NDEBUG
static inline int GETBIT(bitarrayobject *self, Py_ssize_t i)
static INLINE int GETBIT(bitarrayobject *self, Py_ssize_t i)
{
assert(0 <= i && i < self->nbits);
return ((self)->ob_item[(i) / 8] & BITMASK((self)->endian, i) ? 1 : 0);
Expand All @@ -60,7 +66,7 @@ static inline int GETBIT(bitarrayobject *self, Py_ssize_t i)
((self)->ob_item[(i) / 8] & BITMASK((self)->endian, i) ? 1 : 0)
#endif

static inline void
static INLINE void
setbit(bitarrayobject *self, Py_ssize_t i, int bit)
{
char *cp, mask;
Expand All @@ -76,7 +82,7 @@ setbit(bitarrayobject *self, Py_ssize_t i, int bit)

/* sets unused padding bits (within last byte of buffer) to 0,
and return the number of padding bits -- self->nbits is unchanged */
static inline int
static INLINE int
setunused(bitarrayobject *self)
{
const char mask[16] = {
Expand Down Expand Up @@ -110,7 +116,7 @@ static const unsigned char bitcount_lookup[256] = {

/* Interpret a PyObject (usually PyLong or PyBool) as a bit, return 0 or 1.
On error, return -1 and set error message. */
static inline int
static INLINE int
pybit_as_int(PyObject *v)
{
Py_ssize_t x;
Expand Down
3 changes: 2 additions & 1 deletion bitarray/pythoncapi_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,9 @@ PyObject_CallOneArg(PyObject *func, PyObject *arg)
static inline int
PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value)
{
int res;
Py_XINCREF(value);
int res = PyModule_AddObject(module, name, value);
res = PyModule_AddObject(module, name, value);
if (res < 0) {
Py_XDECREF(value);
}
Expand Down

0 comments on commit 608a4f2

Please sign in to comment.