Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:38

0001 //  (C) Copyright David Abrahams 2000.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 //
0006 //  The author gratefully acknowleges the support of Dragon Systems, Inc., in
0007 //  producing this work.
0008 
0009 //  This file serves as a wrapper around <Python.h> which allows it to be
0010 //  compiled with GCC 2.95.2 under Win32 and which disables the default MSVC
0011 //  behavior so that a program may be compiled in debug mode without requiring a
0012 //  special debugging build of the Python library.
0013 
0014 
0015 //  To use the Python debugging library, #define BOOST_DEBUG_PYTHON on the
0016 //  compiler command-line.
0017 
0018 // Revision History:
0019 // 05 Mar 01  Suppress warnings under Cygwin with Python 2.0 (Dave Abrahams)
0020 // 04 Mar 01  Rolled in some changes from the Dragon fork (Dave Abrahams)
0021 // 01 Mar 01  define PyObject_INIT() for Python 1.x (Dave Abrahams)
0022 
0023 #ifdef _DEBUG
0024 # ifndef BOOST_DEBUG_PYTHON
0025 #  ifdef _MSC_VER  
0026     // VC8.0 will complain if system headers are #included both with
0027     // and without _DEBUG defined, so we have to #include all the
0028     // system headers used by pyconfig.h right here.
0029 #   include <stddef.h>
0030 #   include <stdarg.h>
0031 #   include <stdio.h>
0032 #   include <stdlib.h>
0033 #   include <assert.h>
0034 #   include <errno.h>
0035 #   include <ctype.h>
0036 #   include <wchar.h>
0037 #   include <basetsd.h>
0038 #   include <io.h>
0039 #   include <limits.h>
0040 #   include <float.h>
0041 #   include <string.h>
0042 #   include <math.h>
0043 #   include <time.h>
0044 #  endif
0045 #  undef _DEBUG // Don't let Python force the debug library just because we're debugging.
0046 #  define DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
0047 # endif
0048 #endif
0049 
0050 // pyconfig.h defines a macro with hypot name, what breaks libstdc++ math headers
0051 // that Python.h tries to include afterwards.
0052 #if defined(__MINGW32__)
0053 # include <cmath>
0054 # include <math.h>
0055 #endif
0056 
0057 # include <pyconfig.h>
0058 # if defined(_SGI_COMPILER_VERSION) && _SGI_COMPILER_VERSION >= 740
0059 #  undef _POSIX_C_SOURCE
0060 #  undef _XOPEN_SOURCE
0061 #  undef HAVE_STDINT_H // undo Python 2.5.1 define
0062 # endif
0063 
0064 //
0065 // Python's LongObject.h helpfully #defines ULONGLONG_MAX for us,
0066 // which confuses Boost's config
0067 //
0068 #include <limits.h>
0069 #ifndef ULONG_MAX
0070 # define BOOST_PYTHON_ULONG_MAX_UNDEFINED
0071 #endif
0072 #ifndef LONGLONG_MAX
0073 # define BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
0074 #endif
0075 #ifndef ULONGLONG_MAX
0076 # define BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
0077 #endif
0078 
0079 //
0080 // Get ahold of Python's version number
0081 //
0082 #include <patchlevel.h>
0083 
0084 #if PY_MAJOR_VERSION<2 || PY_MAJOR_VERSION==2 && PY_MINOR_VERSION<2
0085 #error Python 2.2 or higher is required for this version of Boost.Python.
0086 #endif
0087 
0088 //
0089 // Some things we need in order to get Python.h to work with compilers other
0090 // than MSVC on Win32
0091 //
0092 #if defined(_WIN32) || defined(__CYGWIN__)
0093 
0094 # if defined(__GNUC__) && defined(__CYGWIN__)
0095 
0096 #  if defined(__LP64__)
0097 #   define SIZEOF_LONG 8
0098 #  else
0099 #   define SIZEOF_LONG 4
0100 #  endif
0101 
0102 
0103 #  if PY_MAJOR_VERSION < 2 || PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 2
0104 
0105 typedef int pid_t;
0106 
0107 #   if defined(__LP64__)
0108 #    define WORD_BIT 64
0109 #   else
0110 #    define WORD_BIT 32
0111 #   endif
0112 #   define hypot _hypot
0113 #   include <stdio.h>
0114 
0115 #   if PY_MAJOR_VERSION < 2
0116 #    define HAVE_CLOCK
0117 #    define HAVE_STRFTIME
0118 #    define HAVE_STRERROR
0119 #   endif
0120 
0121 #   define NT_THREADS
0122 
0123 #   ifndef NETSCAPE_PI
0124 #    define USE_SOCKET
0125 #   endif
0126 
0127 #   ifdef USE_DL_IMPORT
0128 #    define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
0129 #   endif
0130 
0131 #   ifdef USE_DL_EXPORT
0132 #    define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
0133 #    define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
0134 #   endif
0135 
0136 #   define HAVE_LONG_LONG 1
0137 #   define LONG_LONG long long
0138 #  endif
0139 
0140 # elif defined(__MWERKS__)
0141 
0142 #  ifndef _MSC_VER
0143 #   define PY_MSC_VER_DEFINED_FROM_WRAP_PYTHON_H 1
0144 #   define _MSC_VER 900
0145 #  endif
0146 
0147 #  undef hypot // undo the evil #define left by Python.
0148 
0149 # elif defined(__BORLANDC__) && !defined(__clang__)
0150 #  undef HAVE_HYPOT
0151 #  define HAVE_HYPOT 1
0152 # endif
0153 
0154 #endif // _WIN32
0155 
0156 #if defined(__GNUC__)
0157 # if defined(__has_warning)
0158 #  define BOOST_PYTHON_GCC_HAS_WREGISTER __has_warning("-Wregister")
0159 # else
0160 #  define BOOST_PYTHON_GCC_HAS_WREGISTER __GNUC__ >= 7
0161 # endif
0162 #else
0163 # define BOOST_PYTHON_GCC_HAS_WREGISTER 0
0164 #endif
0165 
0166 // Python.h header uses `register` keyword until Python 3.4
0167 #if BOOST_PYTHON_GCC_HAS_WREGISTER
0168 # pragma GCC diagnostic push
0169 # pragma GCC diagnostic ignored "-Wregister"
0170 #elif defined(_MSC_VER)
0171 # pragma warning(push)
0172 # pragma warning(disable : 5033)  // 'register' is no longer a supported storage class
0173 #endif
0174 
0175 #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2
0176 # include <boost/python/detail/python22_fixed.h>
0177 #else
0178 # include <Python.h>
0179 #endif
0180 
0181 #if BOOST_PYTHON_GCC_HAS_WREGISTER
0182 # pragma GCC diagnostic pop
0183 #elif defined(_MSC_VER)
0184 # pragma warning(pop)
0185 #endif
0186 #undef BOOST_PYTHON_GCC_HAS_WREGISTER
0187 
0188 #ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED
0189 # undef ULONG_MAX
0190 # undef BOOST_PYTHON_ULONG_MAX_UNDEFINED
0191 #endif
0192 
0193 #ifdef BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
0194 # undef LONGLONG_MAX
0195 # undef BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
0196 #endif
0197 
0198 #ifdef BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
0199 # undef ULONGLONG_MAX
0200 # undef BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
0201 #endif
0202 
0203 #ifdef PY_MSC_VER_DEFINED_FROM_WRAP_PYTHON_H
0204 # undef _MSC_VER
0205 #endif
0206 
0207 #ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
0208 # undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
0209 # define _DEBUG
0210 # ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
0211 #  undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
0212 #  undef _CRT_NOFORCE_MANIFEST
0213 # endif
0214 #endif
0215 
0216 #if !defined(PY_MAJOR_VERSION) || PY_MAJOR_VERSION < 2
0217 # define PyObject_INIT(op, typeobj) \
0218         ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
0219 #endif
0220 
0221 // Define Python 3 macros for Python 2.x
0222 #if PY_VERSION_HEX < 0x02060000
0223 
0224 # define Py_TYPE(o)    (((PyObject*)(o))->ob_type)
0225 # define Py_REFCNT(o)  (((PyObject*)(o))->ob_refcnt)
0226 # define Py_SIZE(o)    (((PyVarObject*)(o))->ob_size)
0227 
0228 # define PyVarObject_HEAD_INIT(type, size) \
0229         PyObject_HEAD_INIT(type) size,
0230 #endif
0231 
0232 #if PY_VERSION_HEX < 0x030900A4
0233 #  define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
0234 #  define Py_SET_SIZE(obj, size) ((Py_SIZE(obj) = (size)), (void)0)
0235 #endif
0236 
0237 
0238 #ifdef __MWERKS__
0239 # pragma warn_possunwant off
0240 #elif _MSC_VER
0241 # pragma warning(disable:4786)
0242 #endif
0243 
0244 #if defined(HAVE_LONG_LONG)
0245 # if defined(PY_LONG_LONG)
0246 #  define BOOST_PYTHON_LONG_LONG PY_LONG_LONG
0247 # elif defined(LONG_LONG)
0248 #  define BOOST_PYTHON_LONG_LONG LONG_LONG
0249 # else
0250 #  error "HAVE_LONG_LONG defined but not PY_LONG_LONG or LONG_LONG"
0251 # endif
0252 #endif