OTAtomicAdd32 deprecated


#1

I’m getting the repeated warning about OTAtomicAdd32 being deprecated with the 10.4 SDK. Changing juce_Atomic.h as follows fixes it:

[code]#if JUCE_MAC && ! DOXYGEN

#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)

#include <libkern/OSAtomic.h>

forcedinline void atomicIncrement (int& variable) throw()
{
    OSAtomicAdd32 (1, (int32_t*) &variable);
}

forcedinline int atomicIncrementAndReturn (int& variable) throw()
{
    return OSAtomicAdd32 (1, (int32_t*) &variable);
}

forcedinline void atomicDecrement (int& variable) throw()
{
    OSAtomicAdd32 (-1, (int32_t*) &variable);
}

forcedinline int atomicDecrementAndReturn (int& variable) throw()
{
    return OSAtomicAdd32 (-1, (int32_t*) &variable);
}

#else

forcedinline void atomicIncrement (int& variable) throw()
{
    OTAtomicAdd32 (1, (SInt32*) &variable);
}

forcedinline int atomicIncrementAndReturn (int& variable) throw()
{
    return OTAtomicAdd32 (1, (SInt32*) &variable);
}

forcedinline void atomicDecrement (int& variable) throw()
{
    OTAtomicAdd32 (-1, (SInt32*) &variable);
}

forcedinline int atomicDecrementAndReturn (int& variable) throw()
{
    return OTAtomicAdd32 (-1, (SInt32*) &variable);
}

#endif

Matt


#2

Ah - nice one. I’d noticed that they deprecated those functions, but hadn’t got around to finding out what they changed them to yet. Cheers, matt!


#3

…in fact, it looks like they’ve got some inc/dec functions now, so it might be a bit more efficient to use:

[code] forcedinline void atomicIncrement (int& variable) throw()
{
OSAtomicIncrement32 ((int32_t*) &variable);
}

forcedinline int atomicIncrementAndReturn (int& variable) throw()
{
    return OSAtomicIncrement32 ((int32_t*) &variable);
}

forcedinline void atomicDecrement (int& variable) throw()
{
    OSAtomicDecrement32 ((int32_t*) &variable);
}

forcedinline int atomicDecrementAndReturn (int& variable) throw()
{
   return OSAtomicDecrement32 ((int32_t*) &variable);
}

[/code]


#4

Spiffy!

It would be nice just to use the new ones, but I couldn’t get these to work with the 10.3.9 SDK.


#5