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

[t:3586] [t:3604] Merge icc onto main. Refs #3586, #3604.

git-svn-id: file:///svn/toku/tokudb@32232 c7de825b-a66e-492c-adef-691d508d4ae1
parent 26bc1517
......@@ -17,13 +17,13 @@ include $(TOKUROOT)toku_include/Makefile.include
# GCOV_FLAGS = -fprofile-arcs -ftest-coverage
CPPFLAGS = -I../include -I../toku_include
CXXFLAGS = $(GCC_VERSION_SPECIFIC) -Werror -Wall -g $(OPTFLAGS) $(GCOV_FLAGS)
CC = c++
LDFLAGS = -lz
SRCS = $(wildcard *.cpp)
OBJS = $(patsubst %.cpp, %.o, $(SRCS))
ifeq ($(CC),icc)
CXXFLAGS += -diag-disable 981
CXX=icc
endif
LIBNAME = libtokudb_cxx
......
......@@ -41,6 +41,7 @@ RPATH_DIRS=$(TOKUROOT)lib
ifeq ($(CC),icc)
CXXFLAGS += -diag-disable 981
CXX=icc
endif
ifneq ($(OSX),)
......
......@@ -48,7 +48,7 @@ static void test_env_exceptions (void) {
{
DbEnv env(0);
int r = env.set_redzone(0); assert(r==0);
TC(env.open(DIR "no.such.dir", -1, 0777), EINVAL);
TC(env.open(DIR "no.such.dir", (u_int32_t)-1, 0777), EINVAL);
}
{
system("rm -rf " DIR);
......@@ -97,7 +97,7 @@ static void test_env_exceptions (void) {
TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE | DB_INIT_LOG | DB_INIT_TXN, 0777), 0);
DbTxn *txn;
TC(env.txn_begin(0, &txn, 0), 0);
TC(txn->commit(-1), EINVAL);
TC(txn->commit((u_int32_t)-1), EINVAL);
delete txn;
}
system("rm -rf " DIR);
......@@ -111,7 +111,7 @@ static void test_db_exceptions (void) {
int r = env.set_redzone(0); assert(r==0);
TC(env.open(DIR, DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE , 0777), 0);
env.set_errfile(stderr);
TC( ({ Db db(&env, -1); assert(0); }), EINVAL); // Create with flags=-1 should do an EINVAL
TC( { Db db(&env, (u_int32_t)-1); assert(0); }, EINVAL); // Create with flags=-1 should do an EINVAL
Db db(&env, 0);
DB *dbdb=db.get_DB();
assert(dbdb!=0);
......@@ -130,7 +130,7 @@ static void test_db_exceptions (void) {
}
{
Db db2(&env, 0);
TC(db2.open(0, FNAME, 0, DB_BTREE, -1, 0777), EINVAL); // bad flags
TC(db2.open(0, FNAME, 0, DB_BTREE, (u_int32_t)-1, 0777), EINVAL); // bad flags
}
{
Db db2(&env, 0);
......@@ -146,21 +146,21 @@ static void test_db_exceptions (void) {
}
{
Dbc *curs;
TC(db.cursor(0, &curs, -1), EINVAL);
TC(db.cursor(0, &curs, (u_int32_t)-1), EINVAL);
}
{
Dbc *curs;
TC(db.cursor(0, &curs, 0), 0);
Dbt key,val;
// TC(curs->get(&key, &val, DB_FIRST), DB_NOTFOUND);
TC(curs->get(&key, &val, -1), EINVAL); // bad flags
TC(curs->get(&key, &val, (u_int32_t)-1), EINVAL); // bad flags
curs->close(); // no deleting cursors.
}
{
Dbt key,val;
TC(db.del(0, &key, -1), EINVAL);
TC(db.get(0, &key, &val, -1), EINVAL);
TC(db.put(0, &key, &val, -1), EINVAL);
TC(db.del(0, &key, (u_int32_t)-1), EINVAL);
TC(db.get(0, &key, &val, (u_int32_t)-1), EINVAL);
TC(db.put(0, &key, &val, (u_int32_t)-1), EINVAL);
}
{
Dbt key((char*)"hello", 6);
......
......@@ -21,6 +21,11 @@ BENCHDBS = bench.bdb/ bench.tokudb
OPTFLAGS = -O2
CXXFLAGS = $(GCC_VERSION_SPECIFIC) -Wall -Werror -g $(OPTFLAGS) $(GCOV_FLAGS)
ifeq ($(CC),icc)
CXX=icc
endif
# CFLAGS += -pg
ifdef BDBDIR
......
......@@ -161,6 +161,8 @@ $(MULTIBENCH_TDB): multi-bench.c $(PTHREAD_LOCAL)
endif
$(TARGETS_BDB): CPPFLAGS+=-DDIRSUF=bdb -DTOKU_ALLOW_DEPRECATED
$(TARGETS_BDB): LDFLAGS+=-L$(TOKUROOT)lib -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib
$(TARGETS_BDB): LDLIBS+=-ltokuportability
$(TARGET_BDB): db-benchmark-test.c
$(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
$(SCANSCAN_BDB): scanscan.c
......
......@@ -303,7 +303,7 @@ static void benchmark_shutdown (void) {
if (singlex_child) fprintf(stderr, "SKIPPED 'small rollback' test for child txn\n");
else
assert(s->rollback_raw_count < 100); // gross test, not worth investigating details
os_free(s);
toku_free(s);
//system("ls -l bench.tokudb");
#endif
}
......
fib:
icc fiblib.c -fPIC -c -o fiblib.o; \
icc --shared fiblib.o -L../cilk_icc -lcilkrts_static -nodefaultlibs -olibfib.so; \
icc -L. -lfib -pthread -lstdc++ fib.c -o fib
clean:
rm -rf fib libfib.so fiblib.o
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "fiblib.h"
int main (int argc, char *argv[]) {
assert(argc==2);
int n = atoi(argv[1]);
long fn = fib(n);
printf("fib(%d)=%ld\n", n, fn);
return 0;
}
#include "fiblib.h"
long fib (int n) {
if (n<=2) return n;
else {
long a,b;
a = _Cilk_spawn fib(n-1);
b = _Cilk_spawn fib(n-2);
_Cilk_sync;
return a+b;
}
}
long fib (int n);
......@@ -10,14 +10,20 @@ OPT_AROPT=-qnoipo #Disable ipo for lib creation even when optimization is on.
SRCS = $(wildcard *.c)
OBJS = $(patsubst %.c,%.$(OEXT),$(SRCS))
TARGET = libtokuportability.$(AEXT)
TARGET = $(LIBPORTABILITY)
build install: $(LIBPORTABILITY)
build install: $(TARGET)
$(LIBPORTABILITY): $(TARGET)
if ! diff $< $@ 2>/dev/null; then cp $< $@; fi
ifeq ($(CC),icc)
#LINUX_NOSTDLIB=-nostdlib
LINUX_NOSTDLIB=-static-intel -diag-disable 10237
else
LINUX_NOSTDLIB=
endif
$(TARGET): $(OBJS)
echo $(patsubst %,linux/%,$(OBJS)) > ../lib/tokuportability.olist
$(CC) -shared $(SYMBOLS) $(OBJS) $(SKIP_WARNING) -o $(TARGET) $(LINUX_NOSTDLIB)
$(OBJS): CFLAGS += -DTOKU_ALLOW_DEPRECATED -D_GNU_SOURCE
$(OBJS): VISIBILITY=
......
......@@ -15,7 +15,8 @@ endif
ifneq ($(GCOV),)
CFLAGS += -fprofile-arcs -ftest-coverage -DGCOV
endif
LDFLAGS = ../libtokuportability.a -lpthread
LDFLAGS = -L../../lib -Wl,-rpath,../../lib
LDLIBS = -ltokuportability -lpthread
SRCS=$(sort $(filter-out dir.%.c,$(wildcard *.c)))
TARGETS = $(patsubst %.c,%,$(SRCS))
RUNTARGETS = $(patsubst %,%.tdbrun,$(TARGETS))
......@@ -37,7 +38,7 @@ INVERTER=;test $$? -ne 0
all: $(TARGETS)
%: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) -lrt
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDLIBS) -lrt
.PHONY: check build
build: $(TARGETS)
......
......@@ -13,16 +13,12 @@ DEPEND_COMPILE += \
log_header.h \
# keep this line so I can have a \ on the previous line
NEWBRT = newbrt.$(AEXT)
NEWBRT_SO = libnewbrt.$(SOEXT)
IPO_NEWBRT = ipo_newbrt.$(AEXT)
NEWBRT_BUNDLE = newbrt.bundle
#All executables need to statically link to newbrt
LINK_FILES += $(NEWBRT)
NEWBRT_SO = $(TOKUROOT)lib/libnewbrt.$(SOEXT)
SKIP_NEWBRTRULE=1
include $(TOKUROOT)toku_include/Makefile.include
LDFLAGS+=-L$(TOKUROOT)lib -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib
LDLIBS+=-lnewbrt -ltokuportability
# When debugging, try: valgrind --show-reachable=yes --leak-check=full ./brt-test
BINS_RAW= \
......@@ -32,8 +28,6 @@ BINS_RAW= \
# Intentionally left blank
# BINS will be defined automatically.
BINS_O = $(patsubst %,%.$(OEXT),$(BINS_RAW))
.PHONY: build default bins libs local
build default: local
......@@ -111,28 +105,11 @@ endif
NEWBRT_O_FILES += brtloader.$(OEXT) quicklz.$(OEXT) compress.$(OEXT)
brtloader.$(OEXT): $(DEPEND_COMPILE)
ifeq ($(BRTLOADER),cilk)
brtloader.$(OEXT): brtloader.c
$(CILKPP) -DTOKU_ALLOW_DEPRECATED $(CILKFLAGS) -c $<
endif
ifeq ($(BRTLOADER),cxx)
brtloader.$(OEXT): brtloader.c
$(CXX) -DTOKU_ALLOW_DEPRECATED $(CXXFLAGS) -c $<
endif
$(NEWBRT_O_FILES): VISIBILITY=
$(NEWBRT): $(NEWBRT_O_FILES)
$(NEWBRT_SO): newbrt.bundle
$(TOKULINKER) $(SHARED) $(SYMBOLS) $(CILK_LINKER_FLAGS) $(GCOV_FLAGS) newbrt.bundle/*.o -o$(NEWBRT_SO) $(CILKRTS_LIB)
$(NEWBRT_BUNDLE): log_code.c log_header.h
ipo_newbrt.obj: $(NEWBRT_BUNDLE)
$(CC) $(CFLAGS) $(CPPFLAGS) -Qipo-c $(filter %.$(OEXT),$^) $(patsubst %.bundle, %.bundle/*.$(OEXT), $(filter-out %.$(OEXT),$^))
mv ipo_out.obj $@
$(IPO_NEWBRT): ipo_newbrt.obj
xilib /out:$@ $^
$(NEWBRT_SO): $(NEWBRT_O_FILES)
echo $(patsubst %,newbrt/%,$(NEWBRT_O_FILES)) > ../lib/newbrt.olist
$(TOKULINKER) $(SHARED) $(SYMBOLS) $(GCOV_FLAGS) $(SKIP_WARNING) $(NEWBRT_O_FILES) -o$(NEWBRT_SO) -nostdlib $(LCILKRTS)
log_code.$(OEXT): log_header.h wbuf.h log-internal.h rbuf.h
......@@ -148,10 +125,10 @@ log_print.c log_header.h: log_code.c
#Needs to be done manually since it does not include newbrt.
logformat$(BINSUF): logformat.c $(LIBPORTABILITY)
$(CC) $< $(BIN_FROM_O_FLAGS_NOLIB) $(ALWAYS_LINK) $(LINK_MUST_BE_LAST)
$(CC) $< $(BIN_FROM_O_FLAGS_NOLIB) $(LDFLAGS) $(ALWAYS_LINK) $(LINK_MUST_BE_LAST) $(LIBPORTABILITY)
libs: $(NEWBRT_SO) $(NEWBRT) $(NEWBRT_BUNDLE)
libs: $(NEWBRT_SO)
bins: $(BINS)
# Put the benchmarktest_256 first since it takes the longest (and we want to use parallelism in the make)
......@@ -160,7 +137,10 @@ bins: $(BINS)
check: bins
cd tests;$(MAKE) check
%$(BINSUF): $(NEWBRT) $(LIBPORTABILITY)
$(BINS): $(NEWBRT_SO) $(LIBPORTABILITY)
foo2:
echo $(BINS)
checko2: SHELL=/bin/bash
checko2:
......@@ -183,7 +163,5 @@ testdump: brtdump$(BINSUF)
./brtdump ../src/tests/dir.test_log5.c.tdb.recover/foo.db > dump.r && ./brtdump ../src/tests/dir.test_log5.c.tdb/foo.db > dump.$(OEXT) && diff dump.$(OEXT) dump.r
foo:
@echo CILKROOT $(CILKROOT)
@echo CILKPP $(CILKPP)
@echo BRTLOADER $(BRTLOADER)
@echo BDBDIR $(BDBDIR)
......@@ -350,7 +350,7 @@ serialize_nonleaf(BRTNODE node, int n_sub_blocks, struct sub_block sub_block[],
wbuf_nocrc_int(wbuf, toku_fifo_n_entries(BNC_BUFFER(node,i)));
FIFO_ITERATE(BNC_BUFFER(node,i), key, keylen, data, datalen, type, xids,
{
invariant(type>=0 && type<256);
invariant(((int)type)>=0 && type<256);
wbuf_nocrc_char(wbuf, (unsigned char)type);
wbuf_nocrc_xids(wbuf, xids);
wbuf_nocrc_bytes(wbuf, key, keylen);
......
......@@ -290,14 +290,10 @@ BOOL toku_brt_is_empty_fast (BRT brt);
// Effect: Return TRUE if there are no messages or leaf entries in the tree. If so, it's empty. If there are messages or leaf entries, we say it's not empty
// even though if we were to optimize the tree it might turn out that they are empty.
double get_tdiff(void) __attribute__((__visibility__("default")));
BOOL toku_brt_is_empty_fast (BRT brt) __attribute__ ((warn_unused_result));
// Effect: Return TRUE if there are no messages or leaf entries in the tree. If so, it's empty. If there are messages or leaf entries, we say it's not empty
// even though if we were to optimize the tree it might turn out that they are empty.
double get_tdiff(void) __attribute__((__visibility__("default"))) __attribute__ ((warn_unused_result));
BOOL toku_brt_is_recovery_logging_suppressed (BRT) __attribute__ ((warn_unused_result));
//TODO: #1485 once we have multiple main threads, restore this code, analyze performance.
#ifndef TOKU_MULTIPLE_MAIN_THREADS
......
......@@ -34,18 +34,19 @@
// cd ../src;make local
#if defined(__cilkplusplus)
#include <cilk.h>
#include <cilk_mutex.h>
#include <fake_mutex.h>
#define cilk_worker_count (cilk::current_worker_count())
#error DISABLING CILK ARTS CILK
#endif
#if defined(__cplusplus)
#error DISABLING cplusplus
#endif
#if defined(HAVE_CILK)
#include <cilk/cilk.h>
#define cilk_worker_count (__cilkrts_get_nworkers())
#else
// maybe #include <cilk_stub.h>
#if !defined(CILK_STUB)
#define CILK_STUB
#define cilk_spawn
#define cilk_sync
#define cilk_for for
#endif
#define cilk_worker_count 1
#endif
......@@ -944,8 +945,8 @@ static int finish_primary_rows_internal (BRTLOADER bl)
int *MALLOC_N(bl->N, ra);
if (ra==NULL) return errno;
#if defined(__cilkplusplus)
#pragma cilk_grainsize = 1
#if defined(HAVE_CILK)
#pragma cilk grainsize = 1
#endif
cilk_for (int i = 0; i < bl->N; i++) {
......@@ -1108,8 +1109,8 @@ static int process_primary_rows_internal (BRTLOADER bl, struct rowset *primary_r
int *XMALLOC_N(bl->N, error_codes);
// Do parallelize this loop with cilk_grainsize = 1 so that every iteration will run in parallel.
#if defined(__cilkplusplus)
#pragma cilk_grainsize = 1
#if defined(HAVE_CILK)
#pragma cilk grainsize = 1
#endif
cilk_for (int i = 0; i < bl->N; i++) {
error_codes[i] = 0;
......@@ -2043,9 +2044,7 @@ struct dbout {
int64_t n_translations;
int64_t n_translations_limit;
struct translation *translation;
#ifndef CILK_STUB
cilk::mutex mutex; // the mutex is initialized by the dbout constructor
#endif
toku_pthread_mutex_t mutex;
};
static inline void dbout_init(struct dbout *out) {
......@@ -2053,6 +2052,8 @@ static inline void dbout_init(struct dbout *out) {
out->current_off = 0;
out->n_translations = out->n_translations_limit = 0;
out->translation = NULL;
int r = toku_pthread_mutex_init(&out->mutex, NULL);
resource_assert_zero(r);
}
static inline void dbout_destroy(struct dbout *out) {
......@@ -2062,22 +2063,15 @@ static inline void dbout_destroy(struct dbout *out) {
}
toku_free(out->translation);
out->translation = NULL;
int r = toku_pthread_mutex_destroy(&out->mutex); resource_assert_zero(r);
}
static inline void dbout_lock(struct dbout *out) {
#ifndef CILK_STUB
out->mutex.lock();
#else
out = out;
#endif
toku_pthread_mutex_lock(&out->mutex);
}
static inline void dbout_unlock(struct dbout *out) {
#ifndef CILK_STUB
out->mutex.unlock();
#else
out = out;
#endif
toku_pthread_mutex_unlock(&out->mutex);
}
static void seek_align_locked(struct dbout *out) {
......@@ -2191,24 +2185,6 @@ static void putbuf_int64_at(struct dbuf *dbuf, int off, unsigned long long v) {
putbuf_int32_at(dbuf, off+4, b);
}
// glibc protects the "random" function with an inlined lock. this lock is not understood by
// cilkscreen, so we have to tell cilkscreen that "random" is safe.
// RFP check windows random behaviour.
#ifndef CILK_STUB
static cilk::fake_mutex random_mutex;
#endif
static inline long int loader_random(void) {
#ifndef CILK_STUB
random_mutex.lock();
#endif
long int r = random();
#ifndef CILK_STUB
random_mutex.unlock();
#endif
return r;
}
static struct leaf_buf *start_leaf (struct dbout *out, const DESCRIPTOR UU(desc), int64_t lblocknum, TXNID xid, uint32_t target_nodesize) {
invariant(lblocknum < out->n_translations_limit);
struct leaf_buf *XMALLOC(lbuf);
......
......@@ -64,7 +64,7 @@ void toku_fifo_iterate (FIFO, void(*f)(bytevec key,ITEMLEN keylen,bytevec data,I
struct fifo_entry *e = toku_fifo_iterate_internal_get_entry(fifo, fifo_iterate_off); \
ITEMLEN keylenvar = e->keylen; \
ITEMLEN datalenvar = e->vallen; \
int typevar = e->type; \
enum brt_msg_type typevar = (enum brt_msg_type)e->type; \
XIDS xidsvar = &e->xids_s; \
bytevec keyvar = xids_get_end_of_array(xidsvar); \
bytevec datavar = (const u_int8_t*)keyvar + e->keylen; \
......
......@@ -182,6 +182,10 @@ static inline int toku_logsizeof_u_int64_t (u_int32_t v __attribute__((__unused_
return 8;
}
static inline int toku_logsizeof_BOOL (u_int32_t v __attribute__((__unused__))) {
return 1;
}
static inline int toku_logsizeof_FILENUM (FILENUM v __attribute__((__unused__))) {
return 4;
}
......
......@@ -80,7 +80,7 @@ const struct logtype rollbacks[] = {
{"BYTESTRING", "key", 0},
NULLFIELD}},
{"cmdupdatebroadcast", 'B', FA{{"FILENUM", "filenum", 0},
{"u_int8_t", "is_resetting_op", 0},
{"BOOL", "is_resetting_op", 0},
NULLFIELD}},
{"change_fdescriptor", 'D', FA{{"FILENUM", "filenum", 0},
{"BYTESTRING", "old_descriptor", 0},
......@@ -190,7 +190,7 @@ const struct logtype logtypes[] = {
{"enq_updatebroadcast", 'B', FA{{"FILENUM", "filenum", 0},
{"TXNID", "xid", 0},
{"BYTESTRING", "extra", 0},
{"u_int8_t", "is_resetting_op", 0},
{"BOOL", "is_resetting_op", 0},
NULLFIELD}},
{"change_fdescriptor", 'D', FA{{"FILENUM", "filenum", 0},
{"TXNID", "xid", 0},
......
......@@ -937,6 +937,13 @@ int toku_fread_u_int64_t (FILE *f, u_int64_t *v, struct x1764 *checksum, u_int32
return 0;
}
int toku_fread_BOOL (FILE *f, BOOL *v, struct x1764 *mm, u_int32_t *len) {
u_int8_t iv;
int r = toku_fread_u_int8_t(f, &iv, mm, len);
*v = (iv!=0);
return r;
}
int toku_fread_LSN (FILE *f, LSN *lsn, struct x1764 *checksum, u_int32_t *len) {
return toku_fread_u_int64_t (f, &lsn->lsn, checksum, len);
}
......@@ -1013,7 +1020,6 @@ int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname, struct
else if (isprint(v)) fprintf(outf, "('%c')", v);
else {}/*nothing*/
return 0;
}
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format) {
......@@ -1034,6 +1040,15 @@ int toku_logprint_u_int64_t (FILE *outf, FILE *inf, const char *fieldname, struc
return 0;
}
int toku_logprint_BOOL (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format __attribute__((__unused__))) {
BOOL v;
int r = toku_fread_BOOL(inf, &v, checksum, len);
if (r!=0) return r;
fprintf(outf, " %s=%s", fieldname, v ? "TRUE" : "FALSE");
return 0;
}
void toku_print_BYTESTRING (FILE *outf, u_int32_t len, char *data) {
fprintf(outf, "{len=%u data=\"", len);
u_int32_t i;
......
......@@ -65,6 +65,7 @@ int toku_fread_u_int8_t (FILE *f, u_int8_t *v, struct x1764 *mm, u_int32_t *len)
int toku_fread_u_int32_t_nocrclen (FILE *f, u_int32_t *v);
int toku_fread_u_int32_t (FILE *f, u_int32_t *v, struct x1764 *checksum, u_int32_t *len);
int toku_fread_u_int64_t (FILE *f, u_int64_t *v, struct x1764 *checksum, u_int32_t *len);
int toku_fread_BOOL (FILE *f, BOOL *v, struct x1764 *checksum, u_int32_t *len);
int toku_fread_LSN (FILE *f, LSN *lsn, struct x1764 *checksum, u_int32_t *len);
int toku_fread_BLOCKNUM (FILE *f, BLOCKNUM *lsn, struct x1764 *checksum, u_int32_t *len);
int toku_fread_FILENUM (FILE *f, FILENUM *filenum, struct x1764 *checksum, u_int32_t *len);
......@@ -78,6 +79,7 @@ int toku_logprint_u_int8_t (FILE *outf, FILE *inf, const char *fieldname, struct
int toku_logprint_u_int32_t (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format);
int toku_logprint_BLOCKNUM (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format);
int toku_logprint_u_int64_t (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format);
int toku_logprint_BOOL (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format __attribute__((__unused__)));
void toku_print_BYTESTRING (FILE *outf, u_int32_t len, char *data);
int toku_logprint_BYTESTRING (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format __attribute__((__unused__)));
int toku_logprint_FILENUM (FILE *outf, FILE *inf, const char *fieldname, struct x1764 *checksum, u_int32_t *len, const char *format);
......
......@@ -76,11 +76,9 @@ static void reset_table_compress(qlz_state_compress *state)
static void reset_table_decompress(qlz_state_decompress *state)
{
int i;
(void)state;
(void)i;
#if QLZ_COMPRESSION_LEVEL == 2
for(i = 0; i < QLZ_HASH_VALUES; i++)
for(int i = 0; i < QLZ_HASH_VALUES; i++)
{
state->hash_counter[i] = 0;
}
......
......@@ -41,6 +41,11 @@ static inline void rbuf_ma_u_int8_t (struct rbuf *r, MEMARENA ma __attribute__((
*num = rbuf_char(r);
}
static inline void rbuf_ma_BOOL (struct rbuf *r, MEMARENA ma __attribute__((__unused__)), BOOL *b) {
u_int8_t n = rbuf_char(r);
*b = (n!=0);
}
//Read an int that MUST be in network order regardless of disk order
static unsigned int rbuf_network_int (struct rbuf *r) __attribute__((__unused__));
static unsigned int rbuf_network_int (struct rbuf *r) {
......
......@@ -42,6 +42,7 @@ toku_commit_fdelete (u_int8_t file_was_open,
r = toku_cachefile_redirect_nullfd(cf);
assert(r==0);
}
{
char *fname_in_env = fixup_fname(&bs_fname);
char *fname_in_cwd = toku_cachetable_get_fname_in_cwd(txn->logger->ct, fname_in_env);
......@@ -49,6 +50,7 @@ toku_commit_fdelete (u_int8_t file_was_open,
assert(r==0 || errno==ENOENT);
toku_free(fname_in_env);
toku_free(fname_in_cwd);
}
done:
return 0;
}
......@@ -107,6 +109,7 @@ toku_rollback_fcreate (FILENUM filenum,
r = toku_cachefile_redirect_nullfd(cf);
assert(r==0);
{
char *fname_in_env = fixup_fname(&bs_fname);
char *fname_in_cwd = toku_cachetable_get_fname_in_cwd(txn->logger->ct, fname_in_env);
......@@ -114,6 +117,7 @@ toku_rollback_fcreate (FILENUM filenum,
assert(r==0 || errno==ENOENT);
toku_free(fname_in_env);
toku_free(fname_in_cwd);
}
done:
return 0;
}
......@@ -230,7 +234,7 @@ toku_rollback_cmdupdate(FILENUM filenum,
int
toku_commit_cmdupdatebroadcast(FILENUM filenum,
u_int8_t is_resetting_op,
BOOL is_resetting_op,
TOKUTXN txn,
YIELDF UU(yield),
void * UU(yieldv),
......@@ -248,7 +252,7 @@ toku_commit_cmdupdatebroadcast(FILENUM filenum,
int
toku_rollback_cmdupdatebroadcast(FILENUM filenum,
u_int8_t UU(is_resetting_op),
BOOL UU(is_resetting_op),
TOKUTXN txn,
YIELDF UU(yield),
void * UU(yieldv),
......
......@@ -39,8 +39,6 @@ BINS_RAW = $(REGRESSION_TESTS_RAW) \
# This line intentially kept commented so I can have a \ on the end of the previous line
# BINS will be defined by adding .exe if appropriate.
$(BINS): BIN_FROM_C_FLAGS+=$(LIBPORTABILITY)
CHECKS = \
benchmarktest_256 \
test-assertA \
......@@ -155,43 +153,45 @@ brtloader_test$(BINSUF): ../brtloader-internal.h ../brtloader.o
../brtloader.$(OEXT): ../brtloader.c ../brtloader-internal.h
cd $(@D) && $(MAKE) $(@F)
CILKSCREEN=../../scripts/tokucilkscreen
check_brtloader: check_brtloader-test-bad-generate check_brtloader-test-extractor check_brtloader-test-extractor-errors check_brtloader-test-merge-files-dbufio check_brtloader-test-open check_brtloader-test-writer check_brtloader-test-writer-errors
cilkscreen_brtloader-tests: cilkscreen_brtloader-test-1
true $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-1: brtloader-test$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-extractor-tests: $(patsubst %,cilkscreen_brtloader-test-extractor-%, 1 2)
true $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-extractor-1: brtloader-test-extractor$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-extractor-2: brtloader-test-extractor$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-extractor-3: brtloader-test-extractor$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s -r 100 --rowsets 100 dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s -r 100 --rowsets 100 dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-writer-tests: $(patsubst %,cilkscreen_brtloader-test-writer-%, 1 2)
true $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-1: brtloader-test-writer$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s -r 1000 dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s -r 1000 dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-2: brtloader-test-writer$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s -r 10000 dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s -r 10000 dir.$@ $(SUMMARIZE_CMD)
# this test sometimes crashes cilkscreen 8503, omit for now
cilkscreen_brtloader-test-writer-3: brtloader-test-writer$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s -r 100000 dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s -r 100000 dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-writer-error-tests: $(patsubst %,cilkscreen_brtloader-test-writer-errors-%, 1 2 3 4)
true $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-errors-1: brtloader-test-writer-errors$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s -r 10000 -u dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s -r 10000 -u dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-errors-2: brtloader-test-writer-errors$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s -r 10000 -w dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s -r 10000 -w dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-errors-3: brtloader-test-writer-errors$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s -r 10000 -m dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s -r 10000 -m dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader-test-writer-errors-4: brtloader-test-writer-errors$(BINSUF)
$(CILKROOT)/bin/cilkscreen ./$< $(VERBVERBOSE) -s -r 10000 --realloc_errors dir.$@ $(SUMMARIZE_CMD)
$(CILKSCREEN) ./$< $(VERBVERBOSE) -s -r 10000 --realloc_errors dir.$@ $(SUMMARIZE_CMD)
cilkscreen_brtloader: cilkscreen_brtloader-tests cilkscreen_brtloader-extractor-tests cilkscreen_brtloader-writer-tests cilkscreen_brtloader-writer-error-tests
......@@ -201,7 +201,7 @@ clean:
rm -f test_oexcl.c.tmp
rm -f *.brt *.clean *.dirty *.tdb *.dat *.data *.out *.check.valgrind
$(BINS): LDFLAGS=-L../ -lnewbrt -lz -lpthread -Wl,-rpath,../
$(BINS): LDFLAGS=-L../../lib -ltokuportability -lnewbrt $(ALWAYS_LINK) -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib
$(BINS): test.h
foo:
......
......@@ -64,7 +64,7 @@ test_fifo_enq (int n) {
buildval(i);
assert((int) keylen == thekeylen); assert(memcmp(key, thekey, keylen) == 0);
assert((int) vallen == thevallen); assert(memcmp(val, theval, vallen) == 0);
assert(i % 256 == type);
assert(i % 256 == (int)type);
assert((TXNID)i==xids_get_innermost_xid(xids));
i += 1;
});
......
......@@ -685,7 +685,11 @@ found_insert:;
new_leafentry->type = LE_MVCC;
new_leafentry->u.mvcc.num_cxrs = toku_htod32(ule->num_cuxrs);
new_leafentry->u.mvcc.num_pxrs = ule->num_puxrs;
// invariant makes cast that follows ok, although not sure if
// check should be "< MAX_TRANSACTION_RECORDS" or
// "< MAX_TRANSACTION_RECORDS - 1"
invariant(ule->num_puxrs < MAX_TRANSACTION_RECORDS);
new_leafentry->u.mvcc.num_pxrs = (u_int8_t)ule->num_puxrs;
//Store actual key.
memcpy(new_leafentry->u.mvcc.key_xrs, ule->keyp, ule->keylen);
......@@ -1620,9 +1624,9 @@ ule_remove_innermost_placeholders(ULE ule) {
}
}
static uint32_t
static uint8_t
outermost_xid_not_in_ule(ULE ule, XIDS xids) {
int index = 0;
uint8_t index = 0;
invariant(ule->num_puxrs < xids_get_num_xids(xids));
if (ule->num_puxrs) {
TXNID ule_xid = ule_get_innermost_xid(ule); // xid of ica
......@@ -1644,7 +1648,7 @@ ule_add_placeholders(ULE ule, XIDS xids) {
TXNID this_xid = xids_get_innermost_xid(xids); // xid of this transaction
invariant(this_xid!=TXNID_NONE);
if (ica_xid != this_xid) { // if this transaction is the ICA, don't push any placeholders
int index = outermost_xid_not_in_ule(ule, xids);
u_int8_t index = outermost_xid_not_in_ule(ule, xids);
TXNID current_msg_xid = xids_get_xid(xids, index);
while (current_msg_xid != this_xid) { // Placeholder for each transaction before this transaction
ule_push_placeholder_uxr(ule, current_msg_xid);
......
......@@ -147,6 +147,10 @@ static inline void wbuf_u_int64_t(struct wbuf *w, u_int64_t ull) {
wbuf_ulonglong(w, ull);
}
static inline void wbuf_nocrc_BOOL (struct wbuf *w, BOOL b) {
wbuf_nocrc_u_int8_t(w, (u_int8_t)(b ? 1 : 0));
}
static inline void wbuf_nocrc_BYTESTRING (struct wbuf *w, BYTESTRING v) {
wbuf_nocrc_bytes(w, v.data, v.len);
}
......
......@@ -79,7 +79,9 @@ xids_create_child(XIDS parent_xids, // xids list for parent transaction
XIDS xids = toku_malloc(sizeof(*xids) + num_child_xids*sizeof(xids->ids[0]));
if (!xids) rval = ENOMEM;
else {
xids->num_xids = num_child_xids;
// comment: invariant (num_child_xids <= MAX_TRANSACTION_RECORDS)
// makes this cast ok
xids->num_xids = (u_int8_t)num_child_xids;
memcpy(xids->ids,
parent_xids->ids,
parent_xids->num_xids*sizeof(parent_xids->ids[0]));
......@@ -95,7 +97,7 @@ xids_create_child(XIDS parent_xids, // xids list for parent transaction
void
xids_create_from_buffer(struct rbuf *rb, // xids list for parent transaction
XIDS * xids_p) { // xids list created
u_int32_t num_xids = rbuf_char(rb);
u_int8_t num_xids = rbuf_char(rb);
invariant(num_xids < MAX_TRANSACTION_RECORDS);
XIDS xids = toku_xmalloc(sizeof(*xids) + num_xids*sizeof(xids->ids[0]));
xids->num_xids = num_xids;
......@@ -153,7 +155,9 @@ TXNID
xids_get_innermost_xid(XIDS xids) {
TXNID rval = TXNID_NONE;
if (xids_get_num_xids(xids)) {
rval = xids_get_xid(xids, xids_get_num_xids(xids)-1);
// if clause above makes this cast ok
u_int8_t innermost_xid = (u_int8_t)(xids_get_num_xids(xids)-1);
rval = xids_get_xid(xids, innermost_xid);
}
return rval;
}
......
#!/usr/bin/env bash
# exit 1 if cilkscreen finds errors
function cleanup() {
if [ "$logfile" != "" ] ; then rm $logfile; logfile=; fi
}
trap cleanup SIGINT
logfile=$(mktemp /tmp/toku_cilkscreen.XXXXXXXX)
cilkscreen $* 2>$logfile
exitcode=$?
if [ $exitcode = 0 ] ; then
cat $logfile >/dev/fd/2
grep "No errors found by Cilkscreen" $logfile >/dev/null 2>&1
exitcode=$?
fi
rm $logfile
exit $exitcode
\ No newline at end of file
......@@ -12,19 +12,9 @@ DEPEND_COMPILE += \
include $(TOKUROOT)toku_include/Makefile.include
CPPFLAGS+=-D_GNU_SOURCE -D_THREAD_SAFE
YDB=ydb.$(AEXT)
YDB_BUNDLE=ydb.bundle
TYDB=tydb.$(AEXT)
TYDB_BUNDLE=tydb.bundle
IPO_YDB = ipo_libtokudb.$(AEXT)
NOIPO_YDB = static_libtokudb.$(AEXT)
LIBNAME=libtokudb
LIBRARY=$(LIBNAME).$(SOEXT)
LIBRARY_S=$(LIBNAME).$(AEXT)
LIBRARY=../lib/$(LIBNAME).$(SOEXT)
OBJS_RAW = \
ydb_lib \
......@@ -44,7 +34,6 @@ LIBRARIES=
LIBRARIES+= \
$(LIBRARY) \
$(LIBRARY_S) \
#Purposely here for \ at end of prev
ifeq ($(OS_CHOICE),windows)
......@@ -61,32 +50,17 @@ LIBRARIES += $(WINYDB)
libtokudb.pdb : $(WINYDB);
endif
INSTALL_LIBRARIES= $(patsubst %,%.install,$(LIBRARIES))
ifeq ($(OS_CHOICE),windows)
#INSTALL_LIBRARIES += libtokudb.pdb.install #Disabled dynamic libraries
endif
.PHONY: build local build_tests
.PHONY:install_libs install.% build install local build_tests
#Half Build Half Install???
build: local build_tests ;
local: buildlocktrees libs install_libs ;
local: buildlocktrees libs ;
build_tests: | local
cd tests && $(MAKE) build
install_libs: $(INSTALL_LIBRARIES)
%.install: %
if ! diff $* ../lib/$* > /dev/null 2>&1; then cp $* ../lib/; fi
.PHONY: install
install: libs install_libs ;
.PHONY: local libs buildlocktrees
libs: $(LIBRARIES) ;
$(IPO_YDB) $(NOIPO_YDB) $(LIBRARIES): | export.def
#Generate export.def
#Take everything from export.map, add snprintf and vsnprintf, and then convert into export.def format.
......@@ -97,37 +71,20 @@ export.def: export.map Makefile
buildlocktrees: $(LOCKTREE) $(RANGETREE) ;
$(YDB): $(OBJS)
$(LIBRARY): $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(DEPEND_COMPILE) $(DEPEND_LINK)
$(LIBRARY): LINK_FILES=ydb_lib.$(OEXT) $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT)
#Skip all BDB tests for CYGWIN+ICC
ifeq ($(CYGWIN),)
$(LIBRARY_S): $(patsubst %.$(AEXT),%.bundle, $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY))
else ifneq ($(CC),icc)
$(LIBRARY_S): $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
else
$(LIBRARY) $(LIBRARY_S):
echo "Dynamic tokudb in windows is deprecated"
test 1 = 0
#$(LIBRARY_S): $(LIBRARY) ;
#$(LIBRARY_S): $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
#$(TLIBRARY_S): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
$(LIBRARY): $(OBJS) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(DEPEND_COMPILE) $(DEPEND_LINK)
NEWBRT_OFILES = $(patsubst %,../%,$(shell cat ../lib/newbrt.olist))
PORTABILITY_OFILES = $(patsubst %,../%,$(shell cat ../lib/tokuportability.olist))
$(LIBRARY): LINK_FILES=$(OBJS) $(LOCKTREE) $(RANGETREE) $(NEWBRT_OFILES) $(PORTABILITY_OFILES)
ifeq ($(CC),icc)
ifeq ($(HAVE_CILK),1)
ifeq (0,1)
#$(LIBRARY): LINK_FILES+=$(wildcard ../cilk_icc/*.o)
else
$(LIBRARY): LINK_FILES+=-lcilkrts
endif
endif
endif
$(NOIPO_YDB): $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT)
xilib /out:$@ $^
ipo_libtokudb.obj: $(YDB_BUNDLE) $(LOCKTREE_BUNDLE) $(RANGETREE_BUNDLE) $(NEWBRT_BUNDLE)
$(CC) $(CFLAGS) $(CPPFLAGS) -Qipo-c $(filter %.$(OEXT),$^) $(patsubst %.bundle, %.bundle/*.$(OEXT), $(filter-out %.$(OEXT),$^))
mv ipo_out.obj $@
$(IPO_YDB): ipo_libtokudb.obj
xilib /out:$@ $^
check_globals: $(LIBNAME).$(SOEXT)
python tokuglobals.py $<
......
......@@ -9,8 +9,9 @@ DEPEND_COMPILE += \
#end
DEPEND_COMPILE+= $(NEWBRT)
LINK_FILES=$(NEWBRT)
include $(TOKUROOT)toku_include/Makefile.include
LDLIBS+=-lnewbrt -ltokuportability
LDFLAGS+=-L$(TOKUROOT)lib -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib
ifeq ($(CC),icc)
SKIP_WARNING += $(ICC_NOWARN)1418 #Non static functions do not need prototypes.
......
......@@ -4,11 +4,11 @@
TOKUROOT=../../../
INCLUDEDIRS=-I. -I../ -I$(TOKUROOT)newbrt
DEPEND_COMPILE+=../rangetree.h ../rangetree-internal.h test.h
NEWBRT=$(TOKUROOT)newbrt/newbrt.$(AEXT)
DEPEND_COMPILE+=$(NEWBRT)
DEPEND_COMPILE+=$(NEWBRT_SO)
LINK_FILES=$(NEWBRT)
include $(TOKUROOT)toku_include/Makefile.include
LDLIBS+=-lnewbrt -ltokuportability
LDFLAGS+=-L$(TOKUROOT)lib -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib
ifeq ($(CC),icc)
SKIP_WARNING += $(ICC_NOWARN)1418 #Non static functions do not need prototypes.
......
......@@ -24,10 +24,10 @@ LIBTDB=$(WIN_YDB)
%.tdb$(BINSUF): LINK_FILES+=$(WIN_YDB)
TDB_EXTRA_NEEDED=$(WIN_YDB)
else
LIBTDB=../libtokudb.$(SOEXT)
LIBTDB=../../lib/libtokudb.$(SOEXT)
TLIBTDB=../libtokudbtrace.$(SOEXT)
%.tdb$(BINSUF): DLINK_FILES+=$(LIBTDB)
%.tdb$(BINSUF): RPATH_DIRS+=$(dir $(LIBTDB))
%.tdb$(BINSUF): RPATH_DIRS+=$(patsubst %/,%,$(dir $(LIBTDB)))
endif
RECOVER_SRCS = $(wildcard recover-*.c)
......@@ -327,7 +327,6 @@ BDB_BINS = $(patsubst %.c,%.bdb$(BINSUF),$(filter-out $(patsubst %,%.c,$(BDB_DON
endif
TDB_TESTS_THAT_SHOULD_FAIL= \
loader_blobs_leaf_split \
test_blobs_leaf_split \
test_truncate_txn_abort \
test_db_no_env \
......@@ -533,7 +532,7 @@ TDB_CFLAGS=
%.bdb$(BINSUF): BDB_CFLAGS= -DENVDIR=\"dir.$<.bdb\" -DUSE_BDB -DIS_TDB=0 -DTOKU_ALLOW_DEPRECATED
%.bdb$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK)
$(CC) $< $(BDB_CFLAGS) $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
$(CC) $< $(BDB_CFLAGS) $(BIN_FROM_C_FLAGS) -L$(TOKUROOT)lib -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib -ltokuportability $(LINK_MUST_BE_LAST)
%.tdbt$(BINSUF): DLINK_FILES+=$(TLIBTDB)
%.tdbt$(BINSUF): RPATH_DIRS+=$(dir $(TLIBTDB))
......@@ -541,10 +540,10 @@ TDB_CFLAGS=
%.tdb$(BINSUF) %.tdbt$(BINSUF): TDB_CFLAGS= -DENVDIR=\"dir.$<.tdb\" -DUSE_TDB -DIS_TDB=1
%.tdb$(BINSUF) %.tdbt$(BINSUF): CPPFLAGS+=-I$(TOKUROOT)include
loader-stress-test: CPPFLAGS+=-I$(TOKUROOT)include -DENVDIR=\"dir.$<\"
loader-stress-test: LOADLIBES+=-L.. -ltokudb -Wl,-rpath,..
loader-stress-test: LOADLIBES+=-L../lib -ltokudb -Wl,-rpath,..
%.tdb$(BINSUF) %.tdbt$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK) $(TDB_EXTRA_NEEDED)
$(CC) $< $(TDB_CFLAGS) $(filter-out ../../lib/libtokuportability.a,$(BIN_FROM_C_FLAGS)) $(LINK_MUST_BE_LAST)
$(CC) $< $(TDB_CFLAGS) $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
ifeq ($(VGRIND),)
BDB_SUPPRESSIONS =
......
......@@ -30,7 +30,7 @@ typedef struct client_spec {
uint32_t start; // approximate start row
int offset; // offset from stride (= MAX_CLIENTS)
Direction dir;
TxnWork txnwork;
int txnwork;
DB_TXN *txn;
uint32_t max_inserts_per_txn; // this is for the parent transaction
DB **dbs;
......@@ -49,7 +49,7 @@ static void * client(void *arg)
assert(cs->dir == FORWARD || cs->dir == BACKWARD);
int r;
if ( cs->txnwork | TXN_CREATE ) { r = env->txn_begin(env, NULL, &cs->txn, 0); CKERR(r); }
if ( cs->txnwork & TXN_CREATE ) { r = env->txn_begin(env, NULL, &cs->txn, 0); CKERR(r); }
DBT key, val;
DBT dest_keys[NUM_DBS];
......@@ -101,7 +101,7 @@ static void * client(void *arg)
n = ( cs->dir == FORWARD ) ? n + 1 : n - 1;
}
if ( cs->txnwork | TXN_END ) { r = cs->txn->commit(cs->txn, DB_TXN_SYNC); CKERR(r); }
if ( cs->txnwork & TXN_END ) { r = cs->txn->commit(cs->txn, DB_TXN_SYNC); CKERR(r); }
if (verbose) printf("client[%d] done\n", cs->client_number);
for (int which=0; which<NUM_DBS; which++) {
......
......@@ -32,7 +32,7 @@ const int OPER_PER_STEP = 43;
#define DBG(str) if (verbose) printf("%s:%25s: %s\n", __FILE__, __FUNCTION__, str)
#define iDBG(iter) if (verbose) printf("%s:%25s: iter = %d\n", __FILE__, __FUNCTION__, iter)
static int firstkey(int iter, STEP step) { return (iter * OPER_PER_ITER) + (step * OPER_PER_STEP); }
static int firstkey(int iter, int step) { return (iter * OPER_PER_ITER) + (step * OPER_PER_STEP); }
//static toku_pthread_t thread;
......
......@@ -207,9 +207,15 @@ uint_dbt_cmp (DB *db, const DBT *a, const DBT *b) {
#if !TOKU_WINDOWS && !defined(BOOL_DEFINED)
#define BOOL_DEFINED
typedef enum __toku_bool { FALSE=0, TRUE=1} BOOL;
#include <stdbool.h>
// typedef enum __toku_bool { FALSE=0, TRUE=1} BOOL;
#define TRUE true
#define FALSE false
typedef bool BOOL;
#endif
#ifdef USE_TDB
#define SET_TRACE_FILE(x) toku_set_trace_file(x)
#define CLOSE_TRACE_FILE(x) toku_close_trace_file()
......
......@@ -45,6 +45,10 @@ ifeq ($(DEBUG),)
DEBUG = 0
endif
ifeq ($(HAVE_CILK),)
HAVE_CILK = 1
endif
ifeq ($(VTUNE),1)
LINK_MUST_BE_LAST = /link /fixed:no
else
......@@ -86,6 +90,14 @@ ifeq ($(SYSTEM),sunos)
CPPFLAGS += -DTOKU_ALLOW_DEPRECATED
endif
ifeq ($(CC),icc)
CPPFLAGS += -DUSING_ICC
ifeq ($(HAVE_CILK),1)
CPPFLAGS += -DHAVE_CILK
LCILKRTS += -lcilkrts
endif
endif
ifeq ($(TOKUDB_REVISION),)
TOKUDB_REVISION = 0
endif
......@@ -119,7 +131,8 @@ else ifeq ($(GCCVERSION),4.4.0)
GCC_VERSION_SPECIFIC = -Wno-deprecated
endif
WALL = $(GCC_VERSION_SPECIFIC) -Wall -Wextra -Wcast-align -Wbad-function-cast -Wno-missing-noreturn -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
WALL = $(GCC_VERSION_SPECIFIC) -Wall -Wextra -Wcast-align -Wbad-function-cast -Wno-missing-noreturn -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
-Wpointer-arith # don't do arithmetic on void*.
FORMAT = -Wmissing-format-attribute #-Wformat=2 #Stronger printf warnings once logger.c cleaned up
ifeq ($(SYSTEM),sunos)
......@@ -142,15 +155,13 @@ else ifeq ($(GCCVERSION),4.4.1)
else ifeq ($(GCCVERSION),4.4.0)
CFLAGS += -Wno-strict-aliasing
endif
LIBPORTABILITY = $(TOKUROOT)lib/libtokuportability.$(AEXT)
LIBPORTABILITY_BUNDLE = $(TOKUROOT)lib/libtokuportability.bundle
LIBPORTABILITY=$(TOKUROOT)lib/libtokuportability.$(SOEXT)
PORTABILITY_HEADERS= $(TOKUROOT)$(SYSTEM)
ALWAYS_LINK= $(LIBPORTABILITY) -lz -lpthread
ALWAYS_LINK= -lz -lpthread
ifeq ($(CC),icc)
ifeq ($(CYGWIN),)
ALWAYS_LINK += -static-intel
endif
# needed for things like intel_fast_memset(), intel_sse2_strlen()
ALWAYS_LINK+=-lirc
endif
C99 = -std=c99
W64 = #-Wshorten-64-to-32
......@@ -263,18 +274,21 @@ ifeq ($(CC),icc)
#Linux
ICC_NOWARN=-diag-disable #Need the space
endif
DISABLE_WARNING +=111# Unreachable code (i.e. assert(0) )
DISABLE_WARNING +=271# Remove warnings about trailing comma being nonstandard
DISABLE_WARNING +=424# Remove warnings about extra ';' being ignored
DISABLE_WARNING +=810# Remove warnings about losing precision
#DISABLE_WARNING +=111# Unreachable code (i.e. assert(0) )
#DISABLE_WARNING +=271# Remove warnings about trailing comma being nonstandard
#DISABLE_WARNING +=424# Remove warnings about extra ';' being ignored
#DISABLE_WARNING +=810# Remove warnings about losing precision
DISABLE_WARNING +=94# Allow arrays of length 0
DISABLE_WARNING +=118# Allow void functions to return void functions
DISABLE_WARNING +=177# Don't complain about static variables that are not used.
#DISABLE_WARNING +=188# Don't complain about enumerated type mixed with another type.
DISABLE_WARNING +=589# Don't complain about goto into a block that skips initializing variables. GCC catches the actual uninitialized variables.
DISABLE_WARNING +=981# Don't complain about "operands are evaluated in unspecified order". This seems to be generated whenever more than one argument to a function or operand is computed by function call.
DISABLE_WARNING +=1324# Don't complain about rdtsc clobbering its registers more than once.
DISABLE_WARNING +=1786# Don't complain about 'read/write/other standards' being deprecated
#DISABLE_WARNING +=118# Allow void functions to return void functions
#DISABLE_WARNING +=177# Do not complain about static variables that are not used.
#DISABLE_WARNING +=188# Do not complain about enumerated type mixed with another type.
DISABLE_WARNING +=589# Do not complain about goto into a block that skips initializing variables. GCC catches the actual uninitialized variables.
#DISABLE_WARNING +=981# Do not complain about "operands are evaluated in unspecified order". This seems to be generated whenever more than one argument to a function or operand is computed by function call.
#DISABLE_WARNING +=1324# Do not complain about rdtsc clobbering its registers more than once.
#DISABLE_WARNING +=1786# Do not complain about 'read/write/other standards' being deprecated
DISABLE_WARNING +=2259# Do not complain about 'non-pointer conversion from int to u_int8_t (and other small types) may lose significant bits'. This is a useless warning because it produces too many false positives.
DISABLE_WARNING +=11000 11001 11006# Do not remark about multi-file optimizations, single-file optimizations, and object temp files.
DISABLE_WARNING += 11003# Don't complain if some file was not compiled with -ipo
SKIP_WARNING = $(ICC_NOWARN)$(shell sed 's/ /,/g' <<< "$(DISABLE_WARNING)" | sed 's/,//')
endif
......@@ -298,7 +312,6 @@ ifneq ($(CYGWIN),)
HGRIND =#No Hgrind in cygwin
FPICFLAGS=#FPIC is default and not allowed as an option.
VISIBILITY=#Not supported
SHADOW=#Not supported
ifeq ($(CC),icc)
#Cygwin icc only
ifeq ($(CRUNTIME),)
......@@ -452,7 +465,7 @@ 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) $(LOCKTREE_BUNDLE): $(@D)*.[ch]
cd $(@D) && $(MAKE) $(@F)
$(LOCKTREE) $(LOCKTREE_LINEAR) $(LOCKTREE_TLOG) $(LOCKTREE_LOG) $(LOCKTREE_BUNDLE): $(NEWBRT_BUNDLE) $(LIBPORTABILITY_BUNDLE) $(LIBPORTABILITY)
$(LOCKTREE) $(LOCKTREE_LINEAR) $(LOCKTREE_TLOG) $(LOCKTREE_LOG) $(LOCKTREE_BUNDLE): $(LIBPORTABILITY)
endif
ifeq ($(SKIP_RANGETREERULE),)
......@@ -463,16 +476,10 @@ 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) $(RANGETREE_BUNDLE): $(@D)*.[ch]
cd $(@D) && $(MAKE) $(@F)
$(RANGETREE) $(RANGETREE_LINEAR) $(RANGETREE_TLOG) $(RANGETREE_LOG) $(RANGETREE_BUNDLE): $(NEWBRT_BUNDLE) $(LIBPORTABILITY_BUNDLE) $(LIBPORTABILITY)
$(RANGETREE) $(RANGETREE_LINEAR) $(RANGETREE_TLOG) $(RANGETREE_LOG) $(RANGETREE_BUNDLE): $(LIBPORTABILITY)
endif
ifeq ($(SKIP_NEWBRTRULE),)
IPO_NEWBRT = $(TOKUROOT)newbrt/ipo_newbrt.$(AEXT)
NEWBRT = $(TOKUROOT)newbrt/newbrt.$(AEXT)
NEWBRT_BUNDLE = $(TOKUROOT)newbrt/newbrt.bundle
$(NEWBRT) $(NEWBRT_BUNDLE) $(IPO_NEWBRT): $(@D)*.[ch]
pwd && cd $(@D) && $(MAKE) $(@F)
$(NEWBRT): $(NEWBRT_BUNDLE)
LOG_HEADER = $(TOKUROOT)newbrt/log_header.h
$(LOG_HEADER): $(TOKUROOT)newbrt/logformat.c
cd $(@D) && $(MAKE) $(@F)
......@@ -501,12 +508,12 @@ PTHREAD_LOCAL=
endif
BIN_FROM_C_FLAGS =$(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(BINOUTPUT)$@
BIN_FROM_C_FLAGS =$(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDLIBS) $(BINOUTPUT)$@
BIN_FROM_C_FLAGS_NOLIB=$(CFLAGS) $(CPPFLAGS) $(LDFLAGS_NOLIB) $(BINOUTPUT)$@
%$(BINSUF):%.c $(DEPEND_COMPILE) $(DEPEND_LINK)
$(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
BIN_FROM_O_FLAGS =$(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(BINOUTPUT)$@
BIN_FROM_O_FLAGS =$(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDLIBS) $(BINOUTPUT)$@
BIN_FROM_O_FLAGS_NOLIB=$(CFLAGS) $(CPPFLAGS) $(LDFLAGS_NOLIB) $(BINOUTPUT)$@
%$(BINSUF):%.$(OEXT) $(DEPEND_COMPILE) $(DEPEND_LINK)
$(CC) $< $(BIN_FROM_O_FLAGS) $(LINK_MUST_BE_LAST)
......@@ -514,14 +521,6 @@ BIN_FROM_O_FLAGS_NOLIB=$(CFLAGS) $(CPPFLAGS) $(LDFLAGS_NOLIB) $(BINOUTPUT)$@
%.$(OEXT):%.c $(DEPEND_COMPILE)
$(CC) $< -c $(CPPFLAGS) $(CFLAGS) $(OOUTPUT)$@
CILKROOT=/usr/local/cilk/
CILKPP=$(CILKROOT)bin/cilk++
CILKFLAGS=$(filter-out -Wbad-function-cast -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -std=c99,$(CFLAGS)) $(CPPFLAGS)
%$(BINSUF):%.cilk $(DEPEND_COMPILE)
$(CILKPP) $(CILKFLAGS) $< $(LOADLIBES) -o $@
%.serial$(BINSUF): %.cilk
$(CILKPP) -fcilk-stub $(CILKFLAGS) $^ $(LOADLIBES) -o $@
CXXFLAGS=$(filter-out -Wbad-function-cast -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -std=c99,$(CFLAGS)) $(CPPFLAGS)
%.$(AEXT):
......@@ -556,18 +555,7 @@ endif
SO_FLAGS=$(SHARED) $(BIN_FROM_O_FLAGS) $(EXPORTMAP)
ifeq ($(BRTLOADER),cilk)
CILK_LINKER_FLAGS = -Wl,-Bsymbolic-functions -Wl,-z,now
ifeq ($(ARCH),x86_64)
CILKRTS_LIB = -L$(CILKROOT)/lib64 -lcilkrts_pic
else
CILKRTS_LIB = -L$(CILKROOT)/lib32 -lcilkrta_pic
endif
SO_FLAGS += $(CILK_LINKER_FLAGS) $(CILKRTS_LIB)
TOKULINKER = $(CXX)
else
TOKULINKER = $(CC)
endif
%.$(SOEXT): $(EXPORTMAPFILE)
$(TOKULINKER) $(SO_FLAGS)
......
#if !defined(TOKU_ATOMIC_H)
#define TOKU_ATOMIC_H
#if defined(__cplusplus) || defined(__cilkplusplus)
#ifdef __cplusplus
extern "C" {
#endif
#if TOKU_WINDOWS
static inline uint32_t
toku_sync_fetch_and_add_uint32(volatile uint32_t *a, uint32_t b) {
return _InterlockedExchangeAdd((LONG*)a, b);
}
static inline uint32_t
toku_sync_fetch_and_increment_uint32(volatile uint32_t *a) {
uint32_t r = _InterlockedIncrement((LONG*)a);
//InterlockedIncrement returns the result, not original.
//Return the original.
return r - 1;
}
static inline uint32_t
toku_sync_fetch_and_decrement_uint32(volatile uint32_t *a) {
uint32_t r = _InterlockedDecrement((LONG*)a);
//InterlockedDecrement returns the result, not original.
//Return the original.
return r + 1;
}
static inline int32_t
toku_sync_fetch_and_add_int32(volatile int32_t *a, int32_t b) {
return _InterlockedExchangeAdd((LONG*)a, b);
}
static inline int32_t
toku_sync_fetch_and_increment_int32(volatile int32_t *a) {
int32_t r = _InterlockedIncrement((LONG*)a);
//InterlockedIncrement returns the result, not original.
//Return the original.
return r - 1;
}
static inline int32_t
toku_sync_fetch_and_decrement_int32(volatile int32_t *a) {
int32_t r = _InterlockedDecrement((LONG*)a);
//InterlockedDecrement returns the result, not original.
//Return the original.
return r + 1;
}
static inline int32_t
toku_sync_increment_and_fetch_int32(volatile int32_t *a) {
int32_t r = _InterlockedIncrement((LONG*)a);
//InterlockedIncrement returns the result, not original.
//Return the result.
return r;
}
static inline int32_t
toku_sync_decrement_and_fetch_int32(volatile int32_t *a) {
int32_t r = _InterlockedDecrement((LONG*)a);
//InterlockedDecrement returns the result, not original.
//Return the result.
return r;
}
#define TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA 0
//Vista has 64 bit atomic instruction functions.
//64 bit windows should also have it, but we're using neither right now.
#if TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA || TOKU_WINDOWS_64
#define TOKU_WINDOWS_HAS_ATOMIC_64 1
#else
#define TOKU_WINDOWS_HAS_ATOMIC_64 0
#endif
static inline uint64_t
toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) {
#if TOKU_WINDOWS_HAS_ATOMIC_64
return _InterlockedExchangeAdd64((int64_t*)a, b);
#else
//Temporarily just use 32 bit atomic instructions (treat the values as 32
//bit only). For now this is ok, the values are only used in show engine
//status.
return toku_sync_fetch_and_add_uint32((uint32_t*)a, b);
#endif
}
static inline uint64_t
toku_sync_fetch_and_increment_uint64(volatile uint64_t *a) {
#if TOKU_WINDOWS_HAS_ATOMIC_64
uint64_t r = _InterlockedIncrement64((int64_t*)a);
//InterlockedIncrement64 returns the result, not original.
//Return the original.
return r - 1;
#else
//Temporarily just use 32 bit atomic instructions (treat the values as 32
//bit only). For now this is ok, the values are only used in show engine
//status.
return toku_sync_fetch_and_increment_uint32((uint32_t*)a);
#endif
}
#else
//Linux
static inline uint32_t toku_sync_fetch_and_add_uint32(volatile uint32_t *a, uint32_t b) {
// icc previously required _InterlockedExchangeAdd((LONG*)a, b);
return __sync_fetch_and_add(a, b);
}
static inline uint32_t toku_sync_fetch_and_increment_uint32(volatile uint32_t *a) {
// ICC has an _InterlockedIncrement function that returns the new result. We'll just use our primitive.
return toku_sync_fetch_and_add_uint32(a, 1);
}
......@@ -145,11 +45,12 @@ static inline int32_t toku_sync_decrement_and_fetch_int32(volatile int32_t *a) {
return toku_sync_add_and_fetch_int32(a, -1);
}
#if __GNUC__ && __i386__
// workaround for a gcc 4.1.2 bug on 32 bit platforms.
uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) __attribute__((noinline));
static uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) __attribute__((noinline), (unused)) {
return __sync_fetch_and_add(a, b);
}
#else
......@@ -163,13 +64,19 @@ static inline uint64_t toku_sync_fetch_and_increment_uint64(volatile uint64_t *a
return toku_sync_fetch_and_add_uint64(a, 1);
}
#define TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA 0
//Vista has 64 bit atomic instruction functions.
//64 bit windows should also have it, but we're using neither right now.
#if TOKU_WINDOWS_MIN_SUPPORTED_IS_VISTA || TOKU_WINDOWS_64
#define TOKU_WINDOWS_HAS_ATOMIC_64 1
#else
#define TOKU_WINDOWS_HAS_ATOMIC_64 0
#endif
// DO_GCC_PRAGMA(GCC __sync_fetch_and_add __sync_add_and_fetch)
#if defined(__cplusplus) || defined(__cilkplusplus)
#ifdef __cplusplus
}
#endif
#endif
......@@ -109,14 +109,14 @@ typedef int64_t toku_off_t;
// Deprecated functions.
#if !defined(TOKU_ALLOW_DEPRECATED)
# if defined(__ICL) //Windows Intel Compiler
# if defined(__ICL) || defined(__ICC) // Intel Compiler
# pragma deprecated (creat, fstat, stat, getpid, syscall, sysconf, mkdir, strdup)
# pragma poison off_t
# pragma poison pthread_attr_t pthread_t
# pragma poison pthread_mutexattr_t pthread_mutex_t
# pragma poison pthread_condattr_t pthread_cond_t
# pragma poison pthread_rwlockattr_t pthread_rwlock_t
# pragma poison timespec
//# pragma poison off_t
//# pragma poison pthread_attr_t pthread_t
//# pragma poison pthread_mutexattr_t pthread_mutex_t
//# pragma poison pthread_condattr_t pthread_cond_t
//# pragma poison pthread_rwlockattr_t pthread_rwlock_t
//# pragma poison timespec
# ifndef DONT_DEPRECATE_WRITES
# pragma poison write pwrite
# endif
......@@ -155,9 +155,9 @@ extern void *realloc(void*, size_t) __THROW __attribute__((__deprecat
# endif
#endif
void *os_malloc(size_t);
void *os_realloc(void*,size_t);
void os_free(void*);
void *os_malloc(size_t) __attribute__((__visibility__("default")));
void *os_realloc(void*,size_t) __attribute__((__visibility__("default")));
void os_free(void*) __attribute__((__visibility__("default")));
// full_pwrite and full_write performs a pwrite, and checks errors. It doesn't return unless all the data was written. */
void toku_os_full_pwrite (int fd, const void *buf, size_t len, toku_off_t off) __attribute__((__visibility__("default")));
......
......@@ -43,7 +43,10 @@ $(UTILS): LINK_FILES+=$(WIN_YDB)
$(UTILS): $(WIN_YDB)
else
$(UTILS): DLINK_FILES=$(TOKUROOT)lib/libtokudb.$(SOEXT)
$(STATIC_UTILS): LINK_FILES+=$(TOKUROOT)lib/libtokudb.$(AEXT)
NEWBRT_OBJS=$(patsubst %,../%,$(shell cat $(TOKUROOT)lib/newbrt.olist))
TOKUPORTABILITY_OBJS=$(patsubst %,../%,$(shell cat $(TOKUROOT)lib/tokuportability.olist))
YDB_OBJS=$(wildcard ../src/*.$(OEXT))
$(STATIC_UTILS): LINK_FILES+= $(NEWBRT_OBJS) $(TOKUPORTABILITY_OBJS) $(YDB_OBJS) ../src/lock_tree/locktree.a ../src/range_tree/rangetree.a
ifeq ($(BRTLOADER),cilk)
DLINK_FILES += cilkrts stdc++
......@@ -81,6 +84,8 @@ endif
$(BDB_UTILS): DLINK_FILES=db.$(SOEXT)
endif
$(BDB_UTILS): CPPFLAGS+=-DTOKU_ALLOW_DEPRECATED
$(BDB_UTILS): LDLIBS+=-ltokuportability
$(BDB_UTILS): LDFLAGS+=-L$(TOKUROOT)lib -Wl,-rpath,$(shell pwd)/$(TOKUROOT)lib
#empty on purpose
$(BDB_UTILS): CPPFLAGS+=-DIS_TDB=0
$(UTILS) $(STATIC_UTILS): CPPFLAGS+=-DIS_TDB=1
......@@ -120,7 +125,7 @@ coverage: $(UTILS)
$(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST) -DUSE_BDB=1
%_static$(BINSUF): %.c ../lib/libtokudb.$(AEXT)
$(CC) $< ../lib/libtokudb.$(AEXT) $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
$(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
strip: $(STATIC_UTILS)
strip $(STATIC_UTILS)
......
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