Re: [PATCH 7/9] mm: split page table lock

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

 



Hugh Dickins writes:

[...]

 > + * When freeing, reset page->mapping so free_pages_check won't complain.
 > + */
 > +#define __pte_lockptr(page)	((spinlock_t *)&((page)->private))
 > +#define pte_lock_init(_page)	do {					\
 > +	BUILD_BUG_ON((size_t)(__pte_lockptr((struct page *)0) + 1) >	\
 > +						sizeof(struct page));	\
 > +	spin_lock_init(__pte_lockptr(_page));				\
 > +} while (0)

Looking at this, I think BUILD_BUG_ON() should be defined in a way that
allows it to be used outside of function scope too (see patch below,
compile-tested).

Nikita.
--
Fix comment describing BUILD_BUG_ON: BUG_ON is not an assertion
(unfortunately).

Also implement BUILD_BUG_ON in a way that can be used outside of a function
scope, so that compile time checks can be placed in convenient places (like in
a header, close to the definition of related constants and data-types).

Signed-off-by: Nikita Danilov <[email protected]>

 include/linux/kernel.h |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff -puN include/linux/kernel.h~BUILD_BUG_ON-fix-comment include/linux/kernel.h
--- git-linux/include/linux/kernel.h~BUILD_BUG_ON-fix-comment	2005-10-23 20:09:33.000000000 +0400
+++ git-linux-nikita/include/linux/kernel.h	2005-10-23 20:44:03.000000000 +0400
@@ -307,8 +307,9 @@ struct sysinfo {
 	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
 };
 
-/* Force a compilation error if condition is false */
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
+/* Force a compilation error if condition is true */
+#define BUILD_BUG_ON(x)							\
+	void __dummy_build_bug_on(int __compile_time_assertion_failed_[-!!(x)])
 
 #ifdef CONFIG_SYSCTL
 extern int randomize_va_space;

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux