]> granicus.if.org Git - zziplib/commitdiff
aligned access
authorGuido Draheim <guidod@gmx.de>
Thu, 17 Aug 2006 01:52:14 +0000 (01:52 +0000)
committerGuido Draheim <guidod@gmx.de>
Thu, 17 Aug 2006 01:52:14 +0000 (01:52 +0000)
 (.)

15 files changed:
ChangeLog
Makefile.in
Makefile.mk
SDL/Makefile.in
aclocal.m4
bins/Makefile.in
config.h.in
configure
configure.ac
docs/Makefile.in
m4/ax_check_aligned_access_required.m4 [new file with mode: 0644]
test/Makefile.in
zzip/Makefile.in
zzip/fseeko.h
zzipwrap/Makefile.in

index c7b9b05c5ac43d98000d4d04b7c52adf8d86f5e2..0d767f3c1af355c74033fc64badfcf49b7d33004 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-08-17
+ * A report by Tuilipant Gergely had shown an "unaligned access"
+   error on an alpha machine. So, I have added macro to test for
+   the condition of aligned access but the alpha platoform seems
+   to be okay. Further reports are required.
 2008-08-14
  * Yvan Phelizot reports a problem in zzip/mmapped.c
  * Malcom MacLeod had spurious problems inside a C++ project,
index 39702df9cef043d2eae5b0fca4006c65f4369957..8d12c9b78f0141a6848a5b801f72d693037f0993 100644 (file)
@@ -51,6 +51,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_compile_check_sizeof.m4 \
        $(top_srcdir)/m4/ax_cflags_no_writable_strings.m4 \
        $(top_srcdir)/m4/ax_cflags_strict_prototypes.m4 \
        $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+       $(top_srcdir)/m4/ax_check_aligned_access_required.m4 \
        $(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
        $(top_srcdir)/m4/ax_enable_builddir_uname.m4 \
        $(top_srcdir)/m4/ax_expand_prefix.m4 \
index 084c042a64d5574c1ce7738cc118408aba3856bd..e25c541e7bbe97e49d379d3993406100ae8e49ec 100644 (file)
@@ -44,30 +44,64 @@ cf_powermac = ppc-osx3
 cf_powerpc = openpower-linux1
 cf_sparc = sparc-solaris1
 cf_solaris = x86-solaris1
-cf_all = $(cf_debian) $(cf_fedora) $(cf_freebsd) $(cf_netbsd) $(cf_openbsd) \
-         $(cf_amd64) $(cf_alpha) $(cf_powerpc) $(cf_sparc) $(cf_solaris) \
-         $(cf_powermac)
+linux = $(cf_fedora)  $(cf_debian)   $(cf_amd64)   $(cf_powerpc)   $(cf_alpha) 
+bsd =   $(cf_freebsd) $(cf_netbsd)   $(cf_openbsd) $(cf_powermac)
+sun =   $(cf_sparc)   $(cf_solaris)
+all = $(linux) $(sun) $(bsd)
+list = all
+
+
+_paths_ = export PATH=$$PATH:X/bin
+_includes_ = CPPFLAGS=\"-IX/include -IX/include/ncurses\"
+sparc-solaris1-gcc-path = $(subst X,/usr/local,$(_paths_));
+x86-solaris1-gcc-path   = $(subst X,/usr/local,$(_paths_));
+sparc-solaris1-cc-path  = $(subst X,/opt/SUNWspro,$(_paths_));
+x86-solaris1-cc-path    = $(subst X,/opt/SUNWspro,$(_paths_));
+sparc-solaris1-gcc-conf = $(subst X,/usr/local,$(_includes_));
+x86-solaris1-gcc-conf   = $(subst X,/usr/local,$(_includes_));
+sparc-solaris1-cc-conf  = $(subst X,/opt/SUNWspro,$(_includes_));
+x86-solaris1-cc-conf    = $(subst X,/opt/SUNWspro,$(_includes_));
+cf_compiler=gcc
+cf_configure =    sh configure $($(cf)-$(cf_compiler)-conf) $(args)
+cf_profile = $(cf_get_uname); $($(cf)-$(cf_compiler)-path)
+cf_get_uname = uname -msr
+cf_unpacked = $(PACKAGE)-$(VERSION)
 cf : cf-upload cf-system-all
 cf-upload: ;   scp $(PUB)$(PACKAGE)-$(VERSION).tar.bz2 cf-shell.sf.net:
 cf-unpack: ; ssh cf-shell.sf.net \
-       "ssh $(cf) 'tar xjvf $(PACKAGE)-$(VERSION).tar.bz2'"
+       ssh $(cf) "'tar xjvf $(PACKAGE)-$(VERSION).tar.bz2 2>&1'"
 cf-configure: ; ssh cf-shell.sf.net \
-       "ssh $(cf) 'uname -msr; cd $(PACKAGE)-$(VERSION) && sh configure'"
+       ssh $(cf) "'$(cf_profile) cd $(cf_unpacked) && $(cf_configure) 2>&1'"
 cf-build: ; ssh cf-shell.sf.net \
-       "ssh $(cf) 'uname -msr; cd $(PACKAGE)-$(VERSION) && make'"
+       ssh $(cf) "'$(cf_profile) cd $(cf_unpacked) && make 2>&1'"
 cf-check: ; ssh cf-shell.sf.net \
-       "ssh $(cf) 'uname -msr; cd $(PACKAGE)-$(VERSION) && make check'"
+       ssh $(cf) "'$(cf_profile) cd $(cf_unpacked) && make check 2>&1'"
+cf-clean: ; ssh cf-shell.sf.net \
+       ssh $(cf) "'$(cf_profile) cd $(cf_unpacked) && make clean 2>&1'"
+cf-distclean: ; ssh cf-shell.sf.net \
+       ssh $(cf) "'$(cf_profile) cd $(cf_unpacked) && rm -rf *.d 2>&1'"
+cf-prep: dist cf-upload cf-unpack
+cf-wipe: ; ssh cf-shell.sf.net \
+       ssh $(cf) "'$(cf_profile) rm -rf $(cf_unpacked)/ 2>&1'"
 cf-system: ; ssh cf-shell.sf.net \
-       "ssh $(cf) 'uname -msr | sed s,^,====$(cf)====,'"
+       ssh $(cf) "'$(cf_profile) $(cf_get_uname) | sed \"s,^,: $(cf) = ,\"'"
 cf-configure-all:
-       @ for cf in $(cf_all) ; do echo $(MAKE) cf-configure cf=$$cf \
-       ; sleep 1;                      $(MAKE) cf-configure cf=$$cf ; done
+       echo $@: `date` "====================" > cf.log
+       @ for cf in $($(list)) ; do echo $(MAKE) cf-configure cf=$$cf \
+       ; sleep 1;                       $(MAKE) cf-configure cf=$$cf \
+       | sed -e "s|^|$$cf: |" | tee -a cf.log ; done
 cf-build-all:
-       @ for cf in $(cf_all) ; do echo $(MAKE) cf-build cf=$$cf \
-       ; sleep 1;                      $(MAKE) cf-build cf=$$cf ; done
+       echo $@: `date` "====================" >> cf.log
+       @ for cf in $($(list)) ; do echo $(MAKE) cf-build cf=$$cf \
+       ; sleep 1;                       $(MAKE) cf-build cf=$$cf \
+       | sed -e "s|^|$$cf: |" | tee -a cf.log ; done
 cf-check-all:
-       @ for cf in $(cf_all) ; do echo $(MAKE) cf-check cf=$$cf \
-       ; sleep 1;                      $(MAKE) cf-check cf=$$cf ; done
+       echo $@: `date` "====================" >> cf.log
+       @ for cf in $($(list)) ; do echo $(MAKE) cf-check cf=$$cf \
+       ; sleep 1;                       $(MAKE) cf-check cf=$$cf \
+       | sed -e "s|^|$$cf: |" | tee -a cf.log ; done
 cf-system-all:
-       @ for cf in $(cf_all) ; do echo $(MAKE) cf-configure cf=$$cf \
-       ; sleep 1 ;                     $(MAKE) cf-system cf=$$cf ; done
+       echo $@: `date` "====================" >> cf.log
+       @ for cf in $($(list)) ; do echo $(MAKE) cf-configure cf=$$cf \
+       ; sleep 1 ;                      $(MAKE) cf-system cf=$$cf \
+       | sed -e "s|^|$$cf: |" | tee -a cf.log ; done
index 7bbad54f18402eae313cede4057cc7e51f446787..7061971b45fffdec3c6454fcee7d84ae23200883 100644 (file)
@@ -51,6 +51,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_compile_check_sizeof.m4 \
        $(top_srcdir)/m4/ax_cflags_no_writable_strings.m4 \
        $(top_srcdir)/m4/ax_cflags_strict_prototypes.m4 \
        $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+       $(top_srcdir)/m4/ax_check_aligned_access_required.m4 \
        $(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
        $(top_srcdir)/m4/ax_enable_builddir_uname.m4 \
        $(top_srcdir)/m4/ax_expand_prefix.m4 \
index 39b8e7d8b68ded6f05bd39a8be6adb5f234a13b8..f7306de2bbc77f8d10f5a96744d1654c450f3dd5 100644 (file)
@@ -7262,6 +7262,7 @@ m4_include([m4/ax_cflags_gcc_option.m4])
 m4_include([m4/ax_cflags_no_writable_strings.m4])
 m4_include([m4/ax_cflags_strict_prototypes.m4])
 m4_include([m4/ax_cflags_warn_all.m4])
+m4_include([m4/ax_check_aligned_access_required.m4])
 m4_include([m4/ax_create_pkgconfig_info.m4])
 m4_include([m4/ax_enable_builddir_uname.m4])
 m4_include([m4/ax_expand_prefix.m4])
index 42380ca40b70d59bc61cdcaa62d87f5694159734..3e2e10688e37fa73c010b3fc25b761a610f83a3c 100644 (file)
@@ -56,6 +56,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_compile_check_sizeof.m4 \
        $(top_srcdir)/m4/ax_cflags_no_writable_strings.m4 \
        $(top_srcdir)/m4/ax_cflags_strict_prototypes.m4 \
        $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+       $(top_srcdir)/m4/ax_check_aligned_access_required.m4 \
        $(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
        $(top_srcdir)/m4/ax_enable_builddir_uname.m4 \
        $(top_srcdir)/m4/ax_expand_prefix.m4 \
index ef1f9971edce5cc982a10a539bfde4b4331afa0e..b242e09405c6a9051fc44521d9dea24b32e56b34 100644 (file)
@@ -1,5 +1,8 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Define if pointers to integers require aligned access */
+#undef HAVE_ALIGNED_ACCESS_REQUIRED
+
 /* Define to 1 if you have the <byteswap.h> header file. */
 #undef HAVE_BYTESWAP_H
 
index a31235f4abfc2edf3cdd87ce21b0fca646ba17d4..72171626eb4149a72dbd6d3a2a1ec4a8882137d5 100755 (executable)
--- a/configure
+++ b/configure
@@ -22113,6 +22113,74 @@ presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
    { (exit 1); exit 1; }; } ;;
 esac
 
+echo "$as_me:$LINENO: checking if pointers to integers require aligned access" >&5
+echo $ECHO_N "checking if pointers to integers require aligned access... $ECHO_C" >&6
+if test "${ax_cv_have_aligned_access_required+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  ax_cv_have_aligned_access_required=no
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+  char* string = malloc(40);
+  int i;
+  for (i=0; i < 40; i++) string[[i]] = i;
+  {
+     void* s = string;
+     int* p = s+1;
+     int* q = s+2;
+
+     if (*p == *q) { return 1; }
+  }
+  return 0;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ax_cv_have_aligned_access_required=yes
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ax_cv_have_aligned_access_required=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+fi
+echo "$as_me:$LINENO: result: $ax_cv_have_aligned_access_required" >&5
+echo "${ECHO_T}$ax_cv_have_aligned_access_required" >&6
+if test "$ax_cv_have_aligned_access_required" = yes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ALIGNED_ACCESS_REQUIRED 1
+_ACEOF
+
+fi
+
 # the default is _disabled_!! anyway, result is prefixed in zzip/_config.h!!
 # Check whether --enable-largefile or --disable-largefile was given.
 if test "${enable_largefile+set}" = set; then
index fc0c7ff9bbf54cc61dc6f4d2728d24706fca5ee4..65bc3bf9efb20ef530d46f7183e3ac14b030c687 100644 (file)
@@ -1,7 +1,7 @@
 AC_INIT(zziplib.spec)
 AC_PREREQ(2.49)
 AC_COPYRIGHT([Guido Draheim <guido@gmx.de> for ZZipLib.SF.net])
-AC_REVISION($Revision: 1.6 $)
+AC_REVISION($Revision: 1.7 $)
 AC_CONFIG_AUX_DIR(uses)
 # =======================================================================
 AC_CANONICAL_SYSTEM
@@ -109,6 +109,7 @@ AC_COMPILE_CHECK_SIZEOF(short)
 AC_COMPILE_CHECK_SIZEOF(int)
 AC_COMPILE_CHECK_SIZEOF(long)
 AC_C_BIGENDIAN
+AX_CHECK_ALIGNED_ACCESS_REQUIRED
 dnl -------------------------------------------------------------
 # the default is _disabled_!! anyway, result is prefixed in zzip/_config.h!!
 AC_SYS_LARGEFILE_SENSITIVE
index 889fffd6ff25ca6af189111539d868d5eb3f6320..8aedfb0cf6b70923d914eb608e915dae5e0aba94 100644 (file)
@@ -47,6 +47,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_compile_check_sizeof.m4 \
        $(top_srcdir)/m4/ax_cflags_no_writable_strings.m4 \
        $(top_srcdir)/m4/ax_cflags_strict_prototypes.m4 \
        $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+       $(top_srcdir)/m4/ax_check_aligned_access_required.m4 \
        $(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
        $(top_srcdir)/m4/ax_enable_builddir_uname.m4 \
        $(top_srcdir)/m4/ax_expand_prefix.m4 \
diff --git a/m4/ax_check_aligned_access_required.m4 b/m4/ax_check_aligned_access_required.m4
new file mode 100644 (file)
index 0000000..18b4056
--- /dev/null
@@ -0,0 +1,49 @@
+dnl @synopsis AC_CHECK_ALIGNED_ACCESS_REQUIRED
+dnl
+dnl While the x86 CPUs allow access to memory objects to be unaligned
+dnl it happens that most of the modern designs require objects to be
+dnl aligned - or they will fail with a buserror. That mode is quite known
+dnl by big-endian machines (sparc, etc) however the alpha cpu is little-
+dnl endian.
+dnl
+dnl The following function will test for aligned access to be required and
+dnl set a config.h define HAVE_ALIGNED_ACCESS_REQUIRED (name derived by
+dnl standard usage). Structures loaded from a file (or mmapped to memory)
+dnl should be accessed per-byte in that case to avoid segfault type errors.
+dnl
+dnl @category C
+dnl @author Guido U. Draheim <guidod@gmx.de>
+dnl @version 2006-08-17
+dnl @license GPLWithACException
+
+AC_DEFUN([AX_CHECK_ALIGNED_ACCESS_REQUIRED],
+[AC_CACHE_CHECK([if pointers to integers require aligned access],
+  [ax_cv_have_aligned_access_required],
+  [AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+
+int main()
+{
+  char* string = malloc(40);
+  int i;
+  for (i=0; i < 40; i++) string[[i]] = i;
+  {
+     void* s = string;
+     int* p = s+1;
+     int* q = s+2;
+
+     if (*p == *q) { return 1; }
+  }
+  return 0;
+}
+              ],
+     [ax_cv_have_aligned_access_required=yes],
+     [ax_cv_have_aligned_access_required=no],
+     [ax_cv_have_aligned_access_required=no])
+  ])
+if test "$ax_cv_have_aligned_access_required" = yes ; then
+  AC_DEFINE([HAVE_ALIGNED_ACCESS_REQUIRED], [1],
+    [Define if pointers to integers require aligned access])
+fi
+])
index 996f9dfbbd4a736d01cf9c10496e18ae287c5796..193ccca3a4e04e588d6993bb06b8b54e7054ae89 100644 (file)
@@ -49,6 +49,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_compile_check_sizeof.m4 \
        $(top_srcdir)/m4/ax_cflags_no_writable_strings.m4 \
        $(top_srcdir)/m4/ax_cflags_strict_prototypes.m4 \
        $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+       $(top_srcdir)/m4/ax_check_aligned_access_required.m4 \
        $(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
        $(top_srcdir)/m4/ax_enable_builddir_uname.m4 \
        $(top_srcdir)/m4/ax_expand_prefix.m4 \
index 695af34ae045d823bae02daa40b3a750eabd4f75..9475e5abd7b237e82580af38c123f50461d7e51b 100644 (file)
@@ -50,6 +50,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_compile_check_sizeof.m4 \
        $(top_srcdir)/m4/ax_cflags_no_writable_strings.m4 \
        $(top_srcdir)/m4/ax_cflags_strict_prototypes.m4 \
        $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+       $(top_srcdir)/m4/ax_check_aligned_access_required.m4 \
        $(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
        $(top_srcdir)/m4/ax_enable_builddir_uname.m4 \
        $(top_srcdir)/m4/ax_expand_prefix.m4 \
index e406c1b1ed6847cd527e9db90b8f7d3cdd8b53ad..6b84ff1739c130af05c7c74186069906969d831f 100644 (file)
@@ -120,4 +120,5 @@ struct zzip_entry /* : struct zzip_disk_entry */
 extern "C" {
 }
 #endif
+#endif
 
index 92d06fb1e8483d4ee6b2e814c92ef9db11b32cae..f33804c7f5af0b50194c700b1716a76975b3d70d 100644 (file)
@@ -52,6 +52,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ac_compile_check_sizeof.m4 \
        $(top_srcdir)/m4/ax_cflags_no_writable_strings.m4 \
        $(top_srcdir)/m4/ax_cflags_strict_prototypes.m4 \
        $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+       $(top_srcdir)/m4/ax_check_aligned_access_required.m4 \
        $(top_srcdir)/m4/ax_create_pkgconfig_info.m4 \
        $(top_srcdir)/m4/ax_enable_builddir_uname.m4 \
        $(top_srcdir)/m4/ax_expand_prefix.m4 \