Skip to content

Instantly share code, notes, and snippets.

@uvlad7
Created January 1, 2023 14:14
Show Gist options
  • Save uvlad7/5c529197360e9aa9e78fec2d0dac4799 to your computer and use it in GitHub Desktop.
Save uvlad7/5c529197360e9aa9e78fec2d0dac4799 to your computer and use it in GitHub Desktop.
require 'ffi'
module C
extend FFI::Library
ffi_lib 'c'
attach_function :printf, [:varargs], :int
end
x = FFI::MemoryPointer.new(:long_long)
l = FFI::MemoryPointer.new(:long_long, 2)
x.write_long_long(1)
if x.read_char.nonzero? # Little-endian
l.write_array_of_long_long([7299807751963697480, 9414436869185655])
else
l.write_array_of_long_long([5215573471842553445, 8583959181729603840])
end
C.printf(:string, "%s\n", :pointer, l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment