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

Compile better on linux, and more dlmalloc fixing. Addresses #1343.

git-svn-id: file:///svn/toku/tokudb.1032b+1343@8553 c7de825b-a66e-492c-adef-691d508d4ae1
parent 7372787c
...@@ -38,8 +38,7 @@ summarize: check ...@@ -38,8 +38,7 @@ summarize: check
check: $(CHECKS) check: $(CHECKS)
clean: clean: $(patsubst %,%.dir.clean,$(SRCDIRS))
$(MAYBEATSIGN)for d in $(SRCDIRS); do (cd $$d && $(MAKE) -k clean); done
$(MAYBEATSIGN)rm -rf lib/*.$(SOEXT) lib/*.$(AEXT) $(MAYBEATSIGN)rm -rf lib/*.$(SOEXT) lib/*.$(AEXT)
install: install:
......
# -*- Mode: Makefile -*-
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved." #ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
# standard build: make # standard build: make
# build with Berkeley DB 4.1: make BDBDIR=/usr/local/BerkeleyDB.4.1 # build with Berkeley DB 4.1: make BDBDIR=/usr/local/BerkeleyDB.4.1
# build with TokuDB: make BDBDIR=~/svn/tokudb # build with TokuDB: make BDBDIR=~/svn/tokudb
# build with g++: make CC=g++
.DEFAULT_GOAL= build
TOKUROOT=../
INCLUDEDIRS=-I. -I../ -I$(TOKUROOT)newbrt -I../range_tree -I../lock_tree
DEPEND_COMPILE += \
./*.h \
#end
SKIP_NORETURN=1 #Do not add the -Wmissing-noreturn flag
HERE = db-benchmark-test-cxx
include $(TOKUROOT)include/Makefile.include
BENCHDBS = bench.bdb/ bench.tokudb BENCHDBS = bench.bdb/ bench.tokudb
...@@ -11,7 +24,7 @@ CXXFLAGS = -Wall -Werror -g $(OPTFLAGS) $(GCOV_FLAGS) ...@@ -11,7 +24,7 @@ CXXFLAGS = -Wall -Werror -g $(OPTFLAGS) $(GCOV_FLAGS)
# CFLAGS += -pg # CFLAGS += -pg
ifdef BDBDIR ifdef BDBDIR
BDB_CPPFLAGS = -I$(BDBDIR)/include BDB_CPPFLAGS = -I$(BDBDIR)/include -DHAVE_CXX_STDHEADERS
BDB_LDFLAGS = -L$(BDBDIR)/lib -ldb_cxx -Wl,-rpath,$(BDBDIR)/lib -lpthread BDB_LDFLAGS = -L$(BDBDIR)/lib -ldb_cxx -Wl,-rpath,$(BDBDIR)/lib -lpthread
else else
BDB_CPPFLAGS = BDB_CPPFLAGS =
...@@ -43,7 +56,7 @@ check-x: $(TARGET_TDB) ...@@ -43,7 +56,7 @@ check-x: $(TARGET_TDB)
$(VALGRIND) ./$(TARGET_TDB) -x $(QUIET) $(SUMMARIZE_CMD) $(VALGRIND) ./$(TARGET_TDB) -x $(QUIET) $(SUMMARIZE_CMD)
clean: clean:
rm -rf $(TARGETS) $(BENCHDBS) *.gcno *.gcda *.gcov $(MAYBEATSIGN)rm -rf $(TARGETS) $(BENCHDBS) *.gcno *.gcda *.gcov
db-benchmark-test-tokudb: ../lib/libtokudb_cxx.a db-benchmark-test-tokudb: ../lib/libtokudb_cxx.a
db-benchmark-test-tokudb: db-benchmark-test.cpp db-benchmark-test-tokudb: db-benchmark-test.cpp
......
...@@ -29,6 +29,7 @@ void *toku_malloc(size_t size) __attribute__((__visibility__("default"))); ...@@ -29,6 +29,7 @@ void *toku_malloc(size_t size) __attribute__((__visibility__("default")));
// xmalloc aborts instead of return NULL if we run out of memory // xmalloc aborts instead of return NULL if we run out of memory
void *toku_xmalloc(size_t size); void *toku_xmalloc(size_t size);
void *toku_xrealloc(void*, size_t size);
/* toku_tagmalloc() performs a malloc(size), but fills in the first 4 bytes with typ. /* toku_tagmalloc() performs a malloc(size), but fills in the first 4 bytes with typ.
* This "tag" is useful if you are debugging and run across a void* that is * This "tag" is useful if you are debugging and run across a void* that is
...@@ -63,8 +64,8 @@ void *toku_realloc(void *, size_t size) __attribute__((__visibility__("default" ...@@ -63,8 +64,8 @@ void *toku_realloc(void *, size_t size) __attribute__((__visibility__("default"
// XMALLOC macros are like MALLOC except they abort if the operation fails // XMALLOC macros are like MALLOC except they abort if the operation fails
#define XMALLOC(v) v = toku_xmalloc(sizeof(*v)) #define XMALLOC(v) v = toku_xmalloc(sizeof(*v))
#define XMALLOC_N(n,v) v = toku_malloc((n)*sizeof(*v)) #define XMALLOC_N(n,v) v = toku_xmalloc((n)*sizeof(*v))
#define XREALLOC_N(n,v) v = toku_realloc(v, (n)*sizeof(*v)) #define XREALLOC_N(n,v) v = toku_xrealloc(v, (n)*sizeof(*v))
/* If you have a type such as /* If you have a type such as
* struct pma *PMA; * struct pma *PMA;
......
...@@ -72,7 +72,7 @@ extern "C" { ...@@ -72,7 +72,7 @@ extern "C" {
// Deprecated functions. // Deprecated functions.
#if !defined(TOKU_ALLOW_DEPRECATED) #if !defined(TOKU_ALLOW_DEPRECATED)
# if defined(__ICL) //Windows Intel Compiler # if defined(__ICL) //Windows Intel Compiler
# pragma deprecated (fstat, getpid, syscall, sysconf, mkdir, strdup); # pragma deprecated (fstat, getpid, syscall, sysconf, mkdir, strdup)
# ifndef DONT_DEPRECATE_MALLOC # ifndef DONT_DEPRECATE_MALLOC
# pragma deprecated (malloc, free, realloc) # pragma deprecated (malloc, free, realloc)
# endif # endif
...@@ -88,11 +88,11 @@ int mkdir() __attribute__((__deprecated__)); ...@@ -88,11 +88,11 @@ int mkdir() __attribute__((__deprecated__));
char* strdup(const char *) __attribute__((__deprecated__)); char* strdup(const char *) __attribute__((__deprecated__));
#undef __strdup #undef __strdup
char* __strdup(const char *) __attribute__((__deprecated__)); char* __strdup(const char *) __attribute__((__deprecated__));
#ifndef DONT_DEPRECATE_MALLOC # ifndef DONT_DEPRECATE_MALLOC
void *malloc(size_t) __attribute__((__deprecated__)); void *malloc(size_t) __attribute__((__deprecated__));
void free(void*) __attribute__((__deprecated__)); void free(void*) __attribute__((__deprecated__));
void *realloc(void*, size_t) __attribute__((__deprecated__)); void *realloc(void*, size_t) __attribute__((__deprecated__));
#endif # endif
# endif # endif
#endif #endif
......
...@@ -21,4 +21,5 @@ $(TARGET): $(OBJS) ...@@ -21,4 +21,5 @@ $(TARGET): $(OBJS)
clean: clean:
$(MAYBEATSIGN)rm -rf $(TARGET) $(LIBPORTABILITY) $(MAYBEATSIGN)rm -rf $(TARGET) $(LIBPORTABILITY)
build: $(OBJS) # For build, do nothing
build:
...@@ -44,6 +44,12 @@ void *toku_xmalloc(size_t size) { ...@@ -44,6 +44,12 @@ void *toku_xmalloc(size_t size) {
return r; return r;
} }
void *toku_xrealloc(void *v, size_t size) {
void *r = toku_realloc(v, size);
if (r==0) abort();
return r;
}
void *toku_tagmalloc(size_t size, enum typ_tag typtag) { void *toku_tagmalloc(size_t size, enum typ_tag typtag) {
//printf("%s:%d tagmalloc\n", __FILE__, __LINE__); //printf("%s:%d tagmalloc\n", __FILE__, __LINE__);
void *r = toku_malloc(size); void *r = toku_malloc(size);
......
...@@ -369,4 +369,3 @@ test_main (int argc, const char *argv[]) { ...@@ -369,4 +369,3 @@ test_main (int argc, const char *argv[]) {
return 0; return 0;
} }
...@@ -163,4 +163,3 @@ test_main(int argc, const char *argv[]) { ...@@ -163,4 +163,3 @@ test_main(int argc, const char *argv[]) {
lastmalloced = NULL; lastmalloced = NULL;
return 0; return 0;
} }
#include <toku_portability.h>
#include <fcntl.h>
#include "test.h"
DB_ENV * const null_env = 0;
DB *db1, *db2;
DB_TXN * const null_txn = 0;
const char * const fname = ENVDIR "/" "test_db_remove.brt";
void test_db_remove (void) {
int r;
system("rm -rf " ENVDIR);
r=toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r==0);
// create the DB
r = db_create(&db1, null_env, 0); assert(r == 0);
r = db1->open(db1, null_txn, fname, 0, DB_BTREE, DB_CREATE, 0666); assert(r == 0);
// Now remove it.
r = db_create(&db2, null_env, 0); assert(r==0);
r = db2->remove(db2, fname, 0, 0); assert(r==0);
r = db1->close(db1, 0); assert(r==0);
}
int
test_main(int argc, const char *argv[]) {
parse_args(argc, argv);
test_db_remove();
return 0;
}
...@@ -167,6 +167,8 @@ table_prelock(char txn, BOOL success) { ...@@ -167,6 +167,8 @@ table_prelock(char txn, BOOL success) {
int r; int r;
#if defined USE_TDB && USE_TDB #if defined USE_TDB && USE_TDB
r = db->pre_acquire_table_lock(db, txns[(int)txn]); r = db->pre_acquire_table_lock(db, txns[(int)txn]);
if (success) CKERR(r);
else CKERR2s(r, DB_LOCK_NOTGRANTED, DB_LOCK_DEADLOCK);
#else #else
DBT key; DBT key;
DBT data; DBT data;
...@@ -182,9 +184,9 @@ table_prelock(char txn, BOOL success) { ...@@ -182,9 +184,9 @@ table_prelock(char txn, BOOL success) {
dbt_init(&data, 0, 0), dbt_init(&data, 0, 0),
DB_NEXT | DB_RMW); DB_NEXT | DB_RMW);
} }
#endif if (success) CKERR2(r, DB_NOTFOUND);
if (success) CKERR(r);
else CKERR2s(r, DB_LOCK_NOTGRANTED, DB_LOCK_DEADLOCK); else CKERR2s(r, DB_LOCK_NOTGRANTED, DB_LOCK_DEADLOCK);
#endif
} }
static void static void
......
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