Hi Geert,

I'm not quite sure what's going on but this email just appeared in my inbox... dated 26/11/2013. Not sure where this has been hiding all this time...

On 11/26/2013 12:12 PM, Geert Uytterhoeven wrote:
Hi,

What's the story behind "__attribute__ ((transparent_union))" for union semun
in <linux/sem.h>?

When building for non-OpenRISC using an OpenRISC tree, I get the following
compiler warning:

  include/uapi/linux/sem.h:45:7: warning: union cannot be made transparent

At some point I tried posting this explanation to the kernel mailing list. I hope it makes some sense. That said, I'm not convinced today that this is the correct solution in general.

"The syscall handler for semctl is written under the assumption that the
toolchain will pass "small" unions as function parameters directly instead
of by reference.  The union semun is "small" and thus fits this description.

Since it is assumed that the union will be passed directly and not by
reference, it is safe to access the union members without going via
get_user.

The OpenRISC architecture, however, passes all unions by reference, thus
breaking the above assumption.

The technically correct fix here is to mark the union as being transparent
so that the ABI of the union's first element determines the parameter
passing method and thus make explicit what's already implied in the function
definition."

...

I can expand on this, if necessary; but it's been a long time since I found this problem and I'm not sure if it's still a problem with the toolchain today (though I think it probably is).

/Jonas


Thx!

Gr{oetje,eeting}s,

                         Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                 -- Linus Torvalds
_______________________________________________
Linux mailing list
Linux@lists.openrisc.net
http://lists.openrisc.net/listinfo/linux

_______________________________________________
Linux mailing list
Linux@lists.openrisc.net
http://lists.openrisc.net/listinfo/linux

Reply via email to