summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2014-01-08 21:20:57 +0100
committerStefan Behnel <stefan_ml@behnel.de>2014-01-08 21:20:57 +0100
commit35beaa0a228204a448bd58a8c4f87383c4c0a2d4 (patch)
tree0b1a54ac8aa43b3119fe509fa7d94eb092a9bc95 /src
parent24f9984df7fe3582cf3edb478efe9167a58f7460 (diff)
downloadpython-lxml-35beaa0a228204a448bd58a8c4f87383c4c0a2d4.tar.gz
try fixing build with MSVC
Diffstat (limited to 'src')
-rw-r--r--src/lxml/includes/etree_defs.h3
-rw-r--r--src/lxml/lxml_endian.h8
-rw-r--r--src/lxml/parser.pxi4
-rw-r--r--src/lxml/python.pxd4
4 files changed, 13 insertions, 6 deletions
diff --git a/src/lxml/includes/etree_defs.h b/src/lxml/includes/etree_defs.h
index 0d2ff7a9..2929b51d 100644
--- a/src/lxml/includes/etree_defs.h
+++ b/src/lxml/includes/etree_defs.h
@@ -239,9 +239,6 @@ long _ftol2( double dblSource ) { return _ftol( dblSource ); }
#define _getNs(c_node) \
(((c_node)->ns == 0) ? 0 : ((c_node)->ns->href))
-#include <stdint.h>
-#define _lx__is_big_endian() \
- (((union {uint32_t i; char c[4];}) {0x01020304}).c[0] == 1)
/* Macro pair implementation of a depth first tree walker
*
diff --git a/src/lxml/lxml_endian.h b/src/lxml/lxml_endian.h
new file mode 100644
index 00000000..01411343
--- /dev/null
+++ b/src/lxml/lxml_endian.h
@@ -0,0 +1,8 @@
+#ifndef PY_BIG_ENDIAN
+#include <stdint.h>
+static CYTHON_INLINE int _lx__is_big_endian(void) {
+ union {uint32_t i; char c[4];} x = {0x01020304};
+ return x.c[0] == 1;
+}
+#define PY_BIG_ENDIAN _lx__is_big_endian()
+#endif
diff --git a/src/lxml/parser.pxi b/src/lxml/parser.pxi
index 3bf5c063..95e9f637 100644
--- a/src/lxml/parser.pxi
+++ b/src/lxml/parser.pxi
@@ -969,13 +969,13 @@ cdef class _BaseParser:
c_encoding = 'ISO-8859-1'
elif c_kind == 2:
py_buffer_len *= 2
- if python._is_big_endian():
+ if python.PY_BIG_ENDIAN:
c_encoding = 'UTF-16BE' # actually UCS-2
else:
c_encoding = 'UTF-16LE' # actually UCS-2
elif c_kind == 4:
py_buffer_len *= 4
- if python._is_big_endian():
+ if python.PY_BIG_ENDIAN:
c_encoding = 'UCS-4BE'
else:
c_encoding = 'UCS-4LE'
diff --git a/src/lxml/python.pxd b/src/lxml/python.pxd
index 91855274..9a3003df 100644
--- a/src/lxml/python.pxd
+++ b/src/lxml/python.pxd
@@ -124,10 +124,12 @@ cdef extern from "pythread.h":
NOWAIT_LOCK
cdef extern from "etree_defs.h": # redefines some functions as macros
- cdef bint _is_big_endian "_lx__is_big_endian" ()
cdef bint _isString(object obj)
cdef const_char* _fqtypename(object t)
cdef object PY_NEW(object t)
cdef bint LXML_UNICODE_STRINGS
cdef bint IS_PYTHON3
cdef bint IS_PYPY
+
+cdef extern from "lxml_endian.h":
+ cdef bint PY_BIG_ENDIAN # defined in later Py3.x versions