Commit 5d7a5dfa authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1185

Modified makefile to be more modular with icc and gcc options.
Modified portability.h with some stubs and some real portability code

Removed named variadic macros for unnamed variadic macros (c99 only supports unnamed)
Removed ', ## __VAR_ARGS__' in favor of ', __VAR_ARGS__' due to apparent bug in the intel compiler (on windows at least)
__ICC means the linux intel compiler, __ICL means the windows intel compiler
__INTEL_COMPILER is set by both
Removed some include files (for windows) that don't exist.

git-svn-id: file:///svn/tokudb.1131b+1080a+1185+nostatementexprs@6473 c7de825b-a66e-492c-adef-691d508d4ae1
parent 31c755d3
......@@ -26,34 +26,74 @@ else
endif
endif
ifneq ($(CYGWIN),)
FORMAT=-Wno-format
CYG_ADD_LIBZ=/usr/lib/libz.a
else
#CFLAG default options
WERROR = -Werror
WALL = -Wall -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn
FORMAT = -Wmissing-format-attribute
VISIBILITY= -fvisibility=hidden
FPICFLAGS = -fPIC
# valgrind is not present on cygwin
SHADOW = -Wshadow
SYMBOLS = -g3 -ggdb3
PORTABILITY=
SKIP_WARNING=
COMBINE_C = -combine -c
LINK_FILES= -lz -lpthread
C99 = -std=gnu99
#Tools
VGRIND = valgrind --quiet --error-exitcode=1 --leak-check=yes
VISIBILITY=-fvisibility=hidden
ifneq ($(CC),icc)
SHADOW=-Wshadow
FORMAT=-Wmissing-format-attribute
ifeq ($(CC),icc)
#icc only:
OPTFLAGS = -O3 -ip -ipo2
COMBINE_C = -ipo-c
FORMAT= #No argument for extra format warnings.
WALL = -Wall -Wcheck # '-Wextra' becomes '-Wcheck' in icc
SYMBOLS= -g -debug all -inline-debug-info
PORTABILITY=-diag-enable port-win
ifneq ($(CYGWIN),)
#Cygwin
ICC_NOWARN=-Qdiag-disable:
else
#Linux
ICC_NOWARN=-diag-disable #Need the space
endif
SKIP_WARNING += $(ICC_NOWARN)177 # Don't complain about static variables that are not used.
#SKIP_WARNING += $(ICC_NOWARN)188 # Don't complain about enumerated type mixed with another type.
SKIP_WARNING += $(ICC_NOWARN)589 # Don't complain about goto into a block that skips initializing variables. GCC catches the actual uninitialized variables.
SKIP_WARNING += $(ICC_NOWARN)869 # Don't complain about unused variables (since we defined __attribute__ to be nothing.)
SKIP_WARNING += $(ICC_NOWARN)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.
SKIP_WARNING += $(ICC_NOWARN)1324 # Don't complain about rdtsc clobbering its registers more than once.
endif
CFLAGS = -Werror -Wall $(FORMAT) $(OPTFLAGS) $(GCOV_FLAGS) $(PROF_FLAGS) $(FPICFLAGS) $(SHADOW) $(VISIBILITY)
ifneq ($(CC),icc)
CFLAGS += -Wextra -Wcast-align -Wbad-function-cast -Wmissing-noreturn -g3 -ggdb3
else
CFLAGS += -g
CFLAGS += -diag-enable port-win
CFLAGS += -diag-disable 177 # Don't complain about static variables that are not used.
#CFLAGS += -diag-disable 188 # Don't complain about enumerated type mixed with another type.
CFLAGS += -diag-disable 589 # Don't complain about goto into a block that skips initializing variables. GCC catches the actual uninitialized variables.
CFLAGS += -diag-disable 869 # Don't complain about unused variables (since we defined __attribute__ to be nothing.)
CFLAGS += -diag-disable 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.
CFLAGS += -diag-disable 1324 # Don't complain about rdtsc clobbering its registers more than once.
ifneq ($(CYGWIN),)
#Cygwin (Windows) Must override some settings
CYG_ADD_LIBZ=/usr/lib/libz.a
VGRIND =#No Valgrind in cygwin
FPICFLAGS=#FPIC is default and not allowed as an option.
VISIBILITY=#Not supported
SHADOW=#Not supported
ifeq ($(CC),icc)
#Cygwin icc only
C99 = -Qstd=c99
OPTFLAGS = -Ox -Qip -Qipo2
COMBINE_C = -Qipo-c
WERROR = -WX # Windows icc version of -Werror
SYMBOLS= -Zi -debug:all -Qinline-debug-info
PORTABILITY=
LINK_FILES=#Not supported
SKIP_WARNING += $(ICC_NOWARN)1786 # Don't complain about 'read/write/other standards' being deprecated
else
#Cygwin gcc only
FORMAT = -Wno-format
endif
endif
LDFLAGS = $(OPTFLAGS) -g $(GCOV_FLAGS) $(PROF_FLAGS) -lz -lpthread
CFLAGS = $(WALL) $(WERROR) $(FORMAT) $(VISIBILITY) $(FPICFLAGS) $(SHADOW)
CFLAGS += $(OPTFLAGS) $(GCOV_FLAGS) $(PROF_FLAGS)
CFLAGS += $(SYMBOLS) $(SKIP_WARNING) $(C99)
LDFLAGS = $(OPTFLAGS) $(SYMBOLS) $(GCOV_FLAGS) $(PROF_FLAGS) $(LINK_FILES)
# Need XOPEN_SOURCE=600 to get strtoll()
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=600
......@@ -114,12 +154,9 @@ HFILES = $(wildcard *.h)
BRT_C_FILES = $(patsubst %,%.c,$(BRT_SOURCES))
ifeq ($(CIL),1)
else ifeq ($(CC),icc)
newbrt.o: $(BRT_C_FILES) $(HFILES)
$(CC) -ipo-c $(CFLAGS) $(CPPFLAGS) $(BRT_C_FILES) -o $@
else
newbrt.o: $(BRT_C_FILES) $(HFILES)
$(CC) -combine $(CFLAGS) $(CPPFLAGS) $(BRT_C_FILES) -c -o $@
$(CC) $(COMBINE_C) $(CFLAGS) $(CPPFLAGS) $(BRT_C_FILES) -o $@
endif
tdb_logprint.o: log-internal.h brttypes.h log.h kv-pair.h log_header.h
......@@ -185,6 +222,7 @@ clean-tests:
clean-local:
rm -rf $(BINS) *.o *.bb *.bbg *.da *.gcov *.gcno *.gcda
rm -rf test_oexcl.c.tmp *.brt
rm -rf *.obj *.pdb *.ilk *.exe
# After doing (cd ../src/tests;make test_log5.recover), run these. The files should have no differences.
testdump: brtdump
......
......@@ -10,7 +10,9 @@
#define _FILE_OFFSET_BITS 64
#include "../include/db.h"
#if !defined(TOKU_WINDOWS)
#include <inttypes.h>
#endif
typedef struct brt *BRT;
struct brt_header;
......
......@@ -9,20 +9,23 @@
// Portability first!
#include "portability.h"
#include <ctype.h>
#if !defined(TOKU_WINDOWS)
#include <dirent.h>
#include <errno.h>
#include <inttypes.h>
#include <malloc.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <unistd.h>
#include <zlib.h>
#endif
#include <ctype.h>
#include <errno.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "block_allocator.h"
#include "brt.h"
......
......@@ -86,7 +86,7 @@ static inline u_int64_t getint64 (unsigned char *p) {
unsigned char* __kvaladdr = 4 + __klenaddr; \
unsigned char* __clenaddr = __klen + __kvaladdr; u_int32_t __clen = getint(__clenaddr); \
unsigned char* __cvaladdr = 4 + __clenaddr; \
return funname ## _le_committed(__klen, __kvaladdr, __clen, __cvaladdr, ## __VA_ARGS__); } \
return funname ## _le_committed(__klen, __kvaladdr, __clen, __cvaladdr, __VA_ARGS__); } \
case LE_BOTH: { \
unsigned char* __xidaddr = 1+(unsigned char*)le; u_int64_t __xid = getint64(__xidaddr); \
unsigned char* __klenaddr = 8 + __xidaddr; u_int32_t __klen = getint(__klenaddr); \
......@@ -95,21 +95,21 @@ static inline u_int64_t getint64 (unsigned char *p) {
unsigned char* __cvaladdr = 4 + __clenaddr; \
unsigned char* __plenaddr = __clen + __cvaladdr; u_int32_t __plen = getint(__plenaddr); \
unsigned char* __pvaladdr = 4 + __plenaddr; \
return funname ## _le_both(__xid, __klen, __kvaladdr, __clen, __cvaladdr, __plen, __pvaladdr, ## __VA_ARGS__); } \
return funname ## _le_both(__xid, __klen, __kvaladdr, __clen, __cvaladdr, __plen, __pvaladdr, __VA_ARGS__); } \
case LE_PROVDEL: { \
unsigned char* __xidaddr = 1+(unsigned char*)le; u_int64_t __xid = getint64(__xidaddr); \
unsigned char* __klenaddr = 8 + __xidaddr; u_int32_t __klen = getint(__klenaddr); \
unsigned char* __kvaladdr = 4 + __klenaddr; \
unsigned char* __dlenaddr = __klen + __kvaladdr; u_int32_t __dlen = getint(__dlenaddr); \
unsigned char* __dvaladdr = 4 + __dlenaddr; \
return funname ## _le_provdel(__xid, __klen, __kvaladdr, __dlen, __dvaladdr, ## __VA_ARGS__); } \
return funname ## _le_provdel(__xid, __klen, __kvaladdr, __dlen, __dvaladdr, __VA_ARGS__); } \
case LE_PROVPAIR: { \
unsigned char* __xidaddr = 1+(unsigned char*)le; u_int64_t __xid = getint64(__xidaddr); \
unsigned char* __klenaddr = 8 + __xidaddr; u_int32_t __klen = getint(__klenaddr); \
unsigned char* __kvaladdr = 4 + __klenaddr; \
unsigned char* __plenaddr = __klen + __kvaladdr; u_int32_t __plen = getint(__plenaddr); \
unsigned char* __pvaladdr = 4 + __plenaddr; \
return funname ## _le_provpair(__xid, __klen, __kvaladdr, __plen, __pvaladdr, ## __VA_ARGS__); } \
return funname ## _le_provpair(__xid, __klen, __kvaladdr, __plen, __pvaladdr, __VA_ARGS__); } \
} abort(); } while (0)
......
......@@ -9,7 +9,9 @@
#include "list.h"
#include "memarena.h"
#include <stdio.h>
#if !defined(TOKU_WINDOWS)
#include <pthread.h>
#endif
#include <sys/types.h>
#include <string.h>
......
......@@ -9,6 +9,7 @@
* The struct definitions.
* The Latex documentation.
*/
#include "portability.h"
#include <assert.h>
#include <ctype.h>
#include <stdarg.h>
......@@ -17,7 +18,9 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#if !defined(TOKU_WINDOWS)
#include <unistd.h>
#endif
typedef struct field {
char *type;
......@@ -314,11 +317,11 @@ generate_dispatch (void) {
DO_ROLLBACKS(lt, fprintf(hf, " case RT_%s: funprefix ## %s (&(s)->u.%s); break;\\\n", lt->name, lt->name, lt->name));
fprintf(hf, " }})\n");
fprintf(hf, "#define logtype_dispatch_assign(s, funprefix, var, args...) do { switch((s)->cmd) {\\\n");
DO_LOGTYPES(lt, fprintf(hf, " case LT_%s: var = funprefix ## %s (&(s)->u.%s, ## args); break;\\\n", lt->name, lt->name, lt->name));
fprintf(hf, "#define logtype_dispatch_assign(s, funprefix, var, ...) do { switch((s)->cmd) {\\\n");
DO_LOGTYPES(lt, fprintf(hf, " case LT_%s: var = funprefix ## %s (&(s)->u.%s, __VA_ARGS__); break;\\\n", lt->name, lt->name, lt->name));
fprintf(hf, " }} while (0)\n");
fprintf(hf, "#define rolltype_dispatch_assign(s, funprefix, var, args...) do { \\\n");
fprintf(hf, "#define rolltype_dispatch_assign(s, funprefix, var, ...) do { \\\n");
fprintf(hf, " switch((s)->cmd) {\\\n");
DO_ROLLBACKS(lt, {
fprintf(hf, " case RT_%s: var = funprefix ## %s (", lt->name, lt->name);
......@@ -328,7 +331,7 @@ generate_dispatch (void) {
fprintf(hf, "(s)->u.%s.%s", lt->name, ft->name);
fieldcount++;
});
fprintf(hf, ",## args); break;\\\n");
fprintf(hf, ", __VA_ARGS__); break;\\\n");
});
fprintf(hf, " default: assert(0);} } while (0)\n");
......
......@@ -3,8 +3,51 @@
// Portability layer
#if defined(__INTEL_COMPILER)
#if !defined(__ICL) && !defined(__ICC)
#error Which intel compiler?
#endif
#if defined(__ICL) && defined(__ICC)
#error Cannot distinguish between windows and linux intel compiler
#endif
#if defined(__ICL)
//Windows Intel Compiler
#define TOKU_WINDOWS
//Define standard integer types.
typedef __int8 int8_t;
typedef unsigned __int8 u_int8_t;
typedef __int16 int16_t;
typedef unsigned __int16 u_int16_t;
typedef __int32 int32_t;
typedef unsigned __int32 u_int32_t;
typedef __int64 int64_t;
typedef unsigned __int64 u_int64_t;
//Define chmod
/*
static inline
int
chmod(const char *path, mode_t mode) {
//TODO: Write API to support what we really need.
//Linux version supports WRITE/EXECUTE/READ bits separately for user/group/world
//windows _chmod supports WRITE/READ bits separately for ?? one type (user? world?)
//See _chmod in sys/stat.h
//Supports setting read/write mode (not separately for user/group/world)
return 0;
}
*/
#define chmod(a,b) (void)0 /* Remove temporarily till compatibility layer exists */
#define FAKE_WINDOWS_STUBS
#ifdef FAKE_WINDOWS_STUBS
typedef size_t ssize_t;
#define PRId64 "lld"
#endif //FAKE_WINDOWS_STUBS
#if defined(__ICC)
#endif //Windows Intel Compiler
// Intel compiler.
// Define ntohl using bswap.
......
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