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>
bitmap-optimize
Theodore Ts'o 2006-04-09 08:41:55 -04:00
parent cef2ac104d
commit 4ea7ea007b
13 changed files with 496 additions and 83 deletions

View File

@ -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)

View File

@ -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/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) $(srcdir)/lib/blkid/blkid_types.h.in
@echo " SUBST $@"
@$(SUBSTITUTE) $(srcdir)/lib/blkid/blkid_types.h.in \
> lib/blkid/blkid_types.h
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) $(srcdir)/lib/uuid/uuid_types.h.in
@echo " SUBST $@"
@$(SUBSTITUTE) $(srcdir)/lib/uuid/uuid_types.h.in \
> lib/uuid/uuid_types.h
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

112
config/parse-types.sh Executable file
View File

@ -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

10
configure vendored
View File

@ -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

View File

@ -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 \

View File

@ -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.

View File

@ -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 $@"

View File

@ -7,55 +7,128 @@
!defined(_EXT2_TYPES_H))
#define _BLKID_TYPES_H
typedef unsigned char __u8;
typedef signed char __s8;
@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
#ifdef __U16_TYPEDEF
typedef __U16_TYPEDEF __u16;
#else
#if (@SIZEOF_INT@ == 2)
typedef unsigned int __u16;
#else
#if (@SIZEOF_SHORT@ == 2)
typedef unsigned short __u16;
#else
?==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;
#else
#if (@SIZEOF_SHORT@ == 2)
typedef short __s16;
#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 unsigned int __u32;
#else
#if (@SIZEOF_LONG@ == 4)
typedef unsigned long __u32;
#else
#if (@SIZEOF_SHORT@ == 4)
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 int __s64;
typedef unsigned int __u64;
#else
#if (@SIZEOF_LONG@ == 8)
typedef long __s64;
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__ */
typedef unsigned long long __u64;
#endif /* SIZEOF_LONG_LONG == 8 */
#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
#endif /* __S64_TYPEDEF */
#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 */
#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 */
#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 */

59
lib/blkid/tst_types.c Normal file
View File

@ -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);
}

View File

@ -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

View File

@ -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"

View File

@ -7,55 +7,128 @@
!defined(_EXT2_TYPES_H))
#define _EXT2_TYPES_H
typedef unsigned char __u8;
typedef signed char __s8;
@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
#ifdef __U16_TYPEDEF
typedef __U16_TYPEDEF __u16;
#else
#if (@SIZEOF_INT@ == 2)
typedef unsigned int __u16;
#else
#if (@SIZEOF_SHORT@ == 2)
typedef unsigned short __u16;
#else
?==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;
#else
#if (@SIZEOF_SHORT@ == 2)
typedef short __s16;
#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 unsigned int __u32;
#else
#if (@SIZEOF_LONG@ == 4)
typedef unsigned long __u32;
#else
#if (@SIZEOF_SHORT@ == 4)
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 int __s64;
typedef unsigned int __u64;
#else
#if (@SIZEOF_LONG@ == 8)
typedef long __s64;
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__ */
typedef unsigned long long __u64;
#endif /* SIZEOF_LONG_LONG == 8 */
#endif /* SIZEOF_LONG == 8 */
#endif /* SIZEOF_INT == 8 */
#endif /* __S64_TYPEDEF */
#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 */
#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 */
#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 */

59
lib/ext2fs/tst_types.c Normal file
View File

@ -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);
}