Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inline assembly in gcc not working (was Shared Memory )




On 4 okt 2004, at 19:51, Marc Colosimo wrote:

volatile unsigned char  *testB;

int main(void) {

testB = (unsigned char *) malloc(sizeof(unsigned char));

This is wrong. lwarx/stwcx work on word-sized entities. You are only allocating a byte.


*testB = 0;
printf("testB is %d and stored at %d.\n Now locking.\n", *testB, (int) testB);
_lock_(testB);
printf("testB is now %d\n", *testB);

It's normal that this prints 0, since you are on a big-endian system. The byte at test+3 has been incremented by one (and depending on its previous value, possibly also the bytes at test+2 and test+1 and in the extreme case also at test).


   	 return 0;
}


Jonas

_______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Shared Memory (Semaphore and mutex) (From: Marc Colosimo <email@hidden>)
 >Re: Shared Memory (Semaphore and mutex) (From: Shaun Wexler <email@hidden>)
 >Re: Shared Memory (Semaphore and mutex) (From: Marc Colosimo <email@hidden>)
 >Re: Shared Memory (Semaphore and mutex) (From: Shaun Wexler <email@hidden>)
 >inline assembly in gcc not working (was Shared Memory ) (From: Marc Colosimo <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.