Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Sep 2006 12:10:54 -0700
From:      Marcel Moolenaar <xcllnt@mac.com>
To:        Marcel Moolenaar <xcllnt@mac.com>
Cc:        ppc@freebsd.org, Peter Grehan <grehan@freebsd.org>
Subject:   Re: Status of threading and TLS
Message-ID:  <769A17D5-FD72-417F-8F0C-C371148296D9@mac.com>
In-Reply-To: <49A44B45-780B-462D-AB1E-547E87460208@mac.com>
References:  <933C0437-DDF8-4A61-83BA-F4920D9E6E96@mac.com> <44F87E8C.9000705@freebsd.org> <49A44B45-780B-462D-AB1E-547E87460208@mac.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sep 1, 2006, at 11:44 AM, Marcel Moolenaar wrote:
> On Sep 1, 2006, at 11:40 AM, Peter Grehan wrote:
>
>>> If anyone has any suggestions why for libpthread we end up
>>> with r2 off by 8 bytes, I'm happy to hear it...
>>
>>  I don't have access to a PPC machine at the moment, but would it  
>> have anything to do with:
>>
>> struct ppc32_tp {
>>         void            *tp_dtv;        /* dynamic thread vector */
>>         uint32_t        _reserved_;
>>         double          tp_tls[0];      /* static TLS */
>> };
>>
>>  I think the last element was put in for alignment, but would that  
>> possibly have an effect somewhere else, in that it's forcing an 8- 
>> byte pad somewhere ?
>
> I've been thinking about that too. I played with the following  
> definition
> to see if it made a difference:
>
> union ppc32_tp {
> 	void *tp_ptr[2];
> 	double _align_;
> };
>
> It didn't make a difference :-/

I found it!

The ucontext on powerpc is 16-bytes aligned. This means that struct tcb
is a multiple of 16-bytes. It so happened that there were 8 bytes of
padding after struct ppc32_tp. So, we need to force 16-byte alignment
for struct ppc32_tp or add internal padding before struct tcb so as to
eliminate padding after it. I opted for the latter...

All is well!

-- 
Marcel Moolenaar
xcllnt@mac.com





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?769A17D5-FD72-417F-8F0C-C371148296D9>