fadvise 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/Makefile +157 -0
- data/ext/fadvise.c +2 -2
- data/ext/fadvise.o +0 -0
- data/ext/fadvise.so +0 -0
- data/ext/mkmf.log +24 -0
- data/test/test.rb +11 -10
- metadata +11 -5
data/ext/Makefile
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
#### Start of system configuration section. ####
|
5
|
+
|
6
|
+
srcdir = .
|
7
|
+
topdir = /usr/lib/ruby/1.8/x86_64-linux
|
8
|
+
hdrdir = $(topdir)
|
9
|
+
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
10
|
+
exec_prefix = $(prefix)
|
11
|
+
prefix = $(DESTDIR)/usr
|
12
|
+
sharedstatedir = $(prefix)/com
|
13
|
+
mandir = $(prefix)/share/man
|
14
|
+
psdir = $(docdir)
|
15
|
+
oldincludedir = $(DESTDIR)/usr/include
|
16
|
+
localedir = $(datarootdir)/locale
|
17
|
+
bindir = $(exec_prefix)/bin
|
18
|
+
libexecdir = $(prefix)/lib/ruby1.8
|
19
|
+
sitedir = $(DESTDIR)/usr/local/lib/site_ruby
|
20
|
+
htmldir = $(docdir)
|
21
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
22
|
+
includedir = $(prefix)/include
|
23
|
+
infodir = $(prefix)/share/info
|
24
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
25
|
+
sysconfdir = $(DESTDIR)/etc
|
26
|
+
libdir = $(exec_prefix)/lib
|
27
|
+
sbindir = $(exec_prefix)/sbin
|
28
|
+
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
29
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
30
|
+
dvidir = $(docdir)
|
31
|
+
vendordir = $(libdir)/ruby/vendor_ruby
|
32
|
+
datarootdir = $(prefix)/share
|
33
|
+
pdfdir = $(docdir)
|
34
|
+
archdir = $(rubylibdir)/$(arch)
|
35
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
36
|
+
datadir = $(datarootdir)
|
37
|
+
localstatedir = $(DESTDIR)/var
|
38
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
39
|
+
|
40
|
+
CC = cc
|
41
|
+
LIBRUBY = $(LIBRUBY_SO)
|
42
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
43
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
44
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
45
|
+
|
46
|
+
RUBY_EXTCONF_H =
|
47
|
+
CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC $(cflags)
|
48
|
+
INCFLAGS = -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.
|
49
|
+
DEFS =
|
50
|
+
CPPFLAGS = -DHAVE_POSIX_FADVISE
|
51
|
+
CXXFLAGS = $(CFLAGS)
|
52
|
+
ldflags = -L. -rdynamic -Wl,-export-dynamic
|
53
|
+
dldflags =
|
54
|
+
archflag =
|
55
|
+
DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
|
56
|
+
LDSHARED = $(CC) -shared
|
57
|
+
AR = ar
|
58
|
+
EXEEXT =
|
59
|
+
|
60
|
+
RUBY_INSTALL_NAME = ruby1.8
|
61
|
+
RUBY_SO_NAME = ruby1.8
|
62
|
+
arch = x86_64-linux
|
63
|
+
sitearch = x86_64-linux
|
64
|
+
ruby_version = 1.8
|
65
|
+
ruby = /usr/bin/ruby1.8
|
66
|
+
RUBY = $(ruby)
|
67
|
+
RM = rm -f
|
68
|
+
MAKEDIRS = mkdir -p
|
69
|
+
INSTALL = /usr/bin/install -c
|
70
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
71
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
72
|
+
COPY = cp
|
73
|
+
|
74
|
+
#### End of system configuration section. ####
|
75
|
+
|
76
|
+
preload =
|
77
|
+
|
78
|
+
libpath = . $(libdir)
|
79
|
+
LIBPATH = -L. -L$(libdir)
|
80
|
+
DEFFILE =
|
81
|
+
|
82
|
+
CLEANFILES = mkmf.log
|
83
|
+
DISTCLEANFILES =
|
84
|
+
|
85
|
+
extout =
|
86
|
+
extout_prefix =
|
87
|
+
target_prefix =
|
88
|
+
LOCAL_LIBS =
|
89
|
+
LIBS = $(LIBRUBYARG_SHARED) -lpthread -ldl -lcrypt -lm -lc
|
90
|
+
SRCS = fadvise.c
|
91
|
+
OBJS = fadvise.o
|
92
|
+
TARGET = fadvise
|
93
|
+
DLLIB = $(TARGET).so
|
94
|
+
EXTSTATIC =
|
95
|
+
STATIC_LIB =
|
96
|
+
|
97
|
+
BINDIR = $(bindir)
|
98
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
99
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
100
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
101
|
+
|
102
|
+
TARGET_SO = $(DLLIB)
|
103
|
+
CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
|
104
|
+
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
105
|
+
|
106
|
+
all: $(DLLIB)
|
107
|
+
static: $(STATIC_LIB)
|
108
|
+
|
109
|
+
clean:
|
110
|
+
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
111
|
+
|
112
|
+
distclean: clean
|
113
|
+
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
114
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
115
|
+
|
116
|
+
realclean: distclean
|
117
|
+
install: install-so install-rb
|
118
|
+
|
119
|
+
install-so: $(RUBYARCHDIR)
|
120
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
121
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
122
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
123
|
+
install-rb: pre-install-rb install-rb-default
|
124
|
+
install-rb-default: pre-install-rb-default
|
125
|
+
pre-install-rb: Makefile
|
126
|
+
pre-install-rb-default: Makefile
|
127
|
+
$(RUBYARCHDIR):
|
128
|
+
$(MAKEDIRS) $@
|
129
|
+
|
130
|
+
site-install: site-install-so site-install-rb
|
131
|
+
site-install-so: install-so
|
132
|
+
site-install-rb: install-rb
|
133
|
+
|
134
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
135
|
+
|
136
|
+
.cc.o:
|
137
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
138
|
+
|
139
|
+
.cxx.o:
|
140
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
141
|
+
|
142
|
+
.cpp.o:
|
143
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
144
|
+
|
145
|
+
.C.o:
|
146
|
+
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
147
|
+
|
148
|
+
.c.o:
|
149
|
+
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
|
150
|
+
|
151
|
+
$(DLLIB): $(OBJS)
|
152
|
+
@-$(RM) $@
|
153
|
+
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
$(OBJS): ruby.h defines.h
|
data/ext/fadvise.c
CHANGED
@@ -42,8 +42,8 @@ static VALUE File_fadvise(VALUE self, VALUE offset, VALUE len, VALUE advice){
|
|
42
42
|
else if(madvice == symbols[5]) madvice=POSIX_FADV_DONTNEED;
|
43
43
|
else rb_raise(rb_Errno_EINVAL,":%s is not valid advice",rb_id2name(SYM2ID(advice)));
|
44
44
|
|
45
|
-
if (
|
46
|
-
rb_sys_fail(
|
45
|
+
if (errno=posix_fadvise(fd,NUM2OFFT(offset),NUM2OFFT(len),madvice)){
|
46
|
+
rb_sys_fail("posix_fadvise");
|
47
47
|
}
|
48
48
|
|
49
49
|
return self;
|
data/ext/fadvise.o
ADDED
Binary file
|
data/ext/fadvise.so
ADDED
Binary file
|
data/ext/mkmf.log
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
have_func: checking for posix_fadvise()... -------------------- yes
|
2
|
+
|
3
|
+
"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L. -rdynamic -Wl,-export-dynamic -lruby1.8-static -lpthread -ldl -lcrypt -lm -lc"
|
4
|
+
conftest.c: In function ‘t’:
|
5
|
+
conftest.c:3: error: ‘posix_fadvise’ undeclared (first use in this function)
|
6
|
+
conftest.c:3: error: (Each undeclared identifier is reported only once
|
7
|
+
conftest.c:3: error: for each function it appears in.)
|
8
|
+
checked program was:
|
9
|
+
/* begin */
|
10
|
+
1: /*top*/
|
11
|
+
2: int main() { return 0; }
|
12
|
+
3: int t() { void ((*volatile p)()); p = (void ((*)()))posix_fadvise; return 0; }
|
13
|
+
/* end */
|
14
|
+
|
15
|
+
"cc -o conftest -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -L. -L/usr/lib -L. -rdynamic -Wl,-export-dynamic -lruby1.8-static -lpthread -ldl -lcrypt -lm -lc"
|
16
|
+
checked program was:
|
17
|
+
/* begin */
|
18
|
+
1: /*top*/
|
19
|
+
2: int main() { return 0; }
|
20
|
+
3: int t() { posix_fadvise(); return 0; }
|
21
|
+
/* end */
|
22
|
+
|
23
|
+
--------------------
|
24
|
+
|
data/test/test.rb
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'test/unit'
|
3
|
+
require 'tempfile'
|
3
4
|
|
4
5
|
$: << File.expand_path(File.dirname(__FILE__)) + '/../ext'
|
5
6
|
require 'fadvise'
|
6
7
|
|
7
8
|
class TestFadvise < Test::Unit::TestCase
|
8
9
|
def test_symbols
|
9
|
-
f=open("
|
10
|
-
assert_nothing_thrown{ f.fadvise 0,
|
11
|
-
assert_nothing_thrown{ f.fadvise 0,
|
12
|
-
assert_nothing_thrown{ f.fadvise 0,
|
13
|
-
assert_nothing_thrown{ f.fadvise 0,
|
14
|
-
assert_nothing_thrown{ f.fadvise 0,
|
15
|
-
assert_nothing_thrown{ f.fadvise 0,
|
16
|
-
assert_raise(Errno::EINVAL){ f.fadvise 0,
|
10
|
+
f=Tempfile.open("fadvise")
|
11
|
+
assert_nothing_thrown{ f.fadvise 0,100,:normal }
|
12
|
+
assert_nothing_thrown{ f.fadvise 0,100,:sequential }
|
13
|
+
assert_nothing_thrown{ f.fadvise 0,100,:random }
|
14
|
+
assert_nothing_thrown{ f.fadvise 0,100,:no_reuse }
|
15
|
+
assert_nothing_thrown{ f.fadvise 0,100,:will_need }
|
16
|
+
assert_nothing_thrown{ f.fadvise 0,100,:dont_need }
|
17
|
+
assert_raise(Errno::EINVAL){ f.fadvise 0,100,:foobar }
|
17
18
|
f.close
|
18
19
|
end
|
19
20
|
|
20
21
|
def test_closed
|
21
22
|
f=open("/dev/zero")
|
22
|
-
assert_nothing_thrown{ f.fadvise 0,
|
23
|
+
assert_nothing_thrown{ f.fadvise 0,100,:normal }
|
23
24
|
f.close
|
24
|
-
assert_raise(IOError){ f.fadvise 0,
|
25
|
+
assert_raise(IOError){ f.fadvise 0,100,:normal }
|
25
26
|
end
|
26
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fadvise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Bloom
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-06-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,11 +22,17 @@ extensions:
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
24
|
files:
|
25
|
-
- ext/fadvise.c
|
26
25
|
- ext/extconf.rb
|
26
|
+
- ext/fadvise.c
|
27
|
+
- ext/mkmf.log
|
28
|
+
- ext/Makefile
|
29
|
+
- ext/fadvise.o
|
30
|
+
- ext/fadvise.so
|
27
31
|
- test/test.rb
|
28
32
|
has_rdoc: true
|
29
33
|
homepage:
|
34
|
+
licenses: []
|
35
|
+
|
30
36
|
post_install_message:
|
31
37
|
rdoc_options: []
|
32
38
|
|
@@ -47,9 +53,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
53
|
requirements: []
|
48
54
|
|
49
55
|
rubyforge_project:
|
50
|
-
rubygems_version: 1.
|
56
|
+
rubygems_version: 1.3.3
|
51
57
|
signing_key:
|
52
|
-
specification_version:
|
58
|
+
specification_version: 3
|
53
59
|
summary: A binding to the posix_fadvise system call
|
54
60
|
test_files: []
|
55
61
|
|