• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
OSAtomic built-in operations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OSAtomic built-in operations


  • Subject: OSAtomic built-in operations
  • From: Andreas Grosam <email@hidden>
  • Date: Sun, 06 May 2012 11:05:45 +0200

Hi All!


I would like to use OSAtomicCompareAndSwap32 and OSAtomicOr32Orig using the same variable. Unfortunately, the first requires a signed int, the other an unsigned int.

How can I get this to work?


Example:


enum {
	State_Canceling = 1U << 7;
};

int _state; // would like to have an uint32_t


int new_state = OSAtomicCompareAndSwap32(State_0, State_1, &_state);
…


if (OSAtomicOr32Orig(State_Canceling, &_state) != 0) {
	// canceling
}


The solution would be a "OSAtomicCompareAndSwapU32", or is it save to pass a signed int where an unsigned int is required, considering strong Alias rules and whatever optimizations the compiler applies?


Thanks for tips!



Reagards
Andreas
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: OSAtomic built-in operations
      • From: Stefan Werner <email@hidden>
  • Prev by Date: Can record ID in iOS address book database change
  • Next by Date: Re: Issue when hiding NSTableColumn while resizing
  • Previous by thread: Re: Can record ID in iOS address book database change
  • Next by thread: Re: OSAtomic built-in operations
  • Index(es):
    • Date
    • Thread