diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2015-06-06 14:21:20 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2015-06-06 14:21:20 +0200 |
commit | 96aafb0820285b1904fdc36d11ea75bf12c1c77d (patch) | |
tree | d362d3a3a36dd17ecc4e122a6ba35a7d066afa43 /Cython/Utility/ModuleSetupCode.c | |
parent | 736d715f4c26f477b3a1349c533340bf67f0d2fd (diff) | |
download | cython-96aafb0820285b1904fdc36d11ea75bf12c1c77d.tar.gz |
keep C++ code out of C files and vice-versa by splitting module preamble (original patch by Lars Mans)
Diffstat (limited to 'Cython/Utility/ModuleSetupCode.c')
-rw-r--r-- | Cython/Utility/ModuleSetupCode.c | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/Cython/Utility/ModuleSetupCode.c b/Cython/Utility/ModuleSetupCode.c index 073943880..575203b98 100644 --- a/Cython/Utility/ModuleSetupCode.c +++ b/Cython/Utility/ModuleSetupCode.c @@ -200,20 +200,7 @@ typedef struct { #define __Pyx_PyType_AsAsync(obj) NULL #endif -/* inline attribute */ -#ifndef CYTHON_INLINE - #if defined(__GNUC__) - #define CYTHON_INLINE __inline__ - #elif defined(_MSC_VER) - #define CYTHON_INLINE __inline - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_INLINE inline - #else - #define CYTHON_INLINE - #endif -#endif - -/* restrict */ +// restrict #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ @@ -226,22 +213,32 @@ typedef struct { #endif #endif -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and - a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is - a quiet NaN. */ - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} +#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None) + + +/////////////// CInitCode /////////////// + +// inline attribute +#ifndef CYTHON_INLINE + #if defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif #endif -#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None) -#ifdef __cplusplus +/////////////// CppInitCode /////////////// + +// inline attribute +#ifndef CYTHON_INLINE + #define CYTHON_INLINE inline +#endif + // Work around clang bug http://stackoverflow.com/questions/21847816/c-invoke-nested-template-class-destructor template<typename T> void __Pyx_call_destructor(T* x) { @@ -259,7 +256,28 @@ class __Pyx_FakeReference { private: T *ptr; }; + + +/////////////// MathInitCode /////////////// + +#if defined(WIN32) || defined(MS_WINDOWS) + #define _USE_MATH_DEFINES #endif +#include <math.h> + +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + // Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and + // a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is + // a quiet NaN. + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif + /////////////// UtilityFunctionPredeclarations.proto /////////////// |