remove some 64bit functions

This commit is contained in:
Ben Gras 2013-06-17 01:40:26 +02:00
parent d1b3ab953e
commit 4059c0355c
57 changed files with 308 additions and 413 deletions

View File

@ -525,8 +525,8 @@ void geometry(void)
if (ioctl(device, DIOCGETP, &geometry) < 0) if (ioctl(device, DIOCGETP, &geometry) < 0)
err= errno; err= errno;
else { else {
table[0].lowsec= div64u(geometry.base, SECTOR_SIZE); table[0].lowsec= ((u64_t)(geometry.base) / (unsigned)(SECTOR_SIZE));
table[0].size= div64u(geometry.size, SECTOR_SIZE); table[0].size= ((u64_t)(geometry.size) / (unsigned)(SECTOR_SIZE));
cylinders= geometry.cylinders; cylinders= geometry.cylinders;
heads= geometry.heads; heads= geometry.heads;
sectors= geometry.sectors; sectors= geometry.sectors;
@ -578,8 +578,8 @@ exit(1);
* This makes sense for subpartitioning primary partitions. * This makes sense for subpartitioning primary partitions.
*/ */
if (precise && ioctl(device, DIOCGETP, &geometry) >= 0) { if (precise && ioctl(device, DIOCGETP, &geometry) >= 0) {
table[0].lowsec= div64u(geometry.base, SECTOR_SIZE); table[0].lowsec= ((u64_t)(geometry.base) / (unsigned)(SECTOR_SIZE));
table[0].size= div64u(geometry.size, SECTOR_SIZE); table[0].size= ((u64_t)(geometry.size) / (unsigned)(SECTOR_SIZE));
} else { } else {
precise= 0; precise= 0;
} }
@ -2149,8 +2149,8 @@ sanitycheck_failed(char *dev, struct part_entry *pe)
close(fd); close(fd);
it_lowsec = div64u(part.base, SECTOR_SIZE); it_lowsec = ((u64_t)(part.base) / (unsigned)(SECTOR_SIZE));
it_secsize = div64u(part.size, SECTOR_SIZE); it_secsize = ((u64_t)(part.size) / (unsigned)(SECTOR_SIZE));
if(it_lowsec != pe->lowsec || it_secsize != pe->size) { if(it_lowsec != pe->lowsec || it_secsize != pe->size) {
fprintf(stderr, "\nReturned and set numbers don't match up!\n"); fprintf(stderr, "\nReturned and set numbers don't match up!\n");

View File

@ -98,7 +98,7 @@ static struct super_block sb;
* btoa64 gives the byte address of a block * btoa64 gives the byte address of a block
*/ */
#define ztob(z) ((block_nr) (z) << sb.s_log_zone_size) #define ztob(z) ((block_nr) (z) << sb.s_log_zone_size)
#define btoa64(b) (mul64u(b, block_size)) #define btoa64(b) (((u64_t)(b) * (block_size)))
#define SCALE ((int) ztob(1)) /* # blocks in a zone */ #define SCALE ((int) ztob(1)) /* # blocks in a zone */
#define FIRST ((zone_nr) sb.s_firstdatazone) /* as the name says */ #define FIRST ((zone_nr) sb.s_firstdatazone) /* as the name says */
@ -657,12 +657,12 @@ void chksuper()
int inoblock(int inn) int inoblock(int inn)
{ {
return div64u(mul64u(inn - 1, INODE_SIZE), block_size) + BLK_ILIST; return ((u64_t)(((u64_t)(inn - 1) * (INODE_SIZE))) / (unsigned)(block_size)) + BLK_ILIST;
} }
int inooff(int inn) int inooff(int inn)
{ {
return rem64u(mul64u(inn - 1, INODE_SIZE), block_size); return ((u64_t)(((u64_t)(inn - 1) * (INODE_SIZE))) % (unsigned)(block_size));
} }
/* Make a listing of the inodes given by `clist'. If `repair' is set, ask /* Make a listing of the inodes given by `clist'. If `repair' is set, ask

View File

@ -477,8 +477,8 @@ void geometry(void)
if (ioctl(device, DIOCGETP, &geometry) < 0) if (ioctl(device, DIOCGETP, &geometry) < 0)
err= errno; err= errno;
else { else {
table[0].lowsec= div64u(geometry.base, SECTOR_SIZE); table[0].lowsec= ((u64_t)(geometry.base) / (unsigned)(SECTOR_SIZE));
table[0].size= div64u(geometry.size, SECTOR_SIZE); table[0].size= ((u64_t)(geometry.size) / (unsigned)(SECTOR_SIZE));
cylinders= geometry.cylinders; cylinders= geometry.cylinders;
heads= geometry.heads; heads= geometry.heads;
sectors= geometry.sectors; sectors= geometry.sectors;
@ -546,8 +546,8 @@ void geometry(void)
* This makes sense for subpartitioning primary partitions. * This makes sense for subpartitioning primary partitions.
*/ */
if (precise && ioctl(device, DIOCGETP, &geometry) >= 0) { if (precise && ioctl(device, DIOCGETP, &geometry) >= 0) {
table[0].lowsec= div64u(geometry.base, SECTOR_SIZE); table[0].lowsec= ((u64_t)(geometry.base) / (unsigned)(SECTOR_SIZE));
table[0].size= div64u(geometry.size, SECTOR_SIZE); table[0].size= ((u64_t)(geometry.size) / (unsigned)(SECTOR_SIZE));
} else { } else {
precise= 0; precise= 0;
} }

View File

@ -296,16 +296,16 @@ void geometry(void)
/* Use the same fake geometry as part. */ /* Use the same fake geometry as part. */
if (fstat(fd, &sb) < 0) if (fstat(fd, &sb) < 0)
fatal(device); fatal(device);
geometry.base= cvul64(0); geometry.base= ((u64_t)(0));
geometry.size= cvul64(sb.st_size); geometry.size= ((u64_t)(sb.st_size));
geometry.sectors= 32; geometry.sectors= 32;
geometry.heads= 64; geometry.heads= 64;
geometry.cylinders= (sb.st_size-1)/SECTOR_SIZE/ geometry.cylinders= (sb.st_size-1)/SECTOR_SIZE/
(geometry.sectors*geometry.heads) + 1; (geometry.sectors*geometry.heads) + 1;
} }
close(fd); close(fd);
primary.lowsec= div64u(geometry.base, SECTOR_SIZE); primary.lowsec= ((u64_t)(geometry.base) / (unsigned)(SECTOR_SIZE));
primary.size= div64u(geometry.size, SECTOR_SIZE); primary.size= ((u64_t)(geometry.size) / (unsigned)(SECTOR_SIZE));
cylinders= geometry.cylinders; cylinders= geometry.cylinders;
heads= geometry.heads; heads= geometry.heads;
sectors= geometry.sectors; sectors= geometry.sectors;

View File

@ -48,7 +48,7 @@
char *buffer = NULL; char *buffer = NULL;
size_t block_size = 0, mult_max = 0; size_t block_size = 0, mult_max = 0;
size_t buffer_size; size_t buffer_size;
long volume_size; u64_t volume_size;
char *str_vol_size; char *str_vol_size;
int rflag = 0, wflag = 0, oneflag = 0, variable = 0; int rflag = 0, wflag = 0, oneflag = 0, variable = 0;
@ -194,7 +194,7 @@ char *argv[];
if (ioctl(fd, DIOCGETP, &part) < 0) { if (ioctl(fd, DIOCGETP, &part) < 0) {
autovolsize = 0; autovolsize = 0;
} else { } else {
volume_size = cv64ul(part.size); volume_size = part.size;
} }
} }

View File

@ -380,8 +380,7 @@ static int atapi_read_capacity(struct port_state *ps, int cmd)
/* Store the number of LBA blocks and sector size. */ /* Store the number of LBA blocks and sector size. */
buf = ps->tmp_base; buf = ps->tmp_base;
ps->lba_count = add64u(cvu64((buf[0] << 24) | (buf[1] << 16) | ps->lba_count = ((u64_t)(((u64_t)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]))) + (1));
(buf[2] << 8) | buf[3]), 1);
ps->sector_size = ps->sector_size =
(buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7]; (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
@ -395,8 +394,7 @@ static int atapi_read_capacity(struct port_state *ps, int cmd)
dprintf(V_INFO, dprintf(V_INFO,
("%s: medium detected (%u byte sectors, %lu MB size)\n", ("%s: medium detected (%u byte sectors, %lu MB size)\n",
ahci_portname(ps), ps->sector_size, ahci_portname(ps), ps->sector_size,
div64u(mul64(ps->lba_count, cvu64(ps->sector_size)), ((u64_t)(((u64_t)(ps->lba_count) * (((u64_t)(ps->sector_size))))) / (unsigned)(1024 * 1024))));
1024*1024)));
return OK; return OK;
} }
@ -1172,11 +1170,11 @@ static ssize_t port_transfer(struct port_state *ps, u64_t pos, u64_t eof,
* extend beyond the end of the partition. The caller already * extend beyond the end of the partition. The caller already
* guarantees that the starting position lies within the partition. * guarantees that the starting position lies within the partition.
*/ */
if (cmp64(add64ul(pos, size), eof) >= 0) if (cmp64(((u64_t)(pos) + (size)), eof) >= 0)
size = (vir_bytes) diff64(eof, pos); size = (vir_bytes) diff64(eof, pos);
start_lba = div64(pos, cvu64(ps->sector_size)); start_lba = ((u64_t)(pos) / (unsigned)(((u64_t)(ps->sector_size))));
lead = rem64u(pos, ps->sector_size); lead = ((u64_t)(pos) % (unsigned)(ps->sector_size));
count = (lead + size + ps->sector_size - 1) / ps->sector_size; count = (lead + size + ps->sector_size - 1) / ps->sector_size;
/* Position must be word-aligned for read requests, and sector-aligned /* Position must be word-aligned for read requests, and sector-aligned
@ -1428,8 +1426,7 @@ static void port_id_check(struct port_state *ps, int success)
if (ps->flags & FLAG_HAS_MEDIUM) if (ps->flags & FLAG_HAS_MEDIUM)
printf(", %u byte sectors, %lu MB size", printf(", %u byte sectors, %lu MB size",
ps->sector_size, div64u(mul64(ps->lba_count, ps->sector_size, ((u64_t)(((u64_t)(ps->lba_count) * (((u64_t)(ps->sector_size))))) / (unsigned)(1024 * 1024)));
cvu64(ps->sector_size)), 1024*1024));
printf("\n"); printf("\n");
} }
@ -2522,7 +2519,7 @@ static int ahci_open(dev_t minor, int access)
memset(ps->subpart, 0, sizeof(ps->subpart)); memset(ps->subpart, 0, sizeof(ps->subpart));
ps->part[0].dv_size = ps->part[0].dv_size =
mul64(ps->lba_count, cvu64(ps->sector_size)); ((u64_t)(ps->lba_count) * (((u64_t)(ps->sector_size))));
partition(&ahci_dtab, ps->device * DEV_PER_DRIVE, P_PRIMARY, partition(&ahci_dtab, ps->device * DEV_PER_DRIVE, P_PRIMARY,
!!(ps->flags & FLAG_ATAPI)); !!(ps->flags & FLAG_ATAPI));
@ -2626,8 +2623,8 @@ static ssize_t ahci_transfer(dev_t minor, int do_write, u64_t position,
if (cmp64(position, dv->dv_size) >= 0) if (cmp64(position, dv->dv_size) >= 0)
return OK; return OK;
pos = add64(dv->dv_base, position); pos = ((u64_t)(dv->dv_base) + (position));
eof = add64(dv->dv_base, dv->dv_size); eof = ((u64_t)(dv->dv_base) + (dv->dv_size));
return port_transfer(ps, pos, eof, endpt, (iovec_s_t *) iovec, count, return port_transfer(ps, pos, eof, endpt, (iovec_s_t *) iovec, count,
do_write, flags); do_write, flags);

View File

@ -906,7 +906,7 @@ static int w_identify(void)
w_testing = 0; w_testing = 0;
/* Size of the whole drive */ /* Size of the whole drive */
wn->part[0].dv_size = mul64u(size, SECTOR_SIZE); wn->part[0].dv_size = ((u64_t)(size) * (SECTOR_SIZE));
/* Reset/calibrate (where necessary) */ /* Reset/calibrate (where necessary) */
if (w_specify() != OK && w_specify() != OK) { if (w_specify() != OK && w_specify() != OK) {
@ -975,7 +975,7 @@ static int w_io_test(void)
w_testing = 1; w_testing = 1;
/* Try I/O on the actual drive (not any (sub)partition). */ /* Try I/O on the actual drive (not any (sub)partition). */
r = w_transfer(w_drive * DEV_PER_DRIVE, FALSE /*do_write*/, cvu64(0), r = w_transfer(w_drive * DEV_PER_DRIVE, FALSE /*do_write*/, ((u64_t)(0)),
SELF, &iov, 1, BDEV_NOFLAGS); SELF, &iov, 1, BDEV_NOFLAGS);
/* Switch back. */ /* Switch back. */
@ -1204,7 +1204,7 @@ static ssize_t w_transfer(
#endif #endif
/* Check disk address. */ /* Check disk address. */
if (rem64u(position, SECTOR_SIZE) != 0) return(EINVAL); if (((u64_t)(position) % (unsigned)(SECTOR_SIZE)) != 0) return(EINVAL);
errors = 0; errors = 0;
@ -1216,9 +1216,9 @@ static ssize_t w_transfer(
/* Which block on disk and how close to EOF? */ /* Which block on disk and how close to EOF? */
if (cmp64(position, dv_size) >= 0) return(total); /* At EOF */ if (cmp64(position, dv_size) >= 0) return(total); /* At EOF */
if (cmp64(add64ul(position, nbytes), dv_size) > 0) if (cmp64(((u64_t)(position) + (nbytes)), dv_size) > 0)
nbytes = diff64(dv_size, position); nbytes = diff64(dv_size, position);
block = div64u(add64(w_dv->dv_base, position), SECTOR_SIZE); block = ((u64_t)(((u64_t)(w_dv->dv_base) + (position))) / (unsigned)(SECTOR_SIZE));
do_dma= wn->dma; do_dma= wn->dma;
@ -1296,7 +1296,7 @@ static ssize_t w_transfer(
/* Book the bytes successfully transferred. */ /* Book the bytes successfully transferred. */
nbytes -= n; nbytes -= n;
position= add64ul(position, n); position= ((u64_t)(position) + (n));
total += n; total += n;
addr_offset += n; addr_offset += n;
if ((iov->iov_size -= n) == 0) { if ((iov->iov_size -= n) == 0) {
@ -1368,7 +1368,7 @@ static ssize_t w_transfer(
/* Book the bytes successfully transferred. */ /* Book the bytes successfully transferred. */
nbytes -= SECTOR_SIZE; nbytes -= SECTOR_SIZE;
position= add64u(position, SECTOR_SIZE); position= ((u64_t)(position) + (SECTOR_SIZE));
addr_offset += SECTOR_SIZE; addr_offset += SECTOR_SIZE;
total += SECTOR_SIZE; total += SECTOR_SIZE;
if ((iov->iov_size -= SECTOR_SIZE) == 0) { if ((iov->iov_size -= SECTOR_SIZE) == 0) {
@ -1891,7 +1891,7 @@ static void w_geometry(dev_t minor, struct part_geom *entry)
wn = w_wn; wn = w_wn;
if (wn->state & ATAPI) { /* Make up some numbers. */ if (wn->state & ATAPI) { /* Make up some numbers. */
entry->cylinders = div64u(wn->part[0].dv_size, SECTOR_SIZE) / (64*32); entry->cylinders = ((u64_t)(wn->part[0].dv_size) / (unsigned)(SECTOR_SIZE)) / (64*32);
entry->heads = 64; entry->heads = 64;
entry->sectors = 32; entry->sectors = 32;
} else { /* Return logical geometry. */ } else { /* Return logical geometry. */
@ -1911,7 +1911,7 @@ static int atapi_open(void)
* size of the device to something big. What is really needed is a generic * size of the device to something big. What is really needed is a generic
* SCSI layer that does all this stuff for ATAPI and SCSI devices (kjb). (XXX) * SCSI layer that does all this stuff for ATAPI and SCSI devices (kjb). (XXX)
*/ */
w_wn->part[0].dv_size = mul64u(800L*1024, 1024); w_wn->part[0].dv_size = ((u64_t)(800L * 1024) * (1024));
return(OK); return(OK);
} }
@ -1985,9 +1985,9 @@ static int atapi_transfer(
/* The Minix block size is smaller than the CD block size, so we /* The Minix block size is smaller than the CD block size, so we
* may have to read extra before or after the good data. * may have to read extra before or after the good data.
*/ */
pos = add64(w_dv->dv_base, position); pos = ((u64_t)(w_dv->dv_base) + (position));
block = div64u(pos, CD_SECTOR_SIZE); block = ((u64_t)(pos) / (unsigned)(CD_SECTOR_SIZE));
before = rem64u(pos, CD_SECTOR_SIZE); before = ((u64_t)(pos) % (unsigned)(CD_SECTOR_SIZE));
if(before) if(before)
do_dma = 0; do_dma = 0;
@ -2005,7 +2005,7 @@ static int atapi_transfer(
/* Which block on disk and how close to EOF? */ /* Which block on disk and how close to EOF? */
if (cmp64(position, dv_size) >= 0) return(total); /* At EOF */ if (cmp64(position, dv_size) >= 0) return(total); /* At EOF */
if (cmp64(add64ul(position, nbytes), dv_size) > 0) if (cmp64(((u64_t)(position) + (nbytes)), dv_size) > 0)
nbytes = diff64(dv_size, position); nbytes = diff64(dv_size, position);
nblocks = (before + nbytes + CD_SECTOR_SIZE - 1) / CD_SECTOR_SIZE; nblocks = (before + nbytes + CD_SECTOR_SIZE - 1) / CD_SECTOR_SIZE;
@ -2060,7 +2060,7 @@ static int atapi_transfer(
if (chunk > iov->iov_size) if (chunk > iov->iov_size)
chunk = iov->iov_size; chunk = iov->iov_size;
position= add64ul(position, chunk); position= ((u64_t)(position) + (chunk));
nbytes -= chunk; nbytes -= chunk;
total += chunk; total += chunk;
if ((iov->iov_size -= chunk) == 0) { if ((iov->iov_size -= chunk) == 0) {
@ -2103,7 +2103,7 @@ static int atapi_transfer(
} }
if (s != OK) if (s != OK)
panic("Call to sys_insw() failed: %d", s); panic("Call to sys_insw() failed: %d", s);
position= add64ul(position, chunk); position= ((u64_t)(position) + (chunk));
nbytes -= chunk; nbytes -= chunk;
count -= chunk; count -= chunk;
addr_offset += chunk; addr_offset += chunk;

View File

@ -49,14 +49,14 @@ static size_t get_range(struct fbd_rule *rule, u64_t pos, size_t *size,
to_eof = cmp64(rule->start, rule->end) >= 0; to_eof = cmp64(rule->start, rule->end) >= 0;
if (cmp64(pos, rule->start) > 0) { if (cmp64(pos, rule->start) > 0) {
if (skip != NULL) *skip = sub64(pos, rule->start); if (skip != NULL) *skip = ((u64_t)(pos) - (rule->start));
off = 0; off = 0;
} }
else { else {
if (skip != NULL) *skip = cvu64(0); if (skip != NULL) *skip = ((u64_t)(0));
delta = sub64(rule->start, pos); delta = ((u64_t)(rule->start) - (pos));
assert(ex64hi(delta) == 0); assert(ex64hi(delta) == 0);
@ -66,7 +66,7 @@ static size_t get_range(struct fbd_rule *rule, u64_t pos, size_t *size,
if (!to_eof) { if (!to_eof) {
assert(cmp64(pos, rule->end) < 0); assert(cmp64(pos, rule->end) < 0);
delta = sub64(rule->end, pos); delta = ((u64_t)(rule->end) - (pos));
if (cmp64u(delta, *size) < 0) if (cmp64u(delta, *size) < 0)
*size = ex64lo(delta); *size = ex64lo(delta);
@ -186,16 +186,14 @@ static void action_pre_misdir(struct fbd_rule *rule, iovec_t *UNUSED(iov),
* here, because we have no idea about the actual disk size, and the * here, because we have no idea about the actual disk size, and the
* resulting address must of course be valid.. * resulting address must of course be valid..
*/ */
range = div64u(add64u(sub64(rule->params.misdir.end, range = ((u64_t)(((u64_t)(((u64_t)(rule->params.misdir.end) - (rule->params.misdir.start))) + (1))) / (unsigned)(rule->params.misdir.align));
rule->params.misdir.start), 1), rule->params.misdir.align);
if (range > 0) if (range > 0)
choice = get_rand(range - 1); choice = get_rand(range - 1);
else else
choice = 0; choice = 0;
*pos = add64(rule->params.misdir.start, *pos = ((u64_t)(rule->params.misdir.start) + (((u64_t)(choice) * (rule->params.misdir.align))));
mul64u(choice, rule->params.misdir.align));
} }
/*===========================================================================* /*===========================================================================*

View File

@ -92,7 +92,7 @@ static int rule_match(struct fbd_rule *rule, u64_t pos, size_t size, int flag)
*/ */
/* Ranges must overlap (start < pos+size && end > pos). */ /* Ranges must overlap (start < pos+size && end > pos). */
if (cmp64(rule->start, add64u(pos, size)) >= 0 || if (cmp64(rule->start, ((u64_t)(pos) + (size))) >= 0 ||
(cmp64u(rule->end, 0) && cmp64(rule->end, pos) <= 0)) (cmp64u(rule->end, 0) && cmp64(rule->end, pos) <= 0))
return FALSE; return FALSE;

View File

@ -77,8 +77,8 @@ static int driver_open(int which)
if(!size_known) { if(!size_known) {
disk_size = part.size; disk_size = part.size;
size_known = 1; size_known = 1;
sectors = div64u(disk_size, SECTOR_SIZE); sectors = ((u64_t)(disk_size) / (unsigned)(SECTOR_SIZE));
if(cmp64(mul64u(sectors, SECTOR_SIZE), disk_size)) { if(cmp64(((u64_t)(sectors) * (SECTOR_SIZE)), disk_size)) {
printf("Filter: partition too large\n"); printf("Filter: partition too large\n");
return RET_REDO; return RET_REDO;
@ -954,7 +954,7 @@ int read_write(u64_t pos, char *bufa, char *bufb, size_t *sizep, int request)
* report the driver for acting strangely! * report the driver for acting strangely!
*/ */
if (m1.BDEV_STATUS > (ssize_t) *sizep || if (m1.BDEV_STATUS > (ssize_t) *sizep ||
cmp64(add64u(pos, m1.BDEV_STATUS), disk_size) < 0) cmp64(((u64_t)(pos) + (m1.BDEV_STATUS)), disk_size) < 0)
return bad_driver(DRIVER_MAIN, BD_PROTO, EFAULT); return bad_driver(DRIVER_MAIN, BD_PROTO, EFAULT);
/* Return the actual size. */ /* Return the actual size. */
@ -976,7 +976,7 @@ int read_write(u64_t pos, char *bufa, char *bufb, size_t *sizep, int request)
/* As above */ /* As above */
if (m2.BDEV_STATUS > (ssize_t) *sizep || if (m2.BDEV_STATUS > (ssize_t) *sizep ||
cmp64(add64u(pos, m2.BDEV_STATUS), cmp64(((u64_t)(pos) + (m2.BDEV_STATUS)),
disk_size) < 0) disk_size) < 0)
return bad_driver(DRIVER_BACKUP, BD_PROTO, return bad_driver(DRIVER_BACKUP, BD_PROTO,
EFAULT); EFAULT);

View File

@ -139,7 +139,7 @@ static int do_rdwt(int flag_rw)
pos = make64(m_in.BDEV_POS_LO, m_in.BDEV_POS_HI); pos = make64(m_in.BDEV_POS_LO, m_in.BDEV_POS_HI);
size = m_in.BDEV_COUNT; size = m_in.BDEV_COUNT;
if (rem64u(pos, SECTOR_SIZE) != 0 || size % SECTOR_SIZE != 0) { if (((u64_t)(pos) % (unsigned)(SECTOR_SIZE)) != 0 || size % SECTOR_SIZE != 0) {
printf("Filter: unaligned request from caller!\n"); printf("Filter: unaligned request from caller!\n");
return EINVAL; return EINVAL;
@ -198,7 +198,7 @@ static int do_vrdwt(int flag_rw)
for(size = 0, i = 0; i < grants; i++) for(size = 0, i = 0; i < grants; i++)
size += iov_proc[i].iov_size; size += iov_proc[i].iov_size;
if (rem64u(pos, SECTOR_SIZE) != 0 || size % SECTOR_SIZE != 0) { if (((u64_t)(pos) % (unsigned)(SECTOR_SIZE)) != 0 || size % SECTOR_SIZE != 0) {
printf("Filter: unaligned request from caller!\n"); printf("Filter: unaligned request from caller!\n");
return EINVAL; return EINVAL;
} }

View File

@ -8,8 +8,8 @@
#define SEC2SUM_NR(nr) ((nr)/NR_SUM_SEC*(NR_SUM_SEC+1) + NR_SUM_SEC) #define SEC2SUM_NR(nr) ((nr)/NR_SUM_SEC*(NR_SUM_SEC+1) + NR_SUM_SEC)
#define LOG2PHYS(nr) ((nr)/NR_SUM_SEC*(NR_SUM_SEC+1) + (nr)%NR_SUM_SEC) #define LOG2PHYS(nr) ((nr)/NR_SUM_SEC*(NR_SUM_SEC+1) + (nr)%NR_SUM_SEC)
#define POS2SEC(nr) div64u((nr), SECTOR_SIZE) #define POS2SEC(nr) ((u64_t)((nr)) / (unsigned)(SECTOR_SIZE))
#define SEC2POS(nr) mul64u((nr), SECTOR_SIZE) #define SEC2POS(nr) ((u64_t)((nr)) * (SECTOR_SIZE))
/* Data buffers. */ /* Data buffers. */
static char *ext_array, *ext_buffer; /* interspersed buffer */ static char *ext_array, *ext_buffer; /* interspersed buffer */

View File

@ -410,8 +410,7 @@ static struct device *f_prepare(dev_t device)
if (f_fp->fl_density < NT) { if (f_fp->fl_density < NT) {
f_dp = &fdensity[f_fp->fl_density]; f_dp = &fdensity[f_fp->fl_density];
f_sectors = f_dp->secpt; f_sectors = f_dp->secpt;
f_fp->fl_geom.dv_size = mul64u((long) (NR_HEADS * f_sectors f_fp->fl_geom.dv_size = ((u64_t)((long)(NR_HEADS * f_sectors * f_dp->cyls)) * (SECTOR_SIZE));
* f_dp->cyls), SECTOR_SIZE);
} }
/* A partition? */ /* A partition? */
@ -461,7 +460,7 @@ static ssize_t f_transfer(
iovec_t *iop, *iov_end = iov + nr_req; iovec_t *iop, *iov_end = iov + nr_req;
int s, r, errors, nr; int s, r, errors, nr;
unsigned block, nbytes, count, chunk, sector; unsigned block, nbytes, count, chunk, sector;
unsigned long dv_size; u64_t dv_size;
vir_bytes user_offset, iov_offset = 0, iop_offset; vir_bytes user_offset, iov_offset = 0, iop_offset;
unsigned long position; unsigned long position;
signed long uoffsets[MAX_SECTORS], *up; signed long uoffsets[MAX_SECTORS], *up;
@ -472,11 +471,11 @@ static ssize_t f_transfer(
if (f_prepare(minor) == NULL) return(ENXIO); if (f_prepare(minor) == NULL) return(ENXIO);
fp = f_fp; fp = f_fp;
dv_size = cv64ul(f_dv->dv_size); dv_size = f_dv->dv_size;
if (ex64hi(pos64) != 0) if (ex64hi(pos64) != 0)
return OK; /* Way beyond EOF */ return OK; /* Way beyond EOF */
position= cv64ul(pos64); position= pos64;
total = 0; total = 0;
/* Record the direction of the last transfer performed. */ /* Record the direction of the last transfer performed. */
@ -500,7 +499,7 @@ static ssize_t f_transfer(
/* Which block on disk and how close to EOF? */ /* Which block on disk and how close to EOF? */
if (position >= dv_size) return(total); /* At EOF */ if (position >= dv_size) return(total); /* At EOF */
if (position + nbytes > dv_size) nbytes = dv_size - position; if (position + nbytes > dv_size) nbytes = dv_size - position;
block = div64u(add64ul(f_dv->dv_base, position), SECTOR_SIZE); block = ((u64_t)(((u64_t)(f_dv->dv_base) + (position))) / (unsigned)(SECTOR_SIZE));
if ((nbytes & SECTOR_MASK) != 0) return(EINVAL); if ((nbytes & SECTOR_MASK) != 0) return(EINVAL);
@ -1338,7 +1337,7 @@ static int test_read(int density)
position = (off_t) f_dp->test << SECTOR_SHIFT; position = (off_t) f_dp->test << SECTOR_SHIFT;
iovec1.iov_addr = (vir_bytes) floppy_buf; iovec1.iov_addr = (vir_bytes) floppy_buf;
iovec1.iov_size = SECTOR_SIZE; iovec1.iov_size = SECTOR_SIZE;
result = f_transfer(device, FALSE /*do_write*/, cvul64(position), SELF, result = f_transfer(device, FALSE /*do_write*/, position, SELF,
&iovec1, 1, BDEV_NOFLAGS); &iovec1, 1, BDEV_NOFLAGS);
if (result != SECTOR_SIZE) return(EIO); if (result != SECTOR_SIZE) return(EIO);

View File

@ -101,8 +101,8 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
/* Initialize log devices. */ /* Initialize log devices. */
for(i = 0; i < NR_DEVS; i++) { for(i = 0; i < NR_DEVS; i++) {
log_geom[i].dv_size = cvul64(LOG_SIZE); log_geom[i].dv_size = ((u64_t)(LOG_SIZE));
log_geom[i].dv_base = cvul64((long)logdevices[i].log_buffer); log_geom[i].dv_base = ((u64_t)((long)logdevices[i].log_buffer));
logdevices[i].log_size = logdevices[i].log_read = logdevices[i].log_size = logdevices[i].log_read =
logdevices[i].log_write = logdevices[i].log_write =
logdevices[i].log_select_alerted = logdevices[i].log_select_alerted =

View File

@ -167,16 +167,16 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
#endif #endif
/* Ramdisk image built into the memory driver */ /* Ramdisk image built into the memory driver */
m_geom[IMGRD_DEV].dv_base= cvul64(0); m_geom[IMGRD_DEV].dv_base= ((u64_t)(0));
m_geom[IMGRD_DEV].dv_size= cvul64(imgrd_size); m_geom[IMGRD_DEV].dv_size= ((u64_t)(imgrd_size));
m_vaddrs[IMGRD_DEV] = (vir_bytes) imgrd; m_vaddrs[IMGRD_DEV] = (vir_bytes) imgrd;
for(i = 0; i < NR_DEVS; i++) for(i = 0; i < NR_DEVS; i++)
openct[i] = 0; openct[i] = 0;
/* Set up memory range for /dev/mem. */ /* Set up memory range for /dev/mem. */
m_geom[MEM_DEV].dv_base = cvul64(0); m_geom[MEM_DEV].dv_base = ((u64_t)(0));
m_geom[MEM_DEV].dv_size = cvul64(0xffffffff); m_geom[MEM_DEV].dv_size = ((u64_t)(0xffffffff));
m_vaddrs[MEM_DEV] = (vir_bytes) MAP_FAILED; /* we are not mapping this in. */ m_vaddrs[MEM_DEV] = (vir_bytes) MAP_FAILED; /* we are not mapping this in. */
@ -231,20 +231,20 @@ static int m_transfer(
unsigned count; unsigned count;
vir_bytes vir_offset = 0; vir_bytes vir_offset = 0;
struct device *dv; struct device *dv;
unsigned long dv_size; u64_t dv_size;
int s, r; int s, r;
off_t position; u64_t position;
cp_grant_id_t grant; cp_grant_id_t grant;
vir_bytes dev_vaddr; vir_bytes dev_vaddr;
/* ZERO_DEV and NULL_DEV are infinite in size. */ /* ZERO_DEV and NULL_DEV are infinite in size. */
if (m_device != ZERO_DEV && m_device != NULL_DEV && ex64hi(pos64) != 0) if (m_device != ZERO_DEV && m_device != NULL_DEV && ex64hi(pos64) != 0)
return OK; /* Beyond EOF */ return OK; /* Beyond EOF */
position= cv64ul(pos64); position= pos64;
/* Get minor device number and check for /dev/null. */ /* Get minor device number and check for /dev/null. */
dv = &m_geom[m_device]; dv = &m_geom[m_device];
dv_size = cv64ul(dv->dv_size); dv_size = dv->dv_size;
dev_vaddr = m_vaddrs[m_device]; dev_vaddr = m_vaddrs[m_device];
while (nr_req > 0) { while (nr_req > 0) {
@ -435,21 +435,21 @@ static int m_block_transfer(
unsigned count; unsigned count;
vir_bytes vir_offset = 0; vir_bytes vir_offset = 0;
struct device *dv; struct device *dv;
unsigned long dv_size; u64_t dv_size;
int r; int r;
off_t position; u64_t position;
vir_bytes dev_vaddr; vir_bytes dev_vaddr;
cp_grant_id_t grant; cp_grant_id_t grant;
ssize_t total = 0; ssize_t total = 0;
/* Get minor device information. */ /* Get minor device information. */
if ((dv = m_block_part(minor)) == NULL) return(ENXIO); if ((dv = m_block_part(minor)) == NULL) return(ENXIO);
dv_size = cv64ul(dv->dv_size); dv_size = dv->dv_size;
dev_vaddr = m_vaddrs[minor]; dev_vaddr = m_vaddrs[minor];
if (ex64hi(pos64) != 0) if (ex64hi(pos64) != 0)
return OK; /* Beyond EOF */ return OK; /* Beyond EOF */
position= cv64ul(pos64); position= pos64;
while (nr_req > 0) { while (nr_req > 0) {
@ -554,7 +554,7 @@ static int m_block_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
return s; return s;
if(is_imgrd) if(is_imgrd)
ramdev_size = 0; ramdev_size = 0;
if(m_vaddrs[minor] && !cmp64(dv->dv_size, cvul64(ramdev_size))) { if(m_vaddrs[minor] && !cmp64(dv->dv_size, ((u64_t)(ramdev_size)))) {
return(OK); return(OK);
} }
/* openct is 1 for the ioctl(). */ /* openct is 1 for the ioctl(). */
@ -602,7 +602,7 @@ static int m_block_ioctl(dev_t minor, unsigned int request, endpoint_t endpt,
m_vaddrs[minor] = (vir_bytes) mem; m_vaddrs[minor] = (vir_bytes) mem;
dv->dv_size = cvul64(ramdev_size); dv->dv_size = ((u64_t)(ramdev_size));
return(OK); return(OK);
} }

View File

@ -202,7 +202,7 @@ static int r_transfer(
} }
/* Book the number of bytes transferred. */ /* Book the number of bytes transferred. */
position= add64u(position, count); position= ((u64_t)(position) + (count));
if ((iov->iov_size -= count) == 0) { iov++; nr_req--; vir_offset = 0; } if ((iov->iov_size -= count) == 0) { iov++; nr_req--; vir_offset = 0; }
} }

View File

@ -524,7 +524,7 @@ static int store_pages(int conn, int req, vbox_param_t *inp, size_t *offp)
assert(!(pvec[j].vp_addr & (PAGE_SIZE - 1))); assert(!(pvec[j].vp_addr & (PAGE_SIZE - 1)));
pagelist->addr[pagelist->count++] = pagelist->addr[pagelist->count++] =
cvul64(pvec[j].vp_addr); ((u64_t)(pvec[j].vp_addr));
if (pvec[j].vp_size > PAGE_SIZE) { if (pvec[j].vp_size > PAGE_SIZE) {
pvec[j].vp_addr += PAGE_SIZE; pvec[j].vp_addr += PAGE_SIZE;

View File

@ -161,7 +161,7 @@ static void vbox_update_time(void)
sizeof(*req)) == VMMDEV_ERR_OK) { sizeof(*req)) == VMMDEV_ERR_OK) {
time(&otime); /* old time */ time(&otime); /* old time */
ntime = div64u(req->time, 1000); /* new time */ ntime = ((u64_t)(req->time) / (unsigned)(1000)); /* new time */
/* Make time go forward, if the difference exceeds the drift /* Make time go forward, if the difference exceeds the drift
* threshold. Never make time go backward. * threshold. Never make time go backward.

View File

@ -13,21 +13,6 @@
#define make_zero64(i) ((i) = 0) #define make_zero64(i) ((i) = 0)
#define neg64(i) ((i) = -(i)) #define neg64(i) ((i) = -(i))
static inline u64_t add64(u64_t i, u64_t j)
{
return i + j;
}
static inline u64_t add64u(u64_t i, unsigned j)
{
return i + j;
}
static inline u64_t add64ul(u64_t i, unsigned long j)
{
return i + j;
}
static inline int bsr64(u64_t i) static inline int bsr64(u64_t i)
{ {
int index; int index;
@ -71,64 +56,6 @@ static inline int cmp64ul(u64_t i, unsigned long j)
return 0; return 0;
} }
static inline unsigned cv64u(u64_t i)
{
/* return ULONG_MAX if really big */
if (i>>32)
return ULONG_MAX;
return (unsigned)i;
}
static inline unsigned long cv64ul(u64_t i)
{
/* return ULONG_MAX if really big */
if (i>>32)
return ULONG_MAX;
return (unsigned long)i;
}
static inline u64_t cvu64(unsigned i)
{
return i;
}
static inline u64_t cvul64(unsigned long i)
{
return i;
}
static inline unsigned diff64(u64_t i, u64_t j)
{
return (unsigned)(i - j);
}
static inline u64_t div64(u64_t i, u64_t j)
{
return i / j;
}
static inline u64_t rem64(u64_t i, u64_t j)
{
return i % j;
}
static inline unsigned long div64u(u64_t i, unsigned j)
{
return (unsigned long)(i / j);
}
static inline u64_t div64u64(u64_t i, unsigned j)
{
return i / j;
}
static inline unsigned rem64u(u64_t i, unsigned j)
{
return (unsigned)(i % j);
}
static inline unsigned long ex64lo(u64_t i) static inline unsigned long ex64lo(u64_t i)
{ {
return (unsigned long)i; return (unsigned long)i;
@ -144,31 +71,6 @@ static inline u64_t make64(unsigned long lo, unsigned long hi)
return ((u64_t)hi << 32) | (u64_t)lo; return ((u64_t)hi << 32) | (u64_t)lo;
} }
static inline u64_t mul64(u64_t i, u64_t j)
{
return i * j;
}
static inline u64_t mul64u(unsigned long i, unsigned j)
{
return (u64_t)i * j;
}
static inline u64_t sub64(u64_t i, u64_t j)
{
return i - j;
}
static inline u64_t sub64u(u64_t i, unsigned j)
{
return i - j;
}
static inline u64_t sub64ul(u64_t i, unsigned long j)
{
return i - j;
}
u64_t rrotate64(u64_t x, unsigned short b); u64_t rrotate64(u64_t x, unsigned short b);
u64_t rshift64(u64_t x, unsigned short b); u64_t rshift64(u64_t x, unsigned short b);
u64_t xor64(u64_t a, u64_t b); u64_t xor64(u64_t a, u64_t b);

View File

@ -66,13 +66,13 @@ void context_stop(struct proc * p)
if(kbill_ipc) { if(kbill_ipc) {
kbill_ipc->p_kipc_cycles = kbill_ipc->p_kipc_cycles =
add64(kbill_ipc->p_kipc_cycles, tsc_delta); ((u64_t)(kbill_ipc->p_kipc_cycles) + (tsc_delta));
kbill_ipc = NULL; kbill_ipc = NULL;
} }
if(kbill_kcall) { if(kbill_kcall) {
kbill_kcall->p_kcall_cycles = kbill_kcall->p_kcall_cycles =
add64(kbill_kcall->p_kcall_cycles, tsc_delta); ((u64_t)(kbill_kcall->p_kcall_cycles) + (tsc_delta));
kbill_kcall = NULL; kbill_kcall = NULL;
} }
@ -125,12 +125,12 @@ int register_local_timer_handler(const irq_handler_t handler)
u64_t ms_2_cpu_time(unsigned ms) u64_t ms_2_cpu_time(unsigned ms)
{ {
return mul64u(tsc_per_ms[cpuid], ms); return ((u64_t)(tsc_per_ms[cpuid]) * (ms));
} }
unsigned cpu_time_2_ms(u64_t cpu_time) unsigned cpu_time_2_ms(u64_t cpu_time)
{ {
return div64u(cpu_time, tsc_per_ms[cpuid]); return ((u64_t)(cpu_time) / (unsigned)(tsc_per_ms[cpuid]));
} }
short cpu_load(void) short cpu_load(void)

View File

@ -515,14 +515,14 @@ static void apic_calibrate_clocks(unsigned cpu)
rm_irq_handler(&spurious_irq); rm_irq_handler(&spurious_irq);
lapic_delta = lapic_tctr0 - lapic_tctr1; lapic_delta = lapic_tctr0 - lapic_tctr1;
tsc_delta = sub64(tsc1, tsc0); tsc_delta = ((u64_t)(tsc1) - (tsc0));
lapic_bus_freq[cpuid] = system_hz * lapic_delta / (PROBE_TICKS - 1); lapic_bus_freq[cpuid] = system_hz * lapic_delta / (PROBE_TICKS - 1);
BOOT_VERBOSE(printf("APIC bus freq %u MHz\n", BOOT_VERBOSE(printf("APIC bus freq %u MHz\n",
lapic_bus_freq[cpuid] / 1000000)); lapic_bus_freq[cpuid] / 1000000));
cpu_freq = mul64(div64u64(tsc_delta, PROBE_TICKS - 1), make64(system_hz, 0)); cpu_freq = ((u64_t)(((u64_t)(tsc_delta) / (unsigned)(PROBE_TICKS - 1))) * (make64(system_hz, 0)));
cpu_set_freq(cpuid, cpu_freq); cpu_set_freq(cpuid, cpu_freq);
cpu_info[cpuid].freq = div64u(cpu_freq, 1000000); cpu_info[cpuid].freq = ((u64_t)(cpu_freq) / (unsigned)(1000000));
BOOT_VERBOSE(cpu_print_freq(cpuid)); BOOT_VERBOSE(cpu_print_freq(cpuid));
} }

View File

@ -119,11 +119,11 @@ static void estimate_cpu_freq(void)
/* remove the probe */ /* remove the probe */
rm_irq_handler(&calib_cpu); rm_irq_handler(&calib_cpu);
tsc_delta = sub64(tsc1, tsc0); tsc_delta = ((u64_t)(tsc1) - (tsc0));
cpu_freq = mul64(div64u64(tsc_delta, PROBE_TICKS - 1), make64(system_hz, 0)); cpu_freq = ((u64_t)(((u64_t)(tsc_delta) / (unsigned)(PROBE_TICKS - 1))) * (make64(system_hz, 0)));
cpu_set_freq(cpuid, cpu_freq); cpu_set_freq(cpuid, cpu_freq);
cpu_info[cpuid].freq = div64u(cpu_freq, 1000000); cpu_info[cpuid].freq = ((u64_t)(cpu_freq) / (unsigned)(1000000));
BOOT_VERBOSE(cpu_print_freq(cpuid)); BOOT_VERBOSE(cpu_print_freq(cpuid));
} }
@ -223,9 +223,9 @@ void context_stop(struct proc * p)
u64_t tmp; u64_t tmp;
read_tsc_64(&tsc); read_tsc_64(&tsc);
tmp = sub64(tsc, *__tsc_ctr_switch); tmp = ((u64_t)(tsc) - (*__tsc_ctr_switch));
kernel_ticks[cpu] = add64(kernel_ticks[cpu], tmp); kernel_ticks[cpu] = ((u64_t)(kernel_ticks[cpu]) + (tmp));
p->p_cycles = add64(p->p_cycles, tmp); p->p_cycles = ((u64_t)(p->p_cycles) + (tmp));
must_bkl_unlock = 1; must_bkl_unlock = 1;
} else { } else {
u64_t bkl_tsc; u64_t bkl_tsc;
@ -239,11 +239,11 @@ void context_stop(struct proc * p)
read_tsc_64(&tsc); read_tsc_64(&tsc);
bkl_ticks[cpu] = add64(bkl_ticks[cpu], sub64(tsc, bkl_tsc)); bkl_ticks[cpu] = ((u64_t)(bkl_ticks[cpu]) + (((u64_t)(tsc) - (bkl_tsc))));
bkl_tries[cpu]++; bkl_tries[cpu]++;
bkl_succ[cpu] += !(!(succ == 0)); bkl_succ[cpu] += !(!(succ == 0));
p->p_cycles = add64(p->p_cycles, sub64(tsc, *__tsc_ctr_switch)); p->p_cycles = ((u64_t)(p->p_cycles) + (((u64_t)(tsc) - (*__tsc_ctr_switch))));
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
/* /*
@ -261,20 +261,20 @@ void context_stop(struct proc * p)
} }
#else #else
read_tsc_64(&tsc); read_tsc_64(&tsc);
p->p_cycles = add64(p->p_cycles, sub64(tsc, *__tsc_ctr_switch)); p->p_cycles = ((u64_t)(p->p_cycles) + (((u64_t)(tsc) - (*__tsc_ctr_switch))));
#endif #endif
tsc_delta = sub64(tsc, *__tsc_ctr_switch); tsc_delta = ((u64_t)(tsc) - (*__tsc_ctr_switch));
if(kbill_ipc) { if(kbill_ipc) {
kbill_ipc->p_kipc_cycles = kbill_ipc->p_kipc_cycles =
add64(kbill_ipc->p_kipc_cycles, tsc_delta); ((u64_t)(kbill_ipc->p_kipc_cycles) + (tsc_delta));
kbill_ipc = NULL; kbill_ipc = NULL;
} }
if(kbill_kcall) { if(kbill_kcall) {
kbill_kcall->p_kcall_cycles = kbill_kcall->p_kcall_cycles =
add64(kbill_kcall->p_kcall_cycles, tsc_delta); ((u64_t)(kbill_kcall->p_kcall_cycles) + (tsc_delta));
kbill_kcall = NULL; kbill_kcall = NULL;
} }
@ -291,7 +291,7 @@ void context_stop(struct proc * p)
if (ex64hi(tsc_delta) < ex64hi(p->p_cpu_time_left) || if (ex64hi(tsc_delta) < ex64hi(p->p_cpu_time_left) ||
(ex64hi(tsc_delta) == ex64hi(p->p_cpu_time_left) && (ex64hi(tsc_delta) == ex64hi(p->p_cpu_time_left) &&
ex64lo(tsc_delta) < ex64lo(p->p_cpu_time_left))) ex64lo(tsc_delta) < ex64lo(p->p_cpu_time_left)))
p->p_cpu_time_left = sub64(p->p_cpu_time_left, tsc_delta); p->p_cpu_time_left = ((u64_t)(p->p_cpu_time_left) - (tsc_delta));
else { else {
make_zero64(p->p_cpu_time_left); make_zero64(p->p_cpu_time_left);
} }
@ -329,12 +329,12 @@ void context_stop_idle(void)
u64_t ms_2_cpu_time(unsigned ms) u64_t ms_2_cpu_time(unsigned ms)
{ {
return mul64u(tsc_per_ms[cpuid], ms); return ((u64_t)(tsc_per_ms[cpuid]) * (ms));
} }
unsigned cpu_time_2_ms(u64_t cpu_time) unsigned cpu_time_2_ms(u64_t cpu_time)
{ {
return div64u(cpu_time, tsc_per_ms[cpuid]); return ((u64_t)(cpu_time) / (unsigned)(tsc_per_ms[cpuid]));
} }
short cpu_load(void) short cpu_load(void)
@ -358,12 +358,12 @@ short cpu_load(void)
/* calculate load since last cpu_load invocation */ /* calculate load since last cpu_load invocation */
if (!is_zero64(*last_tsc)) { if (!is_zero64(*last_tsc)) {
tsc_delta = sub64(current_tsc, *last_tsc); tsc_delta = ((u64_t)(current_tsc) - (*last_tsc));
idle_delta = sub64(*current_idle, *last_idle); idle_delta = ((u64_t)(*current_idle) - (*last_idle));
busy = sub64(tsc_delta, idle_delta); busy = ((u64_t)(tsc_delta) - (idle_delta));
busy = mul64(busy, make64(100, 0)); busy = ((u64_t)(busy) * (make64(100, 0)));
load = ex64lo(div64(busy, tsc_delta)); load = ex64lo(((u64_t)(busy) / (unsigned)(tsc_delta)));
if (load > 100) if (load > 100)
load = 100; load = 100;

View File

@ -33,7 +33,7 @@ static void intel_arch_watchdog_init(const unsigned cpu)
*/ */
cpuf = cpu_get_freq(cpu); cpuf = cpu_get_freq(cpu);
while (ex64hi(cpuf) || ex64lo(cpuf) > 0x7fffffffU) while (ex64hi(cpuf) || ex64lo(cpuf) > 0x7fffffffU)
cpuf = div64u64(cpuf, 2); cpuf = ((u64_t)(cpuf) / (unsigned)(2));
cpuf = make64(-ex64lo(cpuf), ex64hi(cpuf)); cpuf = make64(-ex64lo(cpuf), ex64hi(cpuf));
watchdog->resetval = watchdog->watchdog_resetval = cpuf; watchdog->resetval = watchdog->watchdog_resetval = cpuf;
@ -159,7 +159,7 @@ static int intel_arch_watchdog_profile_init(const unsigned freq)
/* FIXME works only if all CPUs have the same freq */ /* FIXME works only if all CPUs have the same freq */
cpuf = cpu_get_freq(cpuid); cpuf = cpu_get_freq(cpuid);
cpuf = div64u64(cpuf, freq); cpuf = ((u64_t)(cpuf) / (unsigned)(freq));
/* /*
* if freq is too low and the cpu freq too high we may get in a range of * if freq is too low and the cpu freq too high we may get in a range of
@ -224,7 +224,7 @@ static int amd_watchdog_profile_init(const unsigned freq)
/* FIXME works only if all CPUs have the same freq */ /* FIXME works only if all CPUs have the same freq */
cpuf = cpu_get_freq(cpuid); cpuf = cpu_get_freq(cpuid);
cpuf = div64u64(cpuf, freq); cpuf = ((u64_t)(cpuf) / (unsigned)(freq));
neg64(cpuf); neg64(cpuf);
watchdog->profile_resetval = cpuf; watchdog->profile_resetval = cpuf;

View File

@ -505,7 +505,7 @@ void cpu_print_freq(unsigned cpu)
u64_t freq; u64_t freq;
freq = cpu_get_freq(cpu); freq = cpu_get_freq(cpu);
printf("CPU %d freq %lu MHz\n", cpu, div64u(freq, 1000000)); printf("CPU %d freq %lu MHz\n", cpu, ((u64_t)(freq) / (unsigned)(1000000)));
} }
int is_fpu(void) int is_fpu(void)

View File

@ -1691,9 +1691,8 @@ void dequeue(struct proc *rp)
at a time. */ at a time. */
if (!is_zero64(rp->p_accounting.enter_queue)) { if (!is_zero64(rp->p_accounting.enter_queue)) {
read_tsc_64(&tsc); read_tsc_64(&tsc);
tsc_delta = sub64(tsc, rp->p_accounting.enter_queue); tsc_delta = ((u64_t)(tsc) - (rp->p_accounting.enter_queue));
rp->p_accounting.time_in_queue = add64(rp->p_accounting.time_in_queue, rp->p_accounting.time_in_queue = ((u64_t)(rp->p_accounting.time_in_queue) + (tsc_delta));
tsc_delta);
make_zero64(rp->p_accounting.enter_queue); make_zero64(rp->p_accounting.enter_queue);
} }

View File

@ -29,8 +29,7 @@ static void update_idle_time(void)
idl->p_cycles = make64(0, 0); idl->p_cycles = make64(0, 0);
for (i = 0; i < CONFIG_MAX_CPUS ; i++) { for (i = 0; i < CONFIG_MAX_CPUS ; i++) {
idl->p_cycles = add64(idl->p_cycles, idl->p_cycles = ((u64_t)(idl->p_cycles) + (get_cpu_var(i, idle_proc).p_cycles));
get_cpu_var(i, idle_proc).p_cycles);
} }
} }

View File

@ -290,7 +290,7 @@ static int do_dioctl(struct blockdriver *bdp, dev_t minor,
(*bdp->bdr_geometry)(minor, &entry); (*bdp->bdr_geometry)(minor, &entry);
} else { } else {
/* The driver doesn't care -- make up fake geometry. */ /* The driver doesn't care -- make up fake geometry. */
entry.cylinders = div64u(entry.size, SECTOR_SIZE); entry.cylinders = ((u64_t)(entry.size) / (unsigned)(SECTOR_SIZE));
entry.heads = 64; entry.heads = 64;
entry.sectors = 32; entry.sectors = 32;
} }

View File

@ -73,8 +73,8 @@ u8_t *tmp_buf; /* temporary buffer */
/* Get the geometry of the device to partition */ /* Get the geometry of the device to partition */
if ((dv = (*bdp->bdr_part)(device)) == NULL if ((dv = (*bdp->bdr_part)(device)) == NULL
|| cmp64u(dv->dv_size, 0) == 0) return; || cmp64u(dv->dv_size, 0) == 0) return;
base = div64u(dv->dv_base, SECTOR_SIZE); base = ((u64_t)(dv->dv_base) / (unsigned)(SECTOR_SIZE));
limit = base + div64u(dv->dv_size, SECTOR_SIZE); limit = base + ((u64_t)(dv->dv_size) / (unsigned)(SECTOR_SIZE));
/* Read the partition table for the device. */ /* Read the partition table for the device. */
if(!get_part_table(bdp, device, 0L, table, tmp_buf)) { if(!get_part_table(bdp, device, 0L, table, tmp_buf)) {
@ -109,8 +109,8 @@ u8_t *tmp_buf; /* temporary buffer */
if (pe->lowsec < base) pe->lowsec = base; if (pe->lowsec < base) pe->lowsec = base;
if (part_limit < pe->lowsec) part_limit = pe->lowsec; if (part_limit < pe->lowsec) part_limit = pe->lowsec;
dv->dv_base = mul64u(pe->lowsec, SECTOR_SIZE); dv->dv_base = ((u64_t)(pe->lowsec) * (SECTOR_SIZE));
dv->dv_size = mul64u(part_limit - pe->lowsec, SECTOR_SIZE); dv->dv_size = ((u64_t)(part_limit - pe->lowsec) * (SECTOR_SIZE));
if (style == P_PRIMARY) { if (style == P_PRIMARY) {
/* Each Minix primary partition can be subpartitioned. */ /* Each Minix primary partition can be subpartitioned. */
@ -163,9 +163,8 @@ u8_t *tmp_buf; /* temporary buffer */
if (pe->sysind != NO_PART) { if (pe->sysind != NO_PART) {
if ((dv = (*bdp->bdr_part)(subdev)) == NULL) return; if ((dv = (*bdp->bdr_part)(subdev)) == NULL) return;
dv->dv_base = mul64u(extbase + offset + pe->lowsec, dv->dv_base = ((u64_t)(extbase + offset + pe->lowsec) * (SECTOR_SIZE));
SECTOR_SIZE); dv->dv_size = ((u64_t)(pe->size) * (SECTOR_SIZE));
dv->dv_size = mul64u(pe->size, SECTOR_SIZE);
/* Out of devices? */ /* Out of devices? */
if (++subdev % NR_PARTITIONS == 0) return; if (++subdev % NR_PARTITIONS == 0) return;
@ -191,7 +190,7 @@ u8_t *tmp_buf; /* temporary buffer */
u64_t position; u64_t position;
int r; int r;
position = mul64u(offset, SECTOR_SIZE); position = ((u64_t)(offset) * (SECTOR_SIZE));
iovec1.iov_addr = (vir_bytes) tmp_buf; iovec1.iov_addr = (vir_bytes) tmp_buf;
iovec1.iov_size = CD_SECTOR_SIZE; iovec1.iov_size = CD_SECTOR_SIZE;
r = (*bdp->bdr_transfer)(device, FALSE /*do_write*/, position, SELF, r = (*bdp->bdr_transfer)(device, FALSE /*do_write*/, position, SELF,

View File

@ -40,7 +40,7 @@ static u32_t trace_gettime(void)
read_tsc_64(&tsc); read_tsc_64(&tsc);
tsc = sub64(tsc, trace_tsc); tsc = ((u64_t)(tsc) - (trace_tsc));
return tsc_64_to_micros(tsc); return tsc_64_to_micros(tsc);
} }
@ -195,7 +195,7 @@ void trace_start(thread_id_t id, message *m_ptr)
switch (m_ptr->m_type) { switch (m_ptr->m_type) {
case BDEV_OPEN: case BDEV_OPEN:
case BDEV_CLOSE: case BDEV_CLOSE:
pos = cvu64(0); pos = ((u64_t)(0));
size = m_ptr->BDEV_ACCESS; size = m_ptr->BDEV_ACCESS;
flags = 0; flags = 0;
@ -212,7 +212,7 @@ void trace_start(thread_id_t id, message *m_ptr)
break; break;
case BDEV_IOCTL: case BDEV_IOCTL:
pos = cvu64(0); pos = ((u64_t)(0));
size = m_ptr->BDEV_REQUEST; size = m_ptr->BDEV_REQUEST;
flags = 0; flags = 0;

View File

@ -41,9 +41,9 @@ u64_t *bytes;
perror("sizeup ioctl"); perror("sizeup ioctl");
if(fstat(fd, &st) < 0) { if(fstat(fd, &st) < 0) {
perror("fstat"); perror("fstat");
entry.size = cvu64(0); entry.size = ((u64_t)(0));
} else { } else {
entry.size = cvu64(st.st_size); entry.size = ((u64_t)(st.st_size));
} }
} }
close(fd); close(fd);

View File

@ -18,7 +18,7 @@ void time_init(void)
* the difference between that time and the UNIX epoch, in 100ns units. * the difference between that time and the UNIX epoch, in 100ns units.
*/ */
/* FIXME: we currently do not take into account timezones. */ /* FIXME: we currently do not take into account timezones. */
time_offset = mul64u(116444736, 1000000000); time_offset = ((u64_t)(116444736) * (1000000000));
} }
/*===========================================================================* /*===========================================================================*
@ -33,8 +33,8 @@ void time_put(struct timespec *tsp)
u64_t hgfstime; u64_t hgfstime;
if (tsp != NULL) { if (tsp != NULL) {
hgfstime = add64ul(mul64u(tsp->tv_sec, 10000000), tsp->tv_nsec / 100); hgfstime = ((u64_t)(((u64_t)(tsp->tv_sec) * (10000000))) + (tsp->tv_nsec / 100));
hgfstime = add64(hgfstime, time_offset); hgfstime = ((u64_t)(hgfstime) + (time_offset));
RPC_NEXT32 = ex64lo(hgfstime); RPC_NEXT32 = ex64lo(hgfstime);
RPC_NEXT32 = ex64hi(hgfstime); RPC_NEXT32 = ex64hi(hgfstime);
@ -60,10 +60,10 @@ void time_get(struct timespec *tsp)
time_lo = RPC_NEXT32; time_lo = RPC_NEXT32;
time_hi = RPC_NEXT32; time_hi = RPC_NEXT32;
hgfstime = sub64(make64(time_lo, time_hi), time_offset); hgfstime = ((u64_t)(make64(time_lo, time_hi)) - (time_offset));
tsp->tv_sec = div64u(hgfstime, 10000000); tsp->tv_sec = ((u64_t)(hgfstime) / (unsigned)(10000000));
tsp->tv_nsec = rem64u(hgfstime, 10000000) * 100; tsp->tv_nsec = ((u64_t)(hgfstime) % (unsigned)(10000000)) * 100;
} }
else RPC_ADVANCE(sizeof(u32_t) * 2); else RPC_ADVANCE(sizeof(u32_t) * 2);
} }

View File

@ -75,8 +75,8 @@ u32_t fs_bufs_heuristic(int minbufs, u32_t btotal, u32_t bfree,
vsi.vsi_pagesize / 1024; vsi.vsi_pagesize / 1024;
/* check fs usage. */ /* check fs usage. */
kbytes_used_fs = div64u(mul64u(bused, blocksize), 1024); kbytes_used_fs = ((u64_t)(((u64_t)(bused) * (blocksize))) / (unsigned)(1024));
kbytes_total_fs = div64u(mul64u(btotal, blocksize), 1024); kbytes_total_fs = ((u64_t)(((u64_t)(btotal) * (blocksize))) / (unsigned)(1024));
/* heuristic for a desired cache size based on FS usage; /* heuristic for a desired cache size based on FS usage;
* but never bigger than half of the total filesystem * but never bigger than half of the total filesystem
@ -512,7 +512,7 @@ register struct buf *bp; /* buffer pointer */
ASSERT(fs_block_size > 0); ASSERT(fs_block_size > 0);
ASSERT(!(fs_block_size % PAGE_SIZE)); ASSERT(!(fs_block_size % PAGE_SIZE));
pos = mul64u(bp->lmfs_blocknr, fs_block_size); pos = ((u64_t)(bp->lmfs_blocknr) * (fs_block_size));
if(fs_block_size > PAGE_SIZE) { if(fs_block_size > PAGE_SIZE) {
#define MAXPAGES 20 #define MAXPAGES 20
vir_bytes vaddr = (vir_bytes) bp->data; vir_bytes vaddr = (vir_bytes) bp->data;
@ -674,7 +674,7 @@ void lmfs_rw_scattered(
assert(nblocks > 0); assert(nblocks > 0);
assert(niovecs > 0); assert(niovecs > 0);
pos = mul64u(bufq[0]->lmfs_blocknr, fs_block_size); pos = ((u64_t)(bufq[0]->lmfs_blocknr) * (fs_block_size));
if (rw_flag == READING) if (rw_flag == READING)
r = bdev_gather(dev, pos, iovec, niovecs, BDEV_NOFLAGS); r = bdev_gather(dev, pos, iovec, niovecs, BDEV_NOFLAGS);
else else

View File

@ -62,8 +62,8 @@ int do_statvfs()
*/ */
statvfs.f_bsize = BLOCK_SIZE; statvfs.f_bsize = BLOCK_SIZE;
statvfs.f_frsize = BLOCK_SIZE; statvfs.f_frsize = BLOCK_SIZE;
statvfs.f_blocks = div64u(total, BLOCK_SIZE); statvfs.f_blocks = ((u64_t)(total) / (unsigned)(BLOCK_SIZE));
statvfs.f_bfree = div64u(free, BLOCK_SIZE); statvfs.f_bfree = ((u64_t)(free) / (unsigned)(BLOCK_SIZE));
statvfs.f_bavail = statvfs.f_bfree; statvfs.f_bavail = statvfs.f_bfree;
statvfs.f_files = 0; statvfs.f_files = 0;
statvfs.f_ffree = 0; statvfs.f_ffree = 0;

View File

@ -61,7 +61,7 @@ int do_read()
count -= chunk; count -= chunk;
off += chunk; off += chunk;
pos = add64u(pos, chunk); pos = ((u64_t)(pos) + (chunk));
} }
if (r < 0) if (r < 0)

View File

@ -64,7 +64,7 @@ cp_grant_id_t *grantp;
count -= r; count -= r;
off += r; off += r;
pos = add64u(pos, r); pos = ((u64_t)(pos) + (r));
} }
if (r < 0) if (r < 0)
@ -151,7 +151,7 @@ int do_ftrunc()
/* Write zeroes to the file. We can't create holes. */ /* Write zeroes to the file. We can't create holes. */
if (cmp64(end, start) <= 0) return EINVAL; if (cmp64(end, start) <= 0) return EINVAL;
delta = sub64(end, start); delta = ((u64_t)(end) - (start));
if (ex64hi(delta) != 0) return EINVAL; if (ex64hi(delta) != 0) return EINVAL;

View File

@ -67,8 +67,8 @@ double getidle(void)
if ((r = sys_getidletsc(&idle2)) != OK) if ((r = sys_getidletsc(&idle2)) != OK)
return -1.0; return -1.0;
idelta = sub64(idle2, idle); idelta = ((u64_t)(idle2) - (idle));
tdelta = sub64(stop, start); tdelta = ((u64_t)(stop) - (start));
if (cmp64(idelta, tdelta) >= 0) if (cmp64(idelta, tdelta) >= 0)
return 100.0; return 100.0;

View File

@ -191,13 +191,12 @@ void procexit (char *UNUSED(name))
*/ */
/* Calculate "small" difference. */ /* Calculate "small" difference. */
spent = sub64(stop, cprof_stk[cprof_stk_top].start_2); spent = ((u64_t)(stop) - (cprof_stk[cprof_stk_top].start_2));
cprof_stk[cprof_stk_top].slot->cycles = cprof_stk[cprof_stk_top].slot->cycles =
add64(cprof_stk[cprof_stk_top].slot->cycles, ((u64_t)(cprof_stk[cprof_stk_top].slot->cycles) + (((u64_t)(spent) - (cprof_stk[cprof_stk_top].spent_deeper))));
sub64(spent, cprof_stk[cprof_stk_top].spent_deeper));
/* Clear spent_deeper for call level we're leaving. */ /* Clear spent_deeper for call level we're leaving. */
cprof_stk[cprof_stk_top].spent_deeper = cvu64(0); cprof_stk[cprof_stk_top].spent_deeper = ((u64_t)(0));
/* Adjust call path string and stack. */ /* Adjust call path string and stack. */
cpath_len = cprof_stk[cprof_stk_top].cpath_len; cpath_len = cprof_stk[cprof_stk_top].cpath_len;
@ -217,11 +216,11 @@ void procexit (char *UNUSED(name))
stop = make64(tsc_lo, tsc_hi); stop = make64(tsc_lo, tsc_hi);
/* Calculate "big" difference. */ /* Calculate "big" difference. */
spent = sub64(stop, cprof_stk[cprof_stk_top].start_1); spent = ((u64_t)(stop) - (cprof_stk[cprof_stk_top].start_1));
cprof_stk_top--; /* decrease stack */ cprof_stk_top--; /* decrease stack */
if (cprof_stk_top >= 0) /* don't update non-existent level -1 */ if (cprof_stk_top >= 0) /* don't update non-existent level -1 */
cprof_stk[cprof_stk_top].spent_deeper = cprof_stk[cprof_stk_top].spent_deeper =
add64(cprof_stk[cprof_stk_top].spent_deeper, spent); ((u64_t)(cprof_stk[cprof_stk_top].spent_deeper) + (spent));
cprof_locked = 0; cprof_locked = 0;
} }
@ -242,9 +241,9 @@ static void cprof_init()
for (i=0; i<CPROF_STACK_SIZE; i++) { for (i=0; i<CPROF_STACK_SIZE; i++) {
cprof_stk[i].cpath_len = 0; cprof_stk[i].cpath_len = 0;
cprof_stk[i].slot = 0; cprof_stk[i].slot = 0;
cprof_stk[i].start_1 = cvu64(0); cprof_stk[i].start_1 = ((u64_t)(0));
cprof_stk[i].start_2 = cvu64(0); cprof_stk[i].start_2 = ((u64_t)(0));
cprof_stk[i].spent_deeper = cvu64(0); cprof_stk[i].spent_deeper = ((u64_t)(0));
} }
} }

View File

@ -61,7 +61,7 @@ int spin_check(spin_t *s)
case STATE_TS: case STATE_TS:
read_tsc_64(&cur_tsc); read_tsc_64(&cur_tsc);
tsc_delta = sub64(cur_tsc, s->s_base_tsc); tsc_delta = ((u64_t)(cur_tsc) - (s->s_base_tsc));
micro_delta = tsc_64_to_micros(tsc_delta); micro_delta = tsc_64_to_micros(tsc_delta);

View File

@ -63,7 +63,7 @@ micro_delay(u32_t micros)
CALIBRATE; CALIBRATE;
/* We have to know when to end the delay. */ /* We have to know when to end the delay. */
end = add64(now, mul64u(micros, calib_mhz)); end = ((u64_t)(now) + (((u64_t)(micros) * (calib_mhz))));
/* If we have to wait for at least one HZ tick, use the regular /* If we have to wait for at least one HZ tick, use the regular
* tickdelay first. Round downwards on purpose, so the average * tickdelay first. Round downwards on purpose, so the average
@ -87,7 +87,7 @@ u32_t tsc_64_to_micros(u64_t tsc)
CALIBRATE; CALIBRATE;
tmp = div64u64(tsc, calib_mhz); tmp = ((u64_t)(tsc) / (unsigned)(calib_mhz));
if (ex64hi(tmp)) { if (ex64hi(tmp)) {
printf("tsc_64_to_micros: more than 2^32ms\n"); printf("tsc_64_to_micros: more than 2^32ms\n");
return ~0UL; return ~0UL;

View File

@ -31,7 +31,7 @@ micros_to_ticks(u32_t micros)
{ {
u32_t ticks; u32_t ticks;
ticks = div64u(mul64u(micros, sys_hz()), 1000000); ticks = ((u64_t)(((u64_t)(micros) * (sys_hz()))) / (unsigned)(1000000));
if(ticks < 1) ticks = 1; if(ticks < 1) ticks = 1;
return ticks; return ticks;

View File

@ -10,8 +10,8 @@ static void
get_time(struct timespec *tsp, u64_t nsecs) get_time(struct timespec *tsp, u64_t nsecs)
{ {
tsp->tv_sec = div64u(nsecs, 1000000000); tsp->tv_sec = ((u64_t)(nsecs) / (unsigned)(1000000000));
tsp->tv_nsec = rem64u(nsecs, 1000000000); tsp->tv_nsec = ((u64_t)(nsecs) % (unsigned)(1000000000));
} }
/* /*
@ -21,7 +21,7 @@ static u64_t
set_time(struct timespec *tsp) set_time(struct timespec *tsp)
{ {
return add64u(mul64u(tsp->tv_sec, 1000000000), tsp->tv_nsec); return ((u64_t)(((u64_t)(tsp->tv_sec) * (1000000000))) + (tsp->tv_nsec));
} }
/* /*

View File

@ -93,7 +93,7 @@ int fs_readwrite(void)
} }
/* Read or write 'chunk' bytes. */ /* Read or write 'chunk' bytes. */
r = rw_chunk(rip, cvul64((unsigned long) position), off, chunk, r = rw_chunk(rip, ((u64_t)((unsigned long)position)), off, chunk,
nrbytes, rw_flag, gid, cum_io, block_size, &completed); nrbytes, rw_flag, gid, cum_io, block_size, &completed);
if (r != OK) break; /* EOF reached */ if (r != OK) break; /* EOF reached */
@ -174,7 +174,7 @@ int fs_breadwrite(void)
cum_io = 0; cum_io = 0;
/* Split the transfer into chunks that don't span two blocks. */ /* Split the transfer into chunks that don't span two blocks. */
while (nrbytes > 0) { while (nrbytes > 0) {
off = rem64u(position, block_size); /* offset in blk*/ off = ((u64_t)(position) % (unsigned)(block_size)); /* offset in blk*/
chunk = min(nrbytes, block_size - off); chunk = min(nrbytes, block_size - off);
/* Read or write 'chunk' bytes. */ /* Read or write 'chunk' bytes. */
@ -187,7 +187,7 @@ int fs_breadwrite(void)
/* Update counters and pointers. */ /* Update counters and pointers. */
nrbytes -= chunk; /* bytes yet to be read */ nrbytes -= chunk; /* bytes yet to be read */
cum_io += chunk; /* bytes read so far */ cum_io += chunk; /* bytes read so far */
position = add64ul(position, chunk); /* position within the file */ position = ((u64_t)(position) + (chunk)); /* position within the file */
} }
fs_m_out.RES_SEEK_POS_LO = ex64lo(position); fs_m_out.RES_SEEK_POS_LO = ex64lo(position);
@ -239,7 +239,7 @@ int *completed; /* number of bytes copied */
block_spec = (rip->i_mode & I_TYPE) == I_BLOCK_SPECIAL; block_spec = (rip->i_mode & I_TYPE) == I_BLOCK_SPECIAL;
if (block_spec) { if (block_spec) {
b = div64u(position, block_size); b = ((u64_t)(position) / (unsigned)(block_size));
dev = (dev_t) rip->i_block[0]; dev = (dev_t) rip->i_block[0];
} else { } else {
if (ex64hi(position) != 0) if (ex64hi(position) != 0)
@ -453,7 +453,7 @@ void read_ahead()
assert(rdahedpos >= 0); /* So we can safely cast it to unsigned below */ assert(rdahedpos >= 0); /* So we can safely cast it to unsigned below */
bp = rahead(rip, b, cvul64((unsigned long) rdahedpos), block_size); bp = rahead(rip, b, ((u64_t)((unsigned long)rdahedpos)), block_size);
put_block(bp, PARTIAL_DATA_BLOCK); put_block(bp, PARTIAL_DATA_BLOCK);
} }

View File

@ -92,7 +92,7 @@ register struct super_block *sp; /* pointer to a superblock */
panic("can't allocate memory for super_block buffers"); panic("can't allocate memory for super_block buffers");
assert(_MIN_BLOCK_SIZE <= sizeof(*ondisk_superblock)); assert(_MIN_BLOCK_SIZE <= sizeof(*ondisk_superblock));
r = bdev_read(dev, cvu64(super_block_offset), (char*) ondisk_superblock, r = bdev_read(dev, ((u64_t)(super_block_offset)), (char*) ondisk_superblock,
_MIN_BLOCK_SIZE, BDEV_NOFLAGS); _MIN_BLOCK_SIZE, BDEV_NOFLAGS);
if (r != _MIN_BLOCK_SIZE) if (r != _MIN_BLOCK_SIZE)
@ -177,7 +177,7 @@ register struct super_block *sp; /* pointer to a superblock */
gdt_position = (opt.block_with_super + 1) * 1024; gdt_position = (opt.block_with_super + 1) * 1024;
} }
r = bdev_read(dev, cvu64(gdt_position), (char*) ondisk_group_descs, r = bdev_read(dev, ((u64_t)(gdt_position)), (char*) ondisk_group_descs,
gd_size, BDEV_NOFLAGS); gd_size, BDEV_NOFLAGS);
if (r != (ssize_t) gd_size) { if (r != (ssize_t) gd_size) {
printf("Can not read group descriptors\n"); printf("Can not read group descriptors\n");
@ -230,7 +230,7 @@ struct super_block *sp; /* pointer to a superblock */
super_copy(ondisk_superblock, sp); super_copy(ondisk_superblock, sp);
r = bdev_write(sp->s_dev, cvu64(super_block_offset), (char *) sp, r = bdev_write(sp->s_dev, ((u64_t)(super_block_offset)), (char *) sp,
SUPER_SIZE_D, BDEV_NOFLAGS); SUPER_SIZE_D, BDEV_NOFLAGS);
if (r != SUPER_SIZE_D) if (r != SUPER_SIZE_D)
printf("ext2: Warning, failed to write superblock to the disk!\n"); printf("ext2: Warning, failed to write superblock to the disk!\n");
@ -248,7 +248,7 @@ struct super_block *sp; /* pointer to a superblock */
copy_group_descriptors(ondisk_group_descs, sp->s_group_desc, copy_group_descriptors(ondisk_group_descs, sp->s_group_desc,
sp->s_groups_count); sp->s_groups_count);
r = bdev_write(sp->s_dev, cvu64(gdt_position), r = bdev_write(sp->s_dev, ((u64_t)(gdt_position)),
(char*) ondisk_group_descs, gd_size, BDEV_NOFLAGS); (char*) ondisk_group_descs, gd_size, BDEV_NOFLAGS);
if (r != (ssize_t) gd_size) { if (r != (ssize_t) gd_size) {
printf("Can not write group descriptors\n"); printf("Can not write group descriptors\n");

View File

@ -54,7 +54,7 @@ int fs_read(void) {
if (chunk > bytes_left) chunk = (int) bytes_left; if (chunk > bytes_left) chunk = (int) bytes_left;
/* Read or write 'chunk' bytes. */ /* Read or write 'chunk' bytes. */
r = read_chunk(dir, cvul64(position), off, chunk, (unsigned) nrbytes, r = read_chunk(dir, ((u64_t)(position)), off, chunk, (unsigned) nrbytes,
gid, cum_io, block_size, &completed, rw); gid, cum_io, block_size, &completed, rw);
if (r != OK) break; /* EOF reached */ if (r != OK) break; /* EOF reached */
@ -106,7 +106,7 @@ int fs_bread(void)
cum_io = 0; cum_io = 0;
/* Split the transfer into chunks that don't span two blocks. */ /* Split the transfer into chunks that don't span two blocks. */
while (nrbytes != 0) { while (nrbytes != 0) {
off = rem64u(position, block_size); /* offset in blk*/ off = ((u64_t)(position) % (unsigned)(block_size)); /* offset in blk*/
chunk = MIN(nrbytes, block_size - off); chunk = MIN(nrbytes, block_size - off);
if (chunk < 0) chunk = block_size - off; if (chunk < 0) chunk = block_size - off;
@ -121,7 +121,7 @@ int fs_bread(void)
/* Update counters and pointers. */ /* Update counters and pointers. */
nrbytes -= chunk; /* bytes yet to be read */ nrbytes -= chunk; /* bytes yet to be read */
cum_io += chunk; /* bytes read so far */ cum_io += chunk; /* bytes read so far */
position= add64ul(position, chunk); /* position within the file */ position= ((u64_t)(position) + (chunk)); /* position within the file */
} }
fs_m_out.RES_SEEK_POS_LO = ex64lo(position); fs_m_out.RES_SEEK_POS_LO = ex64lo(position);
@ -310,19 +310,19 @@ int rw; /* READING or PEEKING */
if ((ex64lo(position) <= dir->d_file_size) && if ((ex64lo(position) <= dir->d_file_size) &&
(ex64lo(position) > dir->data_length_l)) { (ex64lo(position) > dir->data_length_l)) {
while ((dir->d_next != NULL) && (ex64lo(position) > dir->data_length_l)) { while ((dir->d_next != NULL) && (ex64lo(position) > dir->data_length_l)) {
position = sub64ul(position, dir->data_length_l); position = ((u64_t)(position) - (dir->data_length_l));
dir = dir->d_next; dir = dir->d_next;
} }
} }
if (dir->inter_gap_size != 0) { if (dir->inter_gap_size != 0) {
rel_block = div64u(position, block_size); rel_block = ((u64_t)(position) / (unsigned)(block_size));
file_unit = rel_block / dir->data_length_l; file_unit = rel_block / dir->data_length_l;
offset = rel_block % dir->file_unit_size; offset = rel_block % dir->file_unit_size;
b = dir->loc_extent_l + (dir->file_unit_size + b = dir->loc_extent_l + (dir->file_unit_size +
dir->inter_gap_size) * file_unit + offset; dir->inter_gap_size) * file_unit + offset;
} else { } else {
b = dir->loc_extent_l + div64u(position, block_size); /* Physical position b = dir->loc_extent_l + ((u64_t)(position) / (unsigned)(block_size)); /* Physical position
* to read. */ * to read. */
} }

View File

@ -91,7 +91,7 @@ int read_vds(
static char sbbuf[ISO9660_MIN_BLOCK_SIZE]; static char sbbuf[ISO9660_MIN_BLOCK_SIZE];
int i = 0; int i = 0;
offset = cvul64(ISO9660_SUPER_BLOCK_POSITION); offset = ((u64_t)(ISO9660_SUPER_BLOCK_POSITION));
while (!vol_ok && i++<MAX_ATTEMPTS) { while (!vol_ok && i++<MAX_ATTEMPTS) {
/* Read the sector of the super block. */ /* Read the sector of the super block. */
@ -101,14 +101,14 @@ int read_vds(
continue; continue;
if ((sbbuf[0] & BYTE) == VD_PRIMARY) { if ((sbbuf[0] & BYTE) == VD_PRIMARY) {
create_v_pri(v_pri,sbbuf,cv64ul(offset)); /* copy the buffer in the data structure. */ create_v_pri(v_pri,sbbuf,offset); /* copy the buffer in the data structure. */
} }
if ((sbbuf[0] & BYTE) == VD_SET_TERM) if ((sbbuf[0] & BYTE) == VD_SET_TERM)
/* I dont need to save anything about it */ /* I dont need to save anything about it */
vol_ok = TRUE; vol_ok = TRUE;
offset = add64u(offset,ISO9660_MIN_BLOCK_SIZE); offset = ((u64_t)(offset) + (ISO9660_MIN_BLOCK_SIZE));
} }
if (vol_ok == FALSE) if (vol_ok == FALSE)

View File

@ -100,7 +100,7 @@ int fs_readwrite(void)
} }
/* Read or write 'chunk' bytes. */ /* Read or write 'chunk' bytes. */
r = rw_chunk(rip, cvul64((unsigned long) position), off, chunk, r = rw_chunk(rip, ((u64_t)((unsigned long)position)), off, chunk,
nrbytes, rw_flag, gid, cum_io, block_size, &completed); nrbytes, rw_flag, gid, cum_io, block_size, &completed);
if (r != OK) break; /* EOF reached */ if (r != OK) break; /* EOF reached */
@ -183,7 +183,7 @@ int fs_breadwrite(void)
cum_io = 0; cum_io = 0;
/* Split the transfer into chunks that don't span two blocks. */ /* Split the transfer into chunks that don't span two blocks. */
while (nrbytes > 0) { while (nrbytes > 0) {
off = rem64u(position, block_size); /* offset in blk*/ off = ((u64_t)(position) % (unsigned)(block_size)); /* offset in blk*/
chunk = min(nrbytes, block_size - off); chunk = min(nrbytes, block_size - off);
/* Read or write 'chunk' bytes. */ /* Read or write 'chunk' bytes. */
@ -196,7 +196,7 @@ int fs_breadwrite(void)
/* Update counters and pointers. */ /* Update counters and pointers. */
nrbytes -= chunk; /* bytes yet to be read */ nrbytes -= chunk; /* bytes yet to be read */
cum_io += chunk; /* bytes read so far */ cum_io += chunk; /* bytes read so far */
position = add64ul(position, chunk); /* position within the file */ position = ((u64_t)(position) + (chunk)); /* position within the file */
} }
fs_m_out.RES_SEEK_POS_LO = ex64lo(position); fs_m_out.RES_SEEK_POS_LO = ex64lo(position);
@ -248,7 +248,7 @@ int *completed; /* number of bytes copied */
block_spec = (rip->i_mode & I_TYPE) == I_BLOCK_SPECIAL; block_spec = (rip->i_mode & I_TYPE) == I_BLOCK_SPECIAL;
if (block_spec) { if (block_spec) {
b = div64u(position, block_size); b = ((u64_t)(position) / (unsigned)(block_size));
dev = (dev_t) rip->i_zone[0]; dev = (dev_t) rip->i_zone[0];
} else { } else {
if (ex64hi(position) != 0) if (ex64hi(position) != 0)

View File

@ -214,10 +214,10 @@ static int rw_super(struct super_block *sp, int writing)
if(writing) { if(writing) {
memset(sbbuf, 0, _MIN_BLOCK_SIZE); memset(sbbuf, 0, _MIN_BLOCK_SIZE);
memcpy(sbbuf, sp, ondisk_bytes); memcpy(sbbuf, sp, ondisk_bytes);
r = bdev_write(sp->s_dev, cvu64(SUPER_BLOCK_BYTES), sbbuf, _MIN_BLOCK_SIZE, r = bdev_write(sp->s_dev, ((u64_t)(SUPER_BLOCK_BYTES)), sbbuf, _MIN_BLOCK_SIZE,
BDEV_NOFLAGS); BDEV_NOFLAGS);
} else { } else {
r = bdev_read(sp->s_dev, cvu64(SUPER_BLOCK_BYTES), sbbuf, _MIN_BLOCK_SIZE, r = bdev_read(sp->s_dev, ((u64_t)(SUPER_BLOCK_BYTES)), sbbuf, _MIN_BLOCK_SIZE,
BDEV_NOFLAGS); BDEV_NOFLAGS);
memset(sp, 0, sizeof(*sp)); memset(sp, 0, sizeof(*sp));
memcpy(sp, sbbuf, ondisk_bytes); memcpy(sp, sbbuf, ondisk_bytes);

View File

@ -680,7 +680,7 @@ int do_ioctl(message *UNUSED(m_out))
if (S_ISBLK(vp->v_mode)) if (S_ISBLK(vp->v_mode))
r = bdev_ioctl(dev, who_e, ioctlrequest, argx); r = bdev_ioctl(dev, who_e, ioctlrequest, argx);
else else
r = dev_io(VFS_DEV_IOCTL, dev, who_e, argx, cvu64(0), r = dev_io(VFS_DEV_IOCTL, dev, who_e, argx, ((u64_t)(0)),
ioctlrequest, f->filp_flags, suspend_reopen); ioctlrequest, f->filp_flags, suspend_reopen);
} }

View File

@ -567,7 +567,7 @@ char path[PATH_MAX]; /* path to script file */
pos = 0; /* Read from the start of the file */ pos = 0; /* Read from the start of the file */
/* Issue request */ /* Issue request */
r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(pos), READING, r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, ((u64_t)(pos)), READING,
VFS_PROC_NR, buf, _MAX_BLOCK_SIZE, &new_pos, &cum_io); VFS_PROC_NR, buf, _MAX_BLOCK_SIZE, &new_pos, &cum_io);
if (r != OK) return(r); if (r != OK) return(r);
@ -692,7 +692,7 @@ static int read_seg(struct exec_info *execi, off_t off, off_t seg_addr, size_t s
if (off + seg_bytes > LONG_MAX) return(EIO); if (off + seg_bytes > LONG_MAX) return(EIO);
if ((unsigned long) vp->v_size < off+seg_bytes) return(EIO); if ((unsigned long) vp->v_size < off+seg_bytes) return(EIO);
if ((r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, cvul64(off), READING, if ((r = req_readwrite(vp->v_fs_e, vp->v_inode_nr, ((u64_t)(off)), READING,
execi->proc_e, (char*)seg_addr, seg_bytes, execi->proc_e, (char*)seg_addr, seg_bytes,
&new_pos, &cum_io)) != OK) { &new_pos, &cum_io)) != OK) {
printf("VFS: read_seg: req_readwrite failed (data)\n"); printf("VFS: read_seg: req_readwrite failed (data)\n");
@ -739,7 +739,7 @@ static int map_header(struct vfs_exec_info *execi)
execi->args.hdr = hdr; execi->args.hdr = hdr;
r = req_readwrite(execi->vp->v_fs_e, execi->vp->v_inode_nr, r = req_readwrite(execi->vp->v_fs_e, execi->vp->v_inode_nr,
cvul64(pos), READING, VFS_PROC_NR, hdr, ((u64_t)(pos)), READING, VFS_PROC_NR, hdr,
execi->args.hdr_len, &new_pos, &cum_io); execi->args.hdr_len, &new_pos, &cum_io);
if (r != OK) { if (r != OK) {
printf("VFS: exec: map_header: req_readwrite failed\n"); printf("VFS: exec: map_header: req_readwrite failed\n");

View File

@ -177,7 +177,7 @@ int get_fd(struct fproc *rfp, int start, mode_t bits, int *k, struct filp **fpt)
assert(f->filp_count >= 0); assert(f->filp_count >= 0);
if (f->filp_count == 0 && mutex_trylock(&f->filp_lock) == 0) { if (f->filp_count == 0 && mutex_trylock(&f->filp_lock) == 0) {
f->filp_mode = bits; f->filp_mode = bits;
f->filp_pos = cvu64(0); f->filp_pos = ((u64_t)(0));
f->filp_selectors = 0; f->filp_selectors = 0;
f->filp_select_ops = 0; f->filp_select_ops = 0;
f->filp_pipe_select_ops = 0; f->filp_pipe_select_ops = 0;

View File

@ -608,16 +608,16 @@ int actual_lseek(message *m_out, int seekfd, int seekwhence, off_t offset)
/* The value of 'whence' determines the start position to use. */ /* The value of 'whence' determines the start position to use. */
switch(seekwhence) { switch(seekwhence) {
case SEEK_SET: pos = cvu64(0); break; case SEEK_SET: pos = ((u64_t)(0)); break;
case SEEK_CUR: pos = rfilp->filp_pos; break; case SEEK_CUR: pos = rfilp->filp_pos; break;
case SEEK_END: pos = cvul64(rfilp->filp_vno->v_size); break; case SEEK_END: pos = ((u64_t)(rfilp->filp_vno->v_size)); break;
default: unlock_filp(rfilp); return(EINVAL); default: unlock_filp(rfilp); return(EINVAL);
} }
if (offset >= 0) if (offset >= 0)
newpos = add64ul(pos, offset); newpos = ((u64_t)(pos) + (offset));
else else
newpos = sub64ul(pos, -offset); newpos = ((u64_t)(pos) - (-offset));
/* Check for overflow. */ /* Check for overflow. */
if (ex64hi(newpos) != 0) { if (ex64hi(newpos) != 0) {
@ -675,9 +675,9 @@ int actual_llseek(struct fproc *rfp, message *m_out, int seekfd, int seekwhence,
/* The value of 'whence' determines the start position to use. */ /* The value of 'whence' determines the start position to use. */
switch(seekwhence) { switch(seekwhence) {
case SEEK_SET: pos = cvu64(0); break; case SEEK_SET: pos = ((u64_t)(0)); break;
case SEEK_CUR: pos = rfilp->filp_pos; break; case SEEK_CUR: pos = rfilp->filp_pos; break;
case SEEK_END: pos = cvul64(rfilp->filp_vno->v_size); break; case SEEK_END: pos = ((u64_t)(rfilp->filp_vno->v_size)); break;
default: unlock_filp(rfilp); return(EINVAL); default: unlock_filp(rfilp); return(EINVAL);
} }

View File

@ -181,7 +181,7 @@ int read_write(struct fproc *rfp, int rw_flag, struct filp *f,
suspend_reopen); suspend_reopen);
if (r >= 0) { if (r >= 0) {
cum_io = r; cum_io = r;
position = add64ul(position, r); position = ((u64_t)(position) + (r));
r = OK; r = OK;
} }
} else if (S_ISBLK(vp->v_mode)) { /* Block special files. */ } else if (S_ISBLK(vp->v_mode)) { /* Block special files. */
@ -205,7 +205,7 @@ int read_write(struct fproc *rfp, int rw_flag, struct filp *f,
} else { /* Regular files */ } else { /* Regular files */
if (rw_flag == WRITING) { if (rw_flag == WRITING) {
/* Check for O_APPEND flag. */ /* Check for O_APPEND flag. */
if (f->filp_flags & O_APPEND) position = cvul64(vp->v_size); if (f->filp_flags & O_APPEND) position = ((u64_t)(vp->v_size));
} }
/* Issue request */ /* Issue request */
@ -315,7 +315,7 @@ size_t req_size;
oflags = f->filp_flags; oflags = f->filp_flags;
vp = f->filp_vno; vp = f->filp_vno;
position = cvu64(0); /* Not actually used */ position = ((u64_t)(0)); /* Not actually used */
assert(rw_flag == READING || rw_flag == WRITING); assert(rw_flag == READING || rw_flag == WRITING);

View File

@ -330,7 +330,7 @@ int req_getdents(
cpf_revoke(grant_id); cpf_revoke(grant_id);
if (r == OK) { if (r == OK) {
*new_pos = cvul64(m.RES_SEEK_POS_LO); *new_pos = ((u64_t)(m.RES_SEEK_POS_LO));
r = m.RES_NBYTES; r = m.RES_NBYTES;
} }
@ -808,7 +808,7 @@ unsigned int *cum_iop;
if (r == OK) { if (r == OK) {
/* Fill in response structure */ /* Fill in response structure */
*new_posp = cvul64(m.RES_SEEK_POS_LO); *new_posp = ((u64_t)(m.RES_SEEK_POS_LO));
*cum_iop = m.RES_NBYTES; *cum_iop = m.RES_NBYTES;
} }

View File

@ -383,7 +383,7 @@ static int select_request_async(struct filp *f, int *ops, int block)
f->filp_select_flags &= ~FSF_UPDATE; f->filp_select_flags &= ~FSF_UPDATE;
r = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL, r = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL,
cvu64(0), 0, 0, FALSE); ((u64_t)(0)), 0, 0, FALSE);
if (r < 0 && r != SUSPEND) if (r < 0 && r != SUSPEND)
return(r); return(r);
@ -435,7 +435,7 @@ static int select_request_sync(struct filp *f, int *ops, int block)
rops = *ops; rops = *ops;
if (block) rops |= SEL_NOTIFY; if (block) rops |= SEL_NOTIFY;
*ops = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL, *ops = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL,
cvu64(0), 0, 0, FALSE); ((u64_t)(0)), 0, 0, FALSE);
if (*ops < 0) if (*ops < 0)
return(*ops); return(*ops);

View File

@ -532,7 +532,7 @@ static void bad_read2(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE,
buf_size + buf2_size + buf3_size, &res); buf_size + buf2_size + buf3_size, &res);
test_sum(buf_ptr, buf_size, buf_sum, FALSE, &res); test_sum(buf_ptr, buf_size, buf_sum, FALSE, &res);
@ -549,7 +549,7 @@ static void bad_read2(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, EINVAL, &res);
test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res); test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res);
test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res); test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res);
@ -561,7 +561,7 @@ static void bad_read2(void)
memcpy(iov, iovt, sizeof(iovt)); memcpy(iov, iovt, sizeof(iovt));
iov[1].iov_size = (vir_bytes) LONG_MAX + 1; iov[1].iov_size = (vir_bytes) LONG_MAX + 1;
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, EINVAL, &res);
test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res); test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res);
test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res); test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res);
@ -574,7 +574,7 @@ static void bad_read2(void)
iov[0].iov_size = LONG_MAX / 2 - 1; iov[0].iov_size = LONG_MAX / 2 - 1;
iov[1].iov_size = LONG_MAX / 2 - 1; iov[1].iov_size = LONG_MAX / 2 - 1;
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, EINVAL, &res);
test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res); test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res);
test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res); test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res);
@ -587,7 +587,7 @@ static void bad_read2(void)
iov[0].iov_size = LONG_MAX - 1; iov[0].iov_size = LONG_MAX - 1;
iov[1].iov_size = LONG_MAX - 1; iov[1].iov_size = LONG_MAX - 1;
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, EINVAL, &res);
test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res); test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res);
test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res); test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res);
@ -604,7 +604,7 @@ static void bad_read2(void)
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
c1 = buf2_ptr[buf2_size - 1]; c1 = buf2_ptr[buf2_size - 1];
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, BUF_SIZE * 3 - 1, raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, BUF_SIZE * 3 - 1,
&res); &res);
if (accept_result(&res, RESULT_BADSTATUS, EINVAL)) { if (accept_result(&res, RESULT_BADSTATUS, EINVAL)) {
@ -631,7 +631,7 @@ static void bad_read2(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, EINVAL, &res);
/* Do not test the first buffer, as it may contain a partial result. */ /* Do not test the first buffer, as it may contain a partial result. */
test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res); test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res);
@ -653,7 +653,7 @@ static void bad_read2(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, EINVAL, &res);
accept_result(&res, RESULT_BADSTATUS, EPERM); accept_result(&res, RESULT_BADSTATUS, EPERM);
@ -675,7 +675,7 @@ static void bad_read2(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, EINVAL, &res);
accept_result(&res, RESULT_BADSTATUS, EPERM); accept_result(&res, RESULT_BADSTATUS, EPERM);
@ -702,7 +702,7 @@ static void bad_read2(void)
c1 = buf2_ptr[0]; c1 = buf2_ptr[0];
c2 = buf2_ptr[buf2_size - 1]; c2 = buf2_ptr[buf2_size - 1];
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, BUF_SIZE * 3 - 2, raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE, BUF_SIZE * 3 - 2,
&res); &res);
if (accept_result(&res, RESULT_BADSTATUS, EINVAL)) { if (accept_result(&res, RESULT_BADSTATUS, EINVAL)) {
@ -730,7 +730,7 @@ static void bad_read2(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(1), iov, 3, FALSE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(1)), iov, 3, FALSE, EINVAL, &res);
test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res); test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res);
test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res); test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res);
@ -745,7 +745,7 @@ static void bad_read2(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(0), iov, 3, FALSE, raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, FALSE,
buf_size + buf2_size + buf3_size, &res); buf_size + buf2_size + buf3_size, &res);
test_sum(buf_ptr, buf_size, buf_sum, FALSE, &res); test_sum(buf_ptr, buf_size, buf_sum, FALSE, &res);
@ -801,7 +801,7 @@ static void bad_write(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(SECTOR_UNALIGN), iov, 3, TRUE, EINVAL, raw_xfer(driver_minor, ((u64_t)(SECTOR_UNALIGN)), iov, 3, TRUE, EINVAL,
&res); &res);
test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res); test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res);
@ -818,7 +818,7 @@ static void bad_write(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(0), iov, 3, TRUE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, TRUE, EINVAL, &res);
test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res); test_sum(buf_ptr, buf_size, buf_sum, TRUE, &res);
test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res); test_sum(buf2_ptr, buf2_size, buf2_sum, TRUE, &res);
@ -838,7 +838,7 @@ static void bad_write(void)
buf2_sum = fill_rand(buf2_ptr, buf2_size); buf2_sum = fill_rand(buf2_ptr, buf2_size);
buf3_sum = fill_rand(buf3_ptr, buf3_size); buf3_sum = fill_rand(buf3_ptr, buf3_size);
raw_xfer(driver_minor, cvu64(0), iov, 3, TRUE, EINVAL, &res); raw_xfer(driver_minor, ((u64_t)(0)), iov, 3, TRUE, EINVAL, &res);
accept_result(&res, RESULT_BADSTATUS, EPERM); accept_result(&res, RESULT_BADSTATUS, EPERM);
@ -868,7 +868,7 @@ static void vector_and_large_sub(size_t small_size)
result_t res; result_t res;
int i; int i;
base_pos = cvu64(sector_size); base_pos = ((u64_t)(sector_size));
large_size = small_size * NR_IOREQS; large_size = small_size * NR_IOREQS;
@ -1185,7 +1185,7 @@ static void read_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
/* Read one sector up to the partition limit. */ /* Read one sector up to the partition limit. */
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size)), buf_ptr,
sector_size, FALSE, sector_size, &res); sector_size, FALSE, sector_size, &res);
sum = get_sum(buf_ptr, sector_size); sum = get_sum(buf_ptr, sector_size);
@ -1195,7 +1195,7 @@ static void read_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
/* Read three sectors up to the partition limit. */ /* Read three sectors up to the partition limit. */
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
simple_xfer(sub0_minor, cvu64(sub_size - buf_size), buf_ptr, buf_size, simple_xfer(sub0_minor, ((u64_t)(sub_size - buf_size)), buf_ptr, buf_size,
FALSE, buf_size, &res); FALSE, buf_size, &res);
test_sum(buf_ptr + sector_size * 2, sector_size, sum, TRUE, &res); test_sum(buf_ptr + sector_size * 2, sector_size, sum, TRUE, &res);
@ -1208,7 +1208,7 @@ static void read_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
sum3 = get_sum(buf_ptr + sector_size * 2, sector_size); sum3 = get_sum(buf_ptr + sector_size * 2, sector_size);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size * 2), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size * 2)), buf_ptr,
buf_size, FALSE, sector_size * 2, &res); buf_size, FALSE, sector_size * 2, &res);
test_sum(buf_ptr, sector_size * 2, sum2, TRUE, &res); test_sum(buf_ptr, sector_size * 2, sum2, TRUE, &res);
@ -1220,7 +1220,7 @@ static void read_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
sum2 = get_sum(buf_ptr + sector_size, sector_size * 2); sum2 = get_sum(buf_ptr + sector_size, sector_size * 2);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size)), buf_ptr,
buf_size, FALSE, sector_size, &res); buf_size, FALSE, sector_size, &res);
test_sum(buf_ptr, sector_size, sum, TRUE, &res); test_sum(buf_ptr, sector_size, sum, TRUE, &res);
@ -1232,7 +1232,7 @@ static void read_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
sum = fill_rand(buf_ptr, buf_size); sum = fill_rand(buf_ptr, buf_size);
sum2 = get_sum(buf_ptr, sector_size); sum2 = get_sum(buf_ptr, sector_size);
simple_xfer(sub0_minor, cvu64(sub_size), buf_ptr, sector_size, FALSE, simple_xfer(sub0_minor, ((u64_t)(sub_size)), buf_ptr, sector_size, FALSE,
0, &res); 0, &res);
test_sum(buf_ptr, sector_size, sum2, TRUE, &res); test_sum(buf_ptr, sector_size, sum2, TRUE, &res);
@ -1240,7 +1240,7 @@ static void read_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
got_result(&res, "one sector read at partition end"); got_result(&res, "one sector read at partition end");
/* Read three sectors starting at the partition end. */ /* Read three sectors starting at the partition end. */
simple_xfer(sub0_minor, cvu64(sub_size), buf_ptr, buf_size, FALSE, 0, simple_xfer(sub0_minor, ((u64_t)(sub_size)), buf_ptr, buf_size, FALSE, 0,
&res); &res);
test_sum(buf_ptr, buf_size, sum, TRUE, &res); test_sum(buf_ptr, buf_size, sum, TRUE, &res);
@ -1248,7 +1248,7 @@ static void read_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
got_result(&res, "multisector read at partition end"); got_result(&res, "multisector read at partition end");
/* Read one sector beyond the partition end. */ /* Read one sector beyond the partition end. */
simple_xfer(sub0_minor, cvu64(sub_size + sector_size), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size + sector_size)), buf_ptr,
buf_size, FALSE, 0, &res); buf_size, FALSE, 0, &res);
test_sum(buf_ptr, sector_size, sum2, TRUE, &res); test_sum(buf_ptr, sector_size, sum2, TRUE, &res);
@ -1307,7 +1307,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
*/ */
sub1_sum = fill_rand(buf_ptr, buf_size); sub1_sum = fill_rand(buf_ptr, buf_size);
simple_xfer(sub1_minor, cvu64(0), buf_ptr, buf_size, TRUE, buf_size, simple_xfer(sub1_minor, ((u64_t)(0)), buf_ptr, buf_size, TRUE, buf_size,
&res); &res);
got_result(&res, "write to second subpartition"); got_result(&res, "write to second subpartition");
@ -1315,7 +1315,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
/* Write one sector, up to the partition limit. */ /* Write one sector, up to the partition limit. */
sum = fill_rand(buf_ptr, sector_size); sum = fill_rand(buf_ptr, sector_size);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size)), buf_ptr,
sector_size, TRUE, sector_size, &res); sector_size, TRUE, sector_size, &res);
got_result(&res, "write up to partition end"); got_result(&res, "write up to partition end");
@ -1323,7 +1323,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
/* Read back to make sure the results have persisted. */ /* Read back to make sure the results have persisted. */
fill_rand(buf_ptr, sector_size * 2); fill_rand(buf_ptr, sector_size * 2);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size * 2), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size * 2)), buf_ptr,
sector_size * 2, FALSE, sector_size * 2, &res); sector_size * 2, FALSE, sector_size * 2, &res);
test_sum(buf_ptr + sector_size, sector_size, sum, TRUE, &res); test_sum(buf_ptr + sector_size, sector_size, sum, TRUE, &res);
@ -1335,7 +1335,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
sum = get_sum(buf_ptr + sector_size, sector_size); sum = get_sum(buf_ptr + sector_size, sector_size);
sum3 = get_sum(buf_ptr, sector_size); sum3 = get_sum(buf_ptr, sector_size);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size * 2), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size * 2)), buf_ptr,
buf_size, TRUE, sector_size * 2, &res); buf_size, TRUE, sector_size * 2, &res);
got_result(&res, "write somewhat across partition end"); got_result(&res, "write somewhat across partition end");
@ -1344,7 +1344,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
sum2 = get_sum(buf_ptr + sector_size, sector_size * 2); sum2 = get_sum(buf_ptr + sector_size, sector_size * 2);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size)), buf_ptr,
buf_size, FALSE, sector_size, &res); buf_size, FALSE, sector_size, &res);
test_sum(buf_ptr, sector_size, sum, TRUE, &res); test_sum(buf_ptr, sector_size, sum, TRUE, &res);
@ -1356,7 +1356,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
sum = get_sum(buf_ptr, sector_size); sum = get_sum(buf_ptr, sector_size);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size)), buf_ptr,
buf_size, TRUE, sector_size, &res); buf_size, TRUE, sector_size, &res);
got_result(&res, "write mostly across partition end"); got_result(&res, "write mostly across partition end");
@ -1364,7 +1364,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
sum2 = get_sum(buf_ptr + sector_size * 2, sector_size); sum2 = get_sum(buf_ptr + sector_size * 2, sector_size);
simple_xfer(sub0_minor, cvu64(sub_size - sector_size * 2), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size * 2)), buf_ptr,
buf_size, FALSE, sector_size * 2, &res); buf_size, FALSE, sector_size * 2, &res);
test_sum(buf_ptr, sector_size, sum3, TRUE, &res); test_sum(buf_ptr, sector_size, sum3, TRUE, &res);
@ -1376,13 +1376,13 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
/* Write one sector at the end of the partition. */ /* Write one sector at the end of the partition. */
fill_rand(buf_ptr, sector_size); fill_rand(buf_ptr, sector_size);
simple_xfer(sub0_minor, cvu64(sub_size), buf_ptr, sector_size, TRUE, 0, simple_xfer(sub0_minor, ((u64_t)(sub_size)), buf_ptr, sector_size, TRUE, 0,
&res); &res);
got_result(&res, "write at partition end"); got_result(&res, "write at partition end");
/* Write one sector beyond the end of the partition. */ /* Write one sector beyond the end of the partition. */
simple_xfer(sub0_minor, cvu64(sub_size + sector_size), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size + sector_size)), buf_ptr,
sector_size, TRUE, 0, &res); sector_size, TRUE, 0, &res);
got_result(&res, "write beyond partition end"); got_result(&res, "write beyond partition end");
@ -1392,7 +1392,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
*/ */
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
simple_xfer(sub1_minor, cvu64(0), buf_ptr, buf_size, FALSE, buf_size, simple_xfer(sub1_minor, ((u64_t)(0)), buf_ptr, buf_size, FALSE, buf_size,
&res); &res);
test_sum(buf_ptr, buf_size, sub1_sum, TRUE, &res); test_sum(buf_ptr, buf_size, sub1_sum, TRUE, &res);
@ -1410,7 +1410,7 @@ static void write_limits(dev_t sub0_minor, dev_t sub1_minor, size_t sub_size)
/* If the last request erroneously succeeded, it would have overwritten /* If the last request erroneously succeeded, it would have overwritten
* the last sector of the first subpartition. * the last sector of the first subpartition.
*/ */
simple_xfer(sub0_minor, cvu64(sub_size - sector_size), buf_ptr, simple_xfer(sub0_minor, ((u64_t)(sub_size - sector_size)), buf_ptr,
sector_size, FALSE, sector_size, &res); sector_size, FALSE, sector_size, &res);
test_sum(buf_ptr, sector_size, sum, TRUE, &res); test_sum(buf_ptr, sector_size, sum, TRUE, &res);
@ -1443,7 +1443,7 @@ static void vir_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs)
/* Set, and check, the size of the first subpartition. */ /* Set, and check, the size of the first subpartition. */
subpart = part; subpart = part;
subpart.size = cvu64(sub_size); subpart.size = ((u64_t)(sub_size));
vir_ioctl(sub0_minor, DIOCSETP, &subpart, OK, &res); vir_ioctl(sub0_minor, DIOCSETP, &subpart, OK, &res);
@ -1461,8 +1461,8 @@ static void vir_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs)
/* Set, and check, the base and size of the second subpartition. */ /* Set, and check, the base and size of the second subpartition. */
subpart = part; subpart = part;
subpart.base = add64u(subpart.base, sub_size); subpart.base = ((u64_t)(subpart.base) + (sub_size));
subpart.size = cvu64(sub_size); subpart.size = ((u64_t)(sub_size));
vir_ioctl(sub1_minor, DIOCSETP, &subpart, OK, &res); vir_ioctl(sub1_minor, DIOCSETP, &subpart, OK, &res);
@ -1520,7 +1520,7 @@ static void real_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs)
memset(buf_ptr, 0, buf_size); memset(buf_ptr, 0, buf_size);
/* Write an invalid partition table. */ /* Write an invalid partition table. */
simple_xfer(driver_minor, cvu64(0), buf_ptr, buf_size, TRUE, buf_size, simple_xfer(driver_minor, ((u64_t)(0)), buf_ptr, buf_size, TRUE, buf_size,
&res); &res);
got_result(&res, "write of invalid partition table"); got_result(&res, "write of invalid partition table");
@ -1567,7 +1567,7 @@ static void real_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs)
entry = (struct part_entry *) &buf_ptr[PART_TABLE_OFF]; entry = (struct part_entry *) &buf_ptr[PART_TABLE_OFF];
entry[0].sysind = MINIX_PART; entry[0].sysind = MINIX_PART;
entry[0].lowsec = div64u(part.base, sector_size) + 1; entry[0].lowsec = ((u64_t)(part.base) / (unsigned)(sector_size)) + 1;
entry[0].size = part_secs; entry[0].size = part_secs;
entry[1].sysind = MINIX_PART; entry[1].sysind = MINIX_PART;
entry[1].lowsec = entry[0].lowsec + entry[0].size; entry[1].lowsec = entry[0].lowsec + entry[0].size;
@ -1576,7 +1576,7 @@ static void real_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs)
buf_ptr[510] = 0x55; buf_ptr[510] = 0x55;
buf_ptr[511] = 0xAA; buf_ptr[511] = 0xAA;
simple_xfer(driver_minor, cvu64(0), buf_ptr, buf_size, TRUE, buf_size, simple_xfer(driver_minor, ((u64_t)(0)), buf_ptr, buf_size, TRUE, buf_size,
&res); &res);
got_result(&res, "write of valid partition table"); got_result(&res, "write of valid partition table");
@ -1594,7 +1594,7 @@ static void real_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs)
vir_ioctl(sub0_minor, DIOCGETP, &subpart, 0, &res); vir_ioctl(sub0_minor, DIOCGETP, &subpart, 0, &res);
if (res.type == RESULT_OK && (cmp64(subpart.base, if (res.type == RESULT_OK && (cmp64(subpart.base,
add64u(part.base, sector_size)) || ((u64_t)(part.base) + (sector_size))) ||
cmp64u(subpart.size, part_secs * sector_size))) { cmp64u(subpart.size, part_secs * sector_size))) {
res.type = RESULT_BADVALUE; res.type = RESULT_BADVALUE;
@ -1606,7 +1606,7 @@ static void real_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs)
vir_ioctl(sub1_minor, DIOCGETP, &subpart, 0, &res); vir_ioctl(sub1_minor, DIOCGETP, &subpart, 0, &res);
if (res.type == RESULT_OK && (cmp64(subpart.base, if (res.type == RESULT_OK && (cmp64(subpart.base,
add64u(part.base, (1 + part_secs) * sector_size)) || ((u64_t)(part.base) + ((1 + part_secs) * sector_size))) ||
cmp64u(subpart.size, part_secs * sector_size))) { cmp64u(subpart.size, part_secs * sector_size))) {
res.type = RESULT_BADVALUE; res.type = RESULT_BADVALUE;
@ -1678,7 +1678,7 @@ static void unaligned_size_io(u64_t base_pos, u8_t *buf_ptr, size_t buf_size,
size_t total_size; size_t total_size;
int i, nr_req; int i, nr_req;
base_pos = add64u(base_pos, sector_size); base_pos = ((u64_t)(base_pos) + (sector_size));
total_size = sector_size * sectors; total_size = sector_size * sectors;
/* If the limit is two elements per sector, we cannot test three /* If the limit is two elements per sector, we cannot test three
@ -1859,7 +1859,7 @@ static void unaligned_size(void)
*/ */
buf_size = sector_size * 5; buf_size = sector_size * 5;
base_pos = cvu64(sector_size * 2); base_pos = ((u64_t)(sector_size * 2));
if ((buf_ptr = alloc_contig(buf_size, 0, NULL)) == NULL) if ((buf_ptr = alloc_contig(buf_size, 0, NULL)) == NULL)
panic("unable to allocate memory"); panic("unable to allocate memory");
@ -1964,7 +1964,7 @@ static void unaligned_pos1(void)
*/ */
buf_size = buf2_size = sector_size * 3; buf_size = buf2_size = sector_size * 3;
base_pos = cvu64(sector_size * 3); base_pos = ((u64_t)(sector_size * 3));
if ((buf_ptr = alloc_contig(buf_size, 0, NULL)) == NULL) if ((buf_ptr = alloc_contig(buf_size, 0, NULL)) == NULL)
panic("unable to allocate memory"); panic("unable to allocate memory");
@ -1997,7 +1997,7 @@ static void unaligned_pos1(void)
fill_rand(buf2_ptr, sector_size); fill_rand(buf2_ptr, sector_size);
sum = get_sum(buf2_ptr + min_read, sector_size - min_read); sum = get_sum(buf2_ptr + min_read, sector_size - min_read);
simple_xfer(driver_minor, add64u(base_pos, sector_size - min_read), simple_xfer(driver_minor, ((u64_t)(base_pos) + (sector_size - min_read)),
buf2_ptr, min_read, FALSE, min_read, &res); buf2_ptr, min_read, FALSE, min_read, &res);
test_sum(buf2_ptr, min_read, get_sum(buf_ptr + sector_size - min_read, test_sum(buf2_ptr, min_read, get_sum(buf_ptr + sector_size - min_read,
@ -2027,7 +2027,7 @@ static void unaligned_pos1(void)
sum = get_sum(buf2_ptr, min_read); sum = get_sum(buf2_ptr, min_read);
sum2 = get_sum(buf2_ptr + min_read * 2, sector_size - min_read * 2); sum2 = get_sum(buf2_ptr + min_read * 2, sector_size - min_read * 2);
simple_xfer(driver_minor, add64u(base_pos, min_read), simple_xfer(driver_minor, ((u64_t)(base_pos) + (min_read)),
buf2_ptr + min_read, min_read, FALSE, min_read, &res); buf2_ptr + min_read, min_read, FALSE, min_read, &res);
test_sum(buf2_ptr + min_read, min_read, get_sum(buf_ptr + min_read, test_sum(buf2_ptr + min_read, min_read, get_sum(buf_ptr + min_read,
@ -2046,7 +2046,7 @@ static void unaligned_pos1(void)
fill_rand(buf2_ptr, buf2_size); fill_rand(buf2_ptr, buf2_size);
sum = get_sum(buf2_ptr + size, buf2_size - size); sum = get_sum(buf2_ptr + size, buf2_size - size);
simple_xfer(driver_minor, add64u(base_pos, sector_size - min_read), simple_xfer(driver_minor, ((u64_t)(base_pos) + (sector_size - min_read)),
buf2_ptr, size, FALSE, size, &res); buf2_ptr, size, FALSE, size, &res);
test_sum(buf2_ptr, size, get_sum(buf_ptr + sector_size - min_read, test_sum(buf2_ptr, size, get_sum(buf_ptr + sector_size - min_read,
@ -2072,7 +2072,7 @@ static void unaligned_pos1(void)
fill_rand(buf2_ptr, buf2_size); fill_rand(buf2_ptr, buf2_size);
sum = get_sum(buf2_ptr + sector_size, buf2_size - sector_size); sum = get_sum(buf2_ptr + sector_size, buf2_size - sector_size);
simple_xfer(driver_minor, add64u(base_pos, min_read), buf2_ptr, simple_xfer(driver_minor, ((u64_t)(base_pos) + (min_read)), buf2_ptr,
sector_size, FALSE, sector_size, &res); sector_size, FALSE, sector_size, &res);
test_sum(buf2_ptr, sector_size, get_sum(buf_ptr + min_read, test_sum(buf2_ptr, sector_size, get_sum(buf_ptr + min_read,
@ -2112,7 +2112,7 @@ static void unaligned_pos2(void)
buf_size = buf2_size = max_size + sector_size; buf_size = buf2_size = max_size + sector_size;
base_pos = cvu64(sector_size * 3); base_pos = ((u64_t)(sector_size * 3));
if ((buf_ptr = alloc_contig(buf_size, 0, NULL)) == NULL) if ((buf_ptr = alloc_contig(buf_size, 0, NULL)) == NULL)
panic("unable to allocate memory"); panic("unable to allocate memory");
@ -2133,7 +2133,7 @@ static void unaligned_pos2(void)
sum2 = fill_rand(buf_ptr + max_size, sector_size); sum2 = fill_rand(buf_ptr + max_size, sector_size);
simple_xfer(driver_minor, add64u(base_pos, max_size), simple_xfer(driver_minor, ((u64_t)(base_pos) + (max_size)),
buf_ptr + max_size, sector_size, TRUE, sector_size, buf_ptr + max_size, sector_size, TRUE, sector_size,
&res); &res);
@ -2150,7 +2150,7 @@ static void unaligned_pos2(void)
got_result(&res, "large baseline read"); got_result(&res, "large baseline read");
simple_xfer(driver_minor, add64u(base_pos, max_size), buf_ptr + simple_xfer(driver_minor, ((u64_t)(base_pos) + (max_size)), buf_ptr +
max_size, sector_size, FALSE, sector_size, &res); max_size, sector_size, FALSE, sector_size, &res);
if (may_write) if (may_write)
@ -2171,7 +2171,7 @@ static void unaligned_pos2(void)
sector_size - min_read); sector_size - min_read);
} }
vir_xfer(driver_minor, add64u(base_pos, min_read), iov, NR_IOREQS, vir_xfer(driver_minor, ((u64_t)(base_pos) + (min_read)), iov, NR_IOREQS,
FALSE, min_read * NR_IOREQS, &res); FALSE, min_read * NR_IOREQS, &res);
for (i = 0; i < NR_IOREQS; i++) { for (i = 0; i < NR_IOREQS; i++) {
@ -2193,7 +2193,7 @@ static void unaligned_pos2(void)
*/ */
fill_rand(buf2_ptr, buf2_size); fill_rand(buf2_ptr, buf2_size);
simple_xfer(driver_minor, add64u(base_pos, min_read), buf2_ptr, simple_xfer(driver_minor, ((u64_t)(base_pos) + (min_read)), buf2_ptr,
max_size, FALSE, max_size, &res); max_size, FALSE, max_size, &res);
test_sum(buf2_ptr, max_size, get_sum(buf_ptr + min_read, max_size), test_sum(buf2_ptr, max_size, get_sum(buf_ptr + min_read, max_size),
@ -2218,7 +2218,7 @@ static void unaligned_pos2(void)
iov[i].iov_size = max_block; iov[i].iov_size = max_block;
} }
vir_xfer(driver_minor, add64u(base_pos, min_read), iov, NR_IOREQS, vir_xfer(driver_minor, ((u64_t)(base_pos) + (min_read)), iov, NR_IOREQS,
FALSE, max_block * NR_IOREQS, &res); FALSE, max_block * NR_IOREQS, &res);
test_sum(buf2_ptr, max_block * NR_IOREQS, get_sum(buf_ptr + min_read, test_sum(buf2_ptr, max_block * NR_IOREQS, get_sum(buf_ptr + min_read,
@ -2280,7 +2280,7 @@ static void sweep_area(u64_t base_pos)
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
fill_rand(buf_ptr, sector_size * 3); fill_rand(buf_ptr, sector_size * 3);
simple_xfer(driver_minor, add64u(base_pos, sector_size * i), simple_xfer(driver_minor, ((u64_t)(base_pos) + (sector_size * i)),
buf_ptr, sector_size * 3, FALSE, sector_size * 3, buf_ptr, sector_size * 3, FALSE, sector_size * 3,
&res); &res);
@ -2295,7 +2295,7 @@ static void sweep_area(u64_t base_pos)
fill_rand(buf_ptr, sector_size * 3); fill_rand(buf_ptr, sector_size * 3);
simple_xfer(driver_minor, add64u(base_pos, sector_size * i), simple_xfer(driver_minor, ((u64_t)(base_pos) + (sector_size * i)),
buf_ptr, sector_size * 3, TRUE, sector_size * 3, &res); buf_ptr, sector_size * 3, TRUE, sector_size * 3, &res);
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
@ -2344,7 +2344,7 @@ static void sweep_and_check(u64_t pos, int check_integ)
if (may_write) { if (may_write) {
sum = fill_rand(buf_ptr, buf_size); sum = fill_rand(buf_ptr, buf_size);
simple_xfer(driver_minor, cvu64(0), buf_ptr, buf_size, simple_xfer(driver_minor, ((u64_t)(0)), buf_ptr, buf_size,
TRUE, buf_size, &res); TRUE, buf_size, &res);
got_result(&res, "write integrity zone"); got_result(&res, "write integrity zone");
@ -2352,7 +2352,7 @@ static void sweep_and_check(u64_t pos, int check_integ)
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
simple_xfer(driver_minor, cvu64(0), buf_ptr, buf_size, FALSE, simple_xfer(driver_minor, ((u64_t)(0)), buf_ptr, buf_size, FALSE,
buf_size, &res); buf_size, &res);
if (may_write) if (may_write)
@ -2368,7 +2368,7 @@ static void sweep_and_check(u64_t pos, int check_integ)
if (check_integ) { if (check_integ) {
fill_rand(buf_ptr, buf_size); fill_rand(buf_ptr, buf_size);
simple_xfer(driver_minor, cvu64(0), buf_ptr, buf_size, FALSE, simple_xfer(driver_minor, ((u64_t)(0)), buf_ptr, buf_size, FALSE,
buf_size, &res); buf_size, &res);
test_sum(buf_ptr, buf_size, sum, TRUE, &res); test_sum(buf_ptr, buf_size, sum, TRUE, &res);
@ -2386,7 +2386,7 @@ static void basic_sweep(void)
test_group("basic area sweep", TRUE); test_group("basic area sweep", TRUE);
sweep_area(cvu64(sector_size)); sweep_area(((u64_t)(sector_size)));
} }
static void high_disk_pos(void) static void high_disk_pos(void)
@ -2402,16 +2402,16 @@ static void high_disk_pos(void)
u64_t base_pos; u64_t base_pos;
base_pos = make64(sector_size * 4, 1L); base_pos = make64(sector_size * 4, 1L);
base_pos = sub64u(base_pos, rem64u(base_pos, sector_size)); base_pos = ((u64_t)(base_pos) - (((u64_t)(base_pos) % (unsigned)(sector_size))));
/* The partition end must exceed 32 bits. */ /* The partition end must exceed 32 bits. */
if (cmp64(add64(part.base, part.size), base_pos) < 0) { if (cmp64(((u64_t)(part.base) + (part.size)), base_pos) < 0) {
test_group("high disk positions", FALSE); test_group("high disk positions", FALSE);
return; return;
} }
base_pos = sub64u(base_pos, sector_size * 8); base_pos = ((u64_t)(base_pos) - (sector_size * 8));
/* The partition start must not. */ /* The partition start must not. */
if (cmp64(base_pos, part.base) < 0) { if (cmp64(base_pos, part.base) < 0) {
@ -2421,7 +2421,7 @@ static void high_disk_pos(void)
test_group("high disk positions", TRUE); test_group("high disk positions", TRUE);
base_pos = sub64(base_pos, part.base); base_pos = ((u64_t)(base_pos) - (part.base));
sweep_and_check(base_pos, !cmp64u(part.base, 0)); sweep_and_check(base_pos, !cmp64u(part.base, 0));
} }
@ -2444,7 +2444,7 @@ static void high_part_pos(void)
} }
base_pos = make64(sector_size * 4, 1L); base_pos = make64(sector_size * 4, 1L);
base_pos = sub64u(base_pos, rem64u(base_pos, sector_size)); base_pos = ((u64_t)(base_pos) - (((u64_t)(base_pos) % (unsigned)(sector_size))));
if (cmp64(part.size, base_pos) < 0) { if (cmp64(part.size, base_pos) < 0) {
test_group("high partition positions", FALSE); test_group("high partition positions", FALSE);
@ -2454,7 +2454,7 @@ static void high_part_pos(void)
test_group("high partition positions", TRUE); test_group("high partition positions", TRUE);
base_pos = sub64u(base_pos, sector_size * 8); base_pos = ((u64_t)(base_pos) - (sector_size * 8));
sweep_and_check(base_pos, TRUE); sweep_and_check(base_pos, TRUE);
} }
@ -2471,16 +2471,16 @@ static void high_lba_pos1(void)
*/ */
u64_t base_pos; u64_t base_pos;
base_pos = mul64u(1L << 24, sector_size); base_pos = ((u64_t)(1L << 24) * (sector_size));
/* The partition end must exceed the 24-bit sector point. */ /* The partition end must exceed the 24-bit sector point. */
if (cmp64(add64(part.base, part.size), base_pos) < 0) { if (cmp64(((u64_t)(part.base) + (part.size)), base_pos) < 0) {
test_group("high LBA positions, part one", FALSE); test_group("high LBA positions, part one", FALSE);
return; return;
} }
base_pos = sub64u(base_pos, sector_size * 8); base_pos = ((u64_t)(base_pos) - (sector_size * 8));
/* The partition start must not. */ /* The partition start must not. */
if (cmp64(base_pos, part.base) < 0) { if (cmp64(base_pos, part.base) < 0) {
@ -2491,7 +2491,7 @@ static void high_lba_pos1(void)
test_group("high LBA positions, part one", TRUE); test_group("high LBA positions, part one", TRUE);
base_pos = sub64(base_pos, part.base); base_pos = ((u64_t)(base_pos) - (part.base));
sweep_and_check(base_pos, !cmp64u(part.base, 0)); sweep_and_check(base_pos, !cmp64u(part.base, 0));
} }
@ -2505,16 +2505,16 @@ static void high_lba_pos2(void)
*/ */
u64_t base_pos; u64_t base_pos;
base_pos = mul64u(1L << 28, sector_size); base_pos = ((u64_t)(1L << 28) * (sector_size));
/* The partition end must exceed the 28-bit sector point. */ /* The partition end must exceed the 28-bit sector point. */
if (cmp64(add64(part.base, part.size), base_pos) < 0) { if (cmp64(((u64_t)(part.base) + (part.size)), base_pos) < 0) {
test_group("high LBA positions, part two", FALSE); test_group("high LBA positions, part two", FALSE);
return; return;
} }
base_pos = sub64u(base_pos, sector_size * 8); base_pos = ((u64_t)(base_pos) - (sector_size * 8));
/* The partition start must not. */ /* The partition start must not. */
if (cmp64(base_pos, part.base) < 0) { if (cmp64(base_pos, part.base) < 0) {
@ -2525,7 +2525,7 @@ static void high_lba_pos2(void)
test_group("high LBA positions, part two", TRUE); test_group("high LBA positions, part two", TRUE);
base_pos = sub64(base_pos, part.base); base_pos = ((u64_t)(base_pos) - (part.base));
sweep_and_check(base_pos, !cmp64u(part.base, 0)); sweep_and_check(base_pos, !cmp64u(part.base, 0));
} }

View File

@ -114,7 +114,7 @@ static void testmul(void)
{ {
int kdone, kidx; int kdone, kidx;
u32_t ilo = ex64lo(i), jlo = ex64lo(j); u32_t ilo = ex64lo(i), jlo = ex64lo(j);
u64_t prod = mul64(i, j); u64_t prod = ((u64_t)(i) * (j));
int prodbits; int prodbits;
/* compute maximum index of highest-order bit */ /* compute maximum index of highest-order bit */
@ -124,7 +124,7 @@ static void testmul(void)
/* compare to 32-bit multiplication if possible */ /* compare to 32-bit multiplication if possible */
if (ex64hi(i) == 0 && ex64hi(j) == 0) { if (ex64hi(i) == 0 && ex64hi(j) == 0) {
if (cmp64(prod, mul64u(ilo, jlo)) != 0) ERR; if (prod != (u64_t) ilo * jlo) ERR;
/* if there is no overflow we can check against pure 32-bit */ /* if there is no overflow we can check against pure 32-bit */
if (prodbits < 32 && cmp64u(prod, ilo * jlo) != 0) ERR; if (prodbits < 32 && cmp64u(prod, ilo * jlo) != 0) ERR;
@ -140,16 +140,16 @@ static void testmul(void)
if (prodbits >= 0 && prodbits < 64 && cmp64u(prod, 0) == 0) ERR; if (prodbits >= 0 && prodbits < 64 && cmp64u(prod, 0) == 0) ERR;
/* commutativity */ /* commutativity */
if (cmp64(prod, mul64(j, i)) != 0) ERR; if (prod != (u64_t) j * i) ERR;
/* loop though all argument value combinations for third argument */ /* loop though all argument value combinations for third argument */
for (kdone = 0, kidx = 0; k = getargval(kidx, &kdone), !kdone; kidx++) { for (kdone = 0, kidx = 0; k = getargval(kidx, &kdone), !kdone; kidx++) {
/* associativity */ /* associativity */
if (cmp64(mul64(mul64(i, j), k), mul64(i, mul64(j, k))) != 0) ERR; if ((u64_t) (i * j) * k != (u64_t) i * (j * k)) ERR;
/* left and right distributivity */ /* left and right distributivity */
if (cmp64(mul64(add64(i, j), k), add64(mul64(i, k), mul64(j, k))) != 0) ERR; if (cmp64(((u64_t)(((u64_t)(i) + (j))) * (k)), ((u64_t)(((u64_t)(i) * (k))) + (((u64_t)(j) * (k))))) != 0) ERR;
if (cmp64(mul64(i, add64(j, k)), add64(mul64(i, j), mul64(i, k))) != 0) ERR; if (cmp64(((u64_t)(i) * (((u64_t)(j) + (k)))), ((u64_t)(((u64_t)(i) * (j))) + (((u64_t)(i) * (k))))) != 0) ERR;
} }
} }
@ -165,11 +165,11 @@ static void testdiv0(void)
if (setjmp(jmpbuf_SIGFPE) == 0) { if (setjmp(jmpbuf_SIGFPE) == 0) {
/* divide by zero using various functions */ /* divide by zero using various functions */
switch (funcidx) { switch (funcidx) {
case 0: div64(i, j); ERR; break; case 0: ((u64_t)(i) / (unsigned)(j)); ERR; break;
case 1: div64u64(i, ex64lo(j)); ERR; break; case 1: ((u64_t)(i) / (unsigned)(ex64lo(j))); ERR; break;
case 2: div64u(i, ex64lo(j)); ERR; break; case 2: ((u64_t)(i) / (unsigned)(ex64lo(j))); ERR; break;
case 3: rem64(i, j); ERR; break; case 3: ((u64_t)(i) % (j)); ERR; break;
case 4: rem64u(i, ex64lo(j)); ERR; break; case 4: ((u64_t)(i) % (unsigned)(ex64lo(j))); ERR; break;
default: assert(0); ERR; break; default: assert(0); ERR; break;
} }
@ -206,8 +206,8 @@ static void testdiv(void)
} }
/* perform division, store q in k to make ERR more informative */ /* perform division, store q in k to make ERR more informative */
q = div64(i, j); q = ((u64_t)(i) / (unsigned)(j));
r = rem64(i, j); r = ((u64_t)(i) % (j));
k = q; k = q;
#if TIMED #if TIMED
@ -227,11 +227,11 @@ static void testdiv(void)
/* compare to 64/32-bit division if possible */ /* compare to 64/32-bit division if possible */
if (!ex64hi(j)) { if (!ex64hi(j)) {
if (cmp64(q, div64u64(i, ex64lo(j))) != 0) ERR; if (cmp64(q, ((u64_t)(i) / (unsigned)(ex64lo(j)))) != 0) ERR;
if (!ex64hi(q)) { if (!ex64hi(q)) {
if (cmp64u(q, div64u(i, ex64lo(j))) != 0) ERR; if (cmp64u(q, ((u64_t)(i) / (unsigned)(ex64lo(j)))) != 0) ERR;
} }
if (cmp64u(r, rem64u(i, ex64lo(j))) != 0) ERR; if (cmp64u(r, ((u64_t)(i) % (unsigned)(ex64lo(j)))) != 0) ERR;
/* compare to 32-bit division if possible */ /* compare to 32-bit division if possible */
if (!ex64hi(i)) { if (!ex64hi(i)) {
@ -241,7 +241,7 @@ static void testdiv(void)
} }
/* check results using i = q j + r and r < j */ /* check results using i = q j + r and r < j */
if (cmp64(i, add64(mul64(q, j), r)) != 0) ERR; if (cmp64(i, ((u64_t)(((u64_t)(q) * (j))) + (r))) != 0) ERR;
if (cmp64(r, j) >= 0) ERR; if (cmp64(r, j) >= 0) ERR;
} }

View File

@ -13,12 +13,15 @@
#if defined(__minix) #if defined(__minix)
#include <minix/minlib.h> #include <minix/minlib.h>
#include <minix/partition.h> #include <minix/partition.h>
#include <minix/u64.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#elif defined(__linux__) #elif defined(__linux__)
#include <mntent.h> #include <mntent.h>
#endif #endif
#ifndef __minix
typedef unsigned long long u64_t;
#endif
#include <assert.h> #include <assert.h>
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
@ -371,7 +374,7 @@ main(int argc, char *argv[])
testb = alloc_block(); testb = alloc_block();
/* Try writing the last block of partition or diskette. */ /* Try writing the last block of partition or diskette. */
if(lseek64(fd, mul64u(blocks - 1, block_size), SEEK_SET, NULL) < 0) { if(lseek64(fd, ((u64_t)(blocks - 1) * (block_size)), SEEK_SET, NULL) < 0) {
err(1, "couldn't seek to last block to test size (1)"); err(1, "couldn't seek to last block to test size (1)");
} }
testb[0] = 0x3245; testb[0] = 0x3245;
@ -381,7 +384,7 @@ main(int argc, char *argv[])
err(1, "File system is too big for minor device (write1 %d/%u)", err(1, "File system is too big for minor device (write1 %d/%u)",
w, block_size); w, block_size);
sync(); /* flush write, so if error next read fails */ sync(); /* flush write, so if error next read fails */
if(lseek64(fd, mul64u(blocks - 1, block_size), SEEK_SET, NULL) < 0) { if(lseek64(fd, ((u64_t)(blocks - 1) * (block_size)), SEEK_SET, NULL) < 0) {
err(1, "couldn't seek to last block to test size (2)"); err(1, "couldn't seek to last block to test size (2)");
} }
testb[0] = 0; testb[0] = 0;
@ -395,7 +398,7 @@ main(int argc, char *argv[])
testb[0], testb[1], testb[block_size-1]); testb[0], testb[1], testb[block_size-1]);
errx(1, "File system is too big for minor device (read)"); errx(1, "File system is too big for minor device (read)");
} }
lseek64(fd, mul64u(blocks - 1, block_size), SEEK_SET, NULL); lseek64(fd, ((u64_t)(blocks - 1) * (block_size)), SEEK_SET, NULL);
testb[0] = 0; testb[0] = 0;
testb[1] = 0; testb[1] = 0;
testb[block_size/2-1] = 0; testb[block_size/2-1] = 0;
@ -550,10 +553,10 @@ sizeup(char * device)
return 0; return 0;
} }
d = div64u(bytes, block_size); d = ((u64_t)(bytes) / (unsigned)(block_size));
rem = rem64u(bytes, block_size); rem = ((u64_t)(bytes) % (unsigned)(block_size));
resize = add64u(mul64u(d, block_size), rem); resize = ((u64_t)(((u64_t)(d) * (block_size))) + (rem));
if(cmp64(resize, bytes) != 0) { if(cmp64(resize, bytes) != 0) {
/* Assume block_t is unsigned */ /* Assume block_t is unsigned */
d = (block_t)(-1ul); d = (block_t)(-1ul);
@ -1570,7 +1573,7 @@ get_block(block_t n, void *buf)
memcpy(buf, zero, block_size); memcpy(buf, zero, block_size);
return; return;
} }
if (lseek64(fd, mul64u(n, block_size), SEEK_SET, NULL) == (off_t)(-1)) if (lseek64(fd, ((u64_t)(n) * (block_size)), SEEK_SET, NULL) == (off_t)(-1))
pexit("get_block couldn't seek"); pexit("get_block couldn't seek");
k = read(fd, buf, block_size); k = read(fd, buf, block_size);
if (k != block_size) if (k != block_size)
@ -1597,7 +1600,7 @@ put_block(block_t n, void *buf)
(void) read_and_set(n); (void) read_and_set(n);
if (lseek64(fd, mul64u(n, block_size), SEEK_SET, NULL) == (off_t) -1) if (lseek64(fd, ((u64_t)(n) * (block_size)), SEEK_SET, NULL) == (off_t) -1)
pexit("put_block couldn't seek"); pexit("put_block couldn't seek");
if (write(fd, buf, block_size)!= block_size) if (write(fd, buf, block_size)!= block_size)
pexit("put_block couldn't write block #%u", (unsigned)n); pexit("put_block couldn't write block #%u", (unsigned)n);