[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-libjit] Handling variable arguments
From: |
Aiden Nibali |
Subject: |
[Dotgnu-libjit] Handling variable arguments |
Date: |
Sat, 02 Oct 2010 07:28:06 +1000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 |
I really appreciate the work that has gone into libjit, and I
understand that you guys are probably very busy. However, I would
still really like some help in using varargs in order to improve my
Ruby bindings for libjit, libjit-ffi. I've spent hours looking through
the documentation and grepping through the source code for instances
of 'vararg', but to no avail.
Below is my (failed) attempt to generate and apply a variadic function:
#include<stdio.h>
#include<jit/jit.h>
int main(int argc, char **argv)
{
jit_context_t context;
jit_function_t function;
jit_type_t params[2], signature;
jit_value_t x, y, tmp;
jit_int arg1, arg2;
void* args[2];
jit_int result;
context = jit_context_create();
jit_context_build_start(context);
/* Create vararg signature with 1 fixed parameter */
params[0] = jit_type_int;
signature = jit_type_create_signature
(jit_abi_vararg, jit_type_int, params, 1, 1);
function = jit_function_create(context, signature);
x = jit_value_get_param(function, 0);
y = jit_value_get_param(function, 1); /*<-- Doesn't seem to work! */
tmp = jit_insn_add(function, x, y);
jit_insn_return(function, tmp);
jit_function_compile(function);
jit_context_build_end(context);
arg1 = 3;
arg2 = 4;
args[0] =&arg1;
args[1] =&arg2;
/* Create new signature */
params[1] = jit_type_int;
signature = jit_type_create_signature(jit_abi_cdecl,
jit_type_int, params, 2, 1);
jit_function_apply_vararg(function, signature, args,&result);
printf("3 + 4 = %d\n", (int)result);
jit_context_destroy(context);
return 0;
}
Any ideas on where I went wrong? Are varargs even fully supported yet?
I could really do with some guidance.
Cheers,
Aiden
PS Mailing lists drive me batty! :)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-libjit] Handling variable arguments,
Aiden Nibali <=