~ubuntu-branches/ubuntu/natty/python3.1/natty-security

« back to all changes in this revision

Viewing changes to debian/patches/arm-float.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-07-06 16:52:42 UTC
  • mfrom: (1.2.1 upstream) (2.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20100706165242-2xv4i019r3et6c0j
Tags: 3.1.2+20100706-1ubuntu1
* Merge with Debian; remaining changes:
  - Regenerate the control file.
  - Add debian/patches/overwrite-semaphore-check for Lucid buildds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh -e
2
 
 
3
 
# DP: Support mixed-endian IEEE floating point, as found in the ARM old-ABI.
4
 
 
5
 
dir=
6
 
if [ $# -eq 3 -a "$2" = '-d' ]; then
7
 
    pdir="-d $3"
8
 
    dir="$3/"
9
 
elif [ $# -ne 1 ]; then
10
 
    echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
11
 
    exit 1
12
 
fi
13
 
case "$1" in
14
 
    -patch)
15
 
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
16
 
        ;;
17
 
    -unpatch)
18
 
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
19
 
        ;;
20
 
    *)
21
 
        echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
22
 
        exit 1
23
 
esac
24
 
exit 0
25
 
 
26
 
--- Objects/floatobject.c.orig  2006-05-25 10:53:30.000000000 -0500
27
 
+++ Objects/floatobject.c       2007-07-27 06:43:15.000000000 -0500
28
 
@@ -982,7 +982,7 @@
29
 
 /* this is for the benefit of the pack/unpack routines below */
30
 
 
31
 
 typedef enum {
32
 
-       unknown_format, ieee_big_endian_format, ieee_little_endian_format
33
 
+       unknown_format, ieee_big_endian_format, ieee_little_endian_format, ieee_mixed_endian_format
34
 
 } float_format_type;
35
 
 
36
 
 static float_format_type double_format, float_format;
37
 
@@ -1021,6 +1021,8 @@
38
 
                return PyString_FromString("IEEE, little-endian");
39
 
        case ieee_big_endian_format:
40
 
                return PyString_FromString("IEEE, big-endian");
41
 
+       case ieee_mixed_endian_format:
42
 
+               return PyString_FromString("IEEE, mixed-endian");
43
 
        default:
44
 
                Py_FatalError("insane float_format or double_format");
45
 
                return NULL;
46
 
@@ -1073,11 +1075,14 @@
47
 
        else if (strcmp(format, "IEEE, big-endian") == 0) {
48
 
                f = ieee_big_endian_format;
49
 
        }
50
 
+       else if (strcmp(format, "IEEE, mixed-endian") == 0) {
51
 
+               f = ieee_mixed_endian_format;
52
 
+       }
53
 
        else {
54
 
                PyErr_SetString(PyExc_ValueError,
55
 
                                "__setformat__() argument 2 must be "
56
 
-                               "'unknown', 'IEEE, little-endian' or "
57
 
-                               "'IEEE, big-endian'");
58
 
+                               "'unknown', 'IEEE, little-endian', "
59
 
+                               "'IEEE, big-endian' or 'IEEE, mixed-endian'");
60
 
                return NULL;
61
 
 
62
 
        }
63
 
@@ -1230,6 +1235,8 @@
64
 
                        detected_double_format = ieee_big_endian_format;
65
 
                else if (memcmp(&x, "\x05\x04\x03\x02\x01\xff\x3f\x43", 8) == 0)
66
 
                        detected_double_format = ieee_little_endian_format;
67
 
+               else if (memcmp(&x, "\x01\xff\x3f\x43\x05\x04\x03\x02", 8) == 0)
68
 
+                       detected_double_format = ieee_mixed_endian_format;
69
 
                else 
70
 
                        detected_double_format = unknown_format;
71
 
        }
72
 
@@ -1565,8 +1572,19 @@
73
 
                        p += 7;
74
 
                        incr = -1;
75
 
                }
76
 
+               else if (double_format == ieee_mixed_endian_format) {
77
 
+                       if (le)
78
 
+                               p += 4;
79
 
+                       else {
80
 
+                               p += 3;
81
 
+                               incr = -1;
82
 
+                       }
83
 
+               }
84
 
                
85
 
                for (i = 0; i < 8; i++) {
86
 
+                       if (double_format == ieee_mixed_endian_format && i == 4)
87
 
+                               p += -8 * incr;
88
 
+
89
 
                        *p = *s++;
90
 
                        p += incr;
91
 
                }
92
 
@@ -1739,6 +1757,27 @@
93
 
                        }
94
 
                        memcpy(&x, buf, 8);
95
 
                }
96
 
+               else if (double_format == ieee_mixed_endian_format) {
97
 
+                       char buf[8];
98
 
+                       char *d;
99
 
+                       int i, incr = 1;
100
 
+
101
 
+                       if (le)
102
 
+                               d = &buf[4];
103
 
+                       else
104
 
+                               d = &buf[3];
105
 
+                       
106
 
+                       for (i = 0; i < 4; i++) {
107
 
+                               *d = *p++;
108
 
+                               d += incr;
109
 
+                       }
110
 
+                       d += -8 * incr;
111
 
+                       for (i = 0; i < 4; i++) {
112
 
+                               *d = *p++;
113
 
+                               d += incr;
114
 
+                       }
115
 
+                       memcpy(&x, buf, 8);
116
 
+               }
117
 
                else {
118
 
                        memcpy(&x, p, 8);
119
 
                }