• 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
How to count Atoms
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to count Atoms


  • Subject: How to count Atoms
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Fri, 07 Oct 2016 14:19:24 +0700

I need (just for debugging purposes) to count something in a thread safe way.
This works, but is deprecated:

SInt32	counter;
- (IBAction)doSomething:sender
{
	counter = 0;
	some loop
	{
		IncrementAtomic( &counter );	//	'IncrementAtomic' is deprecated: first deprecated in macOS 10.8
		....
	}
	fprintf(stderr, "counter %lld\n", counter);	 //	works ok
}

The deprecation message did not say what to use instead. So I tried OSIncrementAtomic.
Now I get: "Implicit declaration of function 'OSIncrementAtomic' is invalid in C99" and the linker fails, because it does not find it.
#import <libkern/OSAtomic.h>	does not help at all.

When I add the Kernel.framework these errors disappear (good), but are only replaced by: “ld: framework not found Kernel” (not so good).

So what is the proper way to count something atomicly and undeprecatedly?

Gerriet.


_______________________________________________

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: How to count Atoms
      • From: Alastair Houghton <email@hidden>
    • Re: How to count Atoms
      • From: Ken Thomases <email@hidden>
    • Re: How to count Atoms
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: MLMediaLibrary sometimes does not call my KVO
  • Next by Date: Re: How to count Atoms
  • Previous by thread: Re: Extra logging in Simulators for iOS 10 & for macOS Sierra?
  • Next by thread: Re: How to count Atoms
  • Index(es):
    • Date
    • Thread