Messages in this thread | | | Date | Fri, 2 Oct 2009 10:37:55 +0900 | From | KAMEZAWA Hiroyuki <> | Subject | Re: No more bits in vm_area_struct's vm_flags. |
| |
On Fri, 2 Oct 2009 09:42:38 +0900 KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> > > > > > (2) All vm macros should be defined with ULL suffix. for supporing ~ > > > == > > > vm_flags 30 arch/x86/mm/hugetlbpage.c unsigned long vm_flags = vma->vm_flags & ~VM_LOCKED; > > > > > > (3) vma_merge()'s vm_flags should be ULL. > > > > At first I thought you'd saved me a lot of embarrassment by mentioning > > those ULL suffixes, I hadn't put them in. But after a quick test of > > what I thought was going to show a problem without them, no problem. > > Please would you send me a test program which demonstrates the need > > for all those ULLs? > > > Ah, I'm sorry if I misunderstand C's rule. > > There are some places which use ~. > like > vm_flags = vma->vm_flags & ~(VM_LOCKED); > > ~VM_LOCKED is > 0xffffdfff or 0xffffffffffffdffff ? > > Is my concern. > > I tried following function on my old x86 box > == > #define FLAG (0x20) > > int foo(unsigned long long x) > { > return x & ~FLAG; > } > == > (returning "int" as "bool") > > compile this with gcc -S -O2 (gcc's version is 4.0) > == > foo: > pushl %ebp > movl %esp, %ebp > movl 8(%ebp), %eax > andl $-33, %eax > leave > ret > == > Them, it seems higher bits are ignored for returning bool. > Sigh, I seems I don't undestand C language yet..
This one == #define FLAG (0x20ULL)
int foo(unsigned long long x) { return (x & ~FLAG); } == is compiled as == foo: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax andl $-33, %eax leave ret == ULL suffix makes no difference ;)
This one == #define FLAG (0x20)
int foo(unsigned long long x) { if (x & ~FLAG) return 1; return 0; }
== foo: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax movl 12(%ebp), %edx andl $-33, %eax orl %edx, %eax setne %al movzbl %al, %eax leave ret
seems good.
Hmm. sorry for noise. Maybe I don't understand C's cast rules.
-Kame
| |