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 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Objective-C/PyObjC/pyobjc-compat.h (limited to 'Objective-C/PyObjC/pyobjc-compat.h') 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 */ -- cgit v1.2.3