summaryrefslogtreecommitdiff
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:16:58 -0800
committerMariatta Wijaya <mariatta.wijaya@gmail.com>2017-02-06 20:16:58 -0800
commitda79bcf8ac7ae72218ab023e1ed54390bc1a3a27 (patch)
tree74845e2dbd9521d9748b9c32f1922f4123083bf3 /Modules/_ctypes
parente3c7e835bdfc97750eb9b7fc0ad2493108c2d438 (diff)
parent1fe806ac56f8b83694d24ab604eb695d00bc8497 (diff)
downloadcpython-da79bcf8ac7ae72218ab023e1ed54390bc1a3a27.tar.gz
Issue #29371: merge with 3.5
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/_ctypes.c48
-rw-r--r--Modules/_ctypes/_ctypes_test.c43
-rw-r--r--Modules/_ctypes/callbacks.c2
-rw-r--r--Modules/_ctypes/callproc.c28
-rw-r--r--Modules/_ctypes/cfield.c76
-rw-r--r--Modules/_ctypes/ctypes.h10
-rw-r--r--Modules/_ctypes/libffi/src/dlmalloc.c2
-rw-r--r--Modules/_ctypes/libffi_arm_wince/debug.c59
-rw-r--r--Modules/_ctypes/libffi_arm_wince/ffi.c310
-rw-r--r--Modules/_ctypes/libffi_arm_wince/ffi.h317
-rw-r--r--Modules/_ctypes/libffi_arm_wince/ffi_common.h111
-rw-r--r--Modules/_ctypes/libffi_arm_wince/fficonfig.h152
-rw-r--r--Modules/_ctypes/libffi_arm_wince/ffitarget.h49
-rw-r--r--Modules/_ctypes/libffi_arm_wince/prep_cif.c175
-rw-r--r--Modules/_ctypes/libffi_arm_wince/sysv.asm228
-rw-r--r--Modules/_ctypes/stgdict.c2
16 files changed, 86 insertions, 1526 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index b32a0ce9e8..df3aedec6e 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -111,12 +111,6 @@ bytes(cdata)
#ifndef IS_INTRESOURCE
#define IS_INTRESOURCE(x) (((size_t)(x) >> 16) == 0)
#endif
-# ifdef _WIN32_WCE
-/* Unlike desktop Windows, WinCE has both W and A variants of
- GetProcAddress, but the default W version is not what we want */
-# undef GetProcAddress
-# define GetProcAddress GetProcAddressA
-# endif
#else
#include "ctypes_dlfcn.h"
#endif
@@ -435,7 +429,7 @@ UnionType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return StructUnionType_new(type, args, kwds, 0);
}
-static char from_address_doc[] =
+static const char from_address_doc[] =
"C.from_address(integer) -> C instance\naccess a C instance at the specified address";
static PyObject *
@@ -453,7 +447,7 @@ CDataType_from_address(PyObject *type, PyObject *value)
return PyCData_AtAddress(type, buf);
}
-static char from_buffer_doc[] =
+static const char from_buffer_doc[] =
"C.from_buffer(object, offset=0) -> C instance\ncreate a C instance from a writeable buffer";
static int
@@ -527,7 +521,7 @@ CDataType_from_buffer(PyObject *type, PyObject *args)
return result;
}
-static char from_buffer_copy_doc[] =
+static const char from_buffer_copy_doc[] =
"C.from_buffer_copy(object, offset=0) -> C instance\ncreate a C instance from a readable buffer";
static PyObject *
@@ -572,7 +566,7 @@ CDataType_from_buffer_copy(PyObject *type, PyObject *args)
return result;
}
-static char in_dll_doc[] =
+static const char in_dll_doc[] =
"C.in_dll(dll, name) -> C instance\naccess a C instance in a dll";
static PyObject *
@@ -629,7 +623,7 @@ CDataType_in_dll(PyObject *type, PyObject *args)
return PyCData_AtAddress(type, address);
}
-static char from_param_doc[] =
+static const char from_param_doc[] =
"Convert a Python object into a function call parameter.";
static PyObject *
@@ -1494,7 +1488,7 @@ _type_ attribute.
*/
-static char *SIMPLE_TYPE_CHARS = "cbBhHiIlLdfuzZqQPXOv?g";
+static const char SIMPLE_TYPE_CHARS[] = "cbBhHiIlLdfuzZqQPXOv?g";
static PyObject *
c_wchar_p_from_param(PyObject *type, PyObject *value)
@@ -1735,7 +1729,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
if (stgd && CDataObject_Check(value) && stgd->proto && PyUnicode_Check(stgd->proto)) {
PyCArgObject *parg;
- switch (_PyUnicode_AsString(stgd->proto)[0]) {
+ switch (PyUnicode_AsUTF8(stgd->proto)[0]) {
case 'z': /* c_char_p */
case 'Z': /* c_wchar_p */
parg = PyCArgObject_new();
@@ -1847,7 +1841,7 @@ PyCSimpleType_paramfunc(CDataObject *self)
dict = PyObject_stgdict((PyObject *)self);
assert(dict); /* Cannot be NULL for CDataObject instances */
- fmt = _PyUnicode_AsString(dict->proto);
+ fmt = PyUnicode_AsUTF8(dict->proto);
assert(fmt);
fd = _ctypes_get_fielddesc(fmt);
@@ -2071,7 +2065,7 @@ PyCSimpleType_from_param(PyObject *type, PyObject *value)
assert(dict);
/* I think we can rely on this being a one-character string */
- fmt = _PyUnicode_AsString(dict->proto);
+ fmt = PyUnicode_AsUTF8(dict->proto);
assert(fmt);
fd = _ctypes_get_fielddesc(fmt);
@@ -2419,7 +2413,7 @@ unique_key(CDataObject *target, Py_ssize_t index)
char *cp = string;
size_t bytes_left;
- assert(sizeof(string) - 1 > sizeof(Py_ssize_t) * 2);
+ Py_BUILD_ASSERT(sizeof(string) - 1 > sizeof(Py_ssize_t) * 2);
cp += sprintf(cp, "%x", Py_SAFE_DOWNCAST(index, Py_ssize_t, int));
while (target->b_base) {
bytes_left = sizeof(string) - (cp - string) - 1;
@@ -3080,7 +3074,7 @@ static PyGetSetDef PyCFuncPtr_getsets[] = {
};
#ifdef MS_WIN32
-static PPROC FindAddress(void *handle, char *name, PyObject *type)
+static PPROC FindAddress(void *handle, const char *name, PyObject *type)
{
#ifdef MS_WIN64
/* win64 has no stdcall calling conv, so it should
@@ -3140,7 +3134,7 @@ _check_outarg_type(PyObject *arg, Py_ssize_t index)
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
&& PyUnicode_Check(dict->proto)
/* We only allow c_void_p, c_char_p and c_wchar_p as a simple output parameter type */
- && (strchr("PzZ", _PyUnicode_AsString(dict->proto)[0]))) {
+ && (strchr("PzZ", PyUnicode_AsUTF8(dict->proto)[0]))) {
return 1;
}
@@ -3214,7 +3208,7 @@ _validate_paramflags(PyTypeObject *type, PyObject *paramflags)
}
static int
-_get_name(PyObject *obj, char **pname)
+_get_name(PyObject *obj, const char **pname)
{
#ifdef MS_WIN32
if (PyLong_Check(obj)) {
@@ -3230,7 +3224,7 @@ _get_name(PyObject *obj, char **pname)
return *pname ? 1 : 0;
}
if (PyUnicode_Check(obj)) {
- *pname = _PyUnicode_AsString(obj);
+ *pname = PyUnicode_AsUTF8(obj);
return *pname ? 1 : 0;
}
PyErr_SetString(PyExc_TypeError,
@@ -3242,7 +3236,7 @@ _get_name(PyObject *obj, char **pname)
static PyObject *
PyCFuncPtr_FromDll(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- char *name;
+ const char *name;
int (* address)(void);
PyObject *ftuple;
PyObject *dll;
@@ -5132,13 +5126,12 @@ static const char module_docs[] =
#ifdef MS_WIN32
-static char comerror_doc[] = "Raised when a COM method call failed.";
+static const char comerror_doc[] = "Raised when a COM method call failed.";
int
comerror_init(PyObject *self, PyObject *args, PyObject *kwds)
{
PyObject *hresult, *text, *details;
- PyBaseExceptionObject *bself;
PyObject *a;
int status;
@@ -5165,9 +5158,8 @@ comerror_init(PyObject *self, PyObject *args, PyObject *kwds)
if (PyObject_SetAttrString(self, "details", details) < 0)
return -1;
- bself = (PyBaseExceptionObject *)self;
Py_INCREF(args);
- Py_SETREF(bself->args, args);
+ Py_SETREF(((PyBaseExceptionObject *)self)->args, args);
return 0;
}
@@ -5247,7 +5239,7 @@ cast_check_pointertype(PyObject *arg)
dict = PyType_stgdict(arg);
if (dict) {
if (PyUnicode_Check(dict->proto)
- && (strchr("sPzUZXO", _PyUnicode_AsString(dict->proto)[0]))) {
+ && (strchr("sPzUZXO", PyUnicode_AsUTF8(dict->proto)[0]))) {
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
return 1;
}
@@ -5497,14 +5489,14 @@ PyInit__ctypes(void)
#endif
/* If RTLD_LOCAL is not defined (Windows!), set it to zero. */
-#ifndef RTLD_LOCAL
+#if !HAVE_DECL_RTLD_LOCAL
#define RTLD_LOCAL 0
#endif
/* If RTLD_GLOBAL is not defined (cygwin), set it to the same value as
RTLD_LOCAL.
*/
-#ifndef RTLD_GLOBAL
+#if !HAVE_DECL_RTLD_GLOBAL
#define RTLD_GLOBAL RTLD_LOCAL
#endif
diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c
index 3c7f89249a..629ddf66bc 100644
--- a/Modules/_ctypes/_ctypes_test.c
+++ b/Modules/_ctypes/_ctypes_test.c
@@ -233,16 +233,15 @@ EXPORT(int) _testfunc_callback_with_pointer(int (*func)(int *))
return (*func)(table);
}
-#ifdef HAVE_LONG_LONG
-EXPORT(PY_LONG_LONG) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
- double d, PY_LONG_LONG q)
+EXPORT(long long) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
+ double d, long long q)
{
- return (PY_LONG_LONG)(b + h + i + l + f + d + q);
+ return (long long)(b + h + i + l + f + d + q);
}
-EXPORT(PY_LONG_LONG) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
+EXPORT(long long) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
{
- return (PY_LONG_LONG)(b + h + i + l + f + d);
+ return (long long)(b + h + i + l + f + d);
}
EXPORT(int) _testfunc_callback_i_if(int value, int (*func)(int))
@@ -255,10 +254,10 @@ EXPORT(int) _testfunc_callback_i_if(int value, int (*func)(int))
return sum;
}
-EXPORT(PY_LONG_LONG) _testfunc_callback_q_qf(PY_LONG_LONG value,
- PY_LONG_LONG (*func)(PY_LONG_LONG))
+EXPORT(long long) _testfunc_callback_q_qf(long long value,
+ long long (*func)(long long))
{
- PY_LONG_LONG sum = 0;
+ long long sum = 0;
while (value != 0) {
sum += func(value);
@@ -267,8 +266,6 @@ EXPORT(PY_LONG_LONG) _testfunc_callback_q_qf(PY_LONG_LONG value,
return sum;
}
-#endif
-
typedef struct {
char *name;
char *value;
@@ -384,8 +381,8 @@ EXPORT(void) _py_func(void)
{
}
-EXPORT(PY_LONG_LONG) last_tf_arg_s;
-EXPORT(unsigned PY_LONG_LONG) last_tf_arg_u;
+EXPORT(long long) last_tf_arg_s;
+EXPORT(unsigned long long) last_tf_arg_u;
struct BITS {
int A: 1, B:2, C:3, D:4, E: 5, F: 6, G: 7, H: 8, I: 9;
@@ -448,8 +445,8 @@ static PyMethodDef module_methods[] = {
{ NULL, NULL, 0, NULL},
};
-#define S last_tf_arg_s = (PY_LONG_LONG)c
-#define U last_tf_arg_u = (unsigned PY_LONG_LONG)c
+#define S last_tf_arg_s = (long long)c
+#define U last_tf_arg_u = (unsigned long long)c
EXPORT(signed char) tf_b(signed char c) { S; return c/3; }
EXPORT(unsigned char) tf_B(unsigned char c) { U; return c/3; }
@@ -459,8 +456,8 @@ EXPORT(int) tf_i(int c) { S; return c/3; }
EXPORT(unsigned int) tf_I(unsigned int c) { U; return c/3; }
EXPORT(long) tf_l(long c) { S; return c/3; }
EXPORT(unsigned long) tf_L(unsigned long c) { U; return c/3; }
-EXPORT(PY_LONG_LONG) tf_q(PY_LONG_LONG c) { S; return c/3; }
-EXPORT(unsigned PY_LONG_LONG) tf_Q(unsigned PY_LONG_LONG c) { U; return c/3; }
+EXPORT(long long) tf_q(long long c) { S; return c/3; }
+EXPORT(unsigned long long) tf_Q(unsigned long long c) { U; return c/3; }
EXPORT(float) tf_f(float c) { S; return c/3; }
EXPORT(double) tf_d(double c) { S; return c/3; }
EXPORT(long double) tf_D(long double c) { S; return c/3; }
@@ -474,8 +471,8 @@ EXPORT(int) __stdcall s_tf_i(int c) { S; return c/3; }
EXPORT(unsigned int) __stdcall s_tf_I(unsigned int c) { U; return c/3; }
EXPORT(long) __stdcall s_tf_l(long c) { S; return c/3; }
EXPORT(unsigned long) __stdcall s_tf_L(unsigned long c) { U; return c/3; }
-EXPORT(PY_LONG_LONG) __stdcall s_tf_q(PY_LONG_LONG c) { S; return c/3; }
-EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_Q(unsigned PY_LONG_LONG c) { U; return c/3; }
+EXPORT(long long) __stdcall s_tf_q(long long c) { S; return c/3; }
+EXPORT(unsigned long long) __stdcall s_tf_Q(unsigned long long c) { U; return c/3; }
EXPORT(float) __stdcall s_tf_f(float c) { S; return c/3; }
EXPORT(double) __stdcall s_tf_d(double c) { S; return c/3; }
EXPORT(long double) __stdcall s_tf_D(long double c) { S; return c/3; }
@@ -490,8 +487,8 @@ EXPORT(int) tf_bi(signed char x, int c) { S; return c/3; }
EXPORT(unsigned int) tf_bI(signed char x, unsigned int c) { U; return c/3; }
EXPORT(long) tf_bl(signed char x, long c) { S; return c/3; }
EXPORT(unsigned long) tf_bL(signed char x, unsigned long c) { U; return c/3; }
-EXPORT(PY_LONG_LONG) tf_bq(signed char x, PY_LONG_LONG c) { S; return c/3; }
-EXPORT(unsigned PY_LONG_LONG) tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
+EXPORT(long long) tf_bq(signed char x, long long c) { S; return c/3; }
+EXPORT(unsigned long long) tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
EXPORT(float) tf_bf(signed char x, float c) { S; return c/3; }
EXPORT(double) tf_bd(signed char x, double c) { S; return c/3; }
EXPORT(long double) tf_bD(signed char x, long double c) { S; return c/3; }
@@ -506,8 +503,8 @@ EXPORT(int) __stdcall s_tf_bi(signed char x, int c) { S; return c/3; }
EXPORT(unsigned int) __stdcall s_tf_bI(signed char x, unsigned int c) { U; return c/3; }
EXPORT(long) __stdcall s_tf_bl(signed char x, long c) { S; return c/3; }
EXPORT(unsigned long) __stdcall s_tf_bL(signed char x, unsigned long c) { U; return c/3; }
-EXPORT(PY_LONG_LONG) __stdcall s_tf_bq(signed char x, PY_LONG_LONG c) { S; return c/3; }
-EXPORT(unsigned PY_LONG_LONG) __stdcall s_tf_bQ(signed char x, unsigned PY_LONG_LONG c) { U; return c/3; }
+EXPORT(long long) __stdcall s_tf_bq(signed char x, long long c) { S; return c/3; }
+EXPORT(unsigned long long) __stdcall s_tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
EXPORT(float) __stdcall s_tf_bf(signed char x, float c) { S; return c/3; }
EXPORT(double) __stdcall s_tf_bd(signed char x, double c) { S; return c/3; }
EXPORT(long double) __stdcall s_tf_bD(signed char x, long double c) { S; return c/3; }
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 91413d7dbf..b958f304c5 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -77,7 +77,7 @@ PyTypeObject PyCThunk_Type = {
/**************************************************************/
static void
-PrintError(char *msg, ...)
+PrintError(const char *msg, ...)
{
char buf[512];
PyObject *f = PySys_GetObject("stderr");
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index abd3bc995d..7d542fb50d 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -382,7 +382,7 @@ static void SetException(DWORD code, EXCEPTION_RECORD *pr)
whose operation is not allowed in the current
machine mode. */
PyErr_SetString(PyExc_OSError,
- "exception: priviledged instruction");
+ "exception: privileged instruction");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
@@ -474,7 +474,6 @@ PyCArg_repr(PyCArgObject *self)
self->tag, self->value.l);
break;
-#ifdef HAVE_LONG_LONG
case 'q':
case 'Q':
sprintf(buffer,
@@ -485,7 +484,6 @@ PyCArg_repr(PyCArgObject *self)
#endif
self->tag, self->value.q);
break;
-#endif
case 'd':
sprintf(buffer, "<cparam '%c' (%f)>",
self->tag, self->value.d);
@@ -593,9 +591,7 @@ union result {
short h;
int i;
long l;
-#ifdef HAVE_LONG_LONG
- PY_LONG_LONG q;
-#endif
+ long long q;
long double D;
double d;
float f;
@@ -930,7 +926,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
* Raise a new exception 'exc_class', adding additional text to the original
* exception string.
*/
-void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...)
+void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...)
{
va_list vargs;
PyObject *tp, *v, *tb, *s, *cls_str, *msg_str;
@@ -1203,7 +1199,7 @@ _parse_voidp(PyObject *obj, void **address)
#ifdef MS_WIN32
-static char format_error_doc[] =
+static const char format_error_doc[] =
"FormatError([integer]) -> string\n\
\n\
Convert a win32 error code into a string. If the error code is not\n\
@@ -1227,7 +1223,7 @@ static PyObject *format_error(PyObject *self, PyObject *args)
return result;
}
-static char load_library_doc[] =
+static const char load_library_doc[] =
"LoadLibrary(name) -> handle\n\
\n\
Load an executable (usually a DLL), and return a handle to it.\n\
@@ -1256,7 +1252,7 @@ static PyObject *load_library(PyObject *self, PyObject *args)
#endif
}
-static char free_library_doc[] =
+static const char free_library_doc[] =
"FreeLibrary(handle) -> void\n\
\n\
Free the handle of an executable previously loaded by LoadLibrary.\n";
@@ -1271,7 +1267,7 @@ static PyObject *free_library(PyObject *self, PyObject *args)
return Py_None;
}
-static char copy_com_pointer_doc[] =
+static const char copy_com_pointer_doc[] =
"CopyComPointer(src, dst) -> HRESULT value\n";
static PyObject *
@@ -1309,7 +1305,7 @@ static PyObject *py_dl_open(PyObject *self, PyObject *args)
PyObject *name, *name2;
char *name_str;
void * handle;
-#ifdef RTLD_LOCAL
+#if HAVE_DECL_RTLD_LOCAL
int mode = RTLD_NOW | RTLD_LOCAL;
#else
/* cygwin doesn't define RTLD_LOCAL */
@@ -1441,7 +1437,7 @@ call_cdeclfunction(PyObject *self, PyObject *args)
/*****************************************************************
* functions
*/
-static char sizeof_doc[] =
+static const char sizeof_doc[] =
"sizeof(C type) -> integer\n"
"sizeof(C instance) -> integer\n"
"Return the size in bytes of a C instance";
@@ -1462,7 +1458,7 @@ sizeof_func(PyObject *self, PyObject *obj)
return NULL;
}
-static char alignment_doc[] =
+static const char alignment_doc[] =
"alignment(C type) -> integer\n"
"alignment(C instance) -> integer\n"
"Return the alignment requirements of a C instance";
@@ -1485,7 +1481,7 @@ align_func(PyObject *self, PyObject *obj)
return NULL;
}
-static char byref_doc[] =
+static const char byref_doc[] =
"byref(C instance[, offset=0]) -> byref-object\n"
"Return a pointer lookalike to a C instance, only usable\n"
"as function argument";
@@ -1529,7 +1525,7 @@ byref(PyObject *self, PyObject *args)
return (PyObject *)parg;
}
-static char addressof_doc[] =
+static const char addressof_doc[] =
"addressof(C instance) -> integer\n"
"Return the address of the C instance internal buffer";
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index d666be5d92..a43585f1b8 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -379,14 +379,12 @@ get_ulong(PyObject *v, unsigned long *p)
return 0;
}
-#ifdef HAVE_LONG_LONG
-
/* Same, but handling native long long. */
static int
-get_longlong(PyObject *v, PY_LONG_LONG *p)
+get_longlong(PyObject *v, long long *p)
{
- PY_LONG_LONG x;
+ long long x;
if (PyFloat_Check(v)) {
PyErr_SetString(PyExc_TypeError,
"int expected instead of float");
@@ -402,23 +400,21 @@ get_longlong(PyObject *v, PY_LONG_LONG *p)
/* Same, but handling native unsigned long long. */
static int
-get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p)
+get_ulonglong(PyObject *v, unsigned long long *p)
{
- unsigned PY_LONG_LONG x;
+ unsigned long long x;
if (PyFloat_Check(v)) {
PyErr_SetString(PyExc_TypeError,
"int expected instead of float");
return -1;
}
x = PyLong_AsUnsignedLongLongMask(v);
- if (x == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())
+ if (x == (unsigned long long)-1 && PyErr_Occurred())
return -1;
*p = x;
return 0;
}
-#endif
-
/*****************************************************************
* Integer fields, with bitfield support
*/
@@ -715,14 +711,6 @@ vBOOL_get(void *ptr, Py_ssize_t size)
}
#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)
{
@@ -730,10 +718,10 @@ bool_set(void *ptr, PyObject *value, Py_ssize_t size)
case -1:
return NULL;
case 0:
- *(BOOL_TYPE *)ptr = 0;
+ *(_Bool *)ptr = 0;
_RET(value);
default:
- *(BOOL_TYPE *)ptr = 1;
+ *(_Bool *)ptr = 1;
_RET(value);
}
}
@@ -741,7 +729,7 @@ bool_set(void *ptr, PyObject *value, Py_ssize_t size)
static PyObject *
bool_get(void *ptr, Py_ssize_t size)
{
- return PyBool_FromLong((long)*(BOOL_TYPE *)ptr);
+ return PyBool_FromLong((long)*(_Bool *)ptr);
}
static PyObject *
@@ -888,16 +876,15 @@ L_get_sw(void *ptr, Py_ssize_t 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;
+ long long val;
+ long long x;
if (get_longlong(value, &val) < 0)
return NULL;
memcpy(&x, ptr, sizeof(x));
- x = SET(PY_LONG_LONG, x, val, size);
+ x = SET(long long, x, val, size);
memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -905,13 +892,13 @@ q_set(void *ptr, PyObject *value, Py_ssize_t size)
static PyObject *
q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
- PY_LONG_LONG val;
- PY_LONG_LONG field;
+ long long val;
+ long long field;
if (get_longlong(value, &val) < 0)
return NULL;
memcpy(&field, ptr, sizeof(field));
field = SWAP_8(field);
- field = SET(PY_LONG_LONG, field, val, size);
+ field = SET(long long, field, val, size);
field = SWAP_8(field);
memcpy(ptr, &field, sizeof(field));
_RET(value);
@@ -920,7 +907,7 @@ q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
static PyObject *
q_get(void *ptr, Py_ssize_t size)
{
- PY_LONG_LONG val;
+ long long val;
memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyLong_FromLongLong(val);
@@ -929,7 +916,7 @@ q_get(void *ptr, Py_ssize_t size)
static PyObject *
q_get_sw(void *ptr, Py_ssize_t size)
{
- PY_LONG_LONG val;
+ long long val;
memcpy(&val, ptr, sizeof(val));
val = SWAP_8(val);
GET_BITFIELD(val, size);
@@ -939,12 +926,12 @@ q_get_sw(void *ptr, Py_ssize_t size)
static PyObject *
Q_set(void *ptr, PyObject *value, Py_ssize_t size)
{
- unsigned PY_LONG_LONG val;
- unsigned PY_LONG_LONG x;
+ unsigned long long val;
+ unsigned long long x;
if (get_ulonglong(value, &val) < 0)
return NULL;
memcpy(&x, ptr, sizeof(x));
- x = SET(PY_LONG_LONG, x, val, size);
+ x = SET(long long, x, val, size);
memcpy(ptr, &x, sizeof(x));
_RET(value);
}
@@ -952,13 +939,13 @@ Q_set(void *ptr, PyObject *value, Py_ssize_t size)
static PyObject *
Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
{
- unsigned PY_LONG_LONG val;
- unsigned PY_LONG_LONG field;
+ unsigned long long val;
+ unsigned long long field;
if (get_ulonglong(value, &val) < 0)
return NULL;
memcpy(&field, ptr, sizeof(field));
field = SWAP_8(field);
- field = SET(unsigned PY_LONG_LONG, field, val, size);
+ field = SET(unsigned long long, field, val, size);
field = SWAP_8(field);
memcpy(ptr, &field, sizeof(field));
_RET(value);
@@ -967,7 +954,7 @@ Q_set_sw(void *ptr, PyObject *value, Py_ssize_t size)
static PyObject *
Q_get(void *ptr, Py_ssize_t size)
{
- unsigned PY_LONG_LONG val;
+ unsigned long long val;
memcpy(&val, ptr, sizeof(val));
GET_BITFIELD(val, size);
return PyLong_FromUnsignedLongLong(val);
@@ -976,13 +963,12 @@ Q_get(void *ptr, Py_ssize_t size)
static PyObject *
Q_get_sw(void *ptr, Py_ssize_t size)
{
- unsigned PY_LONG_LONG val;
+ unsigned 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
@@ -1490,10 +1476,8 @@ P_set(void *ptr, PyObject *value, Py_ssize_t size)
#if SIZEOF_VOID_P <= SIZEOF_LONG
v = (void *)PyLong_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*)"
+#if SIZEOF_LONG_LONG < SIZEOF_VOID_P
+# error "PyLong_AsVoidPtr: sizeof(long long) < sizeof(void*)"
#endif
v = (void *)PyLong_AsUnsignedLongLongMask(value);
#endif
@@ -1538,14 +1522,12 @@ static struct fielddesc formattable[] = {
#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
@@ -1635,10 +1617,8 @@ typedef struct { char c; wchar_t *x; } s_wchar_p;
#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
+typedef struct { char c; long long x; } s_long_long;
+#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(long long))
/* from ffi.h:
typedef struct _ffi_type
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
index f2df5c0e37..5d3b966338 100644
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -31,9 +31,7 @@ union value {
long l;
float f;
double d;
-#ifdef HAVE_LONG_LONG
- PY_LONG_LONG ll;
-#endif
+ long long ll;
long double D;
};
@@ -303,9 +301,7 @@ struct tagPyCArgObject {
short h;
int i;
long l;
-#ifdef HAVE_LONG_LONG
- PY_LONG_LONG q;
-#endif
+ long long q;
long double D;
double d;
float f;
@@ -327,7 +323,7 @@ extern int
PyCData_set(PyObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
Py_ssize_t index, Py_ssize_t size, char *ptr);
-extern void _ctypes_extend_error(PyObject *exc_class, char *fmt, ...);
+extern void _ctypes_extend_error(PyObject *exc_class, const char *fmt, ...);
struct basespec {
CDataObject *base;
diff --git a/Modules/_ctypes/libffi/src/dlmalloc.c b/Modules/_ctypes/libffi/src/dlmalloc.c
index 6e474b7c4f..55c2d768b2 100644
--- a/Modules/_ctypes/libffi/src/dlmalloc.c
+++ b/Modules/_ctypes/libffi/src/dlmalloc.c
@@ -525,7 +525,7 @@ DEFAULT_MMAP_THRESHOLD default: 256K
#define MMAP_CLEARS 1
#endif /* MMAP_CLEARS */
#ifndef HAVE_MREMAP
-#ifdef linux
+#ifdef __linux__
#define HAVE_MREMAP 1
#else /* linux */
#define HAVE_MREMAP 0
diff --git a/Modules/_ctypes/libffi_arm_wince/debug.c b/Modules/_ctypes/libffi_arm_wince/debug.c
deleted file mode 100644
index 98f1f9f0b4..0000000000
--- a/Modules/_ctypes/libffi_arm_wince/debug.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -----------------------------------------------------------------------
- debug.c - Copyright (c) 1996 Red Hat, Inc.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- ``Software''), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
- ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-/* General debugging routines */
-
-void ffi_stop_here(void)
-{
- /* This function is only useful for debugging purposes.
- Place a breakpoint on ffi_stop_here to be notified of
- significant events. */
-}
-
-/* This function should only be called via the FFI_ASSERT() macro */
-
-void ffi_assert(char *expr, char *file, int line)
-{
- fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
- ffi_stop_here();
- abort();
-}
-
-/* Perform a sanity check on an ffi_type structure */
-
-void ffi_type_test(ffi_type *a, char *file, int line)
-{
- FFI_ASSERT_AT(a != NULL, file, line);
-
- /*@-usedef@*/
- FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line);
- FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line);
- FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line);
- FFI_ASSERT_AT(a->type != FFI_TYPE_STRUCT || a->elements != NULL, file, line);
- /*@=usedef@*/
-}
diff --git a/Modules/_ctypes/libffi_arm_wince/ffi.c b/Modules/_ctypes/libffi_arm_wince/ffi.c
deleted file mode 100644
index 1193aaac6b..0000000000
--- a/Modules/_ctypes/libffi_arm_wince/ffi.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* -----------------------------------------------------------------------
- ffi.c - Copyright (c) 1998 Red Hat, Inc.
-
- ARM Foreign Function Interface
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- ``Software''), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
- ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-
-#include <stdlib.h>
-
-#ifdef _WIN32_WCE
-#pragma warning (disable : 4142) /* benign redefinition of type */
-#include <windows.h>
-#endif
-
-/* ffi_prep_args is called by the assembly routine once stack space
- has been allocated for the function's arguments */
-
-/*@-exportheader@*/
-void ffi_prep_args(char *stack, extended_cif *ecif)
-/*@=exportheader@*/
-{
- register unsigned int i;
- register void **p_argv;
- register char *argp;
- register ffi_type **p_arg;
-
- argp = stack;
-
- if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) {
- *(void **) argp = ecif->rvalue;
- argp += 4;
- }
-
- p_argv = ecif->avalue;
-
- for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
- (i != 0);
- i--, p_arg++)
- {
- size_t z;
- size_t argalign = (*p_arg)->alignment;
-
-#ifdef _WIN32_WCE
- if (argalign > 4)
- argalign = 4;
-#endif
- /* Align if necessary */
- if ((argalign - 1) & (unsigned) argp) {
- argp = (char *) ALIGN(argp, argalign);
- }
-
- z = (*p_arg)->size;
- if (z < sizeof(int))
- {
- z = sizeof(int);
- switch ((*p_arg)->type)
- {
- case FFI_TYPE_SINT8:
- *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
- break;
-
- case FFI_TYPE_UINT8:
- *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
- break;
-
- case FFI_TYPE_SINT16:
- *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
- break;
-
- case FFI_TYPE_UINT16:
- *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
- break;
-
- case FFI_TYPE_STRUCT:
- /* *p_argv may not be aligned for a UINT32 */
- memcpy(argp, *p_argv, z);
- break;
-
- default:
- FFI_ASSERT(0);
- }
- }
- else if (z == sizeof(int))
- {
- *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
- }
- else
- {
- memcpy(argp, *p_argv, z);
- }
- p_argv++;
- argp += z;
- }
-
- return;
-}
-
-/* Perform machine dependent cif processing */
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
-{
- /* Set the return type flag */
- switch (cif->rtype->type)
- {
- case FFI_TYPE_VOID:
- case FFI_TYPE_STRUCT:
- case FFI_TYPE_FLOAT:
- case FFI_TYPE_DOUBLE:
- case FFI_TYPE_SINT64:
- cif->flags = (unsigned) cif->rtype->type;
- break;
-
- case FFI_TYPE_UINT64:
- cif->flags = FFI_TYPE_SINT64;
- break;
-
- default:
- cif->flags = FFI_TYPE_INT;
- break;
- }
-
- return FFI_OK;
-}
-
-/*@-declundef@*/
-/*@-exportheader@*/
-extern void ffi_call_SYSV(void (*)(char *, extended_cif *),
- /*@out@*/ extended_cif *,
- unsigned, unsigned,
- /*@out@*/ unsigned *,
- void (*fn)());
-/*@=declundef@*/
-/*@=exportheader@*/
-
-/* Return type changed from void for ctypes */
-int ffi_call(/*@dependent@*/ ffi_cif *cif,
- void (*fn)(),
- /*@out@*/ void *rvalue,
- /*@dependent@*/ void **avalue)
-{
- extended_cif ecif;
-
- ecif.cif = cif;
- ecif.avalue = avalue;
-
- /* If the return value is a struct and we don't have a return */
- /* value address then we need to make one */
-
- if ((rvalue == NULL) &&
- (cif->rtype->type == FFI_TYPE_STRUCT))
- {
- /*@-sysunrecog@*/
- ecif.rvalue = alloca(cif->rtype->size);
- /*@=sysunrecog@*/
- }
- else
- ecif.rvalue = rvalue;
-
-
- switch (cif->abi)
- {
- case FFI_SYSV:
- /*@-usedef@*/
- ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes,
- cif->flags, ecif.rvalue, fn);
- /*@=usedef@*/
- break;
- default:
- FFI_ASSERT(0);
- break;
- }
- /* I think calculating the real stack pointer delta is not useful
- because stdcall is not supported */
- return 0;
-}
-
-/** private members **/
-
-static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
- void** args, ffi_cif* cif);
-
-/* This function is called by ffi_closure_SYSV in sysv.asm */
-
-unsigned int
-ffi_closure_SYSV_inner (ffi_closure *closure, char *in_args, void *rvalue)
-{
- ffi_cif *cif = closure->cif;
- void **out_args;
-
- out_args = (void **) alloca(cif->nargs * sizeof (void *));
-
- /* this call will initialize out_args, such that each
- * element in that array points to the corresponding
- * value on the stack; and if the function returns
- * a structure, it will re-set rvalue to point to the
- * structure return address. */
-
- ffi_prep_incoming_args_SYSV(in_args, &rvalue, out_args, cif);
-
- (closure->fun)(cif, rvalue, out_args, closure->user_data);
-
- /* Tell ffi_closure_SYSV what the returntype is */
- return cif->flags;
-}
-
-/*@-exportheader@*/
-static void
-ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
- void **avalue, ffi_cif *cif)
-/*@=exportheader@*/
-{
- unsigned int i;
- void **p_argv;
- char *argp;
- ffi_type **p_arg;
-
- argp = stack;
-
- if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
- *rvalue = *(void **) argp;
- argp += 4;
- }
-
- p_argv = avalue;
-
- for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
- {
- size_t z;
- size_t argalign = (*p_arg)->alignment;
-
-#ifdef _WIN32_WCE
- if (argalign > 4)
- argalign = 4;
-#endif
- /* Align if necessary */
- if ((argalign - 1) & (unsigned) argp) {
- argp = (char *) ALIGN(argp, argalign);
- }
-
- z = (*p_arg)->size;
- if (z < sizeof(int))
- z = sizeof(int);
-
- *p_argv = (void*) argp;
-
- p_argv++;
- argp += z;
- }
-}
-
-/*
- add ip, pc, #-8 ; ip = address of this trampoline == address of ffi_closure
- ldr pc, [pc, #-4] ; jump to __fun
- DCD __fun
-*/
-#define FFI_INIT_TRAMPOLINE(TRAMP,FUN) \
-{ \
- unsigned int *__tramp = (unsigned int *)(TRAMP); \
- __tramp[0] = 0xe24fc008; /* add ip, pc, #-8 */ \
- __tramp[1] = 0xe51ff004; /* ldr pc, [pc, #-4] */ \
- __tramp[2] = (unsigned int)(FUN); \
- }
-
-/* the cif must already be prep'ed */
-
-/* defined in sysv.asm */
-void ffi_closure_SYSV(void);
-
-ffi_status
-ffi_prep_closure (ffi_closure* closure,
- ffi_cif* cif,
- void (*fun)(ffi_cif*,void*,void**,void*),
- void *user_data)
-{
- FFI_ASSERT (cif->abi == FFI_SYSV);
-
- FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_SYSV);
-
- closure->cif = cif;
- closure->user_data = user_data;
- closure->fun = fun;
-
-#ifdef _WIN32_WCE
- /* This is important to allow calling the trampoline safely */
- FlushInstructionCache(GetCurrentProcess(), 0, 0);
-#endif
-
- return FFI_OK;
-}
-
diff --git a/Modules/_ctypes/libffi_arm_wince/ffi.h b/Modules/_ctypes/libffi_arm_wince/ffi.h
deleted file mode 100644
index 67975b6b44..0000000000
--- a/Modules/_ctypes/libffi_arm_wince/ffi.h
+++ /dev/null
@@ -1,317 +0,0 @@
-/* -----------------------------------------------------------------*-C-*-
- libffi 2.00-beta-wince - Copyright (c) 1996-2003 Red Hat, Inc.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- ``Software''), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
-
- ----------------------------------------------------------------------- */
-
-/* -------------------------------------------------------------------
- The basic API is described in the README file.
-
- The raw API is designed to bypass some of the argument packing
- and unpacking on architectures for which it can be avoided.
-
- The closure API allows interpreted functions to be packaged up
- inside a C function pointer, so that they can be called as C functions,
- with no understanding on the client side that they are interpreted.
- It can also be used in other cases in which it is necessary to package
- up a user specified parameter and a function pointer as a single
- function pointer.
-
- The closure API must be implemented in order to get its functionality,
- e.g. for use by gij. Routines are provided to emulate the raw API
- if the underlying platform doesn't allow faster implementation.
-
- More details on the raw and cloure API can be found in:
-
- http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
-
- and
-
- http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
- -------------------------------------------------------------------- */
-
-#ifndef LIBFFI_H
-#define LIBFFI_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Specify which architecture libffi is configured for. */
-/*#define @TARGET@*/
-
-/* ---- System configuration information --------------------------------- */
-
-#include <ffitarget.h>
-
-#ifndef LIBFFI_ASM
-
-#include <stddef.h>
-#include <limits.h>
-
-/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
- But we can find it either under the correct ANSI name, or under GNU
- C's internal name. */
-#ifdef LONG_LONG_MAX
-# define FFI_LONG_LONG_MAX LONG_LONG_MAX
-#else
-# ifdef LLONG_MAX
-# define FFI_LONG_LONG_MAX LLONG_MAX
-# else
-# ifdef __GNUC__
-# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
-# endif
-# ifdef _MSC_VER
-# define FFI_LONG_LONG_MAX _I64_MAX
-# endif
-# endif
-#endif
-
-#if SCHAR_MAX == 127
-# define ffi_type_uchar ffi_type_uint8
-# define ffi_type_schar ffi_type_sint8
-#else
- #error "char size not supported"
-#endif
-
-#if SHRT_MAX == 32767
-# define ffi_type_ushort ffi_type_uint16
-# define ffi_type_sshort ffi_type_sint16
-#elif SHRT_MAX == 2147483647
-# define ffi_type_ushort ffi_type_uint32
-# define ffi_type_sshort ffi_type_sint32
-#else
- #error "short size not supported"
-#endif
-
-#if INT_MAX == 32767
-# define ffi_type_uint ffi_type_uint16
-# define ffi_type_sint ffi_type_sint16
-#elif INT_MAX == 2147483647
-# define ffi_type_uint ffi_type_uint32
-# define ffi_type_sint ffi_type_sint32
-#elif INT_MAX == 9223372036854775807
-# define ffi_type_uint ffi_type_uint64
-# define ffi_type_sint ffi_type_sint64
-#else
- #error "int size not supported"
-#endif
-
-#define ffi_type_ulong ffi_type_uint64
-#define ffi_type_slong ffi_type_sint64
-#if LONG_MAX == 2147483647
-# if FFI_LONG_LONG_MAX != 9223372036854775807
- #error "no 64-bit data type supported"
-# endif
-#elif LONG_MAX != 9223372036854775807
- #error "long size not supported"
-#endif
-
-/* The closure code assumes that this works on pointers, i.e. a size_t */
-/* can hold a pointer. */
-
-typedef struct _ffi_type
-{
- size_t size;
- unsigned short alignment;
- unsigned short type;
- /*@null@*/ struct _ffi_type **elements;
-} ffi_type;
-
-/* These are defined in types.c */
-extern ffi_type ffi_type_void;
-extern ffi_type ffi_type_uint8;
-extern ffi_type ffi_type_sint8;
-extern ffi_type ffi_type_uint16;
-extern ffi_type ffi_type_sint16;
-extern ffi_type ffi_type_uint32;
-extern ffi_type ffi_type_sint32;
-extern ffi_type ffi_type_uint64;
-extern ffi_type ffi_type_sint64;
-extern ffi_type ffi_type_float;
-extern ffi_type ffi_type_double;
-extern ffi_type ffi_type_longdouble;
-extern ffi_type ffi_type_pointer;
-
-
-typedef enum {
- FFI_OK = 0,
- FFI_BAD_TYPEDEF,
- FFI_BAD_ABI
-} ffi_status;
-
-typedef unsigned FFI_TYPE;
-
-typedef struct {
- ffi_abi abi;
- unsigned nargs;
- /*@dependent@*/ ffi_type **arg_types;
- /*@dependent@*/ ffi_type *rtype;
- unsigned bytes;
- unsigned flags;
-#ifdef FFI_EXTRA_CIF_FIELDS
- FFI_EXTRA_CIF_FIELDS;
-#endif
-} ffi_cif;
-
-/* ---- Definitions for the raw API -------------------------------------- */
-
-#ifndef FFI_SIZEOF_ARG
-# if LONG_MAX == 2147483647
-# define FFI_SIZEOF_ARG 4
-# elif LONG_MAX == 9223372036854775807
-# define FFI_SIZEOF_ARG 8
-# endif
-#endif
-
-typedef union {
- ffi_sarg sint;
- ffi_arg uint;
- float flt;
- char data[FFI_SIZEOF_ARG];
- void* ptr;
-} ffi_raw;
-
-void ffi_raw_call (/*@dependent@*/ ffi_cif *cif,
- void (*fn)(),
- /*@out@*/ void *rvalue,
- /*@dependent@*/ ffi_raw *avalue);
-
-void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
-void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
-size_t ffi_raw_size (ffi_cif *cif);
-
-/* This is analogous to the raw API, except it uses Java parameter */
-/* packing, even on 64-bit machines. I.e. on 64-bit machines */
-/* longs and doubles are followed by an empty 64-bit word. */
-
-void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif,
- void (*fn)(),
- /*@out@*/ void *rvalue,
- /*@dependent@*/ ffi_raw *avalue);
-
-void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
-void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
-size_t ffi_java_raw_size (ffi_cif *cif);
-
-/* ---- Definitions for closures ----------------------------------------- */
-
-#if FFI_CLOSURES
-
-typedef struct {
- char tramp[FFI_TRAMPOLINE_SIZE];
- ffi_cif *cif;
- void (*fun)(ffi_cif*,void*,void**,void*);
- void *user_data;
-} ffi_closure;
-
-ffi_status
-ffi_prep_closure (ffi_closure*,
- ffi_cif *,
- void (*fun)(ffi_cif*,void*,void**,void*),
- void *user_data);
-
-typedef struct {
- char tramp[FFI_TRAMPOLINE_SIZE];
-
- ffi_cif *cif;
-
-#if !FFI_NATIVE_RAW_API
-
- /* if this is enabled, then a raw closure has the same layout
- as a regular closure. We use this to install an intermediate
- handler to do the transaltion, void** -> ffi_raw*. */
-
- void (*translate_args)(ffi_cif*,void*,void**,void*);
- void *this_closure;
-
-#endif
-
- void (*fun)(ffi_cif*,void*,ffi_raw*,void*);
- void *user_data;
-
-} ffi_raw_closure;
-
-ffi_status
-ffi_prep_raw_closure (ffi_raw_closure*,
- ffi_cif *cif,
- void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
- void *user_data);
-
-ffi_status
-ffi_prep_java_raw_closure (ffi_raw_closure*,
- ffi_cif *cif,
- void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
- void *user_data);
-
-#endif /* FFI_CLOSURES */
-
-/* ---- Public interface definition -------------------------------------- */
-
-ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
- ffi_abi abi,
- unsigned int nargs,
- /*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
- /*@dependent@*/ ffi_type **atypes);
-
-/* Return type changed from void for ctypes */
-int ffi_call(/*@dependent@*/ ffi_cif *cif,
- void (*fn)(),
- /*@out@*/ void *rvalue,
- /*@dependent@*/ void **avalue);
-
-/* Useful for eliminating compiler warnings */
-#define FFI_FN(f) ((void (*)())f)
-
-/* ---- Definitions shared with assembly code ---------------------------- */
-
-#endif
-
-/* If these change, update src/mips/ffitarget.h. */
-#define FFI_TYPE_VOID 0
-#define FFI_TYPE_INT 1
-#define FFI_TYPE_FLOAT 2
-#define FFI_TYPE_DOUBLE 3
-#if 0 /*@HAVE_LONG_DOUBLE@*/
-#define FFI_TYPE_LONGDOUBLE 4
-#else
-#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
-#endif
-#define FFI_TYPE_UINT8 5
-#define FFI_TYPE_SINT8 6
-#define FFI_TYPE_UINT16 7
-#define FFI_TYPE_SINT16 8
-#define FFI_TYPE_UINT32 9
-#define FFI_TYPE_SINT32 10
-#define FFI_TYPE_UINT64 11
-#define FFI_TYPE_SINT64 12
-#define FFI_TYPE_STRUCT 13
-#define FFI_TYPE_POINTER 14
-
-/* This should always refer to the last type code (for sanity checks) */
-#define FFI_TYPE_LAST FFI_TYPE_POINTER
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/Modules/_ctypes/libffi_arm_wince/ffi_common.h b/Modules/_ctypes/libffi_arm_wince/ffi_common.h
deleted file mode 100644
index bf879d11da..0000000000
--- a/Modules/_ctypes/libffi_arm_wince/ffi_common.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -----------------------------------------------------------------------
- ffi_common.h - Copyright (c) 1996 Red Hat, Inc.
-
- Common internal definitions and macros. Only necessary for building
- libffi.
- ----------------------------------------------------------------------- */
-
-#ifndef FFI_COMMON_H
-#define FFI_COMMON_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <fficonfig.h>
-
-/* Do not move this. Some versions of AIX are very picky about where
- this is positioned. */
-#ifdef __GNUC__
-# define alloca __builtin_alloca
-#else
-# if HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-# endif
-# endif
-# endif
-#endif
-
-/* Check for the existence of memcpy. */
-#if STDC_HEADERS
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-# define memcpy(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-
-#if defined(FFI_DEBUG)
-#include <stdio.h>
-#endif
-
-#ifdef FFI_DEBUG
-/*@exits@*/ void ffi_assert(/*@temp@*/ char *expr, /*@temp@*/ char *file, int line);
-void ffi_stop_here(void);
-void ffi_type_test(/*@temp@*/ /*@out@*/ ffi_type *a, /*@temp@*/ char *file, int line);
-
-#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
-#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
-#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
-#else
-#define FFI_ASSERT(x)
-#define FFI_ASSERT_AT(x, f, l)
-#define FFI_ASSERT_VALID_TYPE(x)
-#endif
-
-#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
-
-/* Perform machine dependent cif processing */
-ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
-
-/* Extended cif, used in callback from assembly routine */
-typedef struct
-{
- /*@dependent@*/ ffi_cif *cif;
- /*@dependent@*/ void *rvalue;
- /*@dependent@*/ void **avalue;
-} extended_cif;
-
-/* Terse sized type definitions. */
-#if defined(__GNUC__)
-
-typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
-typedef signed int SINT8 __attribute__((__mode__(__QI__)));
-typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
-typedef signed int SINT16 __attribute__((__mode__(__HI__)));
-typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
-typedef signed int SINT32 __attribute__((__mode__(__SI__)));
-typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
-typedef signed int SINT64 __attribute__((__mode__(__DI__)));
-
-#elif defined(_MSC_VER)
-
-typedef unsigned __int8 UINT8;
-typedef signed __int8 SINT8;
-typedef unsigned __int16 UINT16;
-typedef signed __int16 SINT16;
-typedef unsigned __int32 UINT32;
-typedef signed __int32 SINT32;
-typedef unsigned __int64 UINT64;
-typedef signed __int64 SINT64;
-
-#else
-#error "Need typedefs here"
-#endif
-
-typedef float FLOAT32;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/Modules/_ctypes/libffi_arm_wince/fficonfig.h b/Modules/_ctypes/libffi_arm_wince/fficonfig.h
deleted file mode 100644
index 3c7964c934..0000000000
--- a/Modules/_ctypes/libffi_arm_wince/fficonfig.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* fficonfig.h created manually for Windows CE on ARM */
-/* fficonfig.h.in. Generated from configure.ac by autoheader. */
-
-/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
-#define BYTEORDER 1234
-
-/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
- systems. This function is required for `alloca.c' support on those systems.
- */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define to 1 if using `alloca.c'. */
-/* #undef C_ALLOCA */
-
-/* Define to the flags needed for the .section .eh_frame directive. */
-/* #undef EH_FRAME_FLAGS */
-
-/* Define this if you want extra debugging. */
-#ifdef DEBUG /* Defined by the project settings for Debug builds */
-#define FFI_DEBUG
-#else
-#undef FFI_DEBUG
-#endif
-
-/* Define this is you do not want support for the raw API. */
-/* #undef FFI_NO_RAW_API */
-
-/* Define this is you do not want support for aggregate types. */
-/* #undef FFI_NO_STRUCTS */
-
-/* Define to 1 if you have `alloca', as a function or macro. */
-#define HAVE_ALLOCA 1
-
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
- */
-/* #undef HAVE_ALLOCA_H */
-
-/* Define if your assembler supports .register. */
-/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
-
-/* Define if your assembler and linker support unaligned PC relative relocs.
- */
-/* #undef HAVE_AS_SPARC_UA_PCREL */
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-/* #undef HAVE_INTTYPES_H */
-
-/* Define if you have the long double type and it is bigger than a double */
-/* This differs from the MSVC build, but even there it should not be defined */
-/* #undef HAVE_LONG_DOUBLE */
-
-/* Define to 1 if you have the `memcpy' function. */
-#define HAVE_MEMCPY 1
-
-/* Define to 1 if you have the <memory.h> header file. */
-/* WinCE has this but I don't think we need to use it */
-/* #undef HAVE_MEMORY_H */
-
-/* Define to 1 if you have the `mmap' function. */
-/* #undef HAVE_MMAP */
-
-/* Define if mmap with MAP_ANON(YMOUS) works. */
-/* #undef HAVE_MMAP_ANON */
-
-/* Define if mmap of /dev/zero works. */
-/* #undef HAVE_MMAP_DEV_ZERO */
-
-/* Define if read-only mmap of a plain file works. */
-/* #undef HAVE_MMAP_FILE */
-
-/* Define if .eh_frame sections should be read-only. */
-/* #undef HAVE_RO_EH_FRAME */
-
-/* Define to 1 if you have the <stdint.h> header file. */
-/* #undef HAVE_STDINT_H */
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-/* #undef HAVE_STRINGS_H */
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the <sys/mman.h> header file. */
-/* #undef HAVE_SYS_MMAN_H */
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-/* #undef HAVE_SYS_STAT_H */
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-/* #undef HAVE_SYS_TYPES_H */
-
-/* Define to 1 if you have the <unistd.h> header file. */
-/* #undef HAVE_UNISTD_H */
-
-/* Define if the host machine stores words of multi-word integers in
- big-endian order. */
-/* #undef HOST_WORDS_BIG_ENDIAN */
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
-
-/* Name of package */
-/* #undef PACKAGE */
-
-/* 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 version of this package. */
-/* #undef PACKAGE_VERSION */
-
-/* The number of bytes in type double */
-#define SIZEOF_DOUBLE 8
-
-/* The number of bytes in type long double */
-#define SIZEOF_LONG_DOUBLE 8
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown */
-/* #undef STACK_DIRECTION */
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define this if you are using Purify and want to suppress spurious messages.
- */
-/* #undef USING_PURIFY */
-
-/* Version number of package */
-/* #undef VERSION */
-
-/* whether byteorder is bigendian */
-/* #undef WORDS_BIGENDIAN */
-
-#define alloca _alloca
-
-#define abort() exit(999)
diff --git a/Modules/_ctypes/libffi_arm_wince/ffitarget.h b/Modules/_ctypes/libffi_arm_wince/ffitarget.h
deleted file mode 100644
index 2627b25777..0000000000
--- a/Modules/_ctypes/libffi_arm_wince/ffitarget.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -----------------------------------------------------------------*-C-*-
- ffitarget.h - Copyright (c) 1996-2003 Red Hat, Inc.
- Target configuration macros for ARM.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- ``Software''), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
-
- ----------------------------------------------------------------------- */
-
-#ifndef LIBFFI_TARGET_H
-#define LIBFFI_TARGET_H
-
-#ifndef LIBFFI_ASM
-typedef unsigned long ffi_arg;
-typedef signed long ffi_sarg;
-
-typedef enum ffi_abi {
- FFI_FIRST_ABI = 0,
- FFI_SYSV,
- FFI_DEFAULT_ABI = FFI_SYSV,
- FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
-} ffi_abi;
-#endif
-
-/* ---- Definitions for closures ----------------------------------------- */
-
-#define FFI_CLOSURES 1
-#define FFI_TRAMPOLINE_SIZE 12
-
-#define FFI_NATIVE_RAW_API 0
-
-#endif
-
diff --git a/Modules/_ctypes/libffi_arm_wince/prep_cif.c b/Modules/_ctypes/libffi_arm_wince/prep_cif.c
deleted file mode 100644
index 9edce2f65b..0000000000
--- a/Modules/_ctypes/libffi_arm_wince/prep_cif.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/* -----------------------------------------------------------------------
- prep_cif.c - Copyright (c) 1996, 1998 Red Hat, Inc.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- ``Software''), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice shall be included
- in all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
- ----------------------------------------------------------------------- */
-
-#include <ffi.h>
-#include <ffi_common.h>
-#include <stdlib.h>
-
-
-/* Round up to FFI_SIZEOF_ARG. */
-
-#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
-
-/* Perform machine independent initialization of aggregate type
- specifications. */
-
-static ffi_status initialize_aggregate(/*@out@*/ ffi_type *arg)
-{
- ffi_type **ptr;
-
- FFI_ASSERT(arg != NULL);
-
- /*@-usedef@*/
-
- FFI_ASSERT(arg->elements != NULL);
- FFI_ASSERT(arg->size == 0);
- FFI_ASSERT(arg->alignment == 0);
-
- ptr = &(arg->elements[0]);
-
- while ((*ptr) != NULL)
- {
- if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
- return FFI_BAD_TYPEDEF;
-
- /* Perform a sanity check on the argument type */
- FFI_ASSERT_VALID_TYPE(*ptr);
-
- arg->size = ALIGN(arg->size, (*ptr)->alignment);
- arg->size += (*ptr)->size;
-
- arg->alignment = (arg->alignment > (*ptr)->alignment) ?
- arg->alignment : (*ptr)->alignment;
-
- ptr++;
- }
-
- /* Structure size includes tail padding. This is important for
- structures that fit in one register on ABIs like the PowerPC64
- Linux ABI that right justify small structs in a register.
- It's also needed for nested structure layout, for example
- struct A { long a; char b; }; struct B { struct A x; char y; };
- should find y at an offset of 2*sizeof(long) and result in a
- total size of 3*sizeof(long). */
- arg->size = ALIGN (arg->size, arg->alignment);
-
- if (arg->size == 0)
- return FFI_BAD_TYPEDEF;
- else
- return FFI_OK;
-
- /*@=usedef@*/
-}
-
-/* Perform machine independent ffi_cif preparation, then call
- machine dependent routine. */
-
-ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
- ffi_abi abi, unsigned int nargs,
- /*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
- /*@dependent@*/ ffi_type **atypes)
-{
- unsigned bytes = 0;
- unsigned int i;
- ffi_type **ptr;
-
- FFI_ASSERT(cif != NULL);
- FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
-
- cif->abi = abi;
- cif->arg_types = atypes;
- cif->nargs = nargs;
- cif->rtype = rtype;
-
- cif->flags = 0;
-
- /* Initialize the return type if necessary */
- /*@-usedef@*/
- if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
- return FFI_BAD_TYPEDEF;
- /*@=usedef@*/
-
- /* Perform a sanity check on the return type */
- FFI_ASSERT_VALID_TYPE(cif->rtype);
-
- /* x86-64 and s390 stack space allocation is handled in prep_machdep. */
-#if !defined M68K && !defined __x86_64__ && !defined S390
- /* Make space for the return structure pointer */
- if (cif->rtype->type == FFI_TYPE_STRUCT
- /* MSVC returns small structures in registers. But we have a different
- workaround: pretend int32 or int64 return type, and converting to
- structure afterwards. */
-#ifdef SPARC
- && (cif->abi != FFI_V9 || cif->rtype->size > 32)
-#endif
- )
- bytes = STACK_ARG_SIZE(sizeof(void*));
-#endif
-
- for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
- {
-
- /* Initialize any uninitialized aggregate type definitions */
- if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
- return FFI_BAD_TYPEDEF;
-
- /* Perform a sanity check on the argument type, do this
- check after the initialization. */
- FFI_ASSERT_VALID_TYPE(*ptr);
-
-#if !defined __x86_64__ && !defined S390
-#ifdef SPARC
- if (((*ptr)->type == FFI_TYPE_STRUCT
- && ((*ptr)->size > 16 || cif->abi != FFI_V9))
- || ((*ptr)->type == FFI_TYPE_LONGDOUBLE
- && cif->abi != FFI_V9))
- bytes += sizeof(void*);
- else
-#endif
- {
-#ifndef _MSC_VER
- /* Don't know if this is a libffi bug or not. At least on
- Windows with MSVC, function call parameters are *not*
- aligned in the same way as structure fields are, they are
- only aligned in integer boundaries.
-
- This doesn't do any harm for cdecl functions and closures,
- since the caller cleans up the stack, but it is wrong for
- stdcall functions where the callee cleans.
- */
-
- /* Add any padding if necessary */
- if (((*ptr)->alignment - 1) & bytes)
- bytes = ALIGN(bytes, (*ptr)->alignment);
-
-#endif
- bytes += STACK_ARG_SIZE((*ptr)->size);
- }
-#endif
- }
-
- cif->bytes = bytes;
-
- /* Perform machine dependent cif processing */
- return ffi_prep_cif_machdep(cif);
-}
diff --git a/Modules/_ctypes/libffi_arm_wince/sysv.asm b/Modules/_ctypes/libffi_arm_wince/sysv.asm
deleted file mode 100644
index db78b9085e..0000000000
--- a/Modules/_ctypes/libffi_arm_wince/sysv.asm
+++ /dev/null
@@ -1,228 +0,0 @@
-; -----------------------------------------------------------------------
-; sysv.S - Copyright (c) 1998 Red Hat, Inc.
-;
-; ARM Foreign Function Interface
-;
-; Permission is hereby granted, free of charge, to any person obtaining
-; a copy of this software and associated documentation files (the
-; ``Software''), to deal in the Software without restriction, including
-; without limitation the rights to use, copy, modify, merge, publish,
-; distribute, sublicense, and/or sell copies of the Software, and to
-; permit persons to whom the Software is furnished to do so, subject to
-; the following conditions:
-;
-; The above copyright notice and this permission notice shall be included
-; in all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
-; OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-; IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-; OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-; ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-; OTHER DEALINGS IN THE SOFTWARE.
-; ----------------------------------------------------------------------- */
-
-;#define LIBFFI_ASM
-;#include <fficonfig.h>
-;#include <ffi.h>
-;#ifdef HAVE_MACHINE_ASM_H
-;#include <machine/asm.h>
-;#else
-;#ifdef __USER_LABEL_PREFIX__
-;#define CONCAT1(a, b) CONCAT2(a, b)
-;#define CONCAT2(a, b) a ## b
-
-;/* Use the right prefix for global labels. */
-;#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
-;#else
-;#define CNAME(x) x
-;#endif
-;#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
-;#endif
-
-
-FFI_TYPE_VOID EQU 0
-FFI_TYPE_INT EQU 1
-FFI_TYPE_FLOAT EQU 2
-FFI_TYPE_DOUBLE EQU 3
-;FFI_TYPE_LONGDOUBLE EQU 4
-FFI_TYPE_UINT8 EQU 5
-FFI_TYPE_SINT8 EQU 6
-FFI_TYPE_UINT16 EQU 7
-FFI_TYPE_SINT16 EQU 8
-FFI_TYPE_UINT32 EQU 9
-FFI_TYPE_SINT32 EQU 10
-FFI_TYPE_UINT64 EQU 11
-FFI_TYPE_SINT64 EQU 12
-FFI_TYPE_STRUCT EQU 13
-FFI_TYPE_POINTER EQU 14
-
-; WinCE always uses software floating point (I think)
-__SOFTFP__ EQU {TRUE}
-
-
- AREA |.text|, CODE, ARM ; .text
-
-
- ; a1: ffi_prep_args
- ; a2: &ecif
- ; a3: cif->bytes
- ; a4: fig->flags
- ; sp+0: ecif.rvalue
- ; sp+4: fn
-
- ; This assumes we are using gas.
-;ENTRY(ffi_call_SYSV)
-
- EXPORT |ffi_call_SYSV|
-
-|ffi_call_SYSV| PROC
-
- ; Save registers
- stmfd sp!, {a1-a4, fp, lr}
- mov fp, sp
-
- ; Make room for all of the new args.
- sub sp, fp, a3
-
- ; Place all of the ffi_prep_args in position
- mov ip, a1
- mov a1, sp
- ; a2 already set
-
- ; And call
- mov lr, pc
- mov pc, ip
-
- ; move first 4 parameters in registers
- ldr a1, [sp, #0]
- ldr a2, [sp, #4]
- ldr a3, [sp, #8]
- ldr a4, [sp, #12]
-
- ; and adjust stack
- ldr ip, [fp, #8]
- cmp ip, #16
- movge ip, #16
- add sp, sp, ip
-
- ; call function
- mov lr, pc
- ldr pc, [fp, #28]
-
- ; Remove the space we pushed for the args
- mov sp, fp
-
- ; Load a3 with the pointer to storage for the return value
- ldr a3, [sp, #24]
-
- ; Load a4 with the return type code
- ldr a4, [sp, #12]
-
- ; If the return value pointer is NULL, assume no return value.
- cmp a3, #0
- beq call_epilogue
-
-; return INT
- cmp a4, #FFI_TYPE_INT
- streq a1, [a3]
- beq call_epilogue
-
-; return FLOAT
- cmp a4, #FFI_TYPE_FLOAT
- [ __SOFTFP__ ;ifdef __SOFTFP__
- streq a1, [a3]
- | ;else
- stfeqs f0, [a3]
- ] ;endif
- beq call_epilogue
-
-; return DOUBLE or LONGDOUBLE
- cmp a4, #FFI_TYPE_DOUBLE
- [ __SOFTFP__ ;ifdef __SOFTFP__
- stmeqia a3, {a1, a2}
- | ;else
- stfeqd f0, [a3]
- ] ;endif
- beq call_epilogue
-
-; return SINT64 or UINT64
- cmp a4, #FFI_TYPE_SINT64
- stmeqia a3, {a1, a2}
-
-call_epilogue
- ldmfd sp!, {a1-a4, fp, pc}
-
-;.ffi_call_SYSV_end:
- ;.size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
- ENDP
-
-
-RESERVE_RETURN EQU 16
-
- ; This function is called by the trampoline
- ; It is NOT callable from C
- ; ip = pointer to struct ffi_closure
-
- IMPORT |ffi_closure_SYSV_inner|
-
- EXPORT |ffi_closure_SYSV|
-|ffi_closure_SYSV| PROC
-
- ; Store the argument registers on the stack
- stmfd sp!, {a1-a4}
- ; Push the return address onto the stack
- stmfd sp!, {lr}
-
- mov a1, ip ; first arg = address of ffi_closure
- add a2, sp, #4 ; second arg = sp+4 (points to saved a1)
-
- ; Allocate space for a non-struct return value
- sub sp, sp, #RESERVE_RETURN
- mov a3, sp ; third arg = return value address
-
- ; static unsigned int
- ; ffi_closure_SYSV_inner (ffi_closure *closure, char *in_args, void *rvalue)
- bl ffi_closure_SYSV_inner
- ; a1 now contains the return type code
-
- ; At this point the return value is on the stack
- ; Transfer it to the correct registers if necessary
-
-; return INT
- cmp a1, #FFI_TYPE_INT
- ldreq a1, [sp]
- beq closure_epilogue
-
-; return FLOAT
- cmp a1, #FFI_TYPE_FLOAT
- [ __SOFTFP__ ;ifdef __SOFTFP__
- ldreq a1, [sp]
- | ;else
- stfeqs f0, [sp]
- ] ;endif
- beq closure_epilogue
-
-; return DOUBLE or LONGDOUBLE
- cmp a1, #FFI_TYPE_DOUBLE
- [ __SOFTFP__ ;ifdef __SOFTFP__
- ldmeqia sp, {a1, a2}
- | ;else
- stfeqd f0, [sp]
- ] ;endif
- beq closure_epilogue
-
-; return SINT64 or UINT64
- cmp a1, #FFI_TYPE_SINT64
- ldmeqia sp, {a1, a2}
-
-closure_epilogue
- add sp, sp, #RESERVE_RETURN ; remove return value buffer
- ldmfd sp!, {ip} ; ip = pop return address
- add sp, sp, #16 ; remove saved argument registers {a1-a4} from the stack
- mov pc, ip ; return
-
- ENDP ; ffi_closure_SYSV
-
- END
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 6c0fda901a..716d1e9e8e 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -489,7 +489,7 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
if (isStruct && !isPacked) {
char *fieldfmt = dict->format ? dict->format : "B";
- char *fieldname = _PyUnicode_AsString(name);
+ char *fieldname = PyUnicode_AsUTF8(name);
char *ptr;
Py_ssize_t len;
char *buf;