* grub-core/kern/misc.c (grub_divmod64_full): Renamed to ...
(grub_divmod64): ... this.
* include/grub/misc.h (grub_divmod64): Removed. All users switch to full
version.
+2011-05-18 Vladimir Serbinenko <phcoder@gmail.com>
+
+ Use full 64-bit division.
+
+ * grub-core/kern/misc.c (grub_divmod64_full): Renamed to ...
+ (grub_divmod64): ... this.
+ * include/grub/misc.h (grub_divmod64): Removed. All users switch to full
+ version.
+
2011-05-18 Colin Watson <cjwatson@ubuntu.com>
* util/grub-mkrescue.in: Use portable `.' rather than non-portable
if (units)
{
- grub_uint32_t whole, fraction;
+ grub_uint64_t whole, fraction;
whole = grub_divmod64 (fsize, 100, &fraction);
grub_snprintf (buf, sizeof (buf),
- "%u.%02u%c", whole, fraction,
+ "%" PRIuGRUB_UINT64_T
+ ".%02" PRIuGRUB_UINT64_T "%c", whole, fraction,
grub_human_sizes[units]);
grub_printf ("%-12s", buf);
}
get_safe_sectors (grub_disk_addr_t sector, grub_uint32_t sectors)
{
grub_size_t size;
- grub_uint32_t offset;
+ grub_uint64_t offset;
/* OFFSET = SECTOR % SECTORS */
grub_divmod64 (sector, sectors, &offset);
/* This is a striped segment. We have to find the right PV
similar to RAID0. */
struct grub_lvm_node *stripe = seg->nodes;
- grub_uint32_t a, b;
+ grub_uint64_t a, b;
grub_uint64_t seg_offset; /* Offset of the segment in PV device. */
- unsigned int stripenr;
+ grub_uint64_t stripenr;
offset = sector - ((grub_uint64_t) seg->start_extent
* (grub_uint64_t) vg->extent_size);
case 10:
{
grub_disk_addr_t read_sector, far_ofs;
- grub_uint32_t disknr, b, near, far, ofs;
+ grub_uint64_t disknr, b, near, far, ofs;
read_sector = grub_divmod64 (sector, array->chunk_size, &b);
far = ofs = near = 1;
case 6:
{
grub_disk_addr_t read_sector;
- grub_uint32_t b, p, n, disknr, e;
+ grub_uint64_t b, p, n, disknr, e;
/* n = 1 for level 4 and 5, 2 for level 6. */
n = array->level / 3;
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"unsupported SCSI block size");
- grub_uint32_t sector_mod = 0;
+ grub_uint64_t sector_mod = 0;
sector = grub_divmod64 (sector, spb, §or_mod);
if (! (sector_mod == 0 && size % spb == 0))
int block = node->block;
struct grub_affs_file file;
struct grub_affs_data *data = node->data;
- grub_uint32_t mod;
+ grub_uint64_t mod;
/* Find the block that points to the fileblock we are looking up by
following the chain until the right table is reached. */
chunk_found:
{
- grub_uint32_t stripen;
+ grub_uint64_t stripen;
grub_uint64_t stripe_offset;
grub_uint64_t off = addr - grub_le_to_cpu64 (key->offset);
unsigned redundancy = 1;
{
grub_uint64_t stripe_length;
grub_dprintf ("btrfs", "single\n");
- stripe_length = grub_divmod64_full (grub_le_to_cpu64 (chunk->size),
- grub_le_to_cpu16 (chunk->nstripes),
- NULL);
- stripen = grub_divmod64_full (off, stripe_length, &stripe_offset);
+ stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size),
+ grub_le_to_cpu16 (chunk->nstripes),
+ NULL);
+ stripen = grub_divmod64 (off, stripe_length, &stripe_offset);
csize = (stripen + 1) * stripe_length - off;
break;
}
case GRUB_BTRFS_CHUNK_TYPE_RAID0:
{
grub_uint64_t middle, high;
- grub_uint32_t low;
+ grub_uint64_t low;
grub_dprintf ("btrfs", "RAID0\n");
middle = grub_divmod64 (off,
grub_le_to_cpu64 (chunk->stripe_length),
case GRUB_BTRFS_CHUNK_TYPE_RAID10:
{
grub_uint64_t middle, high;
- grub_uint32_t low;
+ grub_uint64_t low;
middle = grub_divmod64 (off,
grub_le_to_cpu64 (chunk->stripe_length),
&low);
grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T
"+0x%" PRIxGRUB_UINT64_T " (%d stripes (%d substripes) of %"
- PRIxGRUB_UINT64_T ") stripe %" PRIxGRUB_UINT32_T
+ PRIxGRUB_UINT64_T ") stripe %" PRIxGRUB_UINT64_T
" maps to 0x%" PRIxGRUB_UINT64_T "\n",
grub_le_to_cpu64 (key->offset),
grub_le_to_cpu64 (chunk->size),
struct grub_pxenv_tftp_read c;
struct grub_pxe_data *data;
struct grub_pxe_disk_data *disk_data = file->device->disk->data;
- grub_uint32_t pn, r;
+ grub_uint32_t pn;
+ grub_uint64_t r;
data = file->data;
grub_disk_addr_t i;
grub_disk_addr_t blockcnt;
grub_uint64_t posblock;
- grub_uint32_t blockoff;
+ grub_uint64_t blockoff;
/* Adjust len so it we can't read past the end of the file. */
if (len + pos > GRUB_MINIX_INODE_SIZE (data))
for (i = posblock; i < blockcnt; i++)
{
grub_disk_addr_t blknr;
- grub_uint32_t blockend = data->block_size;
+ grub_uint64_t blockend = data->block_size;
grub_off_t skipfirst = 0;
blknr = grub_minix_get_file_block (data, i);
static inline grub_uint64_t
grub_nilfs2_palloc_group (struct grub_nilfs2_data *data,
- grub_uint64_t nr, grub_uint32_t * offset)
+ grub_uint64_t nr, grub_uint64_t * offset)
{
return grub_divmod64 (nr, grub_nilfs2_palloc_entries_per_group (data),
offset);
grub_uint64_t nr, unsigned long entry_size)
{
unsigned long group;
- grub_uint32_t group_offset;
+ grub_uint64_t group_offset;
group = grub_nilfs2_palloc_group (data, nr, &group_offset);
return grub_nilfs2_palloc_bitmap_block_offset (data, group,
entry_size) + 1 +
- group_offset / grub_nilfs2_entries_per_block (data, entry_size);
+ grub_divmod64 (group_offset, grub_nilfs2_entries_per_block (data,
+ entry_size),
+ NULL);
}
struct grub_nilfs2_dat_entry entry;
grub_disk_t disk = data->disk;
grub_uint64_t pptr;
- grub_uint32_t blockno, offset;
+ grub_uint64_t blockno, offset;
unsigned int nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data));
blockno = grub_nilfs2_palloc_entry_offset (data, key,
struct grub_nilfs2_checkpoint *cpp)
{
grub_uint64_t blockno;
- grub_uint32_t offset;
+ grub_uint64_t offset;
grub_uint64_t pptr;
grub_disk_t disk = data->disk;
unsigned int nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data));
grub_uint64_t ino, struct grub_nilfs2_inode *inodep)
{
grub_uint64_t blockno;
- unsigned int offset;
+ grub_uint64_t offset;
grub_uint64_t pptr;
grub_disk_t disk = data->disk;
unsigned int nilfs2_block_count = (1 << LOG2_NILFS2_BLOCK_SIZE (data));
if (at->flags & AF_GPOS)
{
grub_disk_addr_t st0, st1;
- grub_uint32_t m;
+ grub_uint64_t m;
grub_divmod64 (ofs >> BLK_SHR, ctx->comp.spc, &m);
{
grub_size_t res = len;
grub_bufio_t bufio = file->data;
- grub_uint32_t pos;
+ grub_uint64_t pos;
if ((file->offset >= bufio->file->offset) &&
(file->offset < bufio->file->offset + bufio->buffer_len))
/* Divide N by D, return the quotient, and store the remainder in *R. */
grub_uint64_t
-grub_divmod64_full (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
+grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r)
{
/* This algorithm is typically implemented by hardware. The idea
is to get the highest bit in N, 64 times, by keeping
/* BASE == 10 */
do
{
- unsigned m;
+ grub_uint64_t m;
n = grub_divmod64 (n, 10, &m);
*p++ = m + '0';
char *EXPORT_FUNC(grub_xvasprintf) (const char *fmt, va_list args) __attribute__ ((warn_unused_result));
void EXPORT_FUNC(grub_exit) (void) __attribute__ ((noreturn));
void EXPORT_FUNC(grub_abort) (void) __attribute__ ((noreturn));
-grub_uint64_t EXPORT_FUNC(grub_divmod64_full) (grub_uint64_t n,
- grub_uint64_t d,
- grub_uint64_t *r);
-static inline grub_uint64_t grub_divmod64 (grub_uint64_t n,
- grub_uint32_t d,
- grub_uint32_t *r)
-{
- grub_uint64_t ret, rr;
-
- ret = grub_divmod64_full (n, d, &rr);
- if (r)
- *r = rr;
- return ret;
-}
+grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
+ grub_uint64_t d,
+ grub_uint64_t *r);
#if NEED_ENABLE_EXECUTE_STACK && !defined(GRUB_UTIL)
void EXPORT_FUNC(__enable_execute_stack) (void *addr);