Whamcloud - gitweb
e2fsck: clear clang warnings for missing field initializers in structs
[tools/e2fsprogs.git] / e2fsck / jfs_user.h
index 16185a5..8289795 100644 (file)
 #include "e2fsck.h"
 #endif
 
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2 || _MSC_VER >= 1300
+#  define __func__ __FUNCTION__
+# else
+#  define __func__ "<unknown>"
+# endif
+#endif
+
 struct buffer_head {
 #ifdef DEBUGFS
        ext2_filsys     b_fs;
@@ -38,10 +46,10 @@ struct buffer_head {
 #endif
        io_channel      b_io;
        int             b_size;
-       unsigned long long b_blocknr;
-       int             b_dirty;
-       int             b_uptodate;
        int             b_err;
+       unsigned int    b_dirty:1;
+       unsigned int    b_uptodate:1;
+       unsigned long long b_blocknr;
        char            b_data[1024];
 };
 
@@ -100,6 +108,9 @@ typedef struct {
 extern lkmem_cache_t *do_cache_create(int len);
 extern void do_cache_destroy(lkmem_cache_t *cache);
 extern size_t journal_tag_bytes(journal_t *journal);
+extern __u32 __hash_32(__u32 val);
+extern __u32 hash_32(__u32 val, unsigned int bits);
+extern __u32 hash_64(__u64 val, unsigned int bits);
 #endif
 
 #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
@@ -121,7 +132,6 @@ extern size_t journal_tag_bytes(journal_t *journal);
 #endif /* __STDC_VERSION__ >= 199901L */
 #endif /* E2FSCK_INCLUDE_INLINE_FUNCS */
 
-
 _INLINE_ lkmem_cache_t *do_cache_create(int len)
 {
        lkmem_cache_t *new_cache;
@@ -137,6 +147,32 @@ _INLINE_ void do_cache_destroy(lkmem_cache_t *cache)
        free(cache);
 }
 
+/* generic hashing taken from the Linux kernel */
+#define GOLDEN_RATIO_32 0x61C88647
+#define GOLDEN_RATIO_64 0x61C8864680B583EBull
+
+_INLINE_ __u32 __hash_32(__u32 val)
+{
+       return val * GOLDEN_RATIO_32;
+}
+
+_INLINE_ __u32 hash_32(__u32 val, unsigned int bits)
+{
+       /* High bits are more random, so use them. */
+       return __hash_32(val) >> (32 - bits);
+}
+
+_INLINE_ __u32 hash_64(__u64 val, unsigned int bits)
+{
+       if (sizeof(long) >= 8) {
+               /* 64x64-bit multiply is efficient on all 64-bit processors */
+               return val * GOLDEN_RATIO_64 >> (64 - bits);
+       } else {
+               /* Hash 64 bits using only 32x32-bit multiply. */
+               return hash_32((__u32)val ^ __hash_32(val >> 32), bits);
+       }
+}
+
 #undef _INLINE_
 #endif
 
@@ -175,7 +211,7 @@ extern e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
        do { if (!(assert)) {                                           \
                printf ("Assertion failure in %s() at %s line %d: "     \
                        "\"%s\"\n",                                     \
-                       __FUNCTION__, __FILE__, __LINE__, # assert);    \
+                       __func__, __FILE__, __LINE__, # assert);        \
                fatal_error(e2fsck_global_ctx, 0);                      \
        } } while (0)