Re: impossible constraint in asm
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Le 7 oct. 08 à 03:36, Steve Jenson a écrit : Hi, I've inherited a chunk of code and am trying to get it to compile on Leopard but am running into a problem and I'm hoping somebody on this list has seen it before. typedef uint32_t lockStructure; static inline int __compareAndSwap(lockStructure *ptr, lockStructure old, lockStructure new) { lockStructure prev = old; asm volatile("lock cmpxchgl %1,%2" : "=a" (old) : "q" (new), "m" (*ptr),"0" (old) : "memory"); return old != prev; } When I try to compile this, I get the following error for the line starting with asm: error: impossible constraint in 'asm' This isn't with Xcode but instead with a standard Makefile. I'm using the stock gcc 4.0.1 that comes with the latest Xcode. Thanks, Steve Don't use asm: #include <libkern/OSAtomic.h> _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... typedef uint32_t lockStructure; static inline int __compareAndSwap(lockStructure *ptr, lockStructure old, lockStructure new) { return OSAtomicCompareAndSwap32(old, new, ptr); } And you can also have a look a some other interesting function like OSSpinLock (as it look like this atomic value is used to do some locking). This email sent to site_archiver@lists.apple.com
participants (1)
-
Jean-Daniel Dupas