2013-04-16 23:57:27 -04:00
|
|
|
#ifndef TOKU_PORTABILITY_H
|
|
|
|
#define TOKU_PORTABILITY_H
|
|
|
|
|
2013-04-16 23:57:28 -04:00
|
|
|
// Tokutek portability layer
|
|
|
|
|
2013-04-16 23:57:27 -04:00
|
|
|
#if defined __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-04-16 23:57:28 -04:00
|
|
|
#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(__ICL))
|
2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
#define TOKU_WINDOWS 1
|
2013-04-16 23:57:28 -04:00
|
|
|
#define DEV_NULL_FILE "NUL"
|
2013-04-16 23:57:27 -04:00
|
|
|
|
2013-04-16 23:57:28 -04:00
|
|
|
#else
|
2013-04-16 23:57:27 -04:00
|
|
|
|
2013-04-16 23:57:28 -04:00
|
|
|
#define TOKU_WINDOWS 0
|
|
|
|
#define DEV_NULL_FILE "/dev/null"
|
2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-04-16 23:57:28 -04:00
|
|
|
#if TOKU_WINDOWS
|
2013-04-16 23:57:27 -04:00
|
|
|
// Windows
|
|
|
|
|
2013-04-16 23:57:37 -04:00
|
|
|
#if defined(__ICL)
|
|
|
|
#define __attribute__(x) /* Nothing */
|
|
|
|
#endif
|
|
|
|
|
2013-04-16 23:57:27 -04:00
|
|
|
#include "stdint.h"
|
|
|
|
#include "inttypes.h"
|
2013-04-16 23:57:45 -04:00
|
|
|
|
|
|
|
#ifndef TOKU_OFF_T_DEFINED
|
|
|
|
#define TOKU_OFF_T_DEFINED
|
|
|
|
typedef int64_t toku_off_t;
|
|
|
|
#endif
|
|
|
|
|
2013-04-16 23:57:28 -04:00
|
|
|
#include <direct.h>
|
|
|
|
#include <sys/types.h>
|
2013-04-16 23:57:27 -04:00
|
|
|
#include "unistd.h"
|
|
|
|
#include "misc.h"
|
2013-04-16 23:57:28 -04:00
|
|
|
#include "toku_pthread.h"
|
2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
#define UNUSED_WARNING(a) a=a /* To make up for missing attributes */
|
|
|
|
|
|
|
|
#elif defined(__INTEL_COMPILER)
|
|
|
|
|
|
|
|
#if defined(__ICC)
|
|
|
|
// Intel linux
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <inttypes.h>
|
2013-04-16 23:57:45 -04:00
|
|
|
|
2013-04-16 23:57:27 -04:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
// GCC linux
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#error Not ICC and not GNUC. What compiler?
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-04-16 23:57:45 -04:00
|
|
|
#ifndef TOKU_OFF_T_DEFINED
|
|
|
|
#define TOKU_OFF_T_DEFINED
|
|
|
|
typedef int64_t toku_off_t;
|
|
|
|
#endif
|
|
|
|
|
2013-04-16 23:57:28 -04:00
|
|
|
#include "toku_os.h"
|
2013-04-16 23:57:28 -04:00
|
|
|
#include "toku_htonl.h"
|
2013-04-16 23:57:27 -04:00
|
|
|
|
|
|
|
#define UU(x) x __attribute__((__unused__))
|
|
|
|
|
2013-04-16 23:57:30 -04:00
|
|
|
// Deprecated functions.
|
2013-04-16 23:57:30 -04:00
|
|
|
#if !defined(TOKU_ALLOW_DEPRECATED)
|
2013-04-16 23:57:30 -04:00
|
|
|
# if defined(__ICL) //Windows Intel Compiler
|
2013-04-16 23:57:45 -04:00
|
|
|
# pragma deprecated (creat, fstat, stat, getpid, syscall, sysconf, mkdir, strdup)
|
2013-04-16 23:57:42 -04:00
|
|
|
# pragma poison off_t
|
2013-04-16 23:57:34 -04:00
|
|
|
# ifndef DONT_DEPRECATE_MALLOC
|
|
|
|
# pragma deprecated (malloc, free, realloc)
|
|
|
|
# endif
|
2013-04-16 23:57:30 -04:00
|
|
|
# else
|
2013-04-16 23:57:40 -04:00
|
|
|
int creat() __attribute__((__deprecated__));
|
2013-04-16 23:57:30 -04:00
|
|
|
int fstat() __attribute__((__deprecated__));
|
2013-04-16 23:57:45 -04:00
|
|
|
int stat() __attribute__((__deprecated__));
|
2013-04-16 23:57:30 -04:00
|
|
|
int getpid(void) __attribute__((__deprecated__));
|
2013-04-16 23:57:30 -04:00
|
|
|
long int syscall(long int __sysno, ...) __attribute__((__deprecated__));
|
2013-04-16 23:57:34 -04:00
|
|
|
// 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__));
|
2013-04-16 23:57:30 -04:00
|
|
|
int mkdir() __attribute__((__deprecated__));
|
2013-04-16 23:57:33 -04:00
|
|
|
// strdup is a macro in some libraries.
|
|
|
|
#undef strdup
|
|
|
|
char* strdup(const char *) __attribute__((__deprecated__));
|
|
|
|
#undef __strdup
|
|
|
|
char* __strdup(const char *) __attribute__((__deprecated__));
|
2013-04-16 23:57:34 -04:00
|
|
|
# ifndef DONT_DEPRECATE_MALLOC
|
2013-04-16 23:57:33 -04:00
|
|
|
void *malloc(size_t) __attribute__((__deprecated__));
|
|
|
|
void free(void*) __attribute__((__deprecated__));
|
2013-04-16 23:57:34 -04:00
|
|
|
void *realloc(void*, size_t) __attribute__((__deprecated__));
|
2013-04-16 23:57:34 -04:00
|
|
|
# endif
|
2013-04-16 23:57:30 -04:00
|
|
|
# endif
|
2013-04-16 23:57:30 -04:00
|
|
|
#endif
|
|
|
|
|
2013-04-16 23:57:34 -04:00
|
|
|
void *os_malloc(size_t);
|
|
|
|
void *os_realloc(void*,size_t);
|
|
|
|
void os_free(void*);
|
2013-04-16 23:57:42 -04:00
|
|
|
ssize_t toku_os_pwrite (int fd, const void *buf, size_t len, toku_off_t off);
|
2013-04-16 23:57:41 -04:00
|
|
|
ssize_t toku_os_write (int fd, const void *buf, size_t len);
|
2013-04-16 23:57:34 -04:00
|
|
|
|
2013-04-16 23:57:34 -04:00
|
|
|
int toku_set_func_fsync (int (*fsync_function)(int));
|
|
|
|
int toku_set_func_malloc (void *(*)(size_t));
|
|
|
|
int toku_set_func_realloc (void *(*)(void*,size_t));
|
|
|
|
int toku_set_func_free (void (*)(void*));
|
2013-04-16 23:57:42 -04:00
|
|
|
int toku_set_func_pwrite (ssize_t (*pwrite_fun)(int, const void *, size_t, toku_off_t));
|
2013-04-16 23:57:38 -04:00
|
|
|
int toku_set_func_write (ssize_t (*pwrite_fun)(int, const void *, size_t));
|
2013-04-16 23:57:34 -04:00
|
|
|
|
2013-04-16 23:57:27 -04:00
|
|
|
#if defined __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|