Whamcloud - gitweb
Include inttypes.h if present. New macros INT_TO_VOIDPTR and
authorTheodore Ts'o <tytso@mit.edu>
Fri, 1 Aug 2003 18:26:23 +0000 (14:26 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 1 Aug 2003 18:26:23 +0000 (14:26 -0400)
VOIDPTR_TO_INT.  Use them throughout for int<->void *
casts to fix 64-bit warnings.

ChangeLog
configure
configure.in
e2fsck/ChangeLog
e2fsck/pass1b.c

index 2edfaa7..f441012 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-08-01  Philipp Thomas <pthomas@suse.de>
+
+       * configure.in: Add tests for inttypes.h and intptr_t.
+
 2003-07-25  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.34
index b19a917..52d49e4 100644 (file)
--- a/configure
+++ b/configure
@@ -5798,20 +5798,93 @@ EOF
 
 fi
 
+for ac_hdr in inttypes.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:5806: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 5811 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:5816: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for intptr_t""... $ac_c" 1>&6
+echo "configure:5843: checking for intptr_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_intptr_t'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 5848 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  egrep "(^|[^a-zA-Z_0-9])intptr_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+  rm -rf conftest*
+  ac_cv_type_intptr_t=yes
+else
+  rm -rf conftest*
+  ac_cv_type_intptr_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_intptr_t" 1>&6
+if test $ac_cv_type_intptr_t = no; then
+  cat >> confdefs.h <<\EOF
+#define intptr_t long
+EOF
+
+fi
+
 echo $ac_n "checking whether struct stat has a st_flags field""... $ac_c" 1>&6
-echo "configure:5803: checking whether struct stat has a st_flags field" >&5
+echo "configure:5876: checking whether struct stat has a st_flags field" >&5
 if eval "test \"`echo '$''{'e2fsprogs_cv_struct_st_flags'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5808 "configure"
+#line 5881 "configure"
 #include "confdefs.h"
 #include <sys/stat.h>
 int main() {
 struct stat stat; stat.st_flags = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:5815: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5888: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   e2fsprogs_cv_struct_st_flags=yes
 else
@@ -5826,19 +5899,19 @@ fi
 echo "$ac_t""$e2fsprogs_cv_struct_st_flags" 1>&6
 if test "$e2fsprogs_cv_struct_st_flags" = yes; then
   echo $ac_n "checking whether st_flags field is useful""... $ac_c" 1>&6
-echo "configure:5830: checking whether st_flags field is useful" >&5
+echo "configure:5903: checking whether st_flags field is useful" >&5
   if eval "test \"`echo '$''{'e2fsprogs_cv_struct_st_flags_immut'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5835 "configure"
+#line 5908 "configure"
 #include "confdefs.h"
 #include <sys/stat.h>
 int main() {
 struct stat stat; stat.st_flags |= UF_IMMUTABLE;
 ; return 0; }
 EOF
-if { (eval echo configure:5842: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   e2fsprogs_cv_struct_st_flags_immut=yes
 else
@@ -5861,12 +5934,12 @@ fi
 for ac_func in chflags getrusage llseek lseek64 open64 getmntinfo strtoull strcasecmp srandom fchown mallinfo fdatasync strnlen strptime sysconf pathconf posix_memalign memalign valloc
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5865: checking for $ac_func" >&5
+echo "configure:5938: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5870 "configure"
+#line 5943 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5889,7 +5962,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:5893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5966: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -5915,7 +5988,7 @@ done
 
 SOCKET_LIB=''
 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:5919: checking for socket in -lsocket" >&5
+echo "configure:5992: checking for socket in -lsocket" >&5
 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5923,7 +5996,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5927 "configure"
+#line 6000 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5934,7 +6007,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:5938: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5957,7 +6030,7 @@ fi
 
 DLOPEN_LIB=''
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:5961: checking for dlopen in -ldl" >&5
+echo "configure:6034: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5965,7 +6038,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5969 "configure"
+#line 6042 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5976,7 +6049,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:5980: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6002,12 +6075,12 @@ fi
 
 
 echo $ac_n "checking for optreset""... $ac_c" 1>&6
-echo "configure:6006: checking for optreset" >&5
+echo "configure:6079: checking for optreset" >&5
 if eval "test \"`echo '$''{'ac_cv_have_optreset'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6011 "configure"
+#line 6084 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 EOF
@@ -6098,20 +6171,20 @@ fi
 
 
 echo $ac_n "checking whether linker accepts -static""... $ac_c" 1>&6
-echo "configure:6102: checking whether linker accepts -static" >&5
+echo "configure:6175: checking whether linker accepts -static" >&5
 if eval "test \"`echo '$''{'ac_cv_e2fsprogs_use_static'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   SAVE_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -static"
 cat > conftest.$ac_ext <<EOF
-#line 6108 "configure"
+#line 6181 "configure"
 #include "confdefs.h"
 #include <stdio.h>
 int main() {
 fflush(stdout);
 ; return 0; }
 EOF
-if { (eval echo configure:6115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_e2fsprogs_use_static=yes
 else
index c462b7b..e90707d 100644 (file)
@@ -657,6 +657,11 @@ AC_SUBST(SIZEOF_LONG)
 AC_SUBST(SIZEOF_LONG_LONG)
 AC_C_BIGENDIAN
 dnl
+dnl See if we have inttypes.h and if intptr_t is defined
+dnl
+AC_CHECK_HEADERS([inttypes.h])
+AC_CHECK_TYPE(intptr_t,long)
+dnl
 dnl See if struct stat has a st_flags field, in which case we can get file
 dnl flags somewhat portably.  Also check for the analogous setter, chflags().
 dnl
index c5223d2..966a98f 100644 (file)
@@ -1,5 +1,9 @@
 2003-08-01  Philipp Thomas <pthomas@suse.de>
 
+       * Include inttypes.h if present.  New macros INT_TO_VOIDPTR and
+               VOIDPTR_TO_INT.  Use them throughout for int<->void *
+               casts to fix 64-bit warnings.
+
        * dirinfo.c, dx_dirinfo.c, e2fsck.c, ea_refcount.c, journal.c,
                message.c, pass1.c, pass1b.c, pass2.c, pass3.c, pass4.c,
                pass5.c, super.c, swapfs.c: ext2fs_getmem(),
index c5ad8ba..39e9030 100644 (file)
 #include <errno.h>
 #endif
 
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+/* Needed for architectures where sizeof(int) != sizeof(void *) */
+#define INT_TO_VOIDPTR(val)  ((void *)(intptr_t)(val))
+#define VOIDPTR_TO_INT(ptr)  ((int)(intptr_t)(ptr))
+
 #include <et/com_err.h>
 #include "e2fsck.h"
 
@@ -91,10 +99,10 @@ static ext2fs_inode_bitmap inode_dup_map;
 
 static int dict_int_cmp(const void *a, const void *b)
 {
-       int     ia, ib;
+       intptr_t        ia, ib;
 
-       ia = (inta;
-       ib = (intb;
+       ia = (intptr_t)a;
+       ib = (intptr_t)b;
 
        return (ia-ib);
 }
@@ -111,7 +119,7 @@ static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk_t blk,
        struct block_el         *blk_el;
        struct inode_el         *ino_el;
 
-       n = dict_lookup(&blk_dict, (void *) blk);
+       n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(blk));
        if (n)
                db = (struct dup_block *) dnode_get(n);
        else {
@@ -119,7 +127,7 @@ static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk_t blk,
                         sizeof(struct dup_block), "duplicate block header");
                db->num_bad = 0;
                db->inode_list = 0;
-               dict_alloc_insert(&blk_dict, (void *) blk, db);
+               dict_alloc_insert(&blk_dict, INT_TO_VOIDPTR(blk), db);
        }
        ino_el = (struct inode_el *) e2fsck_allocate_memory(ctx,
                         sizeof(struct inode_el), "inode element");
@@ -128,7 +136,7 @@ static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk_t blk,
        db->inode_list = ino_el;
        db->num_bad++;
 
-       n = dict_lookup(&ino_dict, (void *) ino);
+       n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino));
        if (n)
                di = (struct dup_inode *) dnode_get(n);
        else {
@@ -138,7 +146,7 @@ static void add_dupe(e2fsck_t ctx, ext2_ino_t ino, blk_t blk,
                di->num_dupblocks = 0;
                di->block_list = 0;
                di->inode = *inode;
-               dict_alloc_insert(&ino_dict, (void *) ino, di);
+               dict_alloc_insert(&ino_dict, INT_TO_VOIDPTR(ino), di);
        }
        blk_el = (struct block_el *) e2fsck_allocate_memory(ctx,
                         sizeof(struct block_el), "block element");
@@ -351,7 +359,7 @@ static int search_dirent_proc(ext2_ino_t dir, int entry,
            !ext2fs_test_inode_bitmap(inode_dup_map, dirent->inode))
                return 0;
 
-       n = dict_lookup(&ino_dict, (void *) dirent->inode);
+       n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(dirent->inode));
        if (!n)
                return 0;
        p = (struct dup_inode *) dnode_get(n);
@@ -412,7 +420,7 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
                p = (struct dup_inode *) dnode_get(n);
                shared_len = 0;
                file_ok = 1;
-               ino = (ext2_ino_t) dnode_getkey(n);
+               ino = (ext2_ino_t)VOIDPTR_TO_INT(dnode_getkey(n));
                if (ino == EXT2_BAD_INO)
                        continue;
 
@@ -423,7 +431,7 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
                 * get the list of inodes, and merge them together.
                 */
                for (s = p->block_list; s; s = s->next) {
-                       m = dict_lookup(&blk_dict, (void *) s->block);
+                       m = dict_lookup(&blk_dict, INT_TO_VOIDPTR(s->block));
                        if (!m)
                                continue; /* Should never happen... */
                        q = (struct dup_block *) dnode_get(m);
@@ -468,7 +476,7 @@ static void pass1d(e2fsck_t ctx, char *block_buf)
                        fix_problem(ctx, PR_1D_SHARE_METADATA, &pctx);
                
                for (i = 0; i < shared_len; i++) {
-                       m = dict_lookup(&ino_dict, (void *) shared[i]);
+                       m = dict_lookup(&ino_dict, INT_TO_VOIDPTR(shared[i]));
                        if (!m)
                                continue; /* should never happen */
                        t = (struct dup_inode *) dnode_get(m);
@@ -530,7 +538,7 @@ static int delete_file_block(ext2_filsys fs,
                return 0;
 
        if (ext2fs_test_block_bitmap(ctx->block_dup_map, *block_nr)) {
-               n = dict_lookup(&blk_dict, (void *) *block_nr);
+               n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(*block_nr));
                if (n) {
                        p = (struct dup_block *) dnode_get(n);
                        decrement_badcount(ctx, *block_nr, p);
@@ -632,7 +640,7 @@ static int clone_file_block(ext2_filsys fs,
                return 0;
 
        if (ext2fs_test_block_bitmap(ctx->block_dup_map, *block_nr)) {
-               n = dict_lookup(&blk_dict, (void *) *block_nr);
+               n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(*block_nr));
                if (n) {
                        p = (struct dup_block *) dnode_get(n);
                        retval = ext2fs_new_block(fs, 0, ctx->block_found_map,
@@ -732,12 +740,12 @@ static int clone_file(e2fsck_t ctx, ext2_ino_t ino,
                 * which refered to that EA block, and modify
                 * them to point to the new EA block.
                 */
-               n = dict_lookup(&blk_dict, (void *) blk);
+               n = dict_lookup(&blk_dict, INT_TO_VOIDPTR(blk));
                db = (struct dup_block *) dnode_get(n);
                for (ino_el = db->inode_list; ino_el; ino_el = ino_el->next) {
                        if (ino_el->inode == ino)
                                continue;
-                       n = dict_lookup(&ino_dict, (void *) ino_el->inode);
+                       n = dict_lookup(&ino_dict, INT_TO_VOIDPTR(ino_el->inode));
                        di = (struct dup_inode *) dnode_get(n);
                        if (di->inode.i_file_acl == blk) {
                                di->inode.i_file_acl = dp->inode.i_file_acl;