mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Warn about save_flags(int)
@ 2002-02-28 12:31 Pavel Machek
  0 siblings, 0 replies; only message in thread
From: Pavel Machek @ 2002-02-28 12:31 UTC (permalink / raw)
  To: kernel list, Dave Jones

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-02-28 12:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-28 12:31 Warn about save_flags(int) Pavel Machek

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®