[illumos-Developer] Understanding libc _curthread v. __curthread and ul_self

Richard Lowe richlowe at richlowe.net
Fri Jun 24 09:49:04 PDT 2011


Hey all,

Hoping someone here understands what's going on:

I'm doing something (not at all exciting) which is necessitating that
I understand the libc _curthread and __curthread calls on SPARC (these
are in inc/thr_inlines.h if gcc, and sparc.il and sparcv9.il if not).

They both return the ulwp_t, _curthread is used to implement the
`curthread' pseudo-var (a macro expanding to a call to _curthread()),
whereas __curthread() is used as a regular call.

_curthread() puts the ulwp address from %g7 into %o0 directly,
__curthread() loads the ul_self of the ulwp in %g7 into %o0.

I'm stuck wondering why:  Can (ulwp_t *)foo->ul_self ever be not equal
to foo?  I don't see it in the code, but I could be not searching hard
enough.
There's surely something important to this.

on x86 and x64 both _curthread and __curthread do the same thing, a
straight move of the ulwp_t from %fs or %gs into %eax or %rax.  That
suggests that whatever important difference exists only exists on
SPARC?

-- Rich



More information about the Developer mailing list