From e449a8b260644955815aa7aa76cd530b27b4c72f Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 28 Jul 2007 18:30:36 -0700 Subject: [PATCH] remove gcc dependance for inline, branch prediction --- Cython/Compiler/Nodes.py | 15 ++++++++++++++- Cython/Compiler/Parsing.py | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 4dc7c45b..6f18ed0a 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2590,12 +2590,20 @@ class FromImportStatNode(StatNode): utility_function_predeclarations = \ """ +#ifdef __GNUC__ +#define INLINE __inline__ +#elif _WIN32 +#define INILNE __inline +#else +#define INLINE +#endif + typedef struct {const char *s; const void **p;} __Pyx_CApiTabEntry; /*proto*/ typedef struct {PyObject **p; char *s;} __Pyx_InternTabEntry; /*proto*/ typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) -static inline int __Pyx_PyObject_IsTrue(PyObject* x) { +static INILNE int __Pyx_PyObject_IsTrue(PyObject* x) { if (x == Py_True) return 1; else if (x == Py_False) return 0; else return PyObject_IsTrue(x); @@ -2606,8 +2614,13 @@ static inline int __Pyx_PyObject_IsTrue(PyObject* x) { if Options.gcc_branch_hints: branch_prediction_macros = \ """ +#ifdef __GNUC__ #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* __GNUC__ */ +#define likely(x) (x) +#define unlikely(x) (x) +#endif /* __GNUC__ */ """ else: branch_prediction_macros = \ diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 8389d774..9ff8c65b 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -1662,7 +1662,7 @@ def p_visibility(s, prev_visibility): def p_c_modifiers(s): if s.systring in ('inline', ): - modifier = s.systring + modifier = s.systring.upper() # uppercase is macro defined for various compilers s.next() return modifier + ' ' + p_c_modifiers(s) return "" -- 2.26.2