[M3devel] further reducing cloned headers wrt pthread?
Jay
jay.krell at cornell.edu
Tue Feb 3 23:05:51 CET 2009
> 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