xkernigh / netscape.net wrote:
> Kernel.syscall was a wrapper around syscall() or \_\_syscall() in libc, but it didn't use the correct types for arguments and return values. I suggest to use Fiddle to call syscall() or \_\_syscall() with the correct types for your system call. Here is a quick example for getdents64() in 32-bit PowerPC Linux.
> 
> ~~~ ruby
> require 'fiddle'
> 
> libc = Fiddle.dlopen('libc.so.6')

I encounter more problems with calling dlopen properly, even
for libc, more than I encounter with mismatched syscall numbers.

I prefer to avoid Fiddle/FFI because I find it's dynamic loading
interface even less predictable across systems than using bare
syscall numbers.

Also, libffi isn't available or costs extra download time on
some systems.  syscall has been in Ruby for ages, and I've
relied on it's equivalent builtin function in Perl every single
day for many years, now.  It's never failed me as a Perl user.
Once a syscall-using script works, it'll work on that system as
long as that scripting language is installed.  No need for extra
libraries to install or potentially get broken during upgrades.

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>