Skip to content

Commit 3695b48

Browse files
committed
Fix compilation errors
1 parent 0f8c966 commit 3695b48

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

immutables/_map.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ map_node_array_without(MapNode_Array *self,
18601860
continue;
18611861
}
18621862

1863-
bitmap |= 1 << i;
1863+
bitmap |= 1u << i;
18641864

18651865
if (IS_BITMAP_NODE(node)) {
18661866
MapNode_Bitmap *child = (MapNode_Bitmap *)node;
@@ -2188,8 +2188,8 @@ map_iterator_bitmap_next(MapIteratorState *iter,
21882188
if (node->b_array[pos] == NULL) {
21892189
iter->i_pos[level] = pos + 2;
21902190

2191-
int8_t next_level = level + 1;
2192-
assert(next_level < _Py_HAMT_MAX_TREE_DEPTH);
2191+
assert(level + 1 < _Py_HAMT_MAX_TREE_DEPTH);
2192+
int8_t next_level = (int8_t)(level + 1);
21932193
iter->i_level = next_level;
21942194
iter->i_pos[next_level] = 0;
21952195
iter->i_nodes[next_level] = (MapNode *)
@@ -2250,8 +2250,8 @@ map_iterator_array_next(MapIteratorState *iter,
22502250
if (node->a_array[i] != NULL) {
22512251
iter->i_pos[level] = i + 1;
22522252

2253-
int8_t next_level = level + 1;
2254-
assert(next_level < _Py_HAMT_MAX_TREE_DEPTH);
2253+
assert((level + 1) < _Py_HAMT_MAX_TREE_DEPTH);
2254+
int8_t next_level = (int8_t)(level + 1);
22552255
iter->i_pos[next_level] = 0;
22562256
iter->i_nodes[next_level] = node->a_array[i];
22572257
iter->i_level = next_level;
@@ -2884,7 +2884,7 @@ static PyMappingMethods Map_as_mapping = {
28842884
};
28852885

28862886
PyTypeObject _Map_Type = {
2887-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
2887+
PyVarObject_HEAD_INIT(NULL, 0)
28882888
"Map",
28892889
sizeof(MapObject),
28902890
.tp_methods = Map_methods,
@@ -2907,7 +2907,7 @@ PyTypeObject _Map_Type = {
29072907

29082908

29092909
PyTypeObject _Map_ArrayNode_Type = {
2910-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
2910+
PyVarObject_HEAD_INIT(NULL, 0)
29112911
"map_array_node",
29122912
sizeof(MapNode_Array),
29132913
0,
@@ -2920,7 +2920,7 @@ PyTypeObject _Map_ArrayNode_Type = {
29202920
};
29212921

29222922
PyTypeObject _Map_BitmapNode_Type = {
2923-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
2923+
PyVarObject_HEAD_INIT(NULL, 0)
29242924
"map_bitmap_node",
29252925
sizeof(MapNode_Bitmap) - sizeof(PyObject *),
29262926
sizeof(PyObject *),
@@ -2933,7 +2933,7 @@ PyTypeObject _Map_BitmapNode_Type = {
29332933
};
29342934

29352935
PyTypeObject _Map_CollisionNode_Type = {
2936-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
2936+
PyVarObject_HEAD_INIT(NULL, 0)
29372937
"map_collision_node",
29382938
sizeof(MapNode_Collision) - sizeof(PyObject *),
29392939
sizeof(PyObject *),

immutables/_map.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef IMMUTABLES_MAP_H
22
#define IMMUTABLES_MAP_H
33

4+
#include <stdint.h>
45
#include "Python.h"
56

67
#define _Py_HAMT_MAX_TREE_DEPTH 7
@@ -59,13 +60,13 @@ typedef struct {
5960
} MapIterator;
6061

6162

62-
PyAPI_DATA(PyTypeObject) _Map_Type;
63-
PyAPI_DATA(PyTypeObject) _Map_ArrayNode_Type;
64-
PyAPI_DATA(PyTypeObject) _Map_BitmapNode_Type;
65-
PyAPI_DATA(PyTypeObject) _Map_CollisionNode_Type;
66-
PyAPI_DATA(PyTypeObject) _MapKeys_Type;
67-
PyAPI_DATA(PyTypeObject) _MapValues_Type;
68-
PyAPI_DATA(PyTypeObject) _MapItems_Type;
63+
PyTypeObject _Map_Type;
64+
PyTypeObject _Map_ArrayNode_Type;
65+
PyTypeObject _Map_BitmapNode_Type;
66+
PyTypeObject _Map_CollisionNode_Type;
67+
PyTypeObject _MapKeys_Type;
68+
PyTypeObject _MapValues_Type;
69+
PyTypeObject _MapItems_Type;
6970

7071

7172
#endif

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
VERSION = '0.1'
66

77
CFLAGS = ['-O2']
8-
98
if platform.uname().system != 'Windows':
10-
CFLAGS.extend(['-fsigned-char', '-Wall', '-Wsign-compare', '-Wconversion'])
9+
CFLAGS.extend(['-std=c99', '-fsigned-char', '-Wall',
10+
'-Wsign-compare', '-Wconversion'])
1111

1212

1313
setuptools.setup(

0 commit comments

Comments
 (0)