qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Posix timer syscalls [Bug 1042388]
@ 2012-08-29  9:44 Erik de Castro Lopo
  2012-08-29  9:57 ` Peter Maydell
  0 siblings, 1 reply; 3+ messages in thread
From: Erik de Castro Lopo @ 2012-08-29  9:44 UTC (permalink / raw)
  To: qemu-devel

Hi all,

I've spent some time messing about in linux-user/syscall.c and I have
stubs for all 5 posix timer syscalls:

    int timer_create(clockid_t clockid, struct sigevent *sevp,
                     timer_t *timerid);

    int timer_settime(timer_t timerid, int flags,
                      const struct itimerspec *new_value,
                      struct itimerspec * old_value);

    int timer_gettime(timer_t timerid, struct itimerspec *curr_value);

    int timer_getoverrun(timer_t timerid);

    int timer_delete(timer_t timerid);

Obviously all these parameters need to be converted between host and
target. I've already found struct target_itimerspec in
linux-user/syscall_defs.h and that looks like it will be useful.

I'm having trouble struct sigevent pointer that is passed to
timer_create() which is defined as:

    typedef struct sigevent {
        sigval_t sigev_value;
        int sigev_signo;
        int sigev_notify;
        union {
            int _pad[SIGEV_PAD_SIZE];
            int _tid;

            struct {
                void (*_function)(sigval_t);
                void *_attribute;	/* really pthread_attr_t */
            } _sigev_thread;
        } _sigev_un;
    } sigevent_t;

Any ideas on how to handle the union within this struct?

Cheers,
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 [Bug 1042388]
  2012-08-29  9:44 [Qemu-devel] Posix timer syscalls [Bug 1042388] Erik de Castro Lopo
@ 2012-08-29  9:57 ` Peter Maydell
  2012-08-29 10:03   ` Erik de Castro Lopo
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Maydell @ 2012-08-29  9:57 UTC (permalink / raw)
  To: qemu-devel

On 29 August 2012 10:44, Erik de Castro Lopo <mle+tools@mega-nerd.com> wrote:
> I'm having trouble struct sigevent pointer that is passed to
> timer_create() which is defined as:
>
>     typedef struct sigevent {
>         sigval_t sigev_value;
>         int sigev_signo;
>         int sigev_notify;
>         union {
>             int _pad[SIGEV_PAD_SIZE];
>             int _tid;
>
>             struct {
>                 void (*_function)(sigval_t);
>                 void *_attribute;       /* really pthread_attr_t */
>             } _sigev_thread;
>         } _sigev_un;
>     } sigevent_t;
>
> Any ideas on how to handle the union within this struct?

You need to look at how the kernel decides which of the
fields of the union is valid, and use the same logic to
decide how to convert it in qemu.

In this case I think that means that if
(sigev_notify & SIGEV_THREAD_ID) != 0, _tid is valid and
must be converted. Otherwise convert _sigev_thread.

-- PMM

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

* Re: [Qemu-devel] Posix timer syscalls [Bug 1042388]
  2012-08-29  9:57 ` Peter Maydell
@ 2012-08-29 10:03   ` Erik de Castro Lopo
  0 siblings, 0 replies; 3+ messages in thread
From: Erik de Castro Lopo @ 2012-08-29 10:03 UTC (permalink / raw)
  To: qemu-devel

Peter Maydell wrote:

> You need to look at how the kernel decides which of the
> fields of the union is valid, and use the same logic to
> decide how to convert it in qemu.
> 
> In this case I think that means that if
> (sigev_notify & SIGEV_THREAD_ID) != 0, _tid is valid and
> must be converted. Otherwise convert _sigev_thread.

Ah, that makes sense. Thanks.

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-29 10:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-29  9:44 [Qemu-devel] Posix timer syscalls [Bug 1042388] Erik de Castro Lopo
2012-08-29  9:57 ` Peter Maydell
2012-08-29 10:03   ` 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).