-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 30 June 2004 10:25, Momchil Velikov wrote: <snip> > Borislav> <from include/asm-i386/thread_info.h> > Borislav> 86 /* how to get the thread information struct from C */ > Borislav> 87 static inline struct thread_info *current_thread_info(void) > Borislav> 88 { > Borislav> 89 struct thread_info *ti; > Borislav> 90 __asm__("andl %%esp,%0; ":"=r" (ti) : "" > (~(THREAD_SIZE - 1))); Borislav> 91 return ti; > Borislav> 92 } > > Borislav> I've read several tutorials on inline asm but what is peculiar > here is, that Borislav> the input operand's constraint is "" (nothing) > > What version of the kernel is that? There's no such thing in 2.6.6 > and both gcc 3.3 and gcc 3.5 report an error compiling your example. > The constraint must be "0", so initially the constant is loaded into a > register and the result is obtained in the same register ("0" means > "the same constraint as the one of operand 0"). You're right. I use lxr - a cross reference tool to browse the kernel code, so, to my dismay, the program indexed the source files wrong - in the original source file <include/asm-i386/thread_info.h> the input operand is "0" but in the browsable version the zero is gone and i have only "" .. strange, i'll have to check that. > > Borislav> I also have another question: > > Borislav> <from include/linux/kernel.h> > Borislav> 203 /** > Borislav> 204 * container_of - cast a member of a structure out to the > containing Borislav> structure > Borislav> 205 * > Borislav> 206 * @ptr: the pointer to the member. > Borislav> 207 * @type: the type of the container struct this is > embedded in. Borislav> 208 * @member: the name of the member within > the struct. Borislav> 209 * > Borislav> 210 */ > Borislav> 211 #define container_of(ptr, type, member) ({ > \ Borislav> 212 const typeof( ((type *)0)->member ) *__mptr = > (ptr); \ Borislav> 213 (type *)( (char *)__mptr - > offsetof(type,member) );}) > > Borislav> I can't understand the ((type *)0) part - type is passed as an > argument and it Borislav> is some struct pointer but the trailing 0 ... > what does it actually do? > > No type is passed as an argument as this is a macro. Actually, type is an argument to the macro: #define container_of(ptr, type, member) the second argument, but this is irrelevant since I still got what i wanted to know for which i blagodarja :)) This was _the_ explanation I was looking for - i couldn't be more indepth :)) I'll have to brush up my C knowledge but the 0 in the expression really got me sweatin', Thanks again. Boris. <snip> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD4DBQFA4oTaiBySr3Fn37QRAsNaAKCHInQ8jYl6ZqEjA6+9pb/CLDi9pQCYrmGu UUQ55xKo3Mh1DNXWA4bzjA== =IClL -----END PGP SIGNATURE----- -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/