[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Lightning] multiple states and multiple functions
From: |
Marco Maggi |
Subject: |
[Lightning] multiple states and multiple functions |
Date: |
Mon, 30 Jul 2007 20:51:13 +0200 |
Ciao (hi Ludovic),
I am trying to learn the basics of GNU Lightning under
i686-pc-linux-gnu, GCC 3.4.2. As a full beginner I
would like signal that (maybe you know it already):
* with version 1.2 "lightning.h" is not installed by
"make" (or at least that is the case if I use
DESTDIR to install under a tmp directory);
* the docs talk about "struct jit_state", but "jit_state"
it a typedef;
* I do not use Automake, and after lightiningize in
"lightning.m4" there are still:
AM_CONDITIONAL(LIGHTNING_MAIN, (exit 1))
AM_CONDITIONAL(HAVE_INSTALLED_LIGHTNING, ...)
I had to comment them out by hand (undocumented, is it
safe to do it?).
It is not clear to me if it is possible to accumulate
code into a buffer from different C functions. I use
a dynamically allocated "jit_state" and I define:
#define _jit data->state
where "data" is a struct with a "jit_state state" field.
I get segfaults that I cannot explain, some of them
because I am still learning, that is for sure, but one
is driving me crazy: is "jit_finish()" supposed to work
if I use it from a C function different from the one in
which I initialised the buffer and the "jit_state"? Is
the state in some way linked to the stack of the first
function in which it is used?
I ask this because when I try the printf example in the
documentation (that is a single function) everything
works; but If I build a dynamic function from multiple
C functions I get a segfault.
The code I am using is:
{
/* Accumulate the code required to get an
argument into R0. */
{
unsigned long in;
jit_prolog(1);
in = jit_arg_p();
jit_getarg_p(JIT_R0, in);
}
/* Does the call: the argument must be in R0 */
jit_prepare(1);
{
jit_pusharg_ul(JIT_R0);
}
jit_finish(scm_call_0);
jit_ret();
}
jit_flush_code(data->buffer, jit_get_ip().ptr);
when I invoke the function: by printing log messages I
see that "scm_call_0()" is evaluated correctly and returns
(I tried different functions and they go on at least up
until the C "return") and then a segfault comes as if
there is a problem with fetching the return address
to jump back to the caller.
TIA
--
Marco Maggi
"Now feel the funk blast!"
Rage Against the Machine - "Calm like a bomb"
- [Lightning] multiple states and multiple functions,
Marco Maggi <=