From a4b5540d3e20eaa07c3b9e022f55220767843da2 Mon Sep 17 00:00:00 2001 From: ivpusic Date: Wed, 21 Aug 2013 14:09:25 +0200 Subject: [PATCH 01/13] added build-pyobjus.sh script --- tools/build-pyobjus.sh | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 tools/build-pyobjus.sh diff --git a/tools/build-pyobjus.sh b/tools/build-pyobjus.sh new file mode 100755 index 0000000..efa0ed4 --- /dev/null +++ b/tools/build-pyobjus.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +. $(dirname $0)/environment.sh + + +if [ ! -d $TMPROOT/pyobjus ] ; then +try pushd $TMPROOT +try git clone -b test_on_device git@github.com:ivpusic/pyobjus.git +try popd +fi + +try pushd $TMPROOT/pyobjus + +OLD_CC="$CC" +OLD_CFLAGS="$CFLAGS" +OLD_LDFLAGS="$LDFLAGS" +OLD_LDSHARED="$LDSHARED" +export CC="$ARM_CC -I$BUILDROOT/include" +export CFLAGS="$ARM_CFLAGS" +export LDFLAGS="$ARM_LDFLAGS" +export LDSHARED="$KIVYIOSROOT/tools/liblink" + +rm -rdf iosbuild/ +try mkdir iosbuild + +try pushd $TMPROOT/pyobjus/pyobjus +find . -name *.pyx -exec $CYTHON {} \; +popd + +try $HOSTPYTHON setup.py build_ext +try $HOSTPYTHON setup.py install -O2 --root iosbuild + +# Strip away the large stuff +find iosbuild/ | grep -E '.*\.(py|pyc|so\.o|so\.a|so\.libs)$$' | xargs rm +rm -rdf "$BUILDROOT/python/lib/python2.7/site-packages/pyobjus" +try cp -R "iosbuid/Library/Python/2.7/site-packages/pyobjus" "$BUILDROOT/python/lib/python2.7/site-packages" +popd + +export CC="$OLD_CC" +export CFLAGS="$OLD_CFLAGS" +export LDFLAGS="$OLD_LDFLAGS" +export LDSHARED="$OLD_LDSHARED" + +bd=$TMPROOT/pyobjus/build/lib.macosx-*/pyobjus +echo $bd +try $KIVYIOSROOT/tools/biglink $BUILDROOT/lib/libpyobjus.a $bd +deduplicate $BUILDROOT/lib/libpyobjus.a From aedcd4e9ebbaf054ea90537741e5996f1d62945c Mon Sep 17 00:00:00 2001 From: ivpusic Date: Thu, 22 Aug 2013 19:14:21 +0200 Subject: [PATCH 02/13] added build libffi script, and fix of pyobjus script --- tools/build-libffi.sh | 26 ++++++++++++++++++++++++++ tools/build-pyobjus.sh | 4 ++-- tools/environment.sh | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100755 tools/build-libffi.sh diff --git a/tools/build-libffi.sh b/tools/build-libffi.sh new file mode 100755 index 0000000..dfe4e24 --- /dev/null +++ b/tools/build-libffi.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +. $(dirname $0)/environment.sh + +if [ ! -f $CACHEROOT/libffi-$FFI_VERSION.tar.gz ]; then + try curl -L ftp://sourceware.org/pub/libffi/libffi-$FFI_VERSION.tar.gz > $CACHEROOT/libffi-$FFI_VERSION.tar.gz +fi +if [ ! -d $TMPROOT/libffi-$FFI_VERSION ]; then + try rm -rf $TMPROOT/libffi-$FFI_VERSION + try tar xvf $CACHEROOT/libffi-$FFI_VERSION.tar.gz + try mv libffi-$FFI_VERSION $TMPROOT +fi + +if [ -f $TMPROOT/libffi-$FFI_VERSION/Release-iphoneos/libffi.a ]; then + exit 0; +fi + +# lib not found, compile it +pushd $TMPROOT/libffi-$FFI_VERSION + +try xcodebuild -project libffi.xcodeproj -target "libffi iOS" -configuration Release -sdk iphoneos$SDKVER OTHER_CFLAGS="-no-integrated-as" + +try cp build/Release-iphoneos/libffi.a $BUILDROOT/lib/libffi.a +try cp -a build/Release-iphoneos/usr/local/include $BUILDROOT/include/ffi + +popd diff --git a/tools/build-pyobjus.sh b/tools/build-pyobjus.sh index efa0ed4..24e0347 100755 --- a/tools/build-pyobjus.sh +++ b/tools/build-pyobjus.sh @@ -15,7 +15,7 @@ OLD_CC="$CC" OLD_CFLAGS="$CFLAGS" OLD_LDFLAGS="$LDFLAGS" OLD_LDSHARED="$LDSHARED" -export CC="$ARM_CC -I$BUILDROOT/include" +export CC="$ARM_CC -I$BUILDROOT/include -I$BUILDROOT/include/ffi" export CFLAGS="$ARM_CFLAGS" export LDFLAGS="$ARM_LDFLAGS" export LDSHARED="$KIVYIOSROOT/tools/liblink" @@ -33,7 +33,7 @@ try $HOSTPYTHON setup.py install -O2 --root iosbuild # Strip away the large stuff find iosbuild/ | grep -E '.*\.(py|pyc|so\.o|so\.a|so\.libs)$$' | xargs rm rm -rdf "$BUILDROOT/python/lib/python2.7/site-packages/pyobjus" -try cp -R "iosbuid/Library/Python/2.7/site-packages/pyobjus" "$BUILDROOT/python/lib/python2.7/site-packages" +try cp -R "iosbuild/usr/local/lib/python2.7/site-packages/pyobjus" "$BUILDROOT/python/lib/python2.7/site-packages" popd export CC="$OLD_CC" diff --git a/tools/environment.sh b/tools/environment.sh index efb3ea9..b75c487 100755 --- a/tools/environment.sh +++ b/tools/environment.sh @@ -33,6 +33,7 @@ export FT_VERSION=2.4.8 export XML2_VERSION=2.7.8 export XSLT_VERSION=1.1.26 export LXML_VERSION=2.3.1 +export FFI_VERSION=3.0.13 # where the build will be located export KIVYIOSROOT="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" From 43b613d9fac180527bcccf3e8d48f2e2178e90b9 Mon Sep 17 00:00:00 2001 From: ivpusic Date: Fri, 23 Aug 2013 14:16:31 +0200 Subject: [PATCH 03/13] some patches for _ctypes compilation. Still it doesn't works. --- src/python_files/ModulesSetup.mobile | 2 ++ tools/build-all.sh | 2 ++ tools/build-libffi.sh | 10 +++++----- tools/build-python.sh | 16 +++++++++------- 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 src/python_files/ModulesSetup.mobile diff --git a/src/python_files/ModulesSetup.mobile b/src/python_files/ModulesSetup.mobile new file mode 100644 index 0000000..826bf1c --- /dev/null +++ b/src/python_files/ModulesSetup.mobile @@ -0,0 +1,2 @@ +# Ctypes +_ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/stgdict.c _ctypes/cfield.c -I$(srcdir)/../../build/include/ffi diff --git a/tools/build-all.sh b/tools/build-all.sh index e3f353d..067147c 100755 --- a/tools/build-all.sh +++ b/tools/build-all.sh @@ -2,6 +2,7 @@ . $(dirname $0)/environment.sh +try $(dirname $0)/build-libffi.sh try $(dirname $0)/build-python.sh try $(dirname $0)/reduce-python.sh try $(dirname $0)/build-ios.sh @@ -12,6 +13,7 @@ try $(dirname $0)/build-sdlmixer.sh try $(dirname $0)/build-libjpeg.sh try $(dirname $0)/build-pil.sh try $(dirname $0)/build-kivy.sh +try $(dirname $0)/build-pyobjus.sh echo '== Build done' echo "Available libraries in $BUILDROOT/lib" diff --git a/tools/build-libffi.sh b/tools/build-libffi.sh index dfe4e24..9621af3 100755 --- a/tools/build-libffi.sh +++ b/tools/build-libffi.sh @@ -3,16 +3,16 @@ . $(dirname $0)/environment.sh if [ ! -f $CACHEROOT/libffi-$FFI_VERSION.tar.gz ]; then - try curl -L ftp://sourceware.org/pub/libffi/libffi-$FFI_VERSION.tar.gz > $CACHEROOT/libffi-$FFI_VERSION.tar.gz + try curl -L ftp://sourceware.org/pub/libffi/libffi-$FFI_VERSION.tar.gz > $CACHEROOT/libffi-$FFI_VERSION.tar.gz fi if [ ! -d $TMPROOT/libffi-$FFI_VERSION ]; then - try rm -rf $TMPROOT/libffi-$FFI_VERSION - try tar xvf $CACHEROOT/libffi-$FFI_VERSION.tar.gz - try mv libffi-$FFI_VERSION $TMPROOT + try rm -rf $TMPROOT/libffi-$FFI_VERSION + try tar xvf $CACHEROOT/libffi-$FFI_VERSION.tar.gz + try mv libffi-$FFI_VERSION $TMPROOT fi if [ -f $TMPROOT/libffi-$FFI_VERSION/Release-iphoneos/libffi.a ]; then - exit 0; + exit 0; fi # lib not found, compile it diff --git a/tools/build-python.sh b/tools/build-python.sh index e0ce939..a3fdca5 100755 --- a/tools/build-python.sh +++ b/tools/build-python.sh @@ -50,21 +50,23 @@ ln -s "$IOSSDKROOT/usr/lib/libgcc_s.1.dylib" extralibs/libgcc_s.10.4.dylib || ec # Copy our setup for modules try cp $KIVYIOSROOT/src/python_files/ModulesSetup Modules/Setup.local +try cat $KIVYIOSROOT/src/python_files/ModulesSetup.mobile >> Modules/Setup.local try cp $KIVYIOSROOT/src/python_files/_scproxy.py Lib/_scproxy.py try ./configure CC="$ARM_CC" LD="$ARM_LD" \ - CFLAGS="$ARM_CFLAGS" \ - LDFLAGS="$ARM_LDFLAGS -Lextralibs/ -lsqlite3" \ - --without-pymalloc \ - --disable-toolbox-glue \ - --host=armv7-apple-darwin \ - --prefix=/python \ + CFLAGS="$ARM_CFLAGS" \ + LDFLAGS="$ARM_LDFLAGS -Lextralibs/ -lsqlite3 -L$BUILDROOT/lib -undefined dynamic_lookup" \ + --without-pymalloc \ + --disable-toolbox-glue \ + --host=armv7-apple-darwin \ + --prefix=/python \ --without-doc-strings try make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen \ CROSS_COMPILE_TARGET=yes -try make install HOSTPYTHON=./hostpython CROSS_COMPILE_TARGET=yes prefix="$BUILDROOT/python" +try make install HOSTPYTHON=./hostpython CROSS_COMPILE_TARGET=yes \ + prefix="$BUILDROOT/python" try mv -f $BUILDROOT/python/lib/libpython2.7.a $BUILDROOT/lib/ From a2aeb88386957047e682a0f31d6f012024321b11 Mon Sep 17 00:00:00 2001 From: ivpusic Date: Mon, 26 Aug 2013 04:07:09 +0200 Subject: [PATCH 04/13] fix for _ctypes compilation on device --- src/python_files/cfield.c | 1761 +++++++++++++++++++++++++++++++++++ src/python_files/pyconfig.h | 1248 +++++++++++++++++++++++++ tools/build-python.sh | 4 + 3 files changed, 3013 insertions(+) create mode 100644 src/python_files/cfield.c create mode 100644 src/python_files/pyconfig.h diff --git a/src/python_files/cfield.c b/src/python_files/cfield.c new file mode 100644 index 0000000..e5c0a94 --- /dev/null +++ b/src/python_files/cfield.c @@ -0,0 +1,1761 @@ +/***************************************************************** + This file should be kept compatible with Python 2.3, see PEP 291. + *****************************************************************/ + +#include "Python.h" + +#include +#ifdef MS_WIN32 +#include +#endif +#include "ctypes.h" + + +#define CTYPES_CAPSULE_WCHAR_T "_ctypes/cfield.c wchar_t buffer from unicode" +CTYPES_CAPSULE_INSTANTIATE_DESTRUCTOR(CTYPES_CAPSULE_WCHAR_T) + + +/******************************************************************/ +/* + PyCField_Type +*/ +static PyObject * +PyCField_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + CFieldObject *obj; + obj = (CFieldObject *)type->tp_alloc(type, 0); + return (PyObject *)obj; +} + +/* + * Expects the size, index and offset for the current field in *psize and + * *poffset, stores the total size so far in *psize, the offset for the next + * field in *poffset, the alignment requirements for the current field in + * *palign, and returns a field desriptor for this field. + */ +/* + * bitfields extension: + * bitsize != 0: this is a bit field. + * pbitofs points to the current bit offset, this will be updated. + * prev_desc points to the type of the previous bitfield, if any. + */ +PyObject * +PyCField_FromDesc(PyObject *desc, Py_ssize_t index, + Py_ssize_t *pfield_size, int bitsize, int *pbitofs, + Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign, + int pack, int big_endian) +{ + CFieldObject *self; + PyObject *proto; + Py_ssize_t size, align, length; + SETFUNC setfunc = NULL; + GETFUNC getfunc = NULL; + StgDictObject *dict; + int fieldtype; +#define NO_BITFIELD 0 +#define NEW_BITFIELD 1 +#define CONT_BITFIELD 2 +#define EXPAND_BITFIELD 3 + + self = (CFieldObject *)PyObject_CallObject((PyObject *)&PyCField_Type, + NULL); + if (self == NULL) + return NULL; + dict = PyType_stgdict(desc); + if (!dict) { + PyErr_SetString(PyExc_TypeError, + "has no _stginfo_"); + Py_DECREF(self); + return NULL; + } + if (bitsize /* this is a bitfield request */ + && *pfield_size /* we have a bitfield open */ +#ifdef MS_WIN32 + /* MSVC, GCC with -mms-bitfields */ + && dict->size * 8 == *pfield_size +#else + /* GCC */ + && dict->size * 8 <= *pfield_size +#endif + && (*pbitofs + bitsize) <= *pfield_size) { + /* continue bit field */ + fieldtype = CONT_BITFIELD; +#ifndef MS_WIN32 + } else if (bitsize /* this is a bitfield request */ + && *pfield_size /* we have a bitfield open */ + && dict->size * 8 >= *pfield_size + && (*pbitofs + bitsize) <= dict->size * 8) { + /* expand bit field */ + fieldtype = EXPAND_BITFIELD; +#endif + } else if (bitsize) { + /* start new bitfield */ + fieldtype = NEW_BITFIELD; + *pbitofs = 0; + *pfield_size = dict->size * 8; + } else { + /* not a bit field */ + fieldtype = NO_BITFIELD; + *pbitofs = 0; + *pfield_size = 0; + } + + size = dict->size; + length = dict->length; + proto = desc; + + /* Field descriptors for 'c_char * n' are be scpecial cased to + return a Python string instead of an Array object instance... + */ + if (PyCArrayTypeObject_Check(proto)) { + StgDictObject *adict = PyType_stgdict(proto); + StgDictObject *idict; + if (adict && adict->proto) { + idict = PyType_stgdict(adict->proto); + if (!idict) { + PyErr_SetString(PyExc_TypeError, + "has no _stginfo_"); + Py_DECREF(self); + return NULL; + } + if (idict->getfunc == _ctypes_get_fielddesc("c")->getfunc) { + struct fielddesc *fd = _ctypes_get_fielddesc("s"); + getfunc = fd->getfunc; + setfunc = fd->setfunc; + } +#ifdef CTYPES_UNICODE + if (idict->getfunc == _ctypes_get_fielddesc("u")->getfunc) { + struct fielddesc *fd = _ctypes_get_fielddesc("U"); + getfunc = fd->getfunc; + setfunc = fd->setfunc; + } +#endif + } + } + + self->setfunc = setfunc; + self->getfunc = getfunc; + self->index = index; + + Py_INCREF(proto); + self->proto = proto; + + switch (fieldtype) { + case NEW_BITFIELD: + if (big_endian) + self->size = (bitsize << 16) + *pfield_size - *pbitofs - bitsize; + else + self->size = (bitsize << 16) + *pbitofs; + *pbitofs = bitsize; + /* fall through */ + case NO_BITFIELD: + if (pack) + align = min(pack, dict->align); + else + align = dict->align; + if (align && *poffset % align) { + Py_ssize_t delta = align - (*poffset % align); + *psize += delta; + *poffset += delta; + } + + if (bitsize == 0) + self->size = size; + *psize += size; + + self->offset = *poffset; + *poffset += size; + + *palign = align; + break; + + case EXPAND_BITFIELD: + *poffset += dict->size - *pfield_size/8; + *psize += dict->size - *pfield_size/8; + + *pfield_size = dict->size * 8; + + if (big_endian) + self->size = (bitsize << 16) + *pfield_size - *pbitofs - bitsize; + else + self->size = (bitsize << 16) + *pbitofs; + + self->offset = *poffset - size; /* poffset is already updated for the NEXT field */ + *pbitofs += bitsize; + break; + + case CONT_BITFIELD: + if (big_endian) + self->size = (bitsize << 16) + *pfield_size - *pbitofs - bitsize; + else + self->size = (bitsize << 16) + *pbitofs; + + self->offset = *poffset - size; /* poffset is already updated for the NEXT field */ + *pbitofs += bitsize; + break; + } + + return (PyObject *)self; +} + +static int +PyCField_set(CFieldObject *self, PyObject *inst, PyObject *value) +{ + CDataObject *dst; + char *ptr; + assert(CDataObject_Check(inst)); + dst = (CDataObject *)inst; + ptr = dst->b_ptr + self->offset; + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } + return PyCData_set(inst, self->proto, self->setfunc, value, + self->index, self->size, ptr); +} + +static PyObject * +PyCField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type) +{ + CDataObject *src; + if (inst == NULL) { + Py_INCREF(self); + return (PyObject *)self; + } + assert(CDataObject_Check(inst)); + src = (CDataObject *)inst; + return PyCData_get(self->proto, self->getfunc, inst, + self->index, self->size, src->b_ptr + self->offset); +} + +static PyObject * +PyCField_get_offset(PyObject *self, void *data) +{ + return PyInt_FromSsize_t(((CFieldObject *)self)->offset); +} + +static PyObject * +PyCField_get_size(PyObject *self, void *data) +{ + return PyInt_FromSsize_t(((CFieldObject *)self)->size); +} + +static PyGetSetDef PyCField_getset[] = { + { "offset", PyCField_get_offset, NULL, "offset in bytes of this field" }, + { "size", PyCField_get_size, NULL, "size in bytes of this field" }, + { NULL, NULL, NULL, NULL }, +}; + +static int +PyCField_traverse(CFieldObject *self, visitproc visit, void *arg) +{ + Py_VISIT(self->proto); + return 0; +} + +static int +PyCField_clear(CFieldObject *self) +{ + Py_CLEAR(self->proto); + return 0; +} + +static void +PyCField_dealloc(PyObject *self) +{ + PyCField_clear((CFieldObject *)self); + self->ob_type->tp_free((PyObject *)self); +} + +static PyObject * +PyCField_repr(CFieldObject *self) +{ + PyObject *result; + Py_ssize_t bits = self->size >> 16; + Py_ssize_t size = self->size & 0xFFFF; + const char *name; + + name = ((PyTypeObject *)self->proto)->tp_name; + + if (bits) + result = PyString_FromFormat( +#if (PY_VERSION_HEX < 0x02050000) + "", +#else + "", +#endif + name, self->offset, size, bits); + else + result = PyString_FromFormat( +#if (PY_VERSION_HEX < 0x02050000) + "", +#else + "", +#endif + name, self->offset, size); + return result; +} + +PyTypeObject PyCField_Type = { + PyVarObject_HEAD_INIT(NULL, 0) + "_ctypes.CField", /* tp_name */ + sizeof(CFieldObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + PyCField_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)PyCField_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + "Structure/Union member", /* tp_doc */ + (traverseproc)PyCField_traverse, /* tp_traverse */ + (inquiry)PyCField_clear, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + PyCField_getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + (descrgetfunc)PyCField_get, /* tp_descr_get */ + (descrsetfunc)PyCField_set, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyCField_new, /* tp_new */ + 0, /* tp_free */ +}; + + +/******************************************************************/ +/* + Accessor functions +*/ + +/* Derived from Modules/structmodule.c: + Helper routine to get a Python integer and raise the appropriate error + if it isn't one */ + +static int +get_long(PyObject *v, long *p) +{ + long x; + if (PyFloat_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "int expected instead of float"); + return -1; + } + x = PyInt_AsUnsignedLongMask(v); + if (x == -1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +/* Same, but handling unsigned long */ + +static int +get_ulong(PyObject *v, unsigned long *p) +{ + unsigned long x; + if (PyFloat_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "int expected instead of float"); + return -1; + } + x = PyInt_AsUnsignedLongMask(v); + if (x == (unsigned long)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +#ifdef HAVE_LONG_LONG + +/* Same, but handling native long long. */ + +static int +get_longlong(PyObject *v, PY_LONG_LONG *p) +{ + PY_LONG_LONG x; + if (PyFloat_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "int expected instead of float"); + return -1; + } + x = PyInt_AsUnsignedLongLongMask(v); + if (x == -1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +/* Same, but handling native unsigned long long. */ + +static int +get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) +{ + unsigned PY_LONG_LONG x; + if (PyFloat_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "int expected instead of float"); + return -1; + } + x = PyInt_AsUnsignedLongLongMask(v); + if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) + return -1; + *p = x; + return 0; +} + +#endif + +/***************************************************************** + * Integer fields, with bitfield support + */ + +/* how to decode the size field, for integer get/set functions */ +#define LOW_BIT(x) ((x) & 0xFFFF) +#define NUM_BITS(x) ((x) >> 16) + +/* This seems nore a compiler issue than a Windows/non-Windows one */ +#ifdef MS_WIN32 +# define BIT_MASK(size) ((1 << NUM_BITS(size))-1) +#else +# define BIT_MASK(size) ((1LL << NUM_BITS(size))-1) +#endif + +/* This macro CHANGES the first parameter IN PLACE. For proper sign handling, + we must first shift left, then right. +*/ +#define GET_BITFIELD(v, size) \ + if (NUM_BITS(size)) { \ + v <<= (sizeof(v)*8 - LOW_BIT(size) - NUM_BITS(size)); \ + v >>= (sizeof(v)*8 - NUM_BITS(size)); \ + } + +/* This macro RETURNS the first parameter with the bit field CHANGED. */ +#define SET(x, v, size) \ + (NUM_BITS(size) ? \ + ( ( x & ~(BIT_MASK(size) << LOW_BIT(size)) ) | ( (v & BIT_MASK(size)) << LOW_BIT(size) ) ) \ + : v) + +/* byte swapping macros */ +#define SWAP_2(v) \ + ( ( (v >> 8) & 0x00FF) | \ + ( (v << 8) & 0xFF00) ) + +#define SWAP_4(v) \ + ( ( (v & 0x000000FF) << 24 ) | \ + ( (v & 0x0000FF00) << 8 ) | \ + ( (v & 0x00FF0000) >> 8 ) | \ + ( ((v >> 24) & 0xFF)) ) + +#ifdef _MSC_VER +#define SWAP_8(v) \ + ( ( (v & 0x00000000000000FFL) << 56 ) | \ + ( (v & 0x000000000000FF00L) << 40 ) | \ + ( (v & 0x0000000000FF0000L) << 24 ) | \ + ( (v & 0x00000000FF000000L) << 8 ) | \ + ( (v & 0x000000FF00000000L) >> 8 ) | \ + ( (v & 0x0000FF0000000000L) >> 24 ) | \ + ( (v & 0x00FF000000000000L) >> 40 ) | \ + ( ((v >> 56) & 0xFF)) ) +#else +#define SWAP_8(v) \ + ( ( (v & 0x00000000000000FFLL) << 56 ) | \ + ( (v & 0x000000000000FF00LL) << 40 ) | \ + ( (v & 0x0000000000FF0000LL) << 24 ) | \ + ( (v & 0x00000000FF000000LL) << 8 ) | \ + ( (v & 0x000000FF00000000LL) >> 8 ) | \ + ( (v & 0x0000FF0000000000LL) >> 24 ) | \ + ( (v & 0x00FF000000000000LL) >> 40 ) | \ + ( ((v >> 56) & 0xFF)) ) +#endif + +#define SWAP_INT SWAP_4 + +#if SIZEOF_LONG == 4 +# define SWAP_LONG SWAP_4 +#elif SIZEOF_LONG == 8 +# define SWAP_LONG SWAP_8 +#endif +/***************************************************************** + * The setter methods return an object which must be kept alive, to keep the + * data valid which has been stored in the memory block. The ctypes object + * instance inserts this object into its 'b_objects' list. + * + * For simple Python types like integers or characters, there is nothing that + * has to been kept alive, so Py_None is returned in these cases. But this + * makes inspecting the 'b_objects' list, which is accessible from Python for + * debugging, less useful. + * + * So, defining the _CTYPES_DEBUG_KEEP symbol returns the original value + * instead of Py_None. + */ + +#ifdef _CTYPES_DEBUG_KEEP +#define _RET(x) Py_INCREF(x); return x +#else +#define _RET(X) Py_INCREF(Py_None); return Py_None +#endif + +/***************************************************************** + * integer accessor methods, supporting bit fields + */ + +static PyObject * +b_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + long val; + if (get_long(value, &val) < 0) + return NULL; + *(signed char *)ptr = (signed char)SET(*(signed char *)ptr, (signed char)val, size); + _RET(value); +} + + +static PyObject * +b_get(void *ptr, Py_ssize_t size) +{ + signed char val = *(signed char *)ptr; + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +static PyObject * +B_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned long val; + if (get_ulong(value, &val) < 0) + return NULL; + *(unsigned char *)ptr = (unsigned char)SET(*(unsigned char*)ptr, + (unsigned short)val, size); + _RET(value); +} + + +static PyObject * +B_get(void *ptr, Py_ssize_t size) +{ + unsigned char val = *(unsigned char *)ptr; + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +static PyObject * +h_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + long val; + short x; + if (get_long(value, &val) < 0) + return NULL; + memcpy(&x, ptr, sizeof(x)); + x = SET(x, (short)val, size); + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + + +static PyObject * +h_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + long val; + short field; + if (get_long(value, &val) < 0) + return NULL; + memcpy(&field, ptr, sizeof(field)); + field = SWAP_2(field); + field = SET(field, (short)val, size); + field = SWAP_2(field); + memcpy(ptr, &field, sizeof(field)); + _RET(value); +} + +static PyObject * +h_get(void *ptr, Py_ssize_t size) +{ + short val; + memcpy(&val, ptr, sizeof(val)); + GET_BITFIELD(val, size); + return PyInt_FromLong((long)val); +} + +static PyObject * +h_get_sw(void *ptr, Py_ssize_t size) +{ + short val; + memcpy(&val, ptr, sizeof(val)); + val = SWAP_2(val); + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +static PyObject * +H_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned long val; + unsigned short x; + if (get_ulong(value, &val) < 0) + return NULL; + memcpy(&x, ptr, sizeof(x)); + x = SET(x, (unsigned short)val, size); + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + +static PyObject * +H_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned long val; + unsigned short field; + if (get_ulong(value, &val) < 0) + return NULL; + memcpy(&field, ptr, sizeof(field)); + field = SWAP_2(field); + field = SET(field, (unsigned short)val, size); + field = SWAP_2(field); + memcpy(ptr, &field, sizeof(field)); + _RET(value); +} + + +static PyObject * +H_get(void *ptr, Py_ssize_t size) +{ + unsigned short val; + memcpy(&val, ptr, sizeof(val)); + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +static PyObject * +H_get_sw(void *ptr, Py_ssize_t size) +{ + unsigned short val; + memcpy(&val, ptr, sizeof(val)); + val = SWAP_2(val); + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +static PyObject * +i_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + long val; + int x; + if (get_long(value, &val) < 0) + return NULL; + memcpy(&x, ptr, sizeof(x)); + x = SET(x, (int)val, size); + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + +static PyObject * +i_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + long val; + int field; + if (get_long(value, &val) < 0) + return NULL; + memcpy(&field, ptr, sizeof(field)); + field = SWAP_INT(field); + field = SET(field, (int)val, size); + field = SWAP_INT(field); + memcpy(ptr, &field, sizeof(field)); + _RET(value); +} + + +static PyObject * +i_get(void *ptr, Py_ssize_t size) +{ + int val; + memcpy(&val, ptr, sizeof(val)); + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +static PyObject * +i_get_sw(void *ptr, Py_ssize_t size) +{ + int val; + memcpy(&val, ptr, sizeof(val)); + val = SWAP_INT(val); + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +#ifdef MS_WIN32 +/* short BOOL - VARIANT_BOOL */ +static PyObject * +vBOOL_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + switch (PyObject_IsTrue(value)) { + case -1: + return NULL; + case 0: + *(short int *)ptr = VARIANT_FALSE; + _RET(value); + default: + *(short int *)ptr = VARIANT_TRUE; + _RET(value); + } +} + +static PyObject * +vBOOL_get(void *ptr, Py_ssize_t size) +{ + return PyBool_FromLong((long)*(short int *)ptr); +} +#endif + +#ifdef HAVE_C99_BOOL +#define BOOL_TYPE _Bool +#else +#define BOOL_TYPE char +#undef SIZEOF__BOOL +#define SIZEOF__BOOL 1 +#endif + +static PyObject * +bool_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + switch (PyObject_IsTrue(value)) { + case -1: + return NULL; + case 0: + *(BOOL_TYPE *)ptr = 0; + _RET(value); + default: + *(BOOL_TYPE *)ptr = 1; + _RET(value); + } +} + +static PyObject * +bool_get(void *ptr, Py_ssize_t size) +{ + return PyBool_FromLong((long)*(BOOL_TYPE *)ptr); +} + +static PyObject * +I_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned long val; + unsigned int x; + if (get_ulong(value, &val) < 0) + return NULL; + memcpy(&x, ptr, sizeof(x)); + x = SET(x, (unsigned int)val, size); + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + +static PyObject * +I_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned long val; + unsigned int field; + if (get_ulong(value, &val) < 0) + return NULL; + memcpy(&field, ptr, sizeof(field)); + field = (unsigned int)SET(field, (unsigned int)val, size); + field = SWAP_INT(field); + memcpy(ptr, &field, sizeof(field)); + _RET(value); +} + + +static PyObject * +I_get(void *ptr, Py_ssize_t size) +{ + unsigned int val; + memcpy(&val, ptr, sizeof(val)); + GET_BITFIELD(val, size); + return PyLong_FromUnsignedLong(val); +} + +static PyObject * +I_get_sw(void *ptr, Py_ssize_t size) +{ + unsigned int val; + memcpy(&val, ptr, sizeof(val)); + val = SWAP_INT(val); + GET_BITFIELD(val, size); + return PyLong_FromUnsignedLong(val); +} + +static PyObject * +l_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + long val; + long x; + if (get_long(value, &val) < 0) + return NULL; + memcpy(&x, ptr, sizeof(x)); + x = SET(x, val, size); + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + +static PyObject * +l_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + long val; + long field; + if (get_long(value, &val) < 0) + return NULL; + memcpy(&field, ptr, sizeof(field)); + field = SWAP_LONG(field); + field = (long)SET(field, val, size); + field = SWAP_LONG(field); + memcpy(ptr, &field, sizeof(field)); + _RET(value); +} + + +static PyObject * +l_get(void *ptr, Py_ssize_t size) +{ + long val; + memcpy(&val, ptr, sizeof(val)); + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +static PyObject * +l_get_sw(void *ptr, Py_ssize_t size) +{ + long val; + memcpy(&val, ptr, sizeof(val)); + val = SWAP_LONG(val); + GET_BITFIELD(val, size); + return PyInt_FromLong(val); +} + +static PyObject * +L_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned long val; + unsigned long x; + if (get_ulong(value, &val) < 0) + return NULL; + memcpy(&x, ptr, sizeof(x)); + x = SET(x, val, size); + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + +static PyObject * +L_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned long val; + unsigned long field; + if (get_ulong(value, &val) < 0) + return NULL; + memcpy(&field, ptr, sizeof(field)); + field = SWAP_LONG(field); + field = (unsigned long)SET(field, val, size); + field = SWAP_LONG(field); + memcpy(ptr, &field, sizeof(field)); + _RET(value); +} + + +static PyObject * +L_get(void *ptr, Py_ssize_t size) +{ + unsigned long val; + memcpy(&val, ptr, sizeof(val)); + GET_BITFIELD(val, size); + return PyLong_FromUnsignedLong(val); +} + +static PyObject * +L_get_sw(void *ptr, Py_ssize_t size) +{ + unsigned long val; + memcpy(&val, ptr, sizeof(val)); + val = SWAP_LONG(val); + GET_BITFIELD(val, size); + return PyLong_FromUnsignedLong(val); +} + +#ifdef HAVE_LONG_LONG +static PyObject * +q_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + PY_LONG_LONG val; + PY_LONG_LONG x; + if (get_longlong(value, &val) < 0) + return NULL; + memcpy(&x, ptr, sizeof(x)); + x = SET(x, val, size); + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + +static PyObject * +q_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + PY_LONG_LONG val; + PY_LONG_LONG field; + if (get_longlong(value, &val) < 0) + return NULL; + memcpy(&field, ptr, sizeof(field)); + field = SWAP_8(field); + field = (PY_LONG_LONG)SET(field, val, size); + field = SWAP_8(field); + memcpy(ptr, &field, sizeof(field)); + _RET(value); +} + +static PyObject * +q_get(void *ptr, Py_ssize_t size) +{ + PY_LONG_LONG val; + memcpy(&val, ptr, sizeof(val)); + GET_BITFIELD(val, size); + return PyLong_FromLongLong(val); +} + +static PyObject * +q_get_sw(void *ptr, Py_ssize_t size) +{ + PY_LONG_LONG val; + memcpy(&val, ptr, sizeof(val)); + val = SWAP_8(val); + GET_BITFIELD(val, size); + return PyLong_FromLongLong(val); +} + +static PyObject * +Q_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned PY_LONG_LONG val; + unsigned PY_LONG_LONG x; + if (get_ulonglong(value, &val) < 0) + return NULL; + memcpy(&x, ptr, sizeof(x)); + x = SET(x, val, size); + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + +static PyObject * +Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + unsigned PY_LONG_LONG val; + unsigned PY_LONG_LONG field; + if (get_ulonglong(value, &val) < 0) + return NULL; + memcpy(&field, ptr, sizeof(field)); + field = SWAP_8(field); + field = (unsigned PY_LONG_LONG)SET(field, val, size); + field = SWAP_8(field); + memcpy(ptr, &field, sizeof(field)); + _RET(value); +} + +static PyObject * +Q_get(void *ptr, Py_ssize_t size) +{ + unsigned PY_LONG_LONG val; + memcpy(&val, ptr, sizeof(val)); + GET_BITFIELD(val, size); + return PyLong_FromUnsignedLongLong(val); +} + +static PyObject * +Q_get_sw(void *ptr, Py_ssize_t size) +{ + unsigned PY_LONG_LONG val; + memcpy(&val, ptr, sizeof(val)); + val = SWAP_8(val); + GET_BITFIELD(val, size); + return PyLong_FromUnsignedLongLong(val); +} +#endif + +/***************************************************************** + * non-integer accessor methods, not supporting bit fields + */ + + +static PyObject * +g_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + long double x; + + x = PyFloat_AsDouble(value); + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } + memcpy(ptr, &x, sizeof(long double)); + _RET(value); +} + +static PyObject * +g_get(void *ptr, Py_ssize_t size) +{ + long double val; + memcpy(&val, ptr, sizeof(long double)); + return PyFloat_FromDouble(val); +} + +static PyObject * +d_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + double x; + + x = PyFloat_AsDouble(value); + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } + memcpy(ptr, &x, sizeof(double)); + _RET(value); +} + +static PyObject * +d_get(void *ptr, Py_ssize_t size) +{ + double val; + memcpy(&val, ptr, sizeof(val)); + return PyFloat_FromDouble(val); +} + +static PyObject * +d_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + double x; + + x = PyFloat_AsDouble(value); + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } +#ifdef WORDS_BIGENDIAN + if (_PyFloat_Pack8(x, (unsigned char *)ptr, 1)) + return NULL; +#else + if (_PyFloat_Pack8(x, (unsigned char *)ptr, 0)) + return NULL; +#endif + _RET(value); +} + +static PyObject * +d_get_sw(void *ptr, Py_ssize_t size) +{ +#ifdef WORDS_BIGENDIAN + return PyFloat_FromDouble(_PyFloat_Unpack8(ptr, 1)); +#else + return PyFloat_FromDouble(_PyFloat_Unpack8(ptr, 0)); +#endif +} + +static PyObject * +f_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + float x; + + x = (float)PyFloat_AsDouble(value); + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } + memcpy(ptr, &x, sizeof(x)); + _RET(value); +} + +static PyObject * +f_get(void *ptr, Py_ssize_t size) +{ + float val; + memcpy(&val, ptr, sizeof(val)); + return PyFloat_FromDouble(val); +} + +static PyObject * +f_set_sw(void *ptr, PyObject *value, Py_ssize_t size) +{ + float x; + + x = (float)PyFloat_AsDouble(value); + if (x == -1 && PyErr_Occurred()) { + PyErr_Format(PyExc_TypeError, + " float expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } +#ifdef WORDS_BIGENDIAN + if (_PyFloat_Pack4(x, (unsigned char *)ptr, 1)) + return NULL; +#else + if (_PyFloat_Pack4(x, (unsigned char *)ptr, 0)) + return NULL; +#endif + _RET(value); +} + +static PyObject * +f_get_sw(void *ptr, Py_ssize_t size) +{ +#ifdef WORDS_BIGENDIAN + return PyFloat_FromDouble(_PyFloat_Unpack4(ptr, 1)); +#else + return PyFloat_FromDouble(_PyFloat_Unpack4(ptr, 0)); +#endif +} + +/* + py_object refcounts: + + 1. If we have a py_object instance, O_get must Py_INCREF the returned + object, of course. If O_get is called from a function result, no py_object + instance is created - so callproc.c::GetResult has to call Py_DECREF. + + 2. The memory block in py_object owns a refcount. So, py_object must call + Py_DECREF on destruction. Maybe only when b_needsfree is non-zero. +*/ +static PyObject * +O_get(void *ptr, Py_ssize_t size) +{ + PyObject *ob = *(PyObject **)ptr; + if (ob == NULL) { + if (!PyErr_Occurred()) + /* Set an error if not yet set */ + PyErr_SetString(PyExc_ValueError, + "PyObject is NULL"); + return NULL; + } + Py_INCREF(ob); + return ob; +} + +static PyObject * +O_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + /* Hm, does the memory block need it's own refcount or not? */ + *(PyObject **)ptr = value; + Py_INCREF(value); + return value; +} + + +static PyObject * +c_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + if (!PyString_Check(value) || (1 != PyString_Size(value))) { + PyErr_Format(PyExc_TypeError, + "one character string expected"); + return NULL; + } + *(char *)ptr = PyString_AS_STRING(value)[0]; + _RET(value); +} + + +static PyObject * +c_get(void *ptr, Py_ssize_t size) +{ + return PyString_FromStringAndSize((char *)ptr, 1); +} + +#ifdef CTYPES_UNICODE +/* u - a single wchar_t character */ +static PyObject * +u_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + Py_ssize_t len; + + if (PyString_Check(value)) { + value = PyUnicode_FromEncodedObject(value, + _ctypes_conversion_encoding, + _ctypes_conversion_errors); + if (!value) + return NULL; + } else if (!PyUnicode_Check(value)) { + PyErr_Format(PyExc_TypeError, + "unicode string expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } else + Py_INCREF(value); + + len = PyUnicode_GET_SIZE(value); + if (len != 1) { + Py_DECREF(value); + PyErr_SetString(PyExc_TypeError, + "one character unicode string expected"); + return NULL; + } + + *(wchar_t *)ptr = PyUnicode_AS_UNICODE(value)[0]; + Py_DECREF(value); + + _RET(value); +} + + +static PyObject * +u_get(void *ptr, Py_ssize_t size) +{ + return PyUnicode_FromWideChar((wchar_t *)ptr, 1); +} + +/* U - a unicode string */ +static PyObject * +U_get(void *ptr, Py_ssize_t size) +{ + PyObject *result; + Py_ssize_t len; + Py_UNICODE *p; + + size /= sizeof(wchar_t); /* we count character units here, not bytes */ + + result = PyUnicode_FromWideChar((wchar_t *)ptr, size); + if (!result) + return NULL; + /* We need 'result' to be able to count the characters with wcslen, + since ptr may not be NUL terminated. If the length is smaller (if + it was actually NUL terminated, we construct a new one and throw + away the result. + */ + /* chop off at the first NUL character, if any. */ + p = PyUnicode_AS_UNICODE(result); + for (len = 0; len < size; ++len) + if (!p[len]) + break; + + if (len < size) { + PyObject *ob = PyUnicode_FromWideChar((wchar_t *)ptr, len); + Py_DECREF(result); + return ob; + } + return result; +} + +static PyObject * +U_set(void *ptr, PyObject *value, Py_ssize_t length) +{ + Py_ssize_t size; + + /* It's easier to calculate in characters than in bytes */ + length /= sizeof(wchar_t); + + if (PyString_Check(value)) { + value = PyUnicode_FromEncodedObject(value, + _ctypes_conversion_encoding, + _ctypes_conversion_errors); + if (!value) + return NULL; + } else if (!PyUnicode_Check(value)) { + PyErr_Format(PyExc_TypeError, + "unicode string expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } else + Py_INCREF(value); + size = PyUnicode_GET_SIZE(value); + if (size > length) { + PyErr_Format(PyExc_ValueError, +#if (PY_VERSION_HEX < 0x02050000) + "string too long (%d, maximum length %d)", +#else + "string too long (%zd, maximum length %zd)", +#endif + size, length); + Py_DECREF(value); + return NULL; + } else if (size < length-1) + /* copy terminating NUL character if there is space */ + size += 1; + PyUnicode_AsWideChar((PyUnicodeObject *)value, (wchar_t *)ptr, size); + return value; +} + +#endif + +static PyObject * +s_get(void *ptr, Py_ssize_t size) +{ + PyObject *result; + size_t slen; + + result = PyString_FromString((char *)ptr); + if (!result) + return NULL; + /* chop off at the first NUL character, if any. + * On error, result will be deallocated and set to NULL. + */ + slen = strlen(PyString_AS_STRING(result)); + size = min(size, (Py_ssize_t)slen); + if (result->ob_refcnt == 1) { + /* shorten the result */ + _PyString_Resize(&result, size); + return result; + } else + /* cannot shorten the result */ + return PyString_FromStringAndSize(ptr, size); +} + +static PyObject * +s_set(void *ptr, PyObject *value, Py_ssize_t length) +{ + char *data; + Py_ssize_t size; + + data = PyString_AsString(value); + if (!data) + return NULL; + size = strlen(data); + if (size < length) { + /* This will copy the leading NUL character + * if there is space for it. + */ + ++size; + } else if (size > length) { + PyErr_Format(PyExc_ValueError, +#if (PY_VERSION_HEX < 0x02050000) + "string too long (%d, maximum length %d)", +#else + "string too long (%zd, maximum length %zd)", +#endif + size, length); + return NULL; + } + /* Also copy the terminating NUL character if there is space */ + memcpy((char *)ptr, data, size); + _RET(value); +} + +static PyObject * +z_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + if (value == Py_None) { + *(char **)ptr = NULL; + Py_INCREF(value); + return value; + } + if (PyString_Check(value)) { + *(char **)ptr = PyString_AS_STRING(value); + Py_INCREF(value); + return value; + } else if (PyUnicode_Check(value)) { + PyObject *str = PyUnicode_AsEncodedString(value, + _ctypes_conversion_encoding, + _ctypes_conversion_errors); + if (str == NULL) + return NULL; + *(char **)ptr = PyString_AS_STRING(str); + return str; + } else if (PyInt_Check(value) || PyLong_Check(value)) { +#if SIZEOF_VOID_P == SIZEOF_LONG_LONG + *(char **)ptr = (char *)PyInt_AsUnsignedLongLongMask(value); +#else + *(char **)ptr = (char *)PyInt_AsUnsignedLongMask(value); +#endif + _RET(value); + } + PyErr_Format(PyExc_TypeError, + "string or integer address expected instead of %s instance", + value->ob_type->tp_name); + return NULL; +} + +static PyObject * +z_get(void *ptr, Py_ssize_t size) +{ + /* XXX What about invalid pointers ??? */ + if (*(void **)ptr) { +#if defined(MS_WIN32) && !defined(_WIN32_WCE) + if (IsBadStringPtrA(*(char **)ptr, -1)) { + PyErr_Format(PyExc_ValueError, + "invalid string pointer %p", + *(char **)ptr); + return NULL; + } +#endif + return PyString_FromString(*(char **)ptr); + } else { + Py_INCREF(Py_None); + return Py_None; + } +} + +#ifdef CTYPES_UNICODE +static PyObject * +Z_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + if (value == Py_None) { + *(wchar_t **)ptr = NULL; + Py_INCREF(value); + return value; + } + if (PyString_Check(value)) { + value = PyUnicode_FromEncodedObject(value, + _ctypes_conversion_encoding, + _ctypes_conversion_errors); + if (!value) + return NULL; + } else if (PyInt_Check(value) || PyLong_Check(value)) { +#if SIZEOF_VOID_P == SIZEOF_LONG_LONG + *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongLongMask(value); +#else + *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongMask(value); +#endif + Py_INCREF(Py_None); + return Py_None; + } else if (!PyUnicode_Check(value)) { + PyErr_Format(PyExc_TypeError, + "unicode string or integer address expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } else + Py_INCREF(value); +#ifdef HAVE_USABLE_WCHAR_T + /* HAVE_USABLE_WCHAR_T means that Py_UNICODE and wchar_t is the same + type. So we can copy directly. Hm, are unicode objects always NUL + terminated in Python, internally? + */ + *(wchar_t **)ptr = PyUnicode_AS_UNICODE(value); + return value; +#else + { + /* We must create a wchar_t* buffer from the unicode object, + and keep it alive */ + PyObject *keep; + wchar_t *buffer; + + int size = PyUnicode_GET_SIZE(value); + size += 1; /* terminating NUL */ + size *= sizeof(wchar_t); + buffer = (wchar_t *)PyMem_Malloc(size); + if (!buffer) { + Py_DECREF(value); + return PyErr_NoMemory(); + } + memset(buffer, 0, size); + keep = CAPSULE_NEW(buffer, CTYPES_CAPSULE_WCHAR_T); + if (!keep) { + Py_DECREF(value); + PyMem_Free(buffer); + return NULL; + } + *(wchar_t **)ptr = (wchar_t *)buffer; + if (-1 == PyUnicode_AsWideChar((PyUnicodeObject *)value, + buffer, PyUnicode_GET_SIZE(value))) { + Py_DECREF(value); + Py_DECREF(keep); + return NULL; + } + Py_DECREF(value); + return keep; + } +#endif +} + +static PyObject * +Z_get(void *ptr, Py_ssize_t size) +{ + wchar_t *p; + p = *(wchar_t **)ptr; + if (p) { +#if defined(MS_WIN32) && !defined(_WIN32_WCE) + if (IsBadStringPtrW(*(wchar_t **)ptr, -1)) { + PyErr_Format(PyExc_ValueError, + "invalid string pointer %p", + *(wchar_t **)ptr); + return NULL; + } +#endif + return PyUnicode_FromWideChar(p, wcslen(p)); + } else { + Py_INCREF(Py_None); + return Py_None; + } +} +#endif + +#ifdef MS_WIN32 +static PyObject * +BSTR_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + BSTR bstr; + + /* convert value into a PyUnicodeObject or NULL */ + if (Py_None == value) { + value = NULL; + } else if (PyString_Check(value)) { + value = PyUnicode_FromEncodedObject(value, + _ctypes_conversion_encoding, + _ctypes_conversion_errors); + if (!value) + return NULL; + } else if (PyUnicode_Check(value)) { + Py_INCREF(value); /* for the descref below */ + } else { + PyErr_Format(PyExc_TypeError, + "unicode string expected instead of %s instance", + value->ob_type->tp_name); + return NULL; + } + + /* create a BSTR from value */ + if (value) { + Py_ssize_t size = PyUnicode_GET_SIZE(value); + if ((unsigned) size != size) { + PyErr_SetString(PyExc_ValueError, "String too long for BSTR"); + return NULL; + } + bstr = SysAllocStringLen(PyUnicode_AS_UNICODE(value), + (unsigned)size); + Py_DECREF(value); + } else + bstr = NULL; + + /* free the previous contents, if any */ + if (*(BSTR *)ptr) + SysFreeString(*(BSTR *)ptr); + + /* and store it */ + *(BSTR *)ptr = bstr; + + /* We don't need to keep any other object */ + _RET(value); +} + + +static PyObject * +BSTR_get(void *ptr, Py_ssize_t size) +{ + BSTR p; + p = *(BSTR *)ptr; + if (p) + return PyUnicode_FromWideChar(p, SysStringLen(p)); + else { + /* Hm, it seems NULL pointer and zero length string are the + same in BSTR, see Don Box, p 81 + */ + Py_INCREF(Py_None); + return Py_None; + } +} +#endif + +static PyObject * +P_set(void *ptr, PyObject *value, Py_ssize_t size) +{ + void *v; + if (value == Py_None) { + *(void **)ptr = NULL; + _RET(value); + } + + if (!PyInt_Check(value) && !PyLong_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "cannot be converted to pointer"); + return NULL; + } + +#if SIZEOF_VOID_P <= SIZEOF_LONG + v = (void *)PyInt_AsUnsignedLongMask(value); +#else +#ifndef HAVE_LONG_LONG +# error "PyLong_AsVoidPtr: sizeof(void*) > sizeof(long), but no long long" +#elif SIZEOF_LONG_LONG < SIZEOF_VOID_P +# error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" +#endif + v = (void *)PyInt_AsUnsignedLongLongMask(value); +#endif + + if (PyErr_Occurred()) + return NULL; + + *(void **)ptr = v; + _RET(value); +} + +static PyObject * +P_get(void *ptr, Py_ssize_t size) +{ + if (*(void **)ptr == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + return PyLong_FromVoidPtr(*(void **)ptr); +} + +static struct fielddesc formattable[] = { + { 's', s_set, s_get, &ffi_type_pointer}, + { 'b', b_set, b_get, &ffi_type_schar}, + { 'B', B_set, B_get, &ffi_type_uchar}, + { 'c', c_set, c_get, &ffi_type_schar}, + { 'd', d_set, d_get, &ffi_type_double, d_set_sw, d_get_sw}, + { 'g', g_set, g_get, &ffi_type_longdouble}, + { 'f', f_set, f_get, &ffi_type_float, f_set_sw, f_get_sw}, + { 'h', h_set, h_get, &ffi_type_sshort, h_set_sw, h_get_sw}, + { 'H', H_set, H_get, &ffi_type_ushort, H_set_sw, H_get_sw}, + { 'i', i_set, i_get, &ffi_type_sint, i_set_sw, i_get_sw}, + { 'I', I_set, I_get, &ffi_type_uint, I_set_sw, I_get_sw}, +/* XXX Hm, sizeof(int) == sizeof(long) doesn't hold on every platform */ +/* As soon as we can get rid of the type codes, this is no longer a problem */ +#if SIZEOF_LONG == 4 + { 'l', l_set, l_get, &ffi_type_sint32, l_set_sw, l_get_sw}, + { 'L', L_set, L_get, &ffi_type_uint32, L_set_sw, L_get_sw}, +#elif SIZEOF_LONG == 8 + { 'l', l_set, l_get, &ffi_type_sint64, l_set_sw, l_get_sw}, + { 'L', L_set, L_get, &ffi_type_uint64, L_set_sw, L_get_sw}, +#else +# error +#endif +#ifdef HAVE_LONG_LONG +#if SIZEOF_LONG_LONG == 8 + { 'q', q_set, q_get, &ffi_type_sint64, q_set_sw, q_get_sw}, + { 'Q', Q_set, Q_get, &ffi_type_uint64, Q_set_sw, Q_get_sw}, +#else +# error +#endif +#endif + { 'P', P_set, P_get, &ffi_type_pointer}, + { 'z', z_set, z_get, &ffi_type_pointer}, +#ifdef CTYPES_UNICODE + { 'u', u_set, u_get, NULL}, /* ffi_type set later */ + { 'U', U_set, U_get, &ffi_type_pointer}, + { 'Z', Z_set, Z_get, &ffi_type_pointer}, +#endif +#ifdef MS_WIN32 + { 'X', BSTR_set, BSTR_get, &ffi_type_pointer}, + { 'v', vBOOL_set, vBOOL_get, &ffi_type_sshort}, +#endif +#if SIZEOF__BOOL == 1 + { '?', bool_set, bool_get, &ffi_type_uchar}, /* Also fallback for no native _Bool support */ +#elif SIZEOF__BOOL == SIZEOF_SHORT + { '?', bool_set, bool_get, &ffi_type_ushort}, +#elif SIZEOF__BOOL == SIZEOF_INT + { '?', bool_set, bool_get, &ffi_type_uint, I_set_sw, I_get_sw}, +#elif SIZEOF__BOOL == SIZEOF_LONG + { '?', bool_set, bool_get, &ffi_type_ulong, L_set_sw, L_get_sw}, +#elif SIZEOF__BOOL == SIZEOF_LONG_LONG + { '?', bool_set, bool_get, &ffi_type_ulong, Q_set_sw, Q_get_sw}, +#endif /* SIZEOF__BOOL */ + { 'O', O_set, O_get, &ffi_type_pointer}, + { 0, NULL, NULL, NULL}, +}; + +/* + Ideas: Implement VARIANT in this table, using 'V' code. + Use '?' as code for BOOL. +*/ + +struct fielddesc * +_ctypes_get_fielddesc(char *fmt) +{ + static int initialized = 0; + struct fielddesc *table = formattable; + + if (!initialized) { + initialized = 1; +#ifdef CTYPES_UNICODE + if (sizeof(wchar_t) == sizeof(short)) + _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sshort; + else if (sizeof(wchar_t) == sizeof(int)) + _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sint; + else if (sizeof(wchar_t) == sizeof(long)) + _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_slong; +#endif + } + + for (; table->code; ++table) { + if (table->code == fmt[0]) + return table; + } + return NULL; +} + +typedef struct { char c; char x; } s_char; +typedef struct { char c; short x; } s_short; +typedef struct { char c; int x; } s_int; +typedef struct { char c; long x; } s_long; +typedef struct { char c; float x; } s_float; +typedef struct { char c; double x; } s_double; +typedef struct { char c; long double x; } s_long_double; +typedef struct { char c; char *x; } s_char_p; +typedef struct { char c; void *x; } s_void_p; + +/* +#define CHAR_ALIGN (sizeof(s_char) - sizeof(char)) +#define SHORT_ALIGN (sizeof(s_short) - sizeof(short)) +#define INT_ALIGN (sizeof(s_int) - sizeof(int)) +#define LONG_ALIGN (sizeof(s_long) - sizeof(long)) +*/ +#define FLOAT_ALIGN (sizeof(s_float) - sizeof(float)) +#define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double)) +#define LONGDOUBLE_ALIGN (sizeof(s_long_double) - sizeof(long double)) + +/* #define CHAR_P_ALIGN (sizeof(s_char_p) - sizeof(char*)) */ +#define VOID_P_ALIGN (sizeof(s_void_p) - sizeof(void*)) + +/* +#ifdef HAVE_USABLE_WCHAR_T +typedef struct { char c; wchar_t x; } s_wchar; +typedef struct { char c; wchar_t *x; } s_wchar_p; + +#define WCHAR_ALIGN (sizeof(s_wchar) - sizeof(wchar_t)) +#define WCHAR_P_ALIGN (sizeof(s_wchar_p) - sizeof(wchar_t*)) +#endif +*/ + +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } s_long_long; +#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) +#endif + +/* from ffi.h: +typedef struct _ffi_type +{ + size_t size; + unsigned short alignment; + unsigned short type; + struct _ffi_type **elements; +} ffi_type; +*/ + +/* align and size are bogus for void, but they must not be zero */ + + +#ifdef ffi_type_longdouble +#undef ffi_type_longdouble +#endif + /* This is already defined on OSX */ +ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN, + FFI_TYPE_LONGDOUBLE }; + + +/*---------------- EOF ----------------*/ diff --git a/src/python_files/pyconfig.h b/src/python_files/pyconfig.h new file mode 100644 index 0000000..de3cca2 --- /dev/null +++ b/src/python_files/pyconfig.h @@ -0,0 +1,1248 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.in by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +/* #undef ENABLE_IPV6 */ + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ASM_TYPES_H */ + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the `chflags' function. */ +#define HAVE_CHFLAGS 1 + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +#define HAVE_CONFSTR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +#define HAVE_CTERMID 1 + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define if we have /dev/ptc. */ +/* #undef HAVE_DEV_PTC */ + +/* Define if we have /dev/ptmx. */ +#define HAVE_DEV_PTMX 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +/* #undef HAVE_EPOLL */ + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +/* #undef HAVE_FDATASYNC */ + +/* Define to 1 if you have the `finite' function. */ +/* #undef HAVE_FINITE */ + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +#define HAVE_FORKPTY 1 + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if you have the getaddrinfo function. */ +/* #undef HAVE_GETADDRINFO */ + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +/* #undef HAVE_GETRESGID */ + +/* Define to 1 if you have the `getresuid' function. */ +/* #undef HAVE_GETRESUID */ + +/* Define to 1 if you have the `getsid' function. */ +#define HAVE_GETSID 1 + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +#define HAVE_GETWD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +#define HAVE_LARGEFILE_SUPPORT 1 + +/* Define to 1 if you have the `lchflags' function. */ +#define HAVE_LCHFLAGS 1 + +/* Define to 1 if you have the `lchmod' function. */ +#define HAVE_LCHMOD 1 + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_NETLINK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mremap' function. */ +/* #undef HAVE_MREMAP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NETPACKET_PACKET_H */ + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +#define HAVE_OPENPTY 1 + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +#define HAVE_PTHREAD_INIT 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +/* #undef HAVE_SEM_TIMEDWAIT */ + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +/* #undef HAVE_SETRESGID */ + +/* Define to 1 if you have the `setresuid' function. */ +/* #undef HAVE_SETRESUID */ + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +#define HAVE_SIGRELSE 1 + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +#define HAVE_SOCKADDR_SA_LEN 1 + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SPAWN_H 1 + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +#define HAVE_STAT_TV_NSEC2 1 + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1 + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_FLAGS 1 + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_GEN 1 + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_EPOLL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_LOCK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +/* #undef MAJOR_IN_SYSMACROS */ + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +#define PY_UNICODE_TYPE unsigned short + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +/* #undef Py_ENABLE_SHARED */ + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 2 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 8 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +/* #undef WITH_DOC_STRINGS */ + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +#define WITH_DYLD 1 + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +/* #undef WITH_PYMALLOC */ + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +/* #undef _POSIX_C_SOURCE */ + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +/* #undef _XOPEN_SOURCE */ + +/* Define to activate Unix95-and-earlier features */ +/* #undef _XOPEN_SOURCE_EXTENDED */ + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ diff --git a/tools/build-python.sh b/tools/build-python.sh index a3fdca5..944f838 100755 --- a/tools/build-python.sh +++ b/tools/build-python.sh @@ -62,6 +62,10 @@ try ./configure CC="$ARM_CC" LD="$ARM_LD" \ --prefix=/python \ --without-doc-strings +# with undefined lookup, checks in configure just failed :( +try cp $KIVYIOSROOT/src/python_files/pyconfig.h pyconfig.h +try cp $KIVYIOSROOT/src/python_files/cfield.c Modules/_ctypes/cfield.c + try make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen \ CROSS_COMPILE_TARGET=yes From 8217ea4a552ce1ba5050abdfcfe207091d672874 Mon Sep 17 00:00:00 2001 From: ivpusic Date: Mon, 26 Aug 2013 20:39:29 +0200 Subject: [PATCH 05/13] fixed ctypes error. Added .patch files for required modifications to get working pyobjus on iOS. --- src/ffi_files/ffi-3.0.13-sysv.S.patch | 137 ++ src/python_files/cfield.c | 1761 ------------------------- src/python_files/pyconfig.h | 1248 ------------------ tools/build-libffi.sh | 4 +- tools/build-pyobjus.sh | 4 +- tools/build-python.sh | 4 +- 6 files changed, 144 insertions(+), 3014 deletions(-) create mode 100644 src/ffi_files/ffi-3.0.13-sysv.S.patch delete mode 100644 src/python_files/cfield.c delete mode 100644 src/python_files/pyconfig.h diff --git a/src/ffi_files/ffi-3.0.13-sysv.S.patch b/src/ffi_files/ffi-3.0.13-sysv.S.patch new file mode 100644 index 0000000..436b03d --- /dev/null +++ b/src/ffi_files/ffi-3.0.13-sysv.S.patch @@ -0,0 +1,137 @@ +--- libffi-3.0.13-old/src/arm/sysv.S 2013-03-16 12:19:39.000000000 +0100 ++++ libffi-3.0.13-new/src/arm/sysv.S 2013-08-26 19:33:28.000000000 +0200 +@@ -109,58 +109,35 @@ + #define UNWIND @ + #endif + ++.syntax unified + + #if defined(__thumb__) && !defined(__THUMB_INTERWORK__) +-.macro ARM_FUNC_START name +- .text +- .align 0 +- .thumb +- .thumb_func +-#ifdef __APPLE__ +- ENTRY($0) ++#define ARM_FUNC_START(name) \ ++ .text; \ ++ .align 4; \ ++ .thumb; \ ++ .thumb_func; \ ++ ENTRY(name); \ ++ bx pc; \ ++ nop; \ ++ .arm; \ ++ UNWIND .fnstart; \ ++_L__##name: + #else +- ENTRY(\name) +-#endif +- bx pc +- nop +- .arm +- UNWIND .fnstart +-/* A hook to tell gdb that we've switched to ARM mode. Also used to call +- directly from other local arm routines. */ +-#ifdef __APPLE__ +-_L__$0: +-#else +-_L__\name: +-#endif +-.endm +-#else +-.macro ARM_FUNC_START name +- .text +- .align 0 +- .arm +-#ifdef __APPLE__ +- ENTRY($0) +-#else +- ENTRY(\name) +-#endif ++#define ARM_FUNC_START(name) \ ++ .text; \ ++ .align 4; \ ++ .arm; \ ++ ENTRY(name); \ + UNWIND .fnstart +-.endm + #endif + +-.macro RETLDM regs=, cond=, dirn=ia ++.macro RETLDM + #if defined (__INTERWORKING__) +- .ifc "\regs","" +- ldr\cond lr, [sp], #4 +- .else +- ldm\cond\dirn sp!, {\regs, lr} +- .endif +- bx\cond lr ++ ldr lr, [sp], #4 ++ bx lr + #else +- .ifc "\regs","" +- ldr\cond pc, [sp], #4 +- .else +- ldm\cond\dirn sp!, {\regs, pc} +- .endif ++ ldr pc, [sp], #4 + #endif + .endm + +@@ -170,8 +147,7 @@ + @ r3: fig->flags + @ sp+0: ecif.rvalue + +- @ This assumes we are using gas. +-ARM_FUNC_START ffi_call_SYSV ++ARM_FUNC_START(ffi_call_SYSV) + @ Save registers + stmfd sp!, {r0-r3, fp, lr} + UNWIND .save {r0-r3, fp, lr} +@@ -228,7 +204,7 @@ + #if defined(__SOFTFP__) || defined(__ARM_EABI__) + cmpne r3, #FFI_TYPE_DOUBLE + #endif +- stmeqia r2, {r0, r1} ++ stmiaeq r2, {r0, r1} + + #if !defined(__SOFTFP__) && !defined(__ARM_EABI__) + beq LSYM(Lepilogue) +@@ -266,7 +242,7 @@ + void *args; + */ + +-ARM_FUNC_START ffi_closure_SYSV ++ARM_FUNC_START(ffi_closure_SYSV) + UNWIND .pad #16 + add ip, sp, #16 + stmfd sp!, {ip, lr} +@@ -345,7 +321,7 @@ + @ r3: fig->flags + @ sp+0: ecif.rvalue + +-ARM_FUNC_START ffi_call_VFP ++ARM_FUNC_START(ffi_call_VFP) + @ Save registers + stmfd sp!, {r0-r3, fp, lr} + UNWIND .save {r0-r3, fp, lr} +@@ -410,7 +386,7 @@ + beq LSYM(Lepilogue_vfp) + + cmp r3, #FFI_TYPE_SINT64 +- stmeqia r2, {r0, r1} ++ stmiaeq r2, {r0, r1} + beq LSYM(Lepilogue_vfp) + + cmp r3, #FFI_TYPE_FLOAT +@@ -433,7 +409,7 @@ + .size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP) + + +-ARM_FUNC_START ffi_closure_VFP ++ARM_FUNC_START(ffi_closure_VFP) + fstmfdd sp!, {d0-d7} + @ r0-r3, then d0-d7 + UNWIND .pad #80 diff --git a/src/python_files/cfield.c b/src/python_files/cfield.c deleted file mode 100644 index e5c0a94..0000000 --- a/src/python_files/cfield.c +++ /dev/null @@ -1,1761 +0,0 @@ -/***************************************************************** - This file should be kept compatible with Python 2.3, see PEP 291. - *****************************************************************/ - -#include "Python.h" - -#include -#ifdef MS_WIN32 -#include -#endif -#include "ctypes.h" - - -#define CTYPES_CAPSULE_WCHAR_T "_ctypes/cfield.c wchar_t buffer from unicode" -CTYPES_CAPSULE_INSTANTIATE_DESTRUCTOR(CTYPES_CAPSULE_WCHAR_T) - - -/******************************************************************/ -/* - PyCField_Type -*/ -static PyObject * -PyCField_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - CFieldObject *obj; - obj = (CFieldObject *)type->tp_alloc(type, 0); - return (PyObject *)obj; -} - -/* - * Expects the size, index and offset for the current field in *psize and - * *poffset, stores the total size so far in *psize, the offset for the next - * field in *poffset, the alignment requirements for the current field in - * *palign, and returns a field desriptor for this field. - */ -/* - * bitfields extension: - * bitsize != 0: this is a bit field. - * pbitofs points to the current bit offset, this will be updated. - * prev_desc points to the type of the previous bitfield, if any. - */ -PyObject * -PyCField_FromDesc(PyObject *desc, Py_ssize_t index, - Py_ssize_t *pfield_size, int bitsize, int *pbitofs, - Py_ssize_t *psize, Py_ssize_t *poffset, Py_ssize_t *palign, - int pack, int big_endian) -{ - CFieldObject *self; - PyObject *proto; - Py_ssize_t size, align, length; - SETFUNC setfunc = NULL; - GETFUNC getfunc = NULL; - StgDictObject *dict; - int fieldtype; -#define NO_BITFIELD 0 -#define NEW_BITFIELD 1 -#define CONT_BITFIELD 2 -#define EXPAND_BITFIELD 3 - - self = (CFieldObject *)PyObject_CallObject((PyObject *)&PyCField_Type, - NULL); - if (self == NULL) - return NULL; - dict = PyType_stgdict(desc); - if (!dict) { - PyErr_SetString(PyExc_TypeError, - "has no _stginfo_"); - Py_DECREF(self); - return NULL; - } - if (bitsize /* this is a bitfield request */ - && *pfield_size /* we have a bitfield open */ -#ifdef MS_WIN32 - /* MSVC, GCC with -mms-bitfields */ - && dict->size * 8 == *pfield_size -#else - /* GCC */ - && dict->size * 8 <= *pfield_size -#endif - && (*pbitofs + bitsize) <= *pfield_size) { - /* continue bit field */ - fieldtype = CONT_BITFIELD; -#ifndef MS_WIN32 - } else if (bitsize /* this is a bitfield request */ - && *pfield_size /* we have a bitfield open */ - && dict->size * 8 >= *pfield_size - && (*pbitofs + bitsize) <= dict->size * 8) { - /* expand bit field */ - fieldtype = EXPAND_BITFIELD; -#endif - } else if (bitsize) { - /* start new bitfield */ - fieldtype = NEW_BITFIELD; - *pbitofs = 0; - *pfield_size = dict->size * 8; - } else { - /* not a bit field */ - fieldtype = NO_BITFIELD; - *pbitofs = 0; - *pfield_size = 0; - } - - size = dict->size; - length = dict->length; - proto = desc; - - /* Field descriptors for 'c_char * n' are be scpecial cased to - return a Python string instead of an Array object instance... - */ - if (PyCArrayTypeObject_Check(proto)) { - StgDictObject *adict = PyType_stgdict(proto); - StgDictObject *idict; - if (adict && adict->proto) { - idict = PyType_stgdict(adict->proto); - if (!idict) { - PyErr_SetString(PyExc_TypeError, - "has no _stginfo_"); - Py_DECREF(self); - return NULL; - } - if (idict->getfunc == _ctypes_get_fielddesc("c")->getfunc) { - struct fielddesc *fd = _ctypes_get_fielddesc("s"); - getfunc = fd->getfunc; - setfunc = fd->setfunc; - } -#ifdef CTYPES_UNICODE - if (idict->getfunc == _ctypes_get_fielddesc("u")->getfunc) { - struct fielddesc *fd = _ctypes_get_fielddesc("U"); - getfunc = fd->getfunc; - setfunc = fd->setfunc; - } -#endif - } - } - - self->setfunc = setfunc; - self->getfunc = getfunc; - self->index = index; - - Py_INCREF(proto); - self->proto = proto; - - switch (fieldtype) { - case NEW_BITFIELD: - if (big_endian) - self->size = (bitsize << 16) + *pfield_size - *pbitofs - bitsize; - else - self->size = (bitsize << 16) + *pbitofs; - *pbitofs = bitsize; - /* fall through */ - case NO_BITFIELD: - if (pack) - align = min(pack, dict->align); - else - align = dict->align; - if (align && *poffset % align) { - Py_ssize_t delta = align - (*poffset % align); - *psize += delta; - *poffset += delta; - } - - if (bitsize == 0) - self->size = size; - *psize += size; - - self->offset = *poffset; - *poffset += size; - - *palign = align; - break; - - case EXPAND_BITFIELD: - *poffset += dict->size - *pfield_size/8; - *psize += dict->size - *pfield_size/8; - - *pfield_size = dict->size * 8; - - if (big_endian) - self->size = (bitsize << 16) + *pfield_size - *pbitofs - bitsize; - else - self->size = (bitsize << 16) + *pbitofs; - - self->offset = *poffset - size; /* poffset is already updated for the NEXT field */ - *pbitofs += bitsize; - break; - - case CONT_BITFIELD: - if (big_endian) - self->size = (bitsize << 16) + *pfield_size - *pbitofs - bitsize; - else - self->size = (bitsize << 16) + *pbitofs; - - self->offset = *poffset - size; /* poffset is already updated for the NEXT field */ - *pbitofs += bitsize; - break; - } - - return (PyObject *)self; -} - -static int -PyCField_set(CFieldObject *self, PyObject *inst, PyObject *value) -{ - CDataObject *dst; - char *ptr; - assert(CDataObject_Check(inst)); - dst = (CDataObject *)inst; - ptr = dst->b_ptr + self->offset; - if (value == NULL) { - PyErr_SetString(PyExc_TypeError, - "can't delete attribute"); - return -1; - } - return PyCData_set(inst, self->proto, self->setfunc, value, - self->index, self->size, ptr); -} - -static PyObject * -PyCField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type) -{ - CDataObject *src; - if (inst == NULL) { - Py_INCREF(self); - return (PyObject *)self; - } - assert(CDataObject_Check(inst)); - src = (CDataObject *)inst; - return PyCData_get(self->proto, self->getfunc, inst, - self->index, self->size, src->b_ptr + self->offset); -} - -static PyObject * -PyCField_get_offset(PyObject *self, void *data) -{ - return PyInt_FromSsize_t(((CFieldObject *)self)->offset); -} - -static PyObject * -PyCField_get_size(PyObject *self, void *data) -{ - return PyInt_FromSsize_t(((CFieldObject *)self)->size); -} - -static PyGetSetDef PyCField_getset[] = { - { "offset", PyCField_get_offset, NULL, "offset in bytes of this field" }, - { "size", PyCField_get_size, NULL, "size in bytes of this field" }, - { NULL, NULL, NULL, NULL }, -}; - -static int -PyCField_traverse(CFieldObject *self, visitproc visit, void *arg) -{ - Py_VISIT(self->proto); - return 0; -} - -static int -PyCField_clear(CFieldObject *self) -{ - Py_CLEAR(self->proto); - return 0; -} - -static void -PyCField_dealloc(PyObject *self) -{ - PyCField_clear((CFieldObject *)self); - self->ob_type->tp_free((PyObject *)self); -} - -static PyObject * -PyCField_repr(CFieldObject *self) -{ - PyObject *result; - Py_ssize_t bits = self->size >> 16; - Py_ssize_t size = self->size & 0xFFFF; - const char *name; - - name = ((PyTypeObject *)self->proto)->tp_name; - - if (bits) - result = PyString_FromFormat( -#if (PY_VERSION_HEX < 0x02050000) - "", -#else - "", -#endif - name, self->offset, size, bits); - else - result = PyString_FromFormat( -#if (PY_VERSION_HEX < 0x02050000) - "", -#else - "", -#endif - name, self->offset, size); - return result; -} - -PyTypeObject PyCField_Type = { - PyVarObject_HEAD_INIT(NULL, 0) - "_ctypes.CField", /* tp_name */ - sizeof(CFieldObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - PyCField_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - (reprfunc)PyCField_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - "Structure/Union member", /* tp_doc */ - (traverseproc)PyCField_traverse, /* tp_traverse */ - (inquiry)PyCField_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - PyCField_getset, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - (descrgetfunc)PyCField_get, /* tp_descr_get */ - (descrsetfunc)PyCField_set, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyCField_new, /* tp_new */ - 0, /* tp_free */ -}; - - -/******************************************************************/ -/* - Accessor functions -*/ - -/* Derived from Modules/structmodule.c: - Helper routine to get a Python integer and raise the appropriate error - if it isn't one */ - -static int -get_long(PyObject *v, long *p) -{ - long x; - if (PyFloat_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "int expected instead of float"); - return -1; - } - x = PyInt_AsUnsignedLongMask(v); - if (x == -1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -/* Same, but handling unsigned long */ - -static int -get_ulong(PyObject *v, unsigned long *p) -{ - unsigned long x; - if (PyFloat_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "int expected instead of float"); - return -1; - } - x = PyInt_AsUnsignedLongMask(v); - if (x == (unsigned long)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -#ifdef HAVE_LONG_LONG - -/* Same, but handling native long long. */ - -static int -get_longlong(PyObject *v, PY_LONG_LONG *p) -{ - PY_LONG_LONG x; - if (PyFloat_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "int expected instead of float"); - return -1; - } - x = PyInt_AsUnsignedLongLongMask(v); - if (x == -1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -/* Same, but handling native unsigned long long. */ - -static int -get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) -{ - unsigned PY_LONG_LONG x; - if (PyFloat_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "int expected instead of float"); - return -1; - } - x = PyInt_AsUnsignedLongLongMask(v); - if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred()) - return -1; - *p = x; - return 0; -} - -#endif - -/***************************************************************** - * Integer fields, with bitfield support - */ - -/* how to decode the size field, for integer get/set functions */ -#define LOW_BIT(x) ((x) & 0xFFFF) -#define NUM_BITS(x) ((x) >> 16) - -/* This seems nore a compiler issue than a Windows/non-Windows one */ -#ifdef MS_WIN32 -# define BIT_MASK(size) ((1 << NUM_BITS(size))-1) -#else -# define BIT_MASK(size) ((1LL << NUM_BITS(size))-1) -#endif - -/* This macro CHANGES the first parameter IN PLACE. For proper sign handling, - we must first shift left, then right. -*/ -#define GET_BITFIELD(v, size) \ - if (NUM_BITS(size)) { \ - v <<= (sizeof(v)*8 - LOW_BIT(size) - NUM_BITS(size)); \ - v >>= (sizeof(v)*8 - NUM_BITS(size)); \ - } - -/* This macro RETURNS the first parameter with the bit field CHANGED. */ -#define SET(x, v, size) \ - (NUM_BITS(size) ? \ - ( ( x & ~(BIT_MASK(size) << LOW_BIT(size)) ) | ( (v & BIT_MASK(size)) << LOW_BIT(size) ) ) \ - : v) - -/* byte swapping macros */ -#define SWAP_2(v) \ - ( ( (v >> 8) & 0x00FF) | \ - ( (v << 8) & 0xFF00) ) - -#define SWAP_4(v) \ - ( ( (v & 0x000000FF) << 24 ) | \ - ( (v & 0x0000FF00) << 8 ) | \ - ( (v & 0x00FF0000) >> 8 ) | \ - ( ((v >> 24) & 0xFF)) ) - -#ifdef _MSC_VER -#define SWAP_8(v) \ - ( ( (v & 0x00000000000000FFL) << 56 ) | \ - ( (v & 0x000000000000FF00L) << 40 ) | \ - ( (v & 0x0000000000FF0000L) << 24 ) | \ - ( (v & 0x00000000FF000000L) << 8 ) | \ - ( (v & 0x000000FF00000000L) >> 8 ) | \ - ( (v & 0x0000FF0000000000L) >> 24 ) | \ - ( (v & 0x00FF000000000000L) >> 40 ) | \ - ( ((v >> 56) & 0xFF)) ) -#else -#define SWAP_8(v) \ - ( ( (v & 0x00000000000000FFLL) << 56 ) | \ - ( (v & 0x000000000000FF00LL) << 40 ) | \ - ( (v & 0x0000000000FF0000LL) << 24 ) | \ - ( (v & 0x00000000FF000000LL) << 8 ) | \ - ( (v & 0x000000FF00000000LL) >> 8 ) | \ - ( (v & 0x0000FF0000000000LL) >> 24 ) | \ - ( (v & 0x00FF000000000000LL) >> 40 ) | \ - ( ((v >> 56) & 0xFF)) ) -#endif - -#define SWAP_INT SWAP_4 - -#if SIZEOF_LONG == 4 -# define SWAP_LONG SWAP_4 -#elif SIZEOF_LONG == 8 -# define SWAP_LONG SWAP_8 -#endif -/***************************************************************** - * The setter methods return an object which must be kept alive, to keep the - * data valid which has been stored in the memory block. The ctypes object - * instance inserts this object into its 'b_objects' list. - * - * For simple Python types like integers or characters, there is nothing that - * has to been kept alive, so Py_None is returned in these cases. But this - * makes inspecting the 'b_objects' list, which is accessible from Python for - * debugging, less useful. - * - * So, defining the _CTYPES_DEBUG_KEEP symbol returns the original value - * instead of Py_None. - */ - -#ifdef _CTYPES_DEBUG_KEEP -#define _RET(x) Py_INCREF(x); return x -#else -#define _RET(X) Py_INCREF(Py_None); return Py_None -#endif - -/***************************************************************** - * integer accessor methods, supporting bit fields - */ - -static PyObject * -b_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - long val; - if (get_long(value, &val) < 0) - return NULL; - *(signed char *)ptr = (signed char)SET(*(signed char *)ptr, (signed char)val, size); - _RET(value); -} - - -static PyObject * -b_get(void *ptr, Py_ssize_t size) -{ - signed char val = *(signed char *)ptr; - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -static PyObject * -B_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned long val; - if (get_ulong(value, &val) < 0) - return NULL; - *(unsigned char *)ptr = (unsigned char)SET(*(unsigned char*)ptr, - (unsigned short)val, size); - _RET(value); -} - - -static PyObject * -B_get(void *ptr, Py_ssize_t size) -{ - unsigned char val = *(unsigned char *)ptr; - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -static PyObject * -h_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - long val; - short x; - if (get_long(value, &val) < 0) - return NULL; - memcpy(&x, ptr, sizeof(x)); - x = SET(x, (short)val, size); - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - - -static PyObject * -h_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - long val; - short field; - if (get_long(value, &val) < 0) - return NULL; - memcpy(&field, ptr, sizeof(field)); - field = SWAP_2(field); - field = SET(field, (short)val, size); - field = SWAP_2(field); - memcpy(ptr, &field, sizeof(field)); - _RET(value); -} - -static PyObject * -h_get(void *ptr, Py_ssize_t size) -{ - short val; - memcpy(&val, ptr, sizeof(val)); - GET_BITFIELD(val, size); - return PyInt_FromLong((long)val); -} - -static PyObject * -h_get_sw(void *ptr, Py_ssize_t size) -{ - short val; - memcpy(&val, ptr, sizeof(val)); - val = SWAP_2(val); - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -static PyObject * -H_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned long val; - unsigned short x; - if (get_ulong(value, &val) < 0) - return NULL; - memcpy(&x, ptr, sizeof(x)); - x = SET(x, (unsigned short)val, size); - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - -static PyObject * -H_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned long val; - unsigned short field; - if (get_ulong(value, &val) < 0) - return NULL; - memcpy(&field, ptr, sizeof(field)); - field = SWAP_2(field); - field = SET(field, (unsigned short)val, size); - field = SWAP_2(field); - memcpy(ptr, &field, sizeof(field)); - _RET(value); -} - - -static PyObject * -H_get(void *ptr, Py_ssize_t size) -{ - unsigned short val; - memcpy(&val, ptr, sizeof(val)); - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -static PyObject * -H_get_sw(void *ptr, Py_ssize_t size) -{ - unsigned short val; - memcpy(&val, ptr, sizeof(val)); - val = SWAP_2(val); - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -static PyObject * -i_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - long val; - int x; - if (get_long(value, &val) < 0) - return NULL; - memcpy(&x, ptr, sizeof(x)); - x = SET(x, (int)val, size); - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - -static PyObject * -i_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - long val; - int field; - if (get_long(value, &val) < 0) - return NULL; - memcpy(&field, ptr, sizeof(field)); - field = SWAP_INT(field); - field = SET(field, (int)val, size); - field = SWAP_INT(field); - memcpy(ptr, &field, sizeof(field)); - _RET(value); -} - - -static PyObject * -i_get(void *ptr, Py_ssize_t size) -{ - int val; - memcpy(&val, ptr, sizeof(val)); - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -static PyObject * -i_get_sw(void *ptr, Py_ssize_t size) -{ - int val; - memcpy(&val, ptr, sizeof(val)); - val = SWAP_INT(val); - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -#ifdef MS_WIN32 -/* short BOOL - VARIANT_BOOL */ -static PyObject * -vBOOL_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - switch (PyObject_IsTrue(value)) { - case -1: - return NULL; - case 0: - *(short int *)ptr = VARIANT_FALSE; - _RET(value); - default: - *(short int *)ptr = VARIANT_TRUE; - _RET(value); - } -} - -static PyObject * -vBOOL_get(void *ptr, Py_ssize_t size) -{ - return PyBool_FromLong((long)*(short int *)ptr); -} -#endif - -#ifdef HAVE_C99_BOOL -#define BOOL_TYPE _Bool -#else -#define BOOL_TYPE char -#undef SIZEOF__BOOL -#define SIZEOF__BOOL 1 -#endif - -static PyObject * -bool_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - switch (PyObject_IsTrue(value)) { - case -1: - return NULL; - case 0: - *(BOOL_TYPE *)ptr = 0; - _RET(value); - default: - *(BOOL_TYPE *)ptr = 1; - _RET(value); - } -} - -static PyObject * -bool_get(void *ptr, Py_ssize_t size) -{ - return PyBool_FromLong((long)*(BOOL_TYPE *)ptr); -} - -static PyObject * -I_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned long val; - unsigned int x; - if (get_ulong(value, &val) < 0) - return NULL; - memcpy(&x, ptr, sizeof(x)); - x = SET(x, (unsigned int)val, size); - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - -static PyObject * -I_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned long val; - unsigned int field; - if (get_ulong(value, &val) < 0) - return NULL; - memcpy(&field, ptr, sizeof(field)); - field = (unsigned int)SET(field, (unsigned int)val, size); - field = SWAP_INT(field); - memcpy(ptr, &field, sizeof(field)); - _RET(value); -} - - -static PyObject * -I_get(void *ptr, Py_ssize_t size) -{ - unsigned int val; - memcpy(&val, ptr, sizeof(val)); - GET_BITFIELD(val, size); - return PyLong_FromUnsignedLong(val); -} - -static PyObject * -I_get_sw(void *ptr, Py_ssize_t size) -{ - unsigned int val; - memcpy(&val, ptr, sizeof(val)); - val = SWAP_INT(val); - GET_BITFIELD(val, size); - return PyLong_FromUnsignedLong(val); -} - -static PyObject * -l_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - long val; - long x; - if (get_long(value, &val) < 0) - return NULL; - memcpy(&x, ptr, sizeof(x)); - x = SET(x, val, size); - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - -static PyObject * -l_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - long val; - long field; - if (get_long(value, &val) < 0) - return NULL; - memcpy(&field, ptr, sizeof(field)); - field = SWAP_LONG(field); - field = (long)SET(field, val, size); - field = SWAP_LONG(field); - memcpy(ptr, &field, sizeof(field)); - _RET(value); -} - - -static PyObject * -l_get(void *ptr, Py_ssize_t size) -{ - long val; - memcpy(&val, ptr, sizeof(val)); - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -static PyObject * -l_get_sw(void *ptr, Py_ssize_t size) -{ - long val; - memcpy(&val, ptr, sizeof(val)); - val = SWAP_LONG(val); - GET_BITFIELD(val, size); - return PyInt_FromLong(val); -} - -static PyObject * -L_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned long val; - unsigned long x; - if (get_ulong(value, &val) < 0) - return NULL; - memcpy(&x, ptr, sizeof(x)); - x = SET(x, val, size); - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - -static PyObject * -L_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned long val; - unsigned long field; - if (get_ulong(value, &val) < 0) - return NULL; - memcpy(&field, ptr, sizeof(field)); - field = SWAP_LONG(field); - field = (unsigned long)SET(field, val, size); - field = SWAP_LONG(field); - memcpy(ptr, &field, sizeof(field)); - _RET(value); -} - - -static PyObject * -L_get(void *ptr, Py_ssize_t size) -{ - unsigned long val; - memcpy(&val, ptr, sizeof(val)); - GET_BITFIELD(val, size); - return PyLong_FromUnsignedLong(val); -} - -static PyObject * -L_get_sw(void *ptr, Py_ssize_t size) -{ - unsigned long val; - memcpy(&val, ptr, sizeof(val)); - val = SWAP_LONG(val); - GET_BITFIELD(val, size); - return PyLong_FromUnsignedLong(val); -} - -#ifdef HAVE_LONG_LONG -static PyObject * -q_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - PY_LONG_LONG val; - PY_LONG_LONG x; - if (get_longlong(value, &val) < 0) - return NULL; - memcpy(&x, ptr, sizeof(x)); - x = SET(x, val, size); - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - -static PyObject * -q_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - PY_LONG_LONG val; - PY_LONG_LONG field; - if (get_longlong(value, &val) < 0) - return NULL; - memcpy(&field, ptr, sizeof(field)); - field = SWAP_8(field); - field = (PY_LONG_LONG)SET(field, val, size); - field = SWAP_8(field); - memcpy(ptr, &field, sizeof(field)); - _RET(value); -} - -static PyObject * -q_get(void *ptr, Py_ssize_t size) -{ - PY_LONG_LONG val; - memcpy(&val, ptr, sizeof(val)); - GET_BITFIELD(val, size); - return PyLong_FromLongLong(val); -} - -static PyObject * -q_get_sw(void *ptr, Py_ssize_t size) -{ - PY_LONG_LONG val; - memcpy(&val, ptr, sizeof(val)); - val = SWAP_8(val); - GET_BITFIELD(val, size); - return PyLong_FromLongLong(val); -} - -static PyObject * -Q_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned PY_LONG_LONG val; - unsigned PY_LONG_LONG x; - if (get_ulonglong(value, &val) < 0) - return NULL; - memcpy(&x, ptr, sizeof(x)); - x = SET(x, val, size); - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - -static PyObject * -Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - unsigned PY_LONG_LONG val; - unsigned PY_LONG_LONG field; - if (get_ulonglong(value, &val) < 0) - return NULL; - memcpy(&field, ptr, sizeof(field)); - field = SWAP_8(field); - field = (unsigned PY_LONG_LONG)SET(field, val, size); - field = SWAP_8(field); - memcpy(ptr, &field, sizeof(field)); - _RET(value); -} - -static PyObject * -Q_get(void *ptr, Py_ssize_t size) -{ - unsigned PY_LONG_LONG val; - memcpy(&val, ptr, sizeof(val)); - GET_BITFIELD(val, size); - return PyLong_FromUnsignedLongLong(val); -} - -static PyObject * -Q_get_sw(void *ptr, Py_ssize_t size) -{ - unsigned PY_LONG_LONG val; - memcpy(&val, ptr, sizeof(val)); - val = SWAP_8(val); - GET_BITFIELD(val, size); - return PyLong_FromUnsignedLongLong(val); -} -#endif - -/***************************************************************** - * non-integer accessor methods, not supporting bit fields - */ - - -static PyObject * -g_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - long double x; - - x = PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, - " float expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } - memcpy(ptr, &x, sizeof(long double)); - _RET(value); -} - -static PyObject * -g_get(void *ptr, Py_ssize_t size) -{ - long double val; - memcpy(&val, ptr, sizeof(long double)); - return PyFloat_FromDouble(val); -} - -static PyObject * -d_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - double x; - - x = PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, - " float expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } - memcpy(ptr, &x, sizeof(double)); - _RET(value); -} - -static PyObject * -d_get(void *ptr, Py_ssize_t size) -{ - double val; - memcpy(&val, ptr, sizeof(val)); - return PyFloat_FromDouble(val); -} - -static PyObject * -d_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - double x; - - x = PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, - " float expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } -#ifdef WORDS_BIGENDIAN - if (_PyFloat_Pack8(x, (unsigned char *)ptr, 1)) - return NULL; -#else - if (_PyFloat_Pack8(x, (unsigned char *)ptr, 0)) - return NULL; -#endif - _RET(value); -} - -static PyObject * -d_get_sw(void *ptr, Py_ssize_t size) -{ -#ifdef WORDS_BIGENDIAN - return PyFloat_FromDouble(_PyFloat_Unpack8(ptr, 1)); -#else - return PyFloat_FromDouble(_PyFloat_Unpack8(ptr, 0)); -#endif -} - -static PyObject * -f_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - float x; - - x = (float)PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, - " float expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } - memcpy(ptr, &x, sizeof(x)); - _RET(value); -} - -static PyObject * -f_get(void *ptr, Py_ssize_t size) -{ - float val; - memcpy(&val, ptr, sizeof(val)); - return PyFloat_FromDouble(val); -} - -static PyObject * -f_set_sw(void *ptr, PyObject *value, Py_ssize_t size) -{ - float x; - - x = (float)PyFloat_AsDouble(value); - if (x == -1 && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, - " float expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } -#ifdef WORDS_BIGENDIAN - if (_PyFloat_Pack4(x, (unsigned char *)ptr, 1)) - return NULL; -#else - if (_PyFloat_Pack4(x, (unsigned char *)ptr, 0)) - return NULL; -#endif - _RET(value); -} - -static PyObject * -f_get_sw(void *ptr, Py_ssize_t size) -{ -#ifdef WORDS_BIGENDIAN - return PyFloat_FromDouble(_PyFloat_Unpack4(ptr, 1)); -#else - return PyFloat_FromDouble(_PyFloat_Unpack4(ptr, 0)); -#endif -} - -/* - py_object refcounts: - - 1. If we have a py_object instance, O_get must Py_INCREF the returned - object, of course. If O_get is called from a function result, no py_object - instance is created - so callproc.c::GetResult has to call Py_DECREF. - - 2. The memory block in py_object owns a refcount. So, py_object must call - Py_DECREF on destruction. Maybe only when b_needsfree is non-zero. -*/ -static PyObject * -O_get(void *ptr, Py_ssize_t size) -{ - PyObject *ob = *(PyObject **)ptr; - if (ob == NULL) { - if (!PyErr_Occurred()) - /* Set an error if not yet set */ - PyErr_SetString(PyExc_ValueError, - "PyObject is NULL"); - return NULL; - } - Py_INCREF(ob); - return ob; -} - -static PyObject * -O_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - /* Hm, does the memory block need it's own refcount or not? */ - *(PyObject **)ptr = value; - Py_INCREF(value); - return value; -} - - -static PyObject * -c_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - if (!PyString_Check(value) || (1 != PyString_Size(value))) { - PyErr_Format(PyExc_TypeError, - "one character string expected"); - return NULL; - } - *(char *)ptr = PyString_AS_STRING(value)[0]; - _RET(value); -} - - -static PyObject * -c_get(void *ptr, Py_ssize_t size) -{ - return PyString_FromStringAndSize((char *)ptr, 1); -} - -#ifdef CTYPES_UNICODE -/* u - a single wchar_t character */ -static PyObject * -u_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - Py_ssize_t len; - - if (PyString_Check(value)) { - value = PyUnicode_FromEncodedObject(value, - _ctypes_conversion_encoding, - _ctypes_conversion_errors); - if (!value) - return NULL; - } else if (!PyUnicode_Check(value)) { - PyErr_Format(PyExc_TypeError, - "unicode string expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } else - Py_INCREF(value); - - len = PyUnicode_GET_SIZE(value); - if (len != 1) { - Py_DECREF(value); - PyErr_SetString(PyExc_TypeError, - "one character unicode string expected"); - return NULL; - } - - *(wchar_t *)ptr = PyUnicode_AS_UNICODE(value)[0]; - Py_DECREF(value); - - _RET(value); -} - - -static PyObject * -u_get(void *ptr, Py_ssize_t size) -{ - return PyUnicode_FromWideChar((wchar_t *)ptr, 1); -} - -/* U - a unicode string */ -static PyObject * -U_get(void *ptr, Py_ssize_t size) -{ - PyObject *result; - Py_ssize_t len; - Py_UNICODE *p; - - size /= sizeof(wchar_t); /* we count character units here, not bytes */ - - result = PyUnicode_FromWideChar((wchar_t *)ptr, size); - if (!result) - return NULL; - /* We need 'result' to be able to count the characters with wcslen, - since ptr may not be NUL terminated. If the length is smaller (if - it was actually NUL terminated, we construct a new one and throw - away the result. - */ - /* chop off at the first NUL character, if any. */ - p = PyUnicode_AS_UNICODE(result); - for (len = 0; len < size; ++len) - if (!p[len]) - break; - - if (len < size) { - PyObject *ob = PyUnicode_FromWideChar((wchar_t *)ptr, len); - Py_DECREF(result); - return ob; - } - return result; -} - -static PyObject * -U_set(void *ptr, PyObject *value, Py_ssize_t length) -{ - Py_ssize_t size; - - /* It's easier to calculate in characters than in bytes */ - length /= sizeof(wchar_t); - - if (PyString_Check(value)) { - value = PyUnicode_FromEncodedObject(value, - _ctypes_conversion_encoding, - _ctypes_conversion_errors); - if (!value) - return NULL; - } else if (!PyUnicode_Check(value)) { - PyErr_Format(PyExc_TypeError, - "unicode string expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } else - Py_INCREF(value); - size = PyUnicode_GET_SIZE(value); - if (size > length) { - PyErr_Format(PyExc_ValueError, -#if (PY_VERSION_HEX < 0x02050000) - "string too long (%d, maximum length %d)", -#else - "string too long (%zd, maximum length %zd)", -#endif - size, length); - Py_DECREF(value); - return NULL; - } else if (size < length-1) - /* copy terminating NUL character if there is space */ - size += 1; - PyUnicode_AsWideChar((PyUnicodeObject *)value, (wchar_t *)ptr, size); - return value; -} - -#endif - -static PyObject * -s_get(void *ptr, Py_ssize_t size) -{ - PyObject *result; - size_t slen; - - result = PyString_FromString((char *)ptr); - if (!result) - return NULL; - /* chop off at the first NUL character, if any. - * On error, result will be deallocated and set to NULL. - */ - slen = strlen(PyString_AS_STRING(result)); - size = min(size, (Py_ssize_t)slen); - if (result->ob_refcnt == 1) { - /* shorten the result */ - _PyString_Resize(&result, size); - return result; - } else - /* cannot shorten the result */ - return PyString_FromStringAndSize(ptr, size); -} - -static PyObject * -s_set(void *ptr, PyObject *value, Py_ssize_t length) -{ - char *data; - Py_ssize_t size; - - data = PyString_AsString(value); - if (!data) - return NULL; - size = strlen(data); - if (size < length) { - /* This will copy the leading NUL character - * if there is space for it. - */ - ++size; - } else if (size > length) { - PyErr_Format(PyExc_ValueError, -#if (PY_VERSION_HEX < 0x02050000) - "string too long (%d, maximum length %d)", -#else - "string too long (%zd, maximum length %zd)", -#endif - size, length); - return NULL; - } - /* Also copy the terminating NUL character if there is space */ - memcpy((char *)ptr, data, size); - _RET(value); -} - -static PyObject * -z_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - if (value == Py_None) { - *(char **)ptr = NULL; - Py_INCREF(value); - return value; - } - if (PyString_Check(value)) { - *(char **)ptr = PyString_AS_STRING(value); - Py_INCREF(value); - return value; - } else if (PyUnicode_Check(value)) { - PyObject *str = PyUnicode_AsEncodedString(value, - _ctypes_conversion_encoding, - _ctypes_conversion_errors); - if (str == NULL) - return NULL; - *(char **)ptr = PyString_AS_STRING(str); - return str; - } else if (PyInt_Check(value) || PyLong_Check(value)) { -#if SIZEOF_VOID_P == SIZEOF_LONG_LONG - *(char **)ptr = (char *)PyInt_AsUnsignedLongLongMask(value); -#else - *(char **)ptr = (char *)PyInt_AsUnsignedLongMask(value); -#endif - _RET(value); - } - PyErr_Format(PyExc_TypeError, - "string or integer address expected instead of %s instance", - value->ob_type->tp_name); - return NULL; -} - -static PyObject * -z_get(void *ptr, Py_ssize_t size) -{ - /* XXX What about invalid pointers ??? */ - if (*(void **)ptr) { -#if defined(MS_WIN32) && !defined(_WIN32_WCE) - if (IsBadStringPtrA(*(char **)ptr, -1)) { - PyErr_Format(PyExc_ValueError, - "invalid string pointer %p", - *(char **)ptr); - return NULL; - } -#endif - return PyString_FromString(*(char **)ptr); - } else { - Py_INCREF(Py_None); - return Py_None; - } -} - -#ifdef CTYPES_UNICODE -static PyObject * -Z_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - if (value == Py_None) { - *(wchar_t **)ptr = NULL; - Py_INCREF(value); - return value; - } - if (PyString_Check(value)) { - value = PyUnicode_FromEncodedObject(value, - _ctypes_conversion_encoding, - _ctypes_conversion_errors); - if (!value) - return NULL; - } else if (PyInt_Check(value) || PyLong_Check(value)) { -#if SIZEOF_VOID_P == SIZEOF_LONG_LONG - *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongLongMask(value); -#else - *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongMask(value); -#endif - Py_INCREF(Py_None); - return Py_None; - } else if (!PyUnicode_Check(value)) { - PyErr_Format(PyExc_TypeError, - "unicode string or integer address expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } else - Py_INCREF(value); -#ifdef HAVE_USABLE_WCHAR_T - /* HAVE_USABLE_WCHAR_T means that Py_UNICODE and wchar_t is the same - type. So we can copy directly. Hm, are unicode objects always NUL - terminated in Python, internally? - */ - *(wchar_t **)ptr = PyUnicode_AS_UNICODE(value); - return value; -#else - { - /* We must create a wchar_t* buffer from the unicode object, - and keep it alive */ - PyObject *keep; - wchar_t *buffer; - - int size = PyUnicode_GET_SIZE(value); - size += 1; /* terminating NUL */ - size *= sizeof(wchar_t); - buffer = (wchar_t *)PyMem_Malloc(size); - if (!buffer) { - Py_DECREF(value); - return PyErr_NoMemory(); - } - memset(buffer, 0, size); - keep = CAPSULE_NEW(buffer, CTYPES_CAPSULE_WCHAR_T); - if (!keep) { - Py_DECREF(value); - PyMem_Free(buffer); - return NULL; - } - *(wchar_t **)ptr = (wchar_t *)buffer; - if (-1 == PyUnicode_AsWideChar((PyUnicodeObject *)value, - buffer, PyUnicode_GET_SIZE(value))) { - Py_DECREF(value); - Py_DECREF(keep); - return NULL; - } - Py_DECREF(value); - return keep; - } -#endif -} - -static PyObject * -Z_get(void *ptr, Py_ssize_t size) -{ - wchar_t *p; - p = *(wchar_t **)ptr; - if (p) { -#if defined(MS_WIN32) && !defined(_WIN32_WCE) - if (IsBadStringPtrW(*(wchar_t **)ptr, -1)) { - PyErr_Format(PyExc_ValueError, - "invalid string pointer %p", - *(wchar_t **)ptr); - return NULL; - } -#endif - return PyUnicode_FromWideChar(p, wcslen(p)); - } else { - Py_INCREF(Py_None); - return Py_None; - } -} -#endif - -#ifdef MS_WIN32 -static PyObject * -BSTR_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - BSTR bstr; - - /* convert value into a PyUnicodeObject or NULL */ - if (Py_None == value) { - value = NULL; - } else if (PyString_Check(value)) { - value = PyUnicode_FromEncodedObject(value, - _ctypes_conversion_encoding, - _ctypes_conversion_errors); - if (!value) - return NULL; - } else if (PyUnicode_Check(value)) { - Py_INCREF(value); /* for the descref below */ - } else { - PyErr_Format(PyExc_TypeError, - "unicode string expected instead of %s instance", - value->ob_type->tp_name); - return NULL; - } - - /* create a BSTR from value */ - if (value) { - Py_ssize_t size = PyUnicode_GET_SIZE(value); - if ((unsigned) size != size) { - PyErr_SetString(PyExc_ValueError, "String too long for BSTR"); - return NULL; - } - bstr = SysAllocStringLen(PyUnicode_AS_UNICODE(value), - (unsigned)size); - Py_DECREF(value); - } else - bstr = NULL; - - /* free the previous contents, if any */ - if (*(BSTR *)ptr) - SysFreeString(*(BSTR *)ptr); - - /* and store it */ - *(BSTR *)ptr = bstr; - - /* We don't need to keep any other object */ - _RET(value); -} - - -static PyObject * -BSTR_get(void *ptr, Py_ssize_t size) -{ - BSTR p; - p = *(BSTR *)ptr; - if (p) - return PyUnicode_FromWideChar(p, SysStringLen(p)); - else { - /* Hm, it seems NULL pointer and zero length string are the - same in BSTR, see Don Box, p 81 - */ - Py_INCREF(Py_None); - return Py_None; - } -} -#endif - -static PyObject * -P_set(void *ptr, PyObject *value, Py_ssize_t size) -{ - void *v; - if (value == Py_None) { - *(void **)ptr = NULL; - _RET(value); - } - - if (!PyInt_Check(value) && !PyLong_Check(value)) { - PyErr_SetString(PyExc_TypeError, - "cannot be converted to pointer"); - return NULL; - } - -#if SIZEOF_VOID_P <= SIZEOF_LONG - v = (void *)PyInt_AsUnsignedLongMask(value); -#else -#ifndef HAVE_LONG_LONG -# error "PyLong_AsVoidPtr: sizeof(void*) > sizeof(long), but no long long" -#elif SIZEOF_LONG_LONG < SIZEOF_VOID_P -# error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" -#endif - v = (void *)PyInt_AsUnsignedLongLongMask(value); -#endif - - if (PyErr_Occurred()) - return NULL; - - *(void **)ptr = v; - _RET(value); -} - -static PyObject * -P_get(void *ptr, Py_ssize_t size) -{ - if (*(void **)ptr == NULL) { - Py_INCREF(Py_None); - return Py_None; - } - return PyLong_FromVoidPtr(*(void **)ptr); -} - -static struct fielddesc formattable[] = { - { 's', s_set, s_get, &ffi_type_pointer}, - { 'b', b_set, b_get, &ffi_type_schar}, - { 'B', B_set, B_get, &ffi_type_uchar}, - { 'c', c_set, c_get, &ffi_type_schar}, - { 'd', d_set, d_get, &ffi_type_double, d_set_sw, d_get_sw}, - { 'g', g_set, g_get, &ffi_type_longdouble}, - { 'f', f_set, f_get, &ffi_type_float, f_set_sw, f_get_sw}, - { 'h', h_set, h_get, &ffi_type_sshort, h_set_sw, h_get_sw}, - { 'H', H_set, H_get, &ffi_type_ushort, H_set_sw, H_get_sw}, - { 'i', i_set, i_get, &ffi_type_sint, i_set_sw, i_get_sw}, - { 'I', I_set, I_get, &ffi_type_uint, I_set_sw, I_get_sw}, -/* XXX Hm, sizeof(int) == sizeof(long) doesn't hold on every platform */ -/* As soon as we can get rid of the type codes, this is no longer a problem */ -#if SIZEOF_LONG == 4 - { 'l', l_set, l_get, &ffi_type_sint32, l_set_sw, l_get_sw}, - { 'L', L_set, L_get, &ffi_type_uint32, L_set_sw, L_get_sw}, -#elif SIZEOF_LONG == 8 - { 'l', l_set, l_get, &ffi_type_sint64, l_set_sw, l_get_sw}, - { 'L', L_set, L_get, &ffi_type_uint64, L_set_sw, L_get_sw}, -#else -# error -#endif -#ifdef HAVE_LONG_LONG -#if SIZEOF_LONG_LONG == 8 - { 'q', q_set, q_get, &ffi_type_sint64, q_set_sw, q_get_sw}, - { 'Q', Q_set, Q_get, &ffi_type_uint64, Q_set_sw, Q_get_sw}, -#else -# error -#endif -#endif - { 'P', P_set, P_get, &ffi_type_pointer}, - { 'z', z_set, z_get, &ffi_type_pointer}, -#ifdef CTYPES_UNICODE - { 'u', u_set, u_get, NULL}, /* ffi_type set later */ - { 'U', U_set, U_get, &ffi_type_pointer}, - { 'Z', Z_set, Z_get, &ffi_type_pointer}, -#endif -#ifdef MS_WIN32 - { 'X', BSTR_set, BSTR_get, &ffi_type_pointer}, - { 'v', vBOOL_set, vBOOL_get, &ffi_type_sshort}, -#endif -#if SIZEOF__BOOL == 1 - { '?', bool_set, bool_get, &ffi_type_uchar}, /* Also fallback for no native _Bool support */ -#elif SIZEOF__BOOL == SIZEOF_SHORT - { '?', bool_set, bool_get, &ffi_type_ushort}, -#elif SIZEOF__BOOL == SIZEOF_INT - { '?', bool_set, bool_get, &ffi_type_uint, I_set_sw, I_get_sw}, -#elif SIZEOF__BOOL == SIZEOF_LONG - { '?', bool_set, bool_get, &ffi_type_ulong, L_set_sw, L_get_sw}, -#elif SIZEOF__BOOL == SIZEOF_LONG_LONG - { '?', bool_set, bool_get, &ffi_type_ulong, Q_set_sw, Q_get_sw}, -#endif /* SIZEOF__BOOL */ - { 'O', O_set, O_get, &ffi_type_pointer}, - { 0, NULL, NULL, NULL}, -}; - -/* - Ideas: Implement VARIANT in this table, using 'V' code. - Use '?' as code for BOOL. -*/ - -struct fielddesc * -_ctypes_get_fielddesc(char *fmt) -{ - static int initialized = 0; - struct fielddesc *table = formattable; - - if (!initialized) { - initialized = 1; -#ifdef CTYPES_UNICODE - if (sizeof(wchar_t) == sizeof(short)) - _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sshort; - else if (sizeof(wchar_t) == sizeof(int)) - _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_sint; - else if (sizeof(wchar_t) == sizeof(long)) - _ctypes_get_fielddesc("u")->pffi_type = &ffi_type_slong; -#endif - } - - for (; table->code; ++table) { - if (table->code == fmt[0]) - return table; - } - return NULL; -} - -typedef struct { char c; char x; } s_char; -typedef struct { char c; short x; } s_short; -typedef struct { char c; int x; } s_int; -typedef struct { char c; long x; } s_long; -typedef struct { char c; float x; } s_float; -typedef struct { char c; double x; } s_double; -typedef struct { char c; long double x; } s_long_double; -typedef struct { char c; char *x; } s_char_p; -typedef struct { char c; void *x; } s_void_p; - -/* -#define CHAR_ALIGN (sizeof(s_char) - sizeof(char)) -#define SHORT_ALIGN (sizeof(s_short) - sizeof(short)) -#define INT_ALIGN (sizeof(s_int) - sizeof(int)) -#define LONG_ALIGN (sizeof(s_long) - sizeof(long)) -*/ -#define FLOAT_ALIGN (sizeof(s_float) - sizeof(float)) -#define DOUBLE_ALIGN (sizeof(s_double) - sizeof(double)) -#define LONGDOUBLE_ALIGN (sizeof(s_long_double) - sizeof(long double)) - -/* #define CHAR_P_ALIGN (sizeof(s_char_p) - sizeof(char*)) */ -#define VOID_P_ALIGN (sizeof(s_void_p) - sizeof(void*)) - -/* -#ifdef HAVE_USABLE_WCHAR_T -typedef struct { char c; wchar_t x; } s_wchar; -typedef struct { char c; wchar_t *x; } s_wchar_p; - -#define WCHAR_ALIGN (sizeof(s_wchar) - sizeof(wchar_t)) -#define WCHAR_P_ALIGN (sizeof(s_wchar_p) - sizeof(wchar_t*)) -#endif -*/ - -#ifdef HAVE_LONG_LONG -typedef struct { char c; PY_LONG_LONG x; } s_long_long; -#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG)) -#endif - -/* from ffi.h: -typedef struct _ffi_type -{ - size_t size; - unsigned short alignment; - unsigned short type; - struct _ffi_type **elements; -} ffi_type; -*/ - -/* align and size are bogus for void, but they must not be zero */ - - -#ifdef ffi_type_longdouble -#undef ffi_type_longdouble -#endif - /* This is already defined on OSX */ -ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN, - FFI_TYPE_LONGDOUBLE }; - - -/*---------------- EOF ----------------*/ diff --git a/src/python_files/pyconfig.h b/src/python_files/pyconfig.h deleted file mode 100644 index de3cca2..0000000 --- a/src/python_files/pyconfig.h +++ /dev/null @@ -1,1248 +0,0 @@ -/* pyconfig.h. Generated from pyconfig.h.in by configure. */ -/* pyconfig.h.in. Generated from configure.in by autoheader. */ - - -#ifndef Py_PYCONFIG_H -#define Py_PYCONFIG_H - - -/* Define if building universal (internal helper macro) */ -/* #undef AC_APPLE_UNIVERSAL_BUILD */ - -/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want - support for AIX C++ shared extension modules. */ -/* #undef AIX_GENUINE_CPLUSPLUS */ - -/* Define this if you have AtheOS threads. */ -/* #undef ATHEOS_THREADS */ - -/* Define this if you have BeOS threads. */ -/* #undef BEOS_THREADS */ - -/* Define if you have the Mach cthreads package */ -/* #undef C_THREADS */ - -/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM - mixed-endian order (byte order 45670123) */ -/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ - -/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most - significant byte first */ -/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ - -/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the - least significant byte first */ -/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ - -/* Define if --enable-ipv6 is specified */ -/* #undef ENABLE_IPV6 */ - -/* Define if flock needs to be linked with bsd library. */ -/* #undef FLOCK_NEEDS_LIBBSD */ - -/* Define if getpgrp() must be called as getpgrp(0). */ -/* #undef GETPGRP_HAVE_ARG */ - -/* Define if gettimeofday() does not have second (timezone) argument This is - the case on Motorola V4 (R40V4.2) */ -/* #undef GETTIMEOFDAY_NO_TZ */ - -/* Define to 1 if you have the `acosh' function. */ -#define HAVE_ACOSH 1 - -/* struct addrinfo (netdb.h) */ -#define HAVE_ADDRINFO 1 - -/* Define to 1 if you have the `alarm' function. */ -#define HAVE_ALARM 1 - -/* Define this if your time.h defines altzone. */ -/* #undef HAVE_ALTZONE */ - -/* Define to 1 if you have the `asinh' function. */ -#define HAVE_ASINH 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ASM_TYPES_H */ - -/* Define to 1 if you have the `atanh' function. */ -#define HAVE_ATANH 1 - -/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ -/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ - -/* Define to 1 if you have the `bind_textdomain_codeset' function. */ -/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_BLUETOOTH_H */ - -/* Define if nice() returns success/failure instead of the new priority. */ -/* #undef HAVE_BROKEN_NICE */ - -/* Define if the system reports an invalid PIPE_BUF value. */ -/* #undef HAVE_BROKEN_PIPE_BUF */ - -/* Define if poll() sets errno on invalid file descriptors. */ -/* #undef HAVE_BROKEN_POLL */ - -/* Define if the Posix semaphores do not work on your system */ -/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ - -/* Define if pthread_sigmask() does not work on your system. */ -/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ - -/* define to 1 if your sem_getvalue is broken. */ -#define HAVE_BROKEN_SEM_GETVALUE 1 - -/* Define this if you have the type _Bool. */ -#define HAVE_C99_BOOL 1 - -/* Define to 1 if you have the `chflags' function. */ -#define HAVE_CHFLAGS 1 - -/* Define to 1 if you have the `chown' function. */ -#define HAVE_CHOWN 1 - -/* Define if you have the 'chroot' function. */ -#define HAVE_CHROOT 1 - -/* Define to 1 if you have the `clock' function. */ -#define HAVE_CLOCK 1 - -/* Define to 1 if you have the `confstr' function. */ -#define HAVE_CONFSTR 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_CONIO_H */ - -/* Define to 1 if you have the `copysign' function. */ -#define HAVE_COPYSIGN 1 - -/* Define to 1 if you have the `ctermid' function. */ -#define HAVE_CTERMID 1 - -/* Define if you have the 'ctermid_r' function. */ -#define HAVE_CTERMID_R 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_CURSES_H */ - -/* Define if you have the 'is_term_resized' function. */ -/* #undef HAVE_CURSES_IS_TERM_RESIZED */ - -/* Define if you have the 'resizeterm' function. */ -/* #undef HAVE_CURSES_RESIZETERM */ - -/* Define if you have the 'resize_term' function. */ -/* #undef HAVE_CURSES_RESIZE_TERM */ - -/* Define to 1 if you have the declaration of `isfinite', and to 0 if you - don't. */ -#define HAVE_DECL_ISFINITE 1 - -/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. - */ -#define HAVE_DECL_ISINF 1 - -/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. - */ -#define HAVE_DECL_ISNAN 1 - -/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. - */ -/* #undef HAVE_DECL_TZNAME */ - -/* Define to 1 if you have the device macros. */ -#define HAVE_DEVICE_MACROS 1 - -/* Define if we have /dev/ptc. */ -/* #undef HAVE_DEV_PTC */ - -/* Define if we have /dev/ptmx. */ -#define HAVE_DEV_PTMX 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DIRECT_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -#define HAVE_DIRENT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the `dlopen' function. */ -#define HAVE_DLOPEN 1 - -/* Define to 1 if you have the `dup2' function. */ -#define HAVE_DUP2 1 - -/* Defined when any dynamic module loading is enabled. */ -#define HAVE_DYNAMIC_LOADING 1 - -/* Define if you have the 'epoll' functions. */ -/* #undef HAVE_EPOLL */ - -/* Define to 1 if you have the `erf' function. */ -#define HAVE_ERF 1 - -/* Define to 1 if you have the `erfc' function. */ -#define HAVE_ERFC 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define to 1 if you have the `execv' function. */ -#define HAVE_EXECV 1 - -/* Define to 1 if you have the `expm1' function. */ -#define HAVE_EXPM1 1 - -/* Define if you have the 'fchdir' function. */ -#define HAVE_FCHDIR 1 - -/* Define to 1 if you have the `fchmod' function. */ -#define HAVE_FCHMOD 1 - -/* Define to 1 if you have the `fchown' function. */ -#define HAVE_FCHOWN 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define if you have the 'fdatasync' function. */ -/* #undef HAVE_FDATASYNC */ - -/* Define to 1 if you have the `finite' function. */ -/* #undef HAVE_FINITE */ - -/* Define to 1 if you have the `flock' function. */ -#define HAVE_FLOCK 1 - -/* Define to 1 if you have the `fork' function. */ -#define HAVE_FORK 1 - -/* Define to 1 if you have the `forkpty' function. */ -#define HAVE_FORKPTY 1 - -/* Define to 1 if you have the `fpathconf' function. */ -#define HAVE_FPATHCONF 1 - -/* Define to 1 if you have the `fseek64' function. */ -/* #undef HAVE_FSEEK64 */ - -/* Define to 1 if you have the `fseeko' function. */ -#define HAVE_FSEEKO 1 - -/* Define to 1 if you have the `fstatvfs' function. */ -#define HAVE_FSTATVFS 1 - -/* Define if you have the 'fsync' function. */ -#define HAVE_FSYNC 1 - -/* Define to 1 if you have the `ftell64' function. */ -/* #undef HAVE_FTELL64 */ - -/* Define to 1 if you have the `ftello' function. */ -#define HAVE_FTELLO 1 - -/* Define to 1 if you have the `ftime' function. */ -#define HAVE_FTIME 1 - -/* Define to 1 if you have the `ftruncate' function. */ -#define HAVE_FTRUNCATE 1 - -/* Define to 1 if you have the `gai_strerror' function. */ -#define HAVE_GAI_STRERROR 1 - -/* Define to 1 if you have the `gamma' function. */ -/* #undef HAVE_GAMMA */ - -/* Define if we can use gcc inline assembler to get and set x87 control word - */ -/* #undef HAVE_GCC_ASM_FOR_X87 */ - -/* Define if you have the getaddrinfo function. */ -/* #undef HAVE_GETADDRINFO */ - -/* Define to 1 if you have the `getcwd' function. */ -#define HAVE_GETCWD 1 - -/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ -#define HAVE_GETC_UNLOCKED 1 - -/* Define to 1 if you have the `getgroups' function. */ -#define HAVE_GETGROUPS 1 - -/* Define to 1 if you have the `gethostbyname' function. */ -#define HAVE_GETHOSTBYNAME 1 - -/* Define this if you have some version of gethostbyname_r() */ -/* #undef HAVE_GETHOSTBYNAME_R */ - -/* Define this if you have the 3-arg version of gethostbyname_r(). */ -/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ - -/* Define this if you have the 5-arg version of gethostbyname_r(). */ -/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ - -/* Define this if you have the 6-arg version of gethostbyname_r(). */ -/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ - -/* Define to 1 if you have the `getitimer' function. */ -#define HAVE_GETITIMER 1 - -/* Define to 1 if you have the `getloadavg' function. */ -#define HAVE_GETLOADAVG 1 - -/* Define to 1 if you have the `getlogin' function. */ -#define HAVE_GETLOGIN 1 - -/* Define to 1 if you have the `getnameinfo' function. */ -#define HAVE_GETNAMEINFO 1 - -/* Define if you have the 'getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 - -/* Define to 1 if you have the `getpeername' function. */ -#define HAVE_GETPEERNAME 1 - -/* Define to 1 if you have the `getpgid' function. */ -#define HAVE_GETPGID 1 - -/* Define to 1 if you have the `getpgrp' function. */ -#define HAVE_GETPGRP 1 - -/* Define to 1 if you have the `getpid' function. */ -#define HAVE_GETPID 1 - -/* Define to 1 if you have the `getpriority' function. */ -#define HAVE_GETPRIORITY 1 - -/* Define to 1 if you have the `getpwent' function. */ -#define HAVE_GETPWENT 1 - -/* Define to 1 if you have the `getresgid' function. */ -/* #undef HAVE_GETRESGID */ - -/* Define to 1 if you have the `getresuid' function. */ -/* #undef HAVE_GETRESUID */ - -/* Define to 1 if you have the `getsid' function. */ -#define HAVE_GETSID 1 - -/* Define to 1 if you have the `getspent' function. */ -/* #undef HAVE_GETSPENT */ - -/* Define to 1 if you have the `getspnam' function. */ -/* #undef HAVE_GETSPNAM */ - -/* Define to 1 if you have the `gettimeofday' function. */ -#define HAVE_GETTIMEOFDAY 1 - -/* Define to 1 if you have the `getwd' function. */ -#define HAVE_GETWD 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_GRP_H 1 - -/* Define if you have the 'hstrerror' function. */ -#define HAVE_HSTRERROR 1 - -/* Define to 1 if you have the `hypot' function. */ -#define HAVE_HYPOT 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_IEEEFP_H */ - -/* Define if you have the 'inet_aton' function. */ -#define HAVE_INET_ATON 1 - -/* Define if you have the 'inet_pton' function. */ -#define HAVE_INET_PTON 1 - -/* Define to 1 if you have the `initgroups' function. */ -#define HAVE_INITGROUPS 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_IO_H */ - -/* Define to 1 if you have the `kill' function. */ -#define HAVE_KILL 1 - -/* Define to 1 if you have the `killpg' function. */ -#define HAVE_KILLPG 1 - -/* Define if you have the 'kqueue' functions. */ -#define HAVE_KQUEUE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LANGINFO_H 1 - -/* Defined to enable large file support when an off_t is bigger than a long - and long long is available and at least as big as an off_t. You may need to - add some flags for configuration and compilation to enable this mode. (For - Solaris and Linux, the necessary defines are already defined.) */ -#define HAVE_LARGEFILE_SUPPORT 1 - -/* Define to 1 if you have the `lchflags' function. */ -#define HAVE_LCHFLAGS 1 - -/* Define to 1 if you have the `lchmod' function. */ -#define HAVE_LCHMOD 1 - -/* Define to 1 if you have the `lchown' function. */ -#define HAVE_LCHOWN 1 - -/* Define to 1 if you have the `lgamma' function. */ -#define HAVE_LGAMMA 1 - -/* Define to 1 if you have the `dl' library (-ldl). */ -#define HAVE_LIBDL 1 - -/* Define to 1 if you have the `dld' library (-ldld). */ -/* #undef HAVE_LIBDLD */ - -/* Define to 1 if you have the `ieee' library (-lieee). */ -/* #undef HAVE_LIBIEEE */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LIBINTL_H */ - -/* Define if you have the readline library (-lreadline). */ -/* #undef HAVE_LIBREADLINE */ - -/* Define to 1 if you have the `resolv' library (-lresolv). */ -/* #undef HAVE_LIBRESOLV */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LIBUTIL_H */ - -/* Define if you have the 'link' function. */ -#define HAVE_LINK 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_NETLINK_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_LINUX_TIPC_H */ - -/* Define to 1 if you have the `log1p' function. */ -#define HAVE_LOG1P 1 - -/* Define this if you have the type long double. */ -#define HAVE_LONG_DOUBLE 1 - -/* Define this if you have the type long long. */ -#define HAVE_LONG_LONG 1 - -/* Define to 1 if you have the `lstat' function. */ -#define HAVE_LSTAT 1 - -/* Define this if you have the makedev macro. */ -#define HAVE_MAKEDEV 1 - -/* Define to 1 if you have the `memmove' function. */ -#define HAVE_MEMMOVE 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if you have the `mkfifo' function. */ -#define HAVE_MKFIFO 1 - -/* Define to 1 if you have the `mknod' function. */ -#define HAVE_MKNOD 1 - -/* Define to 1 if you have the `mktime' function. */ -#define HAVE_MKTIME 1 - -/* Define to 1 if you have the `mremap' function. */ -/* #undef HAVE_MREMAP */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NCURSES_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -/* #undef HAVE_NDIR_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NETPACKET_PACKET_H */ - -/* Define to 1 if you have the `nice' function. */ -#define HAVE_NICE 1 - -/* Define to 1 if you have the `openpty' function. */ -#define HAVE_OPENPTY 1 - -/* Define if compiling using MacOS X 10.5 SDK or later. */ -/* #undef HAVE_OSX105_SDK */ - -/* Define to 1 if you have the `pathconf' function. */ -#define HAVE_PATHCONF 1 - -/* Define to 1 if you have the `pause' function. */ -#define HAVE_PAUSE 1 - -/* Define to 1 if you have the `plock' function. */ -/* #undef HAVE_PLOCK */ - -/* Define to 1 if you have the `poll' function. */ -#define HAVE_POLL 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_POLL_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_PROCESS_H */ - -/* Define if your compiler supports function prototype */ -#define HAVE_PROTOTYPES 1 - -/* Define if you have GNU PTH threads. */ -/* #undef HAVE_PTH */ - -/* Defined for Solaris 2.6 bug in pthread header. */ -/* #undef HAVE_PTHREAD_DESTRUCTOR */ - -/* Define to 1 if you have the header file. */ -#define HAVE_PTHREAD_H 1 - -/* Define to 1 if you have the `pthread_init' function. */ -#define HAVE_PTHREAD_INIT 1 - -/* Define to 1 if you have the `pthread_sigmask' function. */ -#define HAVE_PTHREAD_SIGMASK 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_PTY_H */ - -/* Define to 1 if you have the `putenv' function. */ -#define HAVE_PUTENV 1 - -/* Define to 1 if you have the `readlink' function. */ -#define HAVE_READLINK 1 - -/* Define to 1 if you have the `realpath' function. */ -#define HAVE_REALPATH 1 - -/* Define if you have readline 2.1 */ -/* #undef HAVE_RL_CALLBACK */ - -/* Define if you can turn off readline's signal handling. */ -/* #undef HAVE_RL_CATCH_SIGNAL */ - -/* Define if you have readline 2.2 */ -/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ - -/* Define if you have readline 4.0 */ -/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ - -/* Define if you have readline 4.2 */ -/* #undef HAVE_RL_COMPLETION_MATCHES */ - -/* Define if you have rl_completion_suppress_append */ -/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ - -/* Define if you have readline 4.0 */ -/* #undef HAVE_RL_PRE_INPUT_HOOK */ - -/* Define to 1 if you have the `round' function. */ -#define HAVE_ROUND 1 - -/* Define to 1 if you have the `select' function. */ -#define HAVE_SELECT 1 - -/* Define to 1 if you have the `sem_getvalue' function. */ -#define HAVE_SEM_GETVALUE 1 - -/* Define to 1 if you have the `sem_open' function. */ -#define HAVE_SEM_OPEN 1 - -/* Define to 1 if you have the `sem_timedwait' function. */ -/* #undef HAVE_SEM_TIMEDWAIT */ - -/* Define to 1 if you have the `sem_unlink' function. */ -#define HAVE_SEM_UNLINK 1 - -/* Define to 1 if you have the `setegid' function. */ -#define HAVE_SETEGID 1 - -/* Define to 1 if you have the `seteuid' function. */ -#define HAVE_SETEUID 1 - -/* Define to 1 if you have the `setgid' function. */ -#define HAVE_SETGID 1 - -/* Define if you have the 'setgroups' function. */ -#define HAVE_SETGROUPS 1 - -/* Define to 1 if you have the `setitimer' function. */ -#define HAVE_SETITIMER 1 - -/* Define to 1 if you have the `setlocale' function. */ -#define HAVE_SETLOCALE 1 - -/* Define to 1 if you have the `setpgid' function. */ -#define HAVE_SETPGID 1 - -/* Define to 1 if you have the `setpgrp' function. */ -#define HAVE_SETPGRP 1 - -/* Define to 1 if you have the `setregid' function. */ -#define HAVE_SETREGID 1 - -/* Define to 1 if you have the `setresgid' function. */ -/* #undef HAVE_SETRESGID */ - -/* Define to 1 if you have the `setresuid' function. */ -/* #undef HAVE_SETRESUID */ - -/* Define to 1 if you have the `setreuid' function. */ -#define HAVE_SETREUID 1 - -/* Define to 1 if you have the `setsid' function. */ -#define HAVE_SETSID 1 - -/* Define to 1 if you have the `setuid' function. */ -#define HAVE_SETUID 1 - -/* Define to 1 if you have the `setvbuf' function. */ -#define HAVE_SETVBUF 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SHADOW_H */ - -/* Define to 1 if you have the `sigaction' function. */ -#define HAVE_SIGACTION 1 - -/* Define to 1 if you have the `siginterrupt' function. */ -#define HAVE_SIGINTERRUPT 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SIGNAL_H 1 - -/* Define to 1 if you have the `sigrelse' function. */ -#define HAVE_SIGRELSE 1 - -/* Define to 1 if you have the `snprintf' function. */ -#define HAVE_SNPRINTF 1 - -/* Define if sockaddr has sa_len member */ -#define HAVE_SOCKADDR_SA_LEN 1 - -/* struct sockaddr_storage (sys/socket.h) */ -#define HAVE_SOCKADDR_STORAGE 1 - -/* Define if you have the 'socketpair' function. */ -#define HAVE_SOCKETPAIR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SPAWN_H 1 - -/* Define if your compiler provides ssize_t */ -#define HAVE_SSIZE_T 1 - -/* Define to 1 if you have the `statvfs' function. */ -#define HAVE_STATVFS 1 - -/* Define if you have struct stat.st_mtim.tv_nsec */ -/* #undef HAVE_STAT_TV_NSEC */ - -/* Define if you have struct stat.st_mtimensec */ -#define HAVE_STAT_TV_NSEC2 1 - -/* Define if your compiler supports variable length function prototypes (e.g. - void fprintf(FILE *, char *, ...);) *and* */ -#define HAVE_STDARG_PROTOTYPES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strdup' function. */ -#define HAVE_STRDUP 1 - -/* Define to 1 if you have the `strftime' function. */ -#define HAVE_STRFTIME 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STROPTS_H */ - -/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ -#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1 - -/* Define to 1 if `st_blksize' is a member of `struct stat'. */ -#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 - -/* Define to 1 if `st_blocks' is a member of `struct stat'. */ -#define HAVE_STRUCT_STAT_ST_BLOCKS 1 - -/* Define to 1 if `st_flags' is a member of `struct stat'. */ -#define HAVE_STRUCT_STAT_ST_FLAGS 1 - -/* Define to 1 if `st_gen' is a member of `struct stat'. */ -#define HAVE_STRUCT_STAT_ST_GEN 1 - -/* Define to 1 if `st_rdev' is a member of `struct stat'. */ -#define HAVE_STRUCT_STAT_ST_RDEV 1 - -/* Define to 1 if `tm_zone' is a member of `struct tm'. */ -#define HAVE_STRUCT_TM_TM_ZONE 1 - -/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use - `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ -#define HAVE_ST_BLOCKS 1 - -/* Define if you have the 'symlink' function. */ -#define HAVE_SYMLINK 1 - -/* Define to 1 if you have the `sysconf' function. */ -#define HAVE_SYSCONF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYSEXITS_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_AUDIOIO_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_BSDTTY_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_EPOLL_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_EVENT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_FILE_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_LOADAVG_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_LOCK_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_MKDEV_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_MODEM_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_POLL_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SELECT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_SOCKET_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STATVFS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_TERMIO_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIMES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_UTSNAME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have the `tcgetpgrp' function. */ -#define HAVE_TCGETPGRP 1 - -/* Define to 1 if you have the `tcsetpgrp' function. */ -#define HAVE_TCSETPGRP 1 - -/* Define to 1 if you have the `tempnam' function. */ -#define HAVE_TEMPNAM 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_TERMIOS_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_TERM_H */ - -/* Define to 1 if you have the `tgamma' function. */ -#define HAVE_TGAMMA 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_THREAD_H */ - -/* Define to 1 if you have the `timegm' function. */ -#define HAVE_TIMEGM 1 - -/* Define to 1 if you have the `times' function. */ -#define HAVE_TIMES 1 - -/* Define to 1 if you have the `tmpfile' function. */ -#define HAVE_TMPFILE 1 - -/* Define to 1 if you have the `tmpnam' function. */ -#define HAVE_TMPNAM 1 - -/* Define to 1 if you have the `tmpnam_r' function. */ -/* #undef HAVE_TMPNAM_R */ - -/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use - `HAVE_STRUCT_TM_TM_ZONE' instead. */ -#define HAVE_TM_ZONE 1 - -/* Define to 1 if you have the `truncate' function. */ -#define HAVE_TRUNCATE 1 - -/* Define to 1 if you don't have `tm_zone' but do have the external array - `tzname'. */ -/* #undef HAVE_TZNAME */ - -/* Define this if you have tcl and TCL_UTF_MAX==6 */ -/* #undef HAVE_UCS4_TCL */ - -/* Define to 1 if the system has the type `uintptr_t'. */ -#define HAVE_UINTPTR_T 1 - -/* Define to 1 if you have the `uname' function. */ -#define HAVE_UNAME 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if you have the `unsetenv' function. */ -#define HAVE_UNSETENV 1 - -/* Define if you have a useable wchar_t type defined in wchar.h; useable means - wchar_t must be an unsigned type with at least 16 bits. (see - Include/unicodeobject.h). */ -/* #undef HAVE_USABLE_WCHAR_T */ - -/* Define to 1 if you have the header file. */ -#define HAVE_UTIL_H 1 - -/* Define to 1 if you have the `utimes' function. */ -#define HAVE_UTIMES 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UTIME_H 1 - -/* Define to 1 if you have the `wait3' function. */ -#define HAVE_WAIT3 1 - -/* Define to 1 if you have the `wait4' function. */ -#define HAVE_WAIT4 1 - -/* Define to 1 if you have the `waitpid' function. */ -#define HAVE_WAITPID 1 - -/* Define if the compiler provides a wchar.h header file. */ -#define HAVE_WCHAR_H 1 - -/* Define to 1 if you have the `wcscoll' function. */ -#define HAVE_WCSCOLL 1 - -/* Define if tzset() actually switches the local timezone in a meaningful way. - */ -/* #undef HAVE_WORKING_TZSET */ - -/* Define if the zlib library has inflateCopy */ -#define HAVE_ZLIB_COPY 1 - -/* Define to 1 if you have the `_getpty' function. */ -/* #undef HAVE__GETPTY */ - -/* Define if you are using Mach cthreads directly under /include */ -/* #undef HURD_C_THREADS */ - -/* Define if you are using Mach cthreads under mach / */ -/* #undef MACH_C_THREADS */ - -/* Define to 1 if `major', `minor', and `makedev' are declared in . - */ -/* #undef MAJOR_IN_MKDEV */ - -/* Define to 1 if `major', `minor', and `makedev' are declared in - . */ -/* #undef MAJOR_IN_SYSMACROS */ - -/* Define if mvwdelch in curses.h is an expression. */ -/* #undef MVWDELCH_IS_EXPRESSION */ - -/* Define to the address where bug reports for this package should be sent. */ -/* #undef PACKAGE_BUGREPORT */ - -/* Define to the full name of this package. */ -/* #undef PACKAGE_NAME */ - -/* Define to the full name and version of this package. */ -/* #undef PACKAGE_STRING */ - -/* Define to the one symbol short name of this package. */ -/* #undef PACKAGE_TARNAME */ - -/* Define to the home page for this package. */ -/* #undef PACKAGE_URL */ - -/* Define to the version of this package. */ -/* #undef PACKAGE_VERSION */ - -/* Define if POSIX semaphores aren't enabled on your system */ -/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ - -/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ -/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ - -/* Define as the preferred size in bits of long digits */ -/* #undef PYLONG_BITS_IN_DIGIT */ - -/* Define to printf format modifier for long long type */ -#define PY_FORMAT_LONG_LONG "ll" - -/* Define to printf format modifier for Py_ssize_t */ -#define PY_FORMAT_SIZE_T "z" - -/* Define as the integral type used for Unicode representation. */ -#define PY_UNICODE_TYPE unsigned short - -/* Define if you want to build an interpreter with many run-time checks. */ -/* #undef Py_DEBUG */ - -/* Defined if Python is built as a shared library. */ -/* #undef Py_ENABLE_SHARED */ - -/* Define as the size of the unicode type. */ -#define Py_UNICODE_SIZE 2 - -/* Define if you want to have a Unicode type. */ -#define Py_USING_UNICODE 1 - -/* assume C89 semantics that RETSIGTYPE is always void */ -#define RETSIGTYPE void - -/* Define if setpgrp() must be called as setpgrp(0, 0). */ -/* #undef SETPGRP_HAVE_ARG */ - -/* Define this to be extension of shared libraries (including the dot!). */ -#define SHLIB_EXT ".so" - -/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ -/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ - -/* The size of `double', as computed by sizeof. */ -#define SIZEOF_DOUBLE 8 - -/* The size of `float', as computed by sizeof. */ -#define SIZEOF_FLOAT 4 - -/* The size of `fpos_t', as computed by sizeof. */ -#define SIZEOF_FPOS_T 8 - -/* The size of `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of `long', as computed by sizeof. */ -#define SIZEOF_LONG 4 - -/* The size of `long double', as computed by sizeof. */ -#define SIZEOF_LONG_DOUBLE 8 - -/* The size of `long long', as computed by sizeof. */ -#define SIZEOF_LONG_LONG 8 - -/* The size of `off_t', as computed by sizeof. */ -#define SIZEOF_OFF_T 8 - -/* The size of `pid_t', as computed by sizeof. */ -#define SIZEOF_PID_T 4 - -/* The size of `pthread_t', as computed by sizeof. */ -#define SIZEOF_PTHREAD_T 4 - -/* The size of `short', as computed by sizeof. */ -#define SIZEOF_SHORT 2 - -/* The size of `size_t', as computed by sizeof. */ -#define SIZEOF_SIZE_T 4 - -/* The size of `time_t', as computed by sizeof. */ -#define SIZEOF_TIME_T 4 - -/* The size of `uintptr_t', as computed by sizeof. */ -#define SIZEOF_UINTPTR_T 4 - -/* The size of `void *', as computed by sizeof. */ -#define SIZEOF_VOID_P 4 - -/* The size of `wchar_t', as computed by sizeof. */ -#define SIZEOF_WCHAR_T 4 - -/* The size of `_Bool', as computed by sizeof. */ -#define SIZEOF__BOOL 1 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define if you can safely include both and - (which you can't on SCO ODT 3.0). */ -#define SYS_SELECT_WITH_SYS_TIME 1 - -/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ -/* #undef TANH_PRESERVES_ZERO_SIGN */ - -/* Define to 1 if you can safely include both and . */ -#define TIME_WITH_SYS_TIME 1 - -/* Define to 1 if your declares `struct tm'. */ -/* #undef TM_IN_SYS_TIME */ - -/* Enable extensions on AIX 3, Interix. */ -#ifndef _ALL_SOURCE -# define _ALL_SOURCE 1 -#endif -/* Enable GNU extensions on systems that have them. */ -#ifndef _GNU_SOURCE -# define _GNU_SOURCE 1 -#endif -/* Enable threading extensions on Solaris. */ -#ifndef _POSIX_PTHREAD_SEMANTICS -# define _POSIX_PTHREAD_SEMANTICS 1 -#endif -/* Enable extensions on HP NonStop. */ -#ifndef _TANDEM_SOURCE -# define _TANDEM_SOURCE 1 -#endif -/* Enable general extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 -#endif - - -/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ -/* #undef USE_TOOLBOX_OBJECT_GLUE */ - -/* Define if a va_list is an array of some kind */ -/* #undef VA_LIST_IS_ARRAY */ - -/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ -/* #undef WANT_SIGFPE_HANDLER */ - -/* Define if you want wctype.h functions to be used instead of the one - supplied by Python itself. (see Include/unicodectype.h). */ -/* #undef WANT_WCTYPE_FUNCTIONS */ - -/* Define if WINDOW in curses.h offers a field _flags. */ -/* #undef WINDOW_HAS_FLAGS */ - -/* Define if you want documentation strings in extension modules */ -/* #undef WITH_DOC_STRINGS */ - -/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic - linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). - Dyld is necessary to support frameworks. */ -#define WITH_DYLD 1 - -/* Define to 1 if libintl is needed for locale functions. */ -/* #undef WITH_LIBINTL */ - -/* Define if you want to produce an OpenStep/Rhapsody framework (shared - library plus accessory files). */ -/* #undef WITH_NEXT_FRAMEWORK */ - -/* Define if you want to compile in Python-specific mallocs */ -/* #undef WITH_PYMALLOC */ - -/* Define if you want to compile in rudimentary thread support */ -#define WITH_THREAD 1 - -/* Define to profile with the Pentium timestamp counter */ -/* #undef WITH_TSC */ - -/* Define if you want pymalloc to be disabled when running under valgrind */ -/* #undef WITH_VALGRIND */ - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* # undef WORDS_BIGENDIAN */ -# endif -#endif - -/* Define if arithmetic is subject to x87-style double rounding issue */ -/* #undef X87_DOUBLE_ROUNDING */ - -/* Define on OpenBSD to activate all library features */ -/* #undef _BSD_SOURCE */ - -/* Define on Irix to enable u_int */ -#define _BSD_TYPES 1 - -/* Define on Darwin to activate all library features */ -#define _DARWIN_C_SOURCE 1 - -/* This must be set to 64 on some systems to enable large file support. */ -#define _FILE_OFFSET_BITS 64 - -/* Define on Linux to activate all library features */ -#define _GNU_SOURCE 1 - -/* This must be defined on some systems to enable large file support. */ -#define _LARGEFILE_SOURCE 1 - -/* Define to 1 if on MINIX. */ -/* #undef _MINIX */ - -/* Define on NetBSD to activate all library features */ -#define _NETBSD_SOURCE 1 - -/* Define _OSF_SOURCE to get the makedev macro. */ -/* #undef _OSF_SOURCE */ - -/* Define to 2 if the system does not provide POSIX.1 features except with - this defined. */ -/* #undef _POSIX_1_SOURCE */ - -/* Define to activate features from IEEE Stds 1003.1-2001 */ -/* #undef _POSIX_C_SOURCE */ - -/* Define to 1 if you need to in order for `stat' and other things to work. */ -/* #undef _POSIX_SOURCE */ - -/* Define if you have POSIX threads, and your system does not define that. */ -/* #undef _POSIX_THREADS */ - -/* Define to force use of thread-safe errno, h_errno, and other functions */ -#define _REENTRANT 1 - -/* Define for Solaris 2.5.1 so the uint32_t typedef from , - , or is not used. If the typedef were allowed, the - #define below would cause a syntax error. */ -/* #undef _UINT32_T */ - -/* Define for Solaris 2.5.1 so the uint64_t typedef from , - , or is not used. If the typedef were allowed, the - #define below would cause a syntax error. */ -/* #undef _UINT64_T */ - -/* Define to the level of X/Open that your system supports */ -/* #undef _XOPEN_SOURCE */ - -/* Define to activate Unix95-and-earlier features */ -/* #undef _XOPEN_SOURCE_EXTENDED */ - -/* Define on FreeBSD to activate all library features */ -#define __BSD_VISIBLE 1 - -/* Define to 1 if type `char' is unsigned and you are not using gcc. */ -#ifndef __CHAR_UNSIGNED__ -/* # undef __CHAR_UNSIGNED__ */ -#endif - -/* Defined on Solaris to see additional function prototypes. */ -#define __EXTENSIONS__ 1 - -/* Define to 'long' if doesn't define. */ -/* #undef clock_t */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef const */ - -/* Define to `int' if doesn't define. */ -/* #undef gid_t */ - -/* Define to the type of a signed integer type of width exactly 32 bits if - such a type exists and the standard includes do not define it. */ -/* #undef int32_t */ - -/* Define to the type of a signed integer type of width exactly 64 bits if - such a type exists and the standard includes do not define it. */ -/* #undef int64_t */ - -/* Define to `int' if does not define. */ -/* #undef mode_t */ - -/* Define to `long int' if does not define. */ -/* #undef off_t */ - -/* Define to `int' if does not define. */ -/* #undef pid_t */ - -/* Define to empty if the keyword does not work. */ -/* #undef signed */ - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* Define to `int' if does not define. */ -/* #undef socklen_t */ - -/* Define to `int' if doesn't define. */ -/* #undef uid_t */ - -/* Define to the type of an unsigned integer type of width exactly 32 bits if - such a type exists and the standard includes do not define it. */ -/* #undef uint32_t */ - -/* Define to the type of an unsigned integer type of width exactly 64 bits if - such a type exists and the standard includes do not define it. */ -/* #undef uint64_t */ - -/* Define to empty if the keyword does not work. */ -/* #undef volatile */ - - -/* Define the macros needed if on a UnixWare 7.x system. */ -#if defined(__USLC__) && defined(__SCO_VERSION__) -#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ -#endif - -#endif /*Py_PYCONFIG_H*/ diff --git a/tools/build-libffi.sh b/tools/build-libffi.sh index 9621af3..04d848d 100755 --- a/tools/build-libffi.sh +++ b/tools/build-libffi.sh @@ -1,5 +1,7 @@ #!/bin/bash +echo "Building libffi =============================" + . $(dirname $0)/environment.sh if [ ! -f $CACHEROOT/libffi-$FFI_VERSION.tar.gz ]; then @@ -17,10 +19,10 @@ fi # lib not found, compile it pushd $TMPROOT/libffi-$FFI_VERSION +try patch -p1 < $KIVYIOSROOT/src/ffi_files/ffi-$FFI_VERSION-sysv.S.patch try xcodebuild -project libffi.xcodeproj -target "libffi iOS" -configuration Release -sdk iphoneos$SDKVER OTHER_CFLAGS="-no-integrated-as" try cp build/Release-iphoneos/libffi.a $BUILDROOT/lib/libffi.a try cp -a build/Release-iphoneos/usr/local/include $BUILDROOT/include/ffi - popd diff --git a/tools/build-pyobjus.sh b/tools/build-pyobjus.sh index 24e0347..bd89275 100755 --- a/tools/build-pyobjus.sh +++ b/tools/build-pyobjus.sh @@ -1,7 +1,8 @@ #!/bin/bash -. $(dirname $0)/environment.sh +echo "Building pyobjus =============================" +. $(dirname $0)/environment.sh if [ ! -d $TMPROOT/pyobjus ] ; then try pushd $TMPROOT @@ -42,6 +43,5 @@ export LDFLAGS="$OLD_LDFLAGS" export LDSHARED="$OLD_LDSHARED" bd=$TMPROOT/pyobjus/build/lib.macosx-*/pyobjus -echo $bd try $KIVYIOSROOT/tools/biglink $BUILDROOT/lib/libpyobjus.a $bd deduplicate $BUILDROOT/lib/libpyobjus.a diff --git a/tools/build-python.sh b/tools/build-python.sh index 944f838..0c22c85 100755 --- a/tools/build-python.sh +++ b/tools/build-python.sh @@ -63,8 +63,8 @@ try ./configure CC="$ARM_CC" LD="$ARM_LD" \ --without-doc-strings # with undefined lookup, checks in configure just failed :( -try cp $KIVYIOSROOT/src/python_files/pyconfig.h pyconfig.h -try cp $KIVYIOSROOT/src/python_files/cfield.c Modules/_ctypes/cfield.c +try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-pyconfig.patch +try patch -p1 < $KIVYIOSROOT/src/python_files/Python-$IOS_PYTHON_VERSION-ctypes_duplicate.patch try make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen \ CROSS_COMPILE_TARGET=yes From 330c1974b6a257882b09d275c3e884981a862817 Mon Sep 17 00:00:00 2001 From: ivpusic Date: Mon, 26 Aug 2013 20:52:24 +0200 Subject: [PATCH 06/13] pyobjus is getting code from ivpusic/master instead of ivpusic/test_on_device branch --- tools/build-pyobjus.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build-pyobjus.sh b/tools/build-pyobjus.sh index bd89275..85c75fb 100755 --- a/tools/build-pyobjus.sh +++ b/tools/build-pyobjus.sh @@ -6,7 +6,7 @@ echo "Building pyobjus =============================" if [ ! -d $TMPROOT/pyobjus ] ; then try pushd $TMPROOT -try git clone -b test_on_device git@github.com:ivpusic/pyobjus.git +try git clone git@github.com:ivpusic/pyobjus.git try popd fi From 612d0925c7564966d3c07803f4f9dc1912f5e5c8 Mon Sep 17 00:00:00 2001 From: ivpusic Date: Mon, 26 Aug 2013 23:22:49 +0200 Subject: [PATCH 07/13] updated template project. Added libffi.a and libpyobjus to link with binaries section --- tools/populate-project.sh | 2 - .../template.xcodeproj/project.pbxproj | 40 +++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/tools/populate-project.sh b/tools/populate-project.sh index 5be3ffb..3199606 100755 --- a/tools/populate-project.sh +++ b/tools/populate-project.sh @@ -35,6 +35,4 @@ echo "-> Remove unused files (pyc, py)" find $YOURAPPDIR -iname '*.py' -exec rm {} \; find $YOURAPPDIR -iname '*.pyc' -exec rm {} \; - echo "-> Source code of $APPNAME updated." - diff --git a/tools/templates/template.xcodeproj/project.pbxproj b/tools/templates/template.xcodeproj/project.pbxproj index cdfabc7..34a4614 100755 --- a/tools/templates/template.xcodeproj/project.pbxproj +++ b/tools/templates/template.xcodeproj/project.pbxproj @@ -15,6 +15,10 @@ 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; + 2C18EF8C17CBD2900041C0E1 /* libffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C18EF8A17CBD2900041C0E1 /* libffi.a */; }; + 2C18EF8D17CBD2900041C0E1 /* libpyobjus.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C18EF8B17CBD2900041C0E1 /* libpyobjus.a */; }; + 596C7514150CFC75003F57D9 /* include in Resources */ = {isa = PBXBuildFile; fileRef = 596C7513150CFC75003F57D9 /* include */; }; + 5983EC97163CB90D00475EFB /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5983EC96163CB90D00475EFB /* libsqlite3.dylib */; }; 598E034D14F80187000D1362 /* libSDL_mixer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 598E034C14F80187000D1362 /* libSDL_mixer.a */; }; 598E035414F80578000D1362 /* libogg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 598E035314F80578000D1362 /* libogg.a */; }; 598E035A14F8177A000D1362 /* libvorbisidec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 598E035914F8177A000D1362 /* libvorbisidec.a */; }; @@ -26,9 +30,7 @@ 59994DAF148E558600863906 /* libpython2.7.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 59994DAA148E558600863906 /* libpython2.7.a */; }; 59994DB0148E558600863906 /* libSDL_ttf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 59994DAB148E558600863906 /* libSDL_ttf.a */; }; 59994DB1148E558600863906 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 59994DAC148E558600863906 /* libSDL2.a */; }; - 5983EC97163CB90D00475EFB /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5983EC96163CB90D00475EFB /* libsqlite3.dylib */; }; 59994DB3148E564400863906 /* lib in Resources */ = {isa = PBXBuildFile; fileRef = 59994DB2148E564400863906 /* lib */; }; - 596C7514150CFC75003F57D9 /* include in Resources */ = {isa = PBXBuildFile; fileRef = 596C7513150CFC75003F57D9 /* include */; }; 59994E3B148E85C800863906 /* YourApp in Resources */ = {isa = PBXBuildFile; fileRef = 59994E3A148E85C800863906 /* YourApp */; }; 59ED7D08150E0C4400A92BEE /* libios.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 59ED7D07150E0C4400A92BEE /* libios.a */; }; 59ED7D0B150E325100A92BEE /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 59ED7D0A150E325100A92BEE /* MessageUI.framework */; }; @@ -40,10 +42,13 @@ 01532DA9137C099F0076F6BF /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = ""; }; 01790B7A137E5ED900E037D1 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 1D6058910D05DD3D006BFB54 /* ##APPNAME##.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ##APPNAME##.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1D6058910D05DD3D006BFB54 /* ##APPID##.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ##APPID##.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 2C18EF8A17CBD2900041C0E1 /* libffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libffi.a; path = ../build/lib/libffi.a; sourceTree = ""; }; + 2C18EF8B17CBD2900041C0E1 /* libpyobjus.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpyobjus.a; path = ../build/lib/libpyobjus.a; sourceTree = ""; }; + 596C7513150CFC75003F57D9 /* include */ = {isa = PBXFileReference; lastKnownFileType = folder; name = include; path = ../build/python/embed/include; sourceTree = ""; }; 5983EC96163CB90D00475EFB /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; 598E034C14F80187000D1362 /* libSDL_mixer.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL_mixer.a; path = ../build/lib/libSDL_mixer.a; sourceTree = ""; }; 598E035314F80578000D1362 /* libogg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libogg.a; path = ../build/lib/libogg.a; sourceTree = ""; }; @@ -58,7 +63,6 @@ 59994DAC148E558600863906 /* libSDL2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL2.a; path = ../build/lib/libSDL2.a; sourceTree = ""; }; 59994DB2148E564400863906 /* lib */ = {isa = PBXFileReference; lastKnownFileType = folder; name = lib; path = ../build/python/lib; sourceTree = SOURCE_ROOT; }; 59994E3A148E85C800863906 /* YourApp */ = {isa = PBXFileReference; lastKnownFileType = folder; path = YourApp; sourceTree = ""; }; - 596C7513150CFC75003F57D9 /* include */ = {isa = PBXFileReference; lastKnownFileType = folder; name = include; path = ../build/python/embed/include; sourceTree = ""; }; 59ED7D07150E0C4400A92BEE /* libios.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libios.a; path = ../build/lib/libios.a; sourceTree = ""; }; 59ED7D0A150E325100A92BEE /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; 8D1107310486CEB800E47090 /* ##APPID##-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "##APPID##-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; @@ -69,6 +73,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 2C18EF8C17CBD2900041C0E1 /* libffi.a in Frameworks */, + 2C18EF8D17CBD2900041C0E1 /* libpyobjus.a in Frameworks */, 5983EC97163CB90D00475EFB /* libsqlite3.dylib in Frameworks */, 59ED7D0B150E325100A92BEE /* MessageUI.framework in Frameworks */, 59ED7D08150E0C4400A92BEE /* libios.a in Frameworks */, @@ -105,7 +111,7 @@ 19C28FACFE9D520D11CA2CBB /* Products */ = { isa = PBXGroup; children = ( - 1D6058910D05DD3D006BFB54 /* ##APPNAME##.app */, + 1D6058910D05DD3D006BFB54 /* ##APPID##.app */, ); name = Products; sourceTree = ""; @@ -145,6 +151,8 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( + 2C18EF8A17CBD2900041C0E1 /* libffi.a */, + 2C18EF8B17CBD2900041C0E1 /* libpyobjus.a */, 5983EC96163CB90D00475EFB /* libsqlite3.dylib */, 59994DA8148E558600863906 /* libfreetype.a */, 59994DA9148E558600863906 /* libkivy.a */, @@ -172,7 +180,7 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 1D6058900D05DD3D006BFB54 /* ##APPNAME## */ = { + 1D6058900D05DD3D006BFB54 /* ##APPID## */ = { isa = PBXNativeTarget; buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "##APPID##" */; buildPhases = ( @@ -187,7 +195,7 @@ ); name = ##APPID##; productName = ##APPID##; - productReference = 1D6058910D05DD3D006BFB54 /* ##APPNAME##.app */; + productReference = 1D6058910D05DD3D006BFB54 /* ##APPID##.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -232,7 +240,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 113D17E2153E3DB5001310A5 /* ShellScript */ = { + 113D17E2153E3DB5001310A5 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 12; files = ( @@ -243,7 +251,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/bash; - shellScript = "../tools/populate-project.sh ##APPNAME## ##SRCDIR## "; + shellScript = "../tools/populate-project.sh ##APPID## /Users/ivan/development/kivy-ios/kivy-test "; }; /* End PBXShellScriptBuildPhase section */ @@ -278,14 +286,14 @@ "\"$(PROJECT_DIR)/../build/python/include\"", ); INFOPLIST_FILE = "##APPID##-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = ##SDKVER##; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(PROJECT_DIR)/../build/lib\"", ); ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-all_load"; - PRODUCT_NAME = ##APPNAME##; + PRODUCT_NAME = ##APPID##; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; @@ -310,13 +318,13 @@ "\"$(PROJECT_DIR)/../build/python/include\"", ); INFOPLIST_FILE = "##APPID##-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = ##SDKVER##; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(PROJECT_DIR)/../build/lib\"", ); OTHER_LDFLAGS = "-all_load"; - PRODUCT_NAME = ##APPNAME##; + PRODUCT_NAME = ##APPID##; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; @@ -339,7 +347,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; - IPHONEOS_DEPLOYMENT_TARGET = ##SDKVER##; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; ONLY_ACTIVE_ARCH = YES; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; @@ -364,7 +372,7 @@ GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = ##SDKVER##; + IPHONEOS_DEPLOYMENT_TARGET = 6.1; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PROVISIONING_PROFILE = ""; @@ -402,4 +410,4 @@ /* End XCConfigurationList section */ }; rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; -} +} \ No newline at end of file From 21efbbe53089e8c0d0f3d51a3960637f3d74f992 Mon Sep 17 00:00:00 2001 From: ivpusic Date: Mon, 26 Aug 2013 23:39:35 +0200 Subject: [PATCH 08/13] added fix for message -> sed: RE error: illegal byte sequence --- tools/create-xcode-project.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/create-xcode-project.sh b/tools/create-xcode-project.sh index 3350e78..be21bfc 100755 --- a/tools/create-xcode-project.sh +++ b/tools/create-xcode-project.sh @@ -11,6 +11,10 @@ SRCDIR=$2 APPID=$(echo $APPNAME | tr '[A-Z]' '[a-z]') TEMPLATESDIR=$(dirname $0)/templates/ APPDIR=$KIVYIOSROOT/app-$APPID +OLD_LC_CTYPE=$LC_CTYPE +# fix for -> sed: RE error: illegal byte sequence +LC_CTYPE=C + if [ "X$APPNAME" == "X" ]; then echo $(basename $0) " " exit 1 @@ -37,6 +41,8 @@ try find $APPDIR -type f -exec sed -i '' "s/##APPNAME##/$APPNAME/g" {} \; try find $APPDIR -type f -exec sed -i '' "s/##SDKVER##/$SDKVER/g" {} \; try find $APPDIR -type f -exec sed -i '' "s^##SRCDIR##^$SRCDIR^g" {} \; +LC_CTYPE=$OLD_LC_CTYPE + echo "-> Done !" echo From aca9a0eab712879f9fd1fb3cf943ff5d0f98e87e Mon Sep 17 00:00:00 2001 From: ivpusic Date: Tue, 27 Aug 2013 00:33:42 +0200 Subject: [PATCH 09/13] added missing patches --- .gitignore | 1 - .../Python-2.7.1-ctypes_duplicate.patch | 34 ++++ src/python_files/Python-2.7.1-pyconfig.patch | 159 ++++++++++++++++++ 3 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 src/python_files/Python-2.7.1-ctypes_duplicate.patch create mode 100644 src/python_files/Python-2.7.1-pyconfig.patch diff --git a/.gitignore b/.gitignore index a6bd48f..2b4957e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.swo *.swp -Python-* freetype-* build/* src/SDL/Xcode-iPhoneOS/SDL/build/ diff --git a/src/python_files/Python-2.7.1-ctypes_duplicate.patch b/src/python_files/Python-2.7.1-ctypes_duplicate.patch new file mode 100644 index 0000000..c895dc5 --- /dev/null +++ b/src/python_files/Python-2.7.1-ctypes_duplicate.patch @@ -0,0 +1,34 @@ +--- Python2.7-old/Modules/_ctypes/cfield.c 2010-05-09 16:46:46.000000000 +0200 ++++ Python2.7-new/Modules/_ctypes/cfield.c 2013-08-27 00:21:15.000000000 +0200 +@@ -1747,24 +1747,6 @@ + } ffi_type; + */ + +-/* align and size are bogus for void, but they must not be zero */ +-ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID }; +- +-ffi_type ffi_type_uint8 = { 1, 1, FFI_TYPE_UINT8 }; +-ffi_type ffi_type_sint8 = { 1, 1, FFI_TYPE_SINT8 }; +- +-ffi_type ffi_type_uint16 = { 2, 2, FFI_TYPE_UINT16 }; +-ffi_type ffi_type_sint16 = { 2, 2, FFI_TYPE_SINT16 }; +- +-ffi_type ffi_type_uint32 = { 4, 4, FFI_TYPE_UINT32 }; +-ffi_type ffi_type_sint32 = { 4, 4, FFI_TYPE_SINT32 }; +- +-ffi_type ffi_type_uint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_UINT64 }; +-ffi_type ffi_type_sint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_SINT64 }; +- +-ffi_type ffi_type_float = { sizeof(float), FLOAT_ALIGN, FFI_TYPE_FLOAT }; +-ffi_type ffi_type_double = { sizeof(double), DOUBLE_ALIGN, FFI_TYPE_DOUBLE }; +- + #ifdef ffi_type_longdouble + #undef ffi_type_longdouble + #endif +@@ -1772,6 +1754,4 @@ + ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN, + FFI_TYPE_LONGDOUBLE }; + +-ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER }; +- + /*---------------- EOF ----------------*/ diff --git a/src/python_files/Python-2.7.1-pyconfig.patch b/src/python_files/Python-2.7.1-pyconfig.patch new file mode 100644 index 0000000..a7fe342 --- /dev/null +++ b/src/python_files/Python-2.7.1-pyconfig.patch @@ -0,0 +1,159 @@ +--- Python2.7-old/pyconfig.h 2013-08-26 19:26:05.000000000 +0200 ++++ Python2.7-new/pyconfig.h 2013-08-27 00:11:06.000000000 +0200 +@@ -72,7 +72,7 @@ + /* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + + /* Define to 1 if you have the `bind_textdomain_codeset' function. */ +-#define HAVE_BIND_TEXTDOMAIN_CODESET 1 ++/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + + /* Define to 1 if you have the header file. */ + /* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ +@@ -218,7 +218,7 @@ + /* #undef HAVE_FDATASYNC */ + + /* Define to 1 if you have the `finite' function. */ +-#define HAVE_FINITE 1 ++/* #undef HAVE_FINITE */ + + /* Define to 1 if you have the `flock' function. */ + #define HAVE_FLOCK 1 +@@ -233,7 +233,7 @@ + #define HAVE_FPATHCONF 1 + + /* Define to 1 if you have the `fseek64' function. */ +-#define HAVE_FSEEK64 1 ++/* #undef HAVE_FSEEK64 */ + + /* Define to 1 if you have the `fseeko' function. */ + #define HAVE_FSEEKO 1 +@@ -245,7 +245,7 @@ + #define HAVE_FSYNC 1 + + /* Define to 1 if you have the `ftell64' function. */ +-#define HAVE_FTELL64 1 ++/* #undef HAVE_FTELL64 */ + + /* Define to 1 if you have the `ftello' function. */ + #define HAVE_FTELLO 1 +@@ -260,7 +260,7 @@ + #define HAVE_GAI_STRERROR 1 + + /* Define to 1 if you have the `gamma' function. */ +-#define HAVE_GAMMA 1 ++/* #undef HAVE_GAMMA */ + + /* Define if we can use gcc inline assembler to get and set x87 control word + */ +@@ -279,10 +279,10 @@ + #define HAVE_GETGROUPS 1 + + /* Define to 1 if you have the `gethostbyname' function. */ +-/* #undef HAVE_GETHOSTBYNAME */ ++#define HAVE_GETHOSTBYNAME 1 + + /* Define this if you have some version of gethostbyname_r() */ +-#define HAVE_GETHOSTBYNAME_R 1 ++/* #undef HAVE_GETHOSTBYNAME_R */ + + /* Define this if you have the 3-arg version of gethostbyname_r(). */ + /* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ +@@ -291,7 +291,7 @@ + /* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + + /* Define this if you have the 6-arg version of gethostbyname_r(). */ +-#define HAVE_GETHOSTBYNAME_R_6_ARG 1 ++/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + + /* Define to 1 if you have the `getitimer' function. */ + #define HAVE_GETITIMER 1 +@@ -327,19 +327,19 @@ + #define HAVE_GETPWENT 1 + + /* Define to 1 if you have the `getresgid' function. */ +-#define HAVE_GETRESGID 1 ++/* #undef HAVE_GETRESGID */ + + /* Define to 1 if you have the `getresuid' function. */ +-#define HAVE_GETRESUID 1 ++/* #undef HAVE_GETRESUID */ + + /* Define to 1 if you have the `getsid' function. */ + #define HAVE_GETSID 1 + + /* Define to 1 if you have the `getspent' function. */ +-#define HAVE_GETSPENT 1 ++/* #undef HAVE_GETSPENT */ + + /* Define to 1 if you have the `getspnam' function. */ +-#define HAVE_GETSPNAM 1 ++/* #undef HAVE_GETSPNAM */ + + /* Define to 1 if you have the `gettimeofday' function. */ + #define HAVE_GETTIMEOFDAY 1 +@@ -465,7 +465,7 @@ + #define HAVE_MKTIME 1 + + /* Define to 1 if you have the `mremap' function. */ +-#define HAVE_MREMAP 1 ++/* #undef HAVE_MREMAP */ + + /* Define to 1 if you have the header file. */ + /* #undef HAVE_NCURSES_H */ +@@ -492,7 +492,7 @@ + #define HAVE_PAUSE 1 + + /* Define to 1 if you have the `plock' function. */ +-#define HAVE_PLOCK 1 ++/* #undef HAVE_PLOCK */ + + /* Define to 1 if you have the `poll' function. */ + #define HAVE_POLL 1 +@@ -567,7 +567,7 @@ + #define HAVE_SEM_OPEN 1 + + /* Define to 1 if you have the `sem_timedwait' function. */ +-#define HAVE_SEM_TIMEDWAIT 1 ++/* #undef HAVE_SEM_TIMEDWAIT */ + + /* Define to 1 if you have the `sem_unlink' function. */ + #define HAVE_SEM_UNLINK 1 +@@ -600,10 +600,10 @@ + #define HAVE_SETREGID 1 + + /* Define to 1 if you have the `setresgid' function. */ +-#define HAVE_SETRESGID 1 ++/* #undef HAVE_SETRESGID */ + + /* Define to 1 if you have the `setresuid' function. */ +-#define HAVE_SETRESUID 1 ++/* #undef HAVE_SETRESUID */ + + /* Define to 1 if you have the `setreuid' function. */ + #define HAVE_SETREUID 1 +@@ -829,7 +829,7 @@ + #define HAVE_TMPNAM 1 + + /* Define to 1 if you have the `tmpnam_r' function. */ +-#define HAVE_TMPNAM_R 1 ++/* #undef HAVE_TMPNAM_R */ + + /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +@@ -894,7 +894,7 @@ + #define HAVE_ZLIB_COPY 1 + + /* Define to 1 if you have the `_getpty' function. */ +-#define HAVE__GETPTY 1 ++/* #undef HAVE__GETPTY */ + + /* Define if you are using Mach cthreads directly under /include */ + /* #undef HURD_C_THREADS */ +@@ -1245,5 +1245,4 @@ + #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ + #endif + +-#endif /*Py_PYCONFIG_H*/ +- ++#endif /*Py_PYCONFIG_H*/ +\ No newline at end of file From 4fae87d527896eb84b67c83c7c7b33dd7f255d1f Mon Sep 17 00:00:00 2001 From: ivpusic Date: Tue, 27 Aug 2013 14:00:29 +0200 Subject: [PATCH 10/13] updated project template --- .../template.xcodeproj/project.pbxproj | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/templates/template.xcodeproj/project.pbxproj b/tools/templates/template.xcodeproj/project.pbxproj index 34a4614..c33c2c4 100755 --- a/tools/templates/template.xcodeproj/project.pbxproj +++ b/tools/templates/template.xcodeproj/project.pbxproj @@ -42,7 +42,7 @@ 01532DA9137C099F0076F6BF /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = ""; }; 01790B7A137E5ED900E037D1 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 1D6058910D05DD3D006BFB54 /* ##APPID##.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ##APPID##.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1D6058910D05DD3D006BFB54 /* ##APPNAME##.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ##APPNAME##.app; sourceTree = BUILT_PRODUCTS_DIR; }; 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 288765FC0DF74451002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -111,7 +111,7 @@ 19C28FACFE9D520D11CA2CBB /* Products */ = { isa = PBXGroup; children = ( - 1D6058910D05DD3D006BFB54 /* ##APPID##.app */, + 1D6058910D05DD3D006BFB54 /* ##APPNAME##.app */, ); name = Products; sourceTree = ""; @@ -180,7 +180,7 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 1D6058900D05DD3D006BFB54 /* ##APPID## */ = { + 1D6058900D05DD3D006BFB54 /* ##APPNAME## */ = { isa = PBXNativeTarget; buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "##APPID##" */; buildPhases = ( @@ -195,7 +195,7 @@ ); name = ##APPID##; productName = ##APPID##; - productReference = 1D6058910D05DD3D006BFB54 /* ##APPID##.app */; + productReference = 1D6058910D05DD3D006BFB54 /* ##APPNAME##.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -251,7 +251,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/bash; - shellScript = "../tools/populate-project.sh ##APPID## /Users/ivan/development/kivy-ios/kivy-test "; + shellScript = "../tools/populate-project.sh ##APPNAME## ##SRCDIR## "; }; /* End PBXShellScriptBuildPhase section */ @@ -286,14 +286,14 @@ "\"$(PROJECT_DIR)/../build/python/include\"", ); INFOPLIST_FILE = "##APPID##-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; + IPHONEOS_DEPLOYMENT_TARGET = ##SDKVER##; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(PROJECT_DIR)/../build/lib\"", ); ONLY_ACTIVE_ARCH = NO; OTHER_LDFLAGS = "-all_load"; - PRODUCT_NAME = ##APPID##; + PRODUCT_NAME = ##APPNAME##; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; @@ -318,13 +318,13 @@ "\"$(PROJECT_DIR)/../build/python/include\"", ); INFOPLIST_FILE = "##APPID##-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; + IPHONEOS_DEPLOYMENT_TARGET = ##SDKVER##; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "\"$(PROJECT_DIR)/../build/lib\"", ); OTHER_LDFLAGS = "-all_load"; - PRODUCT_NAME = ##APPID##; + PRODUCT_NAME = ##APPNAME##; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; SDKROOT = iphoneos; @@ -347,7 +347,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ""; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; + IPHONEOS_DEPLOYMENT_TARGET = ##SDKVER##; ONLY_ACTIVE_ARCH = YES; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; @@ -372,7 +372,7 @@ GCC_VERSION = com.apple.compilers.llvmgcc42; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 6.1; + IPHONEOS_DEPLOYMENT_TARGET = ##SDKVER##; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; PROVISIONING_PROFILE = ""; From 16f0618c0e10c1edec6a255f820c45950fe3989b Mon Sep 17 00:00:00 2001 From: ivpusic Date: Tue, 27 Aug 2013 14:05:56 +0200 Subject: [PATCH 11/13] small fix --- tools/create-xcode-project.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/create-xcode-project.sh b/tools/create-xcode-project.sh index be21bfc..caf81b2 100755 --- a/tools/create-xcode-project.sh +++ b/tools/create-xcode-project.sh @@ -12,8 +12,11 @@ APPID=$(echo $APPNAME | tr '[A-Z]' '[a-z]') TEMPLATESDIR=$(dirname $0)/templates/ APPDIR=$KIVYIOSROOT/app-$APPID OLD_LC_CTYPE=$LC_CTYPE +OLD_LANG=$LANG + # fix for -> sed: RE error: illegal byte sequence -LC_CTYPE=C +LC_CTYPE=C +LANG=C if [ "X$APPNAME" == "X" ]; then echo $(basename $0) " " @@ -42,9 +45,9 @@ try find $APPDIR -type f -exec sed -i '' "s/##SDKVER##/$SDKVER/g" {} \; try find $APPDIR -type f -exec sed -i '' "s^##SRCDIR##^$SRCDIR^g" {} \; LC_CTYPE=$OLD_LC_CTYPE +LANG=$OLD_LANG echo "-> Done !" - echo echo "Your project is available at $APPDIR" echo From 37d718c20f18b24f6c046124df36a64c04046daf Mon Sep 17 00:00:00 2001 From: ivpusic Date: Wed, 28 Aug 2013 04:29:55 +0200 Subject: [PATCH 12/13] removed cythonizing from build-pyobjus. cythonizing is now donne inside setup.py --- tools/build-pyobjus.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/build-pyobjus.sh b/tools/build-pyobjus.sh index 85c75fb..db7c072 100755 --- a/tools/build-pyobjus.sh +++ b/tools/build-pyobjus.sh @@ -24,10 +24,6 @@ export LDSHARED="$KIVYIOSROOT/tools/liblink" rm -rdf iosbuild/ try mkdir iosbuild -try pushd $TMPROOT/pyobjus/pyobjus -find . -name *.pyx -exec $CYTHON {} \; -popd - try $HOSTPYTHON setup.py build_ext try $HOSTPYTHON setup.py install -O2 --root iosbuild From 5df6c725a9ba87819805b5498cbd1d36382ca218 Mon Sep 17 00:00:00 2001 From: ivpusic Date: Wed, 4 Sep 2013 01:53:33 +0200 Subject: [PATCH 13/13] updated project template. Also updated script for building pyobjus. Script now copy bridge.m/h files to templates dir, so they can be included by default as some start template for new projects. It contains code for accelerometer --- tools/build-pyobjus.sh | 5 +++++ tools/create-xcode-project.sh | 2 ++ tools/templates/template.xcodeproj/project.pbxproj | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/tools/build-pyobjus.sh b/tools/build-pyobjus.sh index db7c072..e80a9fc 100755 --- a/tools/build-pyobjus.sh +++ b/tools/build-pyobjus.sh @@ -41,3 +41,8 @@ export LDSHARED="$OLD_LDSHARED" bd=$TMPROOT/pyobjus/build/lib.macosx-*/pyobjus try $KIVYIOSROOT/tools/biglink $BUILDROOT/lib/libpyobjus.a $bd deduplicate $BUILDROOT/lib/libpyobjus.a + +# copy objc bridge class -> it is used for implementing some objc methods, eg. for accelerometer +try cp $TMPROOT/pyobjus/objc_classes/aux/* $KIVYIOSROOT/tools/templates + +echo "Succesufully finished building pyobjus ===================" diff --git a/tools/create-xcode-project.sh b/tools/create-xcode-project.sh index caf81b2..b740155 100755 --- a/tools/create-xcode-project.sh +++ b/tools/create-xcode-project.sh @@ -34,6 +34,8 @@ try mkdir $APPDIR echo "-> Copy templates" try cp $TEMPLATESDIR/main.m $APPDIR/main.m +try cp $TEMPLATESDIR/bridge.h $APPDIR/bridge.h +try cp $TEMPLATESDIR/bridge.m $APPDIR/bridge.m try cp $TEMPLATESDIR/icon.png $APPDIR/icon.png try cp $TEMPLATESDIR/template-Info.plist $APPDIR/$APPID-Info.plist try cp -a $TEMPLATESDIR/template.xcodeproj $APPDIR/$APPID.xcodeproj diff --git a/tools/templates/template.xcodeproj/project.pbxproj b/tools/templates/template.xcodeproj/project.pbxproj index c33c2c4..489c694 100755 --- a/tools/templates/template.xcodeproj/project.pbxproj +++ b/tools/templates/template.xcodeproj/project.pbxproj @@ -17,6 +17,8 @@ 288765FD0DF74451002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; }; 2C18EF8C17CBD2900041C0E1 /* libffi.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C18EF8A17CBD2900041C0E1 /* libffi.a */; }; 2C18EF8D17CBD2900041C0E1 /* libpyobjus.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C18EF8B17CBD2900041C0E1 /* libpyobjus.a */; }; + 2CB5F34417D51580006187AB /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CB5F34317D51580006187AB /* CoreMotion.framework */; }; + 2CB5F34717D5233A006187AB /* bridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 2CB5F34617D5233A006187AB /* bridge.m */; }; 596C7514150CFC75003F57D9 /* include in Resources */ = {isa = PBXBuildFile; fileRef = 596C7513150CFC75003F57D9 /* include */; }; 5983EC97163CB90D00475EFB /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5983EC96163CB90D00475EFB /* libsqlite3.dylib */; }; 598E034D14F80187000D1362 /* libSDL_mixer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 598E034C14F80187000D1362 /* libSDL_mixer.a */; }; @@ -48,6 +50,9 @@ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 2C18EF8A17CBD2900041C0E1 /* libffi.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libffi.a; path = ../build/lib/libffi.a; sourceTree = ""; }; 2C18EF8B17CBD2900041C0E1 /* libpyobjus.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpyobjus.a; path = ../build/lib/libpyobjus.a; sourceTree = ""; }; + 2CB5F34317D51580006187AB /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; }; + 2CB5F34517D5233A006187AB /* bridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bridge.h; sourceTree = SOURCE_ROOT; }; + 2CB5F34617D5233A006187AB /* bridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = bridge.m; sourceTree = SOURCE_ROOT; }; 596C7513150CFC75003F57D9 /* include */ = {isa = PBXFileReference; lastKnownFileType = folder; name = include; path = ../build/python/embed/include; sourceTree = ""; }; 5983EC96163CB90D00475EFB /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; 598E034C14F80187000D1362 /* libSDL_mixer.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL_mixer.a; path = ../build/lib/libSDL_mixer.a; sourceTree = ""; }; @@ -73,6 +78,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 2CB5F34417D51580006187AB /* CoreMotion.framework in Frameworks */, 2C18EF8C17CBD2900041C0E1 /* libffi.a in Frameworks */, 2C18EF8D17CBD2900041C0E1 /* libpyobjus.a in Frameworks */, 5983EC97163CB90D00475EFB /* libsqlite3.dylib in Frameworks */, @@ -104,6 +110,8 @@ 080E96DDFE201D6D7F000001 /* Classes */ = { isa = PBXGroup; children = ( + 2CB5F34517D5233A006187AB /* bridge.h */, + 2CB5F34617D5233A006187AB /* bridge.m */, ); path = Classes; sourceTree = ""; @@ -151,6 +159,7 @@ 29B97323FDCFA39411CA2CEA /* Frameworks */ = { isa = PBXGroup; children = ( + 2CB5F34317D51580006187AB /* CoreMotion.framework */, 2C18EF8A17CBD2900041C0E1 /* libffi.a */, 2C18EF8B17CBD2900041C0E1 /* libpyobjus.a */, 5983EC96163CB90D00475EFB /* libsqlite3.dylib */, @@ -261,6 +270,7 @@ buildActionMask = 2147483647; files = ( 1D60589B0D05DD56006BFB54 /* main.m in Sources */, + 2CB5F34717D5233A006187AB /* bridge.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };