Module: LIBC

Extended by:
DL::Importable
Defined in:
sample/libc.rb

Constant Summary collapse

Timeval =
struct [
  "long tv_sec",
  "long tv_usec",
]
Timezone =
struct [
  "int tz_minuteswest",
  "int tz_dsttime",
]
COMPARE =
callback("int my_compare(char**, char**)")

Constants included from DL::Importable

DL::Importable::LIB_MAP

Instance Method Summary collapse

Methods included from DL::Importable::Internal

#[], #_args_, #_retval_, #callback, #define_struct, #define_union, #dlload, #encode_argument_types, #extern, #import, #init_sym, #init_types, #parse_cproto, #symbol, #typealias

Instance Method Details

#my_compare(ptr1, ptr2) ⇒ Object



39
40
41
# File 'sample/libc.rb', line 39

def my_compare(ptr1, ptr2)
  ptr1.ptr.to_s <=> ptr2.ptr.to_s
end

#str_qsort(ary, comp) ⇒ Object



23
24
25
26
27
# File 'sample/libc.rb', line 23

def str_qsort(ary, comp)
  len = ary.length
  r,rs = qsort(ary, len, DL.sizeof('P'), comp)
  return rs[0].to_a('S', len)
end