Commit 20e34196 authored by John Esmet's avatar John Esmet

fixes #200 Remove windows logic, which has not been supported in years.

parent 0a747782
......@@ -97,10 +97,6 @@ PATENT RIGHTS GRANT:
// If the fifo_entry is unpacked, the compiler aligns the xids array and we waste a lot of space
#if TOKU_WINDOWS
#pragma pack(push, 1)
#endif
struct __attribute__((__packed__)) fifo_entry {
unsigned int keylen;
unsigned int vallen;
......@@ -128,10 +124,6 @@ fifo_entry_set_msg_type(struct fifo_entry * entry,
entry->type = type;
}
#if TOKU_WINDOWS
#pragma pack(pop)
#endif
typedef struct fifo *FIFO;
int toku_fifo_create(FIFO *);
......
......@@ -91,9 +91,7 @@ PATENT RIGHTS GRANT:
#include <toku_portability.h>
#if !TOKU_WINDOWS
#include <arpa/inet.h>
#endif
#include <stdio.h>
#include <memory.h>
......
......@@ -167,11 +167,8 @@ static int lc_open_logfile(TOKULOGCURSOR lc, int index) {
lc->cur_fp = fopen(lc->logfiles[index], "rb");
if ( lc->cur_fp == NULL )
return DB_NOTFOUND;
// debug printf("%s:%d %s %p %u\n", __FUNCTION__, __LINE__, lc->logfiles[index], lc->buffer, (unsigned) lc->buffer_size);
#if !TOKU_WINDOWS //Windows reads logs fastest if we use default settings (not use setvbuf to change buffering)
r = setvbuf(lc->cur_fp, (char *) lc->buffer, _IOFBF, lc->buffer_size);
assert(r == 0);
#endif
// position fp past header, ignore 0 length file (t:2384)
unsigned int version=0;
if ( lc_file_len(lc->logfiles[index]) >= 12 ) {
......
......@@ -108,13 +108,9 @@ static volatile int n_flush, n_write_me, n_keep_me, n_fetch;
static void
sleep_random (void)
{
#if TOKU_WINDOWS
usleep(random() % 1000); //Will turn out to be almost always 1ms.
#else
toku_timespec_t req = {.tv_sec = 0,
.tv_nsec = random()%1000000}; //Max just under 1ms
nanosleep(&req, NULL);
#endif
}
int expect_value = 42; // initially 42, later 43
......
......@@ -241,8 +241,6 @@ PAIR_ATTR *sizep __attribute__((__unused__)), int * dirtyp, void*extraargs) {
return 0;
}
#if !TOKU_WINDOWS
static void test_multi_filehandles (void) {
CACHETABLE t;
CACHEFILE f1,f2,f3;
......@@ -291,8 +289,6 @@ static void test_multi_filehandles (void) {
toku_cachetable_close(&t);
}
#endif
static void test_dirty_flush(CACHEFILE f,
int UU(fd),
CACHEKEY key,
......@@ -587,15 +583,11 @@ test_main (int argc, const char *argv[]) {
test_mutex_init();
// run tests
#if !TOKU_WINDOWS
test_multi_filehandles();
#endif
test_cachetable_create();
for (i=0; i<1; i++) {
test_nested_pin();
#if !TOKU_WINDOWS
test_multi_filehandles ();
#endif
test_dirty();
test_size_resize();
//test_size_flush();
......
......@@ -115,8 +115,8 @@ __attribute__((__noreturn__))
never_run (void *a) {
assert(a==0);
assert(0);
#if TOKU_WINDOWS || defined(GCOV)
return 0; //ICC ignores the noreturn attribute.
#if defined(GCOV)
return 0;
#endif
}
......
......@@ -2261,9 +2261,6 @@ verify_is_empty:;
return r;
}
#if TOKU_WINDOWS
#pragma pack(push, 1)
#endif
// This is an on-disk format. static_asserts verify everything is packed and aligned correctly.
struct __attribute__ ((__packed__)) leafentry_13 {
struct leafentry_committed_13 {
......@@ -2291,9 +2288,6 @@ struct __attribute__ ((__packed__)) leafentry_13 {
};
static_assert(18 == sizeof(leafentry_13), "wrong size");
static_assert(9 == __builtin_offsetof(leafentry_13, u), "wrong offset");
#if TOKU_WINDOWS
#pragma pack(pop)
#endif
//Requires:
// Leafentry that ule represents should not be destroyed (is not just all deletes)
......
......@@ -93,26 +93,16 @@ PATENT RIGHTS GRANT:
#ident "Copyright (c) 2007-2013 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
// Variable size list of transaction ids (known in design doc as xids<>).
// ids[0] is the outermost transaction.
// ids[num_xids - 1] is the innermost transaction.
// Should only be accessed by accessor functions xids_xxx, not directly.
// If the xids struct is unpacked, the compiler aligns the ids[] and we waste a lot of space
#if TOKU_WINDOWS
#pragma pack(push, 1)
#endif
typedef struct __attribute__((__packed__)) xids_t {
uint8_t num_xids; // maximum value of MAX_TRANSACTION_RECORDS - 1 ...
// ... because transaction 0 is implicit
TXNID ids[];
} XIDS_S;
#if TOKU_WINDOWS
#pragma pack(pop)
#endif
#endif
......@@ -221,7 +221,6 @@ time_fsyncs_many_files(int N, int bytes, int fds[/*N*/]) {
}
}
#if !TOKU_WINDOWS
//sync() does not appear to have an analogue on windows.
static void
time_sync_fsyncs_many_files(int N, int bytes, int fds[/*N*/]) {
......@@ -277,7 +276,6 @@ time_sync_fsyncs_many_files(int N, int bytes, int fds[/*N*/]) {
fflush(stdout);
}
}
#endif
int test_main(int argc, char *const argv[]) {
int i;
......@@ -320,9 +318,7 @@ int test_main(int argc, char *const argv[]) {
time_many_fsyncs_one_file(N, bytes, fds);
time_fsyncs_many_files(N, bytes, fds);
#if !TOKU_WINDOWS
time_sync_fsyncs_many_files(N, bytes, fds);
#endif
return 0;
}
......@@ -101,16 +101,11 @@ PATENT RIGHTS GRANT:
# include <sys/malloc.h>
#endif
#include <dlfcn.h>
#if !TOKU_WINDOWS
#include <execinfo.h>
#endif
#if !TOKU_WINDOWS
#define N_POINTERS 1000
// These are statically allocated so that the backtrace can run without any calls to malloc()
#define N_POINTERS 1000
static void *backtrace_pointers[N_POINTERS];
#endif
static uint64_t engine_status_num_rows = 0;
......@@ -141,11 +136,9 @@ void (*do_assert_hook)(void) = NULL;
extern "C" void db_env_do_backtrace(void) __attribute__((__visibility__("default"))); // also declared in db.h for consumers of that API
extern "C" void db_env_do_backtrace(void) {
// backtrace
#if !TOKU_WINDOWS
int n = backtrace(backtrace_pointers, N_POINTERS);
fprintf(stderr, "Backtrace: (Note: toku_do_assert=0x%p)\n", toku_do_assert); fflush(stderr);
backtrace_symbols_fd(backtrace_pointers, n, fileno(stderr));
#endif
fflush(stderr);
......@@ -173,23 +166,6 @@ extern "C" void db_env_do_backtrace(void) {
__attribute__((noreturn))
static void toku_do_backtrace_abort(void) {
db_env_do_backtrace();
#if TOKU_WINDOWS
//Following commented methods will not always end the process (could hang).
//They could be unacceptable for other reasons as well (popups,
//flush buffers before quitting, etc)
// abort()
// assert(false) (assert.h assert)
// raise(SIGABRT)
// divide by 0
// null dereference
// _exit
// exit
// ExitProcess
TerminateProcess(GetCurrentProcess(), 134); //Only way found so far to unconditionally
//Terminate the process
#endif
abort();
}
......
......@@ -134,14 +134,14 @@ void toku_do_assert_expected_fail(uintptr_t/*expr*/, uintptr_t /*expected*/, con
extern void (*do_assert_hook)(void); // Set this to a function you want called after printing the assertion failure message but before calling abort(). By default this is NULL.
#if defined(GCOV) || TOKU_WINDOWS
#ifdef assert
# undef assert
#endif
#if defined(GCOV)
#define assert(expr) toku_do_assert((expr) != 0, #expr, __FUNCTION__, __FILE__, __LINE__, get_maybe_error_errno())
#define assert_zero(expr) toku_do_assert((expr) == 0, #expr, __FUNCTION__, __FILE__, __LINE__, get_maybe_error_errno())
#define assert_equals(expr, expected) toku_do_assert((expr) == (expected), (expected), #expr, __FUNCTION__, __FILE__, __LINE__, get_maybe_error_errno())
#else
#ifdef assert
# undef assert // some compilers do not like multiple definitions of a single macro - so undef the existing assert def here
#endif
#define assert(expr) ((expr) ? (void)0 : toku_do_assert_fail(#expr, __FUNCTION__, __FILE__, __LINE__, get_maybe_error_errno()))
#define assert_zero(expr) ((expr) == 0 ? (void)0 : toku_do_assert_zero_fail((uintptr_t)(expr), #expr, __FUNCTION__, __FILE__, __LINE__, get_maybe_error_errno()))
#define assert_equals(expr, expected) ((expr) == (expected) ? (void)0 : toku_do_assert_expected_fail((uintptr_t)(expr), (uintptr_t)(expected), #expr, __FUNCTION__, __FILE__, __LINE__, get_maybe_error_errno()))
......
......@@ -108,9 +108,6 @@ PATENT RIGHTS GRANT:
//
//Linux:
// abort() and both assert(false) cause FILE buffers to be flushed and written to disk: Unacceptable
//Windows:
// None of them cause file buffers to be flushed/written to disk, however
// abort(), assert(false) <assert.h>, null dereference, and divide by 0 cause popups requiring user intervention during tests: Unacceptable
//
//kill -SIGKILL $pid is annoying (and so far untested)
//
......@@ -118,11 +115,7 @@ PATENT RIGHTS GRANT:
//I'm choosing raise(SIGABRT), followed by divide by 0, followed by null dereference, followed by all the others just in case one gets caught.
static void __attribute__((unused, noreturn))
toku_hard_crash_on_purpose(void) {
#if TOKU_WINDOWS
TerminateProcess(GetCurrentProcess(), 137);
#else
raise(SIGKILL); //Does not flush buffers on linux; cannot be caught.
#endif
{
int zero = 0;
int infinity = 1/zero;
......
......@@ -172,13 +172,6 @@ int toku_fsync_dir_by_name_without_accounting(const char *dir_name);
// Return 0 on success, otherwise an error number
int toku_get_filesystem_sizes(const char *path, uint64_t *avail_size, uint64_t *free_size, uint64_t *total_size);
#if TOKU_WINDOWS
#include <sys/types.h>
#include <sys/stat.h>
//Test if st_mode (from stat) is a directory
#define S_ISDIR(bitvector) (((bitvector)&_S_IFDIR)!=0)
#endif
// Portable linux 'stat'
int toku_stat(const char *name, toku_struct_stat *statbuf) __attribute__((__visibility__("default")));
// Portable linux 'fstat'
......
......@@ -125,10 +125,8 @@ static inline bool toku_fileids_are_equal(struct fileid *a, struct fileid *b) {
typedef struct stat toku_struct_stat;
// windows compat
#if !defined(O_BINARY)
#define O_BINARY 0
#endif
#endif
......@@ -101,82 +101,21 @@ PATENT RIGHTS GRANT:
# define constexpr_static_assert(a, b) static_assert(a, b)
#endif
#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(__ICL))
#define TOKU_WINDOWS 1
#define DEV_NULL_FILE "NUL"
# if defined(_WIN64)
# define TOKU_WINDOWS_32 0
# define TOKU_WINDOWS_64 1
# else
# define TOKU_WINDOWS_32 1
# define TOKU_WINDOWS_64 2
#if defined(_MSC_VER)
# error "Windows is not supported."
#endif
#else
#define TOKU_WINDOWS 0
#define TOKU_WINDOWS_32 0
#define TOKU_WINDOWS_64 0
#define DEV_NULL_FILE "/dev/null"
#endif
// HACK Poison these mcaros so no one uses them
#define TOKU_WINDOWS ,
#define TOKU_WINDOWS_32 ,
#define TOKU_WINDOWS_64 ,
// include here, before they get deprecated
#include <toku_atomic.h>
#if TOKU_WINDOWS
// Windows
#define DO_GCC_PRAGMA(x) /* Nothing */
#if defined(__ICL)
#define __attribute__(x) /* Nothing */
#endif
#include <malloc.h>
#include "toku_stdint.h"
#ifndef TOKU_OFF_T_DEFINED
#define TOKU_OFF_T_DEFINED
typedef int64_t toku_off_t;
#endif
#include <direct.h>
#include <sys/types.h>
#include "unistd.h"
#include "misc.h"
#include "toku_pthread.h"
#define UNUSED_WARNING(a) a=a /* To make up for missing attributes */
#define cast_to_typeof(v)
#elif defined(__INTEL_COMPILER)
#define DO_GCC_PRAGMA(x) /* Nothing */
#if defined(__ICC)
// Intel linux
#include <alloca.h>
#include <toku_stdint.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#define static_assert(foo, bar)
#endif
#if defined(__cplusplus)
# define cast_to_typeof(v) (decltype(v))
#else
# define cast_to_typeof(v) (__typeof__(v))
#endif
#elif defined(__GNUC__)
#if defined(__GNUC__)
// GCC linux
#define DO_GCC_PRAGMA(x) _Pragma (#x)
......@@ -187,12 +126,15 @@ typedef int64_t toku_off_t;
#include <sys/time.h>
#include <sys/stat.h>
#include <stdio.h>
#if __FreeBSD__
#include <stdarg.h>
#endif
#if defined(HAVE_ALLOCA_H)
# include <alloca.h>
#endif
#if defined(__cplusplus)
# include <type_traits>
#endif
......@@ -203,10 +145,8 @@ typedef int64_t toku_off_t;
# define cast_to_typeof(v) (__typeof__(v))
#endif
#else
#error Not ICC and not GNUC. What compiler?
#else // __GNUC__ was not defined, so...
# error "Must use a GNUC-compatible compiler."
#endif
// Define some constants for Yama in case the build-machine's software is too old.
......@@ -265,10 +205,8 @@ extern "C" {
# ifndef DONT_DEPRECATE_ERRNO
# pragma deprecated (errno)
# endif
# ifndef TOKU_WINDOWS_ALLOW_DEPRECATED
# pragma poison dup2
# pragma poison _dup2
# endif
# pragma poison dup2
# pragma poison _dup2
# else
int creat(const char *pathname, mode_t mode) __attribute__((__deprecated__));
int fstat(int fd, struct stat *buf) __attribute__((__deprecated__));
......@@ -279,8 +217,7 @@ int syscall(int __sysno, ...) __attribute__((__deprecated__));
# else
long int syscall(long int __sysno, ...) __attribute__((__deprecated__));
# endif
// Sadly, dlmalloc needs sysconf, and on linux this causes trouble with -combine. So let the warnings show up under windows only.
// long int sysconf(int) __attribute__((__deprecated__));
long int sysconf(int) __attribute__((__deprecated__));
int mkdir(const char *pathname, mode_t mode) __attribute__((__deprecated__));
int dup2(int fd, int fd2) __attribute__((__deprecated__));
int _dup2(int fd, int fd2) __attribute__((__deprecated__));
......
......@@ -275,7 +275,7 @@ random_acts(void * d) {
return intothevoid;
}
uint64_t max_windows_cachesize = 256 << 20;
uint64_t max_cachesize = 256 << 20;
static void
run_test (int iter, int die) {
......@@ -293,7 +293,7 @@ run_test (int iter, int die) {
const int32_t K256 = 256 * 1024;
uint64_t cachebytes = 0;
cachebytes = K256 * (iter + 1) - (128 * 1024);
if (cachebytes > max_windows_cachesize)
if (cachebytes > max_cachesize)
cachebytes = 0;
if (iter & 2) cachebytes = 0; // use default cachesize half the time
......
......@@ -95,7 +95,7 @@ PATENT RIGHTS GRANT:
#include "checkpoint_test.h"
static const uint64_t max_windows_cachesize = 256 << 20;
static const uint64_t max_cachesize = 256 << 20;
static const int NUM_DICTIONARIES = 1;
static const int OPER_STEPS = 6;
......@@ -495,7 +495,7 @@ static void run_test (int iter) {
uint64_t cachebytes = 0; // 0 => use default size
const int32_t K256 = 256 * 1024;
cachebytes = K256 * (iter + 1) - (128 * 1024);
if (cachebytes > max_windows_cachesize)
if (cachebytes > max_cachesize)
cachebytes = 0;
if (iter & 2) cachebytes = 0; // use default cachesize half the time
......
......@@ -109,37 +109,4 @@ static void __attribute__((destructor)) libtokudb_destroy(void) {
toku_ydb_destroy();
}
#endif
#if TOKU_WINDOWS
#include <windows.h>
#define UNUSED(x) x=x
bool WINAPI DllMain(HINSTANCE h, DWORD reason, LPVOID reserved) {
UNUSED(h); UNUSED(reserved);
// printf("%s:%lu\n", __FUNCTION__, reason);
int r = 0;
switch(reason) {
case DLL_PROCESS_ATTACH:
r = toku_ydb_init();
break;
case DLL_PROCESS_DETACH:
toku_ydb_destroy();
break;
case DLL_THREAD_ATTACH:
//TODO: Any new thread code if necessary, i.e. allocate per-thread
// storage.
break;
case DLL_THREAD_DETACH:
//TODO: Any cleanup thread code if necessary, i.e. free per-thread
// storage.
break;
default:
break;
}
assert(r==0);
return true;
}
#endif
#endif // __GNUC__
......@@ -255,11 +255,6 @@ static int test_main (int argc, char *const argv[]) {
}
sort_delimiter[0] = (char)temp;
sort_delimiter[1] = '\0';
#if TOKU_WINDOWS
if (!strcmp(sort_delimiter, "\n")) {
strcpy(sort_delimiter, "\r\n");
}
#endif
break;
}
case ('V'): {
......
......@@ -195,30 +195,12 @@ void toku_memarena_destroy(MEMARENA *map) {
*map = 0;
}
#if TOKU_WINDOWS_32
#include <windows.h>
#include <crtdbg.h>
#endif
void toku_memarena_move_buffers(MEMARENA dest, MEMARENA source) {
int i;
char **other_bufs = dest->other_bufs;
static int move_counter = 0;
move_counter++;
REALLOC_N(dest->n_other_bufs + source->n_other_bufs + 1, other_bufs);
#if TOKU_WINDOWS_32
if (other_bufs == 0) {
char **new_other_bufs;
printf("_CrtCheckMemory:%d\n", _CrtCheckMemory());
printf("Z: move_counter:%d dest:%p %p %d source:%p %p %d errno:%d\n",
move_counter,
dest, dest->other_bufs, dest->n_other_bufs,
source, source->other_bufs, source->n_other_bufs,
errno);
new_other_bufs = toku_malloc((dest->n_other_bufs + source->n_other_bufs + 1)*sizeof (char **));
printf("new_other_bufs=%p errno=%d\n", new_other_bufs, errno);
}
#endif
dest ->size_of_other_bufs += source->size_of_other_bufs + source->buf_size;
dest ->footprint_of_other_bufs += source->footprint_of_other_bufs + toku_memory_footprint(source->buf, source->buf_used);
......
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