Commit 017d4f8c authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul Committed by Yoni Fogel

Separate out the common malloc into newbrt/memory.c, and put the os-specific...

Separate out the common malloc into newbrt/memory.c, and put the os-specific stuff into windows and linux subdirs.  Things are broken. Addresses #1343.

git-svn-id: file:///svn/toku/tokudb.1032b+1343@8559 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0adc9f9b
...@@ -38,8 +38,9 @@ summarize: check ...@@ -38,8 +38,9 @@ summarize: check
check: $(CHECKS) check: $(CHECKS)
clean: $(patsubst %,%.dir.clean,$(SRCDIRS)) clean: $(patsubst %,%.dir.clean,$(SRCDIRS)) cleanlib
$(MAYBEATSIGN)rm -rf lib/*.$(SOEXT) lib/*.$(AEXT) cleanlib:
$(MAYBEATSIGN)rm -rf lib/*.$(SOEXT) lib/*.$(AEXT) lib/*.bundle
install: install:
./install.bash ./install.bash
......
...@@ -41,10 +41,6 @@ ...@@ -41,10 +41,6 @@
# To make warnings be warnngs instead of errors do # To make warnings be warnngs instead of errors do
# make WERROR= # make WERROR=
ifeq ($(filter --no-print-directory,$(MAKE)),)
MAKE+= --no-print-directory #Do not print 'entering directory' infomration.
endif
ifeq ($(DEBUG),) ifeq ($(DEBUG),)
DEBUG = 0 DEBUG = 0
endif endif
...@@ -318,13 +314,13 @@ clean-default: ...@@ -318,13 +314,13 @@ clean-default:
ifeq ($(SKIP_LIBPORTABILITYRULE),) ifeq ($(SKIP_LIBPORTABILITYRULE),)
ifeq ($(CYGWIN),) ifeq ($(CYGWIN),)
$(LIBPORTABILITY): $(TOKUROOT)linux/*.[ch] $(LIBPORTABILITY): $(TOKUROOT)linux/*.[ch]
$(MAYBEATSIGN)cd $(TOKUROOT)linux && $(MAKE) -s install $(MAYBEATSIGN)cd $(TOKUROOT)linux && $(MAKE) install
else ifneq ($(CC),icc) else ifneq ($(CC),icc)
$(LIBPORTABILITY): $(TOKUROOT)linux/*.[ch] $(LIBPORTABILITY): $(TOKUROOT)linux/*.[ch]
$(MAYBEATSIGN)cd $(TOKUROOT)linux && $(MAKE) -s install $(MAYBEATSIGN)cd $(TOKUROOT)linux && $(MAKE) install
else else
$(LIBPORTABILITY): $(TOKUROOT)windows/*.[ch] $(LIBPORTABILITY): $(TOKUROOT)windows/*.[ch]
$(MAYBEATSIGN)cd $(TOKUROOT)windows && $(MAKE) -s install $(MAYBEATSIGN)cd $(TOKUROOT)windows && $(MAKE) install
endif endif
endif endif
...@@ -334,7 +330,7 @@ LOCKTREE_LINEAR = $(TOKUROOT)src/lock_tree/locktree_linear.$(AEXT) ...@@ -334,7 +330,7 @@ LOCKTREE_LINEAR = $(TOKUROOT)src/lock_tree/locktree_linear.$(AEXT)
LOCKTREE_TLOG = $(TOKUROOT)src/lock_tree/locktree_tlog.$(AEXT) LOCKTREE_TLOG = $(TOKUROOT)src/lock_tree/locktree_tlog.$(AEXT)
LOCKTREE_LOG = $(TOKUROOT)src/lock_tree/locktree_log.$(AEXT) LOCKTREE_LOG = $(TOKUROOT)src/lock_tree/locktree_log.$(AEXT)
$(LOCKTREE) $(LOCKTREE_LINEAR) $(LOCKTREE_TLOG) $(LOCKTREE_LOG): $(@D)*.[ch] $(LOCKTREE) $(LOCKTREE_LINEAR) $(LOCKTREE_TLOG) $(LOCKTREE_LOG): $(@D)*.[ch]
$(MAYBEATSIGN)cd $(@D) && $(MAKE) -s $(@F) $(MAYBEATSIGN)cd $(@D) && $(MAKE) $(@F)
endif endif
ifeq ($(SKIP_RANGETREERULE),) ifeq ($(SKIP_RANGETREERULE),)
...@@ -343,19 +339,21 @@ RANGETREE_LINEAR = $(TOKUROOT)src/range_tree/rangetree_linear.$(AEXT) ...@@ -343,19 +339,21 @@ RANGETREE_LINEAR = $(TOKUROOT)src/range_tree/rangetree_linear.$(AEXT)
RANGETREE_TLOG = $(TOKUROOT)src/range_tree/rangetree_tlog.$(AEXT) RANGETREE_TLOG = $(TOKUROOT)src/range_tree/rangetree_tlog.$(AEXT)
RANGETREE_LOG = $(TOKUROOT)src/range_tree/rangetree_log.$(AEXT) RANGETREE_LOG = $(TOKUROOT)src/range_tree/rangetree_log.$(AEXT)
$(RANGETREE) $(RANGETREE_LINEAR) $(RANGETREE_TLOG) $(RANGETREE_LOG): $(@D)*.[ch] $(RANGETREE) $(RANGETREE_LINEAR) $(RANGETREE_TLOG) $(RANGETREE_LOG): $(@D)*.[ch]
$(MAYBEATSIGN)cd $(@D) && $(MAKE) -s $(@F) $(MAYBEATSIGN)cd $(@D) && $(MAKE) $(@F)
endif endif
ifeq ($(SKIP_NEWBRTRULE),) ifeq ($(SKIP_NEWBRTRULE),)
NEWBRT = $(TOKUROOT)newbrt/newbrt.$(AEXT) NEWBRT = $(TOKUROOT)newbrt/newbrt.$(AEXT)
NEWBRT_BUNDLE = $(TOKUROOT)newbrt/newbrt.bundle NEWBRT_BUNDLE = $(TOKUROOT)newbrt/newbrt.bundle
$(NEWBRT): $(@D)*.[ch] $(NEWBRT): $(@D)*.[ch]
$(MAYBEATSIGN)cd $(@D) && $(MAKE) -s $(@F) $(MAYBEATSIGN)cd $(@D) && $(MAKE) $(@F)
endif endif
BIN_FROM_C_FLAGS =$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS) BIN_FROM_C_FLAGS =$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS)
BIN_FROM_C_FLAGS_NOLIB=$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS_NOLIB) BIN_FROM_C_FLAGS_NOLIB=$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS_NOLIB)
%$(BINSUF):%.c $(DEPEND_COMPILE) $(DEPEND_LINK) %$(BINSUF):%.c $(DEPEND_COMPILE) $(DEPEND_LINK)
echo LDFLAGS $(LDFLAGS)
echo bin_from_c $(BIN_FROM_C_FLAGS)
$(MAYBEATSIGN)$(CC) $< $(BIN_FROM_C_FLAGS) $(MAYBEATSIGN)$(CC) $< $(BIN_FROM_C_FLAGS)
BIN_FROM_O_FLAGS =$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS) BIN_FROM_O_FLAGS =$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS)
......
...@@ -49,6 +49,7 @@ BRT_SOURCES = \ ...@@ -49,6 +49,7 @@ BRT_SOURCES = \
log \ log \
log_code \ log_code \
memarena \ memarena \
memory \
mempool \ mempool \
omt \ omt \
recover \ recover \
...@@ -100,7 +101,6 @@ bins: $(BINS) ...@@ -100,7 +101,6 @@ bins: $(BINS)
check: bins check: bins
$(MAYBEATSIGN)cd tests;$(MAKE) check $(MAYBEATSIGN)cd tests;$(MAKE) check
%$(BINSUF): BIN_FROM_C_FLAGS+=$(LIBPORTABILITY)
%$(BINSUF): $(NEWBRT) $(LIBPORTABILITY) %$(BINSUF): $(NEWBRT) $(LIBPORTABILITY)
checko2: checko2:
......
#include "toku_portability.h"
#include "toku_assert.h"
#include "memory.h"
#include <string.h>
#include <stdlib.h>
int toku_memory_check=0;
int toku_calloc_counter = 0;
int toku_malloc_counter = 0;
int toku_realloc_counter = 0;
int toku_free_counter = 0;
typedef void *(*malloc_fun_t)(size_t);
typedef void (*free_fun_t)(void*);
typedef void *(*realloc_fun_t)(void*,size_t);
static malloc_fun_t t_malloc = 0;
static free_fun_t t_free = 0;
static realloc_fun_t t_realloc = 0;
void *toku_malloc(size_t size) { void *toku_malloc(size_t size) {
toku_malloc_counter++; toku_malloc_counter++;
if (t_malloc) if (t_malloc)
......
...@@ -2,29 +2,12 @@ ...@@ -2,29 +2,12 @@
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved." #ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
#include "toku_portability.h" #include "toku_portability.h"
#include "memory.h" #include <stdlib.h>
#include "assert.h"
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
int toku_memory_check=0;
int toku_calloc_counter = 0;
int toku_malloc_counter = 0;
int toku_realloc_counter = 0;
int toku_free_counter = 0;
typedef void *(*malloc_fun_t)(size_t);
typedef void (*free_fun_t)(void*);
typedef void *(*realloc_fun_t)(void*,size_t);
static malloc_fun_t t_malloc = 0;
static free_fun_t t_free = 0;
static realloc_fun_t t_realloc = 0;
static inline size_t resize(size_t n) { static inline size_t resize(size_t n) {
if (n >= 1*1024*1024) if (n >= 1*1024*1024)
n = (n+7) & ~7; // round up to make windbg !heap happy n = (n+7) & ~7; // round up to make windbg !heap happy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment