require 'rubygems'
require 'ffi'
class Timeval < FFI::Struct
#  layout :tv_sec => :ulong, :tv_usec => :ulong
  layout :tv_sec, :ulong, 0, :tv_usec, :ulong, 4
end
module LibC
  extend FFI::Library
  attach_function :gettimeofday, [ :pointer, :pointer ], :int
end
t = Timeval.new
LibC.gettimeofday(t.pointer, nil)
puts "t.tv_sec=#{t[:tv_sec]} t.tv_usec=#{t[:tv_usec]}"
