[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] Re: multiple states and multiple functions

From: Ludovic Courtès
Subject: [Lightning] Re: multiple states and multiple functions
Date: Mon, 30 Jul 2007 23:03:57 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Ciao Marco!

"Marco Maggi" <address@hidden> writes:

> * 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);

When installing lightning itself, it should get installed (it's listed
in `include_HEADERS').  However, when installing a package that bundles
lightning (i.e., a package that uses `lightninize'), then it makes sense
to not install lightning's headers.

Besides, you should specify which 1.2 sub-version you are using: 1.2b,
1.2c, etc.

> * the docs talk about "struct jit_state", but "jit_state"
>   it a typedef;

Right, I noticed it some time ago.

> * I do not use Automake, and after lightiningize in
>   "lightning.m4" there are still:
>   I had to comment them out by hand (undocumented, is it
>   safe to do it?).

Hmm.  Maybe you should use Automake?  :-)

> where "data" is a struct with a "jit_state state" field.
> I get segfaults that I cannot explain,

First of all, make sure you never write past the end of your buffer.
It's pretty hard to get right because lightning's macros don't check
that.  So you have to either have an estimate of the size of the code
you're generating, so that you can provide a buffer that is large
enough, or you have to hand-check whether you're approaching the end of
the buffer every few `jit_' macros (e.g., by comparing
"jit_get_ip ().ptr - BUFFER" and "BUFFER_SIZE").

> The code I am using is:
>   {

Did you call `jit_set_ip (BUFFER)' first?

>     /* 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);

That should rather be `jit_pusharg_p' for consistency (but it shouldn't

>     }
>     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.

What exact lightning version and what architecture are you using?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]