Remove no-longer-used libpsem and related code and tests.
This commit is contained in:
1 parent
8158666e90
commit
842ff179ec
21 files changed
-936
No files matched your search
@@ -1,36 +0,0 @@
|
||||
require 'ffi'
|
||||
|
||||
require 'process_shared/posix_call'
|
||||
require 'process_shared/psem'
|
||||
|
||||
module ProcessShared
|
||||
module LibC
|
||||
extend FFI::Library
|
||||
extend PosixCall
|
||||
|
||||
ffi_lib FFI::Library::LIBC
|
||||
|
||||
MAP_FAILED = FFI::Pointer.new(-1)
|
||||
MAP_SHARED = PSem.map_shared
|
||||
MAP_PRIVATE = PSem.map_private
|
||||
|
||||
PROT_READ = PSem.prot_read
|
||||
PROT_WRITE = PSem.prot_write
|
||||
PROT_EXEC = PSem.prot_exec
|
||||
PROT_NONE = PSem.prot_none
|
||||
|
||||
O_RDWR = PSem.o_rdwr
|
||||
O_CREAT = PSem.o_creat
|
||||
O_EXCL = PSem.o_excl
|
||||
|
||||
attach_variable :errno, :int
|
||||
|
||||
attach_function :mmap, [:pointer, :size_t, :int, :int, :int, :off_t], :pointer
|
||||
attach_function :munmap, [:pointer, :size_t], :int
|
||||
attach_function :ftruncate, [:int, :off_t], :int
|
||||
attach_function :close, [:int], :int
|
||||
|
||||
error_check(:mmap) { |v| v == MAP_FAILED }
|
||||
error_check(:munmap, :ftruncate, :close)
|
||||
end
|
||||
end
|
||||
@@ -1,113 +0,0 @@
|
||||
require 'ffi'
|
||||
|
||||
module ProcessShared
|
||||
module PSem
|
||||
class Error < FFI::Struct
|
||||
layout(:source, :int,
|
||||
:errno, :int)
|
||||
end
|
||||
|
||||
extend FFI::Library
|
||||
|
||||
# Workaround FFI dylib/bundle issue. See https://github.com/ffi/ffi/issues/42
|
||||
suffix = if FFI::Platform.mac?
|
||||
'bundle'
|
||||
else
|
||||
FFI::Platform::LIBSUFFIX
|
||||
end
|
||||
|
||||
ffi_lib File.join(File.expand_path(File.dirname(__FILE__)),
|
||||
'libpsem.' + suffix)
|
||||
|
||||
class << self
|
||||
# Replace methods in `syms` with error checking wrappers that
|
||||
# invoke the original psem method and raise an appropriate
|
||||
# error.
|
||||
#
|
||||
# The last argument is assumed to be a pointer to a pointer
|
||||
# where either a psem error or NULL will be stored.
|
||||
def psem_error_check(*syms)
|
||||
syms.each do |sym|
|
||||
method = self.method(sym)
|
||||
|
||||
block = lambda do |*args|
|
||||
if method.call(*args) < 0
|
||||
errp = args[-1]
|
||||
unless errp.nil?
|
||||
begin
|
||||
err = Error.new(errp.read_pointer)
|
||||
errp.write_pointer(nil)
|
||||
if err[:source] == PSem.e_source_system
|
||||
raise SystemCallError.new("error in #{sym}", err[:errno])
|
||||
else
|
||||
raise "error in #{sym}: #{err.get_integer(1)}"
|
||||
end
|
||||
ensure
|
||||
psem_error_free(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
define_method(sym, &block)
|
||||
define_singleton_method(sym, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Generic constants
|
||||
|
||||
int_consts = [:o_rdwr,
|
||||
:o_creat,
|
||||
:o_excl,
|
||||
|
||||
:prot_read,
|
||||
:prot_write,
|
||||
:prot_exec,
|
||||
:prot_none,
|
||||
|
||||
:map_shared,
|
||||
:map_private]
|
||||
int_consts.each { |sym| attach_variable sym, :int }
|
||||
|
||||
# Other constants, functions
|
||||
|
||||
attach_function :psem_error_free, :error_free, [:pointer], :void
|
||||
|
||||
attach_variable :e_source_system, :E_SOURCE_SYSTEM, :int
|
||||
attach_variable :e_source_psem, :E_SOURCE_PSEM, :int
|
||||
|
||||
attach_variable :e_name_too_long, :E_NAME_TOO_LONG, :int
|
||||
|
||||
attach_variable :sizeof_psem_t, :size_t
|
||||
attach_variable :sizeof_bsem_t, :size_t
|
||||
|
||||
# PSem functions
|
||||
|
||||
attach_function :psem_open, [:pointer, :string, :uint, :pointer], :int
|
||||
attach_function :psem_close, [:pointer, :pointer], :int
|
||||
attach_function :psem_unlink, [:string, :pointer], :int
|
||||
attach_function :psem_post, [:pointer, :pointer], :int
|
||||
attach_function :psem_wait, [:pointer, :pointer], :int
|
||||
attach_function :psem_trywait, [:pointer, :pointer], :int
|
||||
attach_function :psem_timedwait, [:pointer, :float, :pointer], :int
|
||||
attach_function :psem_getvalue, [:pointer, :pointer, :pointer], :int
|
||||
|
||||
psem_error_check(:psem_open, :psem_close, :psem_unlink, :psem_post,
|
||||
:psem_wait, :psem_trywait, :psem_timedwait, :psem_getvalue)
|
||||
|
||||
# BSem functions
|
||||
|
||||
attach_function :bsem_open, [:pointer, :string, :uint, :uint, :pointer], :int
|
||||
attach_function :bsem_close, [:pointer, :pointer], :int
|
||||
attach_function :bsem_unlink, [:string, :pointer], :int
|
||||
attach_function :bsem_post, [:pointer, :pointer], :int
|
||||
attach_function :bsem_wait, [:pointer, :pointer], :int
|
||||
attach_function :bsem_trywait, [:pointer, :pointer], :int
|
||||
attach_function :bsem_timedwait, [:pointer, :float, :pointer], :int
|
||||
attach_function :bsem_getvalue, [:pointer, :pointer, :pointer], :int
|
||||
|
||||
psem_error_check(:bsem_open, :bsem_close, :bsem_unlink, :bsem_post,
|
||||
:bsem_wait, :bsem_trywait, :bsem_timedwait, :bsem_getvalue)
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,3 @@
|
||||
require 'process_shared/rt'
|
||||
require 'process_shared/libc'
|
||||
require 'process_shared/with_self'
|
||||
require 'process_shared/shared_memory_io'
|
||||
|
||||
|
||||
Reference in new issue
Block a user