Commit e50cfa10 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1519 poison off_t in windows

git-svn-id: file:///svn/toku/tokudb@9783 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2af452ea
...@@ -376,7 +376,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un ...@@ -376,7 +376,7 @@ int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__un
printf("int toku_close_trace_file (void) %s;\n", VISIBLE); printf("int toku_close_trace_file (void) %s;\n", VISIBLE);
printf("int db_env_set_func_free (void (*)(void*)) %s;\n", VISIBLE); printf("int db_env_set_func_free (void (*)(void*)) %s;\n", VISIBLE);
printf("int db_env_set_func_malloc (void *(*)(size_t)) %s;\n", VISIBLE); printf("int db_env_set_func_malloc (void *(*)(size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, off_t)) %s;\n", VISIBLE); printf("int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE); printf("int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) %s;\n", VISIBLE);
printf("int db_env_set_func_realloc (void *(*)(void*, size_t)) %s;\n", VISIBLE); printf("int db_env_set_func_realloc (void *(*)(void*, size_t)) %s;\n", VISIBLE);
printf("#if defined(__cplusplus)\n}\n#endif\n"); printf("#if defined(__cplusplus)\n}\n#endif\n");
......
...@@ -325,7 +325,7 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default"))) ...@@ -325,7 +325,7 @@ int toku_set_trace_file (char *fname) __attribute__((__visibility__("default")))
int toku_close_trace_file (void) __attribute__((__visibility__("default"))); int toku_close_trace_file (void) __attribute__((__visibility__("default")));
int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default"))); int db_env_set_func_free (void (*)(void*)) __attribute__((__visibility__("default")));
int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_malloc (void *(*)(size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, off_t)) __attribute__((__visibility__("default"))); int db_env_set_func_pwrite (ssize_t (*)(int, const void *, size_t, toku_off_t)) __attribute__((__visibility__("default")));
int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_write (ssize_t (*)(int, const void *, size_t)) __attribute__((__visibility__("default")));
int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default"))); int db_env_set_func_realloc (void *(*)(void*, size_t)) __attribute__((__visibility__("default")));
#if defined(__cplusplus) #if defined(__cplusplus)
......
...@@ -20,7 +20,6 @@ typedef unsigned int ITEMLEN; ...@@ -20,7 +20,6 @@ typedef unsigned int ITEMLEN;
typedef const void *bytevec; typedef const void *bytevec;
//typedef const void *bytevec; //typedef const void *bytevec;
typedef int64_t toku_off_t;
typedef int64_t DISKOFF; /* Offset in a disk. -1 is the NULL pointer. */ typedef int64_t DISKOFF; /* Offset in a disk. -1 is the NULL pointer. */
typedef u_int64_t TXNID; typedef u_int64_t TXNID;
typedef struct s_blocknum { int64_t b; } BLOCKNUM; // make a struct so that we will notice type problems. typedef struct s_blocknum { int64_t b; } BLOCKNUM; // make a struct so that we will notice type problems.
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "toku_portability.h" #include "toku_portability.h"
off_t fd_size (int fd) { toku_off_t fd_size (int fd) {
int64_t file_size; int64_t file_size;
int r = toku_os_get_file_size(fd, &file_size); int r = toku_os_get_file_size(fd, &file_size);
assert(r==0); assert(r==0);
...@@ -25,9 +25,9 @@ unsigned char fbuf[NSIZE]; ...@@ -25,9 +25,9 @@ unsigned char fbuf[NSIZE];
unsigned char cbuf[NSIZE+500]; unsigned char cbuf[NSIZE+500];
void void
measure_header (int fd, off_t off, // read header from this offset measure_header (int fd, toku_off_t off, // read header from this offset
off_t *usize, // size uncompressed (but not including any padding) toku_off_t *usize, // size uncompressed (but not including any padding)
off_t *csize) // compressed size toku_off_t *csize) // compressed size
{ {
int r; int r;
r=pread(fd, fbuf, 12, off); r=pread(fd, fbuf, 12, off);
...@@ -50,9 +50,9 @@ measure_header (int fd, off_t off, // read header from this offset ...@@ -50,9 +50,9 @@ measure_header (int fd, off_t off, // read header from this offset
} }
void void
measure_node (int fd, off_t off, // read header from this offset measure_node (int fd, toku_off_t off, // read header from this offset
off_t *usize, // size uncompressed (but not including any padding) toku_off_t *usize, // size uncompressed (but not including any padding)
off_t *csize) // compressed size toku_off_t *csize) // compressed size
{ {
int r; int r;
r=pread(fd, fbuf, 24, off); r=pread(fd, fbuf, 24, off);
...@@ -86,13 +86,13 @@ int main (int argc, const char *argv[]) { ...@@ -86,13 +86,13 @@ int main (int argc, const char *argv[]) {
const char *fname=argv[1]; const char *fname=argv[1];
int fd = open(fname, O_RDONLY); int fd = open(fname, O_RDONLY);
assert(fd>=0); assert(fd>=0);
off_t fsize = fd_size(fd); toku_off_t fsize = fd_size(fd);
printf("fsize (uncompressed with padding)=%lld\n", (long long)fsize); printf("fsize (uncompressed with padding)=%lld\n", (long long)fsize);
off_t usize=0, csize=0; toku_off_t usize=0, csize=0;
measure_header(fd, 0, &usize, &csize); measure_header(fd, 0, &usize, &csize);
off_t i; toku_off_t i;
for (i=NSIZE; i+24<fsize; i+=NSIZE) { for (i=NSIZE; i+24<fsize; i+=NSIZE) {
measure_node(fd, i, &usize, &csize); measure_node(fd, i, &usize, &csize);
} }
......
...@@ -136,7 +136,7 @@ static int write_count = 0; ...@@ -136,7 +136,7 @@ static int write_count = 0;
static int fail_at = FAIL_NEVER; static int fail_at = FAIL_NEVER;
static ssize_t static ssize_t
pwrite_counting_and_failing (int fd, const void *buf, size_t size, off_t off) pwrite_counting_and_failing (int fd, const void *buf, size_t size, toku_off_t off)
{ {
write_count++; write_count++;
if (write_count>fail_at) { if (write_count>fail_at) {
......
...@@ -3686,7 +3686,7 @@ int db_env_set_func_fsync (int (*fsync_function)(int)) { ...@@ -3686,7 +3686,7 @@ int db_env_set_func_fsync (int (*fsync_function)(int)) {
return toku_set_func_fsync(fsync_function); return toku_set_func_fsync(fsync_function);
} }
int db_env_set_func_pwrite (ssize_t (*pwrite_function)(int, const void *, size_t, off_t)) { int db_env_set_func_pwrite (ssize_t (*pwrite_function)(int, const void *, size_t, toku_off_t)) {
return toku_set_func_pwrite(pwrite_function); return toku_set_func_pwrite(pwrite_function);
} }
int db_env_set_func_write (ssize_t (*write_function)(int, const void *, size_t)) { int db_env_set_func_write (ssize_t (*write_function)(int, const void *, size_t)) {
......
...@@ -67,12 +67,15 @@ extern "C" { ...@@ -67,12 +67,15 @@ extern "C" {
#include "toku_os.h" #include "toku_os.h"
#include "toku_htonl.h" #include "toku_htonl.h"
typedef int64_t toku_off_t;
#define UU(x) x __attribute__((__unused__)) #define UU(x) x __attribute__((__unused__))
// Deprecated functions. // Deprecated functions.
#if !defined(TOKU_ALLOW_DEPRECATED) #if !defined(TOKU_ALLOW_DEPRECATED)
# if defined(__ICL) //Windows Intel Compiler # if defined(__ICL) //Windows Intel Compiler
# pragma deprecated (creat, fstat, getpid, syscall, sysconf, mkdir, strdup) # pragma deprecated (creat, fstat, getpid, syscall, sysconf, mkdir, strdup)
# pragma poison off_t
# ifndef DONT_DEPRECATE_MALLOC # ifndef DONT_DEPRECATE_MALLOC
# pragma deprecated (malloc, free, realloc) # pragma deprecated (malloc, free, realloc)
# endif # endif
...@@ -100,14 +103,14 @@ void *realloc(void*, size_t) __attribute__((__deprecated__)); ...@@ -100,14 +103,14 @@ void *realloc(void*, size_t) __attribute__((__deprecated__));
void *os_malloc(size_t); void *os_malloc(size_t);
void *os_realloc(void*,size_t); void *os_realloc(void*,size_t);
void os_free(void*); void os_free(void*);
ssize_t toku_os_pwrite (int fd, const void *buf, size_t len, off_t off); ssize_t toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off);
ssize_t toku_os_write (int fd, const void *buf, size_t len); ssize_t toku_os_write (int fd, const void *buf, size_t len);
int toku_set_func_fsync (int (*fsync_function)(int)); int toku_set_func_fsync (int (*fsync_function)(int));
int toku_set_func_malloc (void *(*)(size_t)); int toku_set_func_malloc (void *(*)(size_t));
int toku_set_func_realloc (void *(*)(void*,size_t)); int toku_set_func_realloc (void *(*)(void*,size_t));
int toku_set_func_free (void (*)(void*)); int toku_set_func_free (void (*)(void*));
int toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, off_t)); int toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, toku_off_t));
int toku_set_func_write (ssize_t (*pwrite_fun)(int, const void *, size_t)); int toku_set_func_write (ssize_t (*pwrite_fun)(int, const void *, size_t));
#if defined __cplusplus #if defined __cplusplus
......
...@@ -73,10 +73,10 @@ ftruncate(int fd, int64_t offset) { ...@@ -73,10 +73,10 @@ ftruncate(int fd, int64_t offset) {
return r; return r;
} }
static ssize_t (*t_pwrite)(int, const void *, size_t, off_t) = 0; static ssize_t (*t_pwrite)(int, const void *, size_t, toku_off_t) = 0;
static ssize_t (*t_write)(int, const void *, size_t) = 0; static ssize_t (*t_write)(int, const void *, size_t) = 0;
int toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, off_t)) { int toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, toku_off_t)) {
t_pwrite = pwrite_fun; t_pwrite = pwrite_fun;
return 0; return 0;
} }
...@@ -89,7 +89,7 @@ int toku_set_func_write (ssize_t (*write_fun)(int, const void *, size_t)) { ...@@ -89,7 +89,7 @@ int toku_set_func_write (ssize_t (*write_fun)(int, const void *, size_t)) {
ssize_t ssize_t
toku_os_pwrite (int fd, const void *buf, size_t len, off_t off) toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off)
{ {
if (t_pwrite) { if (t_pwrite) {
return t_pwrite(fd, buf, len, off); return t_pwrite(fd, buf, len, off);
......
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