From: Pavel Machek <pavel@suse.cz>
To: kernel list <linux-kernel@vger.kernel.org>, Dave Jones <davej@suse.de>
Subject: Warn about save_flags(int)
Date: Thu, 28 Feb 2002 13:31:06 +0100 [thread overview]
Message-ID: <20020228123105.GA14238@elf.ucw.cz> (raw)
Hi!
We still have people trying to store flags in something else than
unsigned long. If it is long it does not break anything, but people
use int there, too.
This patch makes at least warning on i386, so we do not have to fix so
much on x86-64. I'd like to submit this for official kernel.
Pavel
--- clean.2.4/include/linux/kernel.h Thu Feb 28 11:18:25 2002
+++ x86/linux/include/linux/kernel.h Thu Feb 28 12:03:13 2002
@@ -180,5 +175,7 @@
unsigned int mem_unit; /* Memory unit size in bytes */
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
};
+
+#define warn_if_not_ulong(x) do { unsigned long foo; (void) (&(x) == &foo); } while (0)
#endif
--- clean.2.4/include/asm-i386/system.h Wed Dec 5 23:46:05 2001
+++ x86/linux/include/asm-i386/system.h Thu Feb 28 12:53:14 2002
@@ -310,7 +310,7 @@
#define set_wmb(var, value) do { var = value; wmb(); } while (0)
/* interrupt control.. */
-#define __save_flags(x) __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
+#define __save_flags(x) do { warn_if_not_ulong(x); __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */); } while(0)
#define __restore_flags(x) __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
#define __cli() __asm__ __volatile__("cli": : :"memory")
#define __sti() __asm__ __volatile__("sti": : :"memory")
@@ -318,7 +318,7 @@
#define safe_halt() __asm__ __volatile__("sti; hlt": : :"memory")
/* For spinlocks etc */
-#define local_irq_save(x) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
+#define local_irq_save(x) do { __save_flags(x); __cli(); } while (0)
#define local_irq_restore(x) __restore_flags(x)
#define local_irq_disable() __cli()
#define local_irq_enable() __sti()
--
(about SSSCA) "I don't say this lightly. However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
reply other threads:[~2002-02-28 12:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020228123105.GA14238@elf.ucw.cz \
--to=pavel@suse.cz \
--cc=davej@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®