Re: 2.3.26pre2 compile error [PATCH]

Andrzej Krzysztofowicz (ankry@green.mif.pg.gda.pl)
Sat, 6 Nov 1999 10:16:03 +0100 (CET)


Hi,
Here are some trivial fixes for 64-bit div/mod in 2.3.26pre2...
Fixes for UFS and NCPFS are not trivial as needed shifts are not defined.
I omit fixes for FAT (Alexander already corrected it).

By the way would it be the "right way" to implement an "int log2(long long)"
that calculates the shift for a power_of_two argument ?
Of course, its implementation must be architecture dependent.

All 64-bit divisions I met in the kernel are divisions by power_of_two
argument...

Regards
Andrzej

***********************************************************************
diff -u --recursive 2.3.26pre2/drivers/block/loop.c linux/drivers/block/loop.c
--- 2.3.26pre2/drivers/block/loop.c Fri Nov 5 22:28:01 1999
+++ linux/drivers/block/loop.c Sat Nov 6 01:57:25 1999
@@ -151,12 +151,12 @@
int size;

if (S_ISREG(lo->lo_dentry->d_inode->i_mode))
- size = (lo->lo_dentry->d_inode->i_size - lo->lo_offset) / BLOCK_SIZE;
+ size = (lo->lo_dentry->d_inode->i_size - lo->lo_offset) >> BLOCK_SIZE_BITS;
else {
kdev_t lodev = lo->lo_device;
if (blk_size[MAJOR(lodev)])
size = blk_size[MAJOR(lodev)][MINOR(lodev)] -
- lo->lo_offset / BLOCK_SIZE;
+ (lo->lo_offset >> BLOCK_SIZE_BITS);
else
size = MAX_DISK_SIZE;
}
diff -u --recursive 2.3.26pre2/fs/adfs/inode.c linux/fs/adfs/inode.c
--- 2.3.26pre2/fs/adfs/inode.c Fri Mar 26 22:57:41 1999
+++ linux/fs/adfs/inode.c Sat Nov 6 01:22:22 1999
@@ -181,7 +181,7 @@
inode->i_nlink = 2;
inode->i_size = ADFS_NEWDIR_SIZE;
inode->i_blksize = PAGE_SIZE;
- inode->i_blocks = inode->i_size / sb->s_blocksize;
+ inode->i_blocks = inode->i_size >> sb->s_blocksize_bits;
inode->i_mtime =
inode->i_atime =
inode->i_ctime = 0;
diff -u --recursive 2.3.26pre2/fs/sysv/namei.c linux/fs/sysv/namei.c
--- 2.3.26pre2/fs/sysv/namei.c Sun May 16 08:43:05 1999
+++ linux/fs/sysv/namei.c Sat Nov 6 00:02:01 1999
@@ -324,7 +324,7 @@
block = 0;
bh = NULL;
pos = offset = 2*SYSV_DIRSIZE;
- if (inode->i_size % SYSV_DIRSIZE)
+ if ((unsigned long)(inode->i_size) % SYSV_DIRSIZE)
goto bad_dir;
if (inode->i_size < pos)
goto bad_dir;
diff -u --recursive 2.3.26pre2/fs/udf/super.c linux/fs/udf/super.c
--- 2.3.26pre2/fs/udf/super.c Fri Nov 5 22:28:03 1999
+++ linux/fs/udf/super.c Sat Nov 6 01:37:19 1999
@@ -1184,7 +1184,7 @@
if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP15)
{
UDF_SB_TYPEVIRT(sb,i).s_start_offset = UDF_I_EXT0OFFS(UDF_SB_VAT(sb));
- UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size - 36) / sizeof(Uint32);
+ UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size - 36) >> 2;
}
else if (UDF_SB_PARTTYPE(sb,i) == UDF_VIRTUAL_MAP20)
{
@@ -1197,7 +1197,7 @@
le16_to_cpu(((struct VirtualAllocationTable20 *)bh->b_data + UDF_I_EXT0OFFS(UDF_SB_VAT(sb)))->lengthHeader) +
UDF_I_EXT0OFFS(UDF_SB_VAT(sb));
UDF_SB_TYPEVIRT(sb,i).s_num_entries = (UDF_SB_VAT(sb)->i_size -
- UDF_SB_TYPEVIRT(sb,i).s_start_offset) / sizeof(Uint32);
+ UDF_SB_TYPEVIRT(sb,i).s_start_offset) >> 2;
udf_release_data(bh);
}
UDF_SB_PARTROOT(sb,i) = udf_get_pblock(sb, 0, i, 0);
diff -u --recursive 2.3.26pre2/fs/udf/truncate.c linux/fs/udf/truncate.c
--- 2.3.26pre2/fs/udf/truncate.c Sat Sep 4 21:42:30 1999
+++ linux/fs/udf/truncate.c Sat Nov 6 01:39:48 1999
@@ -64,7 +64,7 @@
lb_addr bloc, eloc, neloc = { 0, 0 };
Uint32 extoffset, elen, offset, nelen = 0, lelen = 0, lenalloc;
int etype;
- int first_block = (inode->i_size + inode->i_sb->s_blocksize - 1) / inode->i_sb->s_blocksize;
+ int first_block = (inode->i_size + inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
struct buffer_head *bh = NULL;
int adsize;

diff -u --recursive 2.3.26pre2/mm/swapfile.c linux/mm/swapfile.c
--- 2.3.26pre2/mm/swapfile.c Fri Nov 5 22:28:49 1999
+++ linux/mm/swapfile.c Fri Nov 5 22:55:43 1999
@@ -613,7 +613,7 @@
swapfilesize = 0;
if (blk_size[MAJOR(dev)])
swapfilesize = blk_size[MAJOR(dev)][MINOR(dev)]
- / (PAGE_SIZE / 1024);
+ >> (PAGE_SHIFT - 10);
} else if (S_ISREG(swap_dentry->d_inode->i_mode)) {
error = -EBUSY;
for (i = 0 ; i < nr_swapfiles ; i++) {
@@ -622,7 +622,7 @@
if (swap_dentry->d_inode == swap_info[i].swap_file->d_inode)
goto bad_swap;
}
- swapfilesize = swap_dentry->d_inode->i_size / PAGE_SIZE;
+ swapfilesize = swap_dentry->d_inode->i_size >> PAGE_SHIFT;
} else
goto bad_swap;

***********************************************************************

-- 
=======================================================================
  Andrzej M. Krzysztofowicz               ankry@mif.pg.gda.pl
  phone (48)(58) 347 14 61
Faculty of Applied Phys. & Math.,   Technical University of Gdansk

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/