lib/ffi/libc/libc.rb in ffi-libc-0.0.4 vs lib/ffi/libc/libc.rb in ffi-libc-0.0.5
- old
+ new
@@ -31,12 +31,17 @@
attach_function :free, [:pointer], :void
attach_function :realloc, [:pointer, :size_t], :pointer
attach_function :getenv, [:string], :string
attach_function :putenv, [:string], :int
attach_function :unsetenv, [:string], :int
- attach_function :clearenv, [], :int
+ begin
+ attach_function :clearenv, [], :int
+ rescue FFI::NotFoundError
+ # clearenv is not available on OSX
+ end
+
# time.h
attach_function :time, [:pointer], :time_t
# sys/time.h
attach_function :gettimeofday, [:pointer, :pointer], :int
@@ -50,25 +55,34 @@
attach_function :bzero, [:pointer, :size_t], :void
attach_function :memset, [:pointer, :int, :size_t], :pointer
attach_function :memcpy, [:pointer, :pointer, :size_t], :pointer
attach_function :memcmp, [:pointer, :pointer, :size_t], :int
attach_function :memchr, [:pointer, :int, :size_t], :pointer
- attach_function :memrchr, [:pointer, :int, :size_t], :pointer
+
+ begin
+ attach_function :memrchr, [:pointer, :int, :size_t], :pointer
+ rescue FFI::NotFoundError
+ # memrchr is not available on OSX
+ end
+
attach_function :strcpy, [:string, :string], :pointer
attach_function :strncpy, [:string, :string, :size_t], :pointer
attach_function :strlen, [:string], :size_t
attach_function :index, [:string, :int], :string
attach_function :rindex, [:string, :int], :string
attach_function :strchr, [:string, :int], :string
attach_function :strrchr, [:string, :int], :string
attach_function :strstr, [:string, :string], :string
attach_function :strerror, [:int], :string
-
- # stdio.h
- attach_variable :stdin, :pointer
- attach_variable :stdout, :pointer
- attach_variable :stderr, :pointer
-
+
+ begin
+ attach_variable :stdin, :pointer
+ attach_variable :stdout, :pointer
+ attach_variable :stderr, :pointer
+ rescue FFI::NotFoundError
+ # stdin, stdout, stderr are not available on OSX
+ end
+
attach_function :fopen, [:string, :string], :FILE
attach_function :fdopen, [:int, :string], :FILE
attach_function :freopen, [:string, :string, :FILE], :FILE
attach_function :fseek, [:FILE, :long, :int], :int
attach_function :ftell, [:FILE], :long