upgrade rpm version to 4.14.1
[platform/upstream/rpm.git] / python / rpmsystem-py.h
1 #ifndef H_SYSTEM_PYTHON
2 #define H_SYSTEM_PYTHON
3
4 #if defined(__APPLE__)
5 #include <sys/types.h>
6 #endif
7
8 #define PY_SSIZE_T_CLEAN
9 #include <Python.h>
10 #include <structmember.h>
11
12 #if ((PY_MAJOR_VERSION << 8) | (PY_MINOR_VERSION << 0)) < 0x0205
13 typedef ssize_t Py_ssize_t;
14 typedef Py_ssize_t (*lenfunc)(PyObject *);
15 #endif  
16
17 /* Compatibility macros for Python < 2.6 */
18 #ifndef PyVarObject_HEAD_INIT
19 #define PyVarObject_HEAD_INIT(type, size) \
20         PyObject_HEAD_INIT(type) size,
21 #endif 
22
23 #ifndef Py_TYPE
24 #define Py_TYPE(o) ((o)->ob_type)
25 #endif
26
27 #if ((PY_MAJOR_VERSION << 8) | (PY_MINOR_VERSION << 0)) < 0x0206
28 #define PyBytes_Check PyString_Check
29 #define PyBytes_FromString PyString_FromString
30 #define PyBytes_FromStringAndSize PyString_FromStringAndSize
31 #define PyBytes_Size PyString_Size
32 #define PyBytes_AsString PyString_AsString
33 #endif
34
35 #if ((PY_MAJOR_VERSION << 8) | (PY_MINOR_VERSION << 0)) >= 0x0207
36 #define CAPSULE_BUILD(ptr,name) PyCapsule_New(ptr, name, NULL)
37 #define CAPSULE_CHECK(obj) PyCapsule_CheckExact(obj)
38 #define CAPSULE_EXTRACT(obj,name) PyCapsule_GetPointer(obj, name)
39 #else
40 #define CAPSULE_BUILD(ptr,name) PyCObject_FromVoidPtr(ptr, NULL)
41 #define CAPSULE_CHECK(obj) PyCObject_Check(obj)
42 #define CAPSULE_EXTRACT(obj,name) PyCObject_AsVoidPtr(obj)
43 #endif
44
45 /* For Python 3, use the PyLong type throughout in place of PyInt */
46 #if PY_MAJOR_VERSION >= 3
47 #define PyInt_Check PyLong_Check
48 #define PyInt_AsLong PyLong_AsLong
49 #define PyInt_FromLong PyLong_FromLong
50 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
51 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
52 #define PyInt_AsSsize_t PyLong_AsSsize_t
53 #endif
54
55 #endif  /* H_SYSTEM_PYTHON */