Skip to content

Instantly share code, notes, and snippets.

@bpetering
Last active January 6, 2016 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpetering/d30f940f5c3b3369a23e to your computer and use it in GitHub Desktop.
Save bpetering/d30f940f5c3b3369a23e to your computer and use it in GitHub Desktop.
Nativecall problems #2
#include <stdio.h>
int
foo_generichash(unsigned char *out, size_t outlen, const unsigned char *in,
unsigned long long inlen)
{
unsigned long long i;
for (i = 0; i < inlen; i++) {
out[i] = in[i];
}
return 0;
}
use v6;
use NativeCall;
#int
#foo_generichash(unsigned char *out, size_t outlen, const unsigned char *in,
# unsigned long long inlen)
sub foo_generichash(Buf, size_t, Str, ulonglong)
is native('test')
{*}
my $s = "hello world!";
my $out = Buf.new;
$out[11] = 0;
foo_generichash($out, 12, $s, 12);
say $out.decode();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment