-
Notifications
You must be signed in to change notification settings - Fork 41
/
eager_lib.h
70 lines (51 loc) · 1.82 KB
/
eager_lib.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#define _GNU_SOURCE
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/select.h>
#include <unistd.h>
#include <sys/time.h>
#ifdef __linux__
#include <sys/sendfile.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
#endif
#ifndef __DEBUG__
#define __DEBUG__
#ifdef DEBUG
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define debug(fmt, ...) ((void)0)
#endif
#endif
#define MAX(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#define MIN(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
int safeOpen3(const char *pathname, int flags, mode_t mode);
int safeOpen(const char *pathname, int flags);
off_t safeLseek(int fd);
void fdSetBlocking(int fd, int blocking);
int tryOpenOutput(const char *pathname);
int blockOpenOutput(const char *pathname);
int readInputWriteToFile(int inputFd, int intermediateWriter, int bufferSize);
/* int bufferedReadInputWriteToFile(int inputFd, int intermediateWriter, int bufferSize); */
/* int writeOutput(int outputFd, const char* outputBuf, ssize_t bytesToWrite); */
/* int emptyBuffer(int outputFd, const char* outputBuf, ssize_t* outputBytesRead, ssize_t* outputBytesWritten); */
/* void bufferedOutputRestIntermediateFile(int outputFd, int intermediateWriter, int intermediateReader, */
/* char* outputBuf, int* doneWriting); */
ssize_t safeWriteOutput(int outputFd, int intermediateReader,
off_t intermediateFileDiff, int* doneWriting);
void outputRestIntermediateFile(int outputFd, int intermediateWriter,
int intermediateReader, int* doneWriting);