Example #1
0
      //int posix_memalign(void **memptr, size_t alignment, size_t size);


      // The function aligned_alloc() was added to glibc in version 2.16.
      // http://linux.die.net/man/3/aligned_alloc
      //
      void *aligned_alloc(size_t alignment, size_t size);


      void free(void *ptr);

      void xor(char* data, size_t len);
   """)

   ffi.libc = ffi.dlopen(None)
   ffi.xor = ffi.dlopen('libxor.so')

   variant1(ffi, 16, 1024)
   variant1(ffi, 16, 1024, init = True)

   s = ''.join([chr(i) for i in xrange(16)])
   #variant1(ffi, 16, 1024, initstr = '*' * 1024)
   variant1(ffi, 16, 1024, initstr = s * (1024 / 16))

   ## The next variant will only work on _newest_ libc.
   ##
   ## How do I check programatically?
   ## E.g., you can do this in shell: "apt-cache show libc6"
   ##
   ## The Linux man page says there is a macro: _ISOC11_SOURCE
   ##