From 1b9a067bcc8053201445e9f4375b959525e4cd8d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 14 Sep 2016 14:10:39 +0200 Subject: [PATCH] Move code to apple_compat.h --- frontend/drivers/platform_darwin.m | 27 +--------------- gfx/drivers_context/cocoa_gl_ctx.m | 1 + libretro-common/include/compat/apple_compat.h | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index d573974e8b..1a9a38b1f9 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -45,6 +45,7 @@ #endif #include +#include #include #include #include @@ -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) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 712cd5ff0a..d211fdff86 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -36,6 +36,7 @@ #endif #include +#include #import "../../ui/drivers/cocoa/cocoa_common.h" #include "../video_context_driver.h" diff --git a/libretro-common/include/compat/apple_compat.h b/libretro-common/include/compat/apple_compat.h index 431243e746..1d20bbcbda 100644 --- a/libretro-common/include/compat/apple_compat.h +++ b/libretro-common/include/compat/apple_compat.h @@ -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 #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 #endif #endif + +#endif