Bill Allombert on Tue, 27 Mar 2012 22:42:33 +0200

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

Re: [paridroid] save/restore context

On Tue, Mar 27, 2012 at 12:40:56PM -0400, Charles Boyd wrote:
> Hello, pari-dev!
> I am looking at Section 5.1.5 ("Saving and Restoring the GP context") in
> libpari.dvi, which mentions two functions with following prototypes:
> void gp_context_save(struct gp_context *rec);
> void gp_context_restore(struct gp_context *rec);

These functions save/restore the GP (language) context, not the gp
(interpretor) context. There are insufficiently documented. They are useful
mostly to implement the break loop: we want to stop the GP interpretor,
evaluate code in the current context, and then restart it.

They cannot be used to store the gp interpretor state. Indeed the documentation
says: << The new context must be an ancestor of the current context.>>
They only store the level of the stacks, not the content of the stacks.

> I want to implement save/restore state in Paridroid, and it would be
> nice if I could use these functions directly from my Android wrapper
> library.

Precisely, what do you want to save/restore ?

> I recall Karim showing me something like this and mentioning that
> restoring a context with user-defined function closures will not
> necessarily work. If I am remembering this correctly, could someone
> point me to more documentation (like a bug report) on this issue?

I assume you mean bug #1171, which we fixed some time ago.
In that case, you can use writebin("name",NULL) to save the state of
GP variables and readbin() to read the result.

The format depend on sizeof(long), so you can exchange file between
32bit ARM and 32bit x86, but not between 32bit x86 and 64bit x86.