qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Posix timer syscalls ; dealing with the timer_t type
@ 2012-08-30 12:30 Erik de Castro Lopo
  2012-08-30 16:00 ` Andreas Färber
  0 siblings, 1 reply; 3+ messages in thread
From: Erik de Castro Lopo @ 2012-08-30 12:30 UTC (permalink / raw)
  To: qemu-devel

Hi all,

I'm working on implementing Posix timers in linux-user.

I'm having trouble figuring out how to handle the timer_t type.
Consider the following code with say 32 bit ARM being emulated
on 64 bit x86-64:

    timer_t timerid;

    err = timer_create(clockid, &sev, &timerid);
    err = timer_gettime(timerid, &curr);

The issue is that memory for the timer_t value in the 32 bit
target is alloacted on the tack (where the timer_t is 4 bytes)
but the value provided by the 64 bit host where the timer_t is
8 bytes.

Any suggestions on dealing with this?

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Posix timer syscalls ; dealing with the timer_t type
  2012-08-30 12:30 [Qemu-devel] Posix timer syscalls ; dealing with the timer_t type Erik de Castro Lopo
@ 2012-08-30 16:00 ` Andreas Färber
  2012-08-30 19:15   ` Erik de Castro Lopo
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Färber @ 2012-08-30 16:00 UTC (permalink / raw)
  To: Erik de Castro Lopo; +Cc: Peter Maydell, Riku Voipio, qemu-devel

Hi,

Am 30.08.2012 14:30, schrieb Erik de Castro Lopo:
> I'm working on implementing Posix timers in linux-user.
> 
> I'm having trouble figuring out how to handle the timer_t type.
> Consider the following code with say 32 bit ARM being emulated
> on 64 bit x86-64:
> 
>     timer_t timerid;
> 
>     err = timer_create(clockid, &sev, &timerid);
>     err = timer_gettime(timerid, &curr);
> 
> The issue is that memory for the timer_t value in the 32 bit
> target is alloacted on the tack (where the timer_t is 4 bytes)
> but the value provided by the 64 bit host where the timer_t is
> 8 bytes.
> 
> Any suggestions on dealing with this?

typedef target_ulong target_timer_t;

or abi_ulong, or without the u if signed.

Depending on where/how you use this, you may need to convert back and
forth between host and target values.

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Posix timer syscalls ; dealing with the timer_t type
  2012-08-30 16:00 ` Andreas Färber
@ 2012-08-30 19:15   ` Erik de Castro Lopo
  0 siblings, 0 replies; 3+ messages in thread
From: Erik de Castro Lopo @ 2012-08-30 19:15 UTC (permalink / raw)
  To: qemu-devel

Andreas Färber wrote:

> Hi,
> 
> Am 30.08.2012 14:30, schrieb Erik de Castro Lopo:
> > I'm working on implementing Posix timers in linux-user.
> > 
> > I'm having trouble figuring out how to handle the timer_t type.
> > Consider the following code with say 32 bit ARM being emulated
> > on 64 bit x86-64:
> > 
> >     timer_t timerid;
> > 
> >     err = timer_create(clockid, &sev, &timerid);
> >     err = timer_gettime(timerid, &curr);
> > 
> > The issue is that memory for the timer_t value in the 32 bit
> > target is alloacted on the stack (where the timer_t is 4 bytes)
> > but the value provided by the 64 bit host where the timer_t is
> > 8 bytes.
> > 
> > Any suggestions on dealing with this?
> 
> typedef target_ulong target_timer_t;
> 
> or abi_ulong, or without the u if signed.

The timer_t type is actually an alias for void*.

> Depending on where/how you use this, you may need to convert back and
> forth between host and target values.

The complication is that each call to the host's timer_create() function
generates 64 bits of data, but on the 32 bit target, where there are only
32 bits to store that data.

The only obvious solution is store the 64 bit pointers from the host
in a table and return the index into that table to the target as its
version of the timer_t. Does that make sense?

Cheers,
Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-30 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-30 12:30 [Qemu-devel] Posix timer syscalls ; dealing with the timer_t type Erik de Castro Lopo
2012-08-30 16:00 ` Andreas Färber
2012-08-30 19:15   ` Erik de Castro Lopo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).