diff --git a/CMakeLists.txt b/CMakeLists.txt index b870f5a..7dbad83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,7 @@ INCLUDE(CheckFunctionExists) INCLUDE(CheckCSourceCompiles) CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE) CHECK_FUNCTION_EXISTS(fdatasync HAVE_FDATASYNC) +CHECK_FUNCTION_EXISTS(tdestroy HAVE_TDESTROY) CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE #include #include @@ -71,6 +72,9 @@ int main(int argc, char * argv[]) { } " HAVE_O_DIRECT) +CHECK_C_SOURCE_COMPILES("#include +int main(int argc, char * argv[]) { alloca(1); }" HAVE_ALLOCA_H) + CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE #include @@ -86,6 +90,16 @@ int main(int argc, char* argv[]) { } " HAVE_GCC_ATOMICS) +CHECK_C_SOURCE_COMPILES(" +#include +#include +int main(int argc, char* argv[]) { + pthread_attr_t a; + pthread_attr_setstacksize(&a, PTHREAD_STACK_MIN); + return 0; +} +" HAVE_PTHREAD_STACK_MIN) + MACRO(CREATE_CHECK NAME) ADD_EXECUTABLE(${NAME} ${NAME}.c) TARGET_LINK_LIBRARIES(${NAME} ${COMMON_LIBRARIES}) @@ -112,9 +126,15 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/build # set linker path for this and all subdirs LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/src/stasis) -SET(COMMON_LIBRARIES stasis m pthread) -SET(CMAKE_C_FLAGS "-g -Wall -pedantic -std=gnu99 -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_C_FLAGS}") -SET(CMAKE_CXX_FLAGS "-g -Wall -Wno-variadic-macros -Wno-long-long -pedantic -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_CXX_FLAGS}") +IF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" ) + SET(COMMON_LIBRARIES stasis m pthread) + SET(CMAKE_C_FLAGS "-g -Wall -pedantic -std=gnu99 -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_C_FLAGS}") + SET(CMAKE_CXX_FLAGS "-g -Wall -Wno-variadic-macros -Wno-long-long -pedantic -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_CXX_FLAGS}") +ELSEIF ( "${CMAKE_C_COMPILER_ID}" STREQUAL "SunPro" ) + SET(COMMON_LIBRARIES stasis m pthread Crun Cstd) + SET(CMAKE_C_FLAGS "-g -xc99=all -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_C_FLAGS}") + SET(CMAKE_CXX_FLAGS "-g -DPBL_COMPAT -D_FILE_OFFSET_BITS=64 ${CMAKE_CXX_FLAGS}") +ENDIF () INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/stasis DESTINATION include/ diff --git a/benchmarks/linearHashNTAMultiReader.c b/benchmarks/linearHashNTAMultiReader.c index 8e9a38f..a400fa7 100644 --- a/benchmarks/linearHashNTAMultiReader.c +++ b/benchmarks/linearHashNTAMultiReader.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/benchmarks/linearHashNTAThreaded.c b/benchmarks/linearHashNTAThreaded.c index f8d535c..f82a3c4 100644 --- a/benchmarks/linearHashNTAThreaded.c +++ b/benchmarks/linearHashNTAThreaded.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/benchmarks/linearHashNTAWriteRequests.c b/benchmarks/linearHashNTAWriteRequests.c index 23f9ea1..e223991 100644 --- a/benchmarks/linearHashNTAWriteRequests.c +++ b/benchmarks/linearHashNTAWriteRequests.c @@ -1,3 +1,4 @@ +#include #include #include #include diff --git a/config.h.cmake b/config.h.cmake index f575808..6764069 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -3,4 +3,10 @@ #cmakedefine HAVE_SYNC_FILE_RANGE #cmakedefine HAVE_O_DIRECT #cmakedefine HAVE_GCC_ATOMICS +#cmakedefine HAVE_PTHREAD_STACK_MIN +#cmakedefine HAVE_ALLOCA_H +#cmakedefine HAVE_TDESTROY +#ifndef HAVE_PTHREAD_STACK_MIN +#define PTHREAD_STACK_MIN 32768 // wild guess. +#endif diff --git a/src/stasis/CMakeLists.txt b/src/stasis/CMakeLists.txt index 6ba93c7..b477ebd 100644 --- a/src/stasis/CMakeLists.txt +++ b/src/stasis/CMakeLists.txt @@ -12,7 +12,7 @@ ADD_LIBRARY(stasis crc32.c redblack.c tsearchcompat.c lhtable.c concurrentHash.c consumer.c arrayCollection.c ringbuffer.c fifo.c multiplexer.c graph.c logger/logEntry.c logger/safeWrites.c logger/logWriterUtils.c - logger/filePool.c +# logger/filePool.c logger/inMemoryLog.c logger/logHandle.c logger/logger2.c logger/logMemory.c diff --git a/src/stasis/blobManager.c b/src/stasis/blobManager.c index 84a6b22..8cedf20 100644 --- a/src/stasis/blobManager.c +++ b/src/stasis/blobManager.c @@ -1,3 +1,10 @@ +#include +#ifdef HAVE_ALLOCA_H +#include +#endif + +#include + #include #include #include diff --git a/src/stasis/bufferManager/legacy/legacyBufferManager.c b/src/stasis/bufferManager/legacy/legacyBufferManager.c index 9a6a59c..d6e22cf 100644 --- a/src/stasis/bufferManager/legacy/legacyBufferManager.c +++ b/src/stasis/bufferManager/legacy/legacyBufferManager.c @@ -37,7 +37,7 @@ static int pageWrite_legacyWrapper(stasis_buffer_manager_t *ignored, pageid_t pa releasePage(p); return 0; } -static void forcePageFile_legacyWrapper() { +static void forcePageFile_legacyWrapper(stasis_buffer_manager_t *ignored) { page_handle->force_file(page_handle); } static void forceRangePageFile_legacyWrapper(stasis_buffer_manager_t *ignored, lsn_t start, lsn_t stop) { diff --git a/src/stasis/concurrentHash.c b/src/stasis/concurrentHash.c index fc2754b..329212c 100644 --- a/src/stasis/concurrentHash.c +++ b/src/stasis/concurrentHash.c @@ -4,7 +4,7 @@ * Created on: Oct 15, 2009 * Author: sears */ -#define _XOPEN_SOURCE +#define _XOPEN_SOURCE 600 #include #include #include diff --git a/src/stasis/graph.c b/src/stasis/graph.c index a3f102a..78e5dee 100644 --- a/src/stasis/graph.c +++ b/src/stasis/graph.c @@ -1,3 +1,10 @@ +#include +#ifdef HAVE_ALLOCA_H +#include +#endif + +#include + #include #include #include diff --git a/src/stasis/logger/logWriterUtils.c b/src/stasis/logger/logWriterUtils.c index 4ed533f..2e27936 100644 --- a/src/stasis/logger/logWriterUtils.c +++ b/src/stasis/logger/logWriterUtils.c @@ -1,3 +1,5 @@ +#define _POSIX_C_SOURCE 200112L /* for flockfile() */ +#include #include /** @file diff --git a/src/stasis/operations/linearHashNTA.c b/src/stasis/operations/linearHashNTA.c index 5e9e8f9..c99b6b7 100644 --- a/src/stasis/operations/linearHashNTA.c +++ b/src/stasis/operations/linearHashNTA.c @@ -1,3 +1,4 @@ +#include #define __USE_GNU #define _GNU_SOURCE #include diff --git a/src/stasis/page/slotted.c b/src/stasis/page/slotted.c index 72e32ec..16f0a69 100644 --- a/src/stasis/page/slotted.c +++ b/src/stasis/page/slotted.c @@ -1,3 +1,10 @@ +#include +#ifdef HAVE_ALLOCA_H +#include +#endif + +#include + #include #include //#include diff --git a/src/stasis/stlredblack.cpp b/src/stasis/stlredblack.cpp index fd9f0d2..6c95479 100644 --- a/src/stasis/stlredblack.cpp +++ b/src/stasis/stlredblack.cpp @@ -12,15 +12,18 @@ #include #undef end +extern "C" { + typedef int (*c_cmp_t)(const void*, const void*, const void*); +} class MyCompare { - int (*cmp_)(const void*, const void*, const void*); + c_cmp_t cmp_; const void *arg_; public: bool operator() (const void* const &arg1, const void* const &arg2) const { return cmp_(arg1,arg2,arg_) < 0; }; - MyCompare(int (*cmp)(const void *, const void *, const void*)) : cmp_(cmp), arg_(NULL) {} + MyCompare(c_cmp_t cmp, int dummy) : cmp_(cmp), arg_(NULL) {} }; typedef std::set rb; @@ -28,7 +31,7 @@ typedef std::set rb; extern "C" { rbtree * stl_rbinit(int(*cmp)(const void*,const void*,const void*), int ignored) { - return reinterpret_cast(new rb(MyCompare(cmp))); + return reinterpret_cast(new rb(MyCompare(cmp, 0))); } const void * stl_rbdelete(const void * key, rbtree * tp) { rb::iterator it = reinterpret_cast(tp)->find(key); diff --git a/src/stasis/tsearchcompat.c b/src/stasis/tsearchcompat.c index 41531c2..3675557 100644 --- a/src/stasis/tsearchcompat.c +++ b/src/stasis/tsearchcompat.c @@ -58,7 +58,11 @@ static void noop_free(void* node) {} void compat_rbdestroy(rbtree * tp) { compat_rbtree* t = (compat_rbtree*)tp; if(t->root) { +#ifdef HAVE_TDESTROY tdestroy(&(t->root), noop_free); +#else + abort(); // TODO +#endif } } static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER; diff --git a/stasis/common.h b/stasis/common.h index 53e5ed1..66ff62c 100644 --- a/stasis/common.h +++ b/stasis/common.h @@ -134,22 +134,18 @@ typedef int16_t pagetype_t; * represents how to look up a record on a page * @todo int64_t (for recordid.size) is a stopgap fix. */ -#pragma pack(push,1) typedef struct { pageid_t page; slotid_t slot; int64_t size; } recordid; -#pragma pack(pop) // TODO move blob_record_t into an operation header. -#pragma pack(push,1) typedef struct { size_t offset; size_t size; // unsigned fd : 1; } blob_record_t; -#pragma pack(pop) /* Define Page as an incomplete type to hide its implementation from clients. diff --git a/test/stasis/check_bTree.c b/test/stasis/check_bTree.c index 9f2f45b..a543e0c 100644 --- a/test/stasis/check_bTree.c +++ b/test/stasis/check_bTree.c @@ -64,7 +64,7 @@ START_TEST(bTreeTest) { TbtreeInsert(xid, rid, NULL, &key, sizeof(key), (byte*)&val, sizeof(val)); uint64_t* theval = 0; - size_t thevalsize = -1; + size_t thevalsize = ((size_t)0)-1; int found =TbtreeLookup(xid, rid, NULL, &key, sizeof(key), (byte**)&theval, &thevalsize); assert(found); assert(thevalsize == sizeof(val)); @@ -79,7 +79,7 @@ START_TEST(bTreeTest) { i = 200 - j; } void * scratch; - size_t scratchsize=-1; + size_t scratchsize=((size_t)0)-1; assert(!TbtreeLookup(xid, rid, NULL, (byte*)&i, sizeof(i), (byte**)&scratch, &scratchsize)); TbtreeInsert(xid, rid, NULL, (byte*)&i, sizeof(i), (byte*)&i, sizeof(i)); assert(TbtreeLookup(xid, rid, NULL, (byte*)&i, sizeof(i), (byte**)&scratch, &scratchsize)); diff --git a/test/stasis/check_compensations.c b/test/stasis/check_compensations.c index 7b79c47..cb650a0 100644 --- a/test/stasis/check_compensations.c +++ b/test/stasis/check_compensations.c @@ -73,7 +73,6 @@ void nested(int * i) { (*i)++; compensation_set_error(1); break; - assert(0); } end_action; assert(0); } diff --git a/test/stasis/check_operations.c b/test/stasis/check_operations.c index ebacaf2..078cec0 100644 --- a/test/stasis/check_operations.c +++ b/test/stasis/check_operations.c @@ -188,7 +188,7 @@ START_TEST(operation_physical_do_undo) { Tcommit(xid); Tdeinit(); return; - +#if 0 setToTwo->LSN = 10; p = loadPage(xid, rid.page); @@ -224,6 +224,7 @@ START_TEST(operation_physical_do_undo) { unlock(p->rwlatch); releasePage(p); Tdeinit(); +#endif // 0 } END_TEST