You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
(11) |
Jul
(5) |
Aug
|
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
|
Mar
(18) |
Apr
(7) |
May
(8) |
Jun
(19) |
Jul
(16) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(8) |
Jun
|
Jul
(2) |
Aug
(1) |
Sep
(7) |
Oct
|
Nov
|
Dec
(2) |
2005 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
|
May
(10) |
Jun
|
Jul
(1) |
Aug
(3) |
Sep
|
Oct
|
Nov
(4) |
Dec
(1) |
2006 |
Jan
(41) |
Feb
(41) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
From: Paul M. <le...@li...> - 2007-11-11 09:36:52
|
On Sun, Nov 11, 2007 at 10:06:21AM +0100, Adrian Bunk wrote: > Commit 8687991a734a67f1638782c968f46fff0f94bb1f causes the following > compile error on sh64: > > <-- snip --> > > ... > CC [M] drivers/net/ax88796.o > /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/net/ax88796.c: In function 'ax_get_8390_hdr': > /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/net/ax88796.c:187: error: implicit declaration of function 'readsw' > /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/net/ax88796.c:189: error: implicit declaration of function 'readsb' > /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/net/ax88796.c: In function 'ax_block_output': > /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/net/ax88796.c:275: error: implicit declaration of function 'writesw' > /home/bunk/linux/kernel-2.6/git/linux-2.6/drivers/net/ax88796.c:277: error: implicit declaration of function 'writesb' > make[3]: *** [drivers/net/ax88796.o] Error 1 > > <-- snip --> > That's a pretty good argument for the PLAT_HAS_xxx stuff in the Kconfig space. We could have a if (CONFIG_SUPERH && !CONFIG_SUPERH64) thing here, but there's probably not much point. I'm planning on merging them in the 2.6.25 time period anyways, so adding a stop-gap solution to hide this driver's visibility doesn't really seem like a worthwhile endeavour. |
From: Paul M. <le...@li...> - 2007-10-24 07:36:53
|
On Mon, Oct 22, 2007 at 04:47:30AM +0200, Adrian Bunk wrote: > This patch fixes the following compile error caused by > commit 622a9edd919de98ef59571ae6c40c7458244e3f2: > Applied, thanks Adrian. |
From: Paul M. <le...@li...> - 2007-08-14 00:44:54
|
On Sun, Aug 12, 2007 at 11:36:51PM -0700, jo...@pe... wrote: > Add file pattern to MAINTAINER entry > > Signed-off-by: Joe Perches <jo...@pe...> > > diff --git a/MAINTAINERS b/MAINTAINERS > index 3e51fc6..f42712c 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -4414,6 +4414,8 @@ M: le...@li... > L: lin...@li... (subscribers-only) > W: http://www.linux-sh.org > S: Maintained > +F: arch/sh/ > +F: arch/asm-sh/ > I suppose you meant include/ here? On Sun, Aug 12, 2007 at 11:36:53PM -0700, jo...@pe... wrote: > Add file pattern to MAINTAINER entry > > Signed-off-by: Joe Perches <jo...@pe...> > > diff --git a/MAINTAINERS b/MAINTAINERS > index f42712c..df097fb 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -4423,6 +4423,8 @@ M: le...@li... > L: lin...@li... > W: http://www.linux-sh.org > S: Maintained > +F: arch/sh64/ > +F: arch/asm-sh64/ > Likewise? The more pressing question that comes to mind is what the point of this is? Architecture related drivers and things of that nature fall under this also, as most folks don't create a separate entry for every trivial driver. Are you intending to have a long list of individual drivers here that your script can parse? Is there actually a problem with people just opening up MAINTAINERS in a text file? Surely this is not such a non-intuitive thing, there are already keywords there you can grep for. |
From: Paul M. <le...@li...> - 2007-07-29 22:53:33
|
On Mon, Jul 30, 2007 at 12:44:00AM +0200, Jesper Juhl wrote: > This patch removes the duplicate inclusion of linux/personality.h > from arch/sh64/kernel/signal.c > > Signed-off-by: Jesper Juhl <jes...@gm...> Acked-by: Paul Mundt <le...@li...> |
From: Paul M. <le...@li...> - 2007-04-12 13:13:55
|
On Thu, Apr 12, 2007 at 09:51:50AM +0530, Milind Arun Choudhary wrote: > ROUND_UP macro cleanup, use ALIGN where ever appropriate. > > Signed-off-by: Milind Arun Choudhary <mil...@gm...> > Looks fine, thanks. Acked-by: Paul Mundt <le...@li...> |
From: Paul M. <le...@li...> - 2007-01-16 22:08:48
|
On Tue, Jan 16, 2007 at 09:39:42AM -0700, Eric W. Biederman wrote: > From: Eric W. Biederman <ebi...@xm...> - unquoted > > While doing the C99 conversion I notices that the top level sh64 > directory was using the binary number for CTL_KERN. That is a > no-no so I removed the support for the sysctl binary interface > only leaving sysctl /proc support. > > At least the sysctl tables were placed at the end of > the list so user space did not see this mistake. > > Signed-off-by: Eric W. Biederman <ebi...@xm...> Looks good, thanks Eric. Acked-by: Paul Mundt <le...@li...> |
From: Paul M. <le...@li...> - 2006-08-28 08:06:12
|
On Mon, Aug 28, 2006 at 12:00:49AM +0200, Arnd Bergmann wrote: > sh64 is using system call macros to call some functions > from the kernel. Remove those so we can get rid of > kernel syscalls. > It makes more sense to just rip out the old debug code, since we don't really have that much of a need for it anymore, it was mostly something that was handy during the initial bringup. This also brings us closer to something that looks like readable code again.. I also added a sane kernel_thread() implementation that gets away from this, so that should take care of sh64 at least. Signed-off-by: Paul Mundt <le...@li...> diff --git a/arch/sh64/kernel/process.c b/arch/sh64/kernel/process.c index dba8e14..525d0ec 100644 --- a/arch/sh64/kernel/process.c +++ b/arch/sh64/kernel/process.c @@ -20,261 +20,16 @@ /* * This file handles the architecture-dependent parts of process handling.. */ - -/* Temporary flags/tests. All to be removed/undefined. BEGIN */ -#define IDLE_TRACE -#define VM_SHOW_TABLES -#define VM_TEST_FAULT -#define VM_TEST_RTLBMISS -#define VM_TEST_WTLBMISS - -#undef VM_SHOW_TABLES -#undef IDLE_TRACE -/* Temporary flags/tests. All to be removed/undefined. END */ - -#define __KERNEL_SYSCALLS__ -#include <stdarg.h> - -#include <linux/kernel.h> -#include <linux/rwsem.h> #include <linux/mm.h> -#include <linux/smp.h> -#include <linux/smp_lock.h> #include <linux/ptrace.h> -#include <linux/slab.h> -#include <linux/vmalloc.h> -#include <linux/user.h> -#include <linux/a.out.h> -#include <linux/interrupt.h> -#include <linux/unistd.h> -#include <linux/delay.h> #include <linux/reboot.h> #include <linux/init.h> - +#include <linux/module.h> #include <asm/uaccess.h> #include <asm/pgtable.h> -#include <asm/system.h> -#include <asm/io.h> -#include <asm/processor.h> /* includes also <asm/registers.h> */ -#include <asm/mmu_context.h> -#include <asm/elf.h> -#include <asm/page.h> - -#include <linux/irq.h> struct task_struct *last_task_used_math = NULL; -#ifdef IDLE_TRACE -#ifdef VM_SHOW_TABLES -/* For testing */ -static void print_PTE(long base) -{ - int i, skip=0; - long long x, y, *p = (long long *) base; - - for (i=0; i< 512; i++, p++){ - if (*p == 0) { - if (!skip) { - skip++; - printk("(0s) "); - } - } else { - skip=0; - x = (*p) >> 32; - y = (*p) & 0xffffffff; - printk("%08Lx%08Lx ", x, y); - if (!((i+1)&0x3)) printk("\n"); - } - } -} - -/* For testing */ -static void print_DIR(long base) -{ - int i, skip=0; - long *p = (long *) base; - - for (i=0; i< 512; i++, p++){ - if (*p == 0) { - if (!skip) { - skip++; - printk("(0s) "); - } - } else { - skip=0; - printk("%08lx ", *p); - if (!((i+1)&0x7)) printk("\n"); - } - } -} - -/* For testing */ -static void print_vmalloc_first_tables(void) -{ - -#define PRESENT 0x800 /* Bit 11 */ - - /* - * Do it really dirty by looking at raw addresses, - * raw offsets, no types. If we used pgtable/pgalloc - * macros/definitions we could hide potential bugs. - * - * Note that pointers are 32-bit for CDC. - */ - long pgdt, pmdt, ptet; - - pgdt = (long) &swapper_pg_dir; - printk("-->PGD (0x%08lx):\n", pgdt); - print_DIR(pgdt); - printk("\n"); - - /* VMALLOC pool is mapped at 0xc0000000, second (pointer) entry in PGD */ - pgdt += 4; - pmdt = (long) (* (long *) pgdt); - if (!(pmdt & PRESENT)) { - printk("No PMD\n"); - return; - } else pmdt &= 0xfffff000; - - printk("-->PMD (0x%08lx):\n", pmdt); - print_DIR(pmdt); - printk("\n"); - - /* Get the pmdt displacement for 0xc0000000 */ - pmdt += 2048; - - /* just look at first two address ranges ... */ - /* ... 0xc0000000 ... */ - ptet = (long) (* (long *) pmdt); - if (!(ptet & PRESENT)) { - printk("No PTE0\n"); - return; - } else ptet &= 0xfffff000; - - printk("-->PTE0 (0x%08lx):\n", ptet); - print_PTE(ptet); - printk("\n"); - - /* ... 0xc0001000 ... */ - ptet += 4; - if (!(ptet & PRESENT)) { - printk("No PTE1\n"); - return; - } else ptet &= 0xfffff000; - printk("-->PTE1 (0x%08lx):\n", ptet); - print_PTE(ptet); - printk("\n"); -} -#else -#define print_vmalloc_first_tables() -#endif /* VM_SHOW_TABLES */ - -static void test_VM(void) -{ - void *a, *b, *c; - -#ifdef VM_SHOW_TABLES - printk("Initial PGD/PMD/PTE\n"); -#endif - print_vmalloc_first_tables(); - - printk("Allocating 2 bytes\n"); - a = vmalloc(2); - print_vmalloc_first_tables(); - - printk("Allocating 4100 bytes\n"); - b = vmalloc(4100); - print_vmalloc_first_tables(); - - printk("Allocating 20234 bytes\n"); - c = vmalloc(20234); - print_vmalloc_first_tables(); - -#ifdef VM_TEST_FAULT - /* Here you may want to fault ! */ - -#ifdef VM_TEST_RTLBMISS - printk("Ready to fault upon read.\n"); - if (* (char *) a) { - printk("RTLBMISSed on area a !\n"); - } - printk("RTLBMISSed on area a !\n"); -#endif - -#ifdef VM_TEST_WTLBMISS - printk("Ready to fault upon write.\n"); - *((char *) b) = 'L'; - printk("WTLBMISSed on area b !\n"); -#endif - -#endif /* VM_TEST_FAULT */ - - printk("Deallocating the 4100 byte chunk\n"); - vfree(b); - print_vmalloc_first_tables(); - - printk("Deallocating the 2 byte chunk\n"); - vfree(a); - print_vmalloc_first_tables(); - - printk("Deallocating the last chunk\n"); - vfree(c); - print_vmalloc_first_tables(); -} - -extern unsigned long volatile jiffies; -int once = 0; -unsigned long old_jiffies; -int pid = -1, pgid = -1; - -void idle_trace(void) -{ - - _syscall0(int, getpid) - _syscall1(int, getpgid, int, pid) - - if (!once) { - /* VM allocation/deallocation simple test */ - test_VM(); - pid = getpid(); - - printk("Got all through to Idle !!\n"); - printk("I'm now going to loop forever ...\n"); - printk("Any ! below is a timer tick.\n"); - printk("Any . below is a getpgid system call from pid = %d.\n", pid); - - - old_jiffies = jiffies; - once++; - } - - if (old_jiffies != jiffies) { - old_jiffies = jiffies - old_jiffies; - switch (old_jiffies) { - case 1: - printk("!"); - break; - case 2: - printk("!!"); - break; - case 3: - printk("!!!"); - break; - case 4: - printk("!!!!"); - break; - default: - printk("(%d!)", (int) old_jiffies); - } - old_jiffies = jiffies; - } - pgid = getpgid(pid); - printk("."); -} -#else -#define idle_trace() do { } while (0) -#endif /* IDLE_TRACE */ - static int hlt_counter = 1; #define HARD_IDLE_TIMEOUT (HZ / 3) @@ -323,7 +78,6 @@ void cpu_idle(void) local_irq_disable(); while (!need_resched()) { local_irq_enable(); - idle_trace(); hlt(); local_irq_disable(); } @@ -619,6 +376,10 @@ void free_task_struct(struct task_struct /* * Create a kernel thread */ +ATTRIB_NORET void kernel_thread_helper(void *arg, int (*fn)(void *)) +{ + do_exit(fn(arg)); +} /* * This is the mechanism for creating a new kernel thread. @@ -630,19 +391,17 @@ void free_task_struct(struct task_struct */ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) { - /* A bit less processor dependent than older sh ... */ - unsigned int reply; + struct pt_regs regs; -static __inline__ _syscall2(int,clone,unsigned long,flags,unsigned long,newsp) -static __inline__ _syscall1(int,exit,int,ret) + memset(®s, 0, sizeof(regs)); + regs.regs[2] = (unsigned long)arg; + regs.regs[3] = (unsigned long)fn; - reply = clone(flags | CLONE_VM, 0); - if (!reply) { - /* Child */ - reply = exit(fn(arg)); - } + regs.pc = (unsigned long)kernel_thread_helper; + regs.sr = (1 << 30); - return reply; + return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, + ®s, 0, NULL, NULL); } /* |
From: Arnd B. <ar...@ar...> - 2006-08-27 23:58:56
|
sh64 is using system call macros to call some functions from the kernel. Remove those so we can get rid of kernel syscalls. This is probably not the best implementation and may need to be redone. Signed-off-by: Arnd Bergmann <ar...@ar...> Index: linux-cg/arch/sh64/kernel/process.c =================================================================== --- linux-cg.orig/arch/sh64/kernel/process.c 2006-08-27 23:36:34.000000000 +0200 +++ linux-cg/arch/sh64/kernel/process.c 2006-08-27 23:40:13.000000000 +0200 @@ -32,7 +32,6 @@ #undef IDLE_TRACE /* Temporary flags/tests. All to be removed/undefined. END */ -#define __KERNEL_SYSCALLS__ #include <stdarg.h> #include <linux/kernel.h> @@ -230,13 +229,10 @@ void idle_trace(void) { - _syscall0(int, getpid) - _syscall1(int, getpgid, int, pid) - if (!once) { /* VM allocation/deallocation simple test */ test_VM(); - pid = getpid(); + pid = sys_getpid(); printk("Got all through to Idle !!\n"); printk("I'm now going to loop forever ...\n"); @@ -268,7 +264,7 @@ } old_jiffies = jiffies; } - pgid = getpgid(pid); + pgid = sys_getpgid(pid); printk("."); } #else @@ -628,18 +624,23 @@ * a system call from a "real" process, but the process memory space will * not be free'd until both the parent and the child have exited. */ +#error please implement a working kernel_thread function like the other architectures +/* _syscallN() does not work any more. this probably needs to call + * do_fork directly */ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) { - /* A bit less processor dependent than older sh ... */ - unsigned int reply; - -static __inline__ _syscall2(int,clone,unsigned long,flags,unsigned long,newsp) -static __inline__ _syscall1(int,exit,int,ret) + register unsigned long reply asm ("r9") = ((0x13 << 16) | __NR_clone); + register unsigned long __flags asm ("r2") = flags | CLONE_VM; + register unsigned long __newsp asm ("r3") = 0; + + __asm__ __volatile__ ("trapa %1 !\t\t\t clone(%2,%3)" + : "=r" (__sc0) : "r" (__sc0), "r" (__sc2), "r" (__sc3)); + __asm__ __volatile__ ("!dummy %0 %1" + : : "r" (__sc0), "r" (__sc2), "r" (__sc3) : "memory"); - reply = clone(flags | CLONE_VM, 0); if (!reply) { /* Child */ - reply = exit(fn(arg)); + reply = sys_exit(fn(arg)); } return reply; -- |
From: Dave H. <hav...@us...> - 2006-03-09 20:40:52
|
Just about every architecture defines some macros to do operations on pfns. They're all virtually identical. This patch consolidates all of them. One minor glitch is that at least i386 uses them in a very skeletal header file. To keep away from #include dependency hell, I stuck the new definitions in a new, isolated header. Of all of the implementations, sh64 is the only one that varied by a bit. It used some masks to ensure that any sign-extension got ripped away before the arithmetic is done. Was this simply being cautious, or should we try to replicate this behavior in the generic version because it was really needed? Any compile testing of this patch would be greatly appreciated. --- include/asm-alpha/numnodes.h | 0 work-dave/arch/alpha/kernel/setup.c | 9 +-------- work-dave/arch/alpha/mm/numa.c | 4 +--- work-dave/arch/arm26/mm/init.c | 7 +------ work-dave/arch/cris/kernel/setup.c | 5 +---- work-dave/arch/i386/kernel/setup.c | 1 + work-dave/arch/i386/mm/discontig.c | 1 + work-dave/arch/m32r/kernel/setup.c | 1 + work-dave/arch/m32r/mm/discontig.c | 1 + work-dave/arch/m32r/mm/init.c | 1 + work-dave/arch/mips/ite-boards/ivr/init.c | 3 --- work-dave/arch/mips/ite-boards/qed-4n-s01b/init.c | 3 --- work-dave/arch/mips/kernel/setup.c | 9 +-------- work-dave/arch/mips/mips-boards/generic/memory.c | 7 ++----- work-dave/arch/mips/mips-boards/sim/sim_mem.c | 7 ++----- work-dave/arch/mips/mm/init.c | 4 +--- work-dave/arch/mips/sgi-ip27/ip27-memory.c | 3 +-- work-dave/arch/sh/kernel/setup.c | 5 +---- work-dave/arch/sh64/kernel/setup.c | 1 + work-dave/arch/um/kernel/physmem.c | 3 +-- work-dave/include/asm-i386/setup.h | 4 +--- work-dave/include/asm-m32r/setup.h | 4 ---- work-dave/include/asm-sh64/platform.h | 5 ----- work-dave/include/linux/pfn.h | 9 +++++++++ 24 files changed, 29 insertions(+), 68 deletions(-) diff -puN include/linux/mmzone.h~unify_PFN_macros include/linux/mmzone.h diff -puN arch/alpha/kernel/setup.c~unify_PFN_macros arch/alpha/kernel/setup.c --- work/arch/alpha/kernel/setup.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/alpha/kernel/setup.c 2006-03-09 11:22:46.000000000 -0800 @@ -34,6 +34,7 @@ #include <linux/root_dev.h> #include <linux/initrd.h> #include <linux/eisa.h> +#include <linux/pfn.h> #ifdef CONFIG_MAGIC_SYSRQ #include <linux/sysrq.h> #include <linux/reboot.h> @@ -241,9 +242,6 @@ reserve_std_resources(void) request_resource(io, standard_io_resources+i); } -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) #define PFN_MAX PFN_DOWN(0x80000000) #define for_each_mem_cluster(memdesc, cluster, i) \ for ((cluster) = (memdesc)->cluster, (i) = 0; \ @@ -472,11 +470,6 @@ page_is_ram(unsigned long pfn) return 0; } -#undef PFN_UP -#undef PFN_DOWN -#undef PFN_PHYS -#undef PFN_MAX - void __init setup_arch(char **cmdline_p) { diff -puN arch/alpha/mm/numa.c~unify_PFN_macros arch/alpha/mm/numa.c --- work/arch/alpha/mm/numa.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/alpha/mm/numa.c 2006-03-09 11:22:46.000000000 -0800 @@ -13,6 +13,7 @@ #include <linux/bootmem.h> #include <linux/swap.h> #include <linux/initrd.h> +#include <linux/pfn.h> #include <asm/hwrpb.h> #include <asm/pgalloc.h> @@ -27,9 +28,6 @@ bootmem_data_t node_bdata[MAX_NUMNODES]; #define DBGDCONT(args...) #endif -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) #define for_each_mem_cluster(memdesc, cluster, i) \ for ((cluster) = (memdesc)->cluster, (i) = 0; \ (i) < (memdesc)->numclusters; (i)++, (cluster)++) diff -puN arch/arm26/mm/init.c~unify_PFN_macros arch/arm26/mm/init.c --- work/arch/arm26/mm/init.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/arm26/mm/init.c 2006-03-09 11:22:46.000000000 -0800 @@ -23,6 +23,7 @@ #include <linux/initrd.h> #include <linux/bootmem.h> #include <linux/blkdev.h> +#include <linux/pfn.h> #include <asm/segment.h> #include <asm/mach-types.h> @@ -101,12 +102,6 @@ struct node_info { int bootmap_pages; }; -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) -#define PFN_UP(x) (PAGE_ALIGN(x) >> PAGE_SHIFT) -#define PFN_SIZE(x) ((x) >> PAGE_SHIFT) -#define PFN_RANGE(s,e) PFN_SIZE(PAGE_ALIGN((unsigned long)(e)) - \ - (((unsigned long)(s)) & PAGE_MASK)) - /* * FIXME: We really want to avoid allocating the bootmap bitmap * over the top of the initrd. Hopefully, this is located towards diff -puN arch/m32r/mm/discontig.c~unify_PFN_macros arch/m32r/mm/discontig.c --- work/arch/m32r/mm/discontig.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/m32r/mm/discontig.c 2006-03-09 11:22:46.000000000 -0800 @@ -13,6 +13,7 @@ #include <linux/initrd.h> #include <linux/nodemask.h> #include <linux/module.h> +#include <linux/pfn.h> #include <asm/setup.h> diff -puN arch/cris/kernel/setup.c~unify_PFN_macros arch/cris/kernel/setup.c --- work/arch/cris/kernel/setup.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/cris/kernel/setup.c 2006-03-09 11:22:46.000000000 -0800 @@ -18,6 +18,7 @@ #include <linux/seq_file.h> #include <linux/tty.h> #include <linux/utsname.h> +#include <linux/pfn.h> #include <asm/setup.h> @@ -88,10 +89,6 @@ setup_arch(char **cmdline_p) init_mm.end_data = (unsigned long) &_edata; init_mm.brk = (unsigned long) &_end; -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) - /* min_low_pfn points to the start of DRAM, start_pfn points * to the first DRAM pages after the kernel, and max_low_pfn * to the end of DRAM. diff -puN arch/mips/ite-boards/ivr/init.c~unify_PFN_macros arch/mips/ite-boards/ivr/init.c --- work/arch/mips/ite-boards/ivr/init.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/mips/ite-boards/ivr/init.c 2006-03-09 11:22:46.000000000 -0800 @@ -45,9 +45,6 @@ extern void __init prom_init_cmdline(vo extern unsigned long __init prom_get_memsize(void); extern void __init it8172_init_ram_resource(unsigned long memsize); -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) - const char *get_system_type(void) { return "Globespan IVR"; diff -puN arch/mips/mips-boards/generic/memory.c~unify_PFN_macros arch/mips/mips-boards/generic/memory.c --- work/arch/mips/mips-boards/generic/memory.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/mips/mips-boards/generic/memory.c 2006-03-09 11:22:46.000000000 -0800 @@ -49,9 +49,6 @@ static char *mtypes[3] = { /* References to section boundaries */ extern char _end; -#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) - - struct prom_pmemblock * __init prom_getmdesc(void) { char *memsize_str; @@ -109,10 +106,10 @@ struct prom_pmemblock * __init prom_getm mdesc[3].type = yamon_dontuse; mdesc[3].base = 0x00100000; - mdesc[3].size = CPHYSADDR(PFN_ALIGN(&_end)) - mdesc[3].base; + mdesc[3].size = CPHYSADDR(PAGE_ALIGN(&_end)) - mdesc[3].base; mdesc[4].type = yamon_free; - mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end)); + mdesc[4].base = CPHYSADDR(PAGE_ALIGN(&_end)); mdesc[4].size = memsize - mdesc[4].base; return &mdesc[0]; diff -puN arch/mips/mips-boards/sim/sim_mem.c~unify_PFN_macros arch/mips/mips-boards/sim/sim_mem.c --- work/arch/mips/mips-boards/sim/sim_mem.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/mips/mips-boards/sim/sim_mem.c 2006-03-09 11:22:46.000000000 -0800 @@ -42,9 +42,6 @@ static char *mtypes[3] = { /* References to section boundaries */ extern char _end; -#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) - - struct prom_pmemblock * __init prom_getmdesc(void) { unsigned int memsize; @@ -64,10 +61,10 @@ struct prom_pmemblock * __init prom_getm mdesc[2].type = simmem_reserved; mdesc[2].base = 0x00100000; - mdesc[2].size = CPHYSADDR(PFN_ALIGN(&_end)) - mdesc[2].base; + mdesc[2].size = CPHYSADDR(PAGE_ALIGN(&_end)) - mdesc[2].base; mdesc[3].type = simmem_free; - mdesc[3].base = CPHYSADDR(PFN_ALIGN(&_end)); + mdesc[3].base = CPHYSADDR(PAGE_ALIGN(&_end)); mdesc[3].size = memsize - mdesc[3].base; return &mdesc[0]; diff -puN arch/mips/ite-boards/qed-4n-s01b/init.c~unify_PFN_macros arch/mips/ite-boards/qed-4n-s01b/init.c --- work/arch/mips/ite-boards/qed-4n-s01b/init.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/mips/ite-boards/qed-4n-s01b/init.c 2006-03-09 11:22:46.000000000 -0800 @@ -45,9 +45,6 @@ extern void __init prom_init_cmdline(vo extern unsigned long __init prom_get_memsize(void); extern void __init it8172_init_ram_resource(unsigned long memsize); -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) - const char *get_system_type(void) { return "ITE QED-4N-S01B"; diff -puN arch/mips/kernel/setup.c~unify_PFN_macros arch/mips/kernel/setup.c --- work/arch/mips/kernel/setup.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/mips/kernel/setup.c 2006-03-09 11:22:46.000000000 -0800 @@ -34,6 +34,7 @@ #include <linux/highmem.h> #include <linux/console.h> #include <linux/mmzone.h> +#include <linux/pfn.h> #include <asm/addrspace.h> #include <asm/bootinfo.h> @@ -257,10 +258,6 @@ static inline int parse_rd_cmdline(unsig return 0; } -#define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT) -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) - #define MAXMEM HIGHMEM_START #define MAXMEM_PFN PFN_DOWN(MAXMEM) @@ -504,10 +501,6 @@ static inline void resource_init(void) } } -#undef PFN_UP -#undef PFN_DOWN -#undef PFN_PHYS - #undef MAXMEM #undef MAXMEM_PFN diff -puN arch/mips/mm/init.c~unify_PFN_macros arch/mips/mm/init.c --- work/arch/mips/mm/init.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/mips/mm/init.c 2006-03-09 11:22:46.000000000 -0800 @@ -25,6 +25,7 @@ #include <linux/highmem.h> #include <linux/swap.h> #include <linux/proc_fs.h> +#include <linux/pfn.h> #include <asm/bootinfo.h> #include <asm/cachectl.h> @@ -176,9 +177,6 @@ void __init paging_init(void) free_area_init(zones_size); } -#define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT) -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) - static inline int page_is_ram(unsigned long pagenr) { int i; diff -puN arch/mips/sgi-ip27/ip27-memory.c~unify_PFN_macros arch/mips/sgi-ip27/ip27-memory.c --- work/arch/mips/sgi-ip27/ip27-memory.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/mips/sgi-ip27/ip27-memory.c 2006-03-09 11:22:46.000000000 -0800 @@ -19,6 +19,7 @@ #include <linux/nodemask.h> #include <linux/swap.h> #include <linux/bootmem.h> +#include <linux/pfn.h> #include <asm/page.h> #include <asm/sections.h> @@ -28,8 +29,6 @@ #include <asm/sn/sn_private.h> -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) - #define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) #define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) diff -puN arch/sh/kernel/setup.c~unify_PFN_macros arch/sh/kernel/setup.c --- work/arch/sh/kernel/setup.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/sh/kernel/setup.c 2006-03-09 11:22:46.000000000 -0800 @@ -20,6 +20,7 @@ #include <linux/root_dev.h> #include <linux/utsname.h> #include <linux/cpu.h> +#include <linux/pfn.h> #include <asm/uaccess.h> #include <asm/io.h> #include <asm/sections.h> @@ -275,10 +276,6 @@ void __init setup_arch(char **cmdline_p) sh_mv_setup(cmdline_p); -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) - /* * Find the highest page frame number we have available */ diff -puN arch/um/kernel/physmem.c~unify_PFN_macros arch/um/kernel/physmem.c --- work/arch/um/kernel/physmem.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/um/kernel/physmem.c 2006-03-09 11:22:46.000000000 -0800 @@ -9,6 +9,7 @@ #include "linux/vmalloc.h" #include "linux/bootmem.h" #include "linux/module.h" +#include "linux/pfn.h" #include "asm/types.h" #include "asm/pgtable.h" #include "kern_util.h" @@ -316,8 +317,6 @@ void map_memory(unsigned long virt, unsi } } -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) - extern int __syscall_stub_start, __binary_start; void setup_physmem(unsigned long start, unsigned long reserve_end, diff -puN include/asm-i386/setup.h~unify_PFN_macros include/asm-i386/setup.h --- work/include/asm-i386/setup.h~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/include/asm-i386/setup.h 2006-03-09 11:22:46.000000000 -0800 @@ -6,9 +6,7 @@ #ifndef _i386_SETUP_H #define _i386_SETUP_H -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) +#include <linux/pfn.h> /* * Reserved space for vmalloc and iomap - defined in asm/page.h diff -puN include/asm-m32r/setup.h~unify_PFN_macros include/asm-m32r/setup.h --- work/include/asm-m32r/setup.h~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/include/asm-m32r/setup.h 2006-03-09 11:22:46.000000000 -0800 @@ -24,10 +24,6 @@ #define RAMDISK_PROMPT_FLAG (0x8000) #define RAMDISK_LOAD_FLAG (0x4000) -#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) -#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) - extern unsigned long memory_start; extern unsigned long memory_end; diff -puN include/asm-sh64/platform.h~unify_PFN_macros include/asm-sh64/platform.h --- work/include/asm-sh64/platform.h~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/include/asm-sh64/platform.h 2006-03-09 11:22:46.000000000 -0800 @@ -61,9 +61,4 @@ extern int platform_int_priority[NR_INTC #define code_resource (platform_parms.kram_res_p[STANDARD_KRAM_RESOURCES - 2]) #define data_resource (platform_parms.kram_res_p[STANDARD_KRAM_RESOURCES - 1]) -/* Be prepared to 64-bit sign extensions */ -#define PFN_UP(x) ((((x) + PAGE_SIZE-1) >> PAGE_SHIFT) & 0x000fffff) -#define PFN_DOWN(x) (((x) >> PAGE_SHIFT) & 0x000fffff) -#define PFN_PHYS(x) ((x) << PAGE_SHIFT) - #endif /* __ASM_SH64_PLATFORM_H */ diff -puN include/asm-generic/page.h~unify_PFN_macros include/asm-generic/page.h diff -puN include/asm-alpha/page.h~unify_PFN_macros include/asm-alpha/page.h diff -puN include/asm-cris/page.h~unify_PFN_macros include/asm-cris/page.h diff -puN include/asm-m68knommu/page.h~unify_PFN_macros include/asm-m68knommu/page.h diff -puN include/asm-m68k/page.h~unify_PFN_macros include/asm-m68k/page.h diff -puN include/asm-xtensa/page.h~unify_PFN_macros include/asm-xtensa/page.h diff -puN /dev/null include/linux/pfn.h --- /dev/null 2005-03-30 22:36:15.000000000 -0800 +++ work-dave/include/linux/pfn.h 2006-03-09 11:22:46.000000000 -0800 @@ -0,0 +1,9 @@ +#ifndef _LINUX_PFN_H_ +#define _LINUX_PFN_H_ + +#define PFN_ALIGN(x) (((unsigned long)(x) + (PAGE_SIZE - 1)) & PAGE_MASK) +#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) +#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) +#define PFN_PHYS(x) ((x) << PAGE_SHIFT) + +#endif diff -puN arch/i386/kernel/setup.c~unify_PFN_macros arch/i386/kernel/setup.c --- work/arch/i386/kernel/setup.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/i386/kernel/setup.c 2006-03-09 12:40:02.000000000 -0800 @@ -46,6 +46,7 @@ #include <linux/kexec.h> #include <linux/crash_dump.h> #include <linux/dmi.h> +#include <linux/pfn.h> #include <video/edid.h> diff -puN arch/i386/mm/discontig.c~unify_PFN_macros arch/i386/mm/discontig.c --- work/arch/i386/mm/discontig.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/i386/mm/discontig.c 2006-03-09 12:40:02.000000000 -0800 @@ -31,6 +31,7 @@ #include <linux/nodemask.h> #include <linux/module.h> #include <linux/kexec.h> +#include <linux/pfn.h> #include <asm/e820.h> #include <asm/setup.h> diff -puN arch/m32r/kernel/setup.c~unify_PFN_macros arch/m32r/kernel/setup.c --- work/arch/m32r/kernel/setup.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/m32r/kernel/setup.c 2006-03-09 11:22:46.000000000 -0800 @@ -24,6 +24,7 @@ #include <linux/tty.h> #include <linux/cpu.h> #include <linux/nodemask.h> +#include <linux/pfn.h> #include <asm/processor.h> #include <asm/pgtable.h> diff -puN arch/sh64/kernel/setup.c~unify_PFN_macros arch/sh64/kernel/setup.c --- work/arch/sh64/kernel/setup.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/sh64/kernel/setup.c 2006-03-09 11:22:46.000000000 -0800 @@ -48,6 +48,7 @@ #include <linux/root_dev.h> #include <linux/cpu.h> #include <linux/initrd.h> +#include <linux/pfn.h> #include <asm/processor.h> #include <asm/page.h> #include <asm/pgtable.h> diff -puN arch/m32r/mm/init.c~unify_PFN_macros arch/m32r/mm/init.c --- work/arch/m32r/mm/init.c~unify_PFN_macros 2006-03-09 11:22:46.000000000 -0800 +++ work-dave/arch/m32r/mm/init.c 2006-03-09 11:22:46.000000000 -0800 @@ -18,6 +18,7 @@ #include <linux/highmem.h> #include <linux/bitops.h> #include <linux/nodemask.h> +#include <linux/pfn.h> #include <asm/types.h> #include <asm/processor.h> #include <asm/page.h> diff -puN include/linux/mm.h~unify_PFN_macros include/linux/mm.h diff -puN include/linux/numa.h~unify_PFN_macros include/linux/numa.h diff -puN include/asm-x86_64/numnodes.h~unify_PFN_macros include/asm-x86_64/numnodes.h diff -puN include/asm-sh/numnodes.h~unify_PFN_macros include/asm-sh/numnodes.h diff -puN include/asm-parisc/numnodes.h~unify_PFN_macros include/asm-parisc/numnodes.h diff -puN include/asm-mips/numnodes.h~unify_PFN_macros include/asm-mips/numnodes.h diff -puN include/asm-m32r/numnodes.h~unify_PFN_macros include/asm-m32r/numnodes.h diff -puN include/asm-alpha/numnodes.h~unify_PFN_macros include/asm-alpha/numnodes.h _ |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:15
|
This patch introduces the C-language equivalent of the function: int fls64(__u64 x); In include/asm-generic/bitops/fls64.h This code largely copied from: include/linux/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/fls64.h | 12 ++++++++++++ 1 files changed, 12 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/fls64.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/fls64.h @@ -0,0 +1,12 @@ +#ifndef _ASM_GENERIC_BITOPS_FLS64_H_ +#define _ASM_GENERIC_BITOPS_FLS64_H_ + +static inline int fls64(__u64 x) +{ + __u32 h = x >> 32; + if (h) + return fls(h) + 32; + return fls(x); +} + +#endif /* _ASM_GENERIC_BITOPS_FLS64_H_ */ -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:15
|
This patch introduces the C-language equivalents of the functions below: int ext2_set_bit(int nr, volatile unsigned long *addr); int ext2_clear_bit(int nr, volatile unsigned long *addr); int ext2_test_bit(int nr, const volatile unsigned long *addr); unsigned long ext2_find_first_zero_bit(const unsigned long *addr, unsigned long size); unsinged long ext2_find_next_zero_bit(const unsigned long *addr, unsigned long size); In include/asm-generic/bitops/ext2-non-atomic.h This code largely copied from: include/asm-powerpc/bitops.h include/asm-parisc/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/ext2-non-atomic.h | 18 ++++++ include/asm-generic/bitops/le.h | 53 +++++++++++++++++++ lib/find_next_bit.c | 73 +++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/ext2-non-atomic.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/ext2-non-atomic.h @@ -0,0 +1,18 @@ +#ifndef _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ +#define _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ + +#include <asm-generic/bitops/le.h> + +#define ext2_set_bit(nr,addr) \ + generic___test_and_set_le_bit((nr),(unsigned long *)(addr)) +#define ext2_clear_bit(nr,addr) \ + generic___test_and_clear_le_bit((nr),(unsigned long *)(addr)) + +#define ext2_test_bit(nr,addr) \ + generic_test_le_bit((nr),(unsigned long *)(addr)) +#define ext2_find_first_zero_bit(addr, size) \ + generic_find_first_zero_le_bit((unsigned long *)(addr), (size)) +#define ext2_find_next_zero_bit(addr, size, off) \ + generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off)) + +#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */ Index: 2.6-rc/include/asm-generic/bitops/le.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/le.h @@ -0,0 +1,53 @@ +#ifndef _ASM_GENERIC_BITOPS_LE_H_ +#define _ASM_GENERIC_BITOPS_LE_H_ + +#include <asm/types.h> +#include <asm/byteorder.h> + +#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) + +#if defined(__LITTLE_ENDIAN) + +#define generic_test_le_bit(nr, addr) test_bit(nr, addr) +#define generic___set_le_bit(nr, addr) __set_bit(nr, addr) +#define generic___clear_le_bit(nr, addr) __clear_bit(nr, addr) + +#define generic_test_and_set_le_bit(nr, addr) test_and_set_bit(nr, addr) +#define generic_test_and_clear_le_bit(nr, addr) test_and_clear_bit(nr, addr) + +#define generic___test_and_set_le_bit(nr, addr) __test_and_set_bit(nr, addr) +#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr) + +#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset) + +#elif defined(__BIG_ENDIAN) + +#define generic_test_le_bit(nr, addr) \ + test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) +#define generic___set_le_bit(nr, addr) \ + __set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) +#define generic___clear_le_bit(nr, addr) \ + __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) + +#define generic_test_and_set_le_bit(nr, addr) \ + test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) +#define generic_test_and_clear_le_bit(nr, addr) \ + test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) + +#define generic___test_and_set_le_bit(nr, addr) \ + __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) +#define generic___test_and_clear_le_bit(nr, addr) \ + __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) + +extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, + unsigned long size, unsigned long offset); + +#else +#error "Please fix <asm/byteorder.h>" +#endif + +#define generic_find_first_zero_le_bit(addr, size) \ + generic_find_next_zero_le_bit((addr), (size), 0) + +#endif /* _ASM_GENERIC_BITOPS_LE_H_ */ Index: 2.6-rc/lib/find_next_bit.c =================================================================== --- 2.6-rc.orig/lib/find_next_bit.c +++ 2.6-rc/lib/find_next_bit.c @@ -12,6 +12,7 @@ #include <linux/bitops.h> #include <linux/module.h> #include <asm/types.h> +#include <asm/byteorder.h> #define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) @@ -106,3 +107,75 @@ found_middle: } EXPORT_SYMBOL(find_next_zero_bit); + +#ifdef __BIG_ENDIAN + +/* include/linux/byteorder does not support "unsigned long" type */ +static inline unsigned long ext2_swabp(const unsigned long * x) +{ +#if BITS_PER_LONG == 64 + return (unsigned long) __swab64p((u64 *) x); +#elif BITS_PER_LONG == 32 + return (unsigned long) __swab32p((u32 *) x); +#else +#error BITS_PER_LONG not defined +#endif +} + +/* include/linux/byteorder doesn't support "unsigned long" type */ +static inline unsigned long ext2_swab(const unsigned long y) +{ +#if BITS_PER_LONG == 64 + return (unsigned long) __swab64((u64) y); +#elif BITS_PER_LONG == 32 + return (unsigned long) __swab32((u32) y); +#else +#error BITS_PER_LONG not defined +#endif +} + +unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, unsigned + long size, unsigned long offset) +{ + const unsigned long *p = addr + BITOP_WORD(offset); + unsigned long result = offset & ~(BITS_PER_LONG - 1); + unsigned long tmp; + + if (offset >= size) + return size; + size -= result; + offset &= (BITS_PER_LONG - 1UL); + if (offset) { + tmp = ext2_swabp(p++); + tmp |= (~0UL >> (BITS_PER_LONG - offset)); + if (size < BITS_PER_LONG) + goto found_first; + if (~tmp) + goto found_middle; + size -= BITS_PER_LONG; + result += BITS_PER_LONG; + } + + while (size & ~(BITS_PER_LONG - 1)) { + if (~(tmp = *(p++))) + goto found_middle_swap; + result += BITS_PER_LONG; + size -= BITS_PER_LONG; + } + if (!size) + return result; + tmp = ext2_swabp(p); +found_first: + tmp |= ~0UL << size; + if (tmp == ~0UL) /* Are any bits zero? */ + return result + size; /* Nope. Skip ffz */ +found_middle: + return result + ffz(tmp); + +found_middle_swap: + return result + ffz(ext2_swab(tmp)); +} + +EXPORT_SYMBOL(generic_find_next_zero_le_bit); + +#endif /* __BIG_ENDIAN */ -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:15
|
This patch introduces the C-language equivalent of the function: int sched_find_first_bit(const unsigned long *b); In include/asm-generic/bitops/sched.h This code largely copied from: include/asm-powerpc/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/sched.h | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/sched.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/sched.h @@ -0,0 +1,36 @@ +#ifndef _ASM_GENERIC_BITOPS_SCHED_H_ +#define _ASM_GENERIC_BITOPS_SCHED_H_ + +#include <linux/compiler.h> /* unlikely() */ +#include <asm/types.h> + +/* + * Every architecture must define this function. It's the fastest + * way of searching a 140-bit bitmap where the first 100 bits are + * unlikely to be set. It's guaranteed that at least one of the 140 + * bits is cleared. + */ +static inline int sched_find_first_bit(const unsigned long *b) +{ +#if BITS_PER_LONG == 64 + if (unlikely(b[0])) + return __ffs(b[0]); + if (unlikely(b[1])) + return __ffs(b[1]) + 64; + return __ffs(b[2]) + 128; +#elif BITS_PER_LONG == 32 + if (unlikely(b[0])) + return __ffs(b[0]); + if (unlikely(b[1])) + return __ffs(b[1]) + 32; + if (unlikely(b[2])) + return __ffs(b[2]) + 64; + if (b[3]) + return __ffs(b[3]) + 96; + return __ffs(b[4]) + 128; +#else +#error BITS_PER_LONG not defined +#endif +} + +#endif /* _ASM_GENERIC_BITOPS_SCHED_H_ */ -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:14
|
This patch introduces the C-language equivalents of the functions below: int minix_test_and_set_bit(int nr, volatile unsigned long *addr); int minix_set_bit(int nr, volatile unsigned long *addr); int minix_test_and_clear_bit(int nr, volatile unsigned long *addr); int minix_test_bit(int nr, const volatile unsigned long *addr); unsigned long minix_find_first_zero_bit(const unsigned long *addr, unsigned long size); In include/asm-generic/bitops/minix.h and include/asm-generic/bitops/minix-le.h This code largely copied from: include/asm-sparc/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/minix-le.h | 17 +++++++++++++++++ include/asm-generic/bitops/minix.h | 15 +++++++++++++++ 2 files changed, 32 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/minix.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/minix.h @@ -0,0 +1,15 @@ +#ifndef _ASM_GENERIC_BITOPS_MINIX_H_ +#define _ASM_GENERIC_BITOPS_MINIX_H_ + +#define minix_test_and_set_bit(nr,addr) \ + __test_and_set_bit((nr),(unsigned long *)(addr)) +#define minix_set_bit(nr,addr) \ + __set_bit((nr),(unsigned long *)(addr)) +#define minix_test_and_clear_bit(nr,addr) \ + __test_and_clear_bit((nr),(unsigned long *)(addr)) +#define minix_test_bit(nr,addr) \ + test_bit((nr),(unsigned long *)(addr)) +#define minix_find_first_zero_bit(addr,size) \ + find_first_zero_bit((unsigned long *)(addr),(size)) + +#endif /* _ASM_GENERIC_BITOPS_MINIX_H_ */ Index: 2.6-rc/include/asm-generic/bitops/minix-le.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/minix-le.h @@ -0,0 +1,17 @@ +#ifndef _ASM_GENERIC_BITOPS_MINIX_LE_H_ +#define _ASM_GENERIC_BITOPS_MINIX_LE_H_ + +#include <asm-generic/bitops/le.h> + +#define minix_test_and_set_bit(nr,addr) \ + generic___test_and_set_le_bit((nr),(unsigned long *)(addr)) +#define minix_set_bit(nr,addr) \ + generic___set_le_bit((nr),(unsigned long *)(addr)) +#define minix_test_and_clear_bit(nr,addr) \ + generic___test_and_clear_le_bit((nr),(unsigned long *)(addr)) +#define minix_test_bit(nr,addr) \ + generic_test_le_bit((nr),(unsigned long *)(addr)) +#define minix_find_first_zero_bit(addr,size) \ + generic_find_first_zero_le_bit((unsigned long *)(addr),(size)) + +#endif /* _ASM_GENERIC_BITOPS_MINIX_LE_H_ */ -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:13
|
This patch introduces the C-language equivalents of the functions below: int ext2_set_bit_atomic(int nr, volatile unsigned long *addr); int ext2_clear_bit_atomic(int nr, volatile unsigned long *addr); In include/asm-generic/bitops/ext2-atomic.h This code largely copied from: include/asm-sparc/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/ext2-atomic.h | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/ext2-atomic.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/ext2-atomic.h @@ -0,0 +1,22 @@ +#ifndef _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ +#define _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ + +#define ext2_set_bit_atomic(lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_set_bit((nr), (unsigned long *)(addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#define ext2_clear_bit_atomic(lock, nr, addr) \ + ({ \ + int ret; \ + spin_lock(lock); \ + ret = ext2_clear_bit((nr), (unsigned long *)(addr)); \ + spin_unlock(lock); \ + ret; \ + }) + +#endif /* _ASM_GENERIC_BITOPS_EXT2_ATOMIC_H_ */ -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:11
|
This patch introduces the C-language equivalents of the functions below: unsigned int hweight32(unsigned int w); unsigned int hweight16(unsigned int w); unsigned int hweight8(unsigned int w); unsigned long hweight64(__u64 w); In include/asm-generic/bitops/hweight.h This code largely copied from: include/linux/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/hweight.h | 9 +++++ lib/Makefile | 1 lib/hweight.c | 54 +++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/hweight.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/hweight.h @@ -0,0 +1,9 @@ +#ifndef _ASM_GENERIC_BITOPS_HWEIGHT_H_ +#define _ASM_GENERIC_BITOPS_HWEIGHT_H_ + +extern unsigned int hweight32(unsigned int w); +extern unsigned int hweight16(unsigned int w); +extern unsigned int hweight8(unsigned int w); +extern unsigned long hweight64(__u64 w); + +#endif /* _ASM_GENERIC_BITOPS_HWEIGHT_H_ */ Index: 2.6-rc/lib/Makefile =================================================================== --- 2.6-rc.orig/lib/Makefile +++ 2.6-rc/lib/Makefile @@ -21,6 +21,7 @@ lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o +lib-$(CONFIG_GENERIC_HWEIGHT) += hweight.o obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o Index: 2.6-rc/lib/hweight.c =================================================================== --- /dev/null +++ 2.6-rc/lib/hweight.c @@ -0,0 +1,54 @@ +#include <linux/module.h> +#include <asm/types.h> + +/** + * hweightN - returns the hamming weight of a N-bit word + * @x: the word to weigh + * + * The Hamming Weight of a number is the total number of bits set in it. + */ + +unsigned int hweight32(unsigned int w) +{ + unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555); + res = (res & 0x33333333) + ((res >> 2) & 0x33333333); + res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F); + res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF); + return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF); +} +EXPORT_SYMBOL(hweight32); + +unsigned int hweight16(unsigned int w) +{ + unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555); + res = (res & 0x3333) + ((res >> 2) & 0x3333); + res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F); + return (res & 0x00FF) + ((res >> 8) & 0x00FF); +} +EXPORT_SYMBOL(hweight16); + +unsigned int hweight8(unsigned int w) +{ + unsigned int res = (w & 0x55) + ((w >> 1) & 0x55); + res = (res & 0x33) + ((res >> 2) & 0x33); + return (res & 0x0F) + ((res >> 4) & 0x0F); +} +EXPORT_SYMBOL(hweight8); + +unsigned long hweight64(__u64 w) +{ +#if BITS_PER_LONG == 32 + return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w); +#elif BITS_PER_LONG == 64 + u64 res; + res = (w & 0x5555555555555555ul) + ((w >> 1) & 0x5555555555555555ul); + res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); + res = (res & 0x0F0F0F0F0F0F0F0Ful) + ((res >> 4) & 0x0F0F0F0F0F0F0F0Ful); + res = (res & 0x00FF00FF00FF00FFul) + ((res >> 8) & 0x00FF00FF00FF00FFul); + res = (res & 0x0000FFFF0000FFFFul) + ((res >> 16) & 0x0000FFFF0000FFFFul); + return (res & 0x00000000FFFFFFFFul) + ((res >> 32) & 0x00000000FFFFFFFFul); +#else +#error BITS_PER_LONG not defined +#endif +} +EXPORT_SYMBOL(hweight64); -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:11
|
This patch introduces the C-language equivalent of the function: int fls(int x); In include/asm-generic/bitops/fls.h This code largely copied from: include/linux/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/fls.h | 41 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 41 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/fls.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/fls.h @@ -0,0 +1,41 @@ +#ifndef _ASM_GENERIC_BITOPS_FLS_H_ +#define _ASM_GENERIC_BITOPS_FLS_H_ + +/** + * fls - find last (most-significant) bit set + * @x: the word to search + * + * This is defined the same way as ffs. + * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. + */ + +static inline int fls(int x) +{ + int r = 32; + + if (!x) + return 0; + if (!(x & 0xffff0000u)) { + x <<= 16; + r -= 16; + } + if (!(x & 0xff000000u)) { + x <<= 8; + r -= 8; + } + if (!(x & 0xf0000000u)) { + x <<= 4; + r -= 4; + } + if (!(x & 0xc0000000u)) { + x <<= 2; + r -= 2; + } + if (!(x & 0x80000000u)) { + x <<= 1; + r -= 1; + } + return r; +} + +#endif /* _ASM_GENERIC_BITOPS_FLS_H_ */ -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:11
|
This patch introduces the C-language equivalents of the functions below: unsigned logn find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset); unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, unsigned long offset); unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size); unsigned long find_first_bit(const unsigned long *addr, unsigned long size); In include/asm-generic/bitops/find.h This code largely copied from: arch/powerpc/lib/bitops.c Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/find.h | 13 ++++ lib/find_next_bit.c | 114 +++++++++++++++++++++++++++----------- 2 files changed, 95 insertions(+), 32 deletions(-) Index: 2.6-rc/include/asm-generic/bitops/find.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/find.h @@ -0,0 +1,13 @@ +#ifndef _ASM_GENERIC_BITOPS_FIND_H_ +#define _ASM_GENERIC_BITOPS_FIND_H_ + +extern unsigned long find_next_bit(const unsigned long *addr, unsigned long + size, unsigned long offset); + +extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned + long size, unsigned long offset); + +#define find_first_bit(addr, size) find_next_bit((addr), (size), 0) +#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0) + +#endif /*_ASM_GENERIC_BITOPS_FIND_H_ */ Index: 2.6-rc/lib/find_next_bit.c =================================================================== --- 2.6-rc.orig/lib/find_next_bit.c +++ 2.6-rc/lib/find_next_bit.c @@ -11,48 +11,98 @@ #include <linux/bitops.h> #include <linux/module.h> +#include <asm/types.h> -int find_next_bit(const unsigned long *addr, int size, int offset) +#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) + +/** + * find_next_bit - find the next set bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The maximum size to search + */ +unsigned long find_next_bit(const unsigned long *addr, unsigned long size, + unsigned long offset) { - const unsigned long *base; - const int NBITS = sizeof(*addr) * 8; + const unsigned long *p = addr + BITOP_WORD(offset); + unsigned long result = offset & ~(BITS_PER_LONG-1); unsigned long tmp; - base = addr; + if (offset >= size) + return size; + size -= result; + offset %= BITS_PER_LONG; if (offset) { - int suboffset; - - addr += offset / NBITS; - - suboffset = offset % NBITS; - if (suboffset) { - tmp = *addr; - tmp >>= suboffset; - if (tmp) - goto finish; - } - - addr++; + tmp = *(p++); + tmp &= (~0UL << offset); + if (size < BITS_PER_LONG) + goto found_first; + if (tmp) + goto found_middle; + size -= BITS_PER_LONG; + result += BITS_PER_LONG; } + while (size & ~(BITS_PER_LONG-1)) { + if ((tmp = *(p++))) + goto found_middle; + result += BITS_PER_LONG; + size -= BITS_PER_LONG; + } + if (!size) + return result; + tmp = *p; + +found_first: + tmp &= (~0UL >> (BITS_PER_LONG - size)); + if (tmp == 0UL) /* Are any bits set? */ + return result + size; /* Nope. */ +found_middle: + return result + __ffs(tmp); +} - while ((tmp = *addr) == 0) - addr++; +EXPORT_SYMBOL(find_next_bit); - offset = (addr - base) * NBITS; +/* + * This implementation of find_{first,next}_zero_bit was stolen from + * Linus' asm-alpha/bitops.h. + */ +unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, + unsigned long offset) +{ + const unsigned long *p = addr + BITOP_WORD(offset); + unsigned long result = offset & ~(BITS_PER_LONG-1); + unsigned long tmp; - finish: - /* count the remaining bits without using __ffs() since that takes a 32-bit arg */ - while (!(tmp & 0xff)) { - offset += 8; - tmp >>= 8; + if (offset >= size) + return size; + size -= result; + offset %= BITS_PER_LONG; + if (offset) { + tmp = *(p++); + tmp |= ~0UL >> (BITS_PER_LONG - offset); + if (size < BITS_PER_LONG) + goto found_first; + if (~tmp) + goto found_middle; + size -= BITS_PER_LONG; + result += BITS_PER_LONG; } - - while (!(tmp & 1)) { - offset++; - tmp >>= 1; + while (size & ~(BITS_PER_LONG-1)) { + if (~(tmp = *(p++))) + goto found_middle; + result += BITS_PER_LONG; + size -= BITS_PER_LONG; } - - return offset; + if (!size) + return result; + tmp = *p; + +found_first: + tmp |= ~0UL << size; + if (tmp == ~0UL) /* Are any bits zero? */ + return result + size; /* Nope. */ +found_middle: + return result + ffz(tmp); } -EXPORT_SYMBOL(find_next_bit); +EXPORT_SYMBOL(find_next_zero_bit); -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:05:11
|
- remove __{,test_and_}{set,clear,change}_bit() and test_bit() - remove __ffs() - remove find_{next,first}{,_zero}_bit() - remove generic_hweight{32,16,8}() - remove sched_find_first_bit() - remove generic_ffs() - remove ext2_{set,clear,test,find_first_zero,find_next_zero}_bit() - remove ext2_{set,clear}_bit_atomic() - remove minix_{test,set,test_and_clear,test,find_first_zero}_bit() - remove generic_fls() - remove generic_fls64() Signed-off-by: Akinobu Mita <mi...@mi...> arch/sh64/Kconfig | 8 include/asm-sh64/bitops.h | 384 +--------------------------------------------- 2 files changed, 19 insertions(+), 373 deletions(-) Index: 2.6-rc/include/asm-sh64/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-sh64/bitops.h +++ 2.6-rc/include/asm-sh64/bitops.h @@ -31,16 +31,6 @@ static __inline__ void set_bit(int nr, v local_irq_restore(flags); } -static inline void __set_bit(int nr, void *addr) -{ - int mask; - unsigned int *a = addr; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - *a |= mask; -} - /* * clear_bit() doesn't provide any barrier for the compiler. */ @@ -58,15 +48,6 @@ static inline void clear_bit(int nr, vol local_irq_restore(flags); } -static inline void __clear_bit(int nr, volatile unsigned long *a) -{ - int mask; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - *a &= ~mask; -} - static __inline__ void change_bit(int nr, volatile void * addr) { int mask; @@ -80,16 +61,6 @@ static __inline__ void change_bit(int nr local_irq_restore(flags); } -static __inline__ void __change_bit(int nr, volatile void * addr) -{ - int mask; - volatile unsigned int *a = addr; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - *a ^= mask; -} - static __inline__ int test_and_set_bit(int nr, volatile void * addr) { int mask, retval; @@ -106,19 +77,6 @@ static __inline__ int test_and_set_bit(i return retval; } -static __inline__ int __test_and_set_bit(int nr, volatile void * addr) -{ - int mask, retval; - volatile unsigned int *a = addr; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - retval = (mask & *a) != 0; - *a |= mask; - - return retval; -} - static __inline__ int test_and_clear_bit(int nr, volatile void * addr) { int mask, retval; @@ -135,19 +93,6 @@ static __inline__ int test_and_clear_bit return retval; } -static __inline__ int __test_and_clear_bit(int nr, volatile void * addr) -{ - int mask, retval; - volatile unsigned int *a = addr; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - retval = (mask & *a) != 0; - *a &= ~mask; - - return retval; -} - static __inline__ int test_and_change_bit(int nr, volatile void * addr) { int mask, retval; @@ -164,23 +109,7 @@ static __inline__ int test_and_change_bi return retval; } -static __inline__ int __test_and_change_bit(int nr, volatile void * addr) -{ - int mask, retval; - volatile unsigned int *a = addr; - - a += nr >> 5; - mask = 1 << (nr & 0x1f); - retval = (mask & *a) != 0; - *a ^= mask; - - return retval; -} - -static __inline__ int test_bit(int nr, const volatile void *addr) -{ - return 1UL & (((const volatile unsigned int *) addr)[nr >> 5] >> (nr & 31)); -} +#include <asm-generic/bitops/non-atomic.h> static __inline__ unsigned long ffz(unsigned long word) { @@ -204,307 +133,16 @@ static __inline__ unsigned long ffz(unsi return result; } -/** - * __ffs - find first bit in word - * @word: The word to search - * - * Undefined if no bit exists, so code should check against 0 first. - */ -static inline unsigned long __ffs(unsigned long word) -{ - int r = 0; - - if (!word) - return 0; - if (!(word & 0xffff)) { - word >>= 16; - r += 16; - } - if (!(word & 0xff)) { - word >>= 8; - r += 8; - } - if (!(word & 0xf)) { - word >>= 4; - r += 4; - } - if (!(word & 3)) { - word >>= 2; - r += 2; - } - if (!(word & 1)) { - word >>= 1; - r += 1; - } - return r; -} - -/** - * find_next_bit - find the next set bit in a memory region - * @addr: The address to base the search on - * @offset: The bitnumber to start searching at - * @size: The maximum size to search - */ -static inline unsigned long find_next_bit(const unsigned long *addr, - unsigned long size, unsigned long offset) -{ - unsigned int *p = ((unsigned int *) addr) + (offset >> 5); - unsigned int result = offset & ~31UL; - unsigned int tmp; - - if (offset >= size) - return size; - size -= result; - offset &= 31UL; - if (offset) { - tmp = *p++; - tmp &= ~0UL << offset; - if (size < 32) - goto found_first; - if (tmp) - goto found_middle; - size -= 32; - result += 32; - } - while (size >= 32) { - if ((tmp = *p++) != 0) - goto found_middle; - result += 32; - size -= 32; - } - if (!size) - return result; - tmp = *p; - -found_first: - tmp &= ~0UL >> (32 - size); - if (tmp == 0UL) /* Are any bits set? */ - return result + size; /* Nope. */ -found_middle: - return result + __ffs(tmp); -} - -/** - * find_first_bit - find the first set bit in a memory region - * @addr: The address to start the search at - * @size: The maximum size to search - * - * Returns the bit-number of the first set bit, not the number of the byte - * containing a bit. - */ -#define find_first_bit(addr, size) \ - find_next_bit((addr), (size), 0) - - -static inline int find_next_zero_bit(void *addr, int size, int offset) -{ - unsigned long *p = ((unsigned long *) addr) + (offset >> 5); - unsigned long result = offset & ~31UL; - unsigned long tmp; - - if (offset >= size) - return size; - size -= result; - offset &= 31UL; - if (offset) { - tmp = *(p++); - tmp |= ~0UL >> (32-offset); - if (size < 32) - goto found_first; - if (~tmp) - goto found_middle; - size -= 32; - result += 32; - } - while (size & ~31UL) { - if (~(tmp = *(p++))) - goto found_middle; - result += 32; - size -= 32; - } - if (!size) - return result; - tmp = *p; - -found_first: - tmp |= ~0UL << size; -found_middle: - return result + ffz(tmp); -} - -#define find_first_zero_bit(addr, size) \ - find_next_zero_bit((addr), (size), 0) - -/* - * hweightN: returns the hamming weight (i.e. the number - * of bits set) of a N-bit word - */ - -#define hweight32(x) generic_hweight32(x) -#define hweight16(x) generic_hweight16(x) -#define hweight8(x) generic_hweight8(x) - -/* - * Every architecture must define this function. It's the fastest - * way of searching a 140-bit bitmap where the first 100 bits are - * unlikely to be set. It's guaranteed that at least one of the 140 - * bits is cleared. - */ - -static inline int sched_find_first_bit(unsigned long *b) -{ - if (unlikely(b[0])) - return __ffs(b[0]); - if (unlikely(b[1])) - return __ffs(b[1]) + 32; - if (unlikely(b[2])) - return __ffs(b[2]) + 64; - if (b[3]) - return __ffs(b[3]) + 96; - return __ffs(b[4]) + 128; -} - -/* - * ffs: find first bit set. This is defined the same way as - * the libc and compiler builtin ffs routines, therefore - * differs in spirit from the above ffz (man ffs). - */ - -#define ffs(x) generic_ffs(x) - -/* - * hweightN: returns the hamming weight (i.e. the number - * of bits set) of a N-bit word - */ - -#define hweight32(x) generic_hweight32(x) -#define hweight16(x) generic_hweight16(x) -#define hweight8(x) generic_hweight8(x) - -#ifdef __LITTLE_ENDIAN__ -#define ext2_set_bit(nr, addr) __test_and_set_bit((nr), (addr)) -#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr), (addr)) -#define ext2_test_bit(nr, addr) test_bit((nr), (addr)) -#define ext2_find_first_zero_bit(addr, size) find_first_zero_bit((addr), (size)) -#define ext2_find_next_zero_bit(addr, size, offset) \ - find_next_zero_bit((addr), (size), (offset)) -#else -static __inline__ int ext2_set_bit(int nr, volatile void * addr) -{ - int mask, retval; - volatile unsigned char *ADDR = (unsigned char *) addr; - - ADDR += nr >> 3; - mask = 1 << (nr & 0x07); - retval = (mask & *ADDR) != 0; - *ADDR |= mask; - return retval; -} - -static __inline__ int ext2_clear_bit(int nr, volatile void * addr) -{ - int mask, retval; - volatile unsigned char *ADDR = (unsigned char *) addr; - - ADDR += nr >> 3; - mask = 1 << (nr & 0x07); - retval = (mask & *ADDR) != 0; - *ADDR &= ~mask; - return retval; -} - -static __inline__ int ext2_test_bit(int nr, const volatile void * addr) -{ - int mask; - const volatile unsigned char *ADDR = (const unsigned char *) addr; - - ADDR += nr >> 3; - mask = 1 << (nr & 0x07); - return ((mask & *ADDR) != 0); -} - -#define ext2_find_first_zero_bit(addr, size) \ - ext2_find_next_zero_bit((addr), (size), 0) - -static __inline__ unsigned long ext2_find_next_zero_bit(void *addr, unsigned long size, unsigned long offset) -{ - unsigned long *p = ((unsigned long *) addr) + (offset >> 5); - unsigned long result = offset & ~31UL; - unsigned long tmp; - - if (offset >= size) - return size; - size -= result; - offset &= 31UL; - if(offset) { - /* We hold the little endian value in tmp, but then the - * shift is illegal. So we could keep a big endian value - * in tmp, like this: - * - * tmp = __swab32(*(p++)); - * tmp |= ~0UL >> (32-offset); - * - * but this would decrease preformance, so we change the - * shift: - */ - tmp = *(p++); - tmp |= __swab32(~0UL >> (32-offset)); - if(size < 32) - goto found_first; - if(~tmp) - goto found_middle; - size -= 32; - result += 32; - } - while(size & ~31UL) { - if(~(tmp = *(p++))) - goto found_middle; - result += 32; - size -= 32; - } - if(!size) - return result; - tmp = *p; - -found_first: - /* tmp is little endian, so we would have to swab the shift, - * see above. But then we have to swab tmp below for ffz, so - * we might as well do this here. - */ - return result + ffz(__swab32(tmp) | (~0UL << size)); -found_middle: - return result + ffz(__swab32(tmp)); -} -#endif - -#define ext2_set_bit_atomic(lock, nr, addr) \ - ({ \ - int ret; \ - spin_lock(lock); \ - ret = ext2_set_bit((nr), (addr)); \ - spin_unlock(lock); \ - ret; \ - }) - -#define ext2_clear_bit_atomic(lock, nr, addr) \ - ({ \ - int ret; \ - spin_lock(lock); \ - ret = ext2_clear_bit((nr), (addr)); \ - spin_unlock(lock); \ - ret; \ - }) - -/* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) __set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) -#define minix_test_bit(nr,addr) test_bit(nr,addr) -#define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) - -#define ffs(x) generic_ffs(x) -#define fls(x) generic_fls(x) -#define fls64(x) generic_fls64(x) +#include <asm-generic/bitops/__ffs.h> +#include <asm-generic/bitops/find.h> +#include <asm-generic/bitops/hweight.h> +#include <asm-generic/bitops/sched.h> +#include <asm-generic/bitops/ffs.h> +#include <asm-generic/bitops/ext2-non-atomic.h> +#include <asm-generic/bitops/ext2-atomic.h> +#include <asm-generic/bitops/minix.h> +#include <asm-generic/bitops/fls.h> +#include <asm-generic/bitops/fls64.h> #endif /* __KERNEL__ */ Index: 2.6-rc/arch/sh64/Kconfig =================================================================== --- 2.6-rc.orig/arch/sh64/Kconfig +++ 2.6-rc/arch/sh64/Kconfig @@ -21,6 +21,14 @@ config RWSEM_GENERIC_SPINLOCK bool default y +config GENERIC_FIND_NEXT_BIT + bool + default y + +config GENERIC_HWEIGHT + bool + default y + config GENERIC_CALIBRATE_DELAY bool default y -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:04:57
|
Bitmap functions for the minix filesystem and the ext2 filesystem except ext2_set_bit_atomic() and ext2_clear_bit_atomic() do not require the atomic guarantees. But these are defined by using atomic bit operations on several architectures. (cris, frv, h8300, ia64, m32r, m68k, m68knommu, mips, s390, sh, sh64, sparc, sparc64, v850, and xtensa) This patch switches to non atomic bit operation. Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-cris/bitops.h | 8 ++++---- include/asm-frv/bitops.h | 14 +++++++------- include/asm-h8300/bitops.h | 6 +++--- include/asm-ia64/bitops.h | 10 +++++----- include/asm-m32r/bitops.h | 2 +- include/asm-m68k/bitops.h | 10 +++++----- include/asm-m68knommu/bitops.h | 6 +++--- include/asm-mips/bitops.h | 6 +++--- include/asm-s390/bitops.h | 10 +++++----- include/asm-sh/bitops.h | 16 +++++----------- include/asm-sh64/bitops.h | 16 +++++----------- include/asm-sparc/bitops.h | 6 +++--- include/asm-sparc64/bitops.h | 6 +++--- include/asm-v850/bitops.h | 10 +++++----- include/asm-xtensa/bitops.h | 6 +++--- 15 files changed, 60 insertions(+), 72 deletions(-) Index: 2.6-rc/include/asm-h8300/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-h8300/bitops.h +++ 2.6-rc/include/asm-h8300/bitops.h @@ -397,9 +397,9 @@ found_middle: } /* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) +#define minix_set_bit(nr,addr) __set_bit(nr,addr) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) Index: 2.6-rc/include/asm-ia64/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-ia64/bitops.h +++ 2.6-rc/include/asm-ia64/bitops.h @@ -394,18 +394,18 @@ extern int __find_next_bit(const void *a #define __clear_bit(nr, addr) clear_bit(nr, addr) -#define ext2_set_bit test_and_set_bit +#define ext2_set_bit __test_and_set_bit #define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit test_and_clear_bit +#define ext2_clear_bit __test_and_clear_bit #define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a) #define ext2_test_bit test_bit #define ext2_find_first_zero_bit find_first_zero_bit #define ext2_find_next_zero_bit find_next_zero_bit /* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) +#define minix_set_bit(nr,addr) __set_bit(nr,addr) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) Index: 2.6-rc/include/asm-mips/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-mips/bitops.h +++ 2.6-rc/include/asm-mips/bitops.h @@ -962,9 +962,9 @@ found_middle: * FIXME: These assume that Minix uses the native byte/bitorder. * This limits the Minix filesystem's value for data exchange very much. */ -#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) +#define minix_set_bit(nr,addr) __set_bit(nr,addr) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) Index: 2.6-rc/include/asm-s390/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-s390/bitops.h +++ 2.6-rc/include/asm-s390/bitops.h @@ -871,11 +871,11 @@ static inline int sched_find_first_bit(u */ #define ext2_set_bit(nr, addr) \ - test_and_set_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) + __test_and_set_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) #define ext2_set_bit_atomic(lock, nr, addr) \ test_and_set_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) #define ext2_clear_bit(nr, addr) \ - test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) + __test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) #define ext2_clear_bit_atomic(lock, nr, addr) \ test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) #define ext2_test_bit(nr, addr) \ @@ -1014,11 +1014,11 @@ ext2_find_next_zero_bit(void *vaddr, uns /* Bitmap functions for the minix filesystem. */ /* FIXME !!! */ #define minix_test_and_set_bit(nr,addr) \ - test_and_set_bit(nr,(unsigned long *)addr) + __test_and_set_bit(nr,(unsigned long *)addr) #define minix_set_bit(nr,addr) \ - set_bit(nr,(unsigned long *)addr) + __set_bit(nr,(unsigned long *)addr) #define minix_test_and_clear_bit(nr,addr) \ - test_and_clear_bit(nr,(unsigned long *)addr) + __test_and_clear_bit(nr,(unsigned long *)addr) #define minix_test_bit(nr,addr) \ test_bit(nr,(unsigned long *)addr) #define minix_find_first_zero_bit(addr,size) \ Index: 2.6-rc/include/asm-sh/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-sh/bitops.h +++ 2.6-rc/include/asm-sh/bitops.h @@ -339,8 +339,8 @@ static inline int sched_find_first_bit(c } #ifdef __LITTLE_ENDIAN__ -#define ext2_set_bit(nr, addr) test_and_set_bit((nr), (addr)) -#define ext2_clear_bit(nr, addr) test_and_clear_bit((nr), (addr)) +#define ext2_set_bit(nr, addr) __test_and_set_bit((nr), (addr)) +#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr), (addr)) #define ext2_test_bit(nr, addr) test_bit((nr), (addr)) #define ext2_find_first_zero_bit(addr, size) find_first_zero_bit((addr), (size)) #define ext2_find_next_zero_bit(addr, size, offset) \ @@ -349,30 +349,24 @@ static inline int sched_find_first_bit(c static __inline__ int ext2_set_bit(int nr, volatile void * addr) { int mask, retval; - unsigned long flags; volatile unsigned char *ADDR = (unsigned char *) addr; ADDR += nr >> 3; mask = 1 << (nr & 0x07); - local_irq_save(flags); retval = (mask & *ADDR) != 0; *ADDR |= mask; - local_irq_restore(flags); return retval; } static __inline__ int ext2_clear_bit(int nr, volatile void * addr) { int mask, retval; - unsigned long flags; volatile unsigned char *ADDR = (unsigned char *) addr; ADDR += nr >> 3; mask = 1 << (nr & 0x07); - local_irq_save(flags); retval = (mask & *ADDR) != 0; *ADDR &= ~mask; - local_irq_restore(flags); return retval; } @@ -459,9 +453,9 @@ found_middle: }) /* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) +#define minix_set_bit(nr,addr) __set_bit(nr,addr) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) Index: 2.6-rc/include/asm-sh64/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-sh64/bitops.h +++ 2.6-rc/include/asm-sh64/bitops.h @@ -382,8 +382,8 @@ static inline int sched_find_first_bit(u #define hweight8(x) generic_hweight8(x) #ifdef __LITTLE_ENDIAN__ -#define ext2_set_bit(nr, addr) test_and_set_bit((nr), (addr)) -#define ext2_clear_bit(nr, addr) test_and_clear_bit((nr), (addr)) +#define ext2_set_bit(nr, addr) __test_and_set_bit((nr), (addr)) +#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr), (addr)) #define ext2_test_bit(nr, addr) test_bit((nr), (addr)) #define ext2_find_first_zero_bit(addr, size) find_first_zero_bit((addr), (size)) #define ext2_find_next_zero_bit(addr, size, offset) \ @@ -392,30 +392,24 @@ static inline int sched_find_first_bit(u static __inline__ int ext2_set_bit(int nr, volatile void * addr) { int mask, retval; - unsigned long flags; volatile unsigned char *ADDR = (unsigned char *) addr; ADDR += nr >> 3; mask = 1 << (nr & 0x07); - local_irq_save(flags); retval = (mask & *ADDR) != 0; *ADDR |= mask; - local_irq_restore(flags); return retval; } static __inline__ int ext2_clear_bit(int nr, volatile void * addr) { int mask, retval; - unsigned long flags; volatile unsigned char *ADDR = (unsigned char *) addr; ADDR += nr >> 3; mask = 1 << (nr & 0x07); - local_irq_save(flags); retval = (mask & *ADDR) != 0; *ADDR &= ~mask; - local_irq_restore(flags); return retval; } @@ -502,9 +496,9 @@ found_middle: }) /* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) +#define minix_set_bit(nr,addr) __set_bit(nr,addr) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) Index: 2.6-rc/include/asm-sparc/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-sparc/bitops.h +++ 2.6-rc/include/asm-sparc/bitops.h @@ -523,11 +523,11 @@ found_middle: /* Bitmap functions for the minix filesystem. */ #define minix_test_and_set_bit(nr,addr) \ - test_and_set_bit((nr),(unsigned long *)(addr)) + __test_and_set_bit((nr),(unsigned long *)(addr)) #define minix_set_bit(nr,addr) \ - set_bit((nr),(unsigned long *)(addr)) + __set_bit((nr),(unsigned long *)(addr)) #define minix_test_and_clear_bit(nr,addr) \ - test_and_clear_bit((nr),(unsigned long *)(addr)) + __test_and_clear_bit((nr),(unsigned long *)(addr)) #define minix_test_bit(nr,addr) \ test_bit((nr),(unsigned long *)(addr)) #define minix_find_first_zero_bit(addr,size) \ Index: 2.6-rc/include/asm-sparc64/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-sparc64/bitops.h +++ 2.6-rc/include/asm-sparc64/bitops.h @@ -280,11 +280,11 @@ extern unsigned long find_next_zero_le_b /* Bitmap functions for the minix filesystem. */ #define minix_test_and_set_bit(nr,addr) \ - test_and_set_bit((nr),(unsigned long *)(addr)) + __test_and_set_bit((nr),(unsigned long *)(addr)) #define minix_set_bit(nr,addr) \ - set_bit((nr),(unsigned long *)(addr)) + __set_bit((nr),(unsigned long *)(addr)) #define minix_test_and_clear_bit(nr,addr) \ - test_and_clear_bit((nr),(unsigned long *)(addr)) + __test_and_clear_bit((nr),(unsigned long *)(addr)) #define minix_test_bit(nr,addr) \ test_bit((nr),(unsigned long *)(addr)) #define minix_find_first_zero_bit(addr,size) \ Index: 2.6-rc/include/asm-v850/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-v850/bitops.h +++ 2.6-rc/include/asm-v850/bitops.h @@ -336,18 +336,18 @@ static inline int sched_find_first_bit(u #define hweight16(x) generic_hweight16 (x) #define hweight8(x) generic_hweight8 (x) -#define ext2_set_bit test_and_set_bit +#define ext2_set_bit __test_and_set_bit #define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit test_and_clear_bit +#define ext2_clear_bit __test_and_clear_bit #define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a) #define ext2_test_bit test_bit #define ext2_find_first_zero_bit find_first_zero_bit #define ext2_find_next_zero_bit find_next_zero_bit /* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit test_and_set_bit -#define minix_set_bit set_bit -#define minix_test_and_clear_bit test_and_clear_bit +#define minix_test_and_set_bit __test_and_set_bit +#define minix_set_bit __set_bit +#define minix_test_and_clear_bit __test_and_clear_bit #define minix_test_bit test_bit #define minix_find_first_zero_bit find_first_zero_bit Index: 2.6-rc/include/asm-xtensa/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-xtensa/bitops.h +++ 2.6-rc/include/asm-xtensa/bitops.h @@ -436,9 +436,9 @@ static inline int sched_find_first_bit(c /* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) +#define minix_set_bit(nr,addr) __set_bit(nr,addr) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) Index: 2.6-rc/include/asm-m32r/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-m32r/bitops.h +++ 2.6-rc/include/asm-m32r/bitops.h @@ -575,7 +575,7 @@ found_middle: */ #ifdef __LITTLE_ENDIAN__ -#define ext2_set_bit test_and_set_bit +#define ext2_set_bit __test_and_set_bit #define ext2_clear_bit __test_and_clear_bit #define ext2_test_bit test_bit #define ext2_find_first_zero_bit find_first_zero_bit Index: 2.6-rc/include/asm-cris/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-cris/bitops.h +++ 2.6-rc/include/asm-cris/bitops.h @@ -352,17 +352,17 @@ found_middle: #define find_first_bit(addr, size) \ find_next_bit((addr), (size), 0) -#define ext2_set_bit test_and_set_bit +#define ext2_set_bit __test_and_set_bit #define ext2_set_bit_atomic(l,n,a) test_and_set_bit(n,a) -#define ext2_clear_bit test_and_clear_bit +#define ext2_clear_bit __test_and_clear_bit #define ext2_clear_bit_atomic(l,n,a) test_and_clear_bit(n,a) #define ext2_test_bit test_bit #define ext2_find_first_zero_bit find_first_zero_bit #define ext2_find_next_zero_bit find_next_zero_bit /* Bitmap functions for the minix filesystem. */ -#define minix_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_clear_bit(nr,addr) test_and_clear_bit(nr,addr) +#define minix_set_bit(nr,addr) __test_and_set_bit(nr,addr) +#define minix_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) Index: 2.6-rc/include/asm-frv/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-frv/bitops.h +++ 2.6-rc/include/asm-frv/bitops.h @@ -259,11 +259,11 @@ static inline int sched_find_first_bit(c #define hweight16(x) generic_hweight16(x) #define hweight8(x) generic_hweight8(x) -#define ext2_set_bit(nr, addr) test_and_set_bit ((nr) ^ 0x18, (addr)) -#define ext2_clear_bit(nr, addr) test_and_clear_bit((nr) ^ 0x18, (addr)) +#define ext2_set_bit(nr, addr) __test_and_set_bit ((nr) ^ 0x18, (addr)) +#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr) ^ 0x18, (addr)) -#define ext2_set_bit_atomic(lock,nr,addr) ext2_set_bit((nr), addr) -#define ext2_clear_bit_atomic(lock,nr,addr) ext2_clear_bit((nr), addr) +#define ext2_set_bit_atomic(lock,nr,addr) test_and_set_bit ((nr) ^ 0x18, (addr)) +#define ext2_clear_bit_atomic(lock,nr,addr) test_and_clear_bit((nr) ^ 0x18, (addr)) static inline int ext2_test_bit(int nr, const volatile void * addr) { @@ -331,9 +331,9 @@ found_middle: } /* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) ext2_set_bit(nr,addr) -#define minix_set_bit(nr,addr) ext2_set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) ext2_clear_bit(nr,addr) +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit ((nr) ^ 0x18, (addr)) +#define minix_set_bit(nr,addr) __set_bit((nr) ^ 0x18, (addr)) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit((nr) ^ 0x18, (addr)) #define minix_test_bit(nr,addr) ext2_test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) ext2_find_first_zero_bit(addr,size) Index: 2.6-rc/include/asm-m68k/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-m68k/bitops.h +++ 2.6-rc/include/asm-m68k/bitops.h @@ -365,9 +365,9 @@ static inline int minix_find_first_zero_ return ((p - addr) << 4) + (res ^ 31); } -#define minix_test_and_set_bit(nr, addr) test_and_set_bit((nr) ^ 16, (unsigned long *)(addr)) -#define minix_set_bit(nr,addr) set_bit((nr) ^ 16, (unsigned long *)(addr)) -#define minix_test_and_clear_bit(nr, addr) test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr)) +#define minix_test_and_set_bit(nr, addr) __test_and_set_bit((nr) ^ 16, (unsigned long *)(addr)) +#define minix_set_bit(nr,addr) __set_bit((nr) ^ 16, (unsigned long *)(addr)) +#define minix_test_and_clear_bit(nr, addr) __test_and_clear_bit((nr) ^ 16, (unsigned long *)(addr)) static inline int minix_test_bit(int nr, const void *vaddr) { @@ -377,9 +377,9 @@ static inline int minix_test_bit(int nr, /* Bitmap functions for the ext2 filesystem. */ -#define ext2_set_bit(nr, addr) test_and_set_bit((nr) ^ 24, (unsigned long *)(addr)) +#define ext2_set_bit(nr, addr) __test_and_set_bit((nr) ^ 24, (unsigned long *)(addr)) #define ext2_set_bit_atomic(lock, nr, addr) test_and_set_bit((nr) ^ 24, (unsigned long *)(addr)) -#define ext2_clear_bit(nr, addr) test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr)) +#define ext2_clear_bit(nr, addr) __test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr)) #define ext2_clear_bit_atomic(lock, nr, addr) test_and_clear_bit((nr) ^ 24, (unsigned long *)(addr)) static inline int ext2_test_bit(int nr, const void *vaddr) Index: 2.6-rc/include/asm-m68knommu/bitops.h =================================================================== --- 2.6-rc.orig/include/asm-m68knommu/bitops.h +++ 2.6-rc/include/asm-m68knommu/bitops.h @@ -476,9 +476,9 @@ found_middle: } /* Bitmap functions for the minix filesystem. */ -#define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) -#define minix_set_bit(nr,addr) set_bit(nr,addr) -#define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) +#define minix_test_and_set_bit(nr,addr) __test_and_set_bit(nr,addr) +#define minix_set_bit(nr,addr) __set_bit(nr,addr) +#define minix_test_and_clear_bit(nr,addr) __test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:04:52
|
This patch introduces the C-language equivalent of the function: unsigned long __ffs(unsigned long word); In include/asm-generic/bitops/__ffs.h This code largely copied from: include/asm-sparc/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/__ffs.h | 43 +++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/__ffs.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/__ffs.h @@ -0,0 +1,43 @@ +#ifndef _ASM_GENERIC_BITOPS___FFS_H_ +#define _ASM_GENERIC_BITOPS___FFS_H_ + +#include <asm/types.h> + +/** + * __ffs - find first bit in word. + * @word: The word to search + * + * Undefined if no bit exists, so code should check against 0 first. + */ +static inline unsigned long __ffs(unsigned long word) +{ + int num = 0; + +#if BITS_PER_LONG == 64 + if ((word & 0xffffffff) == 0) { + num += 32; + word >>= 32; + } +#endif + if ((word & 0xffff) == 0) { + num += 16; + word >>= 16; + } + if ((word & 0xff) == 0) { + num += 8; + word >>= 8; + } + if ((word & 0xf) == 0) { + num += 4; + word >>= 4; + } + if ((word & 0x3) == 0) { + num += 2; + word >>= 2; + } + if ((word & 0x1) == 0) + num += 1; + return num; +} + +#endif /* _ASM_GENERIC_BITOPS___FFS_H_ */ -- |
From: Akinobu M. <mi...@mi...> - 2006-02-14 05:04:51
|
This patch introduces the C-language equivalents of the functions below: void __set_bit(int nr, volatile unsigned long *addr); void __clear_bit(int nr, volatile unsigned long *addr); void __change_bit(int nr, volatile unsigned long *addr); int __test_and_set_bit(int nr, volatile unsigned long *addr); int __test_and_clear_bit(int nr, volatile unsigned long *addr); int __test_and_change_bit(int nr, volatile unsigned long *addr); int test_bit(int nr, const volatile unsigned long *addr); In include/asm-generic/bitops/non-atomic.h This code largely copied from: asm-powerpc/bitops.h Signed-off-by: Akinobu Mita <mi...@mi...> include/asm-generic/bitops/non-atomic.h | 111 ++++++++++++++++++++++++++++++++ 1 files changed, 111 insertions(+) Index: 2.6-rc/include/asm-generic/bitops/non-atomic.h =================================================================== --- /dev/null +++ 2.6-rc/include/asm-generic/bitops/non-atomic.h @@ -0,0 +1,111 @@ +#ifndef _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ +#define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ + +#include <asm/types.h> + +#define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) + +/** + * __set_bit - Set a bit in memory + * @nr: the bit to set + * @addr: the address to start counting from + * + * Unlike set_bit(), this function is non-atomic and may be reordered. + * If it's called on the same region of memory simultaneously, the effect + * may be that only one operation succeeds. + */ +static inline void __set_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BITOP_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); + + *p |= mask; +} + +static inline void __clear_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BITOP_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); + + *p &= ~mask; +} + +/** + * __change_bit - Toggle a bit in memory + * @nr: the bit to change + * @addr: the address to start counting from + * + * Unlike change_bit(), this function is non-atomic and may be reordered. + * If it's called on the same region of memory simultaneously, the effect + * may be that only one operation succeeds. + */ +static inline void __change_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BITOP_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); + + *p ^= mask; +} + +/** + * __test_and_set_bit - Set a bit and return its old value + * @nr: Bit to set + * @addr: Address to count from + * + * This operation is non-atomic and can be reordered. + * If two examples of this operation race, one can appear to succeed + * but actually fail. You must protect multiple accesses with a lock. + */ +static inline int __test_and_set_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BITOP_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); + unsigned long old = *p; + + *p = old | mask; + return (old & mask) != 0; +} + +/** + * __test_and_clear_bit - Clear a bit and return its old value + * @nr: Bit to clear + * @addr: Address to count from + * + * This operation is non-atomic and can be reordered. + * If two examples of this operation race, one can appear to succeed + * but actually fail. You must protect multiple accesses with a lock. + */ +static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BITOP_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); + unsigned long old = *p; + + *p = old & ~mask; + return (old & mask) != 0; +} + +/* WARNING: non atomic and it can be reordered! */ +static inline int __test_and_change_bit(int nr, + volatile unsigned long *addr) +{ + unsigned long mask = BITOP_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr); + unsigned long old = *p; + + *p = old ^ mask; + return (old & mask) != 0; +} + +/** + * test_bit - Determine whether a bit is set + * @nr: bit number to test + * @addr: Address to start counting from + */ +static inline int test_bit(int nr, const volatile unsigned long *addr) +{ + return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); +} + +#endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */ -- |
From: Paul M. <le...@li...> - 2006-02-08 11:39:44
|
On Wed, Feb 08, 2006 at 03:25:26PM +0900, KAMEZAWA Hiroyuki wrote: > SH can use generic funcs. >=20 > Signed-Off-By: KAMEZAWA Hiroyuki <kam...@jp...> >=20 On Wed, Feb 08, 2006 at 03:27:04PM +0900, KAMEZAWA Hiroyuki wrote: > sh64 can use generic funcs. >=20 > Signed-Off-By: KAMEZAWA Hiroyuki <kam...@jp...> >=20 Both look fine to me, thanks. Acked-by: Paul Mundt <le...@li...> |
From: <mi...@mi...> - 2006-02-08 10:41:34
|
On Wed, Feb 01, 2006 at 12:27:38PM +0100, Roman Zippel wrote: > For the inline version I would prefer this version: > > { > const unsigned char *tmp = (const unsigned char *)addr; > return (tmp[nr >> 3] & (unsigned char)(1 << (nr & 7))) != 0; > } > > Although this would be a good alternative as well: > > { > return (addr[nr >> 5] & (1 << ((nr ^ 24) & 31))) != 0; > } Thanks, maybe I could use BITOP_LE_SWIZZLE similar to other *_le_bit(). #define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) : #define generic_test_le_bit(nr, addr) test_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) : #endif /* __BIG_ENDIAN */ |
From: KAMEZAWA H. <kam...@jp...> - 2006-02-08 06:25:49
|
sh64 can use generic funcs. Signed-Off-By: KAMEZAWA Hiroyuki <kam...@jp...> Index: test-layout-free-zone/include/asm-sh64/page.h =================================================================== --- test-layout-free-zone.orig/include/asm-sh64/page.h +++ test-layout-free-zone/include/asm-sh64/page.h @@ -105,9 +105,7 @@ typedef struct { unsigned long pgprot; } /* PFN start number, because of __MEMORY_START */ #define PFN_START (__MEMORY_START >> PAGE_SHIFT) - -#define pfn_to_page(pfn) (mem_map + (pfn) - PFN_START) -#define page_to_pfn(page) ((unsigned long)((page) - mem_map) + PFN_START) +#define ARCH_PFN_OFFSET (PFN_START) #define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) #define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr) #define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) |
From: <mi...@mi...> - 2006-02-07 02:02:22
|
On Mon, Feb 06, 2006 at 10:26:00AM +0000, David Howells wrote: > Akinobu Mita <mi...@mi...> wrote: > > > This patch introduces the C-language equivalents of the functions below: > > > > unsigned logn find_next_bit(const unsigned long *addr, unsigned long size, > > unsigned long offset); > > unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size, > > unsigned long offset); > > unsigned long find_first_zero_bit(const unsigned long *addr, > > unsigned long size); > > unsigned long find_first_bit(const unsigned long *addr, unsigned long size); > > These big functions should perhaps be out of line. Yes. I'll make them and below out of line. - hweight*() - ext2_find_*_zero_bit() - minix_find_first_zero_bit() |