io_splice 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,6 @@
1
+ README
2
+ LICENSE
3
+ NEWS
4
+ ChangeLog
5
+ lib
6
+ ext/io_splice/io_splice_ext.c
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ *.o
2
+ *.so
3
+ *.log
4
+ *.rbc
5
+ Makefile
6
+ /GIT-VERSION-FILE
7
+ /local.mk
8
+ /NEWS
9
+ /ChangeLog
10
+ /.manifest
11
+ /GIT-VERSION-FILE
12
+ /man
13
+ /pkg
14
+ /doc
data/COPYING ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/GIT-VERSION-GEN ADDED
@@ -0,0 +1,40 @@
1
+ #!/bin/sh
2
+
3
+ GVF=GIT-VERSION-FILE
4
+ DEF_VER=v0.1.0.GIT
5
+
6
+ LF='
7
+ '
8
+
9
+ # First see if there is a version file (included in release tarballs),
10
+ # then try git-describe, then default.
11
+ if test -f version
12
+ then
13
+ VN=$(cat version) || VN="$DEF_VER"
14
+ elif test -d .git -o -f .git &&
15
+ VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
16
+ case "$VN" in
17
+ *$LF*) (exit 1) ;;
18
+ v[0-9]*)
19
+ git update-index -q --refresh
20
+ test -z "$(git diff-index --name-only HEAD --)" ||
21
+ VN="$VN-dirty" ;;
22
+ esac
23
+ then
24
+ VN=$(echo "$VN" | sed -e 's/-/./g');
25
+ else
26
+ VN="$DEF_VER"
27
+ fi
28
+
29
+ VN=$(expr "$VN" : v*'\(.*\)')
30
+
31
+ if test -r $GVF
32
+ then
33
+ VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
34
+ else
35
+ VC=unset
36
+ fi
37
+ test "$VN" = "$VC" || {
38
+ echo >&2 "GIT_VERSION = $VN"
39
+ echo "GIT_VERSION = $VN" >$GVF
40
+ }
data/GNUmakefile ADDED
@@ -0,0 +1,169 @@
1
+ # use GNU Make to run tests in parallel, and without depending on RubyGems
2
+ all::
3
+ RUBY = ruby
4
+ RAKE = rake
5
+ GIT_URL = git://git.bogomips.org/ruby_io_splice.git
6
+
7
+ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
8
+ @./GIT-VERSION-GEN
9
+ -include GIT-VERSION-FILE
10
+ -include local.mk
11
+ ifeq ($(DLEXT),) # "so" for Linux
12
+ DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
13
+ endif
14
+ ifeq ($(RUBY_VERSION),)
15
+ RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
16
+ endif
17
+
18
+ install: $(bins)
19
+ $(prep_setup_rb)
20
+ $(RM) -r .install-tmp
21
+ mkdir .install-tmp
22
+ cp -p bin/* .install-tmp
23
+ $(RUBY) setup.rb all
24
+ $(RM) $^
25
+ mv .install-tmp/* bin/
26
+ $(RM) -r .install-tmp
27
+ $(prep_setup_rb)
28
+
29
+ setup_rb_files := .config InstalledFiles
30
+ prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
31
+
32
+ clean:
33
+ -$(MAKE) -C ext/io_splice clean
34
+ $(RM) $(setup_rb_files) ext/io_splice/Makefile
35
+
36
+ pkg_extra := GIT-VERSION-FILE NEWS ChangeLog
37
+ manifest: $(pkg_extra)
38
+ $(RM) .manifest
39
+ $(MAKE) .manifest
40
+
41
+ .manifest:
42
+ (git ls-files && \
43
+ for i in $@ $(pkg_extra) $(man1_paths); \
44
+ do echo $$i; done) | LC_ALL=C sort > $@+
45
+ cmp $@+ $@ || mv $@+ $@
46
+ $(RM) $@+
47
+
48
+ NEWS: GIT-VERSION-FILE
49
+ $(RAKE) -s news_rdoc > $@+
50
+ mv $@+ $@
51
+
52
+ SINCE =
53
+ ChangeLog: LOG_VERSION = \
54
+ $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
55
+ echo $(GIT_VERSION) || git describe)
56
+ ifneq ($(SINCE),)
57
+ ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
58
+ endif
59
+ ChangeLog: GIT-VERSION-FILE
60
+ @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
61
+ @echo >> $@+
62
+ git log $(log_range) | sed -e 's/^/ /' >> $@+
63
+ mv $@+ $@
64
+
65
+ news_atom := http://bogomips.org/ruby_io_splice/NEWS.atom.xml
66
+ cgit_atom := http://git.bogomips.org/cgit/ruby_io_splice.git/atom/?h=master
67
+ atom = <link rel="alternate" title="Atom feed" href="$(1)" \
68
+ type="application/atom+xml"/>
69
+
70
+ # using rdoc 2.4.1+
71
+ doc: .document NEWS ChangeLog
72
+ for i in $(man1_bins); do > $$i; done
73
+ rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
74
+ install -m644 COPYING doc/COPYING
75
+ install -m644 $(shell grep '^[A-Z]' .document) doc/
76
+ cd doc && for i in $(base_bins); do \
77
+ html=$$(echo $$i | sed 's/\.rb/_rb/')_1.html; \
78
+ sed -e '/"documentation">/r man1/'$$i'.1.html' \
79
+ < $$html > tmp && mv tmp $$html; done
80
+ $(RUBY) -i -p -e \
81
+ '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
82
+ doc/ChangeLog.html
83
+ $(RUBY) -i -p -e \
84
+ '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
85
+ doc/NEWS.html doc/README.html
86
+ $(RAKE) -s news_atom > doc/NEWS.atom.xml
87
+ cd doc && ln README.html tmp && mv tmp index.html
88
+ $(RM) $(man1_bins)
89
+
90
+ ifneq ($(VERSION),)
91
+ rfproject := qrp
92
+ rfpackage := io_splice
93
+ pkggem := pkg/$(rfpackage)-$(VERSION).gem
94
+ pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
95
+ release_notes := release_notes-$(VERSION)
96
+ release_changes := release_changes-$(VERSION)
97
+
98
+ release-notes: $(release_notes)
99
+ release-changes: $(release_changes)
100
+ $(release_changes):
101
+ $(RAKE) -s release_changes > $@+
102
+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
103
+ $(release_notes):
104
+ GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
105
+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
106
+
107
+ # ensures we're actually on the tagged $(VERSION), only used for release
108
+ verify:
109
+ test x"$(shell umask)" = x0022
110
+ git rev-parse --verify refs/tags/v$(VERSION)^{}
111
+ git diff-index --quiet HEAD^0
112
+ test `git rev-parse --verify HEAD^0` = \
113
+ `git rev-parse --verify refs/tags/v$(VERSION)^{}`
114
+
115
+ fix-perms:
116
+ -git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
117
+ -git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
118
+
119
+ gem: $(pkggem)
120
+
121
+ install-gem: $(pkggem)
122
+ gem install $(CURDIR)/$<
123
+
124
+ $(pkggem): manifest fix-perms
125
+ gem build $(rfpackage).gemspec
126
+ mkdir -p pkg
127
+ mv $(@F) $@
128
+
129
+ $(pkgtgz): distdir = $(basename $@)
130
+ $(pkgtgz): HEAD = v$(VERSION)
131
+ $(pkgtgz): manifest fix-perms
132
+ @test -n "$(distdir)"
133
+ $(RM) -r $(distdir)
134
+ mkdir -p $(distdir)
135
+ tar c `cat .manifest` | (cd $(distdir) && tar x)
136
+ cd pkg && tar c $(basename $(@F)) | gzip -9 > $(@F)+
137
+ mv $@+ $@
138
+
139
+ package: $(pkgtgz) $(pkggem)
140
+
141
+ test-release: verify package $(release_notes) $(release_changes)
142
+ release: verify package $(release_notes) $(release_changes)
143
+ # make tgz release on RubyForge
144
+ rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
145
+ $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
146
+ # push gem to Gemcutter
147
+ gem push $(pkggem)
148
+ # in case of gem downloads from RubyForge releases page
149
+ -rubyforge add_file \
150
+ $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
151
+ else
152
+ gem install-gem: GIT-VERSION-FILE
153
+ $(MAKE) $@ VERSION=$(GIT_VERSION)
154
+ endif
155
+
156
+ ext := ext/io_splice/io_splice_ext.$(DLEXT)
157
+ ext/io_splice/Makefile: ext/io_splice/extconf.rb
158
+ cd $(@D) && $(RUBY) extconf.rb
159
+ $(ext): $(wildcard $(addprefix ext/io_splice/,*.c *.h)) ext/io_splice/Makefile
160
+ $(MAKE) -C $(@D)
161
+
162
+ all:: test
163
+
164
+ build: $(ext)
165
+ test: test-unit
166
+ test-unit: build
167
+ $(RUBY) -I lib:ext/io_splice test/test_io_splice.rb
168
+
169
+ .PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ io_splice is copyrighted Free Software by all contributors, see logs in
2
+ revision control for names and email addresses of all of them.
3
+
4
+ You can redistribute it and/or modify it under either the terms of the GNU
5
+ Lesser General Public License as published by the Free Software Foundation,
6
+ version 3.0 {LGPLv3}[http://www.gnu.org/licenses/lgpl-3.0.txt] (see
7
+ link:COPYING).
8
+
9
+ posix_mq is distributed in the hope that it will be useful, but WITHOUT
10
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12
+ License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with the GNU C Library; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
data/README ADDED
@@ -0,0 +1,87 @@
1
+ = io_splice - zero-copy pipe I/O for Linux and Ruby
2
+
3
+ The splice family of Linux system calls can transfer data between file
4
+ descriptors without the need to copy data into userspace. Instead of a
5
+ userspace buffer, they rely on an ordinary Unix pipe as a kernel-level
6
+ buffer.
7
+
8
+ == Features
9
+
10
+ * Efficient zero-copy I/O avoids data copies into userspace,
11
+ reducing garbage for the Ruby garbage collector as a side effect.
12
+
13
+ * More flexible than sendfile, may be used to enable copies between
14
+ arbitrary file descriptors (assuming kernel support), not just
15
+ socket-to-file.
16
+
17
+ * Thread-safe blocking operations under Ruby 1.9, releases GVL
18
+ if blocking operations are used.
19
+
20
+ * Safely usable with non-blocking I/O frameworks (unlike IO.copy_stream)
21
+ when combined with the IO::Splice::F_NONBLOCK flag.
22
+
23
+ * Fully-documented library API and
24
+ {examples}[http://bogomips.org/ruby_io_splice/examples/]
25
+
26
+ == Install
27
+
28
+ Operating system support for the splice(2), tee(2) and vmsplice(2)
29
+ system calls is required. Currently, only Linux 2.6.17 or later with a
30
+ modern C library (glibc 2.5 or later) support these system calls. Using
31
+ the latest stable Linux kernel is *HIGHLY* recommended as there have
32
+ been numerous bugs in the early releases of these system calls.
33
+
34
+ If you're using a packaged Ruby distribution, make sure you have a C
35
+ compiler and the matching Ruby development libraries and headers.
36
+
37
+ If you use RubyGems:
38
+
39
+ gem install io_splice
40
+
41
+ Otherwise grab the latest tarball from:
42
+
43
+ http://bogomips.org/ruby_io_splice/files/
44
+
45
+ Unpack it, and run "ruby setup.rb"
46
+
47
+ == Usage
48
+
49
+ Our API matches the C API closely, see the RDoc for full API
50
+ documentation and the Linux manpages for more details.
51
+
52
+ All of these system calls are fairly new have seen limited usage
53
+ anywhere, even outside of the Ruby world.
54
+
55
+ If you encounter problems (privilege escalation, memory leaks (in the
56
+ kernel), poor performance, corrupt data, etc..), try upgrading the Linux
57
+ kernel to the latest stable version.
58
+
59
+ These system calls have a lot of potential, and will hopefully be
60
+ standardized and available in non-Linux kernels some day.
61
+
62
+ == Development
63
+
64
+ You can get the latest source via git from the following locations:
65
+
66
+ git://git.bogomips.org/ruby_io_splice.git
67
+ git://repo.or.cz/ruby_io_splice.git (mirror)
68
+
69
+ You may browse the code from the web and download the latest snapshot
70
+ tarballs here:
71
+
72
+ * http://git.bogomips.org/cgit/ruby_io_splice.git (cgit)
73
+ * http://repo.or.cz/w/ruby_io_splice.git (gitweb)
74
+
75
+ Inline patches (from "git format-patch") to the mailing list are
76
+ preferred because they allow code review and comments in the reply to
77
+ the patch.
78
+
79
+ We will adhere to mostly the same conventions for patch submissions as
80
+ git itself. See the Documentation/SubmittingPatches document
81
+ distributed with git on on patch submission guidelines to follow. Just
82
+ don't email the git mailing list or maintainer with io_splice patches.
83
+
84
+ == Contact
85
+
86
+ All feedback (bug reports, user/development discussion, patches, pull
87
+ requests) go to the mailing list: mailto:ruby.io.splice@librelist.com