Lines 1-12
Link Here
|
1 |
XXX: should investigate ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED |
|
|
2 |
|
3 |
This patch for zziplib (0.13.50) fixes a bus error on Linux/SPARC. |
1 |
This patch for zziplib (0.13.50) fixes a bus error on Linux/SPARC. |
4 |
|
2 |
|
5 |
Since SPARC machines are big endian and zip files are stored in little endian, |
3 |
Since SPARC machines are big endian and zip files are stored in little endian, |
6 |
zziplib needs to do byte swapping. On GNU/Linux this is usually done using |
4 |
zziplib needs to do byte swapping. On GNU/Linux this is usually done using |
7 |
glibc's bswap_{16,32,64} functions but in this case calling one of these |
5 |
glibc's bswap_{16,32,64} functions but in this case calling one of these |
8 |
functions triggers a bus error. This patch makes zziplib use it's own byte |
6 |
functions triggers a bus error. This patch completes upstreams work to |
9 |
swapping functions (which do work) on Linux/SPARC instead of glibc's. |
7 |
implement ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED for machines which required aligned |
|
|
8 |
access. |
9 |
After applying the patch zziplib needs to be compiled with |
10 |
-DZZIP_HAVE_ALIGNED_ACCESS_REQUIRED |
10 |
|
11 |
|
11 |
To reproduce it run (in the src dir): |
12 |
To reproduce it run (in the src dir): |
12 |
cd Linux_*_sparc64.d && ./bins/zzcat test/test/README |
13 |
cd Linux_*_sparc64.d && ./bins/zzcat test/test/README |
Lines 26-43
Link Here
|
26 |
|
27 |
|
27 |
#if defined ZZIP_WORDS_BIGENDIAN && \ |
28 |
#if defined ZZIP_WORDS_BIGENDIAN && \ |
28 |
- defined bswap_16 && defined bswap_32 && defined bswap_64 |
29 |
- defined bswap_16 && defined bswap_32 && defined bswap_64 |
29 |
+ defined bswap_16 && defined bswap_32 && defined bswap_64 && !defined(__sparc__) |
30 |
+ defined bswap_16 && defined bswap_32 && defined bswap_64 && !defined(ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED) |
30 |
# define __ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p)) |
31 |
# define __ZZIP_GET16(__p) bswap_16(*(uint16_t*)(__p)) |
31 |
# define __ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p)) |
32 |
# define __ZZIP_GET32(__p) bswap_32(*(uint32_t*)(__p)) |
32 |
# define __ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x))) |
33 |
# define __ZZIP_SET16(__p,__x) (*(uint16_t*)(__p) = bswap_16((uint16_t)(__x))) |
33 |
--- zzip/fetch.h |
|
|
34 |
+++ zzip/fetch.h |
35 |
@@ -24,7 +24,7 @@ extern uint64_t __zzip_get64(zzip_byte_t * s) __zzip_attribute__((const)); |
36 |
extern void __zzip_set64(zzip_byte_t * s, uint64_t v); |
37 |
|
38 |
#ifdef ZZIP_WORDS_BIGENDIAN |
39 |
-# if defined bswap_16 && defined bswap_32 && defined bswap_64 /* i.e. linux */ |
40 |
+# if defined bswap_16 && defined bswap_32 && defined bswap_64 && !defined(__sparc__) /* i.e. linux */ |
41 |
# ifndef ZZIP_HAVE_ALIGNED_ACCESS_REQUIRED |
42 |
# define _ZZIP_USE_BSWAP |
43 |
# endif |