From 4ac5eb3c63c54b08797908286c630a501cc3031d Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Mon, 28 Jan 2008 20:44:35 +0100 Subject: Add pyobjc-compat.h from PyObjC. darcs-hash:939dae08bb2c00fc57bd0a413d1225167758851f --- Objective-C/PyObjC/pyobjc-compat.h | 95 ++++++++++++++++++++++++++++++++++++++ Objective-C/PyObjC/pyobjc.h | 9 ++++ 2 files changed, 104 insertions(+) create mode 100644 Objective-C/PyObjC/pyobjc-compat.h (limited to 'Objective-C/PyObjC') diff --git a/Objective-C/PyObjC/pyobjc-compat.h b/Objective-C/PyObjC/pyobjc-compat.h new file mode 100644 index 0000000..20e7301 --- /dev/null +++ b/Objective-C/PyObjC/pyobjc-compat.h @@ -0,0 +1,95 @@ +#ifndef PyObjC_COMPAT_H +#define PyObjC_COMPAT_H + +/* + * Compatibilty definitions + */ + +#ifdef __GNUC__ +#define unlikely(x) __builtin_expect (!!(x), 0) +#define likely(x) __builtin_expect (!!(x), 1) +#else +#define likely(x) x +#define likely(x) x +#endif + +#import +/* On 10.1 there are no defines for the OS version. */ +#ifndef MAC_OS_X_VERSION_10_1 +#define MAC_OS_X_VERSION_10_1 1010 +#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_1 + +#error "MAC_OS_X_VERSION_10_1 not defined. You aren't running 10.1 are you?" + +#endif + + +#ifndef MAC_OS_X_VERSION_10_2 +#define MAC_OS_X_VERSION_10_2 1020 +#endif + +#ifndef MAC_OS_X_VERSION_10_3 +#define MAC_OS_X_VERSION_10_3 1030 +#endif + +#ifndef MAC_OS_X_VERSION_10_4 +#define MAC_OS_X_VERSION_10_4 1040 +#endif + +#ifndef MAC_OS_X_VERSION_10_5 +#define MAC_OS_X_VERSION_10_5 1050 +#endif + + +/* On some versions of GCC defines LONG_LONG_MAX but not LLONG_MAX, + * compensate. + */ +#ifndef LLONG_MIN +#ifdef LONG_LONG_MIN +#define LLONG_MIN LONG_LONG_MIN +#define LLONG_MAX LONG_LONG_MAX +#define ULLONG_MAX ULONG_LONG_MAX +#endif +#endif + +#if (PY_VERSION_HEX < 0x02050000) +typedef int Py_ssize_t; +#define PY_FORMAT_SIZE_T "" +#define Py_ARG_SIZE_T "i" +#define PY_SSIZE_T_MAX INT_MAX + +#else + +#ifndef Py_ARG_SIZE_T +#define Py_ARG_SIZE_T "n" +#endif + +#endif + + +/* NSInteger and friends are available on Leopard and later, define them here + * for compatibility with earlier versions. + * + * Note that the guard definition is the same as used by Leopard itself. + */ +#import + +#ifndef NSINTEGER_DEFINED + +#ifdef __LP64__ +# error "Huh? 64-bit but no NSINTEGER available???" +#endif + +typedef int NSInteger; +typedef unsigned int NSUInteger; + +#define NSIntegerMax LONG_MAX +#define NSIntegerMin LONG_MIN +#define NSUIntegerMax ULONG_MAX + +#define NSINTEGER_DEFINED + +#endif + + +#endif /* PyObjC_COMPAT_H */ diff --git a/Objective-C/PyObjC/pyobjc.h b/Objective-C/PyObjC/pyobjc.h index 6a2d6b4..3a159c8 100644 --- a/Objective-C/PyObjC/pyobjc.h +++ b/Objective-C/PyObjC/pyobjc.h @@ -7,6 +7,15 @@ #include #include "libobjcl.h" +#ifdef __NEXT_RUNTIME__ +#include "pyobjc-compat.h" +#endif + +#ifndef __OBJC2__ +#define NO_OBJC2_RUNTIME +#endif + +/* #define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 */ #ifdef __NEXT_RUNTIME__ -- cgit v1.2.3