Re: puzzling code in pcpu stuff

From: Julian Elischer <julian_at_elischer.org>
Date: Sun, 02 Aug 2009 03:26:04 -0700
Julian Elischer wrote:
> I simplified the output of the preprocessor for a PCPU_SET(xx, newval)
> (to look at it).
> 
> I came down to: (after formatting) for i386..
> {
>         __typeof(((struct pcpu *)0)->pc_xx) __val;
>         struct __s
>         {
>                 u_char __b[(((sizeof(__val)) < (4)) ?
>                                    (sizeof(__val)) : (4))];
>         } __s;
> 
>         __val = (newval); /* aligned */
> 
>         if (sizeof(__val) == 1
>         || sizeof(__val) == 2
>         || sizeof(__val) == 4) {
>                 __s = *(struct __s *)(void *)&__val;
>                 __asm volatile("mov %1,%%fs:%0" : "=m"
>                   (*(struct __s *)(__builtin_offsetof(
>                        struct pcpu,  pc_xx))) : "r" (__s));
>         } else {
>                 *__extension__ (
>                 {
>                         __typeof(__val) *__p;
>                         __asm volatile("movl %%fs:%1,%0;
>                         addl %2,%0" : "=r" (__p) : "m"
>   (*(struct pcpu *)(__builtin_offsetof(struct pcpu, pc_prvspace))),
>   "i"
>   (__builtin_offsetof(struct pcpu, pc_xx)));
>    __p;
>                 }) = __val;
>         }
> }

p.s. I looked at the original source but I couldn't really work it out 
there either.

> 
> having had my brain explode on this several times,
> I can't figure out exactly what teh clause after the else is doing.

well I know wht it appears to be doing fromt eh source but I can;t 
work out how..  __asm foo to explain it is missing..

> 
> anyone better at reading __asm better than me care to explain it in
> simple words? 

(maybe it's just too late at night for me here)

> 
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
Received on Sun Aug 02 2009 - 08:25:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:53 UTC