File tree Expand file tree Collapse file tree 7 files changed +40
-19
lines changed
Expand file tree Collapse file tree 7 files changed +40
-19
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,10 @@ SRC = btree_c.c btree_py.py
1111ARCH = x64
1212
1313BTREE_DIR = $(MPY_DIR ) /lib/berkeley-db-1.xx
14- BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error="(void)" -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA )
15- CFLAGS += -I$(BTREE_DIR ) /PORT/include
16- CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter $(BTREE_DEFS )
14+ BERKELEY_DB_CONFIG_FILE ?= \"extmod/berkeley-db/berkeley_db_config_port.h\"
15+ CFLAGS += -I$(BTREE_DIR ) /include
16+ CFLAGS += -DBERKELEY_DB_CONFIG_FILE=$(BERKELEY_DB_CONFIG_FILE )
17+ CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter
1718
1819SRC += $(addprefix $(realpath $(BTREE_DIR ) ) /,\
1920 btree/bt_close.c \
Original file line number Diff line number Diff line change @@ -39,6 +39,10 @@ void abort_(void) {
3939 nlr_raise (mp_obj_new_exception (mp_load_global (MP_QSTR_RuntimeError )));
4040}
4141
42+ int puts (const char * s ) {
43+ return mp_printf (& mp_plat_print , "%s\n" , s );
44+ }
45+
4246int native_errno ;
4347#if defined(__linux__ )
4448int * __errno_location (void )
Original file line number Diff line number Diff line change 1+ // Berkeley-db configuration.
2+
3+ #define __DBINTERFACE_PRIVATE 1
4+ #define mpool_error printf
5+ #define abort abort_
6+ #define virt_fd_t void*
7+
8+ #ifdef MICROPY_BERKELEY_DB_DEFPSIZE
9+ #define DEFPSIZE MICROPY_BERKELEY_DB_DEFPSIZE
10+ #endif
11+
12+ #ifdef MICROPY_BERKELEY_DB_MINCACHE
13+ #define MINCACHE MICROPY_BERKELEY_DB_MINCACHE
14+ #endif
15+
16+ __attribute__((noreturn )) void abort_ (void );
Original file line number Diff line number Diff line change @@ -132,27 +132,27 @@ if(MICROPY_PY_BTREE)
132132 )
133133
134134 target_include_directories (micropy_extmod_btree PRIVATE
135- ${MICROPY_LIB_BERKELEY_DIR} /PORT/ include
135+ ${MICROPY_LIB_BERKELEY_DIR} /include
136136 )
137137
138+ if (NOT BERKELEY_DB_CONFIG_FILE)
139+ set (BERKELEY_DB_CONFIG_FILE "${MICROPY_DIR} /extmod/berkeley-db/berkeley_db_config_port.h" )
140+ endif ()
141+
138142 target_compile_definitions (micropy_extmod_btree PRIVATE
139- __DBINTERFACE_PRIVATE=1
140- mpool_error=printf
141- abort=abort_
142- "virt_fd_t=void*"
143+ BERKELEY_DB_CONFIG_FILE= "${BERKELEY_DB_CONFIG_FILE} "
143144 )
144145
145146 # The include directories and compile definitions below are needed to build
146147 # modbtree.c and should be added to the main MicroPython target.
147148
148149 list (APPEND MICROPY_INC_CORE
149- "${MICROPY_LIB_BERKELEY_DIR} /PORT/ include"
150+ "${MICROPY_LIB_BERKELEY_DIR} /include"
150151 )
151152
152153 list (APPEND MICROPY_DEF_CORE
153154 MICROPY_PY_BTREE=1
154- __DBINTERFACE_PRIVATE=1
155- "virt_fd_t=void*"
155+ BERKELEY_DB_CONFIG_FILE="${BERKELEY_DB_CONFIG_FILE} "
156156 )
157157
158158 list (APPEND MICROPY_SOURCE_EXTMOD
Original file line number Diff line number Diff line change @@ -381,8 +381,10 @@ endif
381381
382382ifeq ($(MICROPY_PY_BTREE ) ,1)
383383BTREE_DIR = lib/berkeley-db-1.xx
384- BTREE_DEFS = -D__DBINTERFACE_PRIVATE=1 -Dmpool_error=printf -Dabort=abort_ "-Dvirt_fd_t=void*" $(BTREE_DEFS_EXTRA )
385- INC += -I$(TOP ) /$(BTREE_DIR ) /PORT/include
384+ BERKELEY_DB_CONFIG_FILE ?= \"extmod/berkeley-db/berkeley_db_config_port.h\"
385+ CFLAGS_EXTMOD += -DBERKELEY_DB_CONFIG_FILE=$(BERKELEY_DB_CONFIG_FILE )
386+ CFLAGS_EXTMOD += $(BTREE_DEFS_EXTRA )
387+ INC += -I$(TOP ) /$(BTREE_DIR ) /include
386388SRC_THIRDPARTY_C += $(addprefix $(BTREE_DIR ) /,\
387389 btree/bt_close.c \
388390 btree/bt_conv.c \
@@ -401,9 +403,7 @@ SRC_THIRDPARTY_C += $(addprefix $(BTREE_DIR)/,\
401403 )
402404CFLAGS_EXTMOD += -DMICROPY_PY_BTREE=1
403405# we need to suppress certain warnings to get berkeley-db to compile cleanly
404- # and we have separate BTREE_DEFS so the definitions don't interfere with other source code
405- $(BUILD ) /$(BTREE_DIR ) /% .o : CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter -Wno-deprecated-non-prototype -Wno-unknown-warning-option $(BTREE_DEFS )
406- $(BUILD ) /extmod/modbtree.o : CFLAGS += $(BTREE_DEFS )
406+ $(BUILD ) /$(BTREE_DIR ) /% .o : CFLAGS += -Wno-old-style-definition -Wno-sign-compare -Wno-unused-parameter -Wno-deprecated-non-prototype -Wno-unknown-warning-option
407407endif
408408
409409# ###############################################################################
Original file line number Diff line number Diff line change 5757#undef CIRCLEQ_INSERT_TAIL
5858#undef CIRCLEQ_REMOVE
5959
60- #include <db.h>
61- #include <../../ btree/btree.h>
60+ #include "berkeley-db/db.h"
61+ #include "berkeley-db/ btree.h"
6262
6363typedef struct _mp_obj_btree_t {
6464 mp_obj_base_t base ;
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ MICROPY_ROM_TEXT_COMPRESSION ?= 1
3838MICROPY_PY_SSL = 1
3939MICROPY_SSL_AXTLS = 1
4040AXTLS_DEFS_EXTRA = -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096
41- BTREE_DEFS_EXTRA = -DDEFPSIZE =1024 -DMINCACHE =3
41+ BTREE_DEFS_EXTRA = -DMICROPY_BERKELEY_DB_DEFPSIZE =1024 -DMICROPY_BERKELEY_DB_MINCACHE =3
4242
4343FROZEN_MANIFEST ?= boards/manifest.py
4444
You can’t perform that action at this time.
0 commit comments