[Top][All Lists]

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

Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighan

From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context
Date: Fri, 16 Sep 2011 11:09:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Laszlo Ersek <address@hidden> writes:

> On 09/15/11 21:44, Peter Maydell wrote:
>> On 15 September 2011 18:22, Laszlo Ersek<address@hidden>  wrote:
>>> -int no_shutdown = 0;
>>> +volatile int no_shutdown = 0;
>> So why 'volatile' and not 'sig_atomic_t', then?
> The sigaction() spec  says"volatile sig_atomic_t", so that would be
> ideal. My assumption was that "sig_atomic_t" (which is allowed by
> POSIX not to be wider than "char") would be in practice at least as

Inherited from the C standard.

> wide as "int" and "pid_t". Should my assumption be wrong on some
> platforms, qualifying the variables "volatile" while keeping their
> current types (int / pid_t) does less damage (no damage) than
> narrowing their types.

info libc says:

    In practice, you can assume that `int' is atomic.  You can also
    assume that pointer types are atomic; that is very convenient.  Both
    of these assumptions are true on all of the machines that the GNU C
    library supports and on all POSIX systems we know of.

If you're programming for a machine where int isn't atomic, you very
likely got more serious issues to worry about :)

Non-atomic pid_t would be weird, but not quite as weird as non-atomic

Regardless, no_shutdown is used like bool, so you could easily make it

reply via email to

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