Move code to apple_compat.h

This commit is contained in:
twinaphex 2016-09-14 14:10:39 +02:00
parent 88b29c930f
commit 1b9a067bcc
3 changed files with 33 additions and 26 deletions

View File

@ -45,6 +45,7 @@
#endif
#include <boolean.h>
#include <compat/apple_compat.h>
#include <retro_miscellaneous.h>
#include <file/file_path.h>
#include <rhash.h>
@ -105,32 +106,6 @@ typedef enum
CFAllDomainsMask = 0x0ffff /* All domains: all of the above and future items */
} CFDomainMask;
#ifndef __has_feature
/* Compatibility with non-Clang compilers. */
#define __has_feature(x) 0
#endif
#ifndef CF_RETURNS_RETAINED
#if __has_feature(attribute_cf_returns_retained)
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
#else
#define CF_RETURNS_RETAINED
#endif
#endif
#ifndef NS_INLINE
#define NS_INLINE inline
#endif
NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X)
{
#if __has_feature(objc_arc)
return (__bridge_retained CFTypeRef)X;
#else
return X;
#endif
}
static NSSearchPathDirectory NSConvertFlagsCF(unsigned flags)
{
switch (flags)

View File

@ -36,6 +36,7 @@
#endif
#include <retro_assert.h>
#include <compat/apple_compat.h>
#import "../../ui/drivers/cocoa/cocoa_common.h"
#include "../video_context_driver.h"

View File

@ -20,6 +20,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __APPLE_COMPAT_H
#define __APPLE_COMPAT_H
#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif
@ -32,6 +35,32 @@ typedef unsigned NSUInteger;
typedef float CGFloat;
#endif
#ifndef __has_feature
/* Compatibility with non-Clang compilers. */
#define __has_feature(x) 0
#endif
#ifndef CF_RETURNS_RETAINED
#if __has_feature(attribute_cf_returns_retained)
#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
#else
#define CF_RETURNS_RETAINED
#endif
#endif
#ifndef NS_INLINE
#define NS_INLINE inline
#endif
static NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetainCompat(id X)
{
#if __has_feature(objc_arc)
return (__bridge_retained CFTypeRef)X;
#else
return X;
#endif
}
#endif
#ifdef IOS
@ -47,3 +76,5 @@ typedef float CGFloat;
#include <objc/objc-runtime.h>
#endif
#endif
#endif