From 017d4f8cc3ef6de23ccd757b0bb53f759a3ea6cb Mon Sep 17 00:00:00 2001 From: "Bradley C. Kuszmaul" Date: Tue, 16 Apr 2013 23:57:34 -0400 Subject: [PATCH] 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 --- Makefile | 5 +++-- include/Makefile.include | 18 ++++++++---------- linux/{memory.c => os_malloc.c} | 0 newbrt/Makefile | 2 +- newbrt/memory.c | 22 ++++++++++++++++++++++ windows/{memory.c => os_malloc.c} | 19 +------------------ 6 files changed, 35 insertions(+), 31 deletions(-) rename linux/{memory.c => os_malloc.c} (100%) rename windows/{memory.c => os_malloc.c} (71%) diff --git a/Makefile b/Makefile index 1b7dac22467..a0ca8db885c 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,9 @@ summarize: check check: $(CHECKS) -clean: $(patsubst %,%.dir.clean,$(SRCDIRS)) - $(MAYBEATSIGN)rm -rf lib/*.$(SOEXT) lib/*.$(AEXT) +clean: $(patsubst %,%.dir.clean,$(SRCDIRS)) cleanlib +cleanlib: + $(MAYBEATSIGN)rm -rf lib/*.$(SOEXT) lib/*.$(AEXT) lib/*.bundle install: ./install.bash diff --git a/include/Makefile.include b/include/Makefile.include index f1fb683fa1d..6d259c39803 100644 --- a/include/Makefile.include +++ b/include/Makefile.include @@ -41,10 +41,6 @@ # To make warnings be warnngs instead of errors do # make WERROR= -ifeq ($(filter --no-print-directory,$(MAKE)),) - MAKE+= --no-print-directory #Do not print 'entering directory' infomration. -endif - ifeq ($(DEBUG),) DEBUG = 0 endif @@ -318,13 +314,13 @@ clean-default: ifeq ($(SKIP_LIBPORTABILITYRULE),) ifeq ($(CYGWIN),) $(LIBPORTABILITY): $(TOKUROOT)linux/*.[ch] - $(MAYBEATSIGN)cd $(TOKUROOT)linux && $(MAKE) -s install + $(MAYBEATSIGN)cd $(TOKUROOT)linux && $(MAKE) install else ifneq ($(CC),icc) $(LIBPORTABILITY): $(TOKUROOT)linux/*.[ch] - $(MAYBEATSIGN)cd $(TOKUROOT)linux && $(MAKE) -s install + $(MAYBEATSIGN)cd $(TOKUROOT)linux && $(MAKE) install else $(LIBPORTABILITY): $(TOKUROOT)windows/*.[ch] - $(MAYBEATSIGN)cd $(TOKUROOT)windows && $(MAKE) -s install + $(MAYBEATSIGN)cd $(TOKUROOT)windows && $(MAKE) install endif endif @@ -334,7 +330,7 @@ LOCKTREE_LINEAR = $(TOKUROOT)src/lock_tree/locktree_linear.$(AEXT) LOCKTREE_TLOG = $(TOKUROOT)src/lock_tree/locktree_tlog.$(AEXT) LOCKTREE_LOG = $(TOKUROOT)src/lock_tree/locktree_log.$(AEXT) $(LOCKTREE) $(LOCKTREE_LINEAR) $(LOCKTREE_TLOG) $(LOCKTREE_LOG): $(@D)*.[ch] - $(MAYBEATSIGN)cd $(@D) && $(MAKE) -s $(@F) + $(MAYBEATSIGN)cd $(@D) && $(MAKE) $(@F) endif ifeq ($(SKIP_RANGETREERULE),) @@ -343,19 +339,21 @@ RANGETREE_LINEAR = $(TOKUROOT)src/range_tree/rangetree_linear.$(AEXT) RANGETREE_TLOG = $(TOKUROOT)src/range_tree/rangetree_tlog.$(AEXT) RANGETREE_LOG = $(TOKUROOT)src/range_tree/rangetree_log.$(AEXT) $(RANGETREE) $(RANGETREE_LINEAR) $(RANGETREE_TLOG) $(RANGETREE_LOG): $(@D)*.[ch] - $(MAYBEATSIGN)cd $(@D) && $(MAKE) -s $(@F) + $(MAYBEATSIGN)cd $(@D) && $(MAKE) $(@F) endif ifeq ($(SKIP_NEWBRTRULE),) NEWBRT = $(TOKUROOT)newbrt/newbrt.$(AEXT) NEWBRT_BUNDLE = $(TOKUROOT)newbrt/newbrt.bundle $(NEWBRT): $(@D)*.[ch] - $(MAYBEATSIGN)cd $(@D) && $(MAKE) -s $(@F) + $(MAYBEATSIGN)cd $(@D) && $(MAKE) $(@F) endif BIN_FROM_C_FLAGS =$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS) BIN_FROM_C_FLAGS_NOLIB=$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS_NOLIB) %$(BINSUF):%.c $(DEPEND_COMPILE) $(DEPEND_LINK) + echo LDFLAGS $(LDFLAGS) + echo bin_from_c $(BIN_FROM_C_FLAGS) $(MAYBEATSIGN)$(CC) $< $(BIN_FROM_C_FLAGS) BIN_FROM_O_FLAGS =$(CFLAGS) $(CPPFLAGS) $(BINOUTPUT)$@ $(LDFLAGS) diff --git a/linux/memory.c b/linux/os_malloc.c similarity index 100% rename from linux/memory.c rename to linux/os_malloc.c diff --git a/newbrt/Makefile b/newbrt/Makefile index 7624da4fc78..0f91f625e25 100644 --- a/newbrt/Makefile +++ b/newbrt/Makefile @@ -49,6 +49,7 @@ BRT_SOURCES = \ log \ log_code \ memarena \ + memory \ mempool \ omt \ recover \ @@ -100,7 +101,6 @@ bins: $(BINS) check: bins $(MAYBEATSIGN)cd tests;$(MAKE) check -%$(BINSUF): BIN_FROM_C_FLAGS+=$(LIBPORTABILITY) %$(BINSUF): $(NEWBRT) $(LIBPORTABILITY) checko2: diff --git a/newbrt/memory.c b/newbrt/memory.c index 01a66129046..23228e84f99 100644 --- a/newbrt/memory.c +++ b/newbrt/memory.c @@ -1,3 +1,25 @@ +#include "toku_portability.h" +#include "toku_assert.h" +#include "memory.h" +#include +#include + + +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) { toku_malloc_counter++; if (t_malloc) diff --git a/windows/memory.c b/windows/os_malloc.c similarity index 71% rename from windows/memory.c rename to windows/os_malloc.c index 3d583505f5d..88783d1e0f7 100644 --- a/windows/memory.c +++ b/windows/os_malloc.c @@ -2,29 +2,12 @@ #ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved." #include "toku_portability.h" -#include "memory.h" -#include "assert.h" - +#include #include #include #include -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) { if (n >= 1*1024*1024) n = (n+7) & ~7; // round up to make windbg !heap happy