-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
53 lines (40 loc) · 1.9 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
#ifndef __UTIL_H__
#define __UTIL_H__
#include <stdbool.h>
#include "test_locking.h"
int sharedLock(const char *actor, int fd, struct flock *lck);
int sharedUnlock(const char *actor, int fd, struct flock *lck);
int exclusiveLock(const char *actor, int fd, struct flock *lck);
int exclusiveLockWait(const char *actor, int fd, struct flock *lck);
int exclusiveLockOneTry(const char *actor, int fd, struct flock *lck);
int exclusiveUnlock(const char *actor, int fd, struct flock *lck);
int reader__openMainFile(void);
int reader__openWalFile(void);
int reader__openH2File(void);
int writer__openMainFile(void);
int writer__openWalFile(void);
int writer__openH2File(void);
void closeFiles(int lockfd, int mainfd, int walfd);
void closeLockFileOnly(int mainfd, int lockfd);
void readHeaders(int fd, struct headers *hdr);
void upgradeVersion(int fd, struct headers *hdr);
void upgradeHeaderWalVersion(int fd, struct headers *hdr, int walVersion);
int upgradeWalVersion(int walfd);
int readWalVersion(int walfd);
void truncateWal(int walVersion, int headerWalVersion);
int getCurrentVersion(struct headers *hdr);
char *getCurrentVersionStr(struct headers *hdr);
long getUsecDiff(struct timeval *st, struct timeval *et);
void __gettimeofday(struct timeval *et);
void __debugPrintStart(char *buf, int maxLen, const char *role, int tid, struct headers *hdr, long int udiff, int tries);
void __debugPrintEnd(char *buf, const char *role, int tid, struct headers *hdr, int walVersion);
void __reader__waitWorkloadTime(void);
void __reader__waitPauseTime(void);
void __writer__waitWorkloadTime(void);
void __writer__waitPauseTime(void);
void __writer__waitWalUpdateTime(void);
bool ensureCorrectVersionLocked(int mainfd, int lockfd, struct headers *hdr);
bool isHeaderWalEven(struct headers *hdr, int walVersion);
bool isHeaderWalAboveThreshold(struct headers *hdr, int maxVersion);
void dumpHeaders(struct headers *hdr);
#endif // __UTIL_H__