mirror of
https://github.com/MariaDB/server.git
synced 2025-12-01 17:39:21 +03:00
imp toku_os_ closes #1253
git-svn-id: file:///svn/toku/tokudb.1032b@7837 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
committed by
Yoni Fogel
parent
6258817caf
commit
6ebe124875
@@ -107,7 +107,7 @@ OPT_ARFLAGS=r
|
|||||||
LINK=-l
|
LINK=-l
|
||||||
DEPEND_COMPILE += \
|
DEPEND_COMPILE += \
|
||||||
$(TOKUROOT)include/db.h \
|
$(TOKUROOT)include/db.h \
|
||||||
$(TOKUROOT)include/os.h \
|
$(TOKUROOT)include/toku_os.h \
|
||||||
$(TOKUROOT)include/portability.h \
|
$(TOKUROOT)include/portability.h \
|
||||||
$(TOKUROOT)include/rdtsc.h \
|
$(TOKUROOT)include/rdtsc.h \
|
||||||
# keep this line so I can have a \ on the previous line
|
# keep this line so I can have a \ on the previous line
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ extern "C" {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
#include "toku_htonl.h"
|
#include "toku_htonl.h"
|
||||||
|
|
||||||
#define UU(x) x __attribute__((__unused__))
|
#define UU(x) x __attribute__((__unused__))
|
||||||
|
|||||||
@@ -5,53 +5,53 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os-types.h"
|
#include "toku_os_types.h"
|
||||||
|
|
||||||
// Returns: the current process id
|
// Returns: the current process id
|
||||||
int os_getpid(void);
|
int toku_os_getpid(void);
|
||||||
|
|
||||||
// Returns: the current thread id
|
// Returns: the current thread id
|
||||||
int os_gettid(void);
|
int toku_os_gettid(void);
|
||||||
|
|
||||||
// Returns: the number of processors in the system
|
// Returns: the number of processors in the system
|
||||||
int os_get_number_processors(void);
|
int toku_os_get_number_processors(void);
|
||||||
|
|
||||||
// Returns: the number of active processors in the system
|
// Returns: the number of active processors in the system
|
||||||
int os_get_number_active_processors(void);
|
int toku_os_get_number_active_processors(void);
|
||||||
|
|
||||||
// Returns: the system page size
|
// Returns: the system page size
|
||||||
int os_get_pagesize(void);
|
int toku_os_get_pagesize(void);
|
||||||
|
|
||||||
// Returns: the total number of bytes of physical memory
|
// Returns: the total number of bytes of physical memory
|
||||||
uint64_t os_get_phys_memory_size(void);
|
uint64_t toku_os_get_phys_memory_size(void);
|
||||||
|
|
||||||
// Returns: 0 on success
|
// Returns: 0 on success
|
||||||
// sets fsize to the number of bytes in a file
|
// sets fsize to the number of bytes in a file
|
||||||
int os_get_file_size(int fildes, int64_t *fsize);
|
int toku_os_get_file_size(int fildes, int64_t *fsize);
|
||||||
|
|
||||||
// Returns: 0 on success
|
// Returns: 0 on success
|
||||||
// Initializes id as a unique fileid for fildes on success.
|
// Initializes id as a unique fileid for fildes on success.
|
||||||
int os_get_unique_file_id(int fildes, struct fileid *id);
|
int toku_os_get_unique_file_id(int fildes, struct fileid *id);
|
||||||
|
|
||||||
//Locks a file (should not be open to begin with).
|
//Locks a file (should not be open to begin with).
|
||||||
//Returns: file descriptor (or -1 on error)
|
//Returns: file descriptor (or -1 on error)
|
||||||
int os_lock_file(char *name);
|
int toku_os_lock_file(char *name);
|
||||||
|
|
||||||
//Unlocks and closes a file locked by os_lock_on_file
|
//Unlocks and closes a file locked by toku_os_lock_on_file
|
||||||
int os_unlock_file(int fildes);
|
int toku_os_unlock_file(int fildes);
|
||||||
|
|
||||||
int os_mkdir(const char *pathname, mode_t mode);
|
int toku_os_mkdir(const char *pathname, mode_t mode);
|
||||||
|
|
||||||
// Get the current process user and kernel use times
|
// Get the current process user and kernel use times
|
||||||
int os_get_process_times(struct timeval *usertime, struct timeval *kerneltime);
|
int toku_os_get_process_times(struct timeval *usertime, struct timeval *kerneltime);
|
||||||
|
|
||||||
// Get the current in memory size (in bytes) of the current process
|
// Get the current in memory size (in bytes) of the current process
|
||||||
int os_get_rss(int64_t *rss);
|
int toku_os_get_rss(int64_t *rss);
|
||||||
|
|
||||||
// Get the maximum in memory size (in bytes) of the current process
|
// Get the maximum in memory size (in bytes) of the current process
|
||||||
int os_get_max_rss(int64_t *maxrss);
|
int toku_os_get_max_rss(int64_t *maxrss);
|
||||||
|
|
||||||
int os_initialize_settings(int verbosity);
|
int toku_os_initialize_settings(int verbosity);
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
};
|
};
|
||||||
@@ -13,42 +13,42 @@
|
|||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
os_getpid(void) {
|
toku_os_getpid(void) {
|
||||||
return getpid();
|
return getpid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_gettid(void) {
|
toku_os_gettid(void) {
|
||||||
return syscall(__NR_gettid);
|
return syscall(__NR_gettid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_number_processors(void) {
|
toku_os_get_number_processors(void) {
|
||||||
return sysconf(_SC_NPROCESSORS_CONF);
|
return sysconf(_SC_NPROCESSORS_CONF);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_number_active_processors(void) {
|
toku_os_get_number_active_processors(void) {
|
||||||
return sysconf(_SC_NPROCESSORS_ONLN);
|
return sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_pagesize(void) {
|
toku_os_get_pagesize(void) {
|
||||||
return sysconf(_SC_PAGESIZE);
|
return sysconf(_SC_PAGESIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
os_get_phys_memory_size(void) {
|
toku_os_get_phys_memory_size(void) {
|
||||||
uint64_t npages = sysconf(_SC_PHYS_PAGES);
|
uint64_t npages = sysconf(_SC_PHYS_PAGES);
|
||||||
uint64_t pagesize = sysconf(_SC_PAGESIZE);
|
uint64_t pagesize = sysconf(_SC_PAGESIZE);
|
||||||
return npages*pagesize;
|
return npages*pagesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_file_size(int fildes, int64_t *fsize) {
|
toku_os_get_file_size(int fildes, int64_t *fsize) {
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
int r = fstat(fildes, &sbuf);
|
int r = fstat(fildes, &sbuf);
|
||||||
if (r==0) {
|
if (r==0) {
|
||||||
@@ -58,7 +58,7 @@ os_get_file_size(int fildes, int64_t *fsize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_unique_file_id(int fildes, struct fileid *id) {
|
toku_os_get_unique_file_id(int fildes, struct fileid *id) {
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
memset(id, 0, sizeof(*id));
|
memset(id, 0, sizeof(*id));
|
||||||
int r=fstat(fildes, &statbuf);
|
int r=fstat(fildes, &statbuf);
|
||||||
@@ -71,7 +71,7 @@ os_get_unique_file_id(int fildes, struct fileid *id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_lock_file(char *name) {
|
toku_os_lock_file(char *name) {
|
||||||
int r;
|
int r;
|
||||||
int fd = open(name, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR);
|
int fd = open(name, O_RDWR|O_CREAT, S_IRUSR | S_IWUSR);
|
||||||
if (fd>=0) {
|
if (fd>=0) {
|
||||||
@@ -87,20 +87,20 @@ os_lock_file(char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_unlock_file(int fildes) {
|
toku_os_unlock_file(int fildes) {
|
||||||
int r = flock(fildes, LOCK_UN);
|
int r = flock(fildes, LOCK_UN);
|
||||||
if (r==0) r = close(fildes);
|
if (r==0) r = close(fildes);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_mkdir(const char *pathname, mode_t mode) {
|
toku_os_mkdir(const char *pathname, mode_t mode) {
|
||||||
int r = mkdir(pathname, mode);
|
int r = mkdir(pathname, mode);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_process_times(struct timeval *usertime, struct timeval *kerneltime) {
|
toku_os_get_process_times(struct timeval *usertime, struct timeval *kerneltime) {
|
||||||
int r;
|
int r;
|
||||||
struct rusage rusage;
|
struct rusage rusage;
|
||||||
r = getrusage(RUSAGE_SELF, &rusage);
|
r = getrusage(RUSAGE_SELF, &rusage);
|
||||||
@@ -114,7 +114,7 @@ os_get_process_times(struct timeval *usertime, struct timeval *kerneltime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_initialize_settings(int UU(verbosity)) {
|
toku_os_initialize_settings(int UU(verbosity)) {
|
||||||
int r = 0;
|
int r = 0;
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
assert(initialized==0);
|
assert(initialized==0);
|
||||||
@@ -123,7 +123,7 @@ os_initialize_settings(int UU(verbosity)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_max_rss(int64_t *maxrss) {
|
toku_os_get_max_rss(int64_t *maxrss) {
|
||||||
char statusname[100];
|
char statusname[100];
|
||||||
sprintf(statusname, "/proc/%d/status", getpid());
|
sprintf(statusname, "/proc/%d/status", getpid());
|
||||||
FILE *f = fopen(statusname, "r");
|
FILE *f = fopen(statusname, "r");
|
||||||
@@ -144,7 +144,7 @@ os_get_max_rss(int64_t *maxrss) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_rss(int64_t *rss) {
|
toku_os_get_rss(int64_t *rss) {
|
||||||
char statusname[100];
|
char statusname[100];
|
||||||
sprintf(statusname, "/proc/%d/status", getpid());
|
sprintf(statusname, "/proc/%d/status", getpid());
|
||||||
FILE *f = fopen(statusname, "r");
|
FILE *f = fopen(statusname, "r");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
CPPFLAGS = -I../../include
|
CPPFLAGS = -I../../include -I..
|
||||||
CFLAGS = -Wall -Werror -g -O0
|
CFLAGS = -Wall -Werror -g -O0
|
||||||
LDFLAGS = ../tokulinux.a
|
LDFLAGS = ../tokulinux.a
|
||||||
SRCS = $(wildcard test-*.c)
|
SRCS = $(wildcard test-*.c)
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
assert(os_get_pagesize() == getpagesize());
|
assert(toku_os_get_pagesize() == getpagesize());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <os.h>
|
#include <toku_os.h>
|
||||||
|
|
||||||
static void do_mallocs(void) {
|
static void do_mallocs(void) {
|
||||||
int i;
|
int i;
|
||||||
@@ -18,10 +18,10 @@ static void do_mallocs(void) {
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
int64_t rss;
|
int64_t rss;
|
||||||
|
|
||||||
os_get_max_rss(&rss);
|
toku_os_get_max_rss(&rss);
|
||||||
printf("%"PRId64"\n", rss);
|
printf("%"PRId64"\n", rss);
|
||||||
do_mallocs();
|
do_mallocs();
|
||||||
os_get_max_rss(&rss);
|
toku_os_get_max_rss(&rss);
|
||||||
printf("%"PRId64"\n", rss);
|
printf("%"PRId64"\n", rss);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
|
|
||||||
int os_getpid(void);
|
int toku_os_getpid(void);
|
||||||
|
|
||||||
static int gettid(void) {
|
static int gettid(void) {
|
||||||
return syscall(__NR_gettid);
|
return syscall(__NR_gettid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
assert(os_getpid() == getpid());
|
assert(toku_os_getpid() == getpid());
|
||||||
assert(os_gettid() == gettid());
|
assert(toku_os_gettid() == gettid());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#if !defined(OS_INTERFACE_LINUX_H)
|
#if !defined(TOKU_OS_TYPES_H)
|
||||||
#define OS_INTERFACE_LINUX_H
|
#define TOKU_OS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef int os_handle_t;
|
typedef int toku_os_handle_t;
|
||||||
|
|
||||||
struct fileid {
|
struct fileid {
|
||||||
dev_t st_dev; /* device and inode are enough to uniquely identify a file in unix. */
|
dev_t st_dev; /* device and inode are enough to uniquely identify a file in unix. */
|
||||||
@@ -160,7 +160,7 @@ int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn,
|
|||||||
r = toku_pthread_mutex_init(&t->mutex, 0); assert(r == 0);
|
r = toku_pthread_mutex_init(&t->mutex, 0); assert(r == 0);
|
||||||
|
|
||||||
// set the max number of writeback threads to min(MAX_WRITER_THREADS,nprocs_online)
|
// set the max number of writeback threads to min(MAX_WRITER_THREADS,nprocs_online)
|
||||||
int nprocs = os_get_number_active_processors();
|
int nprocs = toku_os_get_number_active_processors();
|
||||||
if (nprocs > MAX_WRITER_THREADS) nprocs = MAX_WRITER_THREADS;
|
if (nprocs > MAX_WRITER_THREADS) nprocs = MAX_WRITER_THREADS;
|
||||||
r = threadpool_create(&t->threadpool, nprocs); assert(r == 0);
|
r = threadpool_create(&t->threadpool, nprocs); assert(r == 0);
|
||||||
|
|
||||||
@@ -197,7 +197,7 @@ int toku_cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd, const char *fna
|
|||||||
int r;
|
int r;
|
||||||
CACHEFILE extant;
|
CACHEFILE extant;
|
||||||
struct fileid fileid;
|
struct fileid fileid;
|
||||||
r = os_get_unique_file_id(fd, &fileid);
|
r = toku_os_get_unique_file_id(fd, &fileid);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
r=errno; close(fd);
|
r=errno; close(fd);
|
||||||
return r;
|
return r;
|
||||||
@@ -1234,7 +1234,7 @@ int toku_cachefile_redirect_nullfd (CACHEFILE cf) {
|
|||||||
|
|
||||||
null_fd = open(DEV_NULL_FILE, O_WRONLY+O_BINARY);
|
null_fd = open(DEV_NULL_FILE, O_WRONLY+O_BINARY);
|
||||||
assert(null_fd>=0);
|
assert(null_fd>=0);
|
||||||
os_get_unique_file_id(null_fd, &fileid);
|
toku_os_get_unique_file_id(null_fd, &fileid);
|
||||||
close(cf->fd);
|
close(cf->fd);
|
||||||
cf->fd = null_fd;
|
cf->fd = null_fd;
|
||||||
if (cf->fname) {
|
if (cf->fname) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
// Portability first!
|
// Portability first!
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
|
|
||||||
#if TOKU_WINDOWS
|
#if TOKU_WINDOWS
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ static int open_logfile (TOKULOGGER logger) {
|
|||||||
|
|
||||||
static int close_and_open_logfile (TOKULOGGER logger) {
|
static int close_and_open_logfile (TOKULOGGER logger) {
|
||||||
int r;
|
int r;
|
||||||
r=toku_os_fsync_function(logger->fd); if (r!=0) return errno;
|
r = toku_os_fsync_function(logger->fd); if (r!=0) return errno;
|
||||||
r = close(logger->fd); if (r!=0) return errno;
|
r = close(logger->fd); if (r!=0) return errno;
|
||||||
return open_logfile(logger);
|
return open_logfile(logger);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ create_dir_from_file (const char *fname) {
|
|||||||
if (i>0) {
|
if (i>0) {
|
||||||
tmp[i]=0;
|
tmp[i]=0;
|
||||||
mode_t oldu = umask(0);
|
mode_t oldu = umask(0);
|
||||||
int r = os_mkdir(tmp, S_IRWXU);
|
int r = toku_os_mkdir(tmp, S_IRWXU);
|
||||||
if (r!=0 && errno!=EEXIST) {
|
if (r!=0 && errno!=EEXIST) {
|
||||||
printf("error: %s\n", strerror(errno));
|
printf("error: %s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
@@ -702,7 +702,7 @@ int tokudb_recover(const char *data_dir, const char *log_dir) {
|
|||||||
char lockfname[namelen+sizeof(fname)];
|
char lockfname[namelen+sizeof(fname)];
|
||||||
|
|
||||||
snprintf(lockfname, sizeof(lockfname), "%s%s", data_dir, fname);
|
snprintf(lockfname, sizeof(lockfname), "%s%s", data_dir, fname);
|
||||||
lockfd = os_lock_file(lockfname);
|
lockfd = toku_os_lock_file(lockfname);
|
||||||
if (lockfd<0) {
|
if (lockfd<0) {
|
||||||
printf("Couldn't run recovery because some other process holds the recovery lock %s\n", lockfname);
|
printf("Couldn't run recovery because some other process holds the recovery lock %s\n", lockfname);
|
||||||
return errno;
|
return errno;
|
||||||
@@ -760,7 +760,7 @@ int tokudb_recover(const char *data_dir, const char *log_dir) {
|
|||||||
}
|
}
|
||||||
toku_free(logfiles);
|
toku_free(logfiles);
|
||||||
|
|
||||||
r=os_unlock_file(lockfd);
|
r=toku_os_unlock_file(lockfd);
|
||||||
if (r!=0) return errno;
|
if (r!=0) return errno;
|
||||||
|
|
||||||
r=chdir(org_wd);
|
r=chdir(org_wd);
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ int toku_commit_rollinclude (BYTESTRING bs,TOKUTXN txn) {
|
|||||||
assert(fd>=0);
|
assert(fd>=0);
|
||||||
|
|
||||||
int64_t fsize = 0;
|
int64_t fsize = 0;
|
||||||
r = os_get_file_size(fd, &fsize);
|
r = toku_os_get_file_size(fd, &fsize);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
r = toku_commit_fileentries(fd, fsize, txn);
|
r = toku_commit_fileentries(fd, fsize, txn);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
@@ -185,7 +185,7 @@ int toku_rollback_rollinclude (BYTESTRING bs,TOKUTXN txn) {
|
|||||||
int fd = open(fname, O_RDONLY+O_BINARY);
|
int fd = open(fname, O_RDONLY+O_BINARY);
|
||||||
assert(fd>=0);
|
assert(fd>=0);
|
||||||
int64_t fsize = 0;
|
int64_t fsize = 0;
|
||||||
r = os_get_file_size(fd, &fsize);
|
r = toku_os_get_file_size(fd, &fsize);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
r = toku_rollback_fileentries(fd, fsize, txn);
|
r = toku_rollback_fileentries(fd, fsize, txn);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ cachetable_fd_test (void) {
|
|||||||
|
|
||||||
int main(int argc, const char *argv[]) {
|
int main(int argc, const char *argv[]) {
|
||||||
default_parse_args(argc, argv);
|
default_parse_args(argc, argv);
|
||||||
os_initialize_settings(verbose);
|
toku_os_initialize_settings(verbose);
|
||||||
|
|
||||||
cachetable_fd_test();
|
cachetable_fd_test();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ static void test_rename (void) {
|
|||||||
int main (int argc, const char *argv[]) {
|
int main (int argc, const char *argv[]) {
|
||||||
// parse args
|
// parse args
|
||||||
default_parse_args(argc, argv);
|
default_parse_args(argc, argv);
|
||||||
os_initialize_settings(verbose);
|
toku_os_initialize_settings(verbose);
|
||||||
|
|
||||||
// run tests
|
// run tests
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ static void readit (void) {
|
|||||||
struct timeval start, end;
|
struct timeval start, end;
|
||||||
struct timeval start_usertime, start_systime;
|
struct timeval start_usertime, start_systime;
|
||||||
struct timeval end_usertime, end_systime;
|
struct timeval end_usertime, end_systime;
|
||||||
os_get_process_times(&start_usertime, &start_systime);
|
toku_os_get_process_times(&start_usertime, &start_systime);
|
||||||
gettimeofday(&start, 0);
|
gettimeofday(&start, 0);
|
||||||
int i, r;
|
int i, r;
|
||||||
void *block;
|
void *block;
|
||||||
@@ -90,7 +90,7 @@ static void readit (void) {
|
|||||||
r = toku_cachefile_close(&f, 0); assert(r == 0);
|
r = toku_cachefile_close(&f, 0); assert(r == 0);
|
||||||
r = toku_cachetable_close(&t); assert(r == 0);
|
r = toku_cachetable_close(&t); assert(r == 0);
|
||||||
gettimeofday(&end, 0);
|
gettimeofday(&end, 0);
|
||||||
os_get_process_times(&end_usertime, &end_systime);
|
toku_os_get_process_times(&end_usertime, &end_systime);
|
||||||
double diff = tdiff(&end, &start);
|
double diff = tdiff(&end, &start);
|
||||||
double udiff = tdiff(&end_usertime, &start_usertime);
|
double udiff = tdiff(&end_usertime, &start_usertime);
|
||||||
double sdiff = tdiff(&end_systime, &start_systime);
|
double sdiff = tdiff(&end_systime, &start_systime);
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ static void test_nested_pin (void) {
|
|||||||
assert(r==0);
|
assert(r==0);
|
||||||
r = toku_cachetable_unpin(f, make_blocknum(2), f2hash, 0, test_object_size);
|
r = toku_cachetable_unpin(f, make_blocknum(2), f2hash, 0, test_object_size);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
// os_usleep(1*1000000);
|
// toku_os_usleep(1*1000000);
|
||||||
r = toku_cachefile_close(&f, 0); assert(r==0);
|
r = toku_cachefile_close(&f, 0); assert(r==0);
|
||||||
r = toku_cachetable_close(&t); assert(r==0);
|
r = toku_cachetable_close(&t); assert(r==0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ test_flow_control (int limit, int n) {
|
|||||||
writequeue_wait_write(&rwfc->writequeue, &rwfc->mutex);
|
writequeue_wait_write(&rwfc->writequeue, &rwfc->mutex);
|
||||||
}
|
}
|
||||||
r = toku_pthread_mutex_unlock(&rwfc->mutex); assert(r == 0);
|
r = toku_pthread_mutex_unlock(&rwfc->mutex); assert(r == 0);
|
||||||
// os_usleep(random() % 1);
|
// toku_os_usleep(random() % 1);
|
||||||
}
|
}
|
||||||
writequeue_set_closed(&rwfc->writequeue);
|
writequeue_set_closed(&rwfc->writequeue);
|
||||||
void *ret;
|
void *ret;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ int main (int argc __attribute__((__unused__)),
|
|||||||
int r;
|
int r;
|
||||||
long long lognum;
|
long long lognum;
|
||||||
system(rmrf);
|
system(rmrf);
|
||||||
r = os_mkdir(dname, S_IRWXU); assert(r==0);
|
r = toku_os_mkdir(dname, S_IRWXU); assert(r==0);
|
||||||
r = toku_logger_find_next_unused_log_file(dname,&lognum);
|
r = toku_logger_find_next_unused_log_file(dname,&lognum);
|
||||||
assert(r==0 && lognum==0LL);
|
assert(r==0 && lognum==0LL);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)),
|
|||||||
char *argv[] __attribute__((__unused__))) {
|
char *argv[] __attribute__((__unused__))) {
|
||||||
int r;
|
int r;
|
||||||
system(rmrf);
|
system(rmrf);
|
||||||
r = os_mkdir(dname, S_IRWXU); assert(r==0);
|
r = toku_os_mkdir(dname, S_IRWXU); assert(r==0);
|
||||||
TOKULOGGER logger;
|
TOKULOGGER logger;
|
||||||
r = toku_logger_create(&logger);
|
r = toku_logger_create(&logger);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)),
|
|||||||
char *argv[] __attribute__((__unused__))) {
|
char *argv[] __attribute__((__unused__))) {
|
||||||
int r;
|
int r;
|
||||||
system(rmrf);
|
system(rmrf);
|
||||||
r = os_mkdir(dname, S_IRWXU); assert(r==0);
|
r = toku_os_mkdir(dname, S_IRWXU); assert(r==0);
|
||||||
TOKULOGGER logger;
|
TOKULOGGER logger;
|
||||||
r = toku_logger_create(&logger);
|
r = toku_logger_create(&logger);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ int main (int argc __attribute__((__unused__)),
|
|||||||
char *argv[] __attribute__((__unused__))) {
|
char *argv[] __attribute__((__unused__))) {
|
||||||
int r;
|
int r;
|
||||||
system(rmrf);
|
system(rmrf);
|
||||||
r = os_mkdir(dname, S_IRWXU); assert(r==0);
|
r = toku_os_mkdir(dname, S_IRWXU); assert(r==0);
|
||||||
TOKULOGGER logger;
|
TOKULOGGER logger;
|
||||||
r = toku_logger_create(&logger);
|
r = toku_logger_create(&logger);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ int main (int argc __attribute__((__unused__)),
|
|||||||
char *argv[] __attribute__((__unused__))) {
|
char *argv[] __attribute__((__unused__))) {
|
||||||
int r;
|
int r;
|
||||||
system(rmrf);
|
system(rmrf);
|
||||||
r = os_mkdir(dname, S_IRWXU); assert(r==0);
|
r = toku_os_mkdir(dname, S_IRWXU); assert(r==0);
|
||||||
TOKULOGGER logger;
|
TOKULOGGER logger;
|
||||||
r = toku_logger_create(&logger);
|
r = toku_logger_create(&logger);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ int main (int argc __attribute__((__unused__)),
|
|||||||
char *argv[] __attribute__((__unused__))) {
|
char *argv[] __attribute__((__unused__))) {
|
||||||
int r;
|
int r;
|
||||||
system(rmrf);
|
system(rmrf);
|
||||||
r = os_mkdir(dname, S_IRWXU); assert(r==0);
|
r = toku_os_mkdir(dname, S_IRWXU); assert(r==0);
|
||||||
TOKULOGGER logger;
|
TOKULOGGER logger;
|
||||||
r = toku_logger_create(&logger);
|
r = toku_logger_create(&logger);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -53,7 +53,7 @@ fbusy (void *arg) {
|
|||||||
r = toku_pthread_cond_wait(&my_threadpool->wait, &my_threadpool->mutex); assert(r == 0);
|
r = toku_pthread_cond_wait(&my_threadpool->wait, &my_threadpool->mutex); assert(r == 0);
|
||||||
}
|
}
|
||||||
r = toku_pthread_mutex_unlock(&my_threadpool->mutex); assert(r == 0);
|
r = toku_pthread_mutex_unlock(&my_threadpool->mutex); assert(r == 0);
|
||||||
if (verbose) printf("%lu:%s:exit\n", (unsigned long)os_gettid(), __FUNCTION__);
|
if (verbose) printf("%lu:%s:exit\n", (unsigned long)toku_os_gettid(), __FUNCTION__);
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ fidle (void *arg) {
|
|||||||
r = toku_pthread_cond_wait(&my_threadpool->wait, &my_threadpool->mutex); assert(r == 0);
|
r = toku_pthread_cond_wait(&my_threadpool->wait, &my_threadpool->mutex); assert(r == 0);
|
||||||
}
|
}
|
||||||
r = toku_pthread_mutex_unlock(&my_threadpool->mutex); assert(r == 0);
|
r = toku_pthread_mutex_unlock(&my_threadpool->mutex); assert(r == 0);
|
||||||
if (verbose) printf("%lu:%s:exit\n", (unsigned long)os_gettid(), __FUNCTION__);
|
if (verbose) printf("%lu:%s:exit\n", (unsigned long)toku_os_gettid(), __FUNCTION__);
|
||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ int toku_db_id_create(toku_db_id** pdbid, int fd,
|
|||||||
if (!db_id) { r = ENOMEM; goto cleanup; }
|
if (!db_id) { r = ENOMEM; goto cleanup; }
|
||||||
memset(db_id, 0, sizeof(*db_id));
|
memset(db_id, 0, sizeof(*db_id));
|
||||||
|
|
||||||
r = os_get_unique_file_id(fd, &db_id->id);
|
r = toku_os_get_unique_file_id(fd, &db_id->id);
|
||||||
if (r!=0) goto cleanup;
|
if (r!=0) goto cleanup;
|
||||||
|
|
||||||
db_id->sub_database_name = toku_strdup(sub_database_name);
|
db_id->sub_database_name = toku_strdup(sub_database_name);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#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."
|
#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."
|
||||||
|
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
|
||||||
#include <brttypes.h>
|
#include <brttypes.h>
|
||||||
|
|
||||||
#if !defined(TOKU_DB_ID_H)
|
#if !defined(TOKU_DB_ID_H)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
dup_compare = intcmp;
|
dup_compare = intcmp;
|
||||||
|
|
||||||
system("rm -rf " TESTDIR);
|
system("rm -rf " TESTDIR);
|
||||||
os_mkdir(TESTDIR, S_IRWXU|S_IRWXG|S_IRWXO);
|
toku_os_mkdir(TESTDIR, S_IRWXU|S_IRWXG|S_IRWXO);
|
||||||
|
|
||||||
run_test(FALSE);
|
run_test(FALSE);
|
||||||
run_test(TRUE);
|
run_test(TRUE);
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
dup_compare = intcmp;
|
dup_compare = intcmp;
|
||||||
|
|
||||||
system("rm -rf " TESTDIR);
|
system("rm -rf " TESTDIR);
|
||||||
os_mkdir(TESTDIR, S_IRWXU|S_IRWXG|S_IRWXO);
|
toku_os_mkdir(TESTDIR, S_IRWXU|S_IRWXG|S_IRWXO);
|
||||||
|
|
||||||
initial_setup();
|
initial_setup();
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ parse_args (int argc, const char *argv[]) {
|
|||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
os_initialize_settings(1);
|
toku_os_initialize_settings(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __attribute__((__unused__)) DBT *
|
static __attribute__((__unused__)) DBT *
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
parse_args(argc, argv);
|
parse_args(argc, argv);
|
||||||
|
|
||||||
r = system("rm -rf " ENVDIR); assert(r == 0);
|
r = system("rm -rf " ENVDIR); assert(r == 0);
|
||||||
r = os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||||
|
|
||||||
test_cursor_delete(0);
|
test_cursor_delete(0);
|
||||||
#ifdef USE_BDB
|
#ifdef USE_BDB
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ int main(int argc, const char *argv[]) {
|
|||||||
parse_args(argc, argv);
|
parse_args(argc, argv);
|
||||||
|
|
||||||
r = system("rm -rf " ENVDIR); assert(r == 0);
|
r = system("rm -rf " ENVDIR); assert(r == 0);
|
||||||
r = os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
r = toku_os_mkdir(ENVDIR, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
|
||||||
|
|
||||||
for (i=1; i<65537; i *= 2) {
|
for (i=1; i<65537; i *= 2) {
|
||||||
test_cursor_sticky(i, 0);
|
test_cursor_sticky(i, 0);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
static inline unsigned int getmyid() {
|
static inline unsigned int getmyid() {
|
||||||
return os_gettid();
|
return toku_os_gettid();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef unsigned int my_t;
|
typedef unsigned int my_t;
|
||||||
@@ -105,7 +105,7 @@ int main(int argc, char *argv[]) {
|
|||||||
work[i].endno = n;
|
work[i].endno = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) printf("pid:%d\n", os_getpid());
|
if (verbose) printf("pid:%d\n", toku_os_getpid());
|
||||||
|
|
||||||
for (i=1; i<nthreads; i++) {
|
for (i=1; i<nthreads; i++) {
|
||||||
r = toku_pthread_create(&work[i].tid, 0, do_inserts, &work[i]); assert(r == 0);
|
r = toku_pthread_create(&work[i].tid, 0, do_inserts, &work[i]); assert(r == 0);
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ db_put (DB *db, my_t k, my_t v) {
|
|||||||
static void *
|
static void *
|
||||||
do_inserts (void *arg) {
|
do_inserts (void *arg) {
|
||||||
struct db_inserter *mywork = (struct db_inserter *) arg;
|
struct db_inserter *mywork = (struct db_inserter *) arg;
|
||||||
if (verbose) printf("%lu:%d:do_inserts:start:%u-%u\n", (unsigned long)toku_pthread_self(), os_gettid(), mywork->startno, mywork->endno);
|
if (verbose) printf("%lu:%d:do_inserts:start:%u-%u\n", (unsigned long)toku_pthread_self(), toku_os_gettid(), mywork->startno, mywork->endno);
|
||||||
my_t i;
|
my_t i;
|
||||||
for (i=mywork->startno; i < mywork->endno; i++) {
|
for (i=mywork->startno; i < mywork->endno; i++) {
|
||||||
int r = db_put(mywork->db, htonl(i), i); assert(r == 0);
|
int r = db_put(mywork->db, htonl(i), i); assert(r == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) printf("%lu:%d:do_inserts:end\n", (unsigned long)toku_pthread_self(), os_gettid());
|
if (verbose) printf("%lu:%d:do_inserts:end\n", (unsigned long)toku_pthread_self(), toku_os_gettid());
|
||||||
if (mywork->do_exit) return arg;
|
if (mywork->do_exit) return arg;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ int main(int argc, char *argv[]) {
|
|||||||
work[i].endno = n;
|
work[i].endno = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose) printf("pid:%d tid:%d\n", os_getpid(), os_gettid());
|
if (verbose) printf("pid:%d tid:%d\n", toku_os_getpid(), toku_os_gettid());
|
||||||
|
|
||||||
for (i=all_on_threads ? 0 : 1; i<nthreads; i++) {
|
for (i=all_on_threads ? 0 : 1; i<nthreads; i++) {
|
||||||
toku_pthread_attr_t attr;
|
toku_pthread_attr_t attr;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define _TOKU_DIRENT_H
|
#define _TOKU_DIRENT_H
|
||||||
|
|
||||||
//The DIR functions do not exist in windows, but the Linux API ends up
|
//The DIR functions do not exist in windows, but the Linux API ends up
|
||||||
//just using a wrapper. We might convert these into an os_* type api.
|
//just using a wrapper. We might convert these into an toku_os_* type api.
|
||||||
|
|
||||||
DIR *opendir(const char *name);
|
DIR *opendir(const char *name);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#ifndef _MISC_H
|
#ifndef _MISC_H
|
||||||
#define _MISC_H
|
#define _MISC_H
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
//These are functions that really exist in windows but are named
|
//These are functions that really exist in windows but are named
|
||||||
@@ -15,7 +15,7 @@ long long int strtoll(const char *nptr, char **endptr, int base);
|
|||||||
|
|
||||||
|
|
||||||
//TODO: Enforce use of these macros. Otherwise, open, creat, and chmod may fail
|
//TODO: Enforce use of these macros. Otherwise, open, creat, and chmod may fail
|
||||||
//os_mkdir actually ignores the permissions, so it won't fail.
|
//toku_os_mkdir actually ignores the permissions, so it won't fail.
|
||||||
|
|
||||||
//Permissions
|
//Permissions
|
||||||
//User permissions translate to global
|
//User permissions translate to global
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <os.h>
|
#include <toku_os.h>
|
||||||
|
|
||||||
#define DO_MEMORY_INFO 1
|
#define DO_MEMORY_INFO 1
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ get_memory_info(PROCESS_MEMORY_COUNTERS *meminfo) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_rss(int64_t *rss) {
|
toku_os_get_rss(int64_t *rss) {
|
||||||
int r;
|
int r;
|
||||||
#if DO_MEMORY_INFO
|
#if DO_MEMORY_INFO
|
||||||
PROCESS_MEMORY_COUNTERS meminfo;
|
PROCESS_MEMORY_COUNTERS meminfo;
|
||||||
@@ -37,7 +37,7 @@ os_get_rss(int64_t *rss) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_max_rss(int64_t *maxrss) {
|
toku_os_get_max_rss(int64_t *maxrss) {
|
||||||
int r;
|
int r;
|
||||||
#if DO_MEMORY_INFO
|
#if DO_MEMORY_INFO
|
||||||
PROCESS_MEMORY_COUNTERS meminfo;
|
PROCESS_MEMORY_COUNTERS meminfo;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
int verbose;
|
int verbose;
|
||||||
@@ -52,13 +52,13 @@ int main(int argc, char *argv[]) {
|
|||||||
assert(found == -1);
|
assert(found == -1);
|
||||||
|
|
||||||
// try to walk an empty directory
|
// try to walk an empty directory
|
||||||
r = os_mkdir(TESTDIR, 0777); assert(r==0);
|
r = toku_os_mkdir(TESTDIR, 0777); assert(r==0);
|
||||||
found = walk(TESTDIR);
|
found = walk(TESTDIR);
|
||||||
assert(found == 0);
|
assert(found == 0);
|
||||||
//Try to delete the empty directory
|
//Try to delete the empty directory
|
||||||
system("rm -rf " TESTDIR);
|
system("rm -rf " TESTDIR);
|
||||||
|
|
||||||
r = os_mkdir(TESTDIR, 0777); assert(r==0);
|
r = toku_os_mkdir(TESTDIR, 0777); assert(r==0);
|
||||||
// walk a directory with a bunch of files in it
|
// walk a directory with a bunch of files in it
|
||||||
#define N 100
|
#define N 100
|
||||||
for (i=0; i<N; i++) {
|
for (i=0; i<N; i++) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
|
|
||||||
int verbose=0;
|
int verbose=0;
|
||||||
|
|
||||||
@@ -17,10 +17,10 @@ static void test_handles(const char *fname) {
|
|||||||
int i;
|
int i;
|
||||||
struct fileid id_base;
|
struct fileid id_base;
|
||||||
struct fileid id;
|
struct fileid id;
|
||||||
int r = os_get_unique_file_id(fd, &id_base);
|
int r = toku_os_get_unique_file_id(fd, &id_base);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
for (i=0; i < 1<<16; i++) {
|
for (i=0; i < 1<<16; i++) {
|
||||||
r = os_get_unique_file_id(fd, &id);
|
r = toku_os_get_unique_file_id(fd, &id);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
assert(memcmp(&id, &id_base, sizeof(id))==0);
|
assert(memcmp(&id, &id_base, sizeof(id))==0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
|
|
||||||
int verbose;
|
int verbose;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <os.h>
|
#include <toku_os.h>
|
||||||
|
|
||||||
static void do_mallocs(void) {
|
static void do_mallocs(void) {
|
||||||
int i;
|
int i;
|
||||||
@@ -18,10 +18,10 @@ static void do_mallocs(void) {
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
int64_t rss;
|
int64_t rss;
|
||||||
|
|
||||||
os_get_max_rss(&rss);
|
toku_os_get_max_rss(&rss);
|
||||||
printf("%I64d\n", rss);
|
printf("%I64d\n", rss);
|
||||||
do_mallocs();
|
do_mallocs();
|
||||||
os_get_max_rss(&rss);
|
toku_os_get_max_rss(&rss);
|
||||||
printf("%I64d\n", rss);
|
printf("%I64d\n", rss);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
|
|
||||||
int verbose;
|
int verbose;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ int main(void) {
|
|||||||
|
|
||||||
test_stat(".");
|
test_stat(".");
|
||||||
|
|
||||||
r = os_mkdir("testdir", S_IRWXU);
|
r = toku_os_mkdir("testdir", S_IRWXU);
|
||||||
assert(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
test_stat("testdir");
|
test_stat("testdir");
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
|
|
||||||
int verbose;
|
int verbose;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ int main(void) {
|
|||||||
fd = open(DEV_NULL_FILE, O_RDWR);
|
fd = open(DEV_NULL_FILE, O_RDWR);
|
||||||
assert(fd != -1);
|
assert(fd != -1);
|
||||||
|
|
||||||
r = os_get_unique_file_id(fd, &fid);
|
r = toku_os_get_unique_file_id(fd, &fid);
|
||||||
printf("%s:%d %d\n", __FILE__, __LINE__, r);
|
printf("%s:%d %d\n", __FILE__, __LINE__, r);
|
||||||
|
|
||||||
r = close(fd);
|
r = close(fd);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "portability.h"
|
#include "portability.h"
|
||||||
#include "os.h"
|
#include "toku_os.h"
|
||||||
|
|
||||||
int verbose;
|
int verbose;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#if !defined(OS_INTERFACE_WINDOWS_H)
|
#if !defined(TOKU_OS_TYPES_H)
|
||||||
#define OS_INTERFACE_WINDOWS_H
|
#define TOKUOS_TYPES_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
|
|
||||||
// define an OS handle
|
// define an OS handle
|
||||||
typedef void *os_handle_t;
|
typedef void *toku_os_handle_t;
|
||||||
typedef int pid_t;
|
typedef int pid_t;
|
||||||
typedef int mode_t;
|
typedef int mode_t;
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ fsync(int fildes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_file_size(int fildes, int64_t *size) {
|
toku_os_get_file_size(int fildes, int64_t *size) {
|
||||||
struct _stat64 sbuf;
|
struct _stat64 sbuf;
|
||||||
int r = _fstati64(fildes, &sbuf);
|
int r = _fstati64(fildes, &sbuf);
|
||||||
if (r==0) {
|
if (r==0) {
|
||||||
@@ -122,7 +122,7 @@ os_get_file_size(int fildes, int64_t *size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
os_get_phys_memory_size(void) {
|
toku_os_get_phys_memory_size(void) {
|
||||||
MEMORYSTATUS memory_status;
|
MEMORYSTATUS memory_status;
|
||||||
GlobalMemoryStatus(&memory_status);
|
GlobalMemoryStatus(&memory_status);
|
||||||
return memory_status.dwTotalPhys;
|
return memory_status.dwTotalPhys;
|
||||||
@@ -130,14 +130,14 @@ os_get_phys_memory_size(void) {
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_number_processors(void) {
|
toku_os_get_number_processors(void) {
|
||||||
SYSTEM_INFO system_info;
|
SYSTEM_INFO system_info;
|
||||||
GetSystemInfo(&system_info);
|
GetSystemInfo(&system_info);
|
||||||
return system_info.dwNumberOfProcessors;
|
return system_info.dwNumberOfProcessors;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_number_active_processors(void) {
|
toku_os_get_number_active_processors(void) {
|
||||||
SYSTEM_INFO system_info;
|
SYSTEM_INFO system_info;
|
||||||
DWORD mask, n;
|
DWORD mask, n;
|
||||||
GetSystemInfo(&system_info);
|
GetSystemInfo(&system_info);
|
||||||
@@ -148,14 +148,14 @@ os_get_number_active_processors(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_pagesize(void) {
|
toku_os_get_pagesize(void) {
|
||||||
SYSTEM_INFO system_info;
|
SYSTEM_INFO system_info;
|
||||||
GetSystemInfo(&system_info);
|
GetSystemInfo(&system_info);
|
||||||
return system_info.dwPageSize;
|
return system_info.dwPageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_unique_file_id(int fildes, struct fileid *id) {
|
toku_os_get_unique_file_id(int fildes, struct fileid *id) {
|
||||||
int r;
|
int r;
|
||||||
BY_HANDLE_FILE_INFORMATION info;
|
BY_HANDLE_FILE_INFORMATION info;
|
||||||
HANDLE filehandle;
|
HANDLE filehandle;
|
||||||
@@ -197,7 +197,7 @@ convert_filetime_timeval(FILETIME ft, struct timeval *tv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_get_process_times(struct timeval *usertime, struct timeval *kerneltime) {
|
toku_os_get_process_times(struct timeval *usertime, struct timeval *kerneltime) {
|
||||||
FILETIME w_createtime, w_exittime, w_usertime, w_kerneltime;
|
FILETIME w_createtime, w_exittime, w_usertime, w_kerneltime;
|
||||||
|
|
||||||
if (GetProcessTimes(GetCurrentProcess(), &w_createtime, &w_exittime, &w_kerneltime, &w_usertime)) {
|
if (GetProcessTimes(GetCurrentProcess(), &w_createtime, &w_exittime, &w_kerneltime, &w_usertime)) {
|
||||||
@@ -209,7 +209,7 @@ os_get_process_times(struct timeval *usertime, struct timeval *kerneltime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_getpid(void) {
|
toku_os_getpid(void) {
|
||||||
#if 0
|
#if 0
|
||||||
return _getpid();
|
return _getpid();
|
||||||
#else
|
#else
|
||||||
@@ -218,7 +218,7 @@ os_getpid(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_gettid(void) {
|
toku_os_gettid(void) {
|
||||||
return GetCurrentThreadId();
|
return GetCurrentThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,13 +243,13 @@ gettimeofday(struct timeval *tv, struct timezone *tz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_lock_file(char *name) {
|
toku_os_lock_file(char *name) {
|
||||||
int fd = _sopen(name, O_CREAT, _SH_DENYRW, S_IREAD|S_IWRITE);
|
int fd = _sopen(name, O_CREAT, _SH_DENYRW, S_IREAD|S_IWRITE);
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_unlock_file(int fildes) {
|
toku_os_unlock_file(int fildes) {
|
||||||
int r = close(fildes);
|
int r = close(fildes);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
@@ -277,7 +277,7 @@ pwrite(int fildes, const void *buf, size_t nbyte, int64_t offset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_mkdir(const char *pathname, mode_t mode) {
|
toku_os_mkdir(const char *pathname, mode_t mode) {
|
||||||
int r = mkdir(pathname);
|
int r = mkdir(pathname);
|
||||||
UNUSED_WARNING(mode);
|
UNUSED_WARNING(mode);
|
||||||
if (r!=0) r = errno;
|
if (r!=0) r = errno;
|
||||||
@@ -324,7 +324,7 @@ static void ignoreParameterHandler(const wchar_t* expression,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
os_initialize_settings(int verbosity) {
|
toku_os_initialize_settings(int verbosity) {
|
||||||
int r;
|
int r;
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
assert(initialized==0);
|
assert(initialized==0);
|
||||||
|
|||||||
Reference in New Issue
Block a user