ia64/xen-unstable
changeset 12404:825be74657c3
[LIBFS] IA64 & PPC aren't making use of this right now, but it's silly to
have the build fail for some trivial x86 specific assembly. I snagged the
appropriate bitops for ia64 and ppc (untested) and tossed in an
unoptimized option as well in case we want to make use of it.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
have the build fail for some trivial x86 specific assembly. I snagged the
appropriate bitops for ia64 and ppc (untested) and tossed in an
unoptimized option as well in case we want to make use of it.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author | kaf24@localhost.localdomain |
---|---|
date | Sat Nov 11 01:25:00 2006 +0000 (2006-11-11) |
parents | d108efc94de7 |
children | b1d436f094fa |
files | tools/libfsimage/ext2fs/fsys_ext2fs.c tools/libfsimage/reiserfs/fsys_reiserfs.c |
line diff
1.1 --- a/tools/libfsimage/ext2fs/fsys_ext2fs.c Sat Nov 11 01:23:11 2006 +0000 1.2 +++ b/tools/libfsimage/ext2fs/fsys_ext2fs.c Sat Nov 11 01:25:00 2006 +0000 1.3 @@ -232,6 +232,7 @@ struct ext2_dir_entry 1.4 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 1.5 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 1.6 1.7 +#if defined(__i386__) || defined(__x86_64__) 1.8 /* include/asm-i386/bitops.h */ 1.9 /* 1.10 * ffz = Find First Zero in word. Undefined if no zero exists, 1.11 @@ -251,6 +252,66 @@ ffz (unsigned long word) 1.12 return word; 1.13 } 1.14 1.15 +#elif defined(__ia64__) 1.16 + 1.17 +typedef unsigned long __u64; 1.18 + 1.19 +#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 1.20 +# define ia64_popcnt(x) __builtin_popcountl(x) 1.21 +#else 1.22 +# define ia64_popcnt(x) \ 1.23 + ({ \ 1.24 + __u64 ia64_intri_res; \ 1.25 + asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \ 1.26 + ia64_intri_res; \ 1.27 + }) 1.28 +#endif 1.29 + 1.30 +static __inline__ unsigned long 1.31 +ffz (unsigned long word) 1.32 +{ 1.33 + unsigned long result; 1.34 + 1.35 + result = ia64_popcnt(word & (~word - 1)); 1.36 + return result; 1.37 +} 1.38 + 1.39 +#elif defined(__powerpc__) 1.40 + 1.41 +static __inline__ int 1.42 +__ilog2(unsigned long x) 1.43 +{ 1.44 + int lz; 1.45 + 1.46 + asm (PPC_CNTLZL "%0,%1" : "=r" (lz) : "r" (x)); 1.47 + return BITS_PER_LONG - 1 - lz; 1.48 +} 1.49 + 1.50 +static __inline__ unsigned long 1.51 +ffz (unsigned long word) 1.52 +{ 1.53 + if ((word = ~word) == 0) 1.54 + return BITS_PER_LONG; 1.55 + return __ilog2(word & -word); 1.56 +} 1.57 + 1.58 +#else /* Unoptimized */ 1.59 + 1.60 +static __inline__ unsigned long 1.61 +ffz (unsigned long word) 1.62 +{ 1.63 + unsigned long result; 1.64 + 1.65 + result = 0; 1.66 + while(word & 1) 1.67 + { 1.68 + result++; 1.69 + word >>= 1; 1.70 + } 1.71 + return result; 1.72 +} 1.73 +#endif 1.74 + 1.75 /* check filesystem types and read superblock into memory buffer */ 1.76 int 1.77 ext2fs_mount (fsi_file_t *ffi)
2.1 --- a/tools/libfsimage/reiserfs/fsys_reiserfs.c Sat Nov 11 01:23:11 2006 +0000 2.2 +++ b/tools/libfsimage/reiserfs/fsys_reiserfs.c Sat Nov 11 01:25:00 2006 +0000 2.3 @@ -363,6 +363,8 @@ struct fsys_reiser_info 2.4 #define JOURNAL_START ((__u32 *) (INFO + 1)) 2.5 #define JOURNAL_END ((__u32 *) (FSYS_BUF + FSYS_BUFLEN)) 2.6 2.7 +#if defined(__i386__) || defined(__x86_64__) 2.8 + 2.9 #ifdef __amd64 2.10 #define BSF "bsfq" 2.11 #else 2.12 @@ -376,6 +378,61 @@ grub_log2 (unsigned long word) 2.13 : "r" (word)); 2.14 return word; 2.15 } 2.16 + 2.17 +#elif defined(__ia64__) 2.18 + 2.19 +#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 2.20 +# define ia64_popcnt(x) __builtin_popcountl(x) 2.21 +#else 2.22 +# define ia64_popcnt(x) \ 2.23 + ({ \ 2.24 + __u64 ia64_intri_res; \ 2.25 + asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x)); \ 2.26 + ia64_intri_res; \ 2.27 + }) 2.28 +#endif 2.29 + 2.30 +static __inline__ unsigned long 2.31 +grub_log2 (unsigned long word) 2.32 +{ 2.33 + unsigned long result; 2.34 + 2.35 + result = ia64_popcnt((word - 1) & ~word); 2.36 + return result; 2.37 +} 2.38 + 2.39 +#elif defined(__powerpc__) 2.40 + 2.41 +static __inline__ int 2.42 +__ilog2(unsigned long x) 2.43 +{ 2.44 + int lz; 2.45 + 2.46 + asm (PPC_CNTLZL "%0,%1" : "=r" (lz) : "r" (x)); 2.47 + return BITS_PER_LONG - 1 - lz; 2.48 +} 2.49 + 2.50 +static __inline__ unsigned long 2.51 +grub_log2 (unsigned long word) 2.52 +{ 2.53 + return __ilog2(word & -word); 2.54 +} 2.55 + 2.56 +#else /* Unoptimized */ 2.57 + 2.58 +static __inline__ unsigned long 2.59 +grub_log2 (unsigned long word) 2.60 +{ 2.61 + unsigned long result = 0; 2.62 + 2.63 + while (!(word & 1UL)) 2.64 + { 2.65 + result++; 2.66 + word >>= 1; 2.67 + } 2.68 + return result; 2.69 +} 2.70 +#endif 2.71 #define log2 grub_log2 2.72 2.73 static __inline__ int