From f1b0deacf38bd0136a8a28455212f20b57842f0f Mon Sep 17 00:00:00 2001 From: Gerard Date: Mon, 11 Nov 2013 19:17:03 +0100 Subject: [PATCH] Replaced add64, add64u and add64ul with operators. Change-Id: Ia537f83e15cb686f1b81b34d73596f4298b0a924 --- drivers/fbd/rule.c | 2 +- drivers/floppy/floppy.c | 2 +- drivers/random/main.c | 2 +- include/minix/u64.h | 15 --------------- include/timers.h | 4 ++-- kernel/arch/earm/arch_clock.c | 6 ++---- kernel/system/do_getinfo.c | 3 +-- lib/libhgfs/time.c | 4 ++-- lib/libsffs/read.c | 2 +- lib/libsffs/write.c | 2 +- lib/libsys/arch/i386/profile.c | 8 +++----- lib/libsys/arch/i386/tsc_util.c | 2 +- lib/libvboxfs/attr.c | 2 +- servers/ext2/read.c | 6 +++--- servers/iso9660fs/read.c | 6 +++--- servers/iso9660fs/super.c | 2 +- servers/mfs/read.c | 6 +++--- servers/vfs/open.c | 2 +- servers/vfs/read.c | 2 +- test/test53.c | 6 +++--- usr.sbin/mkfs.mfs/mkfs.c | 2 +- 21 files changed, 33 insertions(+), 53 deletions(-) diff --git a/drivers/fbd/rule.c b/drivers/fbd/rule.c index 81ebc6620..f5c140b17 100644 --- a/drivers/fbd/rule.c +++ b/drivers/fbd/rule.c @@ -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). */ - if (cmp64(rule->start, add64u(pos, size)) >= 0 || + if (cmp64(rule->start, pos + size) >= 0 || (cmp64u(rule->end, 0) && cmp64(rule->end, pos) <= 0)) return FALSE; diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index 43f15f402..f62790f11 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -500,7 +500,7 @@ static ssize_t f_transfer( /* Which block on disk and how close to EOF? */ if (position >= dv_size) return(total); /* At EOF */ if (position + nbytes > dv_size) nbytes = dv_size - position; - block = div64u(add64ul(f_dv->dv_base, position), SECTOR_SIZE); + block = div64u(f_dv->dv_base + position, SECTOR_SIZE); if ((nbytes & SECTOR_MASK) != 0) return(EINVAL); diff --git a/drivers/random/main.c b/drivers/random/main.c index 18ed36d34..4202648f6 100644 --- a/drivers/random/main.c +++ b/drivers/random/main.c @@ -202,7 +202,7 @@ static int r_transfer( } /* Book the number of bytes transferred. */ - position= add64u(position, count); + position += count; if ((iov->iov_size -= count) == 0) { iov++; nr_req--; vir_offset = 0; } } diff --git a/include/minix/u64.h b/include/minix/u64.h index a03cae37c..5411aa399 100644 --- a/include/minix/u64.h +++ b/include/minix/u64.h @@ -9,21 +9,6 @@ #include -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) { int index; diff --git a/include/timers.h b/include/timers.h index dcb5ba490..683dca923 100644 --- a/include/timers.h +++ b/include/timers.h @@ -89,12 +89,12 @@ clock_t tmrs_settimer(timer_t **tmrs, timer_t *tp, clock_t exp_time, if(_cum_instances == 0) { \ RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \ } \ - _next_cum_spent = add64(_cum_spenttime, _dt); \ + _next_cum_spent = _cum_spenttime + _dt; \ if(ex64hi(_next_cum_spent)) { \ PRINT_STATS(_cum_spenttime, _cum_instances); \ RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \ } \ - _cum_spenttime = add64(_cum_spenttime, _dt); \ + _cum_spenttime += _dt; \ _cum_instances++; \ _cum_dt = sub64(_endtime, _cum_starttime); \ if(cmp64(_cum_dt, make64(0, 120)) > 0) { \ diff --git a/kernel/arch/earm/arch_clock.c b/kernel/arch/earm/arch_clock.c index 4d2c2164f..754c6ccde 100644 --- a/kernel/arch/earm/arch_clock.c +++ b/kernel/arch/earm/arch_clock.c @@ -68,14 +68,12 @@ void context_stop(struct proc * p) p->p_cycles += tsc_delta; if(kbill_ipc) { - kbill_ipc->p_kipc_cycles = - add64(kbill_ipc->p_kipc_cycles, tsc_delta); + kbill_ipc->p_kipc_cycles += tsc_delta; kbill_ipc = NULL; } if(kbill_kcall) { - kbill_kcall->p_kcall_cycles = - add64(kbill_kcall->p_kcall_cycles, tsc_delta); + kbill_kcall->p_kcall_cycles += tsc_delta; kbill_kcall = NULL; } diff --git a/kernel/system/do_getinfo.c b/kernel/system/do_getinfo.c index fef7ce5a4..94818c89d 100644 --- a/kernel/system/do_getinfo.c +++ b/kernel/system/do_getinfo.c @@ -30,8 +30,7 @@ static void update_idle_time(void) idl->p_cycles = make64(0, 0); for (i = 0; i < CONFIG_MAX_CPUS ; i++) { - idl->p_cycles = add64(idl->p_cycles, - get_cpu_var(i, idle_proc).p_cycles); + idl->p_cycles += get_cpu_var(i, idle_proc).p_cycles; } } diff --git a/lib/libhgfs/time.c b/lib/libhgfs/time.c index 1dc806056..ba3085f14 100644 --- a/lib/libhgfs/time.c +++ b/lib/libhgfs/time.c @@ -33,8 +33,8 @@ void time_put(struct timespec *tsp) u64_t hgfstime; if (tsp != NULL) { - hgfstime = add64ul(mul64u(tsp->tv_sec, 10000000), tsp->tv_nsec / 100); - hgfstime = add64(hgfstime, time_offset); + hgfstime = mul64u(tsp->tv_sec, 10000000) + (tsp->tv_nsec / 100); + hgfstime += time_offset; RPC_NEXT32 = ex64lo(hgfstime); RPC_NEXT32 = ex64hi(hgfstime); diff --git a/lib/libsffs/read.c b/lib/libsffs/read.c index e34bd28d2..d27d9839d 100644 --- a/lib/libsffs/read.c +++ b/lib/libsffs/read.c @@ -61,7 +61,7 @@ int do_read() count -= chunk; off += chunk; - pos = add64u(pos, chunk); + pos += chunk; } if (r < 0) diff --git a/lib/libsffs/write.c b/lib/libsffs/write.c index bf70038a7..bd571a337 100644 --- a/lib/libsffs/write.c +++ b/lib/libsffs/write.c @@ -64,7 +64,7 @@ cp_grant_id_t *grantp; count -= r; off += r; - pos = add64u(pos, r); + pos += r; } if (r < 0) diff --git a/lib/libsys/arch/i386/profile.c b/lib/libsys/arch/i386/profile.c index 51c90f711..6f795c1fc 100644 --- a/lib/libsys/arch/i386/profile.c +++ b/lib/libsys/arch/i386/profile.c @@ -192,9 +192,8 @@ void procexit (char *UNUSED(name)) /* Calculate "small" difference. */ spent = sub64(stop, cprof_stk[cprof_stk_top].start_2); - cprof_stk[cprof_stk_top].slot->cycles = - add64(cprof_stk[cprof_stk_top].slot->cycles, - sub64(spent, cprof_stk[cprof_stk_top].spent_deeper)); + cprof_stk[cprof_stk_top].slot->cycles += + sub64(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)); @@ -220,8 +219,7 @@ void procexit (char *UNUSED(name)) spent = sub64(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 = - add64(cprof_stk[cprof_stk_top].spent_deeper, spent); + cprof_stk[cprof_stk_top].spent_deeper += spent; cprof_locked = 0; } diff --git a/lib/libsys/arch/i386/tsc_util.c b/lib/libsys/arch/i386/tsc_util.c index 87b2b8c1c..9897efcad 100644 --- a/lib/libsys/arch/i386/tsc_util.c +++ b/lib/libsys/arch/i386/tsc_util.c @@ -63,7 +63,7 @@ micro_delay(u32_t micros) CALIBRATE; /* We have to know when to end the delay. */ - end = add64(now, mul64u(micros, calib_mhz)); + end = now + mul64u(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 diff --git a/lib/libvboxfs/attr.c b/lib/libvboxfs/attr.c index 6017748a8..cef9c8a82 100644 --- a/lib/libvboxfs/attr.c +++ b/lib/libvboxfs/attr.c @@ -21,7 +21,7 @@ static u64_t set_time(struct timespec *tsp) { - return add64u(mul64u(tsp->tv_sec, 1000000000), tsp->tv_nsec); + return mul64u(tsp->tv_sec, 1000000000) + tsp->tv_nsec; } /* diff --git a/servers/ext2/read.c b/servers/ext2/read.c index f095a4579..4988d9545 100644 --- a/servers/ext2/read.c +++ b/servers/ext2/read.c @@ -185,9 +185,9 @@ int fs_breadwrite(void) if (rdwt_err < 0) break; /* Update counters and pointers. */ - nrbytes -= chunk; /* bytes yet to be read */ - cum_io += chunk; /* bytes read so far */ - position = add64ul(position, chunk); /* position within the file */ + nrbytes -= chunk; /* bytes yet to be read */ + cum_io += chunk; /* bytes read so far */ + position += chunk; /* position within the file */ } fs_m_out.RES_SEEK_POS_LO = ex64lo(position); diff --git a/servers/iso9660fs/read.c b/servers/iso9660fs/read.c index f43bd1c7c..045fddfe3 100644 --- a/servers/iso9660fs/read.c +++ b/servers/iso9660fs/read.c @@ -119,9 +119,9 @@ int fs_bread(void) if (rdwt_err < 0) break; /* Update counters and pointers. */ - nrbytes -= chunk; /* bytes yet to be read */ - cum_io += chunk; /* bytes read so far */ - position= add64ul(position, chunk); /* position within the file */ + nrbytes -= chunk; /* bytes yet to be read */ + cum_io += chunk; /* bytes read so far */ + position += chunk; /* position within the file */ } fs_m_out.RES_SEEK_POS_LO = ex64lo(position); diff --git a/servers/iso9660fs/super.c b/servers/iso9660fs/super.c index 0df66b113..3f9bcfab8 100644 --- a/servers/iso9660fs/super.c +++ b/servers/iso9660fs/super.c @@ -108,7 +108,7 @@ int read_vds( /* I dont need to save anything about it */ vol_ok = TRUE; - offset = add64u(offset,ISO9660_MIN_BLOCK_SIZE); + offset += ISO9660_MIN_BLOCK_SIZE; } if (vol_ok == FALSE) diff --git a/servers/mfs/read.c b/servers/mfs/read.c index fa41d27b8..704776261 100644 --- a/servers/mfs/read.c +++ b/servers/mfs/read.c @@ -194,9 +194,9 @@ int fs_breadwrite(void) if (lmfs_rdwt_err() < 0) break; /* Update counters and pointers. */ - nrbytes -= chunk; /* bytes yet to be read */ - cum_io += chunk; /* bytes read so far */ - position = add64ul(position, chunk); /* position within the file */ + nrbytes -= chunk; /* bytes yet to be read */ + cum_io += chunk; /* bytes read so far */ + position += chunk; /* position within the file */ } fs_m_out.RES_SEEK_POS_LO = ex64lo(position); diff --git a/servers/vfs/open.c b/servers/vfs/open.c index 2d0dde200..3b1b5b9b0 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -615,7 +615,7 @@ int actual_lseek(message *m_out, int seekfd, int seekwhence, off_t offset) } if (offset >= 0) - newpos = add64ul(pos, offset); + newpos = pos + offset; else newpos = sub64ul(pos, -offset); diff --git a/servers/vfs/read.c b/servers/vfs/read.c index a96f07066..173e4ee00 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -181,7 +181,7 @@ int read_write(struct fproc *rfp, int rw_flag, struct filp *f, suspend_reopen); if (r >= 0) { cum_io = r; - position = add64ul(position, r); + position += r; r = OK; } } else if (S_ISBLK(vp->v_mode)) { /* Block special files. */ diff --git a/test/test53.c b/test/test53.c index 6f946a688..d7d14e583 100644 --- a/test/test53.c +++ b/test/test53.c @@ -148,8 +148,8 @@ static void testmul(void) if (cmp64(mul64(mul64(i, j), k), mul64(i, mul64(j, k))) != 0) ERR; /* left and right distributivity */ - if (cmp64(mul64(add64(i, j), k), add64(mul64(i, k), mul64(j, k))) != 0) ERR; - if (cmp64(mul64(i, add64(j, k)), add64(mul64(i, j), mul64(i, k))) != 0) ERR; + if (cmp64(mul64(i + j, k), mul64(i, k) + mul64(j, k)) != 0) ERR; + if (cmp64(mul64(i, j + k), mul64(i, j) + mul64(i, k)) != 0) ERR; } } @@ -241,7 +241,7 @@ static void testdiv(void) } /* check results using i = q j + r and r < j */ - if (cmp64(i, add64(mul64(q, j), r)) != 0) ERR; + if (cmp64(i, mul64(q, j) + r) != 0) ERR; if (cmp64(r, j) >= 0) ERR; } diff --git a/usr.sbin/mkfs.mfs/mkfs.c b/usr.sbin/mkfs.mfs/mkfs.c index b5256cb98..36f506cf4 100644 --- a/usr.sbin/mkfs.mfs/mkfs.c +++ b/usr.sbin/mkfs.mfs/mkfs.c @@ -556,7 +556,7 @@ sizeup(char * device) d = div64u(bytes, block_size); rem = rem64u(bytes, block_size); - resize = add64u(mul64u(d, block_size), rem); + resize = mul64u(d, block_size) + rem; if(cmp64(resize, bytes) != 0) { /* Assume block_t is unsigned */ d = (block_t)(-1ul);