misc.h 1.96 KB
Newer Older
1 2
#ifndef _MISC_H
#define _MISC_H
3 4 5 6 7

#if defined(__cplusplus)
extern "C" {
#endif

Rich Prohaska's avatar
Rich Prohaska committed
8
#include "toku_os.h"
9 10 11 12 13 14 15
#include <sys/stat.h>

//These are functions that really exist in windows but are named
//something else.
//TODO: Sort these into some .h file that makes sense.

int fsync(int fildes);
16 17
int toku_fsync_init(void);
int toku_fsync_destroy(void);
18 19 20 21 22 23 24

int gettimeofday(struct timeval *tv, struct timezone *tz);

long long int strtoll(const char *nptr, char **endptr, int base);


//TODO: Enforce use of these macros. Otherwise, open, creat, and chmod may fail
Rich Prohaska's avatar
Rich Prohaska committed
25
//toku_os_mkdir actually ignores the permissions, so it won't fail.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

//Permissions
//User permissions translate to global
//Execute bit does not exist
//TODO: Determine if we need to use BINARY mode for opening.
#define S_IRWXU     S_IRUSR | S_IWUSR | S_IXUSR
#define S_IRUSR     S_IREAD
#define S_IWUSR     S_IWRITE
//Execute bit does not exist
#define S_IXUSR     (0)

//Group permissions thrown away.
#define S_IRWXG     S_IRGRP | S_IWGRP | S_IXGRP
#define S_IRGRP     (0)
#define S_IWGRP     (0)
#define S_IXGRP     (0)

//Other permissions thrown away. (Except for read)
//MySQL defines S_IROTH as S_IREAD.  Avoid the warning.
#if defined(S_IROTH)
#undef S_IROTH
#endif
#define S_IRWXO     S_IROTH | S_IWOTH | S_IXOTH
#define S_IROTH     S_IREAD
#define S_IWOTH     (0)
#define S_IXOTH     (0)

long int random(void);
void srandom(unsigned int seed);

//strtoll has a different name in windows.
#define strtoll     _strtoi64
#define strtoull    _strtoui64

//rmdir has a different name in windows.
#define rmdir       _rmdir

#ifndef PATH_MAX
64
#define PATH_MAX _MAX_PATH
65 66 67 68 69 70 71 72
#endif

char *realpath(const char *path, char *resolved_path);


int unsetenv(const char *name);
int setenv(const char *name, const char *value, int overwrite);

73 74 75 76
int vsnprintf(char *str, size_t size, const char *format, va_list ap);

int snprintf(char *str, size_t size, const char *format, ...);

Zardosht Kasheff's avatar
Zardosht Kasheff committed
77 78
int usleep(unsigned int useconds);

79 80 81 82
#if defined(__cplusplus)
};
#endif

83 84
#endif