initial opensolaris port

This commit is contained in:
Sears Russell 2009-11-29 03:22:36 +00:00
parent 1d7e60dbd0
commit 2ff421bff0
19 changed files with 73 additions and 17 deletions

View file

@ -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 <sys/types.h>
#include <sys/stat.h>
@ -71,6 +72,9 @@ int main(int argc, char * argv[]) {
}
" HAVE_O_DIRECT)
CHECK_C_SOURCE_COMPILES("#include <alloca.h>
int main(int argc, char * argv[]) { alloca(1); }" HAVE_ALLOCA_H)
CHECK_C_SOURCE_COMPILES("#define _GNU_SOURCE
#include <stdio.h>
@ -86,6 +90,16 @@ int main(int argc, char* argv[]) {
}
" HAVE_GCC_ATOMICS)
CHECK_C_SOURCE_COMPILES("
#include <pthread.h>
#include <limits.h>
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/

View file

@ -1,3 +1,4 @@
#include <config.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

View file

@ -1,3 +1,4 @@
#include <config.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

View file

@ -1,3 +1,4 @@
#include <config.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

View file

@ -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

View file

@ -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

View file

@ -1,3 +1,10 @@
#include <config.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <stasis/transactional.h>
#include <stasis/bufferManager.h>

View file

@ -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) {

View file

@ -4,7 +4,7 @@
* Created on: Oct 15, 2009
* Author: sears
*/
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#include <config.h>
#include <stasis/concurrentHash.h>
#include <assert.h>

View file

@ -1,3 +1,10 @@
#include <config.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <stdlib.h>
#include <stasis/bufferManager.h>
#include <stasis/graph.h>
#include <stasis/page.h>

View file

@ -1,3 +1,5 @@
#define _POSIX_C_SOURCE 200112L /* for flockfile() */
#include <stdio.h>
#include <stasis/logger/logWriterUtils.h>
/** @file

View file

@ -1,3 +1,4 @@
#include <config.h>
#define __USE_GNU
#define _GNU_SOURCE
#include <stasis/latches.h>

View file

@ -1,3 +1,10 @@
#include <config.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <stdlib.h>
#include <stasis/page.h>
#include <stasis/page/slotted.h>
//#include <assert.h>

View file

@ -12,15 +12,18 @@
#include <stdio.h>
#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<const void*,MyCompare> rb;
@ -28,7 +31,7 @@ typedef std::set<const void*,MyCompare> rb;
extern "C" {
rbtree * stl_rbinit(int(*cmp)(const void*,const void*,const void*), int ignored) {
return reinterpret_cast<rbtree*>(new rb(MyCompare(cmp)));
return reinterpret_cast<rbtree*>(new rb(MyCompare(cmp, 0)));
}
const void * stl_rbdelete(const void * key, rbtree * tp) {
rb::iterator it = reinterpret_cast<rb*>(tp)->find(key);

View file

@ -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;

View file

@ -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.

View file

@ -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));

View file

@ -73,7 +73,6 @@ void nested(int * i) {
(*i)++;
compensation_set_error(1);
break;
assert(0);
} end_action;
assert(0);
}

View file

@ -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