From: Theodore Ts'o Date: Sat, 7 Jun 2008 12:55:21 +0000 (-0400) Subject: Fix ext2fs_swap{16,32,64} for external applications on big-endian machines X-Git-Tag: v1.40.11~6 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=488c75a6a62acb07b82bcfab327d30eb5ea54703;p=tools%2Fe2fsprogs.git Fix ext2fs_swap{16,32,64} for external applications on big-endian machines The public header files depend on the the autoconf defines WORDS_BIGENDIAN and HAVE_SYS_TYPES_H, so we add them to ext2_types.h so that external programs which try to use ext2fs_swap*() will work correctly on big-endian systems. Fortunately, few if any programs need to use this libext2's byte-swap functions directly. Addresses-Debian-Bug: #484879 Signed-off-by: "Theodore Ts'o" --- diff --git a/configure b/configure index 635a94f..bdef3cc 100755 --- a/configure +++ b/configure @@ -779,7 +779,8 @@ MAKEFILE_BSDLIB MAKEFILE_PROFILE MAKEFILE_CHECKER MAKEFILE_LIBRARY -ASM_TYPES_HEADER' +ASM_TYPES_HEADER +PUBLIC_CONFIG_HEADER' ac_precious_vars='build_alias host_alias target_alias @@ -14443,6 +14444,21 @@ esac BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh ASM_TYPES_HEADER=./asm_types.h +echo "/* These defines are needed for the public ext2fs.h header file */" \ + > public_config.h +if grep HAVE_SYS_TYPES_H confdefs.h > tmp_config.$$; then + uniq tmp_config.$$ >> public_config.h +else + echo "#undef HAVE_SYS_TYPES_H" >> public_config.h +fi +if grep WORDS_BIGENDIAN confdefs.h > tmp_config.$$; then + uniq tmp_config.$$ >> public_config.h +else + echo "#undef WORDS_BIGENDIAN" >> public_config.h +fi +rm -f tmp_config.$$ +PUBLIC_CONFIG_HEADER=./public_config.h + for ac_header in inttypes.h do @@ -16081,12 +16097,9 @@ STATIC_LIB_EXT!$STATIC_LIB_EXT$ac_delim PROFILED_LIB_EXT!$PROFILED_LIB_EXT$ac_delim SWAPFS_CMT!$SWAPFS_CMT$ac_delim DEBUGFS_CMT!$DEBUGFS_CMT$ac_delim -IMAGER_CMT!$IMAGER_CMT$ac_delim -RESIZER_CMT!$RESIZER_CMT$ac_delim -FSCK_PROG!$FSCK_PROG$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 76; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 73; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -16134,6 +16147,10 @@ d r $ASM_TYPES_HEADER d } +/^[ ]*@PUBLIC_CONFIG_HEADER@[ ]*$/{ +r $PUBLIC_CONFIG_HEADER +d +} _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g @@ -16153,6 +16170,9 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +IMAGER_CMT!$IMAGER_CMT$ac_delim +RESIZER_CMT!$RESIZER_CMT$ac_delim +FSCK_PROG!$FSCK_PROG$ac_delim FSCK_MAN!$FSCK_MAN$ac_delim E2INITRD_PROG!$E2INITRD_PROG$ac_delim E2INITRD_MAN!$E2INITRD_MAN$ac_delim @@ -16239,7 +16259,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 84; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 87; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.in b/configure.in index 0c97af5..5f91d4a 100644 --- a/configure.in +++ b/configure.in @@ -700,6 +700,25 @@ BUILD_CC="$BUILD_CC" CPP="$CPP" /bin/sh $ac_aux_dir/parse-types.sh ASM_TYPES_HEADER=./asm_types.h AC_SUBST_FILE(ASM_TYPES_HEADER) dnl +dnl Save the configuration #defines needed for the public ext2fs.h +dnl header file +dnl +echo "/* These defines are needed for the public ext2fs.h header file */" \ + > public_config.h +if grep HAVE_SYS_TYPES_H confdefs.h > tmp_config.$$; then + uniq tmp_config.$$ >> public_config.h +else + echo "#undef HAVE_SYS_TYPES_H" >> public_config.h +fi +if grep WORDS_BIGENDIAN confdefs.h > tmp_config.$$; then + uniq tmp_config.$$ >> public_config.h +else + echo "#undef WORDS_BIGENDIAN" >> public_config.h +fi +rm -f tmp_config.$$ +PUBLIC_CONFIG_HEADER=./public_config.h +AC_SUBST_FILE(PUBLIC_CONFIG_HEADER) +dnl dnl See if we have inttypes.h and if intptr_t is defined dnl AC_CHECK_HEADERS([inttypes.h]) diff --git a/lib/ext2fs/ext2_types.h.in b/lib/ext2fs/ext2_types.h.in index 899476b..aa7ca3a 100644 --- a/lib/ext2fs/ext2_types.h.in +++ b/lib/ext2fs/ext2_types.h.in @@ -132,3 +132,5 @@ typedef signed long long __s64; #undef __U64_TYPEDEF #endif /* _*_TYPES_H */ + +@PUBLIC_CONFIG_HEADER@