This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
/
wscript
129 lines (118 loc) · 3.44 KB
/
wscript
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import Options
import sys
def set_options(opt):
pass
#opt.tool_options('compiler_cc')
def configure(conf):
print "--- libeio ---"
#conf.check_tool('compiler_cc')
conf.check(lib='pthread', uselib_store='PTHREAD')
conf.check_cc(lib="pthread", header_name="pthread.h", function_name="pthread_create", mandatory=True)
if sys.platform.startswith("cygwin"):
conf.check_cc(lib="pthread", header_name="unistd.h", function_name="pthread_atfork", mandatory=True)
elif sys.platform.startswith("win32"):
conf.check_cc(lib="pthread", header_name="pthread.h", function_name="pthread_atfork")
else:
conf.check_cc(lib="pthread", header_name="pthread.h", function_name="pthread_atfork", mandatory=True)
conf.check_cc(msg="Checking for futimes(2)", define_name="HAVE_FUTIMES", fragment="""
#include <sys/types.h>
#include <sys/time.h>
#include <utime.h>
struct timeval tv[2];
int res;
int fd;
int main(void)
{
res = futimes (fd, tv);
return 0;
}
""")
conf.check_cc(msg="Checking for readahead(2)", define_name="HAVE_READAHEAD", fragment="""
#include <fcntl.h>
int main(void)
{
int fd = 0;
size_t count = 2;
ssize_t res;
res = readahead (fd, 0, count);
return 0;
}
""")
conf.check_cc(msg="Checking for fdatasync(2)", define_name="HAVE_FDATASYNC", fragment="""
#include <unistd.h>
int main(void)
{
int fd = 0;
fdatasync (fd);
return 0;
}
""")
conf.check_cc(msg="Checking for pread(2) and pwrite(2)", define_name="HAVE_PREADWRITE", fragment="""
#include <unistd.h>
int main(void)
{
int fd = 0;
size_t count = 1;
char buf;
off_t offset = 1;
ssize_t res;
res = pread (fd, &buf, count, offset);
res = pwrite (fd, &buf, count, offset);
return 0;
}
""")
conf.check_cc(msg="Checking for sendfile(2)" , define_name="HAVE_SENDFILE" , fragment="""
# include <sys/types.h>
#if __linux
# include <sys/sendfile.h>
#elif __FreeBSD__ || defined(__APPLE__)
# include <sys/socket.h>
# include <sys/uio.h>
#elif __hpux
# include <sys/socket.h>
#else
# error unsupported architecture
#endif
int main(void)
{
int fd = 0;
off_t offset = 1;
size_t count = 2;
ssize_t res;
#if __linux
res = sendfile (fd, fd, offset, count);
#elif __FreeBSD__
res = sendfile (fd, fd, offset, count, 0, &offset, 0);
#elif __APPLE__
res = sendfile (fd, fd, offset, &offset, 0, 0);
#elif __hpux
res = sendfile (fd, fd, offset, count, 0, 0);
#endif
return 0;
}
""")
conf.env.append_value("CCFLAGS", "-D_GNU_SOURCE")
conf.check_cc(msg="Checking for sync_file_range(2) ", fragment="""
#include <fcntl.h>
int main(void)
{
int fd = 0;
off64_t offset = 1;
off64_t nbytes = 1;
unsigned int flags = SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE|SYNC_FILE_RANGE_WAIT_AFTER;
ssize_t res;
res = sync_file_range (fd, offset, nbytes, flags);
return 0;
}
""", define_name="HAVE_SYNC_FILE_RANGE")
def build(bld):
libeio = bld.new_task_gen("cc")
libeio.source = "eio.c"
libeio.target = 'eio'
libeio.name = 'eio'
libeio.includes = '. ../..'
libeio.uselib = "PTHREAD"
libeio.install_path = None
if bld.env["USE_DEBUG"]:
libeio.clone("debug");
bld.install_files('${PREFIX}/include/node/', 'eio.h');