summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/python/python')
-rw-r--r--meta/recipes-devtools/python/python/01-use-proper-tools-for-cross-build.patch138
-rw-r--r--meta/recipes-devtools/python/python/03-fix-tkinter-detection.patch42
-rw-r--r--meta/recipes-devtools/python/python/05-enable-ctypes-cross-build.patch30
-rw-r--r--meta/recipes-devtools/python/python/06-avoid_usr_lib_termcap_path_in_linking.patch33
-rw-r--r--meta/recipes-devtools/python/python/06-ctypes-libffi-fix-configure.patch44
-rw-r--r--meta/recipes-devtools/python/python/CVE-2013-4073_py27.patch251
-rw-r--r--meta/recipes-devtools/python/python/add-md5module-support.patch18
-rw-r--r--meta/recipes-devtools/python/python/avoid_warning_about_tkinter.patch30
-rw-r--r--meta/recipes-devtools/python/python/avoid_warning_for_sunos_specific_module.patch23
-rw-r--r--meta/recipes-devtools/python/python/builddir.patch55
-rw-r--r--meta/recipes-devtools/python/python/cgi_py.patch23
-rw-r--r--meta/recipes-devtools/python/python/check-if-target-is-64b-not-host.patch57
-rw-r--r--meta/recipes-devtools/python/python/ctypes-libffi-aarch64.patch22
-rw-r--r--meta/recipes-devtools/python/python/fix-makefile-for-ptest.patch33
-rw-r--r--meta/recipes-devtools/python/python/fix_for_using_different_libdir.patch82
-rw-r--r--meta/recipes-devtools/python/python/gcc-4.8-fix-configure-Wformat.patch20
-rw-r--r--meta/recipes-devtools/python/python/host_include_contamination.patch27
-rw-r--r--meta/recipes-devtools/python/python/json-flaw-fix.patch27
-rw-r--r--meta/recipes-devtools/python/python/libffi-aarch64.patch1608
-rw-r--r--meta/recipes-devtools/python/python/multilib.patch257
-rw-r--r--meta/recipes-devtools/python/python/parallel-makeinst-create-bindir.patch19
-rw-r--r--meta/recipes-devtools/python/python/posix_close.patch43
-rw-r--r--meta/recipes-devtools/python/python/pypirc-secure.patch35
-rw-r--r--meta/recipes-devtools/python/python/python-2.7.3-CVE-2012-2135.patch73
-rw-r--r--meta/recipes-devtools/python/python/python-2.7.3-CVE-2013-1752-smtplib-fix.patch101
-rw-r--r--meta/recipes-devtools/python/python/python-2.7.3-CVE-2014-1912.patch26
-rw-r--r--meta/recipes-devtools/python/python/python-2.7.3-CVE-2014-7185.patch75
-rw-r--r--meta/recipes-devtools/python/python/python-2.7.3-berkeley-db-5.3.patch1572
-rw-r--r--meta/recipes-devtools/python/python/python-2.7.3-remove-bsdb-rpath.patch28
-rw-r--r--meta/recipes-devtools/python/python/python-fix-build-error-with-Readline-6.3.patch62
-rw-r--r--meta/recipes-devtools/python/python/python2.7.3-nossl3.patch37
-rw-r--r--meta/recipes-devtools/python/python/remove_sqlite_rpath.patch19
-rw-r--r--meta/recipes-devtools/python/python/run-ptest5
-rw-r--r--meta/recipes-devtools/python/python/search_db_h_in_inc_dirs_and_avoid_warning.patch40
-rw-r--r--meta/recipes-devtools/python/python/setup_py_skip_cross_import_check.patch27
-rw-r--r--meta/recipes-devtools/python/python/setuptweaks.patch57
-rw-r--r--meta/recipes-devtools/python/python/sitecustomize.py45
37 files changed, 5084 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python/01-use-proper-tools-for-cross-build.patch b/meta/recipes-devtools/python/python/01-use-proper-tools-for-cross-build.patch
new file mode 100644
index 0000000000..691beada03
--- /dev/null
+++ b/meta/recipes-devtools/python/python/01-use-proper-tools-for-cross-build.patch
@@ -0,0 +1,138 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3# We need to ensure our host tools get run during build, not the freshly
4# built cross-tools (this will not work), so we introduce HOSTPYTHON and HOSTPGEN.
5# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille-media.de>
6
7Index: Python-2.7.2/Makefile.pre.in
8===================================================================
9--- Python-2.7.2.orig/Makefile.pre.in
10+++ Python-2.7.2/Makefile.pre.in
11@@ -182,6 +182,7 @@ UNICODE_OBJS= @UNICODE_OBJS@
12
13 PYTHON= python$(EXE)
14 BUILDPYTHON= python$(BUILDEXE)
15+HOSTPYTHON= $(BUILDPYTHON)
16
17 # The task to run while instrument when building the profile-opt target
18 PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
19@@ -214,7 +215,7 @@ LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
20 ##########################################################################
21 # Parser
22 PGEN= Parser/pgen$(EXE)
23-
24+HOSTPGEN= $(PGEN)$(EXE)
25 POBJS= \
26 Parser/acceler.o \
27 Parser/grammar1.o \
28@@ -401,14 +402,14 @@ $(BUILDPYTHON): Modules/python.o $(LIBRA
29 $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
30
31 platform: $(BUILDPYTHON)
32- $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
33+ $(RUNSHARED) ./$(BUILDPYTHON) -E -c 'import sys ; from distutils.util import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
34
35
36 # Build the shared modules
37 sharedmods: $(BUILDPYTHON)
38 @case $$MAKEFLAGS in \
39- *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
40- *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
41+ *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \
42+ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \
43 esac
44
45 # Build static library
46@@ -542,7 +543,7 @@ Modules/python.o: $(srcdir)/Modules/pyth
47 $(GRAMMAR_H) $(GRAMMAR_C): Parser/pgen.stamp
48 Parser/pgen.stamp: $(PGEN) $(GRAMMAR_INPUT)
49 -@$(INSTALL) -d Include
50- $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
51+ $(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
52 -touch Parser/pgen.stamp
53
54 $(PGEN): $(PGENOBJS)
55@@ -926,25 +927,25 @@ libinstall: build_all $(srcdir)/Lib/$(PL
56 done
57 $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
58 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
59- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
60+ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
61 -d $(LIBDEST) -f \
62 -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
63 $(DESTDIR)$(LIBDEST)
64 PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
65- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
66+ $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
67 -d $(LIBDEST) -f \
68 -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
69 $(DESTDIR)$(LIBDEST)
70 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
71- ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
72+ $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
73 -d $(LIBDEST)/site-packages -f \
74 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
75 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
76- ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
77+ $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
78 -d $(LIBDEST)/site-packages -f \
79 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
80 -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
81- ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
82+ $(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
83
84 # Create the PLATDIR source directory, if one wasn't distributed..
85 $(srcdir)/Lib/$(PLATDIR):
86@@ -1049,7 +1050,7 @@ libainstall: all python-config
87 # Install the dynamically loadable modules
88 # This goes into $(exec_prefix)
89 sharedinstall: sharedmods
90- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
91+ $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \
92 --prefix=$(prefix) \
93 --install-scripts=$(BINDIR) \
94 --install-platlib=$(DESTSHARED) \
95Index: Python-2.7.2/setup.py
96===================================================================
97--- Python-2.7.2.orig/setup.py
98+++ Python-2.7.2/setup.py
99@@ -313,6 +313,7 @@ class PyBuildExt(build_ext):
100 self.failed.append(ext.name)
101 self.announce('*** WARNING: renaming "%s" since importing it'
102 ' failed: %s' % (ext.name, why), level=3)
103+ return
104 assert not self.inplace
105 basename, tail = os.path.splitext(ext_filename)
106 newname = basename + "_failed" + tail
107@@ -369,8 +370,8 @@ class PyBuildExt(build_ext):
108
109 def detect_modules(self):
110 # Ensure that /usr/local is always used
111- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
112- add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
113+ #add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
114+ #add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
115 self.add_multiarch_paths()
116
117 # Add paths specified in the environment variables LDFLAGS and
118@@ -475,6 +476,9 @@ class PyBuildExt(build_ext):
119
120 # XXX Omitted modules: gl, pure, dl, SGI-specific modules
121
122+ lib_dirs = [ os.getenv("STAGING_LIBDIR"), os.getenv("STAGING_BASELIBDIR") ]
123+ inc_dirs = [ os.getenv("STAGING_INCDIR") ]
124+
125 #
126 # The following modules are all pretty straightforward, and compile
127 # on pretty much any POSIXish platform.
128@@ -677,8 +681,8 @@ class PyBuildExt(build_ext):
129 elif curses_library:
130 readline_libs.append(curses_library)
131 elif self.compiler.find_library_file(lib_dirs +
132- ['/usr/lib/termcap'],
133- 'termcap'):
134+ ['/usr/lib/termcap'],
135+ 'termcap'):
136 readline_libs.append('termcap')
137 exts.append( Extension('readline', ['readline.c'],
138 library_dirs=['/usr/lib/termcap'],
diff --git a/meta/recipes-devtools/python/python/03-fix-tkinter-detection.patch b/meta/recipes-devtools/python/python/03-fix-tkinter-detection.patch
new file mode 100644
index 0000000000..d74e4b1776
--- /dev/null
+++ b/meta/recipes-devtools/python/python/03-fix-tkinter-detection.patch
@@ -0,0 +1,42 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3# We need to supply STAGING_INCDIR here, otherwise the Tk headers
4# will not be found.
5# Signed-Off: Michael 'Mickey' Lauer <mickey@vanille.de>
6
7Index: Python-2.6.1/setup.py
8===================================================================
9--- Python-2.6.1.orig/setup.py
10+++ Python-2.6.1/setup.py
11@@ -1543,7 +1543,7 @@ class PyBuildExt(build_ext):
12 dotversion = dotversion[:-1] + '.' + dotversion[-1]
13 tcl_include_sub = []
14 tk_include_sub = []
15- for dir in inc_dirs:
16+ for dir in [os.getenv("STAGING_INCDIR")]:
17 tcl_include_sub += [dir + os.sep + "tcl" + dotversion]
18 tk_include_sub += [dir + os.sep + "tk" + dotversion]
19 tk_include_sub += tcl_include_sub
20@@ -1562,22 +1562,6 @@ class PyBuildExt(build_ext):
21 if dir not in include_dirs:
22 include_dirs.append(dir)
23
24- # Check for various platform-specific directories
25- if platform == 'sunos5':
26- include_dirs.append('/usr/openwin/include')
27- added_lib_dirs.append('/usr/openwin/lib')
28- elif os.path.exists('/usr/X11R6/include'):
29- include_dirs.append('/usr/X11R6/include')
30- added_lib_dirs.append('/usr/X11R6/lib64')
31- added_lib_dirs.append('/usr/X11R6/lib')
32- elif os.path.exists('/usr/X11R5/include'):
33- include_dirs.append('/usr/X11R5/include')
34- added_lib_dirs.append('/usr/X11R5/lib')
35- else:
36- # Assume default location for X11
37- include_dirs.append('/usr/X11/include')
38- added_lib_dirs.append('/usr/X11/lib')
39-
40 # If Cygwin, then verify that X is installed before proceeding
41 if platform == 'cygwin':
42 x11_inc = find_file('X11/Xlib.h', [], include_dirs)
diff --git a/meta/recipes-devtools/python/python/05-enable-ctypes-cross-build.patch b/meta/recipes-devtools/python/python/05-enable-ctypes-cross-build.patch
new file mode 100644
index 0000000000..a68a20620a
--- /dev/null
+++ b/meta/recipes-devtools/python/python/05-enable-ctypes-cross-build.patch
@@ -0,0 +1,30 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3# CTypes need to know the actual host we are building on.
4# Signed-Off: Michael Dietrich <mdt@emdete.de>
5
6Index: Python-2.6.1/setup.py
7===================================================================
8--- Python-2.6.1.orig/setup.py
9+++ Python-2.6.1/setup.py
10@@ -1656,16 +1656,16 @@ class PyBuildExt(build_ext):
11 ffi_configfile):
12 from distutils.dir_util import mkpath
13 mkpath(ffi_builddir)
14- config_args = []
15+ config_args = ['--host=%s' % os.environ["HOST_SYS"], ]
16
17 # Pass empty CFLAGS because we'll just append the resulting
18 # CFLAGS to Python's; -g or -O2 is to be avoided.
19- cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \
20- % (ffi_builddir, ffi_srcdir, " ".join(config_args))
21+ cmd = "(cd %s && autoconf -W cross) && (cd %s && env CFLAGS='' '%s/configure' %s)" \
22+ % (ffi_srcdir, ffi_builddir, ffi_srcdir, " ".join(config_args))
23
24 res = os.system(cmd)
25 if res or not os.path.exists(ffi_configfile):
26- print "Failed to configure _ctypes module"
27+ print "Failed to configure _ctypes module (res=%d) or missing conffile=%s" % ( res, ffi_configfile )
28 return False
29
30 fficonfig = {}
diff --git a/meta/recipes-devtools/python/python/06-avoid_usr_lib_termcap_path_in_linking.patch b/meta/recipes-devtools/python/python/06-avoid_usr_lib_termcap_path_in_linking.patch
new file mode 100644
index 0000000000..f8ab0e71e9
--- /dev/null
+++ b/meta/recipes-devtools/python/python/06-avoid_usr_lib_termcap_path_in_linking.patch
@@ -0,0 +1,33 @@
1Upstream-Status: Pending
2
3The poison directories patch has detected library path issue while
4compiling the python in cross environment, as seen bellow.
5
6warning: library search path "/usr/lib/termcap" is unsafe for cross-compilation
7
8This Patch fixes this issue in the python build environment.
911 Oct 2010
10Nitin A Kamble <nitin.a.kamble@intel.com>
11
122011/09/29
13Rebased for python 2.7.2
14Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
15
16Index: Python-2.7.2/setup.py
17===================================================================
18--- Python-2.7.2.orig/setup.py
19+++ Python-2.7.2/setup.py
20@@ -680,12 +680,10 @@ class PyBuildExt(build_ext):
21 pass # Issue 7384: Already linked against curses or tinfo.
22 elif curses_library:
23 readline_libs.append(curses_library)
24- elif self.compiler.find_library_file(lib_dirs +
25- ['/usr/lib/termcap'],
26+ elif self.compiler.find_library_file(lib_dirs,
27 'termcap'):
28 readline_libs.append('termcap')
29 exts.append( Extension('readline', ['readline.c'],
30- library_dirs=['/usr/lib/termcap'],
31 extra_link_args=readline_extra_link_args,
32 libraries=readline_libs) )
33 else:
diff --git a/meta/recipes-devtools/python/python/06-ctypes-libffi-fix-configure.patch b/meta/recipes-devtools/python/python/06-ctypes-libffi-fix-configure.patch
new file mode 100644
index 0000000000..abd63d2a96
--- /dev/null
+++ b/meta/recipes-devtools/python/python/06-ctypes-libffi-fix-configure.patch
@@ -0,0 +1,44 @@
1This fixes configure issues with recent autoconf, e.g:
2 autoreconf: Entering directory `Modules/_ctypes/libffi'
3 autoreconf: configure.ac: not using Gettext
4 autoreconf: running: aclocal --force
5 configure.ac:26: error: m4_copy: won't overwrite defined macro: _AC_ARG_VAR_PRECIOUS
6 configure.ac:26: the top level
7
8The problem is still present in python-2.6.5 but fixed in python-svn.
9
10Upstream-Status: Accepted [python-svn]
11
12Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
13Acked-by: Martin Jansa <Martin.Jansa@gmail.com>
14Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
15Signed-off-by: Saul Wold <sgw@linux.intel.com>
16
17
182011/09/29
19Rebased for python 2.7.2
20Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
21
22
23Index: Python-2.7.2/Modules/_ctypes/libffi/Makefile.am
24===================================================================
25--- Python-2.7.2.orig/Modules/_ctypes/libffi/Makefile.am
26+++ Python-2.7.2/Modules/_ctypes/libffi/Makefile.am
27@@ -2,7 +2,7 @@
28
29 AUTOMAKE_OPTIONS = foreign subdir-objects
30
31-SUBDIRS = include testsuite man
32+SUBDIRS = include
33
34 EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
35 src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \
36@@ -34,8 +34,6 @@ EXTRA_DIST = LICENSE ChangeLog.v1 Change
37 libtool-version ChangeLog.libffi m4/libtool.m4 \
38 m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4
39
40-info_TEXINFOS = doc/libffi.texi
41-
42 ## ################################################################
43
44 ##
diff --git a/meta/recipes-devtools/python/python/CVE-2013-4073_py27.patch b/meta/recipes-devtools/python/python/CVE-2013-4073_py27.patch
new file mode 100644
index 0000000000..0d17463052
--- /dev/null
+++ b/meta/recipes-devtools/python/python/CVE-2013-4073_py27.patch
@@ -0,0 +1,251 @@
1Upstream-Status: Backport
2
3Signed-off-by: Saul Wold <sgw@linux.intel.com>
4
5diff -r 9ddc63c039ba Lib/test/nullbytecert.pem
6--- /dev/null Thu Jan 01 00:00:00 1970 +0000
7+++ b/Lib/test/nullbytecert.pem Sun Aug 11 18:13:17 2013 +0200
8@@ -0,0 +1,90 @@
9+Certificate:
10+ Data:
11+ Version: 3 (0x2)
12+ Serial Number: 0 (0x0)
13+ Signature Algorithm: sha1WithRSAEncryption
14+ Issuer: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org
15+ Validity
16+ Not Before: Aug 7 13:11:52 2013 GMT
17+ Not After : Aug 7 13:12:52 2013 GMT
18+ Subject: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, OU=Python Core Development, CN=null.python.org\x00example.org/emailAddress=python-dev@python.org
19+ Subject Public Key Info:
20+ Public Key Algorithm: rsaEncryption
21+ Public-Key: (2048 bit)
22+ Modulus:
23+ 00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3:
24+ 03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97:
25+ 16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2:
26+ 88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1:
27+ 32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4:
28+ 56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8:
29+ a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02:
30+ 45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75:
31+ ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91:
32+ 90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d:
33+ 7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30:
34+ 68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7:
35+ f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12:
36+ f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5:
37+ ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb:
38+ d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f:
39+ 9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da:
40+ 2f:85
41+ Exponent: 65537 (0x10001)
42+ X509v3 extensions:
43+ X509v3 Basic Constraints: critical
44+ CA:FALSE
45+ X509v3 Subject Key Identifier:
46+ 88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C
47+ X509v3 Key Usage:
48+ Digital Signature, Non Repudiation, Key Encipherment
49+ X509v3 Subject Alternative Name:
50+ *************************************************************
51+ WARNING: The values for DNS, email and URI are WRONG. OpenSSL
52+ doesn't print the text after a NULL byte.
53+ *************************************************************
54+ DNS:altnull.python.org, email:null@python.org, URI:http://null.python.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1
55+ Signature Algorithm: sha1WithRSAEncryption
56+ ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5:
57+ a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44:
58+ 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37:
59+ 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3:
60+ 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86:
61+ de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac:
62+ 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4:
63+ 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60:
64+ d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5:
65+ 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60:
66+ 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6:
67+ 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d:
68+ 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e:
69+ 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6:
70+ c1:ca:a9:94
71+-----BEGIN CERTIFICATE-----
72+MIIE2DCCA8CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBxTELMAkGA1UEBhMCVVMx
73+DzANBgNVBAgMBk9yZWdvbjESMBAGA1UEBwwJQmVhdmVydG9uMSMwIQYDVQQKDBpQ
74+eXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEgMB4GA1UECwwXUHl0aG9uIENvcmUg
75+RGV2ZWxvcG1lbnQxJDAiBgNVBAMMG251bGwucHl0aG9uLm9yZwBleGFtcGxlLm9y
76+ZzEkMCIGCSqGSIb3DQEJARYVcHl0aG9uLWRldkBweXRob24ub3JnMB4XDTEzMDgw
77+NzEzMTE1MloXDTEzMDgwNzEzMTI1MlowgcUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQI
78+DAZPcmVnb24xEjAQBgNVBAcMCUJlYXZlcnRvbjEjMCEGA1UECgwaUHl0aG9uIFNv
79+ZnR3YXJlIEZvdW5kYXRpb24xIDAeBgNVBAsMF1B5dGhvbiBDb3JlIERldmVsb3Bt
80+ZW50MSQwIgYDVQQDDBtudWxsLnB5dGhvbi5vcmcAZXhhbXBsZS5vcmcxJDAiBgkq
81+hkiG9w0BCQEWFXB5dGhvbi1kZXZAcHl0aG9uLm9yZzCCASIwDQYJKoZIhvcNAQEB
82+BQADggEPADCCAQoCggEBALXq7cn7Rn1vO3aA3TrzA5QLp6bb7B3f/yN0CJ2XFj+j
83+pHs+Gw6WWSUDpybiiKnPec33BFawq3kyblnBMjBU61ioy5HwQqVkJ8vUVjGIUq3P
84+vX/wBmQfzCe4o4uM89gpHyUL9UYGG8oCRa17dgqcv7u5rg0Wq2B1rgY+nHwx3JIv
85+KRrgSwyRkGzpN8WQ1yrXlxWjgI9de0mPVDDUlywcWze1q2kwaEPTM3hLAmD1PESA
86+oY/n8A/RXoeeRs9i/Pm/DGUS8ZPINXk/yOzsR/XvvkTVroIeLZqfmFpnZeF0cHzL
87+08LODkVJJ9zjLdT7SA4vnne4FEbAxDbKAq5qkYzaL4UCAwEAAaOB0DCBzTAMBgNV
88+HRMBAf8EAjAAMB0GA1UdDgQWBBSIWlXAUv9hzVKjNQ/qWpwkOCL3XDALBgNVHQ8E
89+BAMCBeAwgZAGA1UdEQSBiDCBhYIeYWx0bnVsbC5weXRob24ub3JnAGV4YW1wbGUu
90+Y29tgSBudWxsQHB5dGhvbi5vcmcAdXNlckBleGFtcGxlLm9yZ4YpaHR0cDovL251
91+bGwucHl0aG9uLm9yZwBodHRwOi8vZXhhbXBsZS5vcmeHBMAAAgGHECABDbgAAAAA
92+AAAAAAAAAAEwDQYJKoZIhvcNAQEFBQADggEBAKxPRe99SaghcI6IWT7UNkJw9aO9
93+i9eo0Fj2MUqxpKbdb9noRDy2CnHWf7EIYZ1gznXPdwzSN4YCjV5d+Q9xtBaowT0j
94+HPERs1ZuytCNNJTmhyqZ8q6uzMLoht4IqH/FBfpvgaeC5tBTnTT0rD5A/olXeimk
95+kX4LxlEx5RAvpGB2zZVRGr6LobD9rVK91xuHYNIxxxfEGE8tCCWjp0+3ksri9SXx
96+VHWBnbM9YaL32u3hxm8sYB/Yb8WSBavJCWJJqRStVRHM1koZlJmXNx2BX4vPo6iW
97+RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ=
98+-----END CERTIFICATE-----
99diff -r 9ddc63c039ba Lib/test/test_ssl.py
100--- a/Lib/test/test_ssl.py Sun Aug 11 13:04:50 2013 +0300
101+++ b/Lib/test/test_ssl.py Sun Aug 11 18:13:17 2013 +0200
102@@ -25,6 +25,7 @@
103 HOST = test_support.HOST
104 CERTFILE = None
105 SVN_PYTHON_ORG_ROOT_CERT = None
106+NULLBYTECERT = None
107
108 def handle_error(prefix):
109 exc_format = ' '.join(traceback.format_exception(*sys.exc_info()))
110@@ -123,6 +124,27 @@
111 ('DNS', 'projects.forum.nokia.com'))
112 )
113
114+ def test_parse_cert_CVE_2013_4073(self):
115+ p = ssl._ssl._test_decode_cert(NULLBYTECERT)
116+ if test_support.verbose:
117+ sys.stdout.write("\n" + pprint.pformat(p) + "\n")
118+ subject = ((('countryName', 'US'),),
119+ (('stateOrProvinceName', 'Oregon'),),
120+ (('localityName', 'Beaverton'),),
121+ (('organizationName', 'Python Software Foundation'),),
122+ (('organizationalUnitName', 'Python Core Development'),),
123+ (('commonName', 'null.python.org\x00example.org'),),
124+ (('emailAddress', 'python-dev@python.org'),))
125+ self.assertEqual(p['subject'], subject)
126+ self.assertEqual(p['issuer'], subject)
127+ self.assertEqual(p['subjectAltName'],
128+ (('DNS', 'altnull.python.org\x00example.com'),
129+ ('email', 'null@python.org\x00user@example.org'),
130+ ('URI', 'http://null.python.org\x00http://example.org'),
131+ ('IP Address', '192.0.2.1'),
132+ ('IP Address', '2001:DB8:0:0:0:0:0:1\n'))
133+ )
134+
135 def test_DER_to_PEM(self):
136 with open(SVN_PYTHON_ORG_ROOT_CERT, 'r') as f:
137 pem = f.read()
138@@ -1360,7 +1382,7 @@
139
140
141 def test_main(verbose=False):
142- global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT
143+ global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT, NULLBYTECERT
144 CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
145 "keycert.pem")
146 SVN_PYTHON_ORG_ROOT_CERT = os.path.join(
147@@ -1368,10 +1390,13 @@
148 "https_svn_python_org_root.pem")
149 NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir,
150 "nokia.pem")
151+ NULLBYTECERT = os.path.join(os.path.dirname(__file__) or os.curdir,
152+ "nullbytecert.pem")
153
154 if (not os.path.exists(CERTFILE) or
155 not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or
156- not os.path.exists(NOKIACERT)):
157+ not os.path.exists(NOKIACERT) or
158+ not os.path.exists(NULLBYTECERT)):
159 raise test_support.TestFailed("Can't read certificate files!")
160
161 tests = [BasicTests, BasicSocketTests]
162diff -r 9ddc63c039ba Modules/_ssl.c
163--- a/Modules/_ssl.c Sun Aug 11 13:04:50 2013 +0300
164+++ b/Modules/_ssl.c Sun Aug 11 18:13:17 2013 +0200
165@@ -741,8 +741,13 @@
166
167 /* get a rendering of each name in the set of names */
168
169+ int gntype;
170+ ASN1_STRING *as = NULL;
171+
172 name = sk_GENERAL_NAME_value(names, j);
173- if (name->type == GEN_DIRNAME) {
174+ gntype = name-> type;
175+ switch (gntype) {
176+ case GEN_DIRNAME:
177
178 /* we special-case DirName as a tuple of tuples of attributes */
179
180@@ -764,11 +769,61 @@
181 goto fail;
182 }
183 PyTuple_SET_ITEM(t, 1, v);
184+ break;
185
186- } else {
187+ case GEN_EMAIL:
188+ case GEN_DNS:
189+ case GEN_URI:
190+ /* GENERAL_NAME_print() doesn't handle NUL bytes in ASN1_string
191+ correctly. */
192+ t = PyTuple_New(2);
193+ if (t == NULL)
194+ goto fail;
195+ switch (gntype) {
196+ case GEN_EMAIL:
197+ v = PyUnicode_FromString("email");
198+ as = name->d.rfc822Name;
199+ break;
200+ case GEN_DNS:
201+ v = PyUnicode_FromString("DNS");
202+ as = name->d.dNSName;
203+ break;
204+ case GEN_URI:
205+ v = PyUnicode_FromString("URI");
206+ as = name->d.uniformResourceIdentifier;
207+ break;
208+ }
209+ if (v == NULL) {
210+ Py_DECREF(t);
211+ goto fail;
212+ }
213+ PyTuple_SET_ITEM(t, 0, v);
214+ v = PyString_FromStringAndSize((char *)ASN1_STRING_data(as),
215+ ASN1_STRING_length(as));
216+ if (v == NULL) {
217+ Py_DECREF(t);
218+ goto fail;
219+ }
220+ PyTuple_SET_ITEM(t, 1, v);
221+ break;
222
223+ default:
224 /* for everything else, we use the OpenSSL print form */
225-
226+ switch (gntype) {
227+ /* check for new general name type */
228+ case GEN_OTHERNAME:
229+ case GEN_X400:
230+ case GEN_EDIPARTY:
231+ case GEN_IPADD:
232+ case GEN_RID:
233+ break;
234+ default:
235+ if (PyErr_Warn(PyExc_RuntimeWarning,
236+ "Unknown general name type") == -1) {
237+ goto fail;
238+ }
239+ break;
240+ }
241 (void) BIO_reset(biobuf);
242 GENERAL_NAME_print(biobuf, name);
243 len = BIO_gets(biobuf, buf, sizeof(buf)-1);
244@@ -794,6 +849,7 @@
245 goto fail;
246 }
247 PyTuple_SET_ITEM(t, 1, v);
248+ break;
249 }
250
251 /* and add that rendering to the list */
diff --git a/meta/recipes-devtools/python/python/add-md5module-support.patch b/meta/recipes-devtools/python/python/add-md5module-support.patch
new file mode 100644
index 0000000000..33fea77554
--- /dev/null
+++ b/meta/recipes-devtools/python/python/add-md5module-support.patch
@@ -0,0 +1,18 @@
1
2Upstream-Status: Inappropriate [configuration]
3
4Signed-off-by: Saul Wold <sgw@linux.intel.com>
5
6Index: Python-2.7.2/Modules/Setup.dist
7===================================================================
8--- Python-2.7.2.orig/Modules/Setup.dist 2011-06-11 08:46:26.000000000 -0700
9+++ Python-2.7.2/Modules/Setup.dist 2011-12-27 15:51:41.244623219 -0800
10@@ -248,7 +248,7 @@
11 # Message-Digest Algorithm, described in RFC 1321. The necessary files
12 # md5.c and md5.h are included here.
13
14-#_md5 md5module.c md5.c
15+_md5 md5module.c md5.c
16
17
18 # The _sha module implements the SHA checksum algorithms.
diff --git a/meta/recipes-devtools/python/python/avoid_warning_about_tkinter.patch b/meta/recipes-devtools/python/python/avoid_warning_about_tkinter.patch
new file mode 100644
index 0000000000..bedc3909d8
--- /dev/null
+++ b/meta/recipes-devtools/python/python/avoid_warning_about_tkinter.patch
@@ -0,0 +1,30 @@
1_tkinter module needs tk module along with tcl. tk is not yet integrated
2in yocto so we skip the check for this module.
3Avoid a warning by not adding this module to missing variable.
4
5Also simply disable the tk module since its not in DEPENDS.
6
7Upstream-Status: Inappropriate [distribution]
8
9Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
10
11Index: Python-2.7.3/setup.py
12===================================================================
13--- Python-2.7.3.orig/setup.py 2014-07-07 13:45:15.056233820 +0000
14+++ Python-2.7.3/setup.py 2014-07-16 16:06:37.145656284 +0000
15@@ -1639,10 +1639,12 @@
16 self.extensions.extend(exts)
17
18 # Call the method for detecting whether _tkinter can be compiled
19- self.detect_tkinter(inc_dirs, lib_dirs)
20+ #self.detect_tkinter(inc_dirs, lib_dirs)
21
22- if '_tkinter' not in [e.name for e in self.extensions]:
23- missing.append('_tkinter')
24+ # tkinter module will not be avalaible as yocto
25+ # doesn't have tk integrated (yet)
26+ #if '_tkinter' not in [e.name for e in self.extensions]:
27+ # missing.append('_tkinter')
28
29 return missing
30
diff --git a/meta/recipes-devtools/python/python/avoid_warning_for_sunos_specific_module.patch b/meta/recipes-devtools/python/python/avoid_warning_for_sunos_specific_module.patch
new file mode 100644
index 0000000000..337e0e3e29
--- /dev/null
+++ b/meta/recipes-devtools/python/python/avoid_warning_for_sunos_specific_module.patch
@@ -0,0 +1,23 @@
1sunaudiodev module is sunos specific so we avoid a warning by not
2adding this module to missing variable.
3
4Upstream-Status: Inappropriate [distribution]
5
6Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
7
8Index: Python-2.7.2/setup.py
9===================================================================
10--- Python-2.7.2.orig/setup.py 2012-04-05 22:29:18.049196608 +0300
11+++ Python-2.7.2/setup.py 2012-04-05 22:29:57.505195453 +0300
12@@ -1522,8 +1522,9 @@
13 if platform == 'sunos5':
14 # SunOS specific modules
15 exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
16- else:
17- missing.append('sunaudiodev')
18+ # If platform is not sunos warning is useless
19+ #else:
20+ # missing.append('sunaudiodev')
21
22 if platform == 'darwin':
23 # _scproxy
diff --git a/meta/recipes-devtools/python/python/builddir.patch b/meta/recipes-devtools/python/python/builddir.patch
new file mode 100644
index 0000000000..930170b95a
--- /dev/null
+++ b/meta/recipes-devtools/python/python/builddir.patch
@@ -0,0 +1,55 @@
1When cross compiling python, we used to need to install the Makefile, pyconfig.h
2and the python library to their final location before being able to compile the
3rest of python. This change allows us to point python at its own source when
4building, avoiding a variety of sysroot staging issues and simplifying the main
5python recipe.
6
7Upstream-Status: Inappropriate
8RP 2012/11/13
9
10Index: Python-2.7.3/Lib/sysconfig.py
11===================================================================
12--- Python-2.7.3.orig/Lib/sysconfig.py 2012-11-13 14:36:08.429167199 +0000
13+++ Python-2.7.3/Lib/sysconfig.py 2012-11-13 21:58:31.788551800 +0000
14@@ -93,6 +93,7 @@
15 _EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
16 _CONFIG_VARS = None
17 _USER_BASE = None
18+_PYTHONBUILDDIR = os.environ.get("PYTHONBUILDDIR", None)
19
20 def _safe_realpath(path):
21 try:
22@@ -100,7 +102,9 @@
23 except OSError:
24 return path
25
26-if sys.executable:
27+if _PYTHONBUILDDIR:
28+ _PROJECT_BASE = _PYTHONBUILDDIR
29+elif sys.executable:
30 _PROJECT_BASE = os.path.dirname(_safe_realpath(sys.executable))
31 else:
32 # sys.executable can be empty if argv[0] has been changed and Python is
33Index: Python-2.7.3/Lib/distutils/sysconfig.py
34===================================================================
35--- Python-2.7.3.orig/Lib/distutils/sysconfig.py 2012-11-13 14:36:08.005167209 +0000
36+++ Python-2.7.3/Lib/distutils/sysconfig.py 2012-11-13 22:07:05.644540695 +0000
37@@ -26,6 +26,9 @@
38 # live in project/PCBuild9. If we're dealing with an x64 Windows build,
39 # it'll live in project/PCbuild/amd64.
40 project_base = os.path.dirname(os.path.abspath(sys.executable))
41+_PYTHONBUILDDIR = os.environ.get("PYTHONBUILDDIR", None)
42+if _PYTHONBUILDDIR:
43+ project_base = _PYTHONBUILDDIR
44 if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
45 project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
46 # PC/VS7.1
47@@ -247,7 +250,7 @@
48 def get_makefile_filename():
49 """Return full pathname of installed Makefile from the Python build."""
50 if python_build:
51- return os.path.join(os.path.dirname(sys.executable), "Makefile")
52+ return os.path.join(project_base, "Makefile")
53 lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
54 return os.path.join(lib_dir, "config", "Makefile")
55
diff --git a/meta/recipes-devtools/python/python/cgi_py.patch b/meta/recipes-devtools/python/python/cgi_py.patch
new file mode 100644
index 0000000000..de504f9dcf
--- /dev/null
+++ b/meta/recipes-devtools/python/python/cgi_py.patch
@@ -0,0 +1,23 @@
1Lib/cgi.py: Update the script as mentioned in the comment
2
3Upstream-Status: Inappropriate [distribution]
4
5Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
6
7--- Python-2.6.6/Lib/cgi.py.orig 2010-08-01 22:14:27.000000000 -0500
8+++ Python-2.6.6/Lib/cgi.py 2011-09-21 15:28:40.478208631 -0500
9@@ -1,13 +1,4 @@
10-#! /usr/local/bin/python
11-
12-# NOTE: the above "/usr/local/bin/python" is NOT a mistake. It is
13-# intentionally NOT "/usr/bin/env python". On many systems
14-# (e.g. Solaris), /usr/local/bin is not in $PATH as passed to CGI
15-# scripts, and /usr/local/bin is the default directory where Python is
16-# installed, so /usr/bin/env would be unable to find python. Granted,
17-# binary installations by Linux vendors often install Python in
18-# /usr/bin. So let those vendors patch cgi.py to match their choice
19-# of installation.
20+#! /usr/bin/env python
21
22 """Support module for CGI (Common Gateway Interface) scripts.
23
diff --git a/meta/recipes-devtools/python/python/check-if-target-is-64b-not-host.patch b/meta/recipes-devtools/python/python/check-if-target-is-64b-not-host.patch
new file mode 100644
index 0000000000..2b62db3826
--- /dev/null
+++ b/meta/recipes-devtools/python/python/check-if-target-is-64b-not-host.patch
@@ -0,0 +1,57 @@
1Author: Andrei Gherzan <andrei@gherzan.ro>
2Date: Sun Mar 25 02:02:27 2012 +0200
3
4This patch was added for 64bit host machines. In the compile process python
5is checking if platform is a 64bit platform using sys.maxint which is the host's
6value. The patch fixes this issue so that python would check if TARGET machine
7is 64bit not the HOST machine. In this way will have "dl" and "imageop" modules
8built if HOST machine is 64bit but the target machine is 32bit.
9
10Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
11
12Upstream-Status: Pending
13
14Index: Python-2.7.2/setup.py
15===================================================================
16--- Python-2.7.2.orig/setup.py 2012-03-25 01:10:41.540163187 +0200
17+++ Python-2.7.2/setup.py 2012-03-25 01:26:06.092539990 +0200
18@@ -23,6 +23,21 @@
19 # This global variable is used to hold the list of modules to be disabled.
20 disabled_module_list = []
21
22+def target_is_64bit_platform ():
23+ """
24+ In case of cross-compile, some modules are not build as setup checks if HOST
25+ is 64bit and not TARGET.
26+ As python was built for TARGET we can check this in pyconfig.h in this way:
27+ Sizeof LONG on a 32 bit platform is 4 bytes
28+ Sizeof LONG on a 64 bit platform is 8 bytes
29+ """
30+ pyconf = open("pyconfig.h").read()
31+ aux = re.search(r"#s*define\s+SIZEOF_LONG\s+8\s*", pyconf)
32+ if aux is not None:
33+ return True
34+ else:
35+ return False
36+
37 def add_dir_to_list(dirlist, dir):
38 """Add the directory 'dir' to the list 'dirlist' (at the front) if
39 1) 'dir' is not already in 'dirlist'
40@@ -628,7 +643,7 @@
41 exts.append( Extension('audioop', ['audioop.c']) )
42
43 # Disabled on 64-bit platforms
44- if sys.maxint != 9223372036854775807L:
45+ if not target_is_64bit_platform():
46 # Operations on images
47 exts.append( Extension('imageop', ['imageop.c']) )
48 else:
49@@ -1418,7 +1433,7 @@
50 missing.append('_codecs_%s' % loc)
51
52 # Dynamic loading module
53- if sys.maxint == 0x7fffffff:
54+ if not target_is_64bit_platform():
55 # This requires sizeof(int) == sizeof(long) == sizeof(char*)
56 dl_inc = find_file('dlfcn.h', [], inc_dirs)
57 if (dl_inc is not None) and (platform not in ['atheos']):
diff --git a/meta/recipes-devtools/python/python/ctypes-libffi-aarch64.patch b/meta/recipes-devtools/python/python/ctypes-libffi-aarch64.patch
new file mode 100644
index 0000000000..7349c7bfe3
--- /dev/null
+++ b/meta/recipes-devtools/python/python/ctypes-libffi-aarch64.patch
@@ -0,0 +1,22 @@
1Add missing fficonfig.py bits for aarch64
2
3# HG changeset patch
4# User Andreas Schwab <schwab@suse.de>
5# Date 1367276434 -7200
6# Node ID 05e8999a3901b4853e60d6701510e9b3dd54a7f3
7# Parent 84cef4f1999ad9e362694cdac2f65f0981e3d5d0
8
9Upstream-Status: Backport
10Signed-off-by: Tudor Florea <tudor.florea@enea.com>
11
12diff -r 84cef4f1999a -r 05e8999a3901 Modules/_ctypes/libffi/fficonfig.py.in
13--- a/Modules/_ctypes/libffi/fficonfig.py.in Mon Apr 29 16:09:39 2013 -0400
14+++ b/Modules/_ctypes/libffi/fficonfig.py.in Tue Apr 30 01:00:34 2013 +0200
15@@ -28,6 +28,7 @@
16 'PA': ['src/pa/linux.S', 'src/pa/ffi.c'],
17 'PA_LINUX': ['src/pa/linux.S', 'src/pa/ffi.c'],
18 'PA_HPUX': ['src/pa/hpux32.S', 'src/pa/ffi.c'],
19+ 'AARCH64' : ['src/aarch64/ffi.c', 'src/aarch64/sysv.S'],
20 }
21
22 ffi_sources += ffi_platforms['@TARGET@']
diff --git a/meta/recipes-devtools/python/python/fix-makefile-for-ptest.patch b/meta/recipes-devtools/python/python/fix-makefile-for-ptest.patch
new file mode 100644
index 0000000000..669112dab0
--- /dev/null
+++ b/meta/recipes-devtools/python/python/fix-makefile-for-ptest.patch
@@ -0,0 +1,33 @@
1Add 'build-test' and 'runtest-TESTS' targets to Makefile, to build and run tests
2cross-compiled.
3
4Signed-off-by: Tudor Florea <tudor.florea@enea.com>
5Upstream-Status: Pending
6---
7diff -ruN a/Makefile.pre.in b/Makefile.pre.in
8--- a/Makefile.pre.in 2013-06-27 10:44:11.033840532 +0200
9+++ b/Makefile.pre.in 2013-06-27 10:44:39.572635273 +0200
10@@ -709,14 +709,19 @@
11 # generated bytecode. This is sometimes a very shy bug needing a lot of
12 # sample data.
13
14-TESTOPTS= -l $(EXTRATESTOPTS)
15+TESTOPTS= -l -v $(EXTRATESTOPTS)
16 TESTPROG= $(srcdir)/Lib/test/regrtest.py
17-TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS)
18-test: all platform
19- -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
20+TESTPYTHON= $(RUNSHARED) $(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS)
21+test: build-test
22+ $(MAKE) runtest-TESTS
23+
24+runtest-TESTS:
25+ -find $(srcdir) -name '*.py[co]' -print | xargs rm -f
26 -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
27 $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
28
29+build-test: all platform
30+
31 testall: all platform
32 -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
33 $(TESTPYTHON) $(srcdir)/Lib/compileall.py
diff --git a/meta/recipes-devtools/python/python/fix_for_using_different_libdir.patch b/meta/recipes-devtools/python/python/fix_for_using_different_libdir.patch
new file mode 100644
index 0000000000..50d3915425
--- /dev/null
+++ b/meta/recipes-devtools/python/python/fix_for_using_different_libdir.patch
@@ -0,0 +1,82 @@
1Upstream-Status: Inappropriate [Embedded specific]
2
3This patch fixes issuing with different libdir like lib64.
4This patch makes the native python binary modules findable
5in the install process of the host python.
6
7Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
8Date: 2012/03/14
9
10Updated for python 2.7.3
11Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
12Date: 2012/05/01
13
14Index: Python-2.7.3/Lib/sysconfig.py
15===================================================================
16--- Python-2.7.3.orig/Lib/sysconfig.py
17+++ Python-2.7.3/Lib/sysconfig.py
18@@ -7,10 +7,10 @@ from os.path import pardir, realpath
19
20 _INSTALL_SCHEMES = {
21 'posix_prefix': {
22- 'stdlib': '{base}/lib/python{py_version_short}',
23- 'platstdlib': '{platbase}/lib/python{py_version_short}',
24- 'purelib': '{base}/lib/python{py_version_short}/site-packages',
25- 'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
26+ 'stdlib': '{base}/'+sys.lib+'/python{py_version_short}',
27+ 'platstdlib': '{platbase}/'+sys.lib+'/python{py_version_short}',
28+ 'purelib': '{base}/'+sys.lib+'/python{py_version_short}/site-packages',
29+ 'platlib': '{platbase}/'+sys.lib+'/python{py_version_short}/site-packages',
30 'include': '{base}/include/python{py_version_short}',
31 'platinclude': '{platbase}/include/python{py_version_short}',
32 'scripts': '{base}/bin',
33@@ -65,10 +65,10 @@ _INSTALL_SCHEMES = {
34 'data' : '{userbase}',
35 },
36 'posix_user': {
37- 'stdlib': '{userbase}/lib/python{py_version_short}',
38- 'platstdlib': '{userbase}/lib/python{py_version_short}',
39- 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
40- 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
41+ 'stdlib': '{userbase}/'+sys.lib+'/python{py_version_short}',
42+ 'platstdlib': '{userbase}/'+sys.lib+'/python{py_version_short}',
43+ 'purelib': '{userbase}/'+sys.lib+'/python{py_version_short}/site-packages',
44+ 'platlib': '{userbase}/'+sys.lib+'/python{py_version_short}/site-packages',
45 'include': '{userbase}/include/python{py_version_short}',
46 'scripts': '{userbase}/bin',
47 'data' : '{userbase}',
48Index: Python-2.7.3/Makefile.pre.in
49===================================================================
50--- Python-2.7.3.orig/Makefile.pre.in
51+++ Python-2.7.3/Makefile.pre.in
52@@ -941,25 +941,25 @@ libinstall: build_all $(srcdir)/Lib/$(PL
53 $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
54 $(DESTDIR)$(LIBDEST)/distutils/tests ; \
55 fi
56- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
57+ PYTHONPATH=$(DESTDIR)$(LIBDEST):${CROSSPYTHONPATH} $(RUNSHARED) \
58 $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
59 -d $(LIBDEST) -f \
60 -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
61 $(DESTDIR)$(LIBDEST)
62- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
63+ PYTHONPATH=$(DESTDIR)$(LIBDEST):${CROSSPYTHONPATH} $(RUNSHARED) \
64 $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
65 -d $(LIBDEST) -f \
66 -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
67 $(DESTDIR)$(LIBDEST)
68- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
69+ -PYTHONPATH=$(DESTDIR)$(LIBDEST):${CROSSPYTHONPATH} $(RUNSHARED) \
70 $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
71 -d $(LIBDEST)/site-packages -f \
72 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
73- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
74+ -PYTHONPATH=$(DESTDIR)$(LIBDEST):${CROSSPYTHONPATH} $(RUNSHARED) \
75 $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
76 -d $(LIBDEST)/site-packages -f \
77 -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
78- -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
79+ -PYTHONPATH=$(DESTDIR)$(LIBDEST):${CROSSPYTHONPATH} $(RUNSHARED) \
80 $(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
81
82 # Create the PLATDIR source directory, if one wasn't distributed..
diff --git a/meta/recipes-devtools/python/python/gcc-4.8-fix-configure-Wformat.patch b/meta/recipes-devtools/python/python/gcc-4.8-fix-configure-Wformat.patch
new file mode 100644
index 0000000000..b5d9d5d424
--- /dev/null
+++ b/meta/recipes-devtools/python/python/gcc-4.8-fix-configure-Wformat.patch
@@ -0,0 +1,20 @@
1backport bug 17547 from http://hg.python.org/cpython/rev/9d50af4c482f/
2
3-Wformat is needed by gcc 4.8
4
5Signed-off-by: Khem Raj <raj.khem@gmail.com>
6
7Upstream-Status: Backport
8Index: Python-2.7.3/configure.in
9===================================================================
10--- Python-2.7.3.orig/configure.in 2013-06-11 02:22:04.186529212 -0700
11+++ Python-2.7.3/configure.in 2013-06-13 02:17:06.324403327 -0700
12@@ -1196,7 +1196,7 @@
13 then
14 AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
15 save_CFLAGS=$CFLAGS
16- CFLAGS="$CFLAGS -Werror"
17+ CFLAGS="$CFLAGS -Werror -Wformat"
18 AC_COMPILE_IFELSE([
19 AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
20 ],[
diff --git a/meta/recipes-devtools/python/python/host_include_contamination.patch b/meta/recipes-devtools/python/python/host_include_contamination.patch
new file mode 100644
index 0000000000..62cb8b16da
--- /dev/null
+++ b/meta/recipes-devtools/python/python/host_include_contamination.patch
@@ -0,0 +1,27 @@
1when building python for qemux86-64 on ubuntu 11.10/64bit
2it gropes into host includes and then mixes them with cross
3includes and as a result some modules fail to compile and link
4one of the modules is python-elementtree which is then not
5found during image creation
6
7Proble is that setup.py tries to add native includes that newer
8ubuntu has introduced for multiarch support. But that should
9only happen for native builds and not cross building python
10so we add a check here.
11
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13Upstream-Status: Pending
14
15Index: Python-2.7.2/setup.py
16===================================================================
17--- Python-2.7.2.orig/setup.py 2012-02-03 12:10:42.307057756 -0800
18+++ Python-2.7.2/setup.py 2012-02-03 12:11:12.363059210 -0800
19@@ -360,6 +360,8 @@
20 # https://wiki.ubuntu.com/MultiarchSpec
21 if not find_executable('dpkg-architecture'):
22 return
23+ if os.environ.get('CROSS_COMPILE') is not None:
24+ return
25 tmpfile = os.path.join(self.build_temp, 'multiarch')
26 if not os.path.exists(self.build_temp):
27 os.makedirs(self.build_temp)
diff --git a/meta/recipes-devtools/python/python/json-flaw-fix.patch b/meta/recipes-devtools/python/python/json-flaw-fix.patch
new file mode 100644
index 0000000000..e9a6cca017
--- /dev/null
+++ b/meta/recipes-devtools/python/python/json-flaw-fix.patch
@@ -0,0 +1,27 @@
1
2python: fix _json module arbitrary process memory read vulnerability
3
4Upstream-Status: submitted
5
6Signed-off-by: Daniel BORNAZ <daniel.bornaz@enea.com>
7
8--- a/Modules/_json.c 2014-07-15 15:37:17.151046356 +0200
9+++ b/Modules/_json.c 2014-07-15 15:38:37.335605042 +0200
10@@ -1491,7 +1491,7 @@ scan_once_str(PyScannerObject *s, PyObje
11 PyObject *res;
12 char *str = PyString_AS_STRING(pystr);
13 Py_ssize_t length = PyString_GET_SIZE(pystr);
14- if (idx >= length) {
15+ if ( idx < 0 || idx >= length) {
16 PyErr_SetNone(PyExc_StopIteration);
17 return NULL;
18 }
19@@ -1578,7 +1578,7 @@ scan_once_unicode(PyScannerObject *s, Py
20 PyObject *res;
21 Py_UNICODE *str = PyUnicode_AS_UNICODE(pystr);
22 Py_ssize_t length = PyUnicode_GET_SIZE(pystr);
23- if (idx >= length) {
24+ if ( idx < 0 || idx >= length) {
25 PyErr_SetNone(PyExc_StopIteration);
26 return NULL;
27 }
diff --git a/meta/recipes-devtools/python/python/libffi-aarch64.patch b/meta/recipes-devtools/python/python/libffi-aarch64.patch
new file mode 100644
index 0000000000..5581922354
--- /dev/null
+++ b/meta/recipes-devtools/python/python/libffi-aarch64.patch
@@ -0,0 +1,1608 @@
1Add support for aarch64 for ctypes module
2
3Python have its own version of libffi used for ctypes module.
4libffi 3.0.10 contained in original source of Python-2.7.3 does not have
5support for aarch64 architecture.
6This is patch is backport support for aarch64 from libffi 3.1
7
8Upstream-Status: Backport
9Signed-off-by: Tudor Florea <tudor.florea@enea.com>
10
11diff -ruN Python-2.7.3.orig/Modules/_ctypes/libffi/configure.ac Python-2.7.3/Modules/_ctypes/libffi/configure.ac
12--- Python-2.7.3.orig/Modules/_ctypes/libffi/configure.ac 2015-02-27 23:15:16.118393178 +0100
13+++ Python-2.7.3/Modules/_ctypes/libffi/configure.ac 2015-02-27 23:51:03.351556903 +0100
14@@ -44,6 +44,10 @@
15
16 TARGETDIR="unknown"
17 case "$host" in
18+ aarch64*-*-*)
19+ TARGET=AARCH64; TARGETDIR=aarch64
20+ ;;
21+
22 alpha*-*-*)
23 TARGET=ALPHA; TARGETDIR=alpha;
24 # Support 128-bit long double, changeable via command-line switch.
25@@ -195,6 +199,7 @@
26 AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
27 AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
28 AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
29+AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64)
30 AM_CONDITIONAL(ARM, test x$TARGET = xARM)
31 AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
32 AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
33diff -ruN Python-2.7.3.orig/Modules/_ctypes/libffi/src/aarch64/ffi.c Python-2.7.3/Modules/_ctypes/libffi/src/aarch64/ffi.c
34--- Python-2.7.3.orig/Modules/_ctypes/libffi/src/aarch64/ffi.c 1970-01-01 01:00:00.000000000 +0100
35+++ Python-2.7.3/Modules/_ctypes/libffi/src/aarch64/ffi.c 2014-04-25 19:45:13.000000000 +0200
36@@ -0,0 +1,1168 @@
37+/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
38+
39+Permission is hereby granted, free of charge, to any person obtaining
40+a copy of this software and associated documentation files (the
41+``Software''), to deal in the Software without restriction, including
42+without limitation the rights to use, copy, modify, merge, publish,
43+distribute, sublicense, and/or sell copies of the Software, and to
44+permit persons to whom the Software is furnished to do so, subject to
45+the following conditions:
46+
47+The above copyright notice and this permission notice shall be
48+included in all copies or substantial portions of the Software.
49+
50+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
51+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
57+
58+#include <stdio.h>
59+
60+#include <ffi.h>
61+#include <ffi_common.h>
62+
63+#include <stdlib.h>
64+
65+/* Stack alignment requirement in bytes */
66+#if defined (__APPLE__)
67+#define AARCH64_STACK_ALIGN 1
68+#else
69+#define AARCH64_STACK_ALIGN 16
70+#endif
71+
72+#define N_X_ARG_REG 8
73+#define N_V_ARG_REG 8
74+
75+#define AARCH64_FFI_WITH_V (1 << AARCH64_FFI_WITH_V_BIT)
76+
77+union _d
78+{
79+ UINT64 d;
80+ UINT32 s[2];
81+};
82+
83+struct call_context
84+{
85+ UINT64 x [AARCH64_N_XREG];
86+ struct
87+ {
88+ union _d d[2];
89+ } v [AARCH64_N_VREG];
90+};
91+
92+#if defined (__clang__) && defined (__APPLE__)
93+extern void
94+sys_icache_invalidate (void *start, size_t len);
95+#endif
96+
97+static inline void
98+ffi_clear_cache (void *start, void *end)
99+{
100+#if defined (__clang__) && defined (__APPLE__)
101+ sys_icache_invalidate (start, (char *)end - (char *)start);
102+#elif defined (__GNUC__)
103+ __builtin___clear_cache (start, end);
104+#else
105+#error "Missing builtin to flush instruction cache"
106+#endif
107+}
108+
109+static void *
110+get_x_addr (struct call_context *context, unsigned n)
111+{
112+ return &context->x[n];
113+}
114+
115+static void *
116+get_s_addr (struct call_context *context, unsigned n)
117+{
118+#if defined __AARCH64EB__
119+ return &context->v[n].d[1].s[1];
120+#else
121+ return &context->v[n].d[0].s[0];
122+#endif
123+}
124+
125+static void *
126+get_d_addr (struct call_context *context, unsigned n)
127+{
128+#if defined __AARCH64EB__
129+ return &context->v[n].d[1];
130+#else
131+ return &context->v[n].d[0];
132+#endif
133+}
134+
135+static void *
136+get_v_addr (struct call_context *context, unsigned n)
137+{
138+ return &context->v[n];
139+}
140+
141+/* Return the memory location at which a basic type would reside
142+ were it to have been stored in register n. */
143+
144+static void *
145+get_basic_type_addr (unsigned short type, struct call_context *context,
146+ unsigned n)
147+{
148+ switch (type)
149+ {
150+ case FFI_TYPE_FLOAT:
151+ return get_s_addr (context, n);
152+ case FFI_TYPE_DOUBLE:
153+ return get_d_addr (context, n);
154+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
155+ case FFI_TYPE_LONGDOUBLE:
156+ return get_v_addr (context, n);
157+#endif
158+ case FFI_TYPE_UINT8:
159+ case FFI_TYPE_SINT8:
160+ case FFI_TYPE_UINT16:
161+ case FFI_TYPE_SINT16:
162+ case FFI_TYPE_UINT32:
163+ case FFI_TYPE_SINT32:
164+ case FFI_TYPE_INT:
165+ case FFI_TYPE_POINTER:
166+ case FFI_TYPE_UINT64:
167+ case FFI_TYPE_SINT64:
168+ return get_x_addr (context, n);
169+ case FFI_TYPE_VOID:
170+ return NULL;
171+ default:
172+ FFI_ASSERT (0);
173+ return NULL;
174+ }
175+}
176+
177+/* Return the alignment width for each of the basic types. */
178+
179+static size_t
180+get_basic_type_alignment (unsigned short type)
181+{
182+ switch (type)
183+ {
184+ case FFI_TYPE_FLOAT:
185+ case FFI_TYPE_DOUBLE:
186+ return sizeof (UINT64);
187+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
188+ case FFI_TYPE_LONGDOUBLE:
189+ return sizeof (long double);
190+#endif
191+ case FFI_TYPE_UINT8:
192+ case FFI_TYPE_SINT8:
193+#if defined (__APPLE__)
194+ return sizeof (UINT8);
195+#endif
196+ case FFI_TYPE_UINT16:
197+ case FFI_TYPE_SINT16:
198+#if defined (__APPLE__)
199+ return sizeof (UINT16);
200+#endif
201+ case FFI_TYPE_UINT32:
202+ case FFI_TYPE_INT:
203+ case FFI_TYPE_SINT32:
204+#if defined (__APPLE__)
205+ return sizeof (UINT32);
206+#endif
207+ case FFI_TYPE_POINTER:
208+ case FFI_TYPE_UINT64:
209+ case FFI_TYPE_SINT64:
210+ return sizeof (UINT64);
211+
212+ default:
213+ FFI_ASSERT (0);
214+ return 0;
215+ }
216+}
217+
218+/* Return the size in bytes for each of the basic types. */
219+
220+static size_t
221+get_basic_type_size (unsigned short type)
222+{
223+ switch (type)
224+ {
225+ case FFI_TYPE_FLOAT:
226+ return sizeof (UINT32);
227+ case FFI_TYPE_DOUBLE:
228+ return sizeof (UINT64);
229+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
230+ case FFI_TYPE_LONGDOUBLE:
231+ return sizeof (long double);
232+#endif
233+ case FFI_TYPE_UINT8:
234+ return sizeof (UINT8);
235+ case FFI_TYPE_SINT8:
236+ return sizeof (SINT8);
237+ case FFI_TYPE_UINT16:
238+ return sizeof (UINT16);
239+ case FFI_TYPE_SINT16:
240+ return sizeof (SINT16);
241+ case FFI_TYPE_UINT32:
242+ return sizeof (UINT32);
243+ case FFI_TYPE_INT:
244+ case FFI_TYPE_SINT32:
245+ return sizeof (SINT32);
246+ case FFI_TYPE_POINTER:
247+ case FFI_TYPE_UINT64:
248+ return sizeof (UINT64);
249+ case FFI_TYPE_SINT64:
250+ return sizeof (SINT64);
251+
252+ default:
253+ FFI_ASSERT (0);
254+ return 0;
255+ }
256+}
257+
258+extern void
259+ffi_call_SYSV (unsigned (*)(struct call_context *context, unsigned char *,
260+ extended_cif *),
261+ struct call_context *context,
262+ extended_cif *,
263+ size_t,
264+ void (*fn)(void));
265+
266+extern void
267+ffi_closure_SYSV (ffi_closure *);
268+
269+/* Test for an FFI floating point representation. */
270+
271+static unsigned
272+is_floating_type (unsigned short type)
273+{
274+ return (type == FFI_TYPE_FLOAT || type == FFI_TYPE_DOUBLE
275+ || type == FFI_TYPE_LONGDOUBLE);
276+}
277+
278+/* Test for a homogeneous structure. */
279+
280+static unsigned short
281+get_homogeneous_type (ffi_type *ty)
282+{
283+ if (ty->type == FFI_TYPE_STRUCT && ty->elements)
284+ {
285+ unsigned i;
286+ unsigned short candidate_type
287+ = get_homogeneous_type (ty->elements[0]);
288+ for (i =1; ty->elements[i]; i++)
289+ {
290+ unsigned short iteration_type = 0;
291+ /* If we have a nested struct, we must find its homogeneous type.
292+ If that fits with our candidate type, we are still
293+ homogeneous. */
294+ if (ty->elements[i]->type == FFI_TYPE_STRUCT
295+ && ty->elements[i]->elements)
296+ {
297+ iteration_type = get_homogeneous_type (ty->elements[i]);
298+ }
299+ else
300+ {
301+ iteration_type = ty->elements[i]->type;
302+ }
303+
304+ /* If we are not homogeneous, return FFI_TYPE_STRUCT. */
305+ if (candidate_type != iteration_type)
306+ return FFI_TYPE_STRUCT;
307+ }
308+ return candidate_type;
309+ }
310+
311+ /* Base case, we have no more levels of nesting, so we
312+ are a basic type, and so, trivially homogeneous in that type. */
313+ return ty->type;
314+}
315+
316+/* Determine the number of elements within a STRUCT.
317+
318+ Note, we must handle nested structs.
319+
320+ If ty is not a STRUCT this function will return 0. */
321+
322+static unsigned
323+element_count (ffi_type *ty)
324+{
325+ if (ty->type == FFI_TYPE_STRUCT && ty->elements)
326+ {
327+ unsigned n;
328+ unsigned elems = 0;
329+ for (n = 0; ty->elements[n]; n++)
330+ {
331+ if (ty->elements[n]->type == FFI_TYPE_STRUCT
332+ && ty->elements[n]->elements)
333+ elems += element_count (ty->elements[n]);
334+ else
335+ elems++;
336+ }
337+ return elems;
338+ }
339+ return 0;
340+}
341+
342+/* Test for a homogeneous floating point aggregate.
343+
344+ A homogeneous floating point aggregate is a homogeneous aggregate of
345+ a half- single- or double- precision floating point type with one
346+ to four elements. Note that this includes nested structs of the
347+ basic type. */
348+
349+static int
350+is_hfa (ffi_type *ty)
351+{
352+ if (ty->type == FFI_TYPE_STRUCT
353+ && ty->elements[0]
354+ && is_floating_type (get_homogeneous_type (ty)))
355+ {
356+ unsigned n = element_count (ty);
357+ return n >= 1 && n <= 4;
358+ }
359+ return 0;
360+}
361+
362+/* Test if an ffi_type is a candidate for passing in a register.
363+
364+ This test does not check that sufficient registers of the
365+ appropriate class are actually available, merely that IFF
366+ sufficient registers are available then the argument will be passed
367+ in register(s).
368+
369+ Note that an ffi_type that is deemed to be a register candidate
370+ will always be returned in registers.
371+
372+ Returns 1 if a register candidate else 0. */
373+
374+static int
375+is_register_candidate (ffi_type *ty)
376+{
377+ switch (ty->type)
378+ {
379+ case FFI_TYPE_VOID:
380+ case FFI_TYPE_FLOAT:
381+ case FFI_TYPE_DOUBLE:
382+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
383+ case FFI_TYPE_LONGDOUBLE:
384+#endif
385+ case FFI_TYPE_UINT8:
386+ case FFI_TYPE_UINT16:
387+ case FFI_TYPE_UINT32:
388+ case FFI_TYPE_UINT64:
389+ case FFI_TYPE_POINTER:
390+ case FFI_TYPE_SINT8:
391+ case FFI_TYPE_SINT16:
392+ case FFI_TYPE_SINT32:
393+ case FFI_TYPE_INT:
394+ case FFI_TYPE_SINT64:
395+ return 1;
396+
397+ case FFI_TYPE_STRUCT:
398+ if (is_hfa (ty))
399+ {
400+ return 1;
401+ }
402+ else if (ty->size > 16)
403+ {
404+ /* Too large. Will be replaced with a pointer to memory. The
405+ pointer MAY be passed in a register, but the value will
406+ not. This test specifically fails since the argument will
407+ never be passed by value in registers. */
408+ return 0;
409+ }
410+ else
411+ {
412+ /* Might be passed in registers depending on the number of
413+ registers required. */
414+ return (ty->size + 7) / 8 < N_X_ARG_REG;
415+ }
416+ break;
417+
418+ default:
419+ FFI_ASSERT (0);
420+ break;
421+ }
422+
423+ return 0;
424+}
425+
426+/* Test if an ffi_type argument or result is a candidate for a vector
427+ register. */
428+
429+static int
430+is_v_register_candidate (ffi_type *ty)
431+{
432+ return is_floating_type (ty->type)
433+ || (ty->type == FFI_TYPE_STRUCT && is_hfa (ty));
434+}
435+
436+/* Representation of the procedure call argument marshalling
437+ state.
438+
439+ The terse state variable names match the names used in the AARCH64
440+ PCS. */
441+
442+struct arg_state
443+{
444+ unsigned ngrn; /* Next general-purpose register number. */
445+ unsigned nsrn; /* Next vector register number. */
446+ size_t nsaa; /* Next stack offset. */
447+
448+#if defined (__APPLE__)
449+ unsigned allocating_variadic;
450+#endif
451+};
452+
453+/* Initialize a procedure call argument marshalling state. */
454+static void
455+arg_init (struct arg_state *state, size_t call_frame_size)
456+{
457+ state->ngrn = 0;
458+ state->nsrn = 0;
459+ state->nsaa = 0;
460+
461+#if defined (__APPLE__)
462+ state->allocating_variadic = 0;
463+#endif
464+}
465+
466+/* Return the number of available consecutive core argument
467+ registers. */
468+
469+static unsigned
470+available_x (struct arg_state *state)
471+{
472+ return N_X_ARG_REG - state->ngrn;
473+}
474+
475+/* Return the number of available consecutive vector argument
476+ registers. */
477+
478+static unsigned
479+available_v (struct arg_state *state)
480+{
481+ return N_V_ARG_REG - state->nsrn;
482+}
483+
484+static void *
485+allocate_to_x (struct call_context *context, struct arg_state *state)
486+{
487+ FFI_ASSERT (state->ngrn < N_X_ARG_REG);
488+ return get_x_addr (context, (state->ngrn)++);
489+}
490+
491+static void *
492+allocate_to_s (struct call_context *context, struct arg_state *state)
493+{
494+ FFI_ASSERT (state->nsrn < N_V_ARG_REG);
495+ return get_s_addr (context, (state->nsrn)++);
496+}
497+
498+static void *
499+allocate_to_d (struct call_context *context, struct arg_state *state)
500+{
501+ FFI_ASSERT (state->nsrn < N_V_ARG_REG);
502+ return get_d_addr (context, (state->nsrn)++);
503+}
504+
505+static void *
506+allocate_to_v (struct call_context *context, struct arg_state *state)
507+{
508+ FFI_ASSERT (state->nsrn < N_V_ARG_REG);
509+ return get_v_addr (context, (state->nsrn)++);
510+}
511+
512+/* Allocate an aligned slot on the stack and return a pointer to it. */
513+static void *
514+allocate_to_stack (struct arg_state *state, void *stack, size_t alignment,
515+ size_t size)
516+{
517+ void *allocation;
518+
519+ /* Round up the NSAA to the larger of 8 or the natural
520+ alignment of the argument's type. */
521+ state->nsaa = ALIGN (state->nsaa, alignment);
522+ state->nsaa = ALIGN (state->nsaa, alignment);
523+#if defined (__APPLE__)
524+ if (state->allocating_variadic)
525+ state->nsaa = ALIGN (state->nsaa, 8);
526+#else
527+ state->nsaa = ALIGN (state->nsaa, 8);
528+#endif
529+
530+ allocation = stack + state->nsaa;
531+
532+ state->nsaa += size;
533+ return allocation;
534+}
535+
536+static void
537+copy_basic_type (void *dest, void *source, unsigned short type)
538+{
539+ /* This is necessary to ensure that basic types are copied
540+ sign extended to 64-bits as libffi expects. */
541+ switch (type)
542+ {
543+ case FFI_TYPE_FLOAT:
544+ *(float *) dest = *(float *) source;
545+ break;
546+ case FFI_TYPE_DOUBLE:
547+ *(double *) dest = *(double *) source;
548+ break;
549+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
550+ case FFI_TYPE_LONGDOUBLE:
551+ *(long double *) dest = *(long double *) source;
552+ break;
553+#endif
554+ case FFI_TYPE_UINT8:
555+ *(ffi_arg *) dest = *(UINT8 *) source;
556+ break;
557+ case FFI_TYPE_SINT8:
558+ *(ffi_sarg *) dest = *(SINT8 *) source;
559+ break;
560+ case FFI_TYPE_UINT16:
561+ *(ffi_arg *) dest = *(UINT16 *) source;
562+ break;
563+ case FFI_TYPE_SINT16:
564+ *(ffi_sarg *) dest = *(SINT16 *) source;
565+ break;
566+ case FFI_TYPE_UINT32:
567+ *(ffi_arg *) dest = *(UINT32 *) source;
568+ break;
569+ case FFI_TYPE_INT:
570+ case FFI_TYPE_SINT32:
571+ *(ffi_sarg *) dest = *(SINT32 *) source;
572+ break;
573+ case FFI_TYPE_POINTER:
574+ case FFI_TYPE_UINT64:
575+ *(ffi_arg *) dest = *(UINT64 *) source;
576+ break;
577+ case FFI_TYPE_SINT64:
578+ *(ffi_sarg *) dest = *(SINT64 *) source;
579+ break;
580+ case FFI_TYPE_VOID:
581+ break;
582+
583+ default:
584+ FFI_ASSERT (0);
585+ }
586+}
587+
588+static void
589+copy_hfa_to_reg_or_stack (void *memory,
590+ ffi_type *ty,
591+ struct call_context *context,
592+ unsigned char *stack,
593+ struct arg_state *state)
594+{
595+ unsigned elems = element_count (ty);
596+ if (available_v (state) < elems)
597+ {
598+ /* There are insufficient V registers. Further V register allocations
599+ are prevented, the NSAA is adjusted (by allocate_to_stack ())
600+ and the argument is copied to memory at the adjusted NSAA. */
601+ state->nsrn = N_V_ARG_REG;
602+ memcpy (allocate_to_stack (state, stack, ty->alignment, ty->size),
603+ memory,
604+ ty->size);
605+ }
606+ else
607+ {
608+ int i;
609+ unsigned short type = get_homogeneous_type (ty);
610+ for (i = 0; i < elems; i++)
611+ {
612+ void *reg = allocate_to_v (context, state);
613+ copy_basic_type (reg, memory, type);
614+ memory += get_basic_type_size (type);
615+ }
616+ }
617+}
618+
619+/* Either allocate an appropriate register for the argument type, or if
620+ none are available, allocate a stack slot and return a pointer
621+ to the allocated space. */
622+
623+static void *
624+allocate_to_register_or_stack (struct call_context *context,
625+ unsigned char *stack,
626+ struct arg_state *state,
627+ unsigned short type)
628+{
629+ size_t alignment = get_basic_type_alignment (type);
630+ size_t size = alignment;
631+ switch (type)
632+ {
633+ case FFI_TYPE_FLOAT:
634+ /* This is the only case for which the allocated stack size
635+ should not match the alignment of the type. */
636+ size = sizeof (UINT32);
637+ /* Fall through. */
638+ case FFI_TYPE_DOUBLE:
639+ if (state->nsrn < N_V_ARG_REG)
640+ return allocate_to_d (context, state);
641+ state->nsrn = N_V_ARG_REG;
642+ break;
643+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
644+ case FFI_TYPE_LONGDOUBLE:
645+ if (state->nsrn < N_V_ARG_REG)
646+ return allocate_to_v (context, state);
647+ state->nsrn = N_V_ARG_REG;
648+ break;
649+#endif
650+ case FFI_TYPE_UINT8:
651+ case FFI_TYPE_SINT8:
652+ case FFI_TYPE_UINT16:
653+ case FFI_TYPE_SINT16:
654+ case FFI_TYPE_UINT32:
655+ case FFI_TYPE_SINT32:
656+ case FFI_TYPE_INT:
657+ case FFI_TYPE_POINTER:
658+ case FFI_TYPE_UINT64:
659+ case FFI_TYPE_SINT64:
660+ if (state->ngrn < N_X_ARG_REG)
661+ return allocate_to_x (context, state);
662+ state->ngrn = N_X_ARG_REG;
663+ break;
664+ default:
665+ FFI_ASSERT (0);
666+ }
667+
668+ return allocate_to_stack (state, stack, alignment, size);
669+}
670+
671+/* Copy a value to an appropriate register, or if none are
672+ available, to the stack. */
673+
674+static void
675+copy_to_register_or_stack (struct call_context *context,
676+ unsigned char *stack,
677+ struct arg_state *state,
678+ void *value,
679+ unsigned short type)
680+{
681+ copy_basic_type (
682+ allocate_to_register_or_stack (context, stack, state, type),
683+ value,
684+ type);
685+}
686+
687+/* Marshall the arguments from FFI representation to procedure call
688+ context and stack. */
689+
690+static unsigned
691+aarch64_prep_args (struct call_context *context, unsigned char *stack,
692+ extended_cif *ecif)
693+{
694+ int i;
695+ struct arg_state state;
696+
697+ arg_init (&state, ALIGN(ecif->cif->bytes, 16));
698+
699+ for (i = 0; i < ecif->cif->nargs; i++)
700+ {
701+ ffi_type *ty = ecif->cif->arg_types[i];
702+ switch (ty->type)
703+ {
704+ case FFI_TYPE_VOID:
705+ FFI_ASSERT (0);
706+ break;
707+
708+ /* If the argument is a basic type the argument is allocated to an
709+ appropriate register, or if none are available, to the stack. */
710+ case FFI_TYPE_FLOAT:
711+ case FFI_TYPE_DOUBLE:
712+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
713+ case FFI_TYPE_LONGDOUBLE:
714+#endif
715+ case FFI_TYPE_UINT8:
716+ case FFI_TYPE_SINT8:
717+ case FFI_TYPE_UINT16:
718+ case FFI_TYPE_SINT16:
719+ case FFI_TYPE_UINT32:
720+ case FFI_TYPE_INT:
721+ case FFI_TYPE_SINT32:
722+ case FFI_TYPE_POINTER:
723+ case FFI_TYPE_UINT64:
724+ case FFI_TYPE_SINT64:
725+ copy_to_register_or_stack (context, stack, &state,
726+ ecif->avalue[i], ty->type);
727+ break;
728+
729+ case FFI_TYPE_STRUCT:
730+ if (is_hfa (ty))
731+ {
732+ copy_hfa_to_reg_or_stack (ecif->avalue[i], ty, context,
733+ stack, &state);
734+ }
735+ else if (ty->size > 16)
736+ {
737+ /* If the argument is a composite type that is larger than 16
738+ bytes, then the argument has been copied to memory, and
739+ the argument is replaced by a pointer to the copy. */
740+
741+ copy_to_register_or_stack (context, stack, &state,
742+ &(ecif->avalue[i]), FFI_TYPE_POINTER);
743+ }
744+ else if (available_x (&state) >= (ty->size + 7) / 8)
745+ {
746+ /* If the argument is a composite type and the size in
747+ double-words is not more than the number of available
748+ X registers, then the argument is copied into consecutive
749+ X registers. */
750+ int j;
751+ for (j = 0; j < (ty->size + 7) / 8; j++)
752+ {
753+ memcpy (allocate_to_x (context, &state),
754+ &(((UINT64 *) ecif->avalue[i])[j]),
755+ sizeof (UINT64));
756+ }
757+ }
758+ else
759+ {
760+ /* Otherwise, there are insufficient X registers. Further X
761+ register allocations are prevented, the NSAA is adjusted
762+ (by allocate_to_stack ()) and the argument is copied to
763+ memory at the adjusted NSAA. */
764+ state.ngrn = N_X_ARG_REG;
765+
766+ memcpy (allocate_to_stack (&state, stack, ty->alignment,
767+ ty->size), ecif->avalue + i, ty->size);
768+ }
769+ break;
770+
771+ default:
772+ FFI_ASSERT (0);
773+ break;
774+ }
775+
776+#if defined (__APPLE__)
777+ if (i + 1 == ecif->cif->aarch64_nfixedargs)
778+ {
779+ state.ngrn = N_X_ARG_REG;
780+ state.nsrn = N_V_ARG_REG;
781+
782+ state.allocating_variadic = 1;
783+ }
784+#endif
785+ }
786+
787+ return ecif->cif->aarch64_flags;
788+}
789+
790+ffi_status
791+ffi_prep_cif_machdep (ffi_cif *cif)
792+{
793+ /* Round the stack up to a multiple of the stack alignment requirement. */
794+ cif->bytes =
795+ (cif->bytes + (AARCH64_STACK_ALIGN - 1)) & ~ (AARCH64_STACK_ALIGN - 1);
796+
797+ /* Initialize our flags. We are interested if this CIF will touch a
798+ vector register, if so we will enable context save and load to
799+ those registers, otherwise not. This is intended to be friendly
800+ to lazy float context switching in the kernel. */
801+ cif->aarch64_flags = 0;
802+
803+ if (is_v_register_candidate (cif->rtype))
804+ {
805+ cif->aarch64_flags |= AARCH64_FFI_WITH_V;
806+ }
807+ else
808+ {
809+ int i;
810+ for (i = 0; i < cif->nargs; i++)
811+ if (is_v_register_candidate (cif->arg_types[i]))
812+ {
813+ cif->aarch64_flags |= AARCH64_FFI_WITH_V;
814+ break;
815+ }
816+ }
817+
818+ return FFI_OK;
819+}
820+
821+#if defined (__APPLE__)
822+
823+/* Perform Apple-specific cif processing for variadic calls */
824+ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
825+ unsigned int nfixedargs,
826+ unsigned int ntotalargs)
827+{
828+ cif->aarch64_nfixedargs = nfixedargs;
829+
830+ return ffi_prep_cif_machdep(cif);
831+}
832+
833+#endif
834+
835+/* Call a function with the provided arguments and capture the return
836+ value. */
837+void
838+ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
839+{
840+ extended_cif ecif;
841+
842+ ecif.cif = cif;
843+ ecif.avalue = avalue;
844+ ecif.rvalue = rvalue;
845+
846+ switch (cif->abi)
847+ {
848+ case FFI_SYSV:
849+ {
850+ struct call_context context;
851+ size_t stack_bytes;
852+
853+ /* Figure out the total amount of stack space we need, the
854+ above call frame space needs to be 16 bytes aligned to
855+ ensure correct alignment of the first object inserted in
856+ that space hence the ALIGN applied to cif->bytes.*/
857+ stack_bytes = ALIGN(cif->bytes, 16);
858+
859+ memset (&context, 0, sizeof (context));
860+ if (is_register_candidate (cif->rtype))
861+ {
862+ ffi_call_SYSV (aarch64_prep_args, &context, &ecif, stack_bytes, fn);
863+ switch (cif->rtype->type)
864+ {
865+ case FFI_TYPE_VOID:
866+ case FFI_TYPE_FLOAT:
867+ case FFI_TYPE_DOUBLE:
868+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
869+ case FFI_TYPE_LONGDOUBLE:
870+#endif
871+ case FFI_TYPE_UINT8:
872+ case FFI_TYPE_SINT8:
873+ case FFI_TYPE_UINT16:
874+ case FFI_TYPE_SINT16:
875+ case FFI_TYPE_UINT32:
876+ case FFI_TYPE_SINT32:
877+ case FFI_TYPE_POINTER:
878+ case FFI_TYPE_UINT64:
879+ case FFI_TYPE_INT:
880+ case FFI_TYPE_SINT64:
881+ {
882+ void *addr = get_basic_type_addr (cif->rtype->type,
883+ &context, 0);
884+ copy_basic_type (rvalue, addr, cif->rtype->type);
885+ break;
886+ }
887+
888+ case FFI_TYPE_STRUCT:
889+ if (is_hfa (cif->rtype))
890+ {
891+ int j;
892+ unsigned short type = get_homogeneous_type (cif->rtype);
893+ unsigned elems = element_count (cif->rtype);
894+ for (j = 0; j < elems; j++)
895+ {
896+ void *reg = get_basic_type_addr (type, &context, j);
897+ copy_basic_type (rvalue, reg, type);
898+ rvalue += get_basic_type_size (type);
899+ }
900+ }
901+ else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG)
902+ {
903+ size_t size = ALIGN (cif->rtype->size, sizeof (UINT64));
904+ memcpy (rvalue, get_x_addr (&context, 0), size);
905+ }
906+ else
907+ {
908+ FFI_ASSERT (0);
909+ }
910+ break;
911+
912+ default:
913+ FFI_ASSERT (0);
914+ break;
915+ }
916+ }
917+ else
918+ {
919+ memcpy (get_x_addr (&context, 8), &rvalue, sizeof (UINT64));
920+ ffi_call_SYSV (aarch64_prep_args, &context, &ecif,
921+ stack_bytes, fn);
922+ }
923+ break;
924+ }
925+
926+ default:
927+ FFI_ASSERT (0);
928+ break;
929+ }
930+}
931+
932+static unsigned char trampoline [] =
933+{ 0x70, 0x00, 0x00, 0x58, /* ldr x16, 1f */
934+ 0x91, 0x00, 0x00, 0x10, /* adr x17, 2f */
935+ 0x00, 0x02, 0x1f, 0xd6 /* br x16 */
936+};
937+
938+/* Build a trampoline. */
939+
940+#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,FLAGS) \
941+ ({unsigned char *__tramp = (unsigned char*)(TRAMP); \
942+ UINT64 __fun = (UINT64)(FUN); \
943+ UINT64 __ctx = (UINT64)(CTX); \
944+ UINT64 __flags = (UINT64)(FLAGS); \
945+ memcpy (__tramp, trampoline, sizeof (trampoline)); \
946+ memcpy (__tramp + 12, &__fun, sizeof (__fun)); \
947+ memcpy (__tramp + 20, &__ctx, sizeof (__ctx)); \
948+ memcpy (__tramp + 28, &__flags, sizeof (__flags)); \
949+ ffi_clear_cache(__tramp, __tramp + FFI_TRAMPOLINE_SIZE); \
950+ })
951+
952+ffi_status
953+ffi_prep_closure_loc (ffi_closure* closure,
954+ ffi_cif* cif,
955+ void (*fun)(ffi_cif*,void*,void**,void*),
956+ void *user_data,
957+ void *codeloc)
958+{
959+ if (cif->abi != FFI_SYSV)
960+ return FFI_BAD_ABI;
961+
962+ FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_SYSV, codeloc,
963+ cif->aarch64_flags);
964+
965+ closure->cif = cif;
966+ closure->user_data = user_data;
967+ closure->fun = fun;
968+
969+ return FFI_OK;
970+}
971+
972+/* Primary handler to setup and invoke a function within a closure.
973+
974+ A closure when invoked enters via the assembler wrapper
975+ ffi_closure_SYSV(). The wrapper allocates a call context on the
976+ stack, saves the interesting registers (from the perspective of
977+ the calling convention) into the context then passes control to
978+ ffi_closure_SYSV_inner() passing the saved context and a pointer to
979+ the stack at the point ffi_closure_SYSV() was invoked.
980+
981+ On the return path the assembler wrapper will reload call context
982+ registers.
983+
984+ ffi_closure_SYSV_inner() marshalls the call context into ffi value
985+ descriptors, invokes the wrapped function, then marshalls the return
986+ value back into the call context. */
987+
988+void FFI_HIDDEN
989+ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
990+ void *stack)
991+{
992+ ffi_cif *cif = closure->cif;
993+ void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
994+ void *rvalue = NULL;
995+ int i;
996+ struct arg_state state;
997+
998+ arg_init (&state, ALIGN(cif->bytes, 16));
999+
1000+ for (i = 0; i < cif->nargs; i++)
1001+ {
1002+ ffi_type *ty = cif->arg_types[i];
1003+
1004+ switch (ty->type)
1005+ {
1006+ case FFI_TYPE_VOID:
1007+ FFI_ASSERT (0);
1008+ break;
1009+
1010+ case FFI_TYPE_UINT8:
1011+ case FFI_TYPE_SINT8:
1012+ case FFI_TYPE_UINT16:
1013+ case FFI_TYPE_SINT16:
1014+ case FFI_TYPE_UINT32:
1015+ case FFI_TYPE_SINT32:
1016+ case FFI_TYPE_INT:
1017+ case FFI_TYPE_POINTER:
1018+ case FFI_TYPE_UINT64:
1019+ case FFI_TYPE_SINT64:
1020+ case FFI_TYPE_FLOAT:
1021+ case FFI_TYPE_DOUBLE:
1022+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
1023+ case FFI_TYPE_LONGDOUBLE:
1024+ avalue[i] = allocate_to_register_or_stack (context, stack,
1025+ &state, ty->type);
1026+ break;
1027+#endif
1028+
1029+ case FFI_TYPE_STRUCT:
1030+ if (is_hfa (ty))
1031+ {
1032+ unsigned n = element_count (ty);
1033+ if (available_v (&state) < n)
1034+ {
1035+ state.nsrn = N_V_ARG_REG;
1036+ avalue[i] = allocate_to_stack (&state, stack, ty->alignment,
1037+ ty->size);
1038+ }
1039+ else
1040+ {
1041+ switch (get_homogeneous_type (ty))
1042+ {
1043+ case FFI_TYPE_FLOAT:
1044+ {
1045+ /* Eeek! We need a pointer to the structure,
1046+ however the homogeneous float elements are
1047+ being passed in individual S registers,
1048+ therefore the structure is not represented as
1049+ a contiguous sequence of bytes in our saved
1050+ register context. We need to fake up a copy
1051+ of the structure laid out in memory
1052+ correctly. The fake can be tossed once the
1053+ closure function has returned hence alloca()
1054+ is sufficient. */
1055+ int j;
1056+ UINT32 *p = avalue[i] = alloca (ty->size);
1057+ for (j = 0; j < element_count (ty); j++)
1058+ memcpy (&p[j],
1059+ allocate_to_s (context, &state),
1060+ sizeof (*p));
1061+ break;
1062+ }
1063+
1064+ case FFI_TYPE_DOUBLE:
1065+ {
1066+ /* Eeek! We need a pointer to the structure,
1067+ however the homogeneous float elements are
1068+ being passed in individual S registers,
1069+ therefore the structure is not represented as
1070+ a contiguous sequence of bytes in our saved
1071+ register context. We need to fake up a copy
1072+ of the structure laid out in memory
1073+ correctly. The fake can be tossed once the
1074+ closure function has returned hence alloca()
1075+ is sufficient. */
1076+ int j;
1077+ UINT64 *p = avalue[i] = alloca (ty->size);
1078+ for (j = 0; j < element_count (ty); j++)
1079+ memcpy (&p[j],
1080+ allocate_to_d (context, &state),
1081+ sizeof (*p));
1082+ break;
1083+ }
1084+
1085+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
1086+ case FFI_TYPE_LONGDOUBLE:
1087+ memcpy (&avalue[i],
1088+ allocate_to_v (context, &state),
1089+ sizeof (*avalue));
1090+ break;
1091+#endif
1092+
1093+ default:
1094+ FFI_ASSERT (0);
1095+ break;
1096+ }
1097+ }
1098+ }
1099+ else if (ty->size > 16)
1100+ {
1101+ /* Replace Composite type of size greater than 16 with a
1102+ pointer. */
1103+ memcpy (&avalue[i],
1104+ allocate_to_register_or_stack (context, stack,
1105+ &state, FFI_TYPE_POINTER),
1106+ sizeof (avalue[i]));
1107+ }
1108+ else if (available_x (&state) >= (ty->size + 7) / 8)
1109+ {
1110+ avalue[i] = get_x_addr (context, state.ngrn);
1111+ state.ngrn += (ty->size + 7) / 8;
1112+ }
1113+ else
1114+ {
1115+ state.ngrn = N_X_ARG_REG;
1116+
1117+ avalue[i] = allocate_to_stack (&state, stack, ty->alignment,
1118+ ty->size);
1119+ }
1120+ break;
1121+
1122+ default:
1123+ FFI_ASSERT (0);
1124+ break;
1125+ }
1126+ }
1127+
1128+ /* Figure out where the return value will be passed, either in
1129+ registers or in a memory block allocated by the caller and passed
1130+ in x8. */
1131+
1132+ if (is_register_candidate (cif->rtype))
1133+ {
1134+ /* Register candidates are *always* returned in registers. */
1135+
1136+ /* Allocate a scratchpad for the return value, we will let the
1137+ callee scrible the result into the scratch pad then move the
1138+ contents into the appropriate return value location for the
1139+ call convention. */
1140+ rvalue = alloca (cif->rtype->size);
1141+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
1142+
1143+ /* Copy the return value into the call context so that it is returned
1144+ as expected to our caller. */
1145+ switch (cif->rtype->type)
1146+ {
1147+ case FFI_TYPE_VOID:
1148+ break;
1149+
1150+ case FFI_TYPE_UINT8:
1151+ case FFI_TYPE_UINT16:
1152+ case FFI_TYPE_UINT32:
1153+ case FFI_TYPE_POINTER:
1154+ case FFI_TYPE_UINT64:
1155+ case FFI_TYPE_SINT8:
1156+ case FFI_TYPE_SINT16:
1157+ case FFI_TYPE_INT:
1158+ case FFI_TYPE_SINT32:
1159+ case FFI_TYPE_SINT64:
1160+ case FFI_TYPE_FLOAT:
1161+ case FFI_TYPE_DOUBLE:
1162+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
1163+ case FFI_TYPE_LONGDOUBLE:
1164+#endif
1165+ {
1166+ void *addr = get_basic_type_addr (cif->rtype->type, context, 0);
1167+ copy_basic_type (addr, rvalue, cif->rtype->type);
1168+ break;
1169+ }
1170+ case FFI_TYPE_STRUCT:
1171+ if (is_hfa (cif->rtype))
1172+ {
1173+ int j;
1174+ unsigned short type = get_homogeneous_type (cif->rtype);
1175+ unsigned elems = element_count (cif->rtype);
1176+ for (j = 0; j < elems; j++)
1177+ {
1178+ void *reg = get_basic_type_addr (type, context, j);
1179+ copy_basic_type (reg, rvalue, type);
1180+ rvalue += get_basic_type_size (type);
1181+ }
1182+ }
1183+ else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG)
1184+ {
1185+ size_t size = ALIGN (cif->rtype->size, sizeof (UINT64)) ;
1186+ memcpy (get_x_addr (context, 0), rvalue, size);
1187+ }
1188+ else
1189+ {
1190+ FFI_ASSERT (0);
1191+ }
1192+ break;
1193+ default:
1194+ FFI_ASSERT (0);
1195+ break;
1196+ }
1197+ }
1198+ else
1199+ {
1200+ memcpy (&rvalue, get_x_addr (context, 8), sizeof (UINT64));
1201+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
1202+ }
1203+}
1204+
1205diff -ruN Python-2.7.3.orig/Modules/_ctypes/libffi/src/aarch64/ffitarget.h Python-2.7.3/Modules/_ctypes/libffi/src/aarch64/ffitarget.h
1206--- Python-2.7.3.orig/Modules/_ctypes/libffi/src/aarch64/ffitarget.h 1970-01-01 01:00:00.000000000 +0100
1207+++ Python-2.7.3/Modules/_ctypes/libffi/src/aarch64/ffitarget.h 2014-04-25 19:45:13.000000000 +0200
1208@@ -0,0 +1,63 @@
1209+/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
1210+
1211+Permission is hereby granted, free of charge, to any person obtaining
1212+a copy of this software and associated documentation files (the
1213+``Software''), to deal in the Software without restriction, including
1214+without limitation the rights to use, copy, modify, merge, publish,
1215+distribute, sublicense, and/or sell copies of the Software, and to
1216+permit persons to whom the Software is furnished to do so, subject to
1217+the following conditions:
1218+
1219+The above copyright notice and this permission notice shall be
1220+included in all copies or substantial portions of the Software.
1221+
1222+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
1223+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1224+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1225+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1226+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1227+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1228+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1229+
1230+#ifndef LIBFFI_TARGET_H
1231+#define LIBFFI_TARGET_H
1232+
1233+#ifndef LIBFFI_H
1234+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
1235+#endif
1236+
1237+#ifndef LIBFFI_ASM
1238+typedef unsigned long ffi_arg;
1239+typedef signed long ffi_sarg;
1240+
1241+typedef enum ffi_abi
1242+ {
1243+ FFI_FIRST_ABI = 0,
1244+ FFI_SYSV,
1245+ FFI_LAST_ABI,
1246+ FFI_DEFAULT_ABI = FFI_SYSV
1247+ } ffi_abi;
1248+#endif
1249+
1250+/* ---- Definitions for closures ----------------------------------------- */
1251+
1252+#define FFI_CLOSURES 1
1253+#define FFI_TRAMPOLINE_SIZE 36
1254+#define FFI_NATIVE_RAW_API 0
1255+
1256+/* ---- Internal ---- */
1257+
1258+#if defined (__APPLE__)
1259+#define FFI_TARGET_SPECIFIC_VARIADIC
1260+#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_flags; unsigned aarch64_nfixedargs
1261+#else
1262+#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_flags
1263+#endif
1264+
1265+#define AARCH64_FFI_WITH_V_BIT 0
1266+
1267+#define AARCH64_N_XREG 32
1268+#define AARCH64_N_VREG 32
1269+#define AARCH64_CALL_CONTEXT_SIZE (AARCH64_N_XREG * 8 + AARCH64_N_VREG * 16)
1270+
1271+#endif
1272diff -ruN Python-2.7.3.orig/Modules/_ctypes/libffi/src/aarch64/sysv.S Python-2.7.3/Modules/_ctypes/libffi/src/aarch64/sysv.S
1273--- Python-2.7.3.orig/Modules/_ctypes/libffi/src/aarch64/sysv.S 1970-01-01 01:00:00.000000000 +0100
1274+++ Python-2.7.3/Modules/_ctypes/libffi/src/aarch64/sysv.S 2014-04-25 19:45:13.000000000 +0200
1275@@ -0,0 +1,333 @@
1276+/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
1277+
1278+Permission is hereby granted, free of charge, to any person obtaining
1279+a copy of this software and associated documentation files (the
1280+``Software''), to deal in the Software without restriction, including
1281+without limitation the rights to use, copy, modify, merge, publish,
1282+distribute, sublicense, and/or sell copies of the Software, and to
1283+permit persons to whom the Software is furnished to do so, subject to
1284+the following conditions:
1285+
1286+The above copyright notice and this permission notice shall be
1287+included in all copies or substantial portions of the Software.
1288+
1289+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
1290+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1291+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1292+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1293+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1294+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1295+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
1296+
1297+#define LIBFFI_ASM
1298+#include <fficonfig.h>
1299+#include <ffi.h>
1300+
1301+#ifdef HAVE_MACHINE_ASM_H
1302+#include <machine/asm.h>
1303+#else
1304+#ifdef __USER_LABEL_PREFIX__
1305+#define CONCAT1(a, b) CONCAT2(a, b)
1306+#define CONCAT2(a, b) a ## b
1307+
1308+/* Use the right prefix for global labels. */
1309+#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
1310+#else
1311+#define CNAME(x) x
1312+#endif
1313+#endif
1314+
1315+#define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
1316+#define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
1317+#define cfi_restore(reg) .cfi_restore reg
1318+#define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg
1319+
1320+ .text
1321+ .globl CNAME(ffi_call_SYSV)
1322+#ifdef __ELF__
1323+ .type CNAME(ffi_call_SYSV), #function
1324+#endif
1325+#ifdef __APPLE__
1326+ .align 2
1327+#endif
1328+
1329+/* ffi_call_SYSV()
1330+
1331+ Create a stack frame, setup an argument context, call the callee
1332+ and extract the result.
1333+
1334+ The maximum required argument stack size is provided,
1335+ ffi_call_SYSV() allocates that stack space then calls the
1336+ prepare_fn to populate register context and stack. The
1337+ argument passing registers are loaded from the register
1338+ context and the callee called, on return the register passing
1339+ register are saved back to the context. Our caller will
1340+ extract the return value from the final state of the saved
1341+ register context.
1342+
1343+ Prototype:
1344+
1345+ extern unsigned
1346+ ffi_call_SYSV (void (*)(struct call_context *context, unsigned char *,
1347+ extended_cif *),
1348+ struct call_context *context,
1349+ extended_cif *,
1350+ size_t required_stack_size,
1351+ void (*fn)(void));
1352+
1353+ Therefore on entry we have:
1354+
1355+ x0 prepare_fn
1356+ x1 &context
1357+ x2 &ecif
1358+ x3 bytes
1359+ x4 fn
1360+
1361+ This function uses the following stack frame layout:
1362+
1363+ ==
1364+ saved x30(lr)
1365+ x29(fp)-> saved x29(fp)
1366+ saved x24
1367+ saved x23
1368+ saved x22
1369+ sp' -> saved x21
1370+ ...
1371+ sp -> (constructed callee stack arguments)
1372+ ==
1373+
1374+ Voila! */
1375+
1376+#define ffi_call_SYSV_FS (8 * 4)
1377+
1378+ .cfi_startproc
1379+CNAME(ffi_call_SYSV):
1380+ stp x29, x30, [sp, #-16]!
1381+ cfi_adjust_cfa_offset (16)
1382+ cfi_rel_offset (x29, 0)
1383+ cfi_rel_offset (x30, 8)
1384+
1385+ mov x29, sp
1386+ cfi_def_cfa_register (x29)
1387+ sub sp, sp, #ffi_call_SYSV_FS
1388+
1389+ stp x21, x22, [sp, #0]
1390+ cfi_rel_offset (x21, 0 - ffi_call_SYSV_FS)
1391+ cfi_rel_offset (x22, 8 - ffi_call_SYSV_FS)
1392+
1393+ stp x23, x24, [sp, #16]
1394+ cfi_rel_offset (x23, 16 - ffi_call_SYSV_FS)
1395+ cfi_rel_offset (x24, 24 - ffi_call_SYSV_FS)
1396+
1397+ mov x21, x1
1398+ mov x22, x2
1399+ mov x24, x4
1400+
1401+ /* Allocate the stack space for the actual arguments, many
1402+ arguments will be passed in registers, but we assume
1403+ worst case and allocate sufficient stack for ALL of
1404+ the arguments. */
1405+ sub sp, sp, x3
1406+
1407+ /* unsigned (*prepare_fn) (struct call_context *context,
1408+ unsigned char *stack, extended_cif *ecif);
1409+ */
1410+ mov x23, x0
1411+ mov x0, x1
1412+ mov x1, sp
1413+ /* x2 already in place */
1414+ blr x23
1415+
1416+ /* Preserve the flags returned. */
1417+ mov x23, x0
1418+
1419+ /* Figure out if we should touch the vector registers. */
1420+ tbz x23, #AARCH64_FFI_WITH_V_BIT, 1f
1421+
1422+ /* Load the vector argument passing registers. */
1423+ ldp q0, q1, [x21, #8*32 + 0]
1424+ ldp q2, q3, [x21, #8*32 + 32]
1425+ ldp q4, q5, [x21, #8*32 + 64]
1426+ ldp q6, q7, [x21, #8*32 + 96]
1427+1:
1428+ /* Load the core argument passing registers. */
1429+ ldp x0, x1, [x21, #0]
1430+ ldp x2, x3, [x21, #16]
1431+ ldp x4, x5, [x21, #32]
1432+ ldp x6, x7, [x21, #48]
1433+
1434+ /* Don't forget x8 which may be holding the address of a return buffer.
1435+ */
1436+ ldr x8, [x21, #8*8]
1437+
1438+ blr x24
1439+
1440+ /* Save the core argument passing registers. */
1441+ stp x0, x1, [x21, #0]
1442+ stp x2, x3, [x21, #16]
1443+ stp x4, x5, [x21, #32]
1444+ stp x6, x7, [x21, #48]
1445+
1446+ /* Note nothing useful ever comes back in x8! */
1447+
1448+ /* Figure out if we should touch the vector registers. */
1449+ tbz x23, #AARCH64_FFI_WITH_V_BIT, 1f
1450+
1451+ /* Save the vector argument passing registers. */
1452+ stp q0, q1, [x21, #8*32 + 0]
1453+ stp q2, q3, [x21, #8*32 + 32]
1454+ stp q4, q5, [x21, #8*32 + 64]
1455+ stp q6, q7, [x21, #8*32 + 96]
1456+1:
1457+ /* All done, unwind our stack frame. */
1458+ ldp x21, x22, [x29, # - ffi_call_SYSV_FS]
1459+ cfi_restore (x21)
1460+ cfi_restore (x22)
1461+
1462+ ldp x23, x24, [x29, # - ffi_call_SYSV_FS + 16]
1463+ cfi_restore (x23)
1464+ cfi_restore (x24)
1465+
1466+ mov sp, x29
1467+ cfi_def_cfa_register (sp)
1468+
1469+ ldp x29, x30, [sp], #16
1470+ cfi_adjust_cfa_offset (-16)
1471+ cfi_restore (x29)
1472+ cfi_restore (x30)
1473+
1474+ ret
1475+
1476+ .cfi_endproc
1477+#ifdef __ELF__
1478+ .size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV)
1479+#endif
1480+
1481+#define ffi_closure_SYSV_FS (8 * 2 + AARCH64_CALL_CONTEXT_SIZE)
1482+
1483+/* ffi_closure_SYSV
1484+
1485+ Closure invocation glue. This is the low level code invoked directly by
1486+ the closure trampoline to setup and call a closure.
1487+
1488+ On entry x17 points to a struct trampoline_data, x16 has been clobbered
1489+ all other registers are preserved.
1490+
1491+ We allocate a call context and save the argument passing registers,
1492+ then invoked the generic C ffi_closure_SYSV_inner() function to do all
1493+ the real work, on return we load the result passing registers back from
1494+ the call context.
1495+
1496+ On entry
1497+
1498+ extern void
1499+ ffi_closure_SYSV (struct trampoline_data *);
1500+
1501+ struct trampoline_data
1502+ {
1503+ UINT64 *ffi_closure;
1504+ UINT64 flags;
1505+ };
1506+
1507+ This function uses the following stack frame layout:
1508+
1509+ ==
1510+ saved x30(lr)
1511+ x29(fp)-> saved x29(fp)
1512+ saved x22
1513+ saved x21
1514+ ...
1515+ sp -> call_context
1516+ ==
1517+
1518+ Voila! */
1519+
1520+ .text
1521+ .globl CNAME(ffi_closure_SYSV)
1522+#ifdef __APPLE__
1523+ .align 2
1524+#endif
1525+ .cfi_startproc
1526+CNAME(ffi_closure_SYSV):
1527+ stp x29, x30, [sp, #-16]!
1528+ cfi_adjust_cfa_offset (16)
1529+ cfi_rel_offset (x29, 0)
1530+ cfi_rel_offset (x30, 8)
1531+
1532+ mov x29, sp
1533+ cfi_def_cfa_register (x29)
1534+
1535+ sub sp, sp, #ffi_closure_SYSV_FS
1536+
1537+ stp x21, x22, [x29, #-16]
1538+ cfi_rel_offset (x21, -16)
1539+ cfi_rel_offset (x22, -8)
1540+
1541+ /* Load x21 with &call_context. */
1542+ mov x21, sp
1543+ /* Preserve our struct trampoline_data * */
1544+ mov x22, x17
1545+
1546+ /* Save the rest of the argument passing registers. */
1547+ stp x0, x1, [x21, #0]
1548+ stp x2, x3, [x21, #16]
1549+ stp x4, x5, [x21, #32]
1550+ stp x6, x7, [x21, #48]
1551+ /* Don't forget we may have been given a result scratch pad address.
1552+ */
1553+ str x8, [x21, #64]
1554+
1555+ /* Figure out if we should touch the vector registers. */
1556+ ldr x0, [x22, #8]
1557+ tbz x0, #AARCH64_FFI_WITH_V_BIT, 1f
1558+
1559+ /* Save the argument passing vector registers. */
1560+ stp q0, q1, [x21, #8*32 + 0]
1561+ stp q2, q3, [x21, #8*32 + 32]
1562+ stp q4, q5, [x21, #8*32 + 64]
1563+ stp q6, q7, [x21, #8*32 + 96]
1564+1:
1565+ /* Load &ffi_closure.. */
1566+ ldr x0, [x22, #0]
1567+ mov x1, x21
1568+ /* Compute the location of the stack at the point that the
1569+ trampoline was called. */
1570+ add x2, x29, #16
1571+
1572+ bl CNAME(ffi_closure_SYSV_inner)
1573+
1574+ /* Figure out if we should touch the vector registers. */
1575+ ldr x0, [x22, #8]
1576+ tbz x0, #AARCH64_FFI_WITH_V_BIT, 1f
1577+
1578+ /* Load the result passing vector registers. */
1579+ ldp q0, q1, [x21, #8*32 + 0]
1580+ ldp q2, q3, [x21, #8*32 + 32]
1581+ ldp q4, q5, [x21, #8*32 + 64]
1582+ ldp q6, q7, [x21, #8*32 + 96]
1583+1:
1584+ /* Load the result passing core registers. */
1585+ ldp x0, x1, [x21, #0]
1586+ ldp x2, x3, [x21, #16]
1587+ ldp x4, x5, [x21, #32]
1588+ ldp x6, x7, [x21, #48]
1589+ /* Note nothing useful is returned in x8. */
1590+
1591+ /* We are done, unwind our frame. */
1592+ ldp x21, x22, [x29, #-16]
1593+ cfi_restore (x21)
1594+ cfi_restore (x22)
1595+
1596+ mov sp, x29
1597+ cfi_def_cfa_register (sp)
1598+
1599+ ldp x29, x30, [sp], #16
1600+ cfi_adjust_cfa_offset (-16)
1601+ cfi_restore (x29)
1602+ cfi_restore (x30)
1603+
1604+ ret
1605+ .cfi_endproc
1606+#ifdef __ELF__
1607+ .size CNAME(ffi_closure_SYSV), .-CNAME(ffi_closure_SYSV)
1608+#endif
diff --git a/meta/recipes-devtools/python/python/multilib.patch b/meta/recipes-devtools/python/python/multilib.patch
new file mode 100644
index 0000000000..df470f7c09
--- /dev/null
+++ b/meta/recipes-devtools/python/python/multilib.patch
@@ -0,0 +1,257 @@
1commit 248279e54467a8cd5cde98fc124d1d1384703513
2Author: Yu Ke <ke.yu@intel.com>
3Date: Tue Jun 28 21:21:29 2011 +0800
4
5 SUSE patch for the lib64 issue
6
7 see detail in http://bugs.python.org/issue1294959
8
9 also rebased a bit for Yocto python 2.6.6
10
11 Picked-by: Yu Ke <ke.yu@intel.com>
12
132011/09/29
14Rebased for python 2.7.2
15
16Upstream-Status: Inappropriate [configuration]
17
18Signed-Off-By: Nitin A Kamble <nitin.a.kamble@intel.com>
19
20Index: Python-2.7.2/Include/pythonrun.h
21===================================================================
22--- Python-2.7.2.orig/Include/pythonrun.h
23+++ Python-2.7.2/Include/pythonrun.h
24@@ -108,6 +108,7 @@ PyAPI_FUNC(char *) Py_GetPath(void);
25 /* In their own files */
26 PyAPI_FUNC(const char *) Py_GetVersion(void);
27 PyAPI_FUNC(const char *) Py_GetPlatform(void);
28+PyAPI_FUNC(const char *) Py_GetLib(void);
29 PyAPI_FUNC(const char *) Py_GetCopyright(void);
30 PyAPI_FUNC(const char *) Py_GetCompiler(void);
31 PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
32Index: Python-2.7.2/Lib/distutils/command/install.py
33===================================================================
34--- Python-2.7.2.orig/Lib/distutils/command/install.py
35+++ Python-2.7.2/Lib/distutils/command/install.py
36@@ -22,6 +22,8 @@ from site import USER_BASE
37 from site import USER_SITE
38
39
40+libname = sys.lib
41+
42 if sys.version < "2.2":
43 WINDOWS_SCHEME = {
44 'purelib': '$base',
45@@ -42,7 +44,7 @@ else:
46 INSTALL_SCHEMES = {
47 'unix_prefix': {
48 'purelib': '$base/lib/python$py_version_short/site-packages',
49- 'platlib': '$platbase/lib/python$py_version_short/site-packages',
50+ 'platlib': '$platbase/'+libname+'/python$py_version_short/site-packages',
51 'headers': '$base/include/python$py_version_short/$dist_name',
52 'scripts': '$base/bin',
53 'data' : '$base',
54Index: Python-2.7.2/Lib/distutils/sysconfig.py
55===================================================================
56--- Python-2.7.2.orig/Lib/distutils/sysconfig.py
57+++ Python-2.7.2/Lib/distutils/sysconfig.py
58@@ -114,8 +114,11 @@ def get_python_lib(plat_specific=0, stan
59 prefix = plat_specific and EXEC_PREFIX or PREFIX
60
61 if os.name == "posix":
62- libpython = os.path.join(prefix,
63- "lib", "python" + get_python_version())
64+ if plat_specific or standard_lib:
65+ lib = sys.lib
66+ else:
67+ lib = "lib"
68+ libpython = os.path.join(prefix, lib, "python" + get_python_version())
69 if standard_lib:
70 return libpython
71 else:
72Index: Python-2.7.2/Lib/pydoc.py
73===================================================================
74--- Python-2.7.2.orig/Lib/pydoc.py
75+++ Python-2.7.2/Lib/pydoc.py
76@@ -352,7 +352,7 @@ class Doc:
77
78 docloc = os.environ.get("PYTHONDOCS",
79 "http://docs.python.org/library")
80- basedir = os.path.join(sys.exec_prefix, "lib",
81+ basedir = os.path.join(sys.exec_prefix, sys.lib,
82 "python"+sys.version[0:3])
83 if (isinstance(object, type(os)) and
84 (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
85Index: Python-2.7.2/Lib/site.py
86===================================================================
87--- Python-2.7.2.orig/Lib/site.py
88+++ Python-2.7.2/Lib/site.py
89@@ -300,13 +300,19 @@ def getsitepackages():
90 if sys.platform in ('os2emx', 'riscos'):
91 sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
92 elif os.sep == '/':
93- sitepackages.append(os.path.join(prefix, "lib",
94+ sitepackages.append(os.path.join(prefix, sys.lib,
95 "python" + sys.version[:3],
96 "site-packages"))
97- sitepackages.append(os.path.join(prefix, "lib", "site-python"))
98+ if sys.lib != "lib":
99+ sitepackages.append(os.path.join(prefix, "lib",
100+ "python" + sys.version[:3],
101+ "site-packages"))
102+ sitepackages.append(os.path.join(prefix, sys.lib, "site-python"))
103+ if sys.lib != "lib":
104+ sitepackages.append(os.path.join(prefix, "lib", "site-python"))
105 else:
106 sitepackages.append(prefix)
107- sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
108+ sitepackages.append(os.path.join(prefix, sys.lib, "site-packages"))
109 if sys.platform == "darwin":
110 # for framework builds *only* we add the standard Apple
111 # locations.
112Index: Python-2.7.2/Lib/test/test_dl.py
113===================================================================
114--- Python-2.7.2.orig/Lib/test/test_dl.py
115+++ Python-2.7.2/Lib/test/test_dl.py
116@@ -5,10 +5,11 @@
117 import unittest
118 from test.test_support import verbose, import_module
119 dl = import_module('dl', deprecated=True)
120+import sys
121
122 sharedlibs = [
123- ('/usr/lib/libc.so', 'getpid'),
124- ('/lib/libc.so.6', 'getpid'),
125+ ('/usr/'+sys.lib+'/libc.so', 'getpid'),
126+ ('/'+sys.lib+'/libc.so.6', 'getpid'),
127 ('/usr/bin/cygwin1.dll', 'getpid'),
128 ('/usr/lib/libc.dylib', 'getpid'),
129 ]
130Index: Python-2.7.2/Lib/trace.py
131===================================================================
132--- Python-2.7.2.orig/Lib/trace.py
133+++ Python-2.7.2/Lib/trace.py
134@@ -762,10 +762,10 @@ def main(argv=None):
135 # should I also call expanduser? (after all, could use $HOME)
136
137 s = s.replace("$prefix",
138- os.path.join(sys.prefix, "lib",
139+ os.path.join(sys.prefix, sys.lib,
140 "python" + sys.version[:3]))
141 s = s.replace("$exec_prefix",
142- os.path.join(sys.exec_prefix, "lib",
143+ os.path.join(sys.exec_prefix, sys.lib,
144 "python" + sys.version[:3]))
145 s = os.path.normpath(s)
146 ignore_dirs.append(s)
147Index: Python-2.7.2/Makefile.pre.in
148===================================================================
149--- Python-2.7.2.orig/Makefile.pre.in
150+++ Python-2.7.2/Makefile.pre.in
151@@ -81,6 +81,7 @@ PY_CFLAGS= $(CFLAGS) $(CPPFLAGS) $(CFLAG
152
153 # Machine-dependent subdirectories
154 MACHDEP= @MACHDEP@
155+LIB= @LIB@
156
157 # Install prefix for architecture-independent files
158 prefix= @prefix@
159@@ -97,7 +98,7 @@ LIBDIR= @libdir@
160 MANDIR= @mandir@
161 INCLUDEDIR= @includedir@
162 CONFINCLUDEDIR= $(exec_prefix)/include
163-SCRIPTDIR= $(prefix)/lib
164+SCRIPTDIR= $(prefix)/@LIB@
165
166 # Detailed destination directories
167 BINLIBDEST= $(LIBDIR)/python$(VERSION)
168@@ -533,6 +534,7 @@ Modules/getpath.o: $(srcdir)/Modules/get
169 -DEXEC_PREFIX='"$(exec_prefix)"' \
170 -DVERSION='"$(VERSION)"' \
171 -DVPATH='"$(VPATH)"' \
172+ -DLIB='"$(LIB)"' \
173 -o $@ $(srcdir)/Modules/getpath.c
174
175 Modules/python.o: $(srcdir)/Modules/python.c
176@@ -567,7 +569,7 @@ $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
177 Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
178
179 Python/getplatform.o: $(srcdir)/Python/getplatform.c
180- $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
181+ $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -DLIB='"$(LIB)"' -o $@ $(srcdir)/Python/getplatform.c
182
183 Python/importdl.o: $(srcdir)/Python/importdl.c
184 $(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
185Index: Python-2.7.2/Modules/getpath.c
186===================================================================
187--- Python-2.7.2.orig/Modules/getpath.c
188+++ Python-2.7.2/Modules/getpath.c
189@@ -116,9 +116,11 @@
190 #define EXEC_PREFIX PREFIX
191 #endif
192
193+#define LIB_PYTHON LIB "/python" VERSION
194+
195 #ifndef PYTHONPATH
196-#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
197- EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"
198+#define PYTHONPATH PREFIX "/" LIB_PYTHON ":" \
199+ EXEC_PREFIX "/" LIB_PYTHON "/lib-dynload"
200 #endif
201
202 #ifndef LANDMARK
203@@ -129,7 +131,7 @@ static char prefix[MAXPATHLEN+1];
204 static char exec_prefix[MAXPATHLEN+1];
205 static char progpath[MAXPATHLEN+1];
206 static char *module_search_path = NULL;
207-static char lib_python[] = "lib/python" VERSION;
208+static char lib_python[] = LIB_PYTHON;
209
210 static void
211 reduce(char *dir)
212Index: Python-2.7.2/Python/getplatform.c
213===================================================================
214--- Python-2.7.2.orig/Python/getplatform.c
215+++ Python-2.7.2/Python/getplatform.c
216@@ -10,3 +10,13 @@ Py_GetPlatform(void)
217 {
218 return PLATFORM;
219 }
220+
221+#ifndef LIB
222+#define LIB "lib"
223+#endif
224+
225+const char *
226+Py_GetLib(void)
227+{
228+ return LIB;
229+}
230Index: Python-2.7.2/Python/sysmodule.c
231===================================================================
232--- Python-2.7.2.orig/Python/sysmodule.c
233+++ Python-2.7.2/Python/sysmodule.c
234@@ -1416,6 +1416,8 @@ _PySys_Init(void)
235 PyString_FromString(Py_GetCopyright()));
236 SET_SYS_FROM_STRING("platform",
237 PyString_FromString(Py_GetPlatform()));
238+ SET_SYS_FROM_STRING("lib",
239+ PyString_FromString(Py_GetLib()));
240 SET_SYS_FROM_STRING("executable",
241 PyString_FromString(Py_GetProgramFullPath()));
242 SET_SYS_FROM_STRING("prefix",
243Index: Python-2.7.2/configure.in
244===================================================================
245--- Python-2.7.2.orig/configure.in
246+++ Python-2.7.2/configure.in
247@@ -629,6 +629,10 @@ SunOS*)
248 ;;
249 esac
250
251+AC_SUBST(LIB)
252+AC_MSG_CHECKING(LIB)
253+LIB=`basename ${libdir}`
254+AC_MSG_RESULT($LIB)
255
256 AC_SUBST(LIBRARY)
257 AC_MSG_CHECKING(LIBRARY)
diff --git a/meta/recipes-devtools/python/python/parallel-makeinst-create-bindir.patch b/meta/recipes-devtools/python/python/parallel-makeinst-create-bindir.patch
new file mode 100644
index 0000000000..951cb466ff
--- /dev/null
+++ b/meta/recipes-devtools/python/python/parallel-makeinst-create-bindir.patch
@@ -0,0 +1,19 @@
1When using make -j with the 'install' target, it's possible for altbininstall
2(which normally creates BINDIR) and libainstall (which doesn't, though it
3installs python-config there) to race, resulting in a failure due to
4attempting to install python-config into a nonexistent BINDIR. Ensure it also
5exists in the libainstall target.
6
7Upstream-Status: Pending
8
9--- Python-2.7.3.orig/Makefile.pre.in
10+++ Python-2.7.3/Makefile.pre.in
11@@ -1008,7 +1008,7 @@ LIBPL= $(LIBP)/config
12 LIBPC= $(LIBDIR)/pkgconfig
13
14 libainstall: all python-config
15- @for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
16+ @for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC) $(BINDIR); \
17 do \
18 if test ! -d $(DESTDIR)$$i; then \
19 echo "Creating directory $$i"; \
diff --git a/meta/recipes-devtools/python/python/posix_close.patch b/meta/recipes-devtools/python/python/posix_close.patch
new file mode 100644
index 0000000000..725531a240
--- /dev/null
+++ b/meta/recipes-devtools/python/python/posix_close.patch
@@ -0,0 +1,43 @@
1backport from http://bugs.python.org/issue20594
2
3- Issue #20594: Avoid name clash with the libc function posix_close.
4
5Upstream-Status: Backport
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8
9# HG changeset patch
10# User Benjamin Peterson <benjamin@python.org>
11# Date 1392131776 18000
12# Node ID 1d253360d5a6d8d987fb2480e26f4fcc2d730932
13# Parent 41e49f1c5bd8ff48a6c18804c958e82c659daab3
14avoid name clash with posix_close (closes #20594)
15
16diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
17--- a/Modules/posixmodule.c
18+++ b/Modules/posixmodule.c
19@@ -6581,8 +6581,12 @@ PyDoc_STRVAR(posix_close__doc__,
20 "close(fd)\n\n\
21 Close a file descriptor (for low level IO).");
22
23-static PyObject *
24-posix_close(PyObject *self, PyObject *args)
25+/*
26+The underscore at end of function name avoids a name clash with the libc
27+function posix_close.
28+*/
29+static PyObject *
30+posix_close_(PyObject *self, PyObject *args)
31 {
32 int fd, res;
33 if (!PyArg_ParseTuple(args, "i:close", &fd))
34@@ -8960,7 +8964,7 @@ static PyMethodDef posix_methods[] = {
35 {"tcsetpgrp", posix_tcsetpgrp, METH_VARARGS, posix_tcsetpgrp__doc__},
36 #endif /* HAVE_TCSETPGRP */
37 {"open", posix_open, METH_VARARGS, posix_open__doc__},
38- {"close", posix_close, METH_VARARGS, posix_close__doc__},
39+ {"close", posix_close_, METH_VARARGS, posix_close__doc__},
40 {"closerange", posix_closerange, METH_VARARGS, posix_closerange__doc__},
41 {"dup", posix_dup, METH_VARARGS, posix_dup__doc__},
42 {"dup2", posix_dup2, METH_VARARGS, posix_dup2__doc__},
43
diff --git a/meta/recipes-devtools/python/python/pypirc-secure.patch b/meta/recipes-devtools/python/python/pypirc-secure.patch
new file mode 100644
index 0000000000..8e2df677b6
--- /dev/null
+++ b/meta/recipes-devtools/python/python/pypirc-secure.patch
@@ -0,0 +1,35 @@
1# HG changeset patch
2# User Philip Jenvey <pjenvey@underboss.org>
3# Date 1322701507 28800
4# Branch 2.7
5# Node ID e7c20a8476a0e2ca18f8040864cbc400818d8f24
6# Parent 3ecddf168f1f554a17a047384fe0b02f2d688277
7create the .pypirc securely
8
9Upstream-Status: Backport
10
11Signed-off-by: Saul Wold <sgw@linux.intel.com>
12
13
14diff -r 3ecddf168f1f -r e7c20a8476a0 Lib/distutils/config.py
15--- a/Lib/distutils/config.py Tue Nov 29 00:53:09 2011 +0100
16+++ b/Lib/distutils/config.py Wed Nov 30 17:05:07 2011 -0800
17@@ -42,16 +42,8 @@
18 def _store_pypirc(self, username, password):
19 """Creates a default .pypirc file."""
20 rc = self._get_rc_file()
21- f = open(rc, 'w')
22- try:
23- f.write(DEFAULT_PYPIRC % (username, password))
24- finally:
25- f.close()
26- try:
27- os.chmod(rc, 0600)
28- except OSError:
29- # should do something better here
30- pass
31+ with os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0600), 'w') as fp:
32+ fp.write(DEFAULT_PYPIRC % (username, password))
33
34 def _read_pypirc(self):
35 """Reads the .pypirc file."""
diff --git a/meta/recipes-devtools/python/python/python-2.7.3-CVE-2012-2135.patch b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2012-2135.patch
new file mode 100644
index 0000000000..3afdbc0f6e
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2012-2135.patch
@@ -0,0 +1,73 @@
1Upstream-Status: Backport
2
3Reference:http://bugs.python.org/issue14579
4
5The utf-16 decoder in Python 3.1 through 3.3 does not update the
6aligned_end variable after calling the unicode_decode_call_errorhandler
7function, which allows remote attackers to obtain sensitive information
8(process memory) or cause a denial of service (memory corruption and crash)
9via unspecified vectors.
10
11http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-2135
12
13diff -urpN a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
14--- a/Lib/test/test_codecs.py
15+++ b/Lib/test/test_codecs.py
16@@ -495,8 +495,21 @@ class UTF16LETest(ReadTest):
17 )
18
19 def test_errors(self):
20- self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode, "\xff", "strict", True)
21-
22+ tests = [
23+ (b'\xff', u'\ufffd'),
24+ (b'A\x00Z', u'A\ufffd'),
25+ (b'A\x00B\x00C\x00D\x00Z', u'ABCD\ufffd'),
26+ (b'\x00\xd8', u'\ufffd'),
27+ (b'\x00\xd8A', u'\ufffd'),
28+ (b'\x00\xd8A\x00', u'\ufffdA'),
29+ (b'\x00\xdcA\x00', u'\ufffdA'),
30+ ]
31+ for raw, expected in tests:
32+ print('*****', raw, expected)
33+ self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode,
34+ raw, 'strict', True)
35+ self.assertEqual(raw.decode('utf-16le', 'replace'), expected)
36+
37 class UTF16BETest(ReadTest):
38 encoding = "utf-16-be"
39
40@@ -516,7 +529,20 @@ class UTF16BETest(ReadTest):
41 )
42
43 def test_errors(self):
44- self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode, "\xff", "strict", True)
45+ tests = [
46+ (b'\xff', u'\ufffd'),
47+ (b'\x00A\xff', u'A\ufffd'),
48+ (b'\x00A\x00B\x00C\x00DZ', u'ABCD\ufffd'),
49+ (b'\xd8\x00', u'\ufffd'),
50+ (b'\xd8\x00\xdc', u'\ufffd'),
51+ (b'\xd8\x00\x00A', u'\ufffdA'),
52+ (b'\xdc\x00\x00A', u'\ufffdA'),
53+ ]
54+ for raw, expected in tests:
55+ print('*****', raw, expected)
56+ self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode,
57+ raw, 'strict', True)
58+ self.assertEqual(raw.decode('utf-16be', 'replace'), expected)
59
60 class UTF8Test(ReadTest):
61 encoding = "utf-8"
62diff -urpN a/Objects/unicodeobject.c b/Objects/unicodeobject.c
63--- a/Objects/unicodeobject.c 2013-03-04 11:34:34.000000000 +0800
64+++ b/Objects/unicodeobject.c 2013-03-04 11:36:01.000000000 +0800
65@@ -2564,7 +2564,7 @@ PyUnicode_DecodeUTF16Stateful(const char
66 }
67
68 /* UTF-16 code pair: */
69- if (q >= e) {
70+ if (e - q < 2) {
71 errmsg = "unexpected end of data";
72 startinpos = (((const char *)q)-2)-starts;
73 endinpos = ((const char *)e)-starts;
diff --git a/meta/recipes-devtools/python/python/python-2.7.3-CVE-2013-1752-smtplib-fix.patch b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2013-1752-smtplib-fix.patch
new file mode 100644
index 0000000000..f34ff40ea5
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2013-1752-smtplib-fix.patch
@@ -0,0 +1,101 @@
1Upstream-Status: Backport
2
3Reference: http://bugs.python.org/issue16042
4
5CVE-2013-1752: smtplib: Limit amount of data read by limiting the
6call to readline(). Original patch by Christian Heimes
7
8Signed-off-by: Maxin B. John <maxin.john@enea.com>
9---
10diff -Naur Python-2.7.3-orig/Lib/smtplib.py Python-2.7.3/Lib/smtplib.py
11--- Python-2.7.3-orig/Lib/smtplib.py 2012-04-10 01:07:31.000000000 +0200
12+++ Python-2.7.3/Lib/smtplib.py 2014-02-27 14:15:24.444198465 +0100
13@@ -57,6 +57,7 @@
14 SMTP_PORT = 25
15 SMTP_SSL_PORT = 465
16 CRLF = "\r\n"
17+_MAXLINE = 8192 # more than 8 times larger than RFC 821, 4.5.3
18
19 OLDSTYLE_AUTH = re.compile(r"auth=(.*)", re.I)
20
21@@ -179,10 +180,14 @@
22 def __init__(self, sslobj):
23 self.sslobj = sslobj
24
25- def readline(self):
26+ def readline(self, size=-1):
27+ if size < 0:
28+ size = None
29 str = ""
30 chr = None
31 while chr != "\n":
32+ if size is not None and len(str) >= size:
33+ break
34 chr = self.sslobj.read(1)
35 if not chr:
36 break
37@@ -351,7 +356,7 @@
38 self.file = self.sock.makefile('rb')
39 while 1:
40 try:
41- line = self.file.readline()
42+ line = self.file.readline(_MAXLINE + 1)
43 except socket.error as e:
44 self.close()
45 raise SMTPServerDisconnected("Connection unexpectedly closed: "
46@@ -361,6 +366,8 @@
47 raise SMTPServerDisconnected("Connection unexpectedly closed")
48 if self.debuglevel > 0:
49 print>>stderr, 'reply:', repr(line)
50+ if len(line) > _MAXLINE:
51+ raise SMTPResponseException(500, "Line too long.")
52 resp.append(line[4:].strip())
53 code = line[:3]
54 # Check that the error code is syntactically correct.
55diff -Naur Python-2.7.3-orig/Lib/test/test_smtplib.py Python-2.7.3/Lib/test/test_smtplib.py
56--- Python-2.7.3-orig/Lib/test/test_smtplib.py 2012-04-10 01:07:32.000000000 +0200
57+++ Python-2.7.3/Lib/test/test_smtplib.py 2014-02-27 14:15:24.448198293 +0100
58@@ -292,6 +292,33 @@
59 HOST, self.port, 'localhost', 3)
60
61
62+@unittest.skipUnless(threading, 'Threading required for this test.')
63+class TooLongLineTests(unittest.TestCase):
64+ respdata = '250 OK' + ('.' * smtplib._MAXLINE * 2) + '\n'
65+
66+ def setUp(self):
67+ self.old_stdout = sys.stdout
68+ self.output = StringIO.StringIO()
69+ sys.stdout = self.output
70+
71+ self.evt = threading.Event()
72+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
73+ self.sock.settimeout(15)
74+ self.port = test_support.bind_port(self.sock)
75+ servargs = (self.evt, self.respdata, self.sock)
76+ threading.Thread(target=server, args=servargs).start()
77+ self.evt.wait()
78+ self.evt.clear()
79+
80+ def tearDown(self):
81+ self.evt.wait()
82+ sys.stdout = self.old_stdout
83+
84+ def testLineTooLong(self):
85+ self.assertRaises(smtplib.SMTPResponseException, smtplib.SMTP,
86+ HOST, self.port, 'localhost', 3)
87+
88+
89 sim_users = {'Mr.A@somewhere.com':'John A',
90 'Ms.B@somewhere.com':'Sally B',
91 'Mrs.C@somewhereesle.com':'Ruth C',
92@@ -511,7 +538,8 @@
93 def test_main(verbose=None):
94 test_support.run_unittest(GeneralTests, DebuggingServerTests,
95 NonConnectingTests,
96- BadHELOServerTests, SMTPSimTests)
97+ BadHELOServerTests, SMTPSimTests,
98+ TooLongLineTests)
99
100 if __name__ == '__main__':
101 test_main()
diff --git a/meta/recipes-devtools/python/python/python-2.7.3-CVE-2014-1912.patch b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2014-1912.patch
new file mode 100644
index 0000000000..02cc83d314
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2014-1912.patch
@@ -0,0 +1,26 @@
1Upstream-Status: Backport
2
3Reference: http://bugs.python.org/issue20246
4
5CVE-2014-1912: Python buffer overflow in socket.recvfrom_into()
6lets remote users execute arbitrary code.Original patch by Benjamin Peterson
7
8Signed-off-by: Maxin B. John <maxin.john@enea.com>
9---
10diff -r 40fb60df4755 Modules/socketmodule.c
11--- a/Modules/socketmodule.c Sun Jan 12 12:11:47 2014 +0200
12+++ b/Modules/socketmodule.c Mon Jan 13 16:36:35 2014 -0800
13@@ -2744,6 +2744,13 @@
14 recvlen = buflen;
15 }
16
17+ /* Check if the buffer is large enough */
18+ if (buflen < recvlen) {
19+ PyErr_SetString(PyExc_ValueError,
20+ "buffer too small for requested bytes");
21+ goto error;
22+ }
23+
24 readlen = sock_recvfrom_guts(s, buf.buf, recvlen, flags, &addr);
25 if (readlen < 0) {
26 /* Return an error */
diff --git a/meta/recipes-devtools/python/python/python-2.7.3-CVE-2014-7185.patch b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2014-7185.patch
new file mode 100644
index 0000000000..60ef145c7c
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-2.7.3-CVE-2014-7185.patch
@@ -0,0 +1,75 @@
1From 104eb318283dde5203aa6cf7384287bef181e308 Mon Sep 17 00:00:00 2001
2From: Wenzong Fan <wenzong.fan@windriver.com>
3Date: Wed, 12 Nov 2014 01:58:02 -0500
4Subject: [PATCH] python: fix CVE-2014-7185
5
6Reference: http://bugs.python.org/issue21831
7
8CVE-2014-7185: Integer overflow in bufferobject.c in Python before
92.7.8 allows context-dependent attackers to obtain sensitive
10information from process memory via a large size and offset in a
11"buffer" function.
12
13Upstream-Status: Backport
14
15Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
16---
17 Lib/test/test_buffer.py | 6 ++++++
18 Misc/NEWS | 3 +++
19 Objects/bufferobject.c | 2 +-
20 3 files changed, 10 insertions(+), 1 deletion(-)
21
22diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
23index 6bdc34d..3ac1f8c 100644
24--- a/Lib/test/test_buffer.py
25+++ b/Lib/test/test_buffer.py
26@@ -4,6 +4,7 @@ For now, tests just new or changed functionality.
27
28 """
29
30+import sys
31 import unittest
32 from test import test_support
33
34@@ -21,6 +22,11 @@ class BufferTests(unittest.TestCase):
35 self.assertEqual(b[start:stop:step],
36 s[start:stop:step])
37
38+ def test_large_buffer_size_and_offset(self):
39+ data = bytearray('hola mundo')
40+ buf = buffer(data, sys.maxsize, sys.maxsize)
41+ self.assertEqual(buf[:4096], "")
42+
43
44 def test_main():
45 with test_support.check_py3k_warnings(("buffer.. not supported",
46diff --git a/Misc/NEWS b/Misc/NEWS
47index e8778ad..77396c5 100644
48--- a/Misc/NEWS
49+++ b/Misc/NEWS
50@@ -1896,6 +1896,9 @@ What's New in Python 2.7 Release Candidate 1?
51 Core and Builtins
52 -----------------
53
54+- Issue #21831: Avoid integer overflow when large sizes and offsets are given to
55+ the buffer type. CVE-2014-7185.
56+
57 - Issue #8271: during the decoding of an invalid UTF-8 byte sequence, only the
58 start byte and the continuation byte(s) are now considered invalid, instead
59 of the number of bytes specified by the start byte.
60diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c
61index c52f0bc..c542506 100644
62--- a/Objects/bufferobject.c
63+++ b/Objects/bufferobject.c
64@@ -88,7 +88,7 @@ get_buf(PyBufferObject *self, void **ptr, Py_ssize_t *size,
65 *size = count;
66 else
67 *size = self->b_size;
68- if (offset + *size > count)
69+ if (*size > count - offset)
70 *size = count - offset;
71 }
72 return 1;
73--
741.7.9.5
75
diff --git a/meta/recipes-devtools/python/python/python-2.7.3-berkeley-db-5.3.patch b/meta/recipes-devtools/python/python/python-2.7.3-berkeley-db-5.3.patch
new file mode 100644
index 0000000000..3df33368ec
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-2.7.3-berkeley-db-5.3.patch
@@ -0,0 +1,1572 @@
1Upstream-Status: Inappropriate [not author]
2
3Fix to support db 5.3 for bsddb module in python 2.7.2
4
5This patch is made from the db5.1.diff in
6http://archive.ubuntu.com/ubuntu/pool/main/p/python2.7/python2.7_2.7.3-0ubuntu3.diff.gz
7
8Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
9---
10 Lib/bsddb/__init__.py | 2 +-
11 Lib/bsddb/test/test_all.py | 5 +-
12 Lib/bsddb/test/test_dbenv.py | 29 +++-
13 Modules/_bsddb.c | 439 +++++++++++++++++++++++-------------------
14 Modules/bsddb.h | 20 +-
15 setup.py | 25 +++-
16 6 files changed, 307 insertions(+), 213 deletions(-)
17
18diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py
19index ed4deea..1b1c388 100644
20--- a/Lib/bsddb/__init__.py
21+++ b/Lib/bsddb/__init__.py
22@@ -33,7 +33,7 @@
23 #----------------------------------------------------------------------
24
25
26-"""Support for Berkeley DB 4.1 through 4.8 with a simple interface.
27+"""Support for Berkeley DB 4.2 through 5.3 with a simple interface.
28
29 For the full featured object oriented interface use the bsddb.db module
30 instead. It mirrors the Oracle Berkeley DB C API.
31diff --git a/Lib/bsddb/test/test_all.py b/Lib/bsddb/test/test_all.py
32index e9fe618..6a25f4a 100644
33--- a/Lib/bsddb/test/test_all.py
34+++ b/Lib/bsddb/test/test_all.py
35@@ -484,6 +484,8 @@ def print_versions():
36 print '-=' * 38
37 print db.DB_VERSION_STRING
38 print 'bsddb.db.version(): %s' % (db.version(), )
39+ if db.version() >= (5, 0) :
40+ print 'bsddb.db.full_version(): %s' %repr(db.full_version())
41 print 'bsddb.db.__version__: %s' % db.__version__
42 print 'bsddb.db.cvsid: %s' % db.cvsid
43
44@@ -528,7 +530,8 @@ def get_new_database_path() :
45
46 # This path can be overriden via "set_test_path_prefix()".
47 import os, os.path
48-get_new_path.prefix=os.path.join(os.sep,"tmp","z-Berkeley_DB")
49+get_new_path.prefix=os.path.join(os.environ.get("TMPDIR",
50+ os.path.join(os.sep,"tmp")), "z-Berkeley_DB")
51 get_new_path.num=0
52
53 def get_test_path_prefix() :
54diff --git a/Lib/bsddb/test/test_dbenv.py b/Lib/bsddb/test/test_dbenv.py
55index 37281df..6ac1e54 100644
56--- a/Lib/bsddb/test/test_dbenv.py
57+++ b/Lib/bsddb/test/test_dbenv.py
58@@ -25,12 +25,31 @@ class DBEnv(unittest.TestCase):
59 test_support.rmtree(self.homeDir)
60
61 class DBEnv_general(DBEnv) :
62+ def test_get_open_flags(self) :
63+ flags = db.DB_CREATE | db.DB_INIT_MPOOL
64+ self.env.open(self.homeDir, flags)
65+ self.assertEqual(flags, self.env.get_open_flags())
66+
67+ def test_get_open_flags2(self) :
68+ flags = db.DB_CREATE | db.DB_INIT_MPOOL | \
69+ db.DB_INIT_LOCK | db.DB_THREAD
70+ self.env.open(self.homeDir, flags)
71+ self.assertEqual(flags, self.env.get_open_flags())
72+
73 if db.version() >= (4, 7) :
74 def test_lk_partitions(self) :
75 for i in [10, 20, 40] :
76 self.env.set_lk_partitions(i)
77 self.assertEqual(i, self.env.get_lk_partitions())
78
79+ def test_getset_intermediate_dir_mode(self) :
80+ self.assertEqual(None, self.env.get_intermediate_dir_mode())
81+ for mode in ["rwx------", "rw-rw-rw-", "rw-r--r--"] :
82+ self.env.set_intermediate_dir_mode(mode)
83+ self.assertEqual(mode, self.env.get_intermediate_dir_mode())
84+ self.assertRaises(db.DBInvalidArgError,
85+ self.env.set_intermediate_dir_mode, "abcde")
86+
87 if db.version() >= (4, 6) :
88 def test_thread(self) :
89 for i in [16, 100, 1000] :
90@@ -115,7 +134,7 @@ class DBEnv_general(DBEnv) :
91 self.assertEqual(i, self.env.get_lk_max_lockers())
92
93 def test_lg_regionmax(self) :
94- for i in [128, 256, 1024] :
95+ for i in [128, 256, 1000] :
96 i = i*1024*1024
97 self.env.set_lg_regionmax(i)
98 j = self.env.get_lg_regionmax()
99@@ -172,8 +191,12 @@ class DBEnv_general(DBEnv) :
100 self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
101 cachesize = (0, 2*1024*1024, 1)
102 self.assertRaises(db.DBInvalidArgError,
103- self.env.set_cachesize, *cachesize)
104- self.assertEqual(cachesize2, self.env.get_cachesize())
105+ self.env.set_cachesize, *cachesize)
106+ cachesize3 = self.env.get_cachesize()
107+ self.assertEqual(cachesize2[0], cachesize3[0])
108+ self.assertEqual(cachesize2[2], cachesize3[2])
109+ # In Berkeley DB 5.3, the cachesize can change when opening the Env
110+ self.assertTrue(cachesize2[1] <= cachesize3[1])
111
112 def test_set_cachesize_dbenv_db(self) :
113 # You can not configure the cachesize using
114diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
115index d2d12ff..e98e4bc 100644
116--- a/Modules/_bsddb.c
117+++ b/Modules/_bsddb.c
118@@ -187,8 +187,10 @@ static PyObject* DBOldVersionError; /* DB_OLD_VERSION */
119 static PyObject* DBRunRecoveryError; /* DB_RUNRECOVERY */
120 static PyObject* DBVerifyBadError; /* DB_VERIFY_BAD */
121 static PyObject* DBNoServerError; /* DB_NOSERVER */
122+#if (DBVER < 52)
123 static PyObject* DBNoServerHomeError; /* DB_NOSERVER_HOME */
124 static PyObject* DBNoServerIDError; /* DB_NOSERVER_ID */
125+#endif
126 static PyObject* DBPageNotFoundError; /* DB_PAGE_NOTFOUND */
127 static PyObject* DBSecondaryBadError; /* DB_SECONDARY_BAD */
128
129@@ -202,9 +204,7 @@ static PyObject* DBFileExistsError; /* EEXIST */
130 static PyObject* DBNoSuchFileError; /* ENOENT */
131 static PyObject* DBPermissionsError; /* EPERM */
132
133-#if (DBVER >= 42)
134 static PyObject* DBRepHandleDeadError; /* DB_REP_HANDLE_DEAD */
135-#endif
136 #if (DBVER >= 44)
137 static PyObject* DBRepLockoutError; /* DB_REP_LOCKOUT */
138 #endif
139@@ -696,8 +696,10 @@ static int makeDBError(int err)
140 case DB_RUNRECOVERY: errObj = DBRunRecoveryError; break;
141 case DB_VERIFY_BAD: errObj = DBVerifyBadError; break;
142 case DB_NOSERVER: errObj = DBNoServerError; break;
143+#if (DBVER < 52)
144 case DB_NOSERVER_HOME: errObj = DBNoServerHomeError; break;
145 case DB_NOSERVER_ID: errObj = DBNoServerIDError; break;
146+#endif
147 case DB_PAGE_NOTFOUND: errObj = DBPageNotFoundError; break;
148 case DB_SECONDARY_BAD: errObj = DBSecondaryBadError; break;
149 case DB_BUFFER_SMALL: errObj = DBNoMemoryError; break;
150@@ -715,9 +717,7 @@ static int makeDBError(int err)
151 case ENOENT: errObj = DBNoSuchFileError; break;
152 case EPERM : errObj = DBPermissionsError; break;
153
154-#if (DBVER >= 42)
155 case DB_REP_HANDLE_DEAD : errObj = DBRepHandleDeadError; break;
156-#endif
157 #if (DBVER >= 44)
158 case DB_REP_LOCKOUT : errObj = DBRepLockoutError; break;
159 #endif
160@@ -2132,7 +2132,7 @@ DB_get_size(DBObject* self, PyObject* args, PyObject* kwargs)
161 MYDB_BEGIN_ALLOW_THREADS;
162 err = self->db->get(self->db, txn, &key, &data, flags);
163 MYDB_END_ALLOW_THREADS;
164- if (err == DB_BUFFER_SMALL) {
165+ if ((err == DB_BUFFER_SMALL) || (err == 0)) {
166 retval = NUMBER_FromLong((long)data.size);
167 err = 0;
168 }
169@@ -2385,9 +2385,7 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs)
170 return NULL;
171 }
172
173-#if (DBVER >= 42)
174 self->db->get_flags(self->db, &self->setflags);
175-#endif
176
177 self->flags = flags;
178
179@@ -2539,6 +2537,37 @@ DB_get_priority(DBObject* self)
180 #endif
181
182 static PyObject*
183+DB_get_dbname(DBObject* self)
184+{
185+ int err;
186+ const char *filename, *dbname;
187+
188+ CHECK_DB_NOT_CLOSED(self);
189+
190+ MYDB_BEGIN_ALLOW_THREADS;
191+ err = self->db->get_dbname(self->db, &filename, &dbname);
192+ MYDB_END_ALLOW_THREADS;
193+ RETURN_IF_ERR();
194+ /* If "dbname==NULL", it is correctly converted to "None" */
195+ return Py_BuildValue("(ss)", filename, dbname);
196+}
197+
198+static PyObject*
199+DB_get_open_flags(DBObject* self)
200+{
201+ int err;
202+ unsigned int flags;
203+
204+ CHECK_DB_NOT_CLOSED(self);
205+
206+ MYDB_BEGIN_ALLOW_THREADS;
207+ err = self->db->get_open_flags(self->db, &flags);
208+ MYDB_END_ALLOW_THREADS;
209+ RETURN_IF_ERR();
210+ return NUMBER_FromLong(flags);
211+}
212+
213+static PyObject*
214 DB_set_q_extentsize(DBObject* self, PyObject* args)
215 {
216 int err;
217@@ -2555,7 +2584,6 @@ DB_set_q_extentsize(DBObject* self, PyObject* args)
218 RETURN_NONE();
219 }
220
221-#if (DBVER >= 42)
222 static PyObject*
223 DB_get_q_extentsize(DBObject* self)
224 {
225@@ -2570,7 +2598,6 @@ DB_get_q_extentsize(DBObject* self)
226 RETURN_IF_ERR();
227 return NUMBER_FromLong(extentsize);
228 }
229-#endif
230
231 static PyObject*
232 DB_set_bt_minkey(DBObject* self, PyObject* args)
233@@ -2588,7 +2615,6 @@ DB_set_bt_minkey(DBObject* self, PyObject* args)
234 RETURN_NONE();
235 }
236
237-#if (DBVER >= 42)
238 static PyObject*
239 DB_get_bt_minkey(DBObject* self)
240 {
241@@ -2603,7 +2629,6 @@ DB_get_bt_minkey(DBObject* self)
242 RETURN_IF_ERR();
243 return NUMBER_FromLong(bt_minkey);
244 }
245-#endif
246
247 static int
248 _default_cmp(const DBT *leftKey,
249@@ -2759,7 +2784,6 @@ DB_set_cachesize(DBObject* self, PyObject* args)
250 RETURN_NONE();
251 }
252
253-#if (DBVER >= 42)
254 static PyObject*
255 DB_get_cachesize(DBObject* self)
256 {
257@@ -2777,7 +2801,6 @@ DB_get_cachesize(DBObject* self)
258
259 return Py_BuildValue("(iii)", gbytes, bytes, ncache);
260 }
261-#endif
262
263 static PyObject*
264 DB_set_flags(DBObject* self, PyObject* args)
265@@ -2797,7 +2820,6 @@ DB_set_flags(DBObject* self, PyObject* args)
266 RETURN_NONE();
267 }
268
269-#if (DBVER >= 42)
270 static PyObject*
271 DB_get_flags(DBObject* self)
272 {
273@@ -2812,6 +2834,35 @@ DB_get_flags(DBObject* self)
274 RETURN_IF_ERR();
275 return NUMBER_FromLong(flags);
276 }
277+
278+#if (DBVER >= 43)
279+static PyObject*
280+DB_get_transactional(DBObject* self)
281+{
282+ int err;
283+
284+ CHECK_DB_NOT_CLOSED(self);
285+
286+ MYDB_BEGIN_ALLOW_THREADS;
287+ err = self->db->get_transactional(self->db);
288+ MYDB_END_ALLOW_THREADS;
289+
290+ if(err == 0) {
291+ Py_INCREF(Py_False);
292+ return Py_False;
293+ } else if(err == 1) {
294+ Py_INCREF(Py_True);
295+ return Py_True;
296+ }
297+
298+ /*
299+ ** If we reach there, there was an error. The
300+ ** "return" should be unreachable.
301+ */
302+ RETURN_IF_ERR();
303+ assert(0); /* This coude SHOULD be unreachable */
304+ return NULL;
305+}
306 #endif
307
308 static PyObject*
309@@ -2830,7 +2881,6 @@ DB_set_h_ffactor(DBObject* self, PyObject* args)
310 RETURN_NONE();
311 }
312
313-#if (DBVER >= 42)
314 static PyObject*
315 DB_get_h_ffactor(DBObject* self)
316 {
317@@ -2845,7 +2895,6 @@ DB_get_h_ffactor(DBObject* self)
318 RETURN_IF_ERR();
319 return NUMBER_FromLong(ffactor);
320 }
321-#endif
322
323 static PyObject*
324 DB_set_h_nelem(DBObject* self, PyObject* args)
325@@ -2863,7 +2912,6 @@ DB_set_h_nelem(DBObject* self, PyObject* args)
326 RETURN_NONE();
327 }
328
329-#if (DBVER >= 42)
330 static PyObject*
331 DB_get_h_nelem(DBObject* self)
332 {
333@@ -2878,7 +2926,6 @@ DB_get_h_nelem(DBObject* self)
334 RETURN_IF_ERR();
335 return NUMBER_FromLong(nelem);
336 }
337-#endif
338
339 static PyObject*
340 DB_set_lorder(DBObject* self, PyObject* args)
341@@ -2896,7 +2943,6 @@ DB_set_lorder(DBObject* self, PyObject* args)
342 RETURN_NONE();
343 }
344
345-#if (DBVER >= 42)
346 static PyObject*
347 DB_get_lorder(DBObject* self)
348 {
349@@ -2911,7 +2957,6 @@ DB_get_lorder(DBObject* self)
350 RETURN_IF_ERR();
351 return NUMBER_FromLong(lorder);
352 }
353-#endif
354
355 static PyObject*
356 DB_set_pagesize(DBObject* self, PyObject* args)
357@@ -2929,7 +2974,6 @@ DB_set_pagesize(DBObject* self, PyObject* args)
358 RETURN_NONE();
359 }
360
361-#if (DBVER >= 42)
362 static PyObject*
363 DB_get_pagesize(DBObject* self)
364 {
365@@ -2944,7 +2988,6 @@ DB_get_pagesize(DBObject* self)
366 RETURN_IF_ERR();
367 return NUMBER_FromLong(pagesize);
368 }
369-#endif
370
371 static PyObject*
372 DB_set_re_delim(DBObject* self, PyObject* args)
373@@ -2967,7 +3010,6 @@ DB_set_re_delim(DBObject* self, PyObject* args)
374 RETURN_NONE();
375 }
376
377-#if (DBVER >= 42)
378 static PyObject*
379 DB_get_re_delim(DBObject* self)
380 {
381@@ -2981,7 +3023,6 @@ DB_get_re_delim(DBObject* self)
382 RETURN_IF_ERR();
383 return NUMBER_FromLong(re_delim);
384 }
385-#endif
386
387 static PyObject*
388 DB_set_re_len(DBObject* self, PyObject* args)
389@@ -2999,7 +3040,6 @@ DB_set_re_len(DBObject* self, PyObject* args)
390 RETURN_NONE();
391 }
392
393-#if (DBVER >= 42)
394 static PyObject*
395 DB_get_re_len(DBObject* self)
396 {
397@@ -3014,7 +3054,6 @@ DB_get_re_len(DBObject* self)
398 RETURN_IF_ERR();
399 return NUMBER_FromLong(re_len);
400 }
401-#endif
402
403 static PyObject*
404 DB_set_re_pad(DBObject* self, PyObject* args)
405@@ -3036,7 +3075,6 @@ DB_set_re_pad(DBObject* self, PyObject* args)
406 RETURN_NONE();
407 }
408
409-#if (DBVER >= 42)
410 static PyObject*
411 DB_get_re_pad(DBObject* self)
412 {
413@@ -3050,7 +3088,6 @@ DB_get_re_pad(DBObject* self)
414 RETURN_IF_ERR();
415 return NUMBER_FromLong(re_pad);
416 }
417-#endif
418
419 static PyObject*
420 DB_set_re_source(DBObject* self, PyObject* args)
421@@ -3069,7 +3106,6 @@ DB_set_re_source(DBObject* self, PyObject* args)
422 RETURN_NONE();
423 }
424
425-#if (DBVER >= 42)
426 static PyObject*
427 DB_get_re_source(DBObject* self)
428 {
429@@ -3084,7 +3120,6 @@ DB_get_re_source(DBObject* self)
430 RETURN_IF_ERR();
431 return PyBytes_FromString(source);
432 }
433-#endif
434
435 static PyObject*
436 DB_stat(DBObject* self, PyObject* args, PyObject* kwargs)
437@@ -3381,7 +3416,6 @@ DB_set_encrypt(DBObject* self, PyObject* args, PyObject* kwargs)
438 RETURN_NONE();
439 }
440
441-#if (DBVER >= 42)
442 static PyObject*
443 DB_get_encrypt_flags(DBObject* self)
444 {
445@@ -3396,7 +3430,6 @@ DB_get_encrypt_flags(DBObject* self)
446
447 return NUMBER_FromLong(flags);
448 }
449-#endif
450
451
452
453@@ -4987,7 +5020,6 @@ DBEnv_set_encrypt(DBEnvObject* self, PyObject* args, PyObject* kwargs)
454 RETURN_NONE();
455 }
456
457-#if (DBVER >= 42)
458 static PyObject*
459 DBEnv_get_encrypt_flags(DBEnvObject* self)
460 {
461@@ -5025,7 +5057,6 @@ DBEnv_get_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs)
462 RETURN_IF_ERR();
463 return NUMBER_FromLong(timeout);
464 }
465-#endif
466
467
468 static PyObject*
469@@ -5064,7 +5095,6 @@ DBEnv_set_shm_key(DBEnvObject* self, PyObject* args)
470 RETURN_NONE();
471 }
472
473-#if (DBVER >= 42)
474 static PyObject*
475 DBEnv_get_shm_key(DBEnvObject* self)
476 {
477@@ -5081,7 +5111,6 @@ DBEnv_get_shm_key(DBEnvObject* self)
478
479 return NUMBER_FromLong(shm_key);
480 }
481-#endif
482
483 #if (DBVER >= 46)
484 static PyObject*
485@@ -5170,7 +5199,6 @@ DBEnv_set_cachesize(DBEnvObject* self, PyObject* args)
486 RETURN_NONE();
487 }
488
489-#if (DBVER >= 42)
490 static PyObject*
491 DBEnv_get_cachesize(DBEnvObject* self)
492 {
493@@ -5188,7 +5216,6 @@ DBEnv_get_cachesize(DBEnvObject* self)
494
495 return Py_BuildValue("(iii)", gbytes, bytes, ncache);
496 }
497-#endif
498
499
500 static PyObject*
501@@ -5208,7 +5235,6 @@ DBEnv_set_flags(DBEnvObject* self, PyObject* args)
502 RETURN_NONE();
503 }
504
505-#if (DBVER >= 42)
506 static PyObject*
507 DBEnv_get_flags(DBEnvObject* self)
508 {
509@@ -5223,7 +5249,6 @@ DBEnv_get_flags(DBEnvObject* self)
510 RETURN_IF_ERR();
511 return NUMBER_FromLong(flags);
512 }
513-#endif
514
515 #if (DBVER >= 47)
516 static PyObject*
517@@ -5423,7 +5448,6 @@ DBEnv_set_data_dir(DBEnvObject* self, PyObject* args)
518 RETURN_NONE();
519 }
520
521-#if (DBVER >= 42)
522 static PyObject*
523 DBEnv_get_data_dirs(DBEnvObject* self)
524 {
525@@ -5463,7 +5487,6 @@ DBEnv_get_data_dirs(DBEnvObject* self)
526 }
527 return tuple;
528 }
529-#endif
530
531 #if (DBVER >= 44)
532 static PyObject*
533@@ -5513,7 +5536,6 @@ DBEnv_set_lg_bsize(DBEnvObject* self, PyObject* args)
534 RETURN_NONE();
535 }
536
537-#if (DBVER >= 42)
538 static PyObject*
539 DBEnv_get_lg_bsize(DBEnvObject* self)
540 {
541@@ -5528,7 +5550,6 @@ DBEnv_get_lg_bsize(DBEnvObject* self)
542 RETURN_IF_ERR();
543 return NUMBER_FromLong(lg_bsize);
544 }
545-#endif
546
547 static PyObject*
548 DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args)
549@@ -5547,7 +5568,6 @@ DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args)
550 RETURN_NONE();
551 }
552
553-#if (DBVER >= 42)
554 static PyObject*
555 DBEnv_get_lg_dir(DBEnvObject* self)
556 {
557@@ -5562,7 +5582,6 @@ DBEnv_get_lg_dir(DBEnvObject* self)
558 RETURN_IF_ERR();
559 return PyBytes_FromString(dirp);
560 }
561-#endif
562
563 static PyObject*
564 DBEnv_set_lg_max(DBEnvObject* self, PyObject* args)
565@@ -5580,7 +5599,6 @@ DBEnv_set_lg_max(DBEnvObject* self, PyObject* args)
566 RETURN_NONE();
567 }
568
569-#if (DBVER >= 42)
570 static PyObject*
571 DBEnv_get_lg_max(DBEnvObject* self)
572 {
573@@ -5595,8 +5613,6 @@ DBEnv_get_lg_max(DBEnvObject* self)
574 RETURN_IF_ERR();
575 return NUMBER_FromLong(lg_max);
576 }
577-#endif
578-
579
580 static PyObject*
581 DBEnv_set_lg_regionmax(DBEnvObject* self, PyObject* args)
582@@ -5614,7 +5630,6 @@ DBEnv_set_lg_regionmax(DBEnvObject* self, PyObject* args)
583 RETURN_NONE();
584 }
585
586-#if (DBVER >= 42)
587 static PyObject*
588 DBEnv_get_lg_regionmax(DBEnvObject* self)
589 {
590@@ -5629,7 +5644,6 @@ DBEnv_get_lg_regionmax(DBEnvObject* self)
591 RETURN_IF_ERR();
592 return NUMBER_FromLong(lg_regionmax);
593 }
594-#endif
595
596 #if (DBVER >= 47)
597 static PyObject*
598@@ -5680,7 +5694,6 @@ DBEnv_set_lk_detect(DBEnvObject* self, PyObject* args)
599 RETURN_NONE();
600 }
601
602-#if (DBVER >= 42)
603 static PyObject*
604 DBEnv_get_lk_detect(DBEnvObject* self)
605 {
606@@ -5695,8 +5708,6 @@ DBEnv_get_lk_detect(DBEnvObject* self)
607 RETURN_IF_ERR();
608 return NUMBER_FromLong(lk_detect);
609 }
610-#endif
611-
612
613 #if (DBVER < 45)
614 static PyObject*
615@@ -5734,7 +5745,6 @@ DBEnv_set_lk_max_locks(DBEnvObject* self, PyObject* args)
616 RETURN_NONE();
617 }
618
619-#if (DBVER >= 42)
620 static PyObject*
621 DBEnv_get_lk_max_locks(DBEnvObject* self)
622 {
623@@ -5749,7 +5759,6 @@ DBEnv_get_lk_max_locks(DBEnvObject* self)
624 RETURN_IF_ERR();
625 return NUMBER_FromLong(lk_max);
626 }
627-#endif
628
629 static PyObject*
630 DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args)
631@@ -5767,7 +5776,6 @@ DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args)
632 RETURN_NONE();
633 }
634
635-#if (DBVER >= 42)
636 static PyObject*
637 DBEnv_get_lk_max_lockers(DBEnvObject* self)
638 {
639@@ -5782,7 +5790,6 @@ DBEnv_get_lk_max_lockers(DBEnvObject* self)
640 RETURN_IF_ERR();
641 return NUMBER_FromLong(lk_max);
642 }
643-#endif
644
645 static PyObject*
646 DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args)
647@@ -5800,7 +5807,6 @@ DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args)
648 RETURN_NONE();
649 }
650
651-#if (DBVER >= 42)
652 static PyObject*
653 DBEnv_get_lk_max_objects(DBEnvObject* self)
654 {
655@@ -5815,9 +5821,7 @@ DBEnv_get_lk_max_objects(DBEnvObject* self)
656 RETURN_IF_ERR();
657 return NUMBER_FromLong(lk_max);
658 }
659-#endif
660
661-#if (DBVER >= 42)
662 static PyObject*
663 DBEnv_get_mp_mmapsize(DBEnvObject* self)
664 {
665@@ -5832,8 +5836,6 @@ DBEnv_get_mp_mmapsize(DBEnvObject* self)
666 RETURN_IF_ERR();
667 return NUMBER_FromLong(mmapsize);
668 }
669-#endif
670-
671
672 static PyObject*
673 DBEnv_set_mp_mmapsize(DBEnvObject* self, PyObject* args)
674@@ -5869,8 +5871,6 @@ DBEnv_set_tmp_dir(DBEnvObject* self, PyObject* args)
675 RETURN_NONE();
676 }
677
678-
679-#if (DBVER >= 42)
680 static PyObject*
681 DBEnv_get_tmp_dir(DBEnvObject* self)
682 {
683@@ -5887,8 +5887,6 @@ DBEnv_get_tmp_dir(DBEnvObject* self)
684
685 return PyBytes_FromString(dirpp);
686 }
687-#endif
688-
689
690 static PyObject*
691 DBEnv_txn_recover(DBEnvObject* self)
692@@ -5899,7 +5897,7 @@ DBEnv_txn_recover(DBEnvObject* self)
693 DBTxnObject *txn;
694 #define PREPLIST_LEN 16
695 DB_PREPLIST preplist[PREPLIST_LEN];
696-#if (DBVER < 48)
697+#if (DBVER < 48 || DBVER > 51)
698 long retp;
699 #else
700 u_int32_t retp;
701@@ -6003,8 +6001,6 @@ DBEnv_txn_checkpoint(DBEnvObject* self, PyObject* args)
702 RETURN_NONE();
703 }
704
705-
706-#if (DBVER >= 42)
707 static PyObject*
708 DBEnv_get_tx_max(DBEnvObject* self)
709 {
710@@ -6019,8 +6015,6 @@ DBEnv_get_tx_max(DBEnvObject* self)
711 RETURN_IF_ERR();
712 return PyLong_FromUnsignedLong(max);
713 }
714-#endif
715-
716
717 static PyObject*
718 DBEnv_set_tx_max(DBEnvObject* self, PyObject* args)
719@@ -6038,8 +6032,6 @@ DBEnv_set_tx_max(DBEnvObject* self, PyObject* args)
720 RETURN_NONE();
721 }
722
723-
724-#if (DBVER >= 42)
725 static PyObject*
726 DBEnv_get_tx_timestamp(DBEnvObject* self)
727 {
728@@ -6054,7 +6046,6 @@ DBEnv_get_tx_timestamp(DBEnvObject* self)
729 RETURN_IF_ERR();
730 return NUMBER_FromLong(timestamp);
731 }
732-#endif
733
734 static PyObject*
735 DBEnv_set_tx_timestamp(DBEnvObject* self, PyObject* args)
736@@ -6756,6 +6747,55 @@ DBEnv_set_private(DBEnvObject* self, PyObject* private_obj)
737 RETURN_NONE();
738 }
739
740+#if (DBVER >= 47)
741+static PyObject*
742+DBEnv_set_intermediate_dir_mode(DBEnvObject* self, PyObject* args)
743+{
744+ int err;
745+ const char *mode;
746+
747+ if (!PyArg_ParseTuple(args,"s:set_intermediate_dir_mode", &mode))
748+ return NULL;
749+
750+ CHECK_ENV_NOT_CLOSED(self);
751+
752+ MYDB_BEGIN_ALLOW_THREADS;
753+ err = self->db_env->set_intermediate_dir_mode(self->db_env, mode);
754+ MYDB_END_ALLOW_THREADS;
755+ RETURN_IF_ERR();
756+ RETURN_NONE();
757+}
758+
759+static PyObject*
760+DBEnv_get_intermediate_dir_mode(DBEnvObject* self)
761+{
762+ int err;
763+ const char *mode;
764+
765+ CHECK_ENV_NOT_CLOSED(self);
766+
767+ MYDB_BEGIN_ALLOW_THREADS;
768+ err = self->db_env->get_intermediate_dir_mode(self->db_env, &mode);
769+ MYDB_END_ALLOW_THREADS;
770+ RETURN_IF_ERR();
771+ return Py_BuildValue("s", mode);
772+}
773+#endif
774+
775+static PyObject*
776+DBEnv_get_open_flags(DBEnvObject* self)
777+{
778+ int err;
779+ unsigned int flags;
780+
781+ CHECK_ENV_NOT_CLOSED(self);
782+
783+ MYDB_BEGIN_ALLOW_THREADS;
784+ err = self->db_env->get_open_flags(self->db_env, &flags);
785+ MYDB_END_ALLOW_THREADS;
786+ RETURN_IF_ERR();
787+ return NUMBER_FromLong(flags);
788+}
789
790 #if (DBVER < 48)
791 static PyObject*
792@@ -6875,7 +6915,6 @@ DBEnv_set_verbose(DBEnvObject* self, PyObject* args)
793 RETURN_NONE();
794 }
795
796-#if (DBVER >= 42)
797 static PyObject*
798 DBEnv_get_verbose(DBEnvObject* self, PyObject* args)
799 {
800@@ -6893,7 +6932,6 @@ DBEnv_get_verbose(DBEnvObject* self, PyObject* args)
801 RETURN_IF_ERR();
802 return PyBool_FromLong(verbose);
803 }
804-#endif
805
806 #if (DBVER >= 45)
807 static void
808@@ -6975,9 +7013,7 @@ DBEnv_rep_process_message(DBEnvObject* self, PyObject* args)
809 PyObject *control_py, *rec_py;
810 DBT control, rec;
811 int envid;
812-#if (DBVER >= 42)
813 DB_LSN lsn;
814-#endif
815
816 if (!PyArg_ParseTuple(args, "OOi:rep_process_message", &control_py,
817 &rec_py, &envid))
818@@ -6994,13 +7030,8 @@ DBEnv_rep_process_message(DBEnvObject* self, PyObject* args)
819 err = self->db_env->rep_process_message(self->db_env, &control, &rec,
820 envid, &lsn);
821 #else
822-#if (DBVER >= 42)
823 err = self->db_env->rep_process_message(self->db_env, &control, &rec,
824 &envid, &lsn);
825-#else
826- err = self->db_env->rep_process_message(self->db_env, &control, &rec,
827- &envid);
828-#endif
829 #endif
830 MYDB_END_ALLOW_THREADS;
831 switch (err) {
832@@ -7029,12 +7060,10 @@ DBEnv_rep_process_message(DBEnvObject* self, PyObject* args)
833 return r;
834 break;
835 }
836-#if (DBVER >= 42)
837 case DB_REP_NOTPERM :
838 case DB_REP_ISPERM :
839 return Py_BuildValue("(i(ll))", err, lsn.file, lsn.offset);
840 break;
841-#endif
842 }
843 RETURN_IF_ERR();
844 return Py_BuildValue("(OO)", Py_None, Py_None);
845@@ -7086,20 +7115,6 @@ _DBEnv_rep_transportCallback(DB_ENV* db_env, const DBT* control, const DBT* rec,
846 return ret;
847 }
848
849-#if (DBVER <= 41)
850-static int
851-_DBEnv_rep_transportCallbackOLD(DB_ENV* db_env, const DBT* control, const DBT* rec,
852- int envid, u_int32_t flags)
853-{
854- DB_LSN lsn;
855-
856- lsn.file = -1; /* Dummy values */
857- lsn.offset = -1;
858- return _DBEnv_rep_transportCallback(db_env, control, rec, &lsn, envid,
859- flags);
860-}
861-#endif
862-
863 static PyObject*
864 DBEnv_rep_set_transport(DBEnvObject* self, PyObject* args)
865 {
866@@ -7120,13 +7135,8 @@ DBEnv_rep_set_transport(DBEnvObject* self, PyObject* args)
867 err = self->db_env->rep_set_transport(self->db_env, envid,
868 &_DBEnv_rep_transportCallback);
869 #else
870-#if (DBVER >= 42)
871 err = self->db_env->set_rep_transport(self->db_env, envid,
872 &_DBEnv_rep_transportCallback);
873-#else
874- err = self->db_env->set_rep_transport(self->db_env, envid,
875- &_DBEnv_rep_transportCallbackOLD);
876-#endif
877 #endif
878 MYDB_END_ALLOW_THREADS;
879 RETURN_IF_ERR();
880@@ -7608,6 +7618,7 @@ DBEnv_repmgr_start(DBEnvObject* self, PyObject* args, PyObject*
881 RETURN_NONE();
882 }
883
884+#if (DBVER < 52)
885 static PyObject*
886 DBEnv_repmgr_set_local_site(DBEnvObject* self, PyObject* args, PyObject*
887 kwargs)
888@@ -7654,6 +7665,7 @@ DBEnv_repmgr_add_remote_site(DBEnvObject* self, PyObject* args, PyObject*
889 RETURN_IF_ERR();
890 return NUMBER_FromLong(eidp);
891 }
892+#endif
893
894 static PyObject*
895 DBEnv_repmgr_set_ack_policy(DBEnvObject* self, PyObject* args)
896@@ -8482,65 +8494,43 @@ static PyMethodDef DB_methods[] = {
897 {"remove", (PyCFunction)DB_remove, METH_VARARGS|METH_KEYWORDS},
898 {"rename", (PyCFunction)DB_rename, METH_VARARGS},
899 {"set_bt_minkey", (PyCFunction)DB_set_bt_minkey, METH_VARARGS},
900-#if (DBVER >= 42)
901 {"get_bt_minkey", (PyCFunction)DB_get_bt_minkey, METH_NOARGS},
902-#endif
903 {"set_bt_compare", (PyCFunction)DB_set_bt_compare, METH_O},
904 {"set_cachesize", (PyCFunction)DB_set_cachesize, METH_VARARGS},
905-#if (DBVER >= 42)
906 {"get_cachesize", (PyCFunction)DB_get_cachesize, METH_NOARGS},
907-#endif
908 {"set_encrypt", (PyCFunction)DB_set_encrypt, METH_VARARGS|METH_KEYWORDS},
909-#if (DBVER >= 42)
910 {"get_encrypt_flags", (PyCFunction)DB_get_encrypt_flags, METH_NOARGS},
911-#endif
912-
913 {"set_flags", (PyCFunction)DB_set_flags, METH_VARARGS},
914-#if (DBVER >= 42)
915 {"get_flags", (PyCFunction)DB_get_flags, METH_NOARGS},
916+#if (DBVER >= 43)
917+ {"get_transactional", (PyCFunction)DB_get_transactional, METH_NOARGS},
918 #endif
919 {"set_h_ffactor", (PyCFunction)DB_set_h_ffactor, METH_VARARGS},
920-#if (DBVER >= 42)
921 {"get_h_ffactor", (PyCFunction)DB_get_h_ffactor, METH_NOARGS},
922-#endif
923 {"set_h_nelem", (PyCFunction)DB_set_h_nelem, METH_VARARGS},
924-#if (DBVER >= 42)
925 {"get_h_nelem", (PyCFunction)DB_get_h_nelem, METH_NOARGS},
926-#endif
927 {"set_lorder", (PyCFunction)DB_set_lorder, METH_VARARGS},
928-#if (DBVER >= 42)
929 {"get_lorder", (PyCFunction)DB_get_lorder, METH_NOARGS},
930-#endif
931 {"set_pagesize", (PyCFunction)DB_set_pagesize, METH_VARARGS},
932-#if (DBVER >= 42)
933 {"get_pagesize", (PyCFunction)DB_get_pagesize, METH_NOARGS},
934-#endif
935 {"set_re_delim", (PyCFunction)DB_set_re_delim, METH_VARARGS},
936-#if (DBVER >= 42)
937 {"get_re_delim", (PyCFunction)DB_get_re_delim, METH_NOARGS},
938-#endif
939 {"set_re_len", (PyCFunction)DB_set_re_len, METH_VARARGS},
940-#if (DBVER >= 42)
941 {"get_re_len", (PyCFunction)DB_get_re_len, METH_NOARGS},
942-#endif
943 {"set_re_pad", (PyCFunction)DB_set_re_pad, METH_VARARGS},
944-#if (DBVER >= 42)
945 {"get_re_pad", (PyCFunction)DB_get_re_pad, METH_NOARGS},
946-#endif
947 {"set_re_source", (PyCFunction)DB_set_re_source, METH_VARARGS},
948-#if (DBVER >= 42)
949 {"get_re_source", (PyCFunction)DB_get_re_source, METH_NOARGS},
950-#endif
951 {"set_q_extentsize",(PyCFunction)DB_set_q_extentsize, METH_VARARGS},
952-#if (DBVER >= 42)
953 {"get_q_extentsize",(PyCFunction)DB_get_q_extentsize, METH_NOARGS},
954-#endif
955 {"set_private", (PyCFunction)DB_set_private, METH_O},
956 {"get_private", (PyCFunction)DB_get_private, METH_NOARGS},
957 #if (DBVER >= 46)
958 {"set_priority", (PyCFunction)DB_set_priority, METH_VARARGS},
959 {"get_priority", (PyCFunction)DB_get_priority, METH_NOARGS},
960 #endif
961+ {"get_dbname", (PyCFunction)DB_get_dbname, METH_NOARGS},
962+ {"get_open_flags", (PyCFunction)DB_get_open_flags, METH_NOARGS},
963 {"stat", (PyCFunction)DB_stat, METH_VARARGS|METH_KEYWORDS},
964 #if (DBVER >= 43)
965 {"stat_print", (PyCFunction)DB_stat_print,
966@@ -8639,24 +8629,18 @@ static PyMethodDef DBEnv_methods[] = {
967 {"get_thread_count", (PyCFunction)DBEnv_get_thread_count, METH_NOARGS},
968 #endif
969 {"set_encrypt", (PyCFunction)DBEnv_set_encrypt, METH_VARARGS|METH_KEYWORDS},
970-#if (DBVER >= 42)
971 {"get_encrypt_flags", (PyCFunction)DBEnv_get_encrypt_flags, METH_NOARGS},
972 {"get_timeout", (PyCFunction)DBEnv_get_timeout,
973 METH_VARARGS|METH_KEYWORDS},
974-#endif
975 {"set_timeout", (PyCFunction)DBEnv_set_timeout, METH_VARARGS|METH_KEYWORDS},
976 {"set_shm_key", (PyCFunction)DBEnv_set_shm_key, METH_VARARGS},
977-#if (DBVER >= 42)
978 {"get_shm_key", (PyCFunction)DBEnv_get_shm_key, METH_NOARGS},
979-#endif
980 #if (DBVER >= 46)
981 {"set_cache_max", (PyCFunction)DBEnv_set_cache_max, METH_VARARGS},
982 {"get_cache_max", (PyCFunction)DBEnv_get_cache_max, METH_NOARGS},
983 #endif
984 {"set_cachesize", (PyCFunction)DBEnv_set_cachesize, METH_VARARGS},
985-#if (DBVER >= 42)
986 {"get_cachesize", (PyCFunction)DBEnv_get_cachesize, METH_NOARGS},
987-#endif
988 {"memp_trickle", (PyCFunction)DBEnv_memp_trickle, METH_VARARGS},
989 {"memp_sync", (PyCFunction)DBEnv_memp_sync, METH_VARARGS},
990 {"memp_stat", (PyCFunction)DBEnv_memp_stat,
991@@ -8685,33 +8669,21 @@ static PyMethodDef DBEnv_methods[] = {
992 #endif
993 #endif
994 {"set_data_dir", (PyCFunction)DBEnv_set_data_dir, METH_VARARGS},
995-#if (DBVER >= 42)
996 {"get_data_dirs", (PyCFunction)DBEnv_get_data_dirs, METH_NOARGS},
997-#endif
998-#if (DBVER >= 42)
999 {"get_flags", (PyCFunction)DBEnv_get_flags, METH_NOARGS},
1000-#endif
1001 {"set_flags", (PyCFunction)DBEnv_set_flags, METH_VARARGS},
1002 #if (DBVER >= 47)
1003 {"log_set_config", (PyCFunction)DBEnv_log_set_config, METH_VARARGS},
1004 {"log_get_config", (PyCFunction)DBEnv_log_get_config, METH_VARARGS},
1005 #endif
1006 {"set_lg_bsize", (PyCFunction)DBEnv_set_lg_bsize, METH_VARARGS},
1007-#if (DBVER >= 42)
1008 {"get_lg_bsize", (PyCFunction)DBEnv_get_lg_bsize, METH_NOARGS},
1009-#endif
1010 {"set_lg_dir", (PyCFunction)DBEnv_set_lg_dir, METH_VARARGS},
1011-#if (DBVER >= 42)
1012 {"get_lg_dir", (PyCFunction)DBEnv_get_lg_dir, METH_NOARGS},
1013-#endif
1014 {"set_lg_max", (PyCFunction)DBEnv_set_lg_max, METH_VARARGS},
1015-#if (DBVER >= 42)
1016 {"get_lg_max", (PyCFunction)DBEnv_get_lg_max, METH_NOARGS},
1017-#endif
1018 {"set_lg_regionmax",(PyCFunction)DBEnv_set_lg_regionmax, METH_VARARGS},
1019-#if (DBVER >= 42)
1020 {"get_lg_regionmax",(PyCFunction)DBEnv_get_lg_regionmax, METH_NOARGS},
1021-#endif
1022 #if (DBVER >= 44)
1023 {"set_lg_filemode", (PyCFunction)DBEnv_set_lg_filemode, METH_VARARGS},
1024 {"get_lg_filemode", (PyCFunction)DBEnv_get_lg_filemode, METH_NOARGS},
1025@@ -8721,36 +8693,24 @@ static PyMethodDef DBEnv_methods[] = {
1026 {"get_lk_partitions", (PyCFunction)DBEnv_get_lk_partitions, METH_NOARGS},
1027 #endif
1028 {"set_lk_detect", (PyCFunction)DBEnv_set_lk_detect, METH_VARARGS},
1029-#if (DBVER >= 42)
1030 {"get_lk_detect", (PyCFunction)DBEnv_get_lk_detect, METH_NOARGS},
1031-#endif
1032 #if (DBVER < 45)
1033 {"set_lk_max", (PyCFunction)DBEnv_set_lk_max, METH_VARARGS},
1034 #endif
1035 {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS},
1036-#if (DBVER >= 42)
1037 {"get_lk_max_locks", (PyCFunction)DBEnv_get_lk_max_locks, METH_NOARGS},
1038-#endif
1039 {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS},
1040-#if (DBVER >= 42)
1041 {"get_lk_max_lockers", (PyCFunction)DBEnv_get_lk_max_lockers, METH_NOARGS},
1042-#endif
1043 {"set_lk_max_objects", (PyCFunction)DBEnv_set_lk_max_objects, METH_VARARGS},
1044-#if (DBVER >= 42)
1045 {"get_lk_max_objects", (PyCFunction)DBEnv_get_lk_max_objects, METH_NOARGS},
1046-#endif
1047 #if (DBVER >= 43)
1048 {"stat_print", (PyCFunction)DBEnv_stat_print,
1049 METH_VARARGS|METH_KEYWORDS},
1050 #endif
1051 {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize, METH_VARARGS},
1052-#if (DBVER >= 42)
1053 {"get_mp_mmapsize", (PyCFunction)DBEnv_get_mp_mmapsize, METH_NOARGS},
1054-#endif
1055 {"set_tmp_dir", (PyCFunction)DBEnv_set_tmp_dir, METH_VARARGS},
1056-#if (DBVER >= 42)
1057 {"get_tmp_dir", (PyCFunction)DBEnv_get_tmp_dir, METH_NOARGS},
1058-#endif
1059 {"txn_begin", (PyCFunction)DBEnv_txn_begin, METH_VARARGS|METH_KEYWORDS},
1060 {"txn_checkpoint", (PyCFunction)DBEnv_txn_checkpoint, METH_VARARGS},
1061 {"txn_stat", (PyCFunction)DBEnv_txn_stat, METH_VARARGS},
1062@@ -8758,10 +8718,8 @@ static PyMethodDef DBEnv_methods[] = {
1063 {"txn_stat_print", (PyCFunction)DBEnv_txn_stat_print,
1064 METH_VARARGS|METH_KEYWORDS},
1065 #endif
1066-#if (DBVER >= 42)
1067 {"get_tx_max", (PyCFunction)DBEnv_get_tx_max, METH_NOARGS},
1068 {"get_tx_timestamp", (PyCFunction)DBEnv_get_tx_timestamp, METH_NOARGS},
1069-#endif
1070 {"set_tx_max", (PyCFunction)DBEnv_set_tx_max, METH_VARARGS},
1071 {"set_tx_timestamp", (PyCFunction)DBEnv_set_tx_timestamp, METH_VARARGS},
1072 {"lock_detect", (PyCFunction)DBEnv_lock_detect, METH_VARARGS},
1073@@ -8804,11 +8762,16 @@ static PyMethodDef DBEnv_methods[] = {
1074 {"get_mp_max_write", (PyCFunction)DBEnv_get_mp_max_write, METH_NOARGS},
1075 #endif
1076 {"set_verbose", (PyCFunction)DBEnv_set_verbose, METH_VARARGS},
1077-#if (DBVER >= 42)
1078- {"get_verbose", (PyCFunction)DBEnv_get_verbose, METH_VARARGS},
1079+ {"get_verbose", (PyCFunction)DBEnv_get_verbose, METH_VARARGS},
1080+ {"set_private", (PyCFunction)DBEnv_set_private, METH_O},
1081+ {"get_private", (PyCFunction)DBEnv_get_private, METH_NOARGS},
1082+ {"get_open_flags", (PyCFunction)DBEnv_get_open_flags, METH_NOARGS},
1083+#if (DBVER >= 47)
1084+ {"set_intermediate_dir_mode", (PyCFunction)DBEnv_set_intermediate_dir_mode,
1085+ METH_VARARGS},
1086+ {"get_intermediate_dir_mode", (PyCFunction)DBEnv_get_intermediate_dir_mode,
1087+ METH_NOARGS},
1088 #endif
1089- {"set_private", (PyCFunction)DBEnv_set_private, METH_O},
1090- {"get_private", (PyCFunction)DBEnv_get_private, METH_NOARGS},
1091 {"rep_start", (PyCFunction)DBEnv_rep_start,
1092 METH_VARARGS|METH_KEYWORDS},
1093 {"rep_set_transport", (PyCFunction)DBEnv_rep_set_transport, METH_VARARGS},
1094@@ -8855,10 +8818,12 @@ static PyMethodDef DBEnv_methods[] = {
1095 #if (DBVER >= 45)
1096 {"repmgr_start", (PyCFunction)DBEnv_repmgr_start,
1097 METH_VARARGS|METH_KEYWORDS},
1098+#if (DBVER < 52)
1099 {"repmgr_set_local_site", (PyCFunction)DBEnv_repmgr_set_local_site,
1100 METH_VARARGS|METH_KEYWORDS},
1101 {"repmgr_add_remote_site", (PyCFunction)DBEnv_repmgr_add_remote_site,
1102 METH_VARARGS|METH_KEYWORDS},
1103+#endif
1104 {"repmgr_set_ack_policy", (PyCFunction)DBEnv_repmgr_set_ack_policy,
1105 METH_VARARGS},
1106 {"repmgr_get_ack_policy", (PyCFunction)DBEnv_repmgr_get_ack_policy,
1107@@ -8922,13 +8887,9 @@ DBEnv_db_home_get(DBEnvObject* self)
1108
1109 CHECK_ENV_NOT_CLOSED(self);
1110
1111-#if (DBVER >= 42)
1112 MYDB_BEGIN_ALLOW_THREADS;
1113 self->db_env->get_home(self->db_env, &home);
1114 MYDB_END_ALLOW_THREADS;
1115-#else
1116- home=self->db_env->db_home;
1117-#endif
1118
1119 if (home == NULL) {
1120 RETURN_NONE();
1121@@ -9298,10 +9259,25 @@ bsddb_version(PyObject* self)
1122 {
1123 int major, minor, patch;
1124
1125+ /* This should be instantaneous, no need to release the GIL */
1126 db_version(&major, &minor, &patch);
1127 return Py_BuildValue("(iii)", major, minor, patch);
1128 }
1129
1130+#if (DBVER >= 50)
1131+static PyObject*
1132+bsddb_version_full(PyObject* self)
1133+{
1134+ char *version_string;
1135+ int family, release, major, minor, patch;
1136+
1137+ /* This should be instantaneous, no need to release the GIL */
1138+ version_string = db_full_version(&family, &release, &major, &minor, &patch);
1139+ return Py_BuildValue("(siiiii)",
1140+ version_string, family, release, major, minor, patch);
1141+}
1142+#endif
1143+
1144
1145 /* List of functions defined in the module */
1146 static PyMethodDef bsddb_methods[] = {
1147@@ -9311,6 +9287,9 @@ static PyMethodDef bsddb_methods[] = {
1148 {"DBSequence", (PyCFunction)DBSequence_construct, METH_VARARGS | METH_KEYWORDS },
1149 #endif
1150 {"version", (PyCFunction)bsddb_version, METH_NOARGS, bsddb_version_doc},
1151+#if (DBVER >= 50)
1152+ {"full_version", (PyCFunction)bsddb_version_full, METH_NOARGS},
1153+#endif
1154 {NULL, NULL} /* sentinel */
1155 };
1156
1157@@ -9328,6 +9307,11 @@ static BSDDB_api bsddb_api;
1158 */
1159 #define ADD_INT(dict, NAME) _addIntToDict(dict, #NAME, NAME)
1160
1161+/*
1162+** We can rename the module at import time, so the string allocated
1163+** must be big enough, and any use of the name must use this particular
1164+** string.
1165+*/
1166 #define MODULE_NAME_MAX_LEN 11
1167 static char _bsddbModuleName[MODULE_NAME_MAX_LEN+1] = "_bsddb";
1168
1169@@ -9428,16 +9412,10 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1170 ADD_INT(d, DB_MAX_RECORDS);
1171
1172 #if (DBVER < 48)
1173-#if (DBVER >= 42)
1174 ADD_INT(d, DB_RPCCLIENT);
1175-#else
1176- ADD_INT(d, DB_CLIENT);
1177- /* allow apps to be written using DB_RPCCLIENT on older Berkeley DB */
1178- _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT);
1179-#endif
1180 #endif
1181
1182-#if (DBVER < 48)
1183+#if (DBVER < 48 || DBVER > 51)
1184 ADD_INT(d, DB_XA_CREATE);
1185 #endif
1186
1187@@ -9477,6 +9455,14 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1188 ADD_INT(d, DB_TXN_SYNC);
1189 ADD_INT(d, DB_TXN_NOWAIT);
1190
1191+#if (DBVER >= 51)
1192+ ADD_INT(d, DB_TXN_BULK);
1193+#endif
1194+
1195+#if (DBVER >= 48)
1196+ ADD_INT(d, DB_CURSOR_BULK);
1197+#endif
1198+
1199 #if (DBVER >= 46)
1200 ADD_INT(d, DB_TXN_WAIT);
1201 #endif
1202@@ -9561,9 +9547,7 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1203 ADD_INT(d, DB_ARCH_ABS);
1204 ADD_INT(d, DB_ARCH_DATA);
1205 ADD_INT(d, DB_ARCH_LOG);
1206-#if (DBVER >= 42)
1207 ADD_INT(d, DB_ARCH_REMOVE);
1208-#endif
1209
1210 ADD_INT(d, DB_BTREE);
1211 ADD_INT(d, DB_HASH);
1212@@ -9591,9 +9575,6 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1213 ADD_INT(d, DB_CACHED_COUNTS);
1214 #endif
1215
1216-#if (DBVER <= 41)
1217- ADD_INT(d, DB_COMMIT);
1218-#endif
1219 ADD_INT(d, DB_CONSUME);
1220 ADD_INT(d, DB_CONSUME_WAIT);
1221 ADD_INT(d, DB_CURRENT);
1222@@ -9651,8 +9632,10 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1223 ADD_INT(d, DB_LOCK_DEADLOCK);
1224 ADD_INT(d, DB_LOCK_NOTGRANTED);
1225 ADD_INT(d, DB_NOSERVER);
1226+#if (DBVER < 52)
1227 ADD_INT(d, DB_NOSERVER_HOME);
1228 ADD_INT(d, DB_NOSERVER_ID);
1229+#endif
1230 ADD_INT(d, DB_NOTFOUND);
1231 ADD_INT(d, DB_OLD_VERSION);
1232 ADD_INT(d, DB_RUNRECOVERY);
1233@@ -9671,6 +9654,10 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1234 #if (DBVER >= 43)
1235 ADD_INT(d, DB_STAT_SUBSYSTEM);
1236 ADD_INT(d, DB_STAT_MEMP_HASH);
1237+ ADD_INT(d, DB_STAT_LOCK_CONF);
1238+ ADD_INT(d, DB_STAT_LOCK_LOCKERS);
1239+ ADD_INT(d, DB_STAT_LOCK_OBJECTS);
1240+ ADD_INT(d, DB_STAT_LOCK_PARAMS);
1241 #endif
1242
1243 #if (DBVER >= 48)
1244@@ -9690,7 +9677,6 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1245 ADD_INT(d, DB_EID_INVALID);
1246 ADD_INT(d, DB_EID_BROADCAST);
1247
1248-#if (DBVER >= 42)
1249 ADD_INT(d, DB_TIME_NOTGRANTED);
1250 ADD_INT(d, DB_TXN_NOT_DURABLE);
1251 ADD_INT(d, DB_TXN_WRITE_NOSYNC);
1252@@ -9698,9 +9684,8 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1253 ADD_INT(d, DB_INIT_REP);
1254 ADD_INT(d, DB_ENCRYPT);
1255 ADD_INT(d, DB_CHKSUM);
1256-#endif
1257
1258-#if (DBVER >= 42) && (DBVER < 47)
1259+#if (DBVER < 47)
1260 ADD_INT(d, DB_LOG_AUTOREMOVE);
1261 ADD_INT(d, DB_DIRECT_LOG);
1262 #endif
1263@@ -9733,6 +9718,20 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1264 ADD_INT(d, DB_VERB_REPLICATION);
1265 ADD_INT(d, DB_VERB_WAITSFOR);
1266
1267+#if (DBVER >= 50)
1268+ ADD_INT(d, DB_VERB_REP_SYSTEM);
1269+#endif
1270+
1271+#if (DBVER >= 47)
1272+ ADD_INT(d, DB_VERB_REP_ELECT);
1273+ ADD_INT(d, DB_VERB_REP_LEASE);
1274+ ADD_INT(d, DB_VERB_REP_MISC);
1275+ ADD_INT(d, DB_VERB_REP_MSGS);
1276+ ADD_INT(d, DB_VERB_REP_SYNC);
1277+ ADD_INT(d, DB_VERB_REPMGR_CONNFAIL);
1278+ ADD_INT(d, DB_VERB_REPMGR_MISC);
1279+#endif
1280+
1281 #if (DBVER >= 45)
1282 ADD_INT(d, DB_EVENT_PANIC);
1283 ADD_INT(d, DB_EVENT_REP_CLIENT);
1284@@ -9748,16 +9747,25 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1285 ADD_INT(d, DB_EVENT_WRITE_FAILED);
1286 #endif
1287
1288+#if (DBVER >= 50)
1289+ ADD_INT(d, DB_REPMGR_CONF_ELECTIONS);
1290+ ADD_INT(d, DB_EVENT_REP_MASTER_FAILURE);
1291+ ADD_INT(d, DB_EVENT_REP_DUPMASTER);
1292+ ADD_INT(d, DB_EVENT_REP_ELECTION_FAILED);
1293+#endif
1294+#if (DBVER >= 48)
1295+ ADD_INT(d, DB_EVENT_REG_ALIVE);
1296+ ADD_INT(d, DB_EVENT_REG_PANIC);
1297+#endif
1298+
1299 ADD_INT(d, DB_REP_DUPMASTER);
1300 ADD_INT(d, DB_REP_HOLDELECTION);
1301 #if (DBVER >= 44)
1302 ADD_INT(d, DB_REP_IGNORE);
1303 ADD_INT(d, DB_REP_JOIN_FAILURE);
1304 #endif
1305-#if (DBVER >= 42)
1306 ADD_INT(d, DB_REP_ISPERM);
1307 ADD_INT(d, DB_REP_NOTPERM);
1308-#endif
1309 ADD_INT(d, DB_REP_NEWSITE);
1310
1311 ADD_INT(d, DB_REP_MASTER);
1312@@ -9766,7 +9774,13 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1313 ADD_INT(d, DB_REP_PERMANENT);
1314
1315 #if (DBVER >= 44)
1316+#if (DBVER >= 50)
1317+ ADD_INT(d, DB_REP_CONF_AUTOINIT);
1318+#else
1319 ADD_INT(d, DB_REP_CONF_NOAUTOINIT);
1320+#endif /* 5.0 */
1321+#endif /* 4.4 */
1322+#if (DBVER >= 44)
1323 ADD_INT(d, DB_REP_CONF_DELAYCLIENT);
1324 ADD_INT(d, DB_REP_CONF_BULK);
1325 ADD_INT(d, DB_REP_CONF_NOWAIT);
1326@@ -9774,9 +9788,7 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1327 ADD_INT(d, DB_REP_REREQUEST);
1328 #endif
1329
1330-#if (DBVER >= 42)
1331 ADD_INT(d, DB_REP_NOBUFFER);
1332-#endif
1333
1334 #if (DBVER >= 46)
1335 ADD_INT(d, DB_REP_LEASE_EXPIRED);
1336@@ -9819,6 +9831,28 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1337 ADD_INT(d, DB_STAT_ALL);
1338 #endif
1339
1340+#if (DBVER >= 51)
1341+ ADD_INT(d, DB_REPMGR_ACKS_ALL_AVAILABLE);
1342+#endif
1343+
1344+#if (DBVER >= 48)
1345+ ADD_INT(d, DB_REP_CONF_INMEM);
1346+#endif
1347+
1348+ ADD_INT(d, DB_TIMEOUT);
1349+
1350+#if (DBVER >= 50)
1351+ ADD_INT(d, DB_FORCESYNC);
1352+#endif
1353+
1354+#if (DBVER >= 48)
1355+ ADD_INT(d, DB_FAILCHK);
1356+#endif
1357+
1358+#if (DBVER >= 51)
1359+ ADD_INT(d, DB_HOTBACKUP_IN_PROGRESS);
1360+#endif
1361+
1362 #if (DBVER >= 43)
1363 ADD_INT(d, DB_BUFFER_SMALL);
1364 ADD_INT(d, DB_SEQ_DEC);
1365@@ -9856,6 +9890,10 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1366 ADD_INT(d, DB_SET_LOCK_TIMEOUT);
1367 ADD_INT(d, DB_SET_TXN_TIMEOUT);
1368
1369+#if (DBVER >= 48)
1370+ ADD_INT(d, DB_SET_REG_TIMEOUT);
1371+#endif
1372+
1373 /* The exception name must be correct for pickled exception *
1374 * objects to unpickle properly. */
1375 #ifdef PYBSDDB_STANDALONE /* different value needed for standalone pybsddb */
1376@@ -9912,8 +9950,10 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1377 MAKE_EX(DBRunRecoveryError);
1378 MAKE_EX(DBVerifyBadError);
1379 MAKE_EX(DBNoServerError);
1380+#if (DBVER >= 44 && DBVER < 52)
1381 MAKE_EX(DBNoServerHomeError);
1382 MAKE_EX(DBNoServerIDError);
1383+#endif
1384 MAKE_EX(DBPageNotFoundError);
1385 MAKE_EX(DBSecondaryBadError);
1386
1387@@ -9927,9 +9967,7 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1388 MAKE_EX(DBNoSuchFileError);
1389 MAKE_EX(DBPermissionsError);
1390
1391-#if (DBVER >= 42)
1392 MAKE_EX(DBRepHandleDeadError);
1393-#endif
1394 #if (DBVER >= 44)
1395 MAKE_EX(DBRepLockoutError);
1396 #endif
1397@@ -9947,6 +9985,7 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1398 #undef MAKE_EX
1399
1400 /* Initialise the C API structure and add it to the module */
1401+ bsddb_api.api_version = PYBSDDB_API_VERSION;
1402 bsddb_api.db_type = &DB_Type;
1403 bsddb_api.dbcursor_type = &DBCursor_Type;
1404 bsddb_api.dblogcursor_type = &DBLogCursor_Type;
1405@@ -9955,19 +9994,25 @@ PyMODINIT_FUNC PyInit__bsddb(void) /* Note the two underscores */
1406 bsddb_api.dblock_type = &DBLock_Type;
1407 #if (DBVER >= 43)
1408 bsddb_api.dbsequence_type = &DBSequence_Type;
1409+#else
1410+ bsddb_api.dbsequence_type = NULL;
1411 #endif
1412 bsddb_api.makeDBError = makeDBError;
1413
1414 /*
1415- ** Capsules exist from Python 3.1, but I
1416- ** don't want to break the API compatibility
1417- ** for already published Python versions.
1418+ ** Capsules exist from Python 2.7 and 3.1.
1419+ ** We don't support Python 3.0 anymore, so...
1420+ ** #if (PY_VERSION_HEX < ((PY_MAJOR_VERSION < 3) ? 0x02070000 : 0x03020000))
1421 */
1422-#if (PY_VERSION_HEX < 0x03020000)
1423+#if (PY_VERSION_HEX < 0x02070000)
1424 py_api = PyCObject_FromVoidPtr((void*)&bsddb_api, NULL);
1425 #else
1426 {
1427- char py_api_name[250];
1428+ /*
1429+ ** The data must outlive the call!!. So, the static definition.
1430+ ** The buffer must be big enough...
1431+ */
1432+ static char py_api_name[MODULE_NAME_MAX_LEN+10];
1433
1434 strcpy(py_api_name, _bsddbModuleName);
1435 strcat(py_api_name, ".api");
1436diff --git a/Modules/bsddb.h b/Modules/bsddb.h
1437index a3a687b..c1d862a 100644
1438--- a/Modules/bsddb.h
1439+++ b/Modules/bsddb.h
1440@@ -109,7 +109,7 @@
1441 #error "eek! DBVER can't handle minor versions > 9"
1442 #endif
1443
1444-#define PY_BSDDB_VERSION "4.8.4.2"
1445+#define PY_BSDDB_VERSION "5.3.15"
1446
1447 /* Python object definitions */
1448
1449@@ -236,7 +236,7 @@ typedef struct DBSequenceObject {
1450 /* To access the structure from an external module, use code like the
1451 following (error checking missed out for clarity):
1452
1453- // If you are using Python before 3.2:
1454+ // If you are using Python before 2.7:
1455 BSDDB_api* bsddb_api;
1456 PyObject* mod;
1457 PyObject* cobj;
1458@@ -249,7 +249,7 @@ typedef struct DBSequenceObject {
1459 Py_DECREF(mod);
1460
1461
1462- // If you are using Python 3.2 or up:
1463+ // If you are using Python 2.7 or up: (except Python 3.0, unsupported)
1464 BSDDB_api* bsddb_api;
1465
1466 // Use "bsddb3._pybsddb.api" if you're using
1467@@ -257,10 +257,14 @@ typedef struct DBSequenceObject {
1468 bsddb_api = (void **)PyCapsule_Import("bsddb._bsddb.api", 1);
1469
1470
1471+ Check "api_version" number before trying to use the API.
1472+
1473 The structure's members must not be changed.
1474 */
1475
1476+#define PYBSDDB_API_VERSION 1
1477 typedef struct {
1478+ unsigned int api_version;
1479 /* Type objects */
1480 PyTypeObject* db_type;
1481 PyTypeObject* dbcursor_type;
1482@@ -268,9 +272,7 @@ typedef struct {
1483 PyTypeObject* dbenv_type;
1484 PyTypeObject* dbtxn_type;
1485 PyTypeObject* dblock_type;
1486-#if (DBVER >= 43)
1487- PyTypeObject* dbsequence_type;
1488-#endif
1489+ PyTypeObject* dbsequence_type; /* If DBVER < 43 -> NULL */
1490
1491 /* Functions */
1492 int (*makeDBError)(int err);
1493@@ -289,9 +291,9 @@ typedef struct {
1494 #define DBEnvObject_Check(v) ((v)->ob_type == bsddb_api->dbenv_type)
1495 #define DBTxnObject_Check(v) ((v)->ob_type == bsddb_api->dbtxn_type)
1496 #define DBLockObject_Check(v) ((v)->ob_type == bsddb_api->dblock_type)
1497-#if (DBVER >= 43)
1498-#define DBSequenceObject_Check(v) ((v)->ob_type == bsddb_api->dbsequence_type)
1499-#endif
1500+#define DBSequenceObject_Check(v) \
1501+ ((bsddb_api->dbsequence_type) && \
1502+ ((v)->ob_type == bsddb_api->dbsequence_type))
1503
1504 #endif /* COMPILING_BSDDB_C */
1505
1506diff --git a/setup.py b/setup.py
1507index 6b47451..e8ac96c 100644
1508--- a/setup.py
1509+++ b/setup.py
1510@@ -799,7 +799,7 @@ class PyBuildExt(build_ext):
1511 # a release. Most open source OSes come with one or more
1512 # versions of BerkeleyDB already installed.
1513
1514- max_db_ver = (4, 8)
1515+ max_db_ver = (5, 3)
1516 min_db_ver = (4, 1)
1517 db_setup_debug = False # verbose debug prints from this script?
1518
1519@@ -821,7 +821,11 @@ class PyBuildExt(build_ext):
1520 return True
1521
1522 def gen_db_minor_ver_nums(major):
1523- if major == 4:
1524+ if major == 5:
1525+ for x in range(max_db_ver[1]+1):
1526+ if allow_db_ver((5, x)):
1527+ yield x
1528+ elif major == 4:
1529 for x in range(max_db_ver[1]+1):
1530 if allow_db_ver((4, x)):
1531 yield x
1532@@ -835,6 +839,9 @@ class PyBuildExt(build_ext):
1533 # construct a list of paths to look for the header file in on
1534 # top of the normal inc_dirs.
1535 db_inc_paths = [
1536+ '/usr/include/db5',
1537+ '/usr/local/include/db5',
1538+ '/opt/sfw/include/db5',
1539 '/usr/include/db4',
1540 '/usr/local/include/db4',
1541 '/opt/sfw/include/db4',
1542@@ -845,6 +852,16 @@ class PyBuildExt(build_ext):
1543 '/sw/include/db4',
1544 '/sw/include/db3',
1545 ]
1546+ # 5.x minor number specific paths
1547+ for x in gen_db_minor_ver_nums(5):
1548+ db_inc_paths.append('/usr/include/db5%d' % x)
1549+ db_inc_paths.append('/usr/include/db5.%d' % x)
1550+ db_inc_paths.append('/usr/local/BerkeleyDB.5.%d/include' % x)
1551+ db_inc_paths.append('/usr/local/include/db5%d' % x)
1552+ db_inc_paths.append('/pkg/db-5.%d/include' % x)
1553+ db_inc_paths.append('/opt/db-5.%d/include' % x)
1554+ # MacPorts default (http://www.macports.org/)
1555+ db_inc_paths.append('/opt/local/include/db5%d' % x)
1556 # 4.x minor number specific paths
1557 for x in gen_db_minor_ver_nums(4):
1558 db_inc_paths.append('/usr/include/db4%d' % x)
1559@@ -871,6 +888,10 @@ class PyBuildExt(build_ext):
1560 for dn in inc_dirs:
1561 std_variants.append(os.path.join(dn, 'db3'))
1562 std_variants.append(os.path.join(dn, 'db4'))
1563+ std_variants.append(os.path.join(dn, 'db5'))
1564+ for x in gen_db_minor_ver_nums(5):
1565+ std_variants.append(os.path.join(dn, "db5%d"%x))
1566+ std_variants.append(os.path.join(dn, "db5.%d"%x))
1567 for x in gen_db_minor_ver_nums(4):
1568 std_variants.append(os.path.join(dn, "db4%d"%x))
1569 std_variants.append(os.path.join(dn, "db4.%d"%x))
1570--
15711.7.7
1572
diff --git a/meta/recipes-devtools/python/python/python-2.7.3-remove-bsdb-rpath.patch b/meta/recipes-devtools/python/python/python-2.7.3-remove-bsdb-rpath.patch
new file mode 100644
index 0000000000..216be0a448
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-2.7.3-remove-bsdb-rpath.patch
@@ -0,0 +1,28 @@
1Upstream-Status: Inappropriate [embedded specific]
2
3Remove the RPATH to avoid QA issue warning.
4
5RP: Added secondary unnecessary rpath to the list 2012/8/7
6Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
7
8
9Index: Python-2.7.3/setup.py
10===================================================================
11--- Python-2.7.3.orig/setup.py 2012-08-07 10:41:58.560132529 +0000
12+++ Python-2.7.3/setup.py 2012-08-07 11:09:47.852094515 +0000
13@@ -1042,7 +1042,6 @@
14 exts.append(Extension('_bsddb', ['_bsddb.c'],
15 depends = ['bsddb.h'],
16 library_dirs=dblib_dir,
17- runtime_library_dirs=dblib_dir,
18 include_dirs=db_incs,
19 libraries=dblibs))
20 else:
21@@ -1252,7 +1251,6 @@
22 print "building dbm using bdb"
23 dbmext = Extension('dbm', ['dbmmodule.c'],
24 library_dirs=dblib_dir,
25- runtime_library_dirs=dblib_dir,
26 include_dirs=db_incs,
27 define_macros=[
28 ('HAVE_BERKDB_H', None),
diff --git a/meta/recipes-devtools/python/python/python-fix-build-error-with-Readline-6.3.patch b/meta/recipes-devtools/python/python/python-fix-build-error-with-Readline-6.3.patch
new file mode 100644
index 0000000000..b84f8c3461
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-fix-build-error-with-Readline-6.3.patch
@@ -0,0 +1,62 @@
1python: fix build error with Readline 6.3
2
3Backport two patches from upstream:
4
5use new readline function types (closes #20374)
6Issue #20374: Avoid compiler warnings when compiling readline with libedit.
7
8Upstream-Status: Backport
9
10Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
11---
12 Modules/readline.c | 15 ++++++++++++---
13 1 file changed, 12 insertions(+), 3 deletions(-)
14
15diff --git a/Modules/readline.c b/Modules/readline.c
16index b5e258d..d3f52aa 100644
17--- a/Modules/readline.c
18+++ b/Modules/readline.c
19@@ -735,15 +735,24 @@ on_hook(PyObject *func)
20 return result;
21 }
22
23+
24 static int
25+#if defined(_RL_FUNCTION_TYPEDEF)
26 on_startup_hook(void)
27+#else
28+on_startup_hook()
29+#endif
30 {
31 return on_hook(startup_hook);
32 }
33
34 #ifdef HAVE_RL_PRE_INPUT_HOOK
35 static int
36+#if defined(_RL_FUNCTION_TYPEDEF)
37 on_pre_input_hook(void)
38+#else
39+on_pre_input_hook()
40+#endif
41 {
42 return on_hook(pre_input_hook);
43 }
44@@ -886,12 +895,12 @@ setup_readline(void)
45 rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap);
46 rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap);
47 /* Set our hook functions */
48- rl_startup_hook = (Function *)on_startup_hook;
49+ rl_startup_hook = (rl_hook_func_t *)on_startup_hook;
50 #ifdef HAVE_RL_PRE_INPUT_HOOK
51- rl_pre_input_hook = (Function *)on_pre_input_hook;
52+ rl_pre_input_hook = (rl_hook_func_t *)on_pre_input_hook;
53 #endif
54 /* Set our completion function */
55- rl_attempted_completion_function = (CPPFunction *)flex_complete;
56+ rl_attempted_completion_function = (rl_completion_func_t *)flex_complete;
57 /* Set Python word break characters */
58 rl_completer_word_break_characters =
59 strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
60--
611.7.9.5
62
diff --git a/meta/recipes-devtools/python/python/python2.7.3-nossl3.patch b/meta/recipes-devtools/python/python/python2.7.3-nossl3.patch
new file mode 100644
index 0000000000..2d35520a6d
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python2.7.3-nossl3.patch
@@ -0,0 +1,37 @@
1python: Building without SSLv3 support
2
3Building without SSLv3 support when openssl is built
4without any support for SSLv3
5
6Upstream-Status: Backport
7
8Reference:
9https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=76A8611#22
10
11Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
12---
13diff -ruN a/Modules/_ssl.c b/Modules/_ssl.c
14--- a/Modules/_ssl.c 2014-11-26 07:43:58.755679939 +0100
15+++ b/Modules/_ssl.c 2014-11-26 07:49:10.454182400 +0100
16@@ -302,8 +302,10 @@
17 PySSL_BEGIN_ALLOW_THREADS
18 if (proto_version == PY_SSL_VERSION_TLS1)
19 self->ctx = SSL_CTX_new(TLSv1_method()); /* Set up context */
20+#ifndef OPENSSL_NO_SSL3
21 else if (proto_version == PY_SSL_VERSION_SSL3)
22 self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
23+#endif
24 #ifndef OPENSSL_NO_SSL2
25 else if (proto_version == PY_SSL_VERSION_SSL2)
26 self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
27@@ -1777,8 +1779,10 @@
28 PyModule_AddIntConstant(m, "PROTOCOL_SSLv2",
29 PY_SSL_VERSION_SSL2);
30 #endif
31+#ifndef OPENSSL_NO_SSL3
32 PyModule_AddIntConstant(m, "PROTOCOL_SSLv3",
33 PY_SSL_VERSION_SSL3);
34+#endif
35 PyModule_AddIntConstant(m, "PROTOCOL_SSLv23",
36 PY_SSL_VERSION_SSL23);
37 PyModule_AddIntConstant(m, "PROTOCOL_TLSv1",
diff --git a/meta/recipes-devtools/python/python/remove_sqlite_rpath.patch b/meta/recipes-devtools/python/python/remove_sqlite_rpath.patch
new file mode 100644
index 0000000000..4ec627ea51
--- /dev/null
+++ b/meta/recipes-devtools/python/python/remove_sqlite_rpath.patch
@@ -0,0 +1,19 @@
1This patch removes the RPATH setting which contains a pointer to
2the target relocated sysroot, which is incorrect.
3
4Upstream-Status: Inappropriate [Embedded Specific]
5
6Signed-off-by: Saul Wold <sgw@linux.intel.com>
7
8Index: Python-2.6.6/setup.py
9===================================================================
10--- Python-2.6.6.orig/setup.py 2011-09-28 14:22:57.000000000 -0700
11+++ Python-2.6.6/setup.py 2011-09-28 16:11:25.147279633 -0700
12@@ -1079,7 +1079,6 @@
13 include_dirs=["Modules/_sqlite",
14 sqlite_incdir],
15 library_dirs=sqlite_libdir,
16- runtime_library_dirs=sqlite_libdir,
17 extra_link_args=sqlite_extra_link_args,
18 libraries=["sqlite3",]))
19 else:
diff --git a/meta/recipes-devtools/python/python/run-ptest b/meta/recipes-devtools/python/python/run-ptest
new file mode 100644
index 0000000000..89a769f743
--- /dev/null
+++ b/meta/recipes-devtools/python/python/run-ptest
@@ -0,0 +1,5 @@
1#!/bin/sh
2#
3#This script is used to run python test suites
4
5make -f /usr/lib/python/ptest/Makefile -k runtest-TESTS srcdir=/usr/lib/python2.7 TESTPROG=/usr/lib/python2.7/test/regrtest.py | sed -e '/\.\.\. ok/ s/^/PASS: /g' -e '/\.\.\. [ERROR|FAIL]/ s/^/FAIL: /g' -e '/\.\.\. skipped/ s/^/SKIP: /g' -e 's/ \.\.\. ok//g' -e 's/ \.\.\. ERROR//g' -e 's/ \.\.\. FAIL//g' -e 's/ \.\.\. skipped//g'
diff --git a/meta/recipes-devtools/python/python/search_db_h_in_inc_dirs_and_avoid_warning.patch b/meta/recipes-devtools/python/python/search_db_h_in_inc_dirs_and_avoid_warning.patch
new file mode 100644
index 0000000000..0c1f1741cb
--- /dev/null
+++ b/meta/recipes-devtools/python/python/search_db_h_in_inc_dirs_and_avoid_warning.patch
@@ -0,0 +1,40 @@
1python should search for db.h in inc_dirs and not in a hardcoded path.
2If db.h is found but HASHVERSION is not 2 we avoid a warning by not
3adding this module to missing variable.
4
5Upstream-Status: Inappropriate [distribution]
6
7Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
8
9Index: Python-2.7.2/setup.py
10===================================================================
11--- Python-2.7.2.orig/setup.py 2012-04-05 22:27:22.437199989 +0300
12+++ Python-2.7.2/setup.py 2012-04-05 22:26:38.000000000 +0300
13@@ -1141,12 +1141,12 @@
14 # the more recent berkeleydb's db.h file first in the include path
15 # when attempting to compile and it will fail.
16 f = "/usr/include/db.h"
17-
18+ if len(inc_dirs) != 0:
19+ f = os.path.join(inc_dirs[0], "db.h")
20 if sys.platform == 'darwin':
21 if is_macosx_sdk_path(f):
22 sysroot = macosx_sdk_root()
23 f = os.path.join(sysroot, f[1:])
24-
25 if os.path.exists(f) and not db_incs:
26 data = open(f).read()
27 m = re.search(r"#s*define\s+HASHVERSION\s+2\s*", data)
28@@ -1161,8 +1161,10 @@
29 libraries=libraries))
30 else:
31 exts.append(Extension('bsddb185', ['bsddbmodule.c']))
32- else:
33- missing.append('bsddb185')
34+ # If a newer version is detected don't report an useless
35+ # warning
36+ #else:
37+ # missing.append('bsddb185')
38 else:
39 missing.append('bsddb185')
40
diff --git a/meta/recipes-devtools/python/python/setup_py_skip_cross_import_check.patch b/meta/recipes-devtools/python/python/setup_py_skip_cross_import_check.patch
new file mode 100644
index 0000000000..6ccdb948b9
--- /dev/null
+++ b/meta/recipes-devtools/python/python/setup_py_skip_cross_import_check.patch
@@ -0,0 +1,27 @@
1This patch skips over the 'import check' setup.py does when building
2extensions. This generally won't work when cross-compiling.
3
4Upstream-Status: Inappropriate [embedded-specific]
5
6Signed-off-by: Tom Zanussi <tom.zanussi@intel.com>
7
8Index: Python-2.7.2/setup.py
9===================================================================
10--- Python-2.7.2.orig/setup.py 2011-11-04 16:46:34.553796410 -0500
11+++ Python-2.7.2/setup.py 2011-11-04 16:59:49.692802313 -0500
12@@ -287,6 +287,15 @@
13 (ext.name, sys.exc_info()[1]))
14 self.failed.append(ext.name)
15 return
16+
17+ # If we're cross-compiling, we want to skip the import check
18+ # i.e. we shouldn't be dynamically loading target shared libs
19+ if os.environ.get('CROSS_COMPILE') is not None:
20+ self.announce(
21+ 'WARNING: skipping import check for cross-compiled "%s"' %
22+ ext.name)
23+ return
24+
25 # Workaround for Mac OS X: The Carbon-based modules cannot be
26 # reliably imported into a command-line Python
27 if 'Carbon' in ext.extra_link_args:
diff --git a/meta/recipes-devtools/python/python/setuptweaks.patch b/meta/recipes-devtools/python/python/setuptweaks.patch
new file mode 100644
index 0000000000..c34ef160d3
--- /dev/null
+++ b/meta/recipes-devtools/python/python/setuptweaks.patch
@@ -0,0 +1,57 @@
1This patch removes various ways native system options can pass into the python
2compilation and somehow break C modules.
3
4Upstream-Status: Configuration [OE Specific]
5
6RP 2012/04/23
7
8Index: Python-2.7.2/setup.py
9===================================================================
10--- Python-2.7.2.orig/setup.py 2012-04-23 20:03:47.295582553 +0000
11+++ Python-2.7.2/setup.py 2012-04-23 20:03:15.000000000 +0000
12@@ -231,7 +231,13 @@
13 # compilers
14 if compiler is not None:
15 (ccshared,cflags) = sysconfig.get_config_vars('CCSHARED','CFLAGS')
16- args['compiler_so'] = compiler + ' ' + ccshared + ' ' + cflags
17+ # Need to filter out -isysroot from the flags. Ideally should
18+ # figure out target flags here.
19+ flags = []
20+ for f in cflags.split():
21+ if not f.startswith("-isystem"):
22+ flags.append(f)
23+ args['compiler_so'] = compiler + ' ' + ccshared + ' ' + ' '.join(flags)
24 self.compiler.set_executables(**args)
25
26 build_ext.build_extensions(self)
27@@ -393,7 +399,6 @@
28 # into configure and stored in the Makefile (issue found on OS X 10.3).
29 for env_var, arg_name, dir_list in (
30 ('LDFLAGS', '-R', self.compiler.runtime_library_dirs),
31- ('LDFLAGS', '-L', self.compiler.library_dirs),
32 ('CPPFLAGS', '-I', self.compiler.include_dirs)):
33 env_val = sysconfig.get_config_var(env_var)
34 if env_val:
35@@ -419,16 +424,16 @@
36 for directory in reversed(options.dirs):
37 add_dir_to_list(dir_list, directory)
38
39- if os.path.normpath(sys.prefix) != '/usr' \
40- and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
41+# if os.path.normpath(sys.prefix) != '/usr' \
42+# and not sysconfig.get_config_var('PYTHONFRAMEWORK'):
43 # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework
44 # (PYTHONFRAMEWORK is set) to avoid # linking problems when
45 # building a framework with different architectures than
46 # the one that is currently installed (issue #7473)
47- add_dir_to_list(self.compiler.library_dirs,
48- sysconfig.get_config_var("LIBDIR"))
49- add_dir_to_list(self.compiler.include_dirs,
50- sysconfig.get_config_var("INCLUDEDIR"))
51+# add_dir_to_list(self.compiler.library_dirs,
52+# sysconfig.get_config_var("LIBDIR"))
53+# add_dir_to_list(self.compiler.include_dirs,
54+# sysconfig.get_config_var("INCLUDEDIR"))
55
56 try:
57 have_unicode = unicode
diff --git a/meta/recipes-devtools/python/python/sitecustomize.py b/meta/recipes-devtools/python/python/sitecustomize.py
new file mode 100644
index 0000000000..273901898a
--- /dev/null
+++ b/meta/recipes-devtools/python/python/sitecustomize.py
@@ -0,0 +1,45 @@
1# OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
2# GPLv2 or later
3# Version: 20081123
4# Features:
5# * set proper default encoding
6# * enable readline completion in the interactive interpreter
7# * load command line history on startup
8# * save command line history on exit
9
10import os
11
12def __exithandler():
13 try:
14 readline.write_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) )
15 except IOError:
16 pass
17
18def __registerExitHandler():
19 import atexit
20 atexit.register( __exithandler )
21
22def __enableReadlineSupport():
23 readline.set_history_length( 1000 )
24 readline.parse_and_bind( "tab: complete" )
25 try:
26 readline.read_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) )
27 except IOError:
28 pass
29
30def __enableDefaultEncoding():
31 import sys
32 try:
33 sys.setdefaultencoding( "utf8" )
34 except LookupError:
35 pass
36
37import sys
38try:
39 import rlcompleter, readline
40except ImportError:
41 pass
42else:
43 __enableDefaultEncoding()
44 __registerExitHandler()
45 __enableReadlineSupport()