Replaced common u64.h functions with operators.
Change-Id: I71b7b4879209eeff89ce5748d67102afebf871dc
This commit is contained in:
@@ -293,7 +293,8 @@ static int do_dioctl(struct blockdriver *bdp, dev_t minor,
|
||||
(*bdp->bdr_geometry)(minor, &entry);
|
||||
} else {
|
||||
/* The driver doesn't care -- make up fake geometry. */
|
||||
entry.cylinders = div64u(entry.size, SECTOR_SIZE) / (64 * 32);
|
||||
entry.cylinders = (unsigned long)(entry.size / SECTOR_SIZE) /
|
||||
(64 * 32);
|
||||
entry.heads = 64;
|
||||
entry.sectors = 32;
|
||||
}
|
||||
|
||||
@@ -72,9 +72,9 @@ u8_t *tmp_buf; /* temporary buffer */
|
||||
|
||||
/* Get the geometry of the device to partition */
|
||||
if ((dv = (*bdp->bdr_part)(device)) == NULL
|
||||
|| cmp64u(dv->dv_size, 0) == 0) return;
|
||||
base = div64u(dv->dv_base, SECTOR_SIZE);
|
||||
limit = base + div64u(dv->dv_size, SECTOR_SIZE);
|
||||
|| dv->dv_size == 0) return;
|
||||
base = (unsigned long)(dv->dv_base / SECTOR_SIZE);
|
||||
limit = base + (unsigned long)(dv->dv_size / SECTOR_SIZE);
|
||||
|
||||
/* Read the partition table for the device. */
|
||||
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 (part_limit < pe->lowsec) part_limit = pe->lowsec;
|
||||
|
||||
dv->dv_base = mul64u(pe->lowsec, SECTOR_SIZE);
|
||||
dv->dv_size = mul64u(part_limit - pe->lowsec, SECTOR_SIZE);
|
||||
dv->dv_base = (u64_t)pe->lowsec * SECTOR_SIZE;
|
||||
dv->dv_size = (u64_t)(part_limit - pe->lowsec) * SECTOR_SIZE;
|
||||
|
||||
if (style == P_PRIMARY) {
|
||||
/* Each Minix primary partition can be subpartitioned. */
|
||||
@@ -163,9 +163,9 @@ u8_t *tmp_buf; /* temporary buffer */
|
||||
if (pe->sysind != NO_PART) {
|
||||
if ((dv = (*bdp->bdr_part)(subdev)) == NULL) return;
|
||||
|
||||
dv->dv_base = mul64u(extbase + offset + pe->lowsec,
|
||||
SECTOR_SIZE);
|
||||
dv->dv_size = mul64u(pe->size, SECTOR_SIZE);
|
||||
dv->dv_base = (u64_t)(extbase + offset + pe->lowsec) *
|
||||
SECTOR_SIZE;
|
||||
dv->dv_size = (u64_t)pe->size * SECTOR_SIZE;
|
||||
|
||||
/* Out of devices? */
|
||||
if (++subdev % NR_PARTITIONS == 0) return;
|
||||
@@ -191,7 +191,7 @@ u8_t *tmp_buf; /* temporary buffer */
|
||||
u64_t position;
|
||||
int r;
|
||||
|
||||
position = mul64u(offset, SECTOR_SIZE);
|
||||
position = (u64_t)offset * SECTOR_SIZE;
|
||||
iovec1.iov_addr = (vir_bytes) tmp_buf;
|
||||
iovec1.iov_size = CD_SECTOR_SIZE;
|
||||
r = (*bdp->bdr_transfer)(device, FALSE /*do_write*/, position, SELF,
|
||||
|
||||
@@ -40,7 +40,7 @@ static u32_t trace_gettime(void)
|
||||
|
||||
read_tsc_64(&tsc);
|
||||
|
||||
tsc = sub64(tsc, trace_tsc);
|
||||
tsc -= trace_tsc;
|
||||
|
||||
return tsc_64_to_micros(tsc);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ void time_init(void)
|
||||
* the difference between that time and the UNIX epoch, in 100ns units.
|
||||
*/
|
||||
/* FIXME: we currently do not take into account timezones. */
|
||||
time_offset = mul64u(116444736, 1000000000);
|
||||
time_offset = (u64_t)116444736 * 1000000000;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
@@ -33,7 +33,7 @@ void time_put(struct timespec *tsp)
|
||||
u64_t hgfstime;
|
||||
|
||||
if (tsp != NULL) {
|
||||
hgfstime = mul64u(tsp->tv_sec, 10000000) + (tsp->tv_nsec / 100);
|
||||
hgfstime = ((u64_t)tsp->tv_sec * 10000000) + (tsp->tv_nsec / 100);
|
||||
hgfstime += time_offset;
|
||||
|
||||
RPC_NEXT32 = ex64lo(hgfstime);
|
||||
@@ -60,10 +60,10 @@ void time_get(struct timespec *tsp)
|
||||
time_lo = RPC_NEXT32;
|
||||
time_hi = RPC_NEXT32;
|
||||
|
||||
hgfstime = sub64(make64(time_lo, time_hi), time_offset);
|
||||
hgfstime = make64(time_lo, time_hi) - time_offset;
|
||||
|
||||
tsp->tv_sec = div64u(hgfstime, 10000000);
|
||||
tsp->tv_nsec = rem64u(hgfstime, 10000000) * 100;
|
||||
tsp->tv_sec = (unsigned long)(hgfstime / 10000000);
|
||||
tsp->tv_nsec = (unsigned)(hgfstime % 10000000) * 100;
|
||||
}
|
||||
else RPC_ADVANCE(sizeof(u32_t) * 2);
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ static u32_t fs_bufs_heuristic(int minbufs, u32_t btotal, u64_t bfree,
|
||||
vsi.vsi_pagesize / 1024;
|
||||
|
||||
/* check fs usage. */
|
||||
kbytes_used_fs = div64u(mul64u(bused, blocksize), 1024);
|
||||
kbytes_total_fs = div64u(mul64u(btotal, blocksize), 1024);
|
||||
kbytes_used_fs = (unsigned long)(((u64_t)bused * blocksize) / 1024);
|
||||
kbytes_total_fs = (unsigned long)(((u64_t)btotal * blocksize) / 1024);
|
||||
|
||||
/* heuristic for a desired cache size based on FS usage;
|
||||
* but never bigger than half of the total filesystem
|
||||
@@ -518,7 +518,7 @@ register struct buf *bp; /* buffer pointer */
|
||||
ASSERT(bp->lmfs_bytes == fs_block_size);
|
||||
ASSERT(fs_block_size > 0);
|
||||
|
||||
pos = mul64u(bp->lmfs_blocknr, fs_block_size);
|
||||
pos = (u64_t)bp->lmfs_blocknr * fs_block_size;
|
||||
if(fs_block_size > PAGE_SIZE) {
|
||||
#define MAXPAGES 20
|
||||
vir_bytes blockrem, vaddr = (vir_bytes) bp->data;
|
||||
@@ -704,7 +704,7 @@ void lmfs_rw_scattered(
|
||||
assert(nblocks > 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)
|
||||
r = bdev_gather(dev, pos, iovec, niovecs, BDEV_NOFLAGS);
|
||||
else
|
||||
|
||||
@@ -19,7 +19,7 @@ SRCS+= dhcp_gettag.c dhcp_settag.c
|
||||
SRCS+= gcov.c gcov_flush.c
|
||||
|
||||
# Various utils
|
||||
SRCS+= itoa.c u64util.c read_tsc_64.c
|
||||
SRCS+= itoa.c read_tsc_64.c
|
||||
|
||||
# servxcheck
|
||||
SRCS+= servxcheck.c
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/* Few u64 utils implemented in C
|
||||
* Author: Gautam BT
|
||||
*/
|
||||
#include <minix/u64.h>
|
||||
|
||||
u64_t rrotate64(u64_t x, unsigned short b)
|
||||
{
|
||||
b %= 64;
|
||||
if ((b &= 63) == 0)
|
||||
return x;
|
||||
return (x >> b) | (x << (64 - b));
|
||||
}
|
||||
|
||||
u64_t rshift64(u64_t x, unsigned short b)
|
||||
{
|
||||
if (b >= 64)
|
||||
return 0;
|
||||
return x >> b;
|
||||
}
|
||||
|
||||
u64_t xor64(u64_t a, u64_t b)
|
||||
{
|
||||
return a ^ b;
|
||||
}
|
||||
|
||||
u64_t and64(u64_t a, u64_t b)
|
||||
{
|
||||
return a & b;
|
||||
}
|
||||
|
||||
u64_t not64(u64_t a)
|
||||
{
|
||||
return ~a;
|
||||
}
|
||||
@@ -47,8 +47,8 @@ int do_statvfs()
|
||||
statvfs.f_bsize = BLOCK_SIZE;
|
||||
statvfs.f_frsize = BLOCK_SIZE;
|
||||
statvfs.f_iosize = BLOCK_SIZE;
|
||||
statvfs.f_blocks = div64u(total, BLOCK_SIZE);
|
||||
statvfs.f_bfree = div64u(free, BLOCK_SIZE);
|
||||
statvfs.f_blocks = (unsigned long)(total / BLOCK_SIZE);
|
||||
statvfs.f_bfree = (unsigned long)(free / BLOCK_SIZE);
|
||||
statvfs.f_bavail = statvfs.f_bfree;
|
||||
statvfs.f_namemax = NAME_MAX;
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ int do_stat()
|
||||
stat.st_uid = sffs_params->p_uid;
|
||||
stat.st_gid = sffs_params->p_gid;
|
||||
stat.st_rdev = NO_DEV;
|
||||
if (cmp64u(attr.a_size, LONG_MAX) > 0)
|
||||
if (attr.a_size > LONG_MAX)
|
||||
stat.st_size = LONG_MAX;
|
||||
else
|
||||
stat.st_size = ex64lo(attr.a_size);
|
||||
|
||||
@@ -138,7 +138,7 @@ int do_ftrunc()
|
||||
start = make64(m_in.REQ_TRC_START_LO, m_in.REQ_TRC_START_HI);
|
||||
end = make64(m_in.REQ_TRC_END_LO, m_in.REQ_TRC_END_HI);
|
||||
|
||||
if (cmp64u(end, 0) == 0) {
|
||||
if (end == 0) {
|
||||
/* Truncate or expand the file. */
|
||||
if ((r = verify_inode(ino, path, NULL)) != OK)
|
||||
return r;
|
||||
@@ -149,9 +149,9 @@ int do_ftrunc()
|
||||
r = sffs_table->t_setattr(path, &attr);
|
||||
} else {
|
||||
/* Write zeroes to the file. We can't create holes. */
|
||||
if (cmp64(end, start) <= 0) return EINVAL;
|
||||
if (end <= start) return EINVAL;
|
||||
|
||||
delta = sub64(end, start);
|
||||
delta = end - start;
|
||||
|
||||
if (ex64hi(delta) != 0) return EINVAL;
|
||||
|
||||
|
||||
@@ -67,10 +67,10 @@ double getidle(void)
|
||||
if ((r = sys_getidletsc(&idle2)) != OK)
|
||||
return -1.0;
|
||||
|
||||
idelta = sub64(idle2, idle);
|
||||
tdelta = sub64(stop, start);
|
||||
idelta = idle2 - idle;
|
||||
tdelta = stop - start;
|
||||
|
||||
if (cmp64(idelta, tdelta) >= 0)
|
||||
if (idelta >= tdelta)
|
||||
return 100.0;
|
||||
|
||||
ifp = make_double(idelta);
|
||||
|
||||
@@ -191,9 +191,9 @@ void procexit (char *UNUSED(name))
|
||||
*/
|
||||
|
||||
/* Calculate "small" difference. */
|
||||
spent = sub64(stop, cprof_stk[cprof_stk_top].start_2);
|
||||
spent = stop - cprof_stk[cprof_stk_top].start_2;
|
||||
cprof_stk[cprof_stk_top].slot->cycles +=
|
||||
sub64(spent, cprof_stk[cprof_stk_top].spent_deeper);
|
||||
spent - cprof_stk[cprof_stk_top].spent_deeper;
|
||||
|
||||
/* Clear spent_deeper for call level we're leaving. */
|
||||
cprof_stk[cprof_stk_top].spent_deeper = ((u64_t)(0));
|
||||
@@ -216,7 +216,7 @@ void procexit (char *UNUSED(name))
|
||||
stop = make64(tsc_lo, tsc_hi);
|
||||
|
||||
/* Calculate "big" difference. */
|
||||
spent = sub64(stop, cprof_stk[cprof_stk_top].start_1);
|
||||
spent = stop - cprof_stk[cprof_stk_top].start_1;
|
||||
cprof_stk_top--; /* decrease stack */
|
||||
if (cprof_stk_top >= 0) /* don't update non-existent level -1 */
|
||||
cprof_stk[cprof_stk_top].spent_deeper += spent;
|
||||
|
||||
@@ -61,7 +61,7 @@ int spin_check(spin_t *s)
|
||||
case STATE_TS:
|
||||
read_tsc_64(&cur_tsc);
|
||||
|
||||
tsc_delta = sub64(cur_tsc, s->s_base_tsc);
|
||||
tsc_delta = cur_tsc - s->s_base_tsc;
|
||||
|
||||
micro_delta = tsc_64_to_micros(tsc_delta);
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ micro_delay(u32_t micros)
|
||||
CALIBRATE;
|
||||
|
||||
/* We have to know when to end the delay. */
|
||||
end = now + mul64u(micros, calib_mhz);
|
||||
end = now + ((u64_t)micros * calib_mhz);
|
||||
|
||||
/* If we have to wait for at least one HZ tick, use the regular
|
||||
* tickdelay first. Round downwards on purpose, so the average
|
||||
@@ -75,7 +75,7 @@ micro_delay(u32_t micros)
|
||||
tickdelay(micros*Hz/MICROHZ);
|
||||
|
||||
/* Wait (the rest) of the delay time using busywait. */
|
||||
while(cmp64(now, end) < 0)
|
||||
while(now < end)
|
||||
read_tsc_64(&now);
|
||||
|
||||
return OK;
|
||||
@@ -87,7 +87,7 @@ u32_t tsc_64_to_micros(u64_t tsc)
|
||||
|
||||
CALIBRATE;
|
||||
|
||||
tmp = div64u64(tsc, calib_mhz);
|
||||
tmp = tsc / calib_mhz;
|
||||
if (ex64hi(tmp)) {
|
||||
printf("tsc_64_to_micros: more than 2^32ms\n");
|
||||
return ~0UL;
|
||||
|
||||
@@ -31,7 +31,7 @@ micros_to_ticks(u32_t micros)
|
||||
{
|
||||
u32_t ticks;
|
||||
|
||||
ticks = div64u(mul64u(micros, sys_hz()), 1000000);
|
||||
ticks = (u32_t)(((u64_t)micros * sys_hz()) / 1000000);
|
||||
if(ticks < 1) ticks = 1;
|
||||
|
||||
return ticks;
|
||||
|
||||
@@ -10,8 +10,8 @@ static void
|
||||
get_time(struct timespec *tsp, u64_t nsecs)
|
||||
{
|
||||
|
||||
tsp->tv_sec = div64u(nsecs, 1000000000);
|
||||
tsp->tv_nsec = rem64u(nsecs, 1000000000);
|
||||
tsp->tv_sec = (unsigned long)(nsecs / 1000000000);
|
||||
tsp->tv_nsec = (unsigned)(nsecs % 1000000000);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -21,7 +21,7 @@ static u64_t
|
||||
set_time(struct timespec *tsp)
|
||||
{
|
||||
|
||||
return mul64u(tsp->tv_sec, 1000000000) + tsp->tv_nsec;
|
||||
return ((u64_t)tsp->tv_sec * 1000000000) + tsp->tv_nsec;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user