libuv 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +17 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +16 -0
  6. data/Gemfile +2 -0
  7. data/LICENSE +24 -0
  8. data/README.md +73 -0
  9. data/Rakefile +31 -0
  10. data/lib/libuv.rb +34 -0
  11. data/lib/libuv/assertions.rb +23 -0
  12. data/lib/libuv/async.rb +33 -0
  13. data/lib/libuv/check.rb +49 -0
  14. data/lib/libuv/error.rb +70 -0
  15. data/lib/libuv/ext/ext.rb +257 -0
  16. data/lib/libuv/ext/platform/darwin_x64.rb +12 -0
  17. data/lib/libuv/ext/platform/linux.rb +8 -0
  18. data/lib/libuv/ext/platform/unix.rb +14 -0
  19. data/lib/libuv/ext/platform/windows.rb +27 -0
  20. data/lib/libuv/ext/tasks.rb +27 -0
  21. data/lib/libuv/ext/tasks/mac.rb +23 -0
  22. data/lib/libuv/ext/tasks/unix.rb +23 -0
  23. data/lib/libuv/ext/tasks/win.rb +11 -0
  24. data/lib/libuv/ext/types.rb +230 -0
  25. data/lib/libuv/fs_event.rb +31 -0
  26. data/lib/libuv/handle.rb +82 -0
  27. data/lib/libuv/idle.rb +49 -0
  28. data/lib/libuv/listener.rb +34 -0
  29. data/lib/libuv/loop.rb +310 -0
  30. data/lib/libuv/net.rb +38 -0
  31. data/lib/libuv/pipe.rb +97 -0
  32. data/lib/libuv/prepare.rb +49 -0
  33. data/lib/libuv/q.rb +429 -0
  34. data/lib/libuv/resource.rb +28 -0
  35. data/lib/libuv/simple_async.rb +28 -0
  36. data/lib/libuv/stream.rb +124 -0
  37. data/lib/libuv/tcp.rb +194 -0
  38. data/lib/libuv/timer.rb +75 -0
  39. data/lib/libuv/tty.rb +34 -0
  40. data/lib/libuv/udp.rb +256 -0
  41. data/lib/libuv/version.rb +3 -0
  42. data/lib/libuv/work.rb +62 -0
  43. data/libuv.gemspec +54 -0
  44. data/spec/async_spec.rb +60 -0
  45. data/spec/defer_spec.rb +980 -0
  46. data/spec/idle_spec.rb +56 -0
  47. data/spec/pipe_spec.rb +148 -0
  48. data/spec/tcp_spec.rb +188 -0
  49. metadata +382 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Yjc3NDY3YzZhNTZjNGU3ZDM0NGE4NzQwN2YxYWI5NGRjM2JjYmQ1Zg==
5
+ data.tar.gz: !binary |-
6
+ MDY5ZWM3NDY2NGRhNTRjZjhjYjIyZGI2ZDNhN2RlNzJkMTk3MDAzYg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NzRiMjc5MjNlNDZjYTcwNGM1MTEwMDEzODVhYmNkMzk4OTQyZWNiNjA1OGRj
10
+ MTM3MTViNzM0YmQ1YzkxMzk0NWM0Mzc3YjI5MWM0Njk2OTg4NWFjNjk3YjQy
11
+ ZmQ4NTZkNWNhYmM5OWJmMmU2OTg1NmZmYmE1MjAwMjY4OGVkNTA=
12
+ data.tar.gz: !binary |-
13
+ ZWRlNjQwOGE5M2UxZjVmY2QzYmVlYjIxMTg2OGM1MTU0MGE1MzRlZjk4ODM3
14
+ Y2JiMDEzMTQ2NmU2ZTEyNjAyZmUwZGVhMDcyN2U2M2YzOTg2ZWY1NzM1YjNh
15
+ N2FlZGNjNTFkZmI3MzczODhkODBlYzEyOTUxOTZjMDRiMGY3NjI=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ html
6
+ pkg
7
+ doc
8
+ tmp
9
+ rerun.txt
10
+ Gemfile.lock
11
+ .bundle
12
+ .idea
13
+ *.rbc
14
+ .yardoc
15
+ bin
16
+ Gemfile-custom
17
+ ext/*
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "ext/libuv"]
2
+ path = ext/libuv
3
+ url = https://github.com/joyent/libuv.git
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - rbx-20mode
6
+ - jruby-19mode
7
+ - jruby-20mode
8
+ branches:
9
+ only:
10
+ - master
11
+ before_install:
12
+ - sudo apt-get install subversion
13
+ - git submodule update --init --recursive
14
+ - echo "yes" | gem uninstall ffi -a
15
+ before_script:
16
+ - rake compile
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2004-2013 Cotag Media
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is furnished
8
+ to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
21
+ ===
22
+
23
+ This license applies to all parts of uvrb (Ruby FFI bindings for libuv only)
24
+ Libuv itself [is using Node license](https://github.com/joyent/libuv/blob/master/LICENSE)
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Libuv FFI bindings for Ruby
2
+
3
+ [![Build Status](https://travis-ci.org/cotag/libuv.png?branch=master)](https://travis-ci.org/cotag/libuv)
4
+
5
+ [Libuv](https://github.com/joyent/libuv) is a cross platform asynchronous IO implementation that powers NodeJS. It supports sockets, both UDP and TCP, filesystem watch, TTY, Pipes and other asynchronous primitives like timer, check, prepare and idle.
6
+
7
+ The Libuv gem contains Libuv and a Ruby wrapper that implements [pipelined promises](http://en.wikipedia.org/wiki/Futures_and_promises#Promise_pipelining) for asynchronous flow control
8
+
9
+ ## Usage
10
+
11
+ Create a new libuv loop or use a default one
12
+
13
+ ```ruby
14
+ require 'libuv'
15
+
16
+ loop = Libuv::Loop.default
17
+ # or
18
+ # loop = Libuv::Loop.new
19
+
20
+ loop.run do
21
+ timer = loop.timer do |error|
22
+ p error if error
23
+ puts "50 seconds passed"
24
+ timer.close
25
+ loop.stop
26
+ end
27
+ timer.start(50000)
28
+ end
29
+ ```
30
+
31
+ Check out the [yard documentation](http://rubydoc.info/gems/libuv/Libuv/Loop)
32
+
33
+
34
+ ## Installation
35
+
36
+ ```Shell
37
+ gem install libuv
38
+ ```
39
+
40
+ or
41
+
42
+ ```shell
43
+ git clone https://github.com/cotag/libuv.git
44
+ cd libuv
45
+ bundle install
46
+ rake compile
47
+ ```
48
+
49
+ ### Prerequisites
50
+
51
+ * The installation requires __subversion__ to be installed on your system and available on the PATH
52
+ * Windows users will require a copy of Visual Studio 2010 or later. [Visual Studio Express](http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products) works fine.
53
+
54
+ or
55
+
56
+ if you have a compatible `libuv.(so | dylib | dll)` on the PATH already, setting the environmental variable `USE_GLOBAL_LIBUV` will prevent compiling the packaged version.
57
+
58
+
59
+ ## What's supported
60
+
61
+ * TCP
62
+ * UDP
63
+ * TTY
64
+ * Pipe
65
+ * Timer
66
+ * Prepare
67
+ * Check
68
+ * Idle
69
+ * Async
70
+ * Filesystem Events
71
+ * Errors
72
+ * Work queue (thread pool)
73
+
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'rspec/core/rake_task' # testing framework
3
+ require 'yard' # yard documentation
4
+ require 'ffi' # loads the extension
5
+ require 'rake/clean' # for the :clobber rake task
6
+ require 'libuv/ext/tasks' # platform specific rake tasks used by compile
7
+
8
+
9
+
10
+ # By default we don't run network tests
11
+ task :default => :limited_spec
12
+ RSpec::Core::RakeTask.new(:limited_spec) do |t|
13
+ # Exclude network tests and tests that won't run on java (real io)
14
+ t.rspec_opts = "--tag ~network --tag ~real_io"
15
+ end
16
+ RSpec::Core::RakeTask.new(:spec)
17
+
18
+
19
+ desc "Run all tests"
20
+ task :test => [:spec]
21
+
22
+
23
+ YARD::Rake::YardocTask.new do |t|
24
+ t.files = ['lib/**/*.rb', '-', 'ext/README.md', 'README.md']
25
+ end
26
+
27
+
28
+ desc "Compile libuv from submodule"
29
+ task :compile => ["ext/libuv.#{FFI::Platform::LIBSUFFIX}"]
30
+
31
+ CLOBBER.include("ext/libuv.#{FFI::Platform::LIBSUFFIX}")
data/lib/libuv.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'forwardable'
2
+ require 'ffi'
3
+
4
+ module Libuv
5
+ require 'libuv/ext/ext' # The libuv ffi ext
6
+ require 'libuv/q' # The promise library
7
+
8
+ autoload :Assertions, 'libuv/assertions' # Common code to check arguments
9
+ autoload :Resource, 'libuv/resource' # Common code to check for errors
10
+ autoload :Listener, 'libuv/listener' # Common callback code
11
+
12
+ autoload :Error, 'libuv/error' # List of errors (matching those in uv.h)
13
+ autoload :Net, 'libuv/net' # Common functions for tcp and udp
14
+
15
+ autoload :Handle, 'libuv/handle' # Libuv handle base class
16
+
17
+ autoload :Loop, 'libuv/loop' # The libuv reactor or event loop
18
+ autoload :Timer, 'libuv/timer' # High resolution timer
19
+ autoload :Check, 'libuv/check' # Called before processing events on the loop
20
+ autoload :Prepare, 'libuv/prepare' # Called at the end of a loop cycle
21
+ autoload :Idle, 'libuv/idle' # Called when there are no events to process
22
+ autoload :Async, 'libuv/async' # Provide a threadsafe way to signal the event loop (uses promises)
23
+ autoload :SimpleAsync, 'libuv/simple_async' # Same as above using a simple callback
24
+ autoload :Work, 'libuv/work' # Provide work to be completed on another thread (thread pool)
25
+
26
+ # Streams
27
+ autoload :Stream, 'libuv/stream'
28
+ autoload :TCP, 'libuv/tcp' # Communicate over TCP
29
+ autoload :Pipe, 'libuv/pipe' # Communicate over Pipes
30
+ autoload :TTY, 'libuv/tty' # Terminal output
31
+
32
+ autoload :UDP, 'libuv/udp' # Communicate over UDP
33
+ autoload :FSEvent, 'libuv/fs_event' # Notifies of changes to files and folders as they occur
34
+ end
@@ -0,0 +1,23 @@
1
+ module Libuv
2
+ module Assertions
3
+ MSG_NO_PROC = 'no block given'
4
+
5
+ def assert_block(proc, msg = MSG_NO_PROC)
6
+ raise ArgumentError, msg, caller if proc.nil?
7
+ end
8
+
9
+ def assert_type(type, actual, msg = nil)
10
+ if not actual.kind_of?(type)
11
+ msg ||= "value #{actual.inspect} is not a valid #{type}"
12
+ raise ArgumentError, msg, caller
13
+ end
14
+ end
15
+
16
+ def assert_boolean(actual, msg = nil)
17
+ if not (actual.kind_of?(TrueClass) || actual.kind_of?(FalseClass))
18
+ msg ||= "value #{actual.inspect} is not a valid Boolean"
19
+ raise ArgumentError, msg, caller
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ module Libuv
2
+ class Async < Handle
3
+
4
+
5
+ def initialize(loop)
6
+ @loop = loop
7
+ async_ptr = ::Libuv::Ext.create_handle(:uv_async)
8
+ error = check_result(::Libuv::Ext.async_init(loop.handle, async_ptr, callback(:on_async)))
9
+
10
+ super(async_ptr, error)
11
+ end
12
+
13
+ def call
14
+ return if @closed
15
+ error = check_result ::Libuv::Ext.async_send(handle)
16
+ reject(error) if error
17
+ end
18
+
19
+
20
+ private
21
+
22
+
23
+ def on_async(handle, status)
24
+ e = check_result(status)
25
+
26
+ if e
27
+ reject(e)
28
+ else
29
+ defer.notify(self) # notify of a call
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,49 @@
1
+ module Libuv
2
+ class Check < Handle
3
+
4
+
5
+ def initialize(loop, callback = nil, &blk)
6
+ @loop = loop
7
+ @callback = callback || blk
8
+
9
+ check_ptr = ::Libuv::Ext.create_handle(:uv_check)
10
+ error = check_result(::Libuv::Ext.check_init(loop.handle, check_ptr))
11
+
12
+ super(check_ptr, error)
13
+ end
14
+
15
+ def start
16
+ return if @closed
17
+ error = check_result ::Libuv::Ext.check_start(handle, callback(:on_check))
18
+ reject(error) if error
19
+ end
20
+
21
+ def stop
22
+ return if @closed
23
+ error = check_result ::Libuv::Ext.check_stop(handle)
24
+ reject(error) if error
25
+ end
26
+
27
+ def progress(callback = nil, &blk)
28
+ @callback = callback || blk
29
+ end
30
+
31
+
32
+ private
33
+
34
+
35
+ def on_check(handle, status)
36
+ e = check_result(status)
37
+
38
+ if e
39
+ reject(e)
40
+ else
41
+ begin
42
+ @callback.call
43
+ rescue Exception => e
44
+ @loop.log :error, :check_cb, e
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,70 @@
1
+ module Libuv
2
+ class Error < StandardError
3
+ class EACCES < Error; end
4
+ class EADDRINUSE < Error; end
5
+ class EADDRNOTAVAIL < Error; end
6
+ class EAFNOSUPPORT < Error; end
7
+ class EAGAIN < Error; end
8
+ class EAI_ADDRFAMILY < Error; end
9
+ class EAI_AGAIN < Error; end
10
+ class EAI_BADFLAGS < Error; end
11
+ class EAI_CANCELED < Error; end
12
+ class EAI_FAIL < Error; end
13
+ class EAI_FAMILY < Error; end
14
+ class EAI_MEMORY < Error; end
15
+ class EAI_NODATA < Error; end
16
+ class EAI_NONAME < Error; end
17
+ class EAI_SERVICE < Error; end
18
+ class EAI_SOCKTYPE < Error; end
19
+ class EAI_SYSTEM < Error; end
20
+ class EALREADY < Error; end
21
+ class EBADF < Error; end
22
+ class EBUSY < Error; end
23
+ class ECANCELED < Error; end
24
+ class ECHARSET < Error; end
25
+ class ECONNABORTED < Error; end
26
+ class ECONNREFUSED < Error; end
27
+ class ECONNRESET < Error; end
28
+ class EDESTADDRREQ < Error; end
29
+ class EEXIST < Error; end
30
+ class EFAULT < Error; end
31
+ class EHOSTUNREACH < Error; end
32
+ class EINTR < Error; end
33
+ class EINVAL < Error; end
34
+ class EIO < Error; end
35
+ class EISCONN < Error; end
36
+ class EISDIR < Error; end
37
+ class ELOOP < Error; end
38
+ class EMFILE < Error; end
39
+ class EMSGSIZE < Error; end
40
+ class ENAMETOOLONG < Error; end
41
+ class ENETDOWN < Error; end
42
+ class ENETUNREACH < Error; end
43
+ class ENFILE < Error; end
44
+ class ENOBUFS < Error; end
45
+ class ENODEV < Error; end
46
+ class ENOENT < Error; end
47
+ class ENOMEM < Error; end
48
+ class ENONET < Error; end
49
+ class ENOSPC < Error; end
50
+ class ENOSYS < Error; end
51
+ class ENOTCONN < Error; end
52
+ class ENOTDIR < Error; end
53
+ class ENOTEMPTY < Error; end
54
+ class ENOTSOCK < Error; end
55
+ class ENOTSUP < Error; end
56
+ class EPERM < Error; end
57
+ class EPIPE < Error; end
58
+ class EPROTO < Error; end
59
+ class EPROTONOSUPPORT < Error; end
60
+ class EPROTOTYPE < Error; end
61
+ class EROFS < Error; end
62
+ class ESHUTDOWN < Error; end
63
+ class ESPIPE < Error; end
64
+ class ESRCH < Error; end
65
+ class ETIMEDOUT < Error; end
66
+ class EXDEV < Error; end
67
+ class UNKNOWN < Error; end
68
+ class EOF < Error; end
69
+ end
70
+ end
@@ -0,0 +1,257 @@
1
+ require 'forwardable'
2
+ require 'ffi'
3
+
4
+ module Libuv
5
+ module Ext
6
+ extend Forwardable
7
+ extend FFI::Library
8
+ FFI::DEBUG = 10
9
+
10
+
11
+ # In windows each library requires its own module
12
+ module LIBC
13
+ extend FFI::Library
14
+ ffi_lib(FFI::Library::LIBC).first
15
+
16
+ attach_function :malloc, [:size_t], :pointer, :blocking => true
17
+ attach_function :free, [:pointer], :void, :blocking => true
18
+ end
19
+ def_delegators :LIBC, :malloc, :free
20
+ module_function :malloc, :free
21
+
22
+
23
+ begin
24
+ # bias the library discovery to a path inside the gem first, then
25
+ # to the usual system paths
26
+ path_to_internal_libuv = File.dirname(__FILE__) + '/../../../ext'
27
+ LIBUV_PATHS = [
28
+ path_to_internal_libuv, '/usr/local/lib', '/opt/local/lib', '/usr/lib64'
29
+ ].map{|path| "#{path}/libuv.#{FFI::Platform::LIBSUFFIX}"}
30
+ libuv = ffi_lib(LIBUV_PATHS + %w{libuv}).first
31
+ rescue LoadError
32
+ warn <<-WARNING
33
+ Unable to load this gem. The libuv library (or DLL) could not be found.
34
+ If this is a Windows platform, make sure libuv.dll is on the PATH.
35
+ For non-Windows platforms, make sure libuv is located in this search path:
36
+ #{LIBUV_PATHS.inspect}
37
+ WARNING
38
+ exit 255
39
+ end
40
+
41
+
42
+ require 'libuv/ext/types'
43
+
44
+ attach_function :version_number, :uv_version, [], :uint, :blocking => true
45
+ attach_function :version_string, :uv_version_string, [], :string, :blocking => true
46
+
47
+ attach_function :loop_new, :uv_loop_new, [], :uv_loop_t, :blocking => true
48
+ attach_function :loop_delete, :uv_loop_delete, [:uv_loop_t], :void, :blocking => true
49
+ attach_function :default_loop, :uv_default_loop, [], :uv_loop_t, :blocking => true
50
+ attach_function :run, :uv_run, [:uv_loop_t, :uv_run_mode], :int, :blocking => true
51
+ attach_function :stop, :uv_stop, [:uv_loop_t], :void, :blocking => true
52
+ #attach_function :run_once, :uv_run_once, [:uv_loop_t], :int
53
+ attach_function :update_time, :uv_update_time, [:uv_loop_t], :void, :blocking => true
54
+ attach_function :now, :uv_now, [:uv_loop_t], :int64, :blocking => true
55
+
56
+ attach_function :backend_timeout, :uv_backend_timeout, [:uv_loop_t], :int, :blocking => true
57
+ attach_function :backend_fd, :uv_backend_fd, [:uv_loop_t], :int, :blocking => true
58
+
59
+ #attach_function :last_error, :uv_last_error, [:uv_loop_t], :int
60
+ attach_function :strerror, :uv_strerror, [:int], :string, :blocking => true
61
+ attach_function :err_name, :uv_err_name, [:int], :string, :blocking => true
62
+
63
+ attach_function :ref, :uv_ref, [:uv_handle_t], :void, :blocking => true
64
+ attach_function :unref, :uv_unref, [:uv_handle_t], :void, :blocking => true
65
+ attach_function :has_ref, :uv_has_ref, [:uv_handle_t], :int, :blocking => true
66
+ attach_function :is_active, :uv_is_active, [:uv_handle_t], :int, :blocking => true
67
+ attach_function :walk, :uv_walk, [:uv_loop_t, :uv_walk_cb, :pointer], :void, :blocking => true
68
+ attach_function :close, :uv_close, [:uv_handle_t, :uv_close_cb], :void, :blocking => true
69
+ attach_function :is_closing, :uv_is_closing, [:uv_handle_t], :int, :blocking => true
70
+
71
+ attach_function :buf_init, :uv_buf_init, [:pointer, :size_t], :uv_buf_t, :blocking => true
72
+ attach_function :strlcpy, :uv_strlcpy, [:string, :string, :size_t], :size_t, :blocking => true
73
+ attach_function :strlcat, :uv_strlcat, [:string, :string, :size_t], :size_t, :blocking => true
74
+
75
+ attach_function :listen, :uv_listen, [:uv_stream_t, :int, :uv_connection_cb], :int, :blocking => true
76
+ attach_function :accept, :uv_accept, [:uv_stream_t, :uv_stream_t], :int, :blocking => true
77
+ attach_function :read_start, :uv_read_start, [:uv_stream_t, :uv_alloc_cb, :uv_read_cb], :int, :blocking => true
78
+ attach_function :read_stop, :uv_read_stop, [:uv_stream_t], :int, :blocking => true
79
+ attach_function :read2_start, :uv_read2_start, [:uv_stream_t, :uv_alloc_cb, :uv_read2_cb], :int, :blocking => true
80
+ attach_function :write, :uv_write, [:uv_write_t, :uv_stream_t, :pointer, :int, :uv_write_cb], :int, :blocking => true
81
+ attach_function :write2, :uv_write2, [:uv_write_t, :uv_stream_t, :pointer, :int, :uv_stream_t, :uv_write_cb], :int, :blocking => true
82
+ attach_function :is_readable, :uv_is_readable, [:uv_stream_t], :int, :blocking => true
83
+ attach_function :is_writable, :uv_is_writable, [:uv_stream_t], :int, :blocking => true
84
+ attach_function :shutdown, :uv_shutdown, [:uv_shutdown_t, :uv_stream_t, :uv_shutdown_cb], :int, :blocking => true
85
+
86
+ attach_function :tcp_init, :uv_tcp_init, [:uv_loop_t, :uv_tcp_t], :int, :blocking => true
87
+ #attach_function :tcp_open, :uv_tcp_open, [:uv_tcp_t, :uv_os_sock_t], :int
88
+ attach_function :tcp_nodelay, :uv_tcp_nodelay, [:uv_tcp_t, :int], :int, :blocking => true
89
+ attach_function :tcp_keepalive, :uv_tcp_keepalive, [:uv_tcp_t, :int, :uint], :int, :blocking => true
90
+ attach_function :tcp_simultaneous_accepts, :uv_tcp_simultaneous_accepts, [:uv_tcp_t, :int], :int, :blocking => true
91
+ attach_function :tcp_bind, :uv_tcp_bind, [:uv_tcp_t, :sockaddr_in], :int, :blocking => true
92
+ attach_function :tcp_bind6, :uv_tcp_bind6, [:uv_tcp_t, :sockaddr_in6], :int, :blocking => true
93
+ attach_function :tcp_getsockname, :uv_tcp_getsockname, [:uv_tcp_t, :pointer, :pointer], :int, :blocking => true
94
+ attach_function :tcp_getpeername, :uv_tcp_getpeername, [:uv_tcp_t, :pointer, :pointer], :int, :blocking => true
95
+ attach_function :tcp_connect, :uv_tcp_connect, [:uv_connect_t, :uv_tcp_t, :sockaddr_in, :uv_connect_cb], :int, :blocking => true
96
+ attach_function :tcp_connect6, :uv_tcp_connect6, [:uv_connect_t, :uv_tcp_t, :sockaddr_in6, :uv_connect_cb], :int, :blocking => true
97
+
98
+ attach_function :udp_init, :uv_udp_init, [:uv_loop_t, :uv_udp_t], :int, :blocking => true
99
+ attach_function :udp_bind, :uv_udp_bind, [:uv_udp_t, :sockaddr_in, :uint], :int, :blocking => true
100
+ attach_function :udp_bind6, :uv_udp_bind6, [:uv_udp_t, :sockaddr_in6, :uint], :int, :blocking => true
101
+ attach_function :udp_getsockname, :uv_udp_getsockname, [:uv_udp_t, :pointer, :pointer], :int, :blocking => true
102
+ attach_function :udp_set_membership, :uv_udp_set_membership, [:uv_udp_t, :string, :string, :uv_membership], :int, :blocking => true
103
+ attach_function :udp_set_multicast_loop, :uv_udp_set_multicast_loop, [:uv_udp_t, :int], :int, :blocking => true
104
+ attach_function :udp_set_multicast_ttl, :uv_udp_set_multicast_ttl, [:uv_udp_t, :int], :int, :blocking => true
105
+ attach_function :udp_set_broadcast, :uv_udp_set_broadcast, [:uv_udp_t, :int], :int, :blocking => true
106
+ attach_function :udp_set_ttl, :uv_udp_set_ttl, [:uv_udp_t, :int], :int, :blocking => true
107
+ attach_function :udp_send, :uv_udp_send, [:uv_udp_send_t, :uv_udp_t, :pointer, :int, :sockaddr_in, :uv_udp_send_cb], :int, :blocking => true
108
+ attach_function :udp_send6, :uv_udp_send6, [:uv_udp_send_t, :uv_udp_t, :pointer, :int, :sockaddr_in6, :uv_udp_send_cb], :int, :blocking => true
109
+ attach_function :udp_recv_start, :uv_udp_recv_start, [:uv_udp_t, :uv_alloc_cb, :uv_udp_recv_cb], :int, :blocking => true
110
+ attach_function :udp_recv_stop, :uv_udp_recv_stop, [:uv_udp_t], :int, :blocking => true
111
+
112
+ attach_function :tty_init, :uv_tty_init, [:uv_loop_t, :uv_tty_t, :uv_file, :int], :int, :blocking => true
113
+ attach_function :tty_set_mode, :uv_tty_set_mode, [:uv_tty_t, :int], :int, :blocking => true
114
+ attach_function :tty_reset_mode, :uv_tty_reset_mode, [], :void, :blocking => true
115
+ attach_function :tty_get_winsize, :uv_tty_get_winsize, [:uv_tty_t, :pointer, :pointer], :int, :blocking => true
116
+
117
+ attach_function :guess_handle, :uv_guess_handle, [:uv_file], :uv_handle_type, :blocking => true
118
+
119
+ attach_function :pipe_init, :uv_pipe_init, [:uv_loop_t, :uv_pipe_t, :int], :int, :blocking => true
120
+ attach_function :pipe_open, :uv_pipe_open, [:uv_pipe_t, :uv_file], :void, :blocking => true
121
+ attach_function :pipe_bind, :uv_pipe_bind, [:uv_pipe_t, :string], :int, :blocking => true
122
+ attach_function :pipe_connect, :uv_pipe_connect, [:uv_connect_t, :uv_pipe_t, :string, :uv_connect_cb], :void, :blocking => true
123
+ attach_function :pipe_pending_instances, :uv_pipe_pending_instances, [:uv_pipe_t, :int], :void, :blocking => true
124
+
125
+ attach_function :prepare_init, :uv_prepare_init, [:uv_loop_t, :uv_prepare_t], :int, :blocking => true
126
+ attach_function :prepare_start, :uv_prepare_start, [:uv_prepare_t, :uv_prepare_cb], :int, :blocking => true
127
+ attach_function :prepare_stop, :uv_prepare_stop, [:uv_prepare_t], :int, :blocking => true
128
+
129
+ attach_function :check_init, :uv_check_init, [:uv_loop_t, :uv_check_t], :int, :blocking => true
130
+ attach_function :check_start, :uv_check_start, [:uv_check_t, :uv_check_cb], :int, :blocking => true
131
+ attach_function :check_stop, :uv_check_stop, [:uv_check_t], :int, :blocking => true
132
+
133
+ attach_function :idle_init, :uv_idle_init, [:uv_loop_t, :uv_idle_t], :int, :blocking => true
134
+ attach_function :idle_start, :uv_idle_start, [:uv_idle_t, :uv_idle_cb], :int, :blocking => true
135
+ attach_function :idle_stop, :uv_idle_stop, [:uv_idle_t], :int, :blocking => true
136
+
137
+ attach_function :async_init, :uv_async_init, [:uv_loop_t, :uv_async_t, :uv_async_cb], :int, :blocking => true
138
+ attach_function :async_send, :uv_async_send, [:uv_async_t], :int, :blocking => true
139
+
140
+ attach_function :timer_init, :uv_timer_init, [:uv_loop_t, :uv_timer_t], :int, :blocking => true
141
+ attach_function :timer_start, :uv_timer_start, [:uv_timer_t, :uv_timer_cb, :int64_t, :int64_t], :int, :blocking => true
142
+ attach_function :timer_stop, :uv_timer_stop, [:uv_timer_t], :int, :blocking => true
143
+ attach_function :timer_again, :uv_timer_again, [:uv_timer_t], :int, :blocking => true
144
+ attach_function :timer_set_repeat, :uv_timer_set_repeat, [:uv_timer_t, :int64_t], :void, :blocking => true
145
+ attach_function :timer_get_repeat, :uv_timer_get_repeat, [:uv_timer_t], :int64_t, :blocking => true
146
+
147
+ #attach_function :ares_init_options, :uv_ares_init_options, [:uv_loop_t, :ares_channel, :ares_options, :int], :int
148
+ #attach_function :ares_destroy, :uv_ares_destroy, [:uv_loop_t, :ares_channel], :void
149
+
150
+ attach_function :getaddrinfo, :uv_getaddrinfo, [:uv_loop_t, :uv_getaddrinfo_t, :uv_getaddrinfo_cb, :string, :string, :addrinfo], :int, :blocking => true
151
+ attach_function :freeaddrinfo, :uv_freeaddrinfo, [:addrinfo], :void, :blocking => true
152
+
153
+ attach_function :spawn, :uv_spawn, [:uv_loop_t, :uv_process_t, :uv_options_t], :int, :blocking => true
154
+ attach_function :process_kill, :uv_process_kill, [:uv_process_t, :int], :int, :blocking => true
155
+ attach_function :kill, :uv_kill, [:int, :int], :int, :blocking => true
156
+ attach_function :queue_work, :uv_queue_work, [:uv_loop_t, :uv_work_t, :uv_work_cb, :uv_after_work_cb], :int, :blocking => true
157
+ attach_function :cancel, :uv_cancel, [:pointer], :int, :blocking => true
158
+ attach_function :setup_args, :uv_setup_args, [:int, :varargs], :pointer, :blocking => true
159
+ attach_function :get_process_title, :uv_get_process_title, [:pointer, :size_t], :int, :blocking => true
160
+ attach_function :set_process_title, :uv_set_process_title, [:string], :int, :blocking => true
161
+ attach_function :resident_set_memory, :uv_resident_set_memory, [:size_t], :int, :blocking => true
162
+
163
+ attach_function :uptime, :uv_uptime, [:pointer], :int, :blocking => true
164
+ attach_function :cpu_info, :uv_cpu_info, [:uv_cpu_info_t, :pointer], :int, :blocking => true
165
+ attach_function :loadavg, :uv_loadavg, [:pointer], :void, :blocking => true
166
+ attach_function :free_cpu_info, :uv_free_cpu_info, [:uv_cpu_info_t, :int], :void, :blocking => true
167
+ attach_function :interface_addresses, :uv_interface_addresses, [:uv_interface_address_t, :pointer], :int, :blocking => true
168
+ attach_function :free_interface_addresses, :uv_free_interface_addresses, [:uv_interface_address_t, :int], :void, :blocking => true
169
+
170
+ #attach_function :fs_req_result, :uv_fs_req_result, [:uv_fs_t], :ssize_t
171
+ #attach_function :fs_req_stat, :uv_fs_req_stat, [:uv_fs_t], :uv_fs_stat_t
172
+ #attach_function :fs_req_pointer, :uv_fs_req_pointer, [:uv_fs_t], :pointer
173
+
174
+ attach_function :fs_req_cleanup, :uv_fs_req_cleanup, [:uv_fs_t], :void, :blocking => true
175
+ attach_function :fs_close, :uv_fs_close, [:uv_loop_t, :uv_fs_t, :uv_file, :uv_fs_cb], :int, :blocking => true
176
+ attach_function :fs_open, :uv_fs_open, [:uv_loop_t, :uv_fs_t, :string, :int, :int, :uv_fs_cb], :int, :blocking => true
177
+ attach_function :fs_read, :uv_fs_read, [:uv_loop_t, :uv_fs_t, :uv_file, :string, :size_t, :off_t, :uv_fs_cb], :int, :blocking => true
178
+ attach_function :fs_unlink, :uv_fs_unlink, [:uv_loop_t, :uv_fs_t, :string, :uv_fs_cb], :int, :blocking => true
179
+ attach_function :fs_write, :uv_fs_write, [:uv_loop_t, :uv_fs_t, :uv_file, :string, :size_t, :off_t, :uv_fs_cb], :int, :blocking => true
180
+ attach_function :fs_mkdir, :uv_fs_mkdir, [:uv_loop_t, :uv_fs_t, :string, :int, :uv_fs_cb], :int, :blocking => true
181
+ attach_function :fs_rmdir, :uv_fs_rmdir, [:uv_loop_t, :uv_fs_t, :string, :uv_fs_cb], :int, :blocking => true
182
+ attach_function :fs_readdir, :uv_fs_readdir, [:uv_loop_t, :uv_fs_t, :string, :int, :uv_fs_cb], :int, :blocking => true
183
+ attach_function :fs_stat, :uv_fs_stat, [:uv_loop_t, :uv_fs_t, :string, :uv_fs_cb], :int, :blocking => true
184
+ attach_function :fs_fstat, :uv_fs_fstat, [:uv_loop_t, :uv_fs_t, :uv_file, :uv_fs_cb], :int, :blocking => true
185
+ attach_function :fs_rename, :uv_fs_rename, [:uv_loop_t, :uv_fs_t, :string, :string, :uv_fs_cb], :int, :blocking => true
186
+ attach_function :fs_fsync, :uv_fs_fsync, [:uv_loop_t, :uv_fs_t, :uv_file, :uv_fs_cb], :int, :blocking => true
187
+ attach_function :fs_fdatasync, :uv_fs_fdatasync, [:uv_loop_t, :uv_fs_t, :uv_file, :uv_fs_cb], :int, :blocking => true
188
+ attach_function :fs_ftruncate, :uv_fs_ftruncate, [:uv_loop_t, :uv_fs_t, :uv_file, :off_t, :uv_fs_cb], :int, :blocking => true
189
+ attach_function :fs_sendfile, :uv_fs_sendfile, [:uv_loop_t, :uv_fs_t, :uv_file, :uv_file, :off_t, :size_t, :uv_fs_cb], :int, :blocking => true
190
+ attach_function :fs_chmod, :uv_fs_chmod, [:uv_loop_t, :uv_fs_t, :string, :int, :uv_fs_cb], :int, :blocking => true
191
+ attach_function :fs_utime, :uv_fs_utime, [:uv_loop_t, :uv_fs_t, :string, :double, :double, :uv_fs_cb], :int, :blocking => true
192
+ attach_function :fs_futime, :uv_fs_futime, [:uv_loop_t, :uv_fs_t, :uv_file, :double, :double, :uv_fs_cb], :int, :blocking => true
193
+ attach_function :fs_lstat, :uv_fs_lstat, [:uv_loop_t, :uv_fs_t, :string, :uv_fs_cb], :int, :blocking => true
194
+ attach_function :fs_link, :uv_fs_link, [:uv_loop_t, :uv_fs_t, :string, :string, :uv_fs_cb], :int, :blocking => true
195
+ attach_function :fs_symlink, :uv_fs_symlink, [:uv_loop_t, :uv_fs_t, :string, :string, :int, :uv_fs_cb], :int, :blocking => true
196
+ attach_function :fs_readlink, :uv_fs_readlink, [:uv_loop_t, :uv_fs_t, :string, :uv_fs_cb], :int, :blocking => true
197
+ attach_function :fs_fchmod, :uv_fs_fchmod, [:uv_loop_t, :uv_fs_t, :uv_file, :int, :uv_fs_cb], :int, :blocking => true
198
+ attach_function :fs_chown, :uv_fs_chown, [:uv_loop_t, :uv_fs_t, :string, :int, :int, :uv_fs_cb], :int, :blocking => true
199
+ attach_function :fs_fchown, :uv_fs_fchown, [:uv_loop_t, :uv_fs_t, :uv_file, :int, :int, :uv_fs_cb], :int, :blocking => true
200
+
201
+ attach_function :fs_event_init, :uv_fs_event_init, [:uv_loop_t, :uv_fs_event_t, :string, :uv_fs_event_cb, :int], :int, :blocking => true
202
+
203
+ attach_function :ip4_addr, :uv_ip4_addr, [:string, :int], :sockaddr_in, :blocking => true
204
+ attach_function :ip6_addr, :uv_ip6_addr, [:string, :int], :sockaddr_in6, :blocking => true
205
+ attach_function :ip4_name, :uv_ip4_name, [SockaddrIn.by_ref, :pointer, :size_t], :int, :blocking => true
206
+ attach_function :ip6_name, :uv_ip6_name, [SockaddrIn6.by_ref, :pointer, :size_t], :int, :blocking => true
207
+ #TODO:: attach_function :inet_ntop, :uv_inet_ntop, [:int, :pointer, ]
208
+ #TODO:: attach_function :uv_inet_pton
209
+
210
+ attach_function :exepath, :uv_exepath, [:pointer, :size_t], :int, :blocking => true
211
+ attach_function :cwd, :uv_cwd, [:pointer, :size_t], :int, :blocking => true
212
+ attach_function :chdir, :uv_chdir, [:string], :int, :blocking => true
213
+ attach_function :get_free_memory, :uv_get_free_memory, [], :uint64, :blocking => true
214
+ attach_function :get_total_memory, :uv_get_total_memory, [], :uint64, :blocking => true
215
+ attach_function :hrtime, :uv_hrtime, [], :uint64, :blocking => true
216
+ attach_function :disable_stdio_inheritance, :uv_disable_stdio_inheritance, [], :void, :blocking => true
217
+ attach_function :dlopen, :uv_dlopen, [:string, :uv_lib_t], :int, :blocking => true
218
+ attach_function :dlclose, :uv_dlclose, [:uv_lib_t], :int, :blocking => true
219
+ attach_function :dlsym, :uv_dlsym, [:uv_lib_t, :string, :pointer], :int, :blocking => true
220
+ #attach_function :dlerror, :uv_dlerror, [:uv_lib_t], :string
221
+ #attach_function :dlerror_free, :uv_dlerror_free, [:uv_lib_t, :string], :void
222
+
223
+ attach_function :mutex_init, :uv_mutex_init, [:uv_mutex_t], :int, :blocking => true
224
+ attach_function :mutex_destroy, :uv_mutex_destroy, [:uv_mutex_t], :void, :blocking => true
225
+ attach_function :mutex_lock, :uv_mutex_lock, [:uv_mutex_t], :void, :blocking => true
226
+ attach_function :mutex_trylock, :uv_mutex_trylock, [:uv_mutex_t], :int, :blocking => true
227
+ attach_function :mutex_unlock, :uv_mutex_unlock, [:uv_mutex_t], :void, :blocking => true
228
+
229
+ attach_function :rwlock_init, :uv_rwlock_init, [:uv_rwlock_t], :int, :blocking => true
230
+ attach_function :rwlock_destroy, :uv_rwlock_destroy, [:uv_rwlock_t], :void, :blocking => true
231
+ attach_function :rwlock_rdlock, :uv_rwlock_rdlock, [:uv_rwlock_t], :void, :blocking => true
232
+ attach_function :rwlock_tryrdlock, :uv_rwlock_tryrdlock, [:uv_rwlock_t], :int, :blocking => true
233
+ attach_function :rwlock_rdunlock, :uv_rwlock_rdunlock, [:uv_rwlock_t], :void, :blocking => true
234
+ attach_function :rwlock_wrlock, :uv_rwlock_wrlock, [:uv_rwlock_t], :void, :blocking => true
235
+ attach_function :rwlock_trywrlock, :uv_rwlock_trywrlock, [:uv_rwlock_t], :int, :blocking => true
236
+ attach_function :rwlock_wrunlock, :uv_rwlock_wrunlock, [:uv_rwlock_t], :void, :blocking => true
237
+
238
+ attach_function :once, :uv_once, [:uv_once_t, :uv_cb], :void, :blocking => true
239
+ attach_function :thread_create, :uv_thread_create, [:uv_thread_t, :uv_cb], :int, :blocking => true
240
+ attach_function :thread_join, :uv_thread_join, [:uv_thread_t], :int, :blocking => true
241
+
242
+ attach_function :handle_size, :uv_handle_size, [:uv_handle_type], :size_t, :blocking => true
243
+ attach_function :req_size, :uv_req_size, [:uv_req_type], :size_t, :blocking => true
244
+
245
+ # This function is attached differently in windows - see ./types/windows.rb
246
+ attach_function :ntohs, [:ushort], :ushort, :blocking => true unless FFI::Platform.windows?
247
+
248
+
249
+ def self.create_handle(type)
250
+ LIBC.malloc(Ext.handle_size(type))
251
+ end
252
+
253
+ def self.create_request(type)
254
+ LIBC.malloc(Ext.req_size(type))
255
+ end
256
+ end
257
+ end