summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2006-04-09 08:41:55 -0400
committerTheodore Ts'o <tytso@mit.edu>2006-04-09 08:41:55 -0400
commit4ea7ea007bb227727ee1d4dca997c4f5b21d3a30 (patch)
treea984da943ed78f0b99fa22834495255619f8a61e
parentcef2ac104d45c351344cd10ac1419ad5f6422d8b (diff)
downloade2fsprogs-4ea7ea007bb227727ee1d4dca997c4f5b21d3a30.tar.gz
Fix asm_types.h type conflicts
This caused FTBFS bugs on AMD64 platforms, since it uses a different 64-bit type when compared with IA64, so we need to make our autoconfiguration system more intelligent. Addresses Debian Bugs: #360661, #360317 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--ChangeLog8
-rw-r--r--Makefile.in25
-rwxr-xr-xconfig/parse-types.sh112
-rwxr-xr-xconfigure10
-rw-r--r--configure.in6
-rw-r--r--lib/blkid/ChangeLog6
-rw-r--r--lib/blkid/Makefile.in7
-rw-r--r--lib/blkid/blkid_types.h.in113
-rw-r--r--lib/blkid/tst_types.c59
-rw-r--r--lib/ext2fs/ChangeLog6
-rw-r--r--lib/ext2fs/Makefile.in7
-rw-r--r--lib/ext2fs/ext2_types.h.in113
-rw-r--r--lib/ext2fs/tst_types.c59
13 files changed, 472 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index c917640d..6a7f8380 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-04-09 Theodore Ts'o <tytso@mit.edu>
+
+ * configure.in, Makefile.in, config/parse-types.sh: Make the
+ ext2_types.h.in and blkid_types.h.in from config.sys,
+ instead of using the subst program. Create the
+ asm_types.h file from the system's
+ /usr/include/asm/types.h header file.
+
2006-03-23 Theodore Ts'o <tytso@mit.edu>
* MCONFIG.in (mandir): Define $(man5dir)
diff --git a/Makefile.in b/Makefile.in
index abbd5a84..88d6c3ad 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -100,20 +100,17 @@ realclean: realclean-recursive realclean-local
depend:: depend-recursive
-lib/ext2fs/ext2_types.h: $(DEP_SUBSTITUTE) $(srcdir)/lib/ext2fs/ext2_types.h.in
- @echo " SUBST $@"
- @$(SUBSTITUTE) $(srcdir)/lib/ext2fs/ext2_types.h.in \
- > lib/ext2fs/ext2_types.h
-
-lib/blkid/blkid_types.h: $(DEP_SUBSTITUTE) $(srcdir)/lib/blkid/blkid_types.h.in
- @echo " SUBST $@"
- @$(SUBSTITUTE) $(srcdir)/lib/blkid/blkid_types.h.in \
- > lib/blkid/blkid_types.h
-
-lib/uuid/uuid_types.h: $(DEP_SUBSTITUTE) $(srcdir)/lib/uuid/uuid_types.h.in
- @echo " SUBST $@"
- @$(SUBSTITUTE) $(srcdir)/lib/uuid/uuid_types.h.in \
- > lib/uuid/uuid_types.h
+lib/ext2fs/ext2_types.h: $(DEP_SUBSTITUTE) asm_types.h \
+ $(srcdir)/lib/ext2fs/ext2_types.h.in
+ cd $(top_builddir); CONFIG_FILES=./lib/ext2fs/ext2_types.h ./config.status
+
+lib/blkid/blkid_types.h: $(DEP_SUBSTITUTE) asm_types.h \
+ $(srcdir)/lib/blkid/blkid_types.h.in
+ cd $(top_builddir); CONFIG_FILES=./lib/blkid/blkid_types.h ./config.status
+
+lib/uuid/uuid_types.h: $(DEP_SUBSTITUTE) asm_types.h \
+ $(srcdir)/lib/uuid/uuid_types.h.in
+ cd $(top_builddir); CONFIG_FILES=./lib/uuid/uuid_types.h ./config.status
mostlyclean-local:
$(RM) -f \#* *~ *.orig core MAKELOG
diff --git a/config/parse-types.sh b/config/parse-types.sh
new file mode 100755
index 00000000..f4014ea3
--- /dev/null
+++ b/config/parse-types.sh
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+ASM_TYPES=/usr/include/asm/types.h
+
+if test ! -f $ASM_TYPES
+then
+ echo "" > asm_types.h
+ echo "No asm_types file found"
+ exit 1
+fi
+
+cat > /tmp/sed.script << "EOF"
+/^#/d
+/^$/d
+s/__extension__ //
+s/typedef \(.*\) __u\([1-9]*\);/#define __U\2_TYPEDEF \1/
+s/typedef \(.*\) __s\([1-9]*\);/#define __S\2_TYPEDEF \1/
+EOF
+
+gcc -E $ASM_TYPES | sed -f /tmp/sed.script | grep ^# > asm_types.h
+
+cp asm_types.h asm_types.c
+
+cat >> asm_types.c <<EOF
+main(int argc, char **argv)
+{
+#ifdef __U8_TYPEDEF
+ if (sizeof(__U8_TYPEDEF) != 1) {
+ printf("Sizeof(__U8__TYPEDEF) is %d should be 1\n",
+ sizeof(__U8_TYPEDEF));
+ exit(1);
+ }
+#else
+#warning __U8_TYPEDEF not defined
+#endif
+#ifdef __S8_TYPEDEF
+ if (sizeof(__S8_TYPEDEF) != 1) {
+ printf("Sizeof(_S8__TYPEDEF) is %d should be 1\n",
+ sizeof(__S8_TYPEDEF));
+ exit(1);
+ }
+#else
+#warning __S8_TYPEDEF not defined
+#endif
+#ifdef __U16_TYPEDEF
+ if (sizeof(__U16_TYPEDEF) != 2) {
+ printf("Sizeof(__U16__TYPEDEF) is %d should be 2\n",
+ sizeof(__U16_TYPEDEF));
+ exit(1);
+ }
+#else
+#warning __U16_TYPEDEF not defined
+#endif
+#ifdef __S16_TYPEDEF
+ if (sizeof(__S16_TYPEDEF) != 2) {
+ printf("Sizeof(__S16__TYPEDEF) is %d should be 2\n",
+ sizeof(__S16_TYPEDEF));
+ exit(1);
+ }
+#else
+#warning __S16_TYPEDEF not defined
+#endif
+
+#ifdef __U32_TYPEDEF
+ if (sizeof(__U32_TYPEDEF) != 4) {
+ printf("Sizeof(__U32__TYPEDEF) is %d should be 4\n",
+ sizeof(__U32_TYPEDEF));
+ exit(1);
+ }
+#else
+#warning __U32_TYPEDEF not defined
+#endif
+#ifdef __S32_TYPEDEF
+ if (sizeof(__S32_TYPEDEF) != 4) {
+ printf("Sizeof(__S32__TYPEDEF) is %d should be 4\n",
+ sizeof(__S32_TYPEDEF));
+ exit(1);
+ }
+#else
+#warning __S32_TYPEDEF not defined
+#endif
+
+#ifdef __U64_TYPEDEF
+ if (sizeof(__U64_TYPEDEF) != 8) {
+ printf("Sizeof(__U64__TYPEDEF) is %d should be 8\n",
+ sizeof(__U64_TYPEDEF));
+ exit(1);
+ }
+#else
+#warning __U64_TYPEDEF not defined
+#endif
+#ifdef __S64_TYPEDEF
+ if (sizeof(__S64_TYPEDEF) != 8) {
+ printf("Sizeof(__S64__TYPEDEF) is %d should be 8\n",
+ sizeof(__S64_TYPEDEF));
+ exit(1);
+ }
+#else
+#warning __S64_TYPEDEF not defined
+#endif
+ exit(0);
+}
+EOF
+
+cc -o asm_types asm_types.c
+if ! ./asm_types
+then
+ echo "Problem detected with asm_types.h"
+ echo "" > asm_types.h
+fi
+rm asm_types.c asm_types
+
diff --git a/configure b/configure
index 26517459..ac0f05ec 100755
--- a/configure
+++ b/configure
@@ -310,7 +310,7 @@ ac_includes_default="\
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS E2FSPROGS_YEAR E2FSPROGS_MONTH E2FSPROGS_DAY E2FSPROGS_VERSION build build_cpu build_vendor build_os host host_cpu host_vendor host_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT LD CPP EGREP LINUX_INCLUDE MAINTAINER_CMT HTREE_CMT ELF_CMT BSDLIB_CMT PROFILE_CMT CHECKER_CMT LIB_EXT STATIC_LIB_EXT PROFILED_LIB_EXT SWAPFS_CMT DEBUGFS_CMT IMAGER_CMT RESIZER_CMT E2FSCK_TYPE FSCK_PROG FSCK_MAN E2INITRD_PROG E2INITRD_MAN DEVMAPPER_REQ DEVMAPPER_PC_LIBS DEVMAPPER_LIBS STATIC_DEVMAPPER_LIBS GETTEXT_PACKAGE PACKAGE VERSION SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA MKINSTALLDIRS USE_NLS MSGFMT GMSGFMT XGETTEXT MSGMERGE RANLIB ac_ct_RANLIB ALLOCA GLIBC21 HAVE_POSIX_PRINTF HAVE_ASPRINTF HAVE_SNPRINTF HAVE_WPRINTF LIBICONV LTLIBICONV INTLBISON BUILD_INCLUDED_LIBINTL USE_INCLUDED_LIBINTL CATOBJEXT DATADIRNAME INSTOBJEXT GENCAT INTLOBJS INTL_LIBTOOL_SUFFIX_PREFIX INTLLIBS LIBINTL LTLIBINTL POSUB BINARY_TYPE LN LN_S MV CP RM CHMOD AWK SED PERL LDCONFIG AR ac_ct_AR STRIP ac_ct_STRIP BUILD_CC SIZEOF_SHORT SIZEOF_INT SIZEOF_LONG SIZEOF_LONG_LONG SOCKET_LIB DLOPEN_LIB LINUX_CMT CYGWIN_CMT UNIX_CMT root_prefix root_bindir root_sbindir root_libdir root_sysconfdir LDFLAG_STATIC SS_DIR ET_DIR DO_TEST_SUITE INTL_FLAGS BUILD_CFLAGS BUILD_LDFLAGS LIBOBJS LTLIBOBJS'
-ac_subst_files='MCONFIG MAKEFILE_ELF MAKEFILE_BSDLIB MAKEFILE_PROFILE MAKEFILE_CHECKER MAKEFILE_LIBRARY'
+ac_subst_files='MCONFIG MAKEFILE_ELF MAKEFILE_BSDLIB MAKEFILE_PROFILE MAKEFILE_CHECKER MAKEFILE_LIBRARY ASM_TYPES_HEADER'
# Initialize some variables set by options.
ac_init_help=
@@ -13392,6 +13392,9 @@ presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
+/bin/sh $ac_aux_dir/parse-types.sh
+ASM_TYPES_HEADER=./asm_types.h
+
for ac_header in inttypes.h
do
@@ -14294,7 +14297,8 @@ test -d include/linux || mkdir include/linux
test -d include/asm || mkdir include/asm
for i in MCONFIG Makefile e2fsprogs.spec \
util/Makefile util/subst.conf util/gen-tarball \
- lib/et/Makefile lib/ss/Makefile lib/ext2fs/Makefile lib/e2p/Makefile \
+ lib/et/Makefile lib/ss/Makefile lib/e2p/Makefile \
+ lib/ext2fs/Makefile lib/ext2fs/ext2_types.h \
lib/uuid/Makefile lib/uuid/uuid_types.h \
lib/blkid/Makefile lib/blkid/blkid_types.h \
lib/ss/ss.pc lib/uuid/uuid.pc lib/et/com_err.pc \
@@ -15092,6 +15096,8 @@ s,@MAKEFILE_PROFILE@,,;t t
s,@MAKEFILE_CHECKER@,,;t t
/@MAKEFILE_LIBRARY@/r $MAKEFILE_LIBRARY
s,@MAKEFILE_LIBRARY@,,;t t
+/@ASM_TYPES_HEADER@/r $ASM_TYPES_HEADER
+s,@ASM_TYPES_HEADER@,,;t t
CEOF
_ACEOF
diff --git a/configure.in b/configure.in
index 744301c9..d26ca695 100644
--- a/configure.in
+++ b/configure.in
@@ -620,6 +620,9 @@ AC_SUBST(SIZEOF_INT)
AC_SUBST(SIZEOF_LONG)
AC_SUBST(SIZEOF_LONG_LONG)
AC_C_BIGENDIAN
+/bin/sh $ac_aux_dir/parse-types.sh
+ASM_TYPES_HEADER=./asm_types.h
+AC_SUBST_FILE(ASM_TYPES_HEADER)
dnl
dnl See if we have inttypes.h and if intptr_t is defined
dnl
@@ -840,7 +843,8 @@ test -d include/linux || mkdir include/linux
test -d include/asm || mkdir include/asm
for i in MCONFIG Makefile e2fsprogs.spec \
util/Makefile util/subst.conf util/gen-tarball \
- lib/et/Makefile lib/ss/Makefile lib/ext2fs/Makefile lib/e2p/Makefile \
+ lib/et/Makefile lib/ss/Makefile lib/e2p/Makefile \
+ lib/ext2fs/Makefile lib/ext2fs/ext2_types.h \
lib/uuid/Makefile lib/uuid/uuid_types.h \
lib/blkid/Makefile lib/blkid/blkid_types.h \
lib/ss/ss.pc lib/uuid/uuid.pc lib/et/com_err.pc \
diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog
index 8b4eea01..98542de9 100644
--- a/lib/blkid/ChangeLog
+++ b/lib/blkid/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-09 Theodore Ts'o <tytso@mit.edu>
+
+ * blkid_types.h.in, Makefile.in, tst_types.c: Use the asm_types.h
+ file to define the __[us]{8,16,32,64} types. Add a
+ tst_types program to make sure the types are correct.
+
2006-03-23 Theodore Ts'o <tytso@mit.edu>
* probe.c (blkid_verify): Fix file descriptor leak on error.
diff --git a/lib/blkid/Makefile.in b/lib/blkid/Makefile.in
index 046f182e..07b72ac1 100644
--- a/lib/blkid/Makefile.in
+++ b/lib/blkid/Makefile.in
@@ -112,6 +112,10 @@ tst_tag: $(srcdir)/tag.c $(DEPLIBS_BLKID)
@echo " LD $@"
@$(CC) -o tst_tag -DTEST_PROGRAM $(srcdir)/tag.c $(LIBS_BLKID) $(ALL_CFLAGS)
+tst_types: tst_types.o blkid_types.h
+ @echo " LD $@"
+ @$(CC) -o tst_types tst_types.o
+
../../misc/blkid.o: $(top_srcdir)/misc/blkid.c blkid.h
@echo " CC $@"
@$(CC) $(ALL_CFLAGS) -c $(top_srcdir)/misc/blkid.c \
@@ -129,8 +133,9 @@ test_probe: test_probe.in Makefile
@chmod +x test_probe
check:: all tst_cache tst_dev tst_devname tst_devno tst_getsize tst_probe \
- tst_read tst_resolve tst_save tst_tag test_probe
+ tst_read tst_resolve tst_save tst_tag test_probe tst_types
./test_probe
+ ./tst_types
blkid.pc: $(srcdir)/blkid.pc.in $(top_builddir)/config.status
@echo " CONFIG.STATUS $@"
diff --git a/lib/blkid/blkid_types.h.in b/lib/blkid/blkid_types.h.in
index 0fde69fa..cb5b10d5 100644
--- a/lib/blkid/blkid_types.h.in
+++ b/lib/blkid/blkid_types.h.in
@@ -7,55 +7,128 @@
!defined(_EXT2_TYPES_H))
#define _BLKID_TYPES_H
+@ASM_TYPES_HEADER@
+
+#ifdef __U8_TYPEDEF
+typedef __U8_TYPEDEF __u8;
+#else
typedef unsigned char __u8;
+#endif
+
+#ifdef __S8_TYPEDEF
+typedef __S8_TYPEDEF __s8;
+#else
typedef signed char __s8;
+#endif
-#if (@SIZEOF_INT@ == 8)
-typedef int __s64;
-typedef unsigned int __u64;
+#ifdef __U16_TYPEDEF
+typedef __U16_TYPEDEF __u16;
#else
-#if (@SIZEOF_LONG@ == 8)
-typedef long __s64;
-typedef unsigned long __u64;
+#if (@SIZEOF_INT@ == 2)
+typedef unsigned int __u16;
#else
-#if (@SIZEOF_LONG_LONG@ == 8)
-#if defined(__GNUC__)
-typedef __signed__ long long __s64;
+#if (@SIZEOF_SHORT@ == 2)
+typedef unsigned short __u16;
#else
-typedef signed long long __s64;
-#endif /* __GNUC__ */
-typedef unsigned long long __u64;
-#endif /* SIZEOF_LONG_LONG == 8 */
-#endif /* SIZEOF_LONG == 8 */
-#endif /* SIZEOF_INT == 8 */
+ ?==error: undefined 16 bit type
+#endif /* SIZEOF_SHORT == 2 */
+#endif /* SIZEOF_INT == 2 */
+#endif /* __U16_TYPEDEF */
+#ifdef __S16_TYPEDEF
+typedef __S16_TYPEDEF __s16;
+#else
#if (@SIZEOF_INT@ == 2)
typedef int __s16;
-typedef unsigned int __u16;
#else
#if (@SIZEOF_SHORT@ == 2)
typedef short __s16;
-typedef unsigned short __u16;
#else
?==error: undefined 16 bit type
#endif /* SIZEOF_SHORT == 2 */
#endif /* SIZEOF_INT == 2 */
+#endif /* __S16_TYPEDEF */
+
+#ifdef __U32_TYPEDEF
+typedef __U32_TYPEDEF __u32;
+#else
#if (@SIZEOF_INT@ == 4)
-typedef int __s32;
typedef unsigned int __u32;
#else
#if (@SIZEOF_LONG@ == 4)
-typedef long __s32;
typedef unsigned long __u32;
#else
#if (@SIZEOF_SHORT@ == 4)
-typedef short __s32;
typedef unsigned short __u32;
#else
?== error: undefined 32 bit type
#endif /* SIZEOF_SHORT == 4 */
#endif /* SIZEOF_LONG == 4 */
#endif /* SIZEOF_INT == 4 */
+#endif /* __U32_TYPEDEF */
+
+#ifdef __S32_TYPEDEF
+typedef __S32_TYPEDEF __s32;
+#else
+#if (@SIZEOF_INT@ == 4)
+typedef int __s32;
+#else
+#if (@SIZEOF_LONG@ == 4)
+typedef long __s32;
+#else
+#if (@SIZEOF_SHORT@ == 4)
+typedef short __s32;
+#else
+ ?== error: undefined 32 bit type
+#endif /* SIZEOF_SHORT == 4 */
+#endif /* SIZEOF_LONG == 4 */
+#endif /* SIZEOF_INT == 4 */
+#endif /* __S32_TYPEDEF */
+
+#ifdef __U64_TYPEDEF
+typedef __U64_TYPEDEF __u64;
+#else
+#if (@SIZEOF_INT@ == 8)
+typedef unsigned int __u64;
+#else
+#if (@SIZEOF_LONG@ == 8)
+typedef unsigned long __u64;
+#else
+#if (@SIZEOF_LONG_LONG@ == 8)
+typedef unsigned long long __u64;
+#endif /* SIZEOF_LONG_LONG == 8 */
+#endif /* SIZEOF_LONG == 8 */
+#endif /* SIZEOF_INT == 8 */
+#endif /* __U64_TYPEDEF */
+
+#ifdef __S64_TYPEDEF
+typedef __S64_TYPEDEF __s64;
+#else
+#if (@SIZEOF_INT@ == 8)
+typedef int __s64;
+#else
+#if (@SIZEOF_LONG@ == 8)
+typedef long __s64;
+#else
+#if (@SIZEOF_LONG_LONG@ == 8)
+#if defined(__GNUC__)
+typedef __signed__ long long __s64;
+#else
+typedef signed long long __s64;
+#endif /* __GNUC__ */
+#endif /* SIZEOF_LONG_LONG == 8 */
+#endif /* SIZEOF_LONG == 8 */
+#endif /* SIZEOF_INT == 8 */
+#endif /* __S64_TYPEDEF */
+
+#undef __S8_TYPEDEF
+#undef __U8_TYPEDEF
+#undef __S16_TYPEDEF
+#undef __U16_TYPEDEF
+#undef __S32_TYPEDEF
+#undef __U32_TYPEDEF
+#undef __S64_TYPEDEF
+#undef __U64_TYPEDEF
#endif /* _*_TYPES_H */
diff --git a/lib/blkid/tst_types.c b/lib/blkid/tst_types.c
new file mode 100644
index 00000000..53cfc816
--- /dev/null
+++ b/lib/blkid/tst_types.c
@@ -0,0 +1,59 @@
+/*
+ * This testing program makes sure the blkid_types header file
+ *
+ * Copyright (C) 2006 by Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#include "blkid/blkid_types.h"
+
+main(int argc, char **argv)
+{
+ if (sizeof(__u8) != 1) {
+ printf("Sizeof(__u8) is %d should be 1\n",
+ sizeof(__u8));
+ exit(1);
+ }
+ if (sizeof(__s8) != 1) {
+ printf("Sizeof(_s8) is %d should be 1\n",
+ sizeof(__s8));
+ exit(1);
+ }
+ if (sizeof(__u16) != 2) {
+ printf("Sizeof(__u16) is %d should be 2\n",
+ sizeof(__u16));
+ exit(1);
+ }
+ if (sizeof(__s16) != 2) {
+ printf("Sizeof(__s16) is %d should be 2\n",
+ sizeof(__s16));
+ exit(1);
+ }
+ if (sizeof(__u32) != 4) {
+ printf("Sizeof(__u32) is %d should be 4\n",
+ sizeof(__u32));
+ exit(1);
+ }
+ if (sizeof(__s32) != 4) {
+ printf("Sizeof(__s32) is %d should be 4\n",
+ sizeof(__s32));
+ exit(1);
+ }
+ if (sizeof(__u64) != 8) {
+ printf("Sizeof(__u64) is %d should be 8\n",
+ sizeof(__u64));
+ exit(1);
+ }
+ if (sizeof(__s64) != 8) {
+ printf("Sizeof(__s64) is %d should be 8\n",
+ sizeof(__s64));
+ exit(1);
+ }
+ printf("The blkid_types.h types are correct.\n");
+ exit(0);
+}
+
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index ff579b77..87bb4ccb 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-09 Theodore Ts'o <tytso@mit.edu>
+
+ * ext2_types.h.in, Makefile.in, tst_types.c: Use the asm_types.h
+ file to define the __[us]{8,16,32,64} types. Add a
+ tst_types program to make sure the types are correct.
+
2006-04-04 Theodore Ts'o <tytso@mit.edu>
* mkjournal.c (ext2fs_add_journal_inode): If the filesystem is
diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in
index b86c2134..280b6145 100644
--- a/lib/ext2fs/Makefile.in
+++ b/lib/ext2fs/Makefile.in
@@ -220,15 +220,20 @@ tst_getsectsize: tst_getsectsize.o getsectsize.o $(STATIC_LIBEXT2FS)
@$(CC) -o tst_sectgetsize tst_getsectsize.o getsectsize.o \
$(STATIC_LIBEXT2FS) $(LIBCOM_ERR)
+tst_types: tst_types.o ext2_types.h
+ @echo " LD $@"
+ @$(CC) -o tst_types tst_types.o
+
mkjournal: mkjournal.c $(STATIC_LIBEXT2FS)
@echo " LD $@"
@$(CC) -o mkjournal $(srcdir)/mkjournal.c -DDEBUG $(STATIC_LIBEXT2FS) $(LIBCOM_ERR) $(ALL_CFLAGS)
-check:: tst_bitops tst_badblocks tst_iscan @SWAPFS_CMT@ tst_byteswap
+check:: tst_bitops tst_badblocks tst_iscan @SWAPFS_CMT@ tst_byteswap tst_types
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_bitops
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_badblocks
LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_iscan
@SWAPFS_CMT@ LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_byteswap
+ LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) ./tst_types
installdirs::
@echo " MKINSTALLDIRS $(libdir) $(includedir)/ext2fs"
diff --git a/lib/ext2fs/ext2_types.h.in b/lib/ext2fs/ext2_types.h.in
index a3e16d0a..899476bd 100644
--- a/lib/ext2fs/ext2_types.h.in
+++ b/lib/ext2fs/ext2_types.h.in
@@ -7,55 +7,128 @@
!defined(_EXT2_TYPES_H))
#define _EXT2_TYPES_H
+@ASM_TYPES_HEADER@
+
+#ifdef __U8_TYPEDEF
+typedef __U8_TYPEDEF __u8;
+#else
typedef unsigned char __u8;
+#endif
+
+#ifdef __S8_TYPEDEF
+typedef __S8_TYPEDEF __s8;
+#else
typedef signed char __s8;
+#endif
-#if (@SIZEOF_INT@ == 8)
-typedef int __s64;
-typedef unsigned int __u64;
+#ifdef __U16_TYPEDEF
+typedef __U16_TYPEDEF __u16;
#else
-#if (@SIZEOF_LONG@ == 8)
-typedef long __s64;
-typedef unsigned long __u64;
+#if (@SIZEOF_INT@ == 2)
+typedef unsigned int __u16;
#else
-#if (@SIZEOF_LONG_LONG@ == 8)
-#if defined(__GNUC__)
-typedef __signed__ long long __s64;
+#if (@SIZEOF_SHORT@ == 2)
+typedef unsigned short __u16;
#else
-typedef signed long long __s64;
-#endif /* __GNUC__ */
-typedef unsigned long long __u64;
-#endif /* SIZEOF_LONG_LONG == 8 */
-#endif /* SIZEOF_LONG == 8 */
-#endif /* SIZEOF_INT == 8 */
+ ?==error: undefined 16 bit type
+#endif /* SIZEOF_SHORT == 2 */
+#endif /* SIZEOF_INT == 2 */
+#endif /* __U16_TYPEDEF */
+#ifdef __S16_TYPEDEF
+typedef __S16_TYPEDEF __s16;
+#else
#if (@SIZEOF_INT@ == 2)
typedef int __s16;
-typedef unsigned int __u16;
#else
#if (@SIZEOF_SHORT@ == 2)
typedef short __s16;
-typedef unsigned short __u16;
#else
?==error: undefined 16 bit type
#endif /* SIZEOF_SHORT == 2 */
#endif /* SIZEOF_INT == 2 */
+#endif /* __S16_TYPEDEF */
+
+#ifdef __U32_TYPEDEF
+typedef __U32_TYPEDEF __u32;
+#else
#if (@SIZEOF_INT@ == 4)
-typedef int __s32;
typedef unsigned int __u32;
#else
#if (@SIZEOF_LONG@ == 4)
-typedef long __s32;
typedef unsigned long __u32;
#else
#if (@SIZEOF_SHORT@ == 4)
-typedef short __s32;
typedef unsigned short __u32;
#else
?== error: undefined 32 bit type
#endif /* SIZEOF_SHORT == 4 */
#endif /* SIZEOF_LONG == 4 */
#endif /* SIZEOF_INT == 4 */
+#endif /* __U32_TYPEDEF */
+
+#ifdef __S32_TYPEDEF
+typedef __S32_TYPEDEF __s32;
+#else
+#if (@SIZEOF_INT@ == 4)
+typedef int __s32;
+#else
+#if (@SIZEOF_LONG@ == 4)
+typedef long __s32;
+#else
+#if (@SIZEOF_SHORT@ == 4)
+typedef short __s32;
+#else
+ ?== error: undefined 32 bit type
+#endif /* SIZEOF_SHORT == 4 */
+#endif /* SIZEOF_LONG == 4 */
+#endif /* SIZEOF_INT == 4 */
+#endif /* __S32_TYPEDEF */
+
+#ifdef __U64_TYPEDEF
+typedef __U64_TYPEDEF __u64;
+#else
+#if (@SIZEOF_INT@ == 8)
+typedef unsigned int __u64;
+#else
+#if (@SIZEOF_LONG@ == 8)
+typedef unsigned long __u64;
+#else
+#if (@SIZEOF_LONG_LONG@ == 8)
+typedef unsigned long long __u64;
+#endif /* SIZEOF_LONG_LONG == 8 */
+#endif /* SIZEOF_LONG == 8 */
+#endif /* SIZEOF_INT == 8 */
+#endif /* __U64_TYPEDEF */
+
+#ifdef __S64_TYPEDEF
+typedef __S64_TYPEDEF __s64;
+#else
+#if (@SIZEOF_INT@ == 8)
+typedef int __s64;
+#else
+#if (@SIZEOF_LONG@ == 8)
+typedef long __s64;
+#else
+#if (@SIZEOF_LONG_LONG@ == 8)
+#if defined(__GNUC__)
+typedef __signed__ long long __s64;
+#else
+typedef signed long long __s64;
+#endif /* __GNUC__ */
+#endif /* SIZEOF_LONG_LONG == 8 */
+#endif /* SIZEOF_LONG == 8 */
+#endif /* SIZEOF_INT == 8 */
+#endif /* __S64_TYPEDEF */
+
+#undef __S8_TYPEDEF
+#undef __U8_TYPEDEF
+#undef __S16_TYPEDEF
+#undef __U16_TYPEDEF
+#undef __S32_TYPEDEF
+#undef __U32_TYPEDEF
+#undef __S64_TYPEDEF
+#undef __U64_TYPEDEF
#endif /* _*_TYPES_H */
diff --git a/lib/ext2fs/tst_types.c b/lib/ext2fs/tst_types.c
new file mode 100644
index 00000000..739b7236
--- /dev/null
+++ b/lib/ext2fs/tst_types.c
@@ -0,0 +1,59 @@
+/*
+ * This testing program makes sure the ext2_types header file
+ *
+ * Copyright (C) 2006 by Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#include "ext2fs/ext2_types.h"
+
+main(int argc, char **argv)
+{
+ if (sizeof(__u8) != 1) {
+ printf("Sizeof(__u8) is %d should be 1\n",
+ sizeof(__u8));
+ exit(1);
+ }
+ if (sizeof(__s8) != 1) {
+ printf("Sizeof(_s8) is %d should be 1\n",
+ sizeof(__s8));
+ exit(1);
+ }
+ if (sizeof(__u16) != 2) {
+ printf("Sizeof(__u16) is %d should be 2\n",
+ sizeof(__u16));
+ exit(1);
+ }
+ if (sizeof(__s16) != 2) {
+ printf("Sizeof(__s16) is %d should be 2\n",
+ sizeof(__s16));
+ exit(1);
+ }
+ if (sizeof(__u32) != 4) {
+ printf("Sizeof(__u32) is %d should be 4\n",
+ sizeof(__u32));
+ exit(1);
+ }
+ if (sizeof(__s32) != 4) {
+ printf("Sizeof(__s32) is %d should be 4\n",
+ sizeof(__s32));
+ exit(1);
+ }
+ if (sizeof(__u64) != 8) {
+ printf("Sizeof(__u64) is %d should be 8\n",
+ sizeof(__u64));
+ exit(1);
+ }
+ if (sizeof(__s64) != 8) {
+ printf("Sizeof(__s64) is %d should be 8\n",
+ sizeof(__s64));
+ exit(1);
+ }
+ printf("The ext2_types.h types are correct.\n");
+ exit(0);
+}
+