diff options
| author | Trent Nelson <trent@trent.me> | 2012-10-17 22:08:40 (GMT) |
|---|---|---|
| committer | Trent Nelson <trent@trent.me> | 2012-10-17 22:08:40 (GMT) |
| commit | f17512f67e545bfeda1905b63f80217e0b7853aa (patch) | |
| tree | f88dd59d7d4b46c8063ec714dae0c99dbf3aeca6 /Modules/_struct.c | |
| parent | c78649873fe76da34230bb8ee5284ff64b2af2e4 (diff) | |
| parent | 743e0cd6b5d59767aae2524700857f188ca1e80e (diff) | |
| download | cpython-f17512f67e545bfeda1905b63f80217e0b7853aa.zip cpython-f17512f67e545bfeda1905b63f80217e0b7853aa.tar.gz cpython-f17512f67e545bfeda1905b63f80217e0b7853aa.tar.bz2 | |
Merge heads.
Diffstat (limited to 'Modules/_struct.c')
| -rw-r--r-- | Modules/_struct.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index 0b20e26..0f50144 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1199,12 +1199,11 @@ whichtable(char **pfmt) case '!': /* Network byte order is big-endian */ return bigendian_table; case '=': { /* Host byte order -- different from native in alignment! */ - int n = 1; - char *p = (char *) &n; - if (*p == 1) - return lilendian_table; - else - return bigendian_table; +#if PY_LITTLE_ENDIAN + return lilendian_table; +#else + return bigendian_table; +#endif } default: --*pfmt; /* Back out of pointer increment */ @@ -2088,13 +2087,13 @@ PyInit__struct(void) /* Check endian and swap in faster functions */ { - int one = 1; formatdef *native = native_table; formatdef *other, *ptr; - if ((int)*(unsigned char*)&one) - other = lilendian_table; - else - other = bigendian_table; +#if PY_LITTLE_ENDIAN + other = lilendian_table; +#else + other = bigendian_table; +#endif /* Scan through the native table, find a matching entry in the endian table and swap in the native implementations whenever possible |
