Re: Native and global variables

Odd Arild Olsen <[email protected]> Wed, 23 Jun 2004 14:22:47 +0200
Newsgroups gmane.comp.hardware.microcontrollers.tini
Message-ID <[email protected]>
On Tuesday 22 June 2004 16:25, Thomas Chenot wrote:
> Odd Arild Olsen wrote:
> >As far as I have understood, native methods can not use global variables.
> >I need a few global variables for my native library that will be
> > persistent over  library calls.
> >
> >Is there any practical way to do this, e. g.
> >
> >by malloc
>
> Yes.
>
> >or ephemeral state blocks?
>
> Yes.
>

>From what I understand from the doc and example, this would work:

The java app  at startup calls a native_init function which 
1  Calls NatLib_GetEphemeralStateBlock with the library signature as parameter
2  if that returned 0 we allready have an ESB and an associated memory block. 
If not,  we MM_Malloc a block of memory and then call 
NatLib_InstallEphemeralStateBlock. At this point I understand that we have an 
ESB and a memory block for our persistent data which we can use until the 
Tini reboots without any further mallocs.

A native function can now get a pointer to the malloc'ed memory by just 
calling NatLib_GetEphemeralStateBlock with the lib signature as parameter. By 
the returned pointer the function may both read and write the memory block.

OAO

_______________________________________________
TINI mailing list
TINI-6tN4nzCoH/[email protected]
To UNSUBSCRIBE, edit your profile, or see list archives:
http://lists.dalsemi.com/mailman/listinfo/tini