Module: Sqreen::Backport::ClockGettime
- Defined in:
- lib/sqreen/backport/clock_gettime.rb
Defined Under Namespace
Modules: Constants, LibC
Classes: Timespec
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.supported? ⇒ Boolean
10
11
12
|
# File 'lib/sqreen/backport/clock_gettime.rb', line 10
def supported?
Process.respond_to?(:clock_gettime)
end
|
Instance Method Details
#clock_gettime(clock_id, unit = :float_second) ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/sqreen/backport/clock_gettime.rb', line 50
def clock_gettime(clock_id, unit = :float_second)
unless unit == :float_second
raise "Process.clock_gettime: unsupported unit #{unit.inspect}"
end
t = Sqreen::Backport::ClockGettime::Timespec.new
ret = Sqreen::Backport::ClockGettime::LibC.clock_gettime(
clock_id,
t.pointer,
)
raise SystemCallError, "Errno #{FFI.errno}" if ret == -1
t[:tv_sec].to_f + t[:tv_nsec].to_f / 1_000_000_000
end
|