Received: from eggs.gnu.org ([140.186.70.92]:49218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4UQa-0006OP-34 for qemu-devel@nongnu.org; Fri, 16 Sep 2011 05:09:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R4UQZ-000640-4b for qemu-devel@nongnu.org; Fri, 16 Sep 2011 05:09:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R4UQY-00063h-Rs for qemu-devel@nongnu.org; Fri, 16 Sep 2011 05:09:43 -0400 From: Markus Armbruster References: <1316107350-31172-1-git-send-email-lersek@redhat.com> <4E730188.7090103@redhat.com> Date: Fri, 16 Sep 2011 11:09:37 +0200 In-Reply-To: <4E730188.7090103@redhat.com> (Laszlo Ersek's message of "Fri, 16 Sep 2011 09:58:00 +0200") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH RFC] main loop: fix some accesses made in sighandler context List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: Peter Maydell , qemu-devel@nongnu.org Laszlo Ersek writes: > On 09/15/11 21:44, Peter Maydell wrote: >> On 15 September 2011 18:22, Laszlo Ersek 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 int. Regardless, no_shutdown is used like bool, so you could easily make it sig_atomic_t.