[M3devel] further reducing cloned headers wrt pthread?

Tony Hosking hosking at cs.purdue.edu
Tue Feb 3 23:54:01 CET 2009


I suggest you come up with a proposal for us to look over before you  
change the code base for this.

On 4 Feb 2009, at 09:05, Jay wrote:

>
>> Hmm, yes, you are right that there is a possible alignment issue. I
>> am used to pthread_mutext_t being a simple reference. But surely in C
>> the type of the pthread_mutex_t struct would have appropriate
>> alignment padding anyway so as to allow allocation using  
>> malloc(sizeof
>> pthread_mutex_t)? So, it all should just work right?
>
>
> I think "the other way around" and same conclusion.
> malloc should return something "maximally aligned" so that
>
>  pthread_mutex_t* x = (pthread_mutex_t*)  
> malloc(sizeof(pthread_mutex_t));
>
>
> works. pthread_mutex_t doesn't need the padding, malloc does, so to  
> speak.
>
>
> Just as long as we don't have
>
>
> TYPE Foo = RECORD
>   a: pthread_mutex_t;
>   b: pthread_mutex_t;
>   c: pthread_t;
>   d: pthread_t;
>   e: pthread_cond_t;
>   f: pthread_cond_t;
> END;
>
>
> and such, ok.
>
>
> malloc on NT returns something with 2 * sizeof(void*) alignment.
> I think on Win9x only 4 alignment, thus there is _malloc_aligned for  
> dealing with SSE stuff.
> Something like that.
>
>
> I didn't realize untraced allocations were basically just malloc but  
> indeed they are.
>
>
> I'm still mulling over the possible deoptimizations here.
> I'm reluctant to increase heap allocations.
>
>
>
> - Jay




More information about the M3devel mailing list