From 984a00592cbe2324c5f27d21a32913625aa95284 Mon Sep 17 00:00:00 2001 From: Gerard Date: Mon, 11 Nov 2013 19:17:03 +0100 Subject: [PATCH] Removal of u64.h Change-Id: I895b530a44d80ffbab40466b360981d39b06e9a5 --- commands/autopart/autopart.c | 13 ++- commands/btrace/btrace.c | 4 +- commands/fbdctl/fbdctl.c | 15 ++-- commands/fsck.mfs/fsck.c | 7 +- commands/part/part.c | 9 +- commands/partition/partition.c | 5 +- commands/time/time.c | 1 - commands/vol/vol.c | 1 - drivers/fb/fb.c | 6 +- drivers/fbd/action.c | 10 +-- drivers/fbd/fbd.c | 8 +- drivers/fbd/rule.c | 4 +- drivers/filter/driver.c | 4 +- drivers/filter/main.c | 8 +- drivers/filter/sum.c | 7 +- drivers/floppy/floppy.c | 8 +- drivers/hello/hello.c | 12 +-- drivers/i2c/i2c.c | 4 +- drivers/memory/memory.c | 8 +- include/minix/Makefile | 2 +- include/minix/driver.h | 1 - include/minix/hash.h | 10 +-- include/minix/partition.h | 2 - include/minix/sffs.h | 1 - include/minix/syslib.h | 1 - include/minix/u64.h | 131 ---------------------------- include/timers.h | 19 ++-- kernel/arch/earm/arch_clock.c | 5 +- kernel/arch/earm/arch_reset.c | 1 - kernel/arch/earm/arch_system.c | 2 - kernel/arch/i386/apic.c | 8 +- kernel/arch/i386/arch_clock.c | 9 +- kernel/arch/i386/arch_reset.c | 2 - kernel/arch/i386/arch_system.c | 10 +-- kernel/arch/i386/arch_watchdog.c | 23 +++-- kernel/debug.c | 5 +- kernel/main.c | 3 +- kernel/system/do_fork.c | 1 - kernel/system/do_getinfo.c | 3 +- lib/libbdev/bdev.c | 12 +-- lib/libblockdriver/driver.c | 6 +- lib/libblockdriver/drvlib.c | 18 ++-- lib/libblockdriver/trace.c | 4 +- lib/libc/minix/malloc-debug.h | 1 - lib/libc/minix/minix-malloc-debug.c | 2 +- lib/libc/sys-minix/lseek64.c | 7 +- lib/libc/sys-minix/mmap.c | 5 +- lib/libc/sys-minix/pread.c | 3 +- lib/libc/sys-minix/pwrite.c | 4 +- lib/libc/sys-minix/sizeup.c | 1 - lib/libchardriver/chardriver.c | 4 +- lib/libhgfs/attr.c | 6 +- lib/libhgfs/file.c | 8 +- lib/libhgfs/info.c | 4 +- lib/libhgfs/time.c | 14 +-- lib/libminixfs/cache.c | 11 ++- lib/libminlib/Makefile | 2 +- lib/libminlib/read_tsc_64.c | 3 +- lib/libminlib/u64util.c | 34 -------- lib/libpuffs/read.c | 1 - lib/libsffs/link.c | 4 +- lib/libsffs/lookup.c | 4 +- lib/libsffs/misc.c | 4 +- lib/libsffs/mount.c | 4 +- lib/libsffs/read.c | 6 +- lib/libsffs/stat.c | 4 +- lib/libsffs/write.c | 20 ++--- lib/libsys/arch/earm/tsc_util.c | 3 +- lib/libsys/arch/i386/getidle.c | 11 ++- lib/libsys/arch/i386/profile.c | 13 ++- lib/libsys/arch/i386/spin.c | 2 +- lib/libsys/arch/i386/tsc_util.c | 13 ++- lib/libsys/sys_hz.c | 3 +- lib/libvboxfs/attr.c | 6 +- servers/devman/buf.c | 1 - servers/devman/devman.h | 1 - servers/devman/main.c | 1 - servers/ext2/balloc.c | 1 - servers/ext2/ialloc.c | 1 - servers/ext2/read.c | 29 +++--- servers/ext2/super.c | 1 - servers/iso9660fs/read.c | 23 ++--- servers/iso9660fs/super.c | 1 - servers/mfs/cache.c | 1 - servers/mfs/read.c | 29 +++--- servers/mfs/stats.c | 1 - servers/mfs/super.c | 1 - servers/procfs/inc.h | 1 - servers/procfs/pid.c | 12 +-- servers/vfs/device.c | 5 +- servers/vfs/exec.c | 1 - servers/vfs/filedes.c | 1 - servers/vfs/lock.c | 5 +- servers/vfs/misc.c | 9 +- servers/vfs/open.c | 28 +++--- servers/vfs/path.c | 2 +- servers/vfs/pipe.c | 1 - servers/vfs/read.c | 15 ++-- servers/vfs/request.c | 21 +++-- servers/vfs/select.c | 1 - servers/vfs/stadir.c | 1 - servers/vm/cache.c | 2 +- servers/vm/mmap.c | 2 +- servers/vm/regionavl.c | 1 - servers/vm/regionavl_defs.h | 1 - servers/vm/vfs.c | 4 +- test/blocktest/blocktest.c | 8 +- test/test53.c | 108 +++++++++++++---------- usr.bin/top/top.c | 5 +- usr.sbin/mkfs.mfs/mkfs.c | 25 +++--- 110 files changed, 371 insertions(+), 599 deletions(-) delete mode 100644 include/minix/u64.h delete mode 100644 lib/libminlib/u64util.c diff --git a/commands/autopart/autopart.c b/commands/autopart/autopart.c index 4d6a85cb0..970b4e1a9 100644 --- a/commands/autopart/autopart.c +++ b/commands/autopart/autopart.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -525,8 +524,8 @@ void geometry(void) if (ioctl(device, DIOCGETP, &geometry) < 0) err= errno; else { - table[0].lowsec= div64u(geometry.base, SECTOR_SIZE); - table[0].size= div64u(geometry.size, SECTOR_SIZE); + table[0].lowsec= (unsigned long)(geometry.base / SECTOR_SIZE); + table[0].size= (unsigned long)(geometry.size / SECTOR_SIZE); cylinders= geometry.cylinders; heads= geometry.heads; sectors= geometry.sectors; @@ -578,8 +577,8 @@ exit(1); * This makes sense for subpartitioning primary partitions. */ if (precise && ioctl(device, DIOCGETP, &geometry) >= 0) { - table[0].lowsec= div64u(geometry.base, SECTOR_SIZE); - table[0].size= div64u(geometry.size, SECTOR_SIZE); + table[0].lowsec= (unsigned long)(geometry.base / SECTOR_SIZE); + table[0].size= (unsigned long)(geometry.size / SECTOR_SIZE); } else { precise= 0; } @@ -2149,8 +2148,8 @@ sanitycheck_failed(char *dev, struct part_entry *pe) close(fd); - it_lowsec = div64u(part.base, SECTOR_SIZE); - it_secsize = div64u(part.size, SECTOR_SIZE); + it_lowsec = (unsigned long)(part.base / SECTOR_SIZE); + it_secsize = (unsigned long)(part.size / SECTOR_SIZE); if(it_lowsec != pe->lowsec || it_secsize != pe->size) { fprintf(stderr, "\nReturned and set numbers don't match up!\n"); diff --git a/commands/btrace/btrace.c b/commands/btrace/btrace.c index 6e9451adb..b0c7ea7a4 100644 --- a/commands/btrace/btrace.c +++ b/commands/btrace/btrace.c @@ -6,7 +6,6 @@ #include #include #include -#include #include static btrace_entry buf[BTBUF_SIZE]; @@ -144,7 +143,8 @@ static void dump_entry(btrace_entry *entry) case BTREQ_GATHER: case BTREQ_SCATTER: printf("- position:\t%08lx%08lx\n", - ex64hi(entry->position), ex64lo(entry->position)); + (unsigned long)(entry->position>>32), + (unsigned long)(entry->position)); printf("- size:\t\t%u\n", entry->size); printf("- flags:\t%x\n", entry->flags); break; diff --git a/commands/fbdctl/fbdctl.c b/commands/fbdctl/fbdctl.c index 5e951f061..de1d1eba6 100644 --- a/commands/fbdctl/fbdctl.c +++ b/commands/fbdctl/fbdctl.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -32,8 +31,8 @@ static int usage(char *name) static void print_rule(struct fbd_rule *rule) { printf("%-2d %04lX%08lX-%04lX%08lX %-4d %-5d %c%c ", - rule->num, ex64hi(rule->start), ex64lo(rule->start), - ex64hi(rule->end), ex64lo(rule->end), rule->skip, + rule->num, (unsigned long)(rule->start>>32), (unsigned long)(rule->start), + (unsigned long)(rule->end>>32), (unsigned long)(rule->end), rule->skip, rule->count, (rule->flags & FBD_FLAG_READ) ? 'r' : ' ', (rule->flags & FBD_FLAG_WRITE) ? 'w' : ' '); @@ -67,10 +66,10 @@ static void print_rule(struct fbd_rule *rule) case FBD_ACTION_MISDIR: printf("%-7s %04lX%08lX-%04lX%08lX %u", - "misdir", ex64hi(rule->params.misdir.start), - ex64lo(rule->params.misdir.start), - ex64hi(rule->params.misdir.end), - ex64lo(rule->params.misdir.end), + "misdir", (unsigned long)(rule->params.misdir.start>>32), + (unsigned long)(rule->params.misdir.start), + (unsigned long)(rule->params.misdir.end>>32), + (unsigned long)(rule->params.misdir.end), rule->params.misdir.align); break; @@ -128,7 +127,7 @@ static int scan_hex64(char *input, u64_t *val) lo = strtoul(input, NULL, 16); - *val = make64(lo, hi); + *val = (u64_t)lo | ((u64_t)hi << 32); return 1; } diff --git a/commands/fsck.mfs/fsck.c b/commands/fsck.mfs/fsck.c index b9cdda513..afee08754 100644 --- a/commands/fsck.mfs/fsck.c +++ b/commands/fsck.mfs/fsck.c @@ -46,7 +46,6 @@ #include #include #include -#include #include "mfs/const.h" #include "mfs/inode.h" #include "mfs/type.h" @@ -97,7 +96,7 @@ static struct super_block sb; * btoa64 gives the byte address of a block */ #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 FIRST ((zone_nr) sb.s_firstdatazone) /* as the name says */ @@ -656,12 +655,12 @@ void chksuper() int inoblock(int inn) { - return div64u(mul64u(inn - 1, INODE_SIZE), block_size) + BLK_ILIST; + return (unsigned long)(((u64_t)(inn - 1) * INODE_SIZE) / block_size) + BLK_ILIST; } int inooff(int inn) { - return rem64u(mul64u(inn - 1, INODE_SIZE), block_size); + return (unsigned)(((u64_t)(inn - 1) * INODE_SIZE) % block_size); } /* Make a listing of the inodes given by `clist'. If `repair' is set, ask diff --git a/commands/part/part.c b/commands/part/part.c index d141d8553..90a4cd434 100644 --- a/commands/part/part.c +++ b/commands/part/part.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -477,8 +476,8 @@ void geometry(void) if (ioctl(device, DIOCGETP, &geometry) < 0) err= errno; else { - table[0].lowsec= div64u(geometry.base, SECTOR_SIZE); - table[0].size= div64u(geometry.size, SECTOR_SIZE); + table[0].lowsec= (unsigned long)(geometry.base / SECTOR_SIZE); + table[0].size= (unsigned long)(geometry.size / SECTOR_SIZE); cylinders= geometry.cylinders; heads= geometry.heads; sectors= geometry.sectors; @@ -546,8 +545,8 @@ void geometry(void) * This makes sense for subpartitioning primary partitions. */ if (precise && ioctl(device, DIOCGETP, &geometry) >= 0) { - table[0].lowsec= div64u(geometry.base, SECTOR_SIZE); - table[0].size= div64u(geometry.size, SECTOR_SIZE); + table[0].lowsec= (unsigned long)(geometry.base / SECTOR_SIZE); + table[0].size= (unsigned long)(geometry.size / SECTOR_SIZE); } else { precise= 0; } diff --git a/commands/partition/partition.c b/commands/partition/partition.c index c3b2afd12..4bc6b1a27 100644 --- a/commands/partition/partition.c +++ b/commands/partition/partition.c @@ -20,7 +20,6 @@ #include #include #include -#include #else #include "partition.h" #define NR_PARTITIONS 4 @@ -322,8 +321,8 @@ void geometry(void) geometry.cylinders= (sb.st_size-1)/SECTOR_SIZE/ (geometry.sectors*geometry.heads) + 1; } - primary.lowsec= div64u(geometry.base, SECTOR_SIZE); - primary.size= div64u(geometry.size, SECTOR_SIZE); + primary.lowsec= (unsigned long)(geometry.base / SECTOR_SIZE); + primary.size= (unsigned long)(geometry.size / SECTOR_SIZE); cylinders= geometry.cylinders; heads= geometry.heads; sectors= geometry.sectors; diff --git a/commands/time/time.c b/commands/time/time.c index 651d244c6..b951312bf 100644 --- a/commands/time/time.c +++ b/commands/time/time.c @@ -11,7 +11,6 @@ #include #include #include -// #include #include /* -DNEW prints time to 0.01 sec. */ diff --git a/commands/vol/vol.c b/commands/vol/vol.c index 845c08a45..3f87c5304 100644 --- a/commands/vol/vol.c +++ b/commands/vol/vol.c @@ -27,7 +27,6 @@ #include #include #include -#include /* Preferred block size to variable block length tapes, block devices or files. */ diff --git a/drivers/fb/fb.c b/drivers/fb/fb.c index 52c08fce7..fc3145976 100644 --- a/drivers/fb/fb.c +++ b/drivers/fb/fb.c @@ -169,7 +169,7 @@ fb_do_read(endpoint_t ep, iovec_t *iov, int minor, u64_t pos, size_t *io_bytes) } return sys_safecopyto(ep, (cp_grant_id_t) iov->iov_addr, 0, - (vir_bytes) (dev.dv_base + ex64lo(pos)), + (vir_bytes) (dev.dv_base + (unsigned long)(pos)), *io_bytes); } @@ -296,8 +296,8 @@ fb_do_write(endpoint_t ep, iovec_t *iov, int minor, u64_t pos, size_t *io_bytes) } return sys_safecopyfrom(ep, (cp_grant_id_t) iov->iov_addr, 0, - (vir_bytes) (dev.dv_base + ex64lo(pos)), - *io_bytes); + (vir_bytes) (dev.dv_base + (unsigned long)(pos)), + *io_bytes); } static int diff --git a/drivers/fbd/action.c b/drivers/fbd/action.c index adacc0183..ed57913bb 100644 --- a/drivers/fbd/action.c +++ b/drivers/fbd/action.c @@ -58,9 +58,9 @@ static size_t get_range(struct fbd_rule *rule, u64_t pos, size_t *size, delta = rule->start - pos; - assert(ex64hi(delta) == 0); + assert((unsigned long)(delta>>32) == 0); - off = ex64lo(delta); + off = (unsigned long)(delta); } if (!to_eof) { @@ -69,7 +69,7 @@ static size_t get_range(struct fbd_rule *rule, u64_t pos, size_t *size, delta = rule->end - pos; if (delta < *size) - *size = ex64lo(delta); + *size = (unsigned long)(delta); } assert(*size > off); @@ -121,11 +121,11 @@ static void action_io_corrupt(struct fbd_rule *rule, char *buf, size_t size, /* Non-dword-aligned positions and sizes are not supported; * not by us, and not by the driver. */ - if (ex64lo(pos) & (sizeof(val) - 1)) break; + if ((unsigned long)(pos) & (sizeof(val) - 1)) break; if (size & (sizeof(val) - 1)) break; /* Consistently produce the same pattern for the same range. */ - val = ex64lo(skip); + val = (unsigned long)(skip); for ( ; size >= sizeof(val); size -= sizeof(val)) { *((u32_t *) buf) = val ^ 0xdeadbeefUL; diff --git a/drivers/fbd/fbd.c b/drivers/fbd/fbd.c index 700fe92b9..3730b0988 100644 --- a/drivers/fbd/fbd.c +++ b/drivers/fbd/fbd.c @@ -264,8 +264,8 @@ static ssize_t fbd_transfer_direct(int do_write, u64_t position, m.BDEV_GRANT = grant; m.BDEV_FLAGS = flags; m.BDEV_ID = 0; - m.BDEV_POS_LO = ex64lo(position); - m.BDEV_POS_HI = ex64hi(position); + m.BDEV_POS_LO = (unsigned long)(position); + m.BDEV_POS_HI = (unsigned long)(position>>32); if ((r = sendrec(driver_endpt, &m)) != OK) panic("sendrec to driver failed (%d)\n", r); @@ -357,8 +357,8 @@ static ssize_t fbd_transfer_copy(int do_write, u64_t position, m.BDEV_GRANT = grant; m.BDEV_FLAGS = flags; m.BDEV_ID = 0; - m.BDEV_POS_LO = ex64lo(position); - m.BDEV_POS_HI = ex64hi(position); + m.BDEV_POS_LO = (unsigned long)(position); + m.BDEV_POS_HI = (unsigned long)(position>>32); if ((r = sendrec(driver_endpt, &m)) != OK) panic("sendrec to driver failed (%d)\n", r); diff --git a/drivers/fbd/rule.c b/drivers/fbd/rule.c index f5c140b17..69bc8f542 100644 --- a/drivers/fbd/rule.c +++ b/drivers/fbd/rule.c @@ -92,8 +92,8 @@ 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, pos + size) >= 0 || - (cmp64u(rule->end, 0) && cmp64(rule->end, pos) <= 0)) + if (rule->start >= (pos + size) || + (rule->end != 0 && rule->end <= pos)) return FALSE; /* Flags must match. */ diff --git a/drivers/filter/driver.c b/drivers/filter/driver.c index d0a959078..a1309f124 100644 --- a/drivers/filter/driver.c +++ b/drivers/filter/driver.c @@ -918,8 +918,8 @@ int read_write(u64_t pos, char *bufa, char *bufb, size_t *sizep, int request) memset(&m1, 0, sizeof(m1)); m1.m_type = (request == FLT_WRITE) ? BDEV_SCATTER : BDEV_GATHER; m1.BDEV_COUNT = count; - m1.BDEV_POS_LO = ex64lo(pos); - m1.BDEV_POS_HI = ex64hi(pos); + m1.BDEV_POS_LO = (unsigned long)(pos); + m1.BDEV_POS_HI = (unsigned long)(pos>>32); m2 = m1; diff --git a/drivers/filter/main.c b/drivers/filter/main.c index b825ed31c..b005d8f90 100644 --- a/drivers/filter/main.c +++ b/drivers/filter/main.c @@ -136,10 +136,10 @@ static int do_rdwt(int flag_rw) u64_t pos; int r; - pos = make64(m_in.BDEV_POS_LO, m_in.BDEV_POS_HI); + pos = (u64_t)m_in.BDEV_POS_LO | ((u64_t)m_in.BDEV_POS_HI<<32); size = m_in.BDEV_COUNT; - if (rem64u(pos, SECTOR_SIZE) != 0 || size % SECTOR_SIZE != 0) { + if ((unsigned)(pos % SECTOR_SIZE) != 0 || size % SECTOR_SIZE != 0) { printf("Filter: unaligned request from caller!\n"); return EINVAL; @@ -194,11 +194,11 @@ static int do_vrdwt(int flag_rw) panic("copying in grant vector failed: %d", r); } - pos = make64(m_in.BDEV_POS_LO, m_in.BDEV_POS_HI); + pos = (u64_t)m_in.BDEV_POS_LO | ((u64_t)m_in.BDEV_POS_HI<<32); for(size = 0, i = 0; i < grants; i++) size += iov_proc[i].iov_size; - if (rem64u(pos, SECTOR_SIZE) != 0 || size % SECTOR_SIZE != 0) { + if ((unsigned)(pos % SECTOR_SIZE) != 0 || size % SECTOR_SIZE != 0) { printf("Filter: unaligned request from caller!\n"); return EINVAL; } diff --git a/drivers/filter/sum.c b/drivers/filter/sum.c index 5fe581c2e..f242d0d46 100644 --- a/drivers/filter/sum.c +++ b/drivers/filter/sum.c @@ -8,8 +8,8 @@ #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 POS2SEC(nr) div64u((nr), SECTOR_SIZE) -#define SEC2POS(nr) mul64u((nr), SECTOR_SIZE) +#define POS2SEC(nr) (unsigned long)((nr) / SECTOR_SIZE) +#define SEC2POS(nr) (unsigned long)((nr) / SECTOR_SIZE) /* Data buffers. */ static char *ext_array, *ext_buffer; /* interspersed buffer */ @@ -543,7 +543,8 @@ int transfer(u64_t pos, char *buffer, size_t *sizep, int flag_rw) #if DEBUG2 printf("Filter: transfer: pos 0x%lx:0x%lx -> phys_pos 0x%lx:0x%lx\n", - ex64hi(pos), ex64lo(pos), ex64hi(phys_pos), ex64lo(phys_pos)); + (unsigned long)(pos>>32), (unsigned long)(pos), + (unsigned long)(phys_pos>>32), (unsigned long)(phys_pos)); #endif /* Compute the size for the buffer and for the user data after diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index f62790f11..9ae766ade 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -410,8 +410,8 @@ static struct device *f_prepare(dev_t device) if (f_fp->fl_density < NT) { f_dp = &fdensity[f_fp->fl_density]; f_sectors = f_dp->secpt; - f_fp->fl_geom.dv_size = mul64u((long) (NR_HEADS * f_sectors - * f_dp->cyls), SECTOR_SIZE); + f_fp->fl_geom.dv_size = (u64_t)(NR_HEADS * f_sectors + * f_dp->cyls) * SECTOR_SIZE; } /* A partition? */ @@ -474,7 +474,7 @@ static ssize_t f_transfer( fp = f_fp; dv_size = f_dv->dv_size; - if (ex64hi(pos64) != 0) + if ((unsigned long)(pos64>>32) != 0) return OK; /* Way beyond EOF */ position= pos64; total = 0; @@ -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(f_dv->dv_base + position, SECTOR_SIZE); + block = (unsigned long)((f_dv->dv_base + position) / SECTOR_SIZE); if ((nbytes & SECTOR_MASK) != 0) return(EINVAL); diff --git a/drivers/hello/hello.c b/drivers/hello/hello.c index 0dd6a27e4..0db9c3849 100644 --- a/drivers/hello/hello.c +++ b/drivers/hello/hello.c @@ -56,8 +56,8 @@ static int hello_close(message *UNUSED(m)) static struct device * hello_prepare(dev_t UNUSED(dev)) { - hello_device.dv_base = make64(0, 0); - hello_device.dv_size = make64(strlen(HELLO_MESSAGE), 0); + hello_device.dv_base = (u64_t)0; + hello_device.dv_size = (u64_t)(strlen(HELLO_MESSAGE)); return &hello_device; } @@ -75,8 +75,8 @@ static int hello_transfer(endpoint_t endpt, int opcode, u64_t position, printf("HELLO: vectored transfer request, using first element only\n"); } - bytes = strlen(HELLO_MESSAGE) - ex64lo(position) < iov->iov_size ? - strlen(HELLO_MESSAGE) - ex64lo(position) : iov->iov_size; + bytes = strlen(HELLO_MESSAGE) - (unsigned long)(position) < iov->iov_size ? + strlen(HELLO_MESSAGE) - (unsigned long)(position) : iov->iov_size; if (bytes <= 0) { @@ -86,8 +86,8 @@ static int hello_transfer(endpoint_t endpt, int opcode, u64_t position, { case DEV_GATHER_S: ret = sys_safecopyto(endpt, (cp_grant_id_t) iov->iov_addr, 0, - (vir_bytes) (HELLO_MESSAGE + ex64lo(position)), - bytes); + (vir_bytes) (HELLO_MESSAGE + (unsigned long)(position)), + bytes); iov->iov_size -= bytes; break; diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c index 36d8af324..b3513a1ab 100644 --- a/drivers/i2c/i2c.c +++ b/drivers/i2c/i2c.c @@ -357,8 +357,8 @@ struct device * i2c_prepare(dev_t dev) { /* NOP */ - i2c_device.dv_base = make64(0, 0); - i2c_device.dv_size = make64(0, 0); + i2c_device.dv_base = (u64_t)0; + i2c_device.dv_size = (u64_t)0; return &i2c_device; } diff --git a/drivers/memory/memory.c b/drivers/memory/memory.c index d42167864..c774a5729 100644 --- a/drivers/memory/memory.c +++ b/drivers/memory/memory.c @@ -238,7 +238,7 @@ static int m_transfer( vir_bytes dev_vaddr; /* 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 && (unsigned long)(pos64>>32) != 0) return OK; /* Beyond EOF */ position= pos64; @@ -447,7 +447,7 @@ static int m_block_transfer( dv_size = dv->dv_size; dev_vaddr = m_vaddrs[minor]; - if (ex64hi(pos64) != 0) + if ((unsigned long)(pos64>>32) != 0) return OK; /* Beyond EOF */ position= pos64; @@ -554,7 +554,7 @@ static int m_block_ioctl(dev_t minor, unsigned int request, endpoint_t endpt, return s; if(is_imgrd) ramdev_size = 0; - if(m_vaddrs[minor] && !cmp64(dv->dv_size, ((u64_t)(ramdev_size)))) { + if(m_vaddrs[minor] && dv->dv_size == (u64_t)(ramdev_size)) { return(OK); } /* openct is 1 for the ioctl(). */ @@ -567,7 +567,7 @@ static int m_block_ioctl(dev_t minor, unsigned int request, endpoint_t endpt, u32_t a, o; u64_t size; int r; - if(ex64hi(dv->dv_size)) { + if((unsigned long)(dv->dv_size>>32)) { panic("huge old ramdisk"); } size = dv->dv_size; diff --git a/include/minix/Makefile b/include/minix/Makefile index bf2cdd730..c73f3383e 100644 --- a/include/minix/Makefile +++ b/include/minix/Makefile @@ -18,7 +18,7 @@ INCS+= acpi.h audio_fw.h bitmap.h \ reboot.h rs.h safecopies.h sched.h sef.h sffs.h \ sound.h spin.h sys_config.h sysinfo.h \ syslib.h sysutil.h termios.h timers.h type.h \ - tty.h u64.h usb.h usb_ch9.h vbox.h \ + tty.h usb.h usb_ch9.h vbox.h \ vboxfs.h vboxif.h vboxtype.h vm.h \ vfsif.h vtreefs.h libminixfs.h netsock.h \ virtio.h diff --git a/include/minix/driver.h b/include/minix/driver.h index 2995fef45..534f4f7ce 100644 --- a/include/minix/driver.h +++ b/include/minix/driver.h @@ -23,7 +23,6 @@ #include #include #include -#include #include /* Base and size of a partition in bytes. */ diff --git a/include/minix/hash.h b/include/minix/hash.h index b4aab0103..769853e22 100644 --- a/include/minix/hash.h +++ b/include/minix/hash.h @@ -32,11 +32,11 @@ c ^= b; c -= hash_rot(b,24); \ } -#define hash_i_64(a, u, v) { \ - u32_t i1 = (a), i2 = ex64lo(u), i3 = ex64hi(u); \ - hash_mix(i1, i2, i3); \ - hash_final(i1, i2, i3); \ - (v) = i3; \ +#define hash_i_64(a, u, v) { \ + u32_t i1 = (a), i2 = (unsigned long)(u), i3 = (unsigned long)(u>>32); \ + hash_mix(i1, i2, i3); \ + hash_final(i1, i2, i3); \ + (v) = i3; \ } #define hash_32(n, v) { \ diff --git a/include/minix/partition.h b/include/minix/partition.h index 2e9b431d0..fec08ac7f 100644 --- a/include/minix/partition.h +++ b/include/minix/partition.h @@ -8,8 +8,6 @@ #include -#include - int minix_sizeup(char *name, u64_t *bytes); struct part_geom { diff --git a/include/minix/sffs.h b/include/minix/sffs.h index ee8425340..b454a2bfb 100644 --- a/include/minix/sffs.h +++ b/include/minix/sffs.h @@ -5,7 +5,6 @@ #include #include -#include typedef void *sffs_file_t; /* handle to open file */ typedef void *sffs_dir_t; /* handle to directory search */ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 0d1a922da..68b9a1ad3 100644 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -7,7 +7,6 @@ #include #include -#include #include #include diff --git a/include/minix/u64.h b/include/minix/u64.h deleted file mode 100644 index 5411aa399..000000000 --- a/include/minix/u64.h +++ /dev/null @@ -1,131 +0,0 @@ -/* minix/u64.h Author: Kees J. Bot - * 7 Dec 1995 - * Functions to manipulate 64 bit disk addresses. - */ -#ifndef _MINIX__U64_H -#define _MINIX__U64_H - -#include - -#include - -static inline int bsr64(u64_t i) -{ - int index; - u64_t mask; - - for (index = 63, mask = 1ULL << 63; index >= 0; --index, mask >>= 1) { - if (i & mask) - return index; - } - - return -1; -} - -static inline int cmp64(u64_t i, u64_t j) -{ - if (i > j) - return 1; - else if (i < j) - return -1; - else /* (i == j) */ - return 0; -} - -static inline int cmp64u(u64_t i, unsigned j) -{ - if (i > j) - return 1; - else if (i < j) - return -1; - else /* (i == j) */ - return 0; -} - -static inline int cmp64ul(u64_t i, unsigned long j) -{ - if (i > j) - return 1; - else if (i < j) - return -1; - else /* (i == j) */ - return 0; -} - -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) -{ - return (unsigned long)i; -} - -static inline unsigned long ex64hi(u64_t i) -{ - return (unsigned long)(i>>32); -} - -static inline u64_t make64(unsigned long lo, unsigned long hi) -{ - 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 rshift64(u64_t x, unsigned short b); -u64_t xor64(u64_t a, u64_t b); -u64_t and64(u64_t a, u64_t b); -u64_t not64(u64_t a); - -#endif /* _MINIX__U64_H */ diff --git a/include/timers.h b/include/timers.h index 683dca923..ed2e02f1c 100644 --- a/include/timers.h +++ b/include/timers.h @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -64,17 +63,17 @@ clock_t tmrs_settimer(timer_t **tmrs, timer_t *tp, clock_t exp_time, tmr_func_t watchdog, clock_t *new_head); #define PRINT_STATS(cum_spenttime, cum_instances) { \ - if(ex64hi(cum_spenttime)) { util_stacktrace(); printf(" ( ??? %lu %lu)\n", \ - ex64hi(cum_spenttime), ex64lo(cum_spenttime)); } \ + if((unsigned long)(cum_spenttime>>32)) { util_stacktrace(); printf(" ( ??? %lu %lu)\n", \ + (unsigned long)(cum_spenttime>>32), (unsigned long)(cum_spenttime)); } \ printf("%s:%d,%lu,%lu\n", \ __FILE__, __LINE__, cum_instances, \ - ex64lo(cum_spenttime)); \ + (unsigned long)(cum_spenttime)); \ } #define RESET_STATS(starttime, cum_instances, cum_spenttime, cum_starttime) { \ cum_instances = 0; \ cum_starttime = starttime; \ - cum_spenttime = make64(0,0); \ + cum_spenttime = (u64_t)0; \ } #define TIME_BLOCK_VAR(timed_code_block, time_interval) do { \ @@ -85,21 +84,21 @@ clock_t tmrs_settimer(timer_t **tmrs, timer_t *tp, clock_t exp_time, read_tsc_64(&_starttime); \ do { timed_code_block } while(0); \ read_tsc_64(&_endtime); \ - _dt = sub64(_endtime, _starttime); \ + _dt = _endtime - _starttime; \ if(_cum_instances == 0) { \ RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \ } \ _next_cum_spent = _cum_spenttime + _dt; \ - if(ex64hi(_next_cum_spent)) { \ + if((unsigned long)(_next_cum_spent>>32)) { \ PRINT_STATS(_cum_spenttime, _cum_instances); \ RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \ } \ _cum_spenttime += _dt; \ _cum_instances++; \ - _cum_dt = sub64(_endtime, _cum_starttime); \ - if(cmp64(_cum_dt, make64(0, 120)) > 0) { \ + _cum_dt = _endtime - _cum_starttime; \ + if(_cum_dt > ((u64_t)120<<32) { \ PRINT_STATS(_cum_spenttime, _cum_instances); \ - RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \ + RESET_STATS(_starttime, _cum_instances, _cum_spenttime, _cum_starttime); \ } \ } while(0) diff --git a/kernel/arch/earm/arch_clock.c b/kernel/arch/earm/arch_clock.c index 754c6ccde..b34db9742 100644 --- a/kernel/arch/earm/arch_clock.c +++ b/kernel/arch/earm/arch_clock.c @@ -6,7 +6,6 @@ #include "kernel/clock.h" #include "kernel/proc.h" #include "kernel/interrupt.h" -#include #include "kernel/glo.h" #include "kernel/profile.h" @@ -126,12 +125,12 @@ int register_local_timer_handler(const irq_handler_t handler) 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) { - return div64u(cpu_time, tsc_per_ms[cpuid]); + return (unsigned long)(cpu_time / tsc_per_ms[cpuid]); } short cpu_load(void) diff --git a/kernel/arch/earm/arch_reset.c b/kernel/arch/earm/arch_reset.c index b6d16870e..d281c64f4 100644 --- a/kernel/arch/earm/arch_reset.c +++ b/kernel/arch/earm/arch_reset.c @@ -11,7 +11,6 @@ #include #include -#include #include "archconst.h" #include "arch_proto.h" diff --git a/kernel/arch/earm/arch_system.c b/kernel/arch/earm/arch_system.c index 1bb48a9d6..1507c58ca 100644 --- a/kernel/arch/earm/arch_system.c +++ b/kernel/arch/earm/arch_system.c @@ -10,8 +10,6 @@ #include #include -#include - #include "archconst.h" #include "arch_proto.h" #include "serial.h" diff --git a/kernel/arch/i386/apic.c b/kernel/arch/i386/apic.c index 9ec3190c2..ced5aad3a 100644 --- a/kernel/arch/i386/apic.c +++ b/kernel/arch/i386/apic.c @@ -12,8 +12,6 @@ #include "arch_proto.h" -#include - #include "apic.h" #include "apic_asm.h" #include "kernel/clock.h" @@ -515,14 +513,14 @@ static void apic_calibrate_clocks(unsigned cpu) rm_irq_handler(&spurious_irq); lapic_delta = lapic_tctr0 - lapic_tctr1; - tsc_delta = sub64(tsc1, tsc0); + tsc_delta = tsc1 - tsc0; lapic_bus_freq[cpuid] = system_hz * lapic_delta / (PROBE_TICKS - 1); BOOT_VERBOSE(printf("APIC bus freq %u MHz\n", lapic_bus_freq[cpuid] / 1000000)); - cpu_freq = mul64(div64u64(tsc_delta, PROBE_TICKS - 1), make64(system_hz, 0)); + cpu_freq = (tsc_delta / (PROBE_TICKS - 1)) * (u64_t)(system_hz); cpu_set_freq(cpuid, cpu_freq); - cpu_info[cpuid].freq = div64u(cpu_freq, 1000000); + cpu_info[cpuid].freq = (unsigned long)(cpu_freq / 1000000); BOOT_VERBOSE(cpu_print_freq(cpuid)); } diff --git a/kernel/arch/i386/arch_clock.c b/kernel/arch/i386/arch_clock.c index ba7af4d0f..3f4d46961 100644 --- a/kernel/arch/i386/arch_clock.c +++ b/kernel/arch/i386/arch_clock.c @@ -8,7 +8,6 @@ #include "kernel/clock.h" #include "kernel/interrupt.h" -#include #include "glo.h" #include "kernel/profile.h" @@ -287,9 +286,9 @@ void context_stop(struct proc * p) p->p_cpu_time_left = 0; #else /* if (tsc_delta < p->p_cpu_time_left) in 64bit */ - if (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))) + if ((unsigned long)(tsc_delta>>32) < (unsigned long)(p->p_cpu_time_left>>32) || + ((unsigned long)(tsc_delta>>32) == (unsigned long)(p->p_cpu_time_left>>32) && + (unsigned long)(tsc_delta) < (unsigned long)(p->p_cpu_time_left))) p->p_cpu_time_left = p->p_cpu_time_left - tsc_delta; else { p->p_cpu_time_left = 0; @@ -362,7 +361,7 @@ short cpu_load(void) busy = tsc_delta - idle_delta; busy = busy * 100; - load = ex64lo(busy / tsc_delta); + load = (unsigned long)(busy / tsc_delta); if (load > 100) load = 100; diff --git a/kernel/arch/i386/arch_reset.c b/kernel/arch/i386/arch_reset.c index 0fd32770d..9ac1f7ba7 100644 --- a/kernel/arch/i386/arch_reset.c +++ b/kernel/arch/i386/arch_reset.c @@ -13,8 +13,6 @@ #include #include -#include - #include "archconst.h" #include "arch_proto.h" #include "serial.h" diff --git a/kernel/arch/i386/arch_system.c b/kernel/arch/i386/arch_system.c index f14d32ae1..199bd228c 100644 --- a/kernel/arch/i386/arch_system.c +++ b/kernel/arch/i386/arch_system.c @@ -14,8 +14,6 @@ #include #include -#include - #include "archconst.h" #include "arch_proto.h" #include "serial.h" @@ -347,10 +345,10 @@ static void dump_bkl_usage(void) printf("--- BKL usage ---\n"); for (cpu = 0; cpu < ncpus; cpu++) { printf("cpu %3d kernel ticks 0x%x%08x bkl ticks 0x%x%08x succ %d tries %d\n", cpu, - ex64hi(kernel_ticks[cpu]), - ex64lo(kernel_ticks[cpu]), - ex64hi(bkl_ticks[cpu]), - ex64lo(bkl_ticks[cpu]), + (unsigned long)(kernel_ticks[cpu]>>32), + (unsigned long)(kernel_ticks[cpu]), + (unsigned long)(bkl_ticks[cpu]>>32), + (unsigned long)(bkl_ticks[cpu]), bkl_succ[cpu], bkl_tries[cpu]); } } diff --git a/kernel/arch/i386/arch_watchdog.c b/kernel/arch/i386/arch_watchdog.c index 4dd3dcc8d..695304741 100644 --- a/kernel/arch/i386/arch_watchdog.c +++ b/kernel/arch/i386/arch_watchdog.c @@ -3,7 +3,6 @@ #include "arch_proto.h" #include "glo.h" #include -#include #include "apic.h" @@ -32,12 +31,12 @@ static void intel_arch_watchdog_init(const unsigned cpu) * lowest 31 bits writable :( */ cpuf = cpu_get_freq(cpu); - while (ex64hi(cpuf) || ex64lo(cpuf) > 0x7fffffffU) - cpuf = div64u64(cpuf, 2); - cpuf = make64(-ex64lo(cpuf), ex64hi(cpuf)); + while ((unsigned long)(cpuf>>32) || (unsigned long)(cpuf) > 0x7fffffffU) + cpuf /= 2; + cpuf = (u64_t)(-(unsigned long)(cpuf)) | ((u64_t)((unsigned long)(cpuf>>32))<<32); watchdog->resetval = watchdog->watchdog_resetval = cpuf; - ia32_msr_write(INTEL_MSR_PERFMON_CRT0, 0, ex64lo(cpuf)); + ia32_msr_write(INTEL_MSR_PERFMON_CRT0, 0, (unsigned long)(cpuf)); ia32_msr_write(INTEL_MSR_PERFMON_SEL0, 0, val | INTEL_MSR_PERFMON_SEL0_ENABLE); @@ -49,7 +48,7 @@ static void intel_arch_watchdog_init(const unsigned cpu) static void intel_arch_watchdog_reinit(const unsigned cpu) { lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI); - ia32_msr_write(INTEL_MSR_PERFMON_CRT0, 0, ex64lo(watchdog->resetval)); + ia32_msr_write(INTEL_MSR_PERFMON_CRT0, 0, (unsigned long)(watchdog->resetval)); } int arch_watchdog_init(void) @@ -159,18 +158,18 @@ static int intel_arch_watchdog_profile_init(const unsigned freq) /* FIXME works only if all CPUs have the same freq */ cpuf = cpu_get_freq(cpuid); - cpuf = div64u64(cpuf, freq); + cpuf /= freq; /* * if freq is too low and the cpu freq too high we may get in a range of * insane value which cannot be handled by the 31bit CPU perf counter */ - if (ex64hi(cpuf) != 0 || ex64lo(cpuf) > 0x7fffffffU) { + if ((unsigned long)(cpuf>>32) != 0 || (unsigned long)(cpuf) > 0x7fffffffU) { printf("ERROR : nmi watchdog ticks exceed 31bits, use higher frequency\n"); return EINVAL; } - cpuf = make64(-ex64lo(cpuf), ex64hi(cpuf)); + cpuf = (u64_t)(-(unsigned long)(cpuf)) | (u64_t)((unsigned long)(cpuf>>32))<<32; watchdog->profile_resetval = cpuf; return OK; @@ -201,7 +200,7 @@ static void amd_watchdog_init(const unsigned cpu) watchdog->resetval = watchdog->watchdog_resetval = cpuf; ia32_msr_write(AMD_MSR_EVENT_CTR0, - ex64hi(watchdog->resetval), ex64lo(watchdog->resetval)); + (unsigned long)(watchdog->resetval>>32), (unsigned long)(watchdog->resetval)); ia32_msr_write(AMD_MSR_EVENT_SEL0, 0, val | AMD_MSR_EVENT_SEL0_ENABLE); @@ -214,7 +213,7 @@ static void amd_watchdog_reinit(const unsigned cpu) { lapic_write(LAPIC_LVTPCR, APIC_ICR_DM_NMI); ia32_msr_write(AMD_MSR_EVENT_CTR0, - ex64hi(watchdog->resetval), ex64lo(watchdog->resetval)); + (unsigned long)(watchdog->resetval>>32), (unsigned long)(watchdog->resetval)); } static int amd_watchdog_profile_init(const unsigned freq) @@ -223,7 +222,7 @@ static int amd_watchdog_profile_init(const unsigned freq) /* FIXME works only if all CPUs have the same freq */ cpuf = cpu_get_freq(cpuid); - cpuf = -div64u64(cpuf, freq); + cpuf /= -freq; watchdog->profile_resetval = cpuf; diff --git a/kernel/debug.c b/kernel/debug.c index 793749e9e..7564d3538 100644 --- a/kernel/debug.c +++ b/kernel/debug.c @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -255,8 +254,8 @@ void print_proc(struct proc *pp) "pdbr 0x%lx rts %s misc %s sched %s ", proc_nr(pp), pp->p_name, pp->p_endpoint, pp->p_priority, pp->p_user_time, - pp->p_sys_time, ex64hi(pp->p_cycles), - ex64lo(pp->p_cycles), pp->p_cpu, + pp->p_sys_time, (unsigned long)(pp->p_cycles>>32), + (unsigned long)(pp->p_cycles), pp->p_cpu, #if defined(__i386__) pp->p_seg.p_cr3, #elif defined(__arm__) diff --git a/kernel/main.c b/kernel/main.c index 83da02c6b..59c7423ea 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include "clock.h" @@ -507,7 +506,7 @@ void cpu_print_freq(unsigned cpu) u64_t freq; freq = cpu_get_freq(cpu); - printf("CPU %d freq %lu MHz\n", cpu, div64u(freq, 1000000)); + printf("CPU %d freq %lu MHz\n", cpu, (unsigned long)(freq / 1000000)); } int is_fpu(void) diff --git a/kernel/system/do_fork.c b/kernel/system/do_fork.c index 49a9424cd..af9f7bb75 100644 --- a/kernel/system/do_fork.c +++ b/kernel/system/do_fork.c @@ -15,7 +15,6 @@ #include #include -#include #if USE_FORK diff --git a/kernel/system/do_getinfo.c b/kernel/system/do_getinfo.c index 94818c89d..0730f118c 100644 --- a/kernel/system/do_getinfo.c +++ b/kernel/system/do_getinfo.c @@ -16,7 +16,6 @@ #if USE_GETINFO -#include #include /*===========================================================================* @@ -27,7 +26,7 @@ static void update_idle_time(void) int i; struct proc * idl = proc_addr(IDLE); - idl->p_cycles = make64(0, 0); + idl->p_cycles = (u64_t)0; for (i = 0; i < CONFIG_MAX_CPUS ; i++) { idl->p_cycles += get_cpu_var(i, idle_proc).p_cycles; diff --git a/lib/libbdev/bdev.c b/lib/libbdev/bdev.c index f8eafb9c9..bf149b280 100644 --- a/lib/libbdev/bdev.c +++ b/lib/libbdev/bdev.c @@ -135,8 +135,8 @@ static int bdev_rdwt_setup(int req, dev_t dev, u64_t pos, char *buf, memset(m, 0, sizeof(*m)); m->m_type = req; m->BDEV_MINOR = minor(dev); - m->BDEV_POS_LO = ex64lo(pos); - m->BDEV_POS_HI = ex64hi(pos); + m->BDEV_POS_LO = (unsigned long)(pos); + m->BDEV_POS_HI = (unsigned long)(pos>>32); m->BDEV_COUNT = count; m->BDEV_GRANT = grant; m->BDEV_FLAGS = flags; @@ -227,8 +227,8 @@ static int bdev_vrdwt_setup(int req, dev_t dev, u64_t pos, iovec_t *vec, memset(m, 0, sizeof(*m)); m->m_type = req; m->BDEV_MINOR = minor(dev); - m->BDEV_POS_LO = ex64lo(pos); - m->BDEV_POS_HI = ex64hi(pos); + m->BDEV_POS_LO = (unsigned long)(pos); + m->BDEV_POS_HI = (unsigned long)(pos>>32); m->BDEV_COUNT = count; m->BDEV_GRANT = grant; m->BDEV_FLAGS = flags; @@ -602,7 +602,7 @@ int bdev_restart_asyn(bdev_call_t *call) bdev_rdwt_cleanup(&call->msg); r = bdev_rdwt_setup(type, call->dev, - make64(call->msg.BDEV_POS_LO, call->msg.BDEV_POS_HI), + (u64_t)call->msg.BDEV_POS_LO | ((u64_t)call->msg.BDEV_POS_HI<<32), (char *) call->vec[0].iov_addr, call->msg.BDEV_COUNT, call->msg.BDEV_FLAGS, &call->msg); @@ -613,7 +613,7 @@ int bdev_restart_asyn(bdev_call_t *call) bdev_vrdwt_cleanup(&call->msg, call->gvec); r = bdev_vrdwt_setup(type, call->dev, - make64(call->msg.BDEV_POS_LO, call->msg.BDEV_POS_HI), + (u64_t)call->msg.BDEV_POS_LO | ((u64_t)call->msg.BDEV_POS_HI<<32), call->vec, call->msg.BDEV_COUNT, call->msg.BDEV_FLAGS, &call->msg, call->gvec); diff --git a/lib/libblockdriver/driver.c b/lib/libblockdriver/driver.c index f45b11552..f7ca988ef 100644 --- a/lib/libblockdriver/driver.c +++ b/lib/libblockdriver/driver.c @@ -204,7 +204,7 @@ static int do_rdwt(struct blockdriver *bdp, message *mp) /* Transfer bytes from/to the device. */ do_write = (mp->m_type == BDEV_WRITE); - position = make64(mp->BDEV_POS_LO, mp->BDEV_POS_HI); + position = (u64_t)mp->BDEV_POS_LO | ((u64_t)mp->BDEV_POS_HI<<32); r = (*bdp->bdr_transfer)(mp->BDEV_MINOR, do_write, position, mp->m_source, &iovec1, 1, mp->BDEV_FLAGS); @@ -245,7 +245,7 @@ static int do_vrdwt(struct blockdriver *bdp, message *mp, thread_id_t id) /* Transfer bytes from/to the device. */ do_write = (mp->m_type == BDEV_SCATTER); - position = make64(mp->BDEV_POS_LO, mp->BDEV_POS_HI); + position = (u64_t)mp->BDEV_POS_LO | ((u64_t)mp->BDEV_POS_HI<<32); r = (*bdp->bdr_transfer)(mp->BDEV_MINOR, do_write, position, mp->m_source, iovec, nr_req, mp->BDEV_FLAGS); @@ -290,7 +290,7 @@ 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); + entry.cylinders = (unsigned long)(entry.size / SECTOR_SIZE); entry.heads = 64; entry.sectors = 32; } diff --git a/lib/libblockdriver/drvlib.c b/lib/libblockdriver/drvlib.c index 55df9f00d..315c61edb 100644 --- a/lib/libblockdriver/drvlib.c +++ b/lib/libblockdriver/drvlib.c @@ -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 == (u64_t)(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, diff --git a/lib/libblockdriver/trace.c b/lib/libblockdriver/trace.c index 395066847..249e523fc 100644 --- a/lib/libblockdriver/trace.c +++ b/lib/libblockdriver/trace.c @@ -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); } @@ -205,7 +205,7 @@ void trace_start(thread_id_t id, message *m_ptr) case BDEV_WRITE: case BDEV_GATHER: case BDEV_SCATTER: - pos = make64(m_ptr->BDEV_POS_LO, m_ptr->BDEV_POS_HI); + pos = (u64_t)m_ptr->BDEV_POS_LO | ((u64_t)m_ptr->BDEV_POS_HI<<32); size = m_ptr->BDEV_COUNT; flags = m_ptr->BDEV_FLAGS; diff --git a/lib/libc/minix/malloc-debug.h b/lib/libc/minix/malloc-debug.h index 47118daf9..b2e78fd86 100644 --- a/lib/libc/minix/malloc-debug.h +++ b/lib/libc/minix/malloc-debug.h @@ -1,4 +1,3 @@ -#include #include /* malloc-debug.c */ diff --git a/lib/libc/minix/minix-malloc-debug.c b/lib/libc/minix/minix-malloc-debug.c index 6fe777482..da946edcb 100644 --- a/lib/libc/minix/minix-malloc-debug.c +++ b/lib/libc/minix/minix-malloc-debug.c @@ -129,7 +129,7 @@ static struct block *block_alloc(size_t size) /* read_tsc_64(&tsc); */ totalsize = block_get_totalsize(size); page_index_max = (ptr_max - ptr_min - totalsize) / PAGE_SIZE; - page_index = (page_index_max > 0) ? (ex64lo(tsc) % page_index_max) : 0; + page_index = (page_index_max > 0) ? ((unsigned long)(tsc) % page_index_max) : 0; ptr = ptr_min + page_index * PAGE_SIZE; /* allocate block */ diff --git a/lib/libc/sys-minix/lseek64.c b/lib/libc/sys-minix/lseek64.c index 1310cba5f..dfdf92d85 100644 --- a/lib/libc/sys-minix/lseek64.c +++ b/lib/libc/sys-minix/lseek64.c @@ -3,7 +3,6 @@ #include #include -#include int lseek64(fd, offset, whence, newpos) int fd; @@ -14,11 +13,11 @@ u64_t *newpos; message m; m.m2_i1 = fd; - m.m2_l1 = ex64lo(offset); - m.m2_l2 = ex64hi(offset); + m.m2_l1 = (unsigned long)(offset); + m.m2_l2 = (unsigned long)(offset>>32); m.m2_i2 = whence; if (_syscall(VFS_PROC_NR, LLSEEK, &m) < 0) return -1; if (newpos) - *newpos= make64(m.m2_l1, m.m2_l2); + *newpos= (u64_t)m.m2_l1 | ((u64_t)m.m2_l2<<32); return 0; } diff --git a/lib/libc/sys-minix/mmap.c b/lib/libc/sys-minix/mmap.c index f213f8fbf..15406fa5d 100644 --- a/lib/libc/sys-minix/mmap.c +++ b/lib/libc/sys-minix/mmap.c @@ -2,7 +2,6 @@ #include #include "namespace.h" #include -#include #include /* INCLUDES HERE */ @@ -33,13 +32,13 @@ void *minix_mmap_for(endpoint_t forwhom, m.VMM_PROT = prot; m.VMM_FLAGS = flags; m.VMM_FD = fd; - m.VMM_OFFSET_LO = ex64lo(offset); + m.VMM_OFFSET_LO = (unsigned long)(offset); if(forwhom != SELF) { m.VMM_FLAGS |= MAP_THIRDPARTY; m.VMM_FORWHOM = forwhom; } else { - m.VMM_OFFSET_HI = ex64hi(offset); + m.VMM_OFFSET_HI = (unsigned long)(offset>>32); } r = _syscall(VM_PROC_NR, VM_MMAP, &m); diff --git a/lib/libc/sys-minix/pread.c b/lib/libc/sys-minix/pread.c index f2b751544..75bf6b713 100644 --- a/lib/libc/sys-minix/pread.c +++ b/lib/libc/sys-minix/pread.c @@ -10,14 +10,13 @@ __weak_alias(pread, _pread) #include #include -#include ssize_t pread64(int fd, void *buffer, size_t nbytes, u64_t where) { u64_t here; ssize_t r; - if (lseek64(fd, make64(0,0), SEEK_CUR, &here) < 0) return(-1); + if (lseek64(fd, (u64_t)0, SEEK_CUR, &here) < 0) return(-1); if (lseek64(fd, where, SEEK_SET, NULL) < 0) return(-1); if ((r = read(fd, buffer, nbytes)) < 0) { int e = errno; diff --git a/lib/libc/sys-minix/pwrite.c b/lib/libc/sys-minix/pwrite.c index f2c07b3a4..3ac41ea7f 100644 --- a/lib/libc/sys-minix/pwrite.c +++ b/lib/libc/sys-minix/pwrite.c @@ -8,14 +8,12 @@ __weak_alias(pwrite, _pwrite) #endif -#include - ssize_t pwrite64(int fd, const void *buffer, size_t nbytes, u64_t where) { u64_t here; ssize_t w; - if (lseek64(fd, make64(0,0), SEEK_CUR, &here) < 0) return(-1); + if (lseek64(fd, (u64_t)0, SEEK_CUR, &here) < 0) return(-1); if (lseek64(fd, where, SEEK_SET, NULL) < 0) return(-1); if ((w = write(fd, buffer, nbytes)) < 0) { int e = errno; diff --git a/lib/libc/sys-minix/sizeup.c b/lib/libc/sys-minix/sizeup.c index 41c0245b1..17f94e616 100644 --- a/lib/libc/sys-minix/sizeup.c +++ b/lib/libc/sys-minix/sizeup.c @@ -1,7 +1,6 @@ #include #include "namespace.h" #include -#include #include #include #include diff --git a/lib/libchardriver/chardriver.c b/lib/libchardriver/chardriver.c index 13fa620b0..3c04ae5b5 100644 --- a/lib/libchardriver/chardriver.c +++ b/lib/libchardriver/chardriver.c @@ -252,7 +252,7 @@ static int do_rdwt(struct chardriver *cdp, message *mp) iovec1.iov_size = mp->COUNT; /* Transfer bytes from/to the device. */ - position= make64(mp->POSITION, mp->HIGHPOS); + position= (u64_t)mp->POSITION | ((u64_t)mp->HIGHPOS<<32); r = (*cdp->cdr_transfer)(mp->m_source, opcode, position, &iovec1, 1, mp->USER_ENDPT, mp->FLAGS); @@ -292,7 +292,7 @@ static int do_vrdwt(struct chardriver *cdp, message *mp) /* Transfer bytes from/to the device. */ opcode = mp->m_type; - position= make64(mp->POSITION, mp->HIGHPOS); + position= (u64_t)mp->POSITION | ((u64_t)mp->HIGHPOS<<32); r = (*cdp->cdr_transfer)(mp->m_source, opcode, position, iovec, nr_req, mp->USER_ENDPT, mp->FLAGS); diff --git a/lib/libhgfs/attr.c b/lib/libhgfs/attr.c index 4814c7b40..38f9ee445 100644 --- a/lib/libhgfs/attr.c +++ b/lib/libhgfs/attr.c @@ -21,7 +21,7 @@ struct sffs_attr *attr; size_lo = RPC_NEXT32; size_hi = RPC_NEXT32; if (attr->a_mask & SFFS_ATTR_SIZE) - attr->a_size = make64(size_lo, size_hi); + attr->a_size = (u64_t)size_lo | ((u64_t)size_hi<<32); time_get((attr->a_mask & SFFS_ATTR_CRTIME) ? &attr->a_crtime : NULL); time_get((attr->a_mask & SFFS_ATTR_ATIME) ? &attr->a_atime : NULL); @@ -86,8 +86,8 @@ struct sffs_attr *attr; RPC_NEXT8 = mask; RPC_NEXT32 = !!(S_ISDIR(attr->a_mode)); - RPC_NEXT32 = ex64lo(attr->a_size); - RPC_NEXT32 = ex64hi(attr->a_size); + RPC_NEXT32 = (unsigned long)(attr->a_size); + RPC_NEXT32 = (unsigned long)(attr->a_size>>32); time_put((attr->a_mask & HGFS_ATTR_CRTIME) ? &attr->a_crtime : NULL); time_put((attr->a_mask & HGFS_ATTR_ATIME) ? &attr->a_atime : NULL); diff --git a/lib/libhgfs/file.c b/lib/libhgfs/file.c index 12f21c692..de395af59 100644 --- a/lib/libhgfs/file.c +++ b/lib/libhgfs/file.c @@ -62,8 +62,8 @@ u64_t off; /* file offset */ RPC_REQUEST(HGFS_REQ_READ); RPC_NEXT32 = (u32_t)handle; - RPC_NEXT32 = ex64lo(off); - RPC_NEXT32 = ex64hi(off); + RPC_NEXT32 = (unsigned long)(off); + RPC_NEXT32 = (unsigned long)(off>>32); max = RPC_BUF_SIZE - RPC_LEN - sizeof(u32_t); RPC_NEXT32 = (size < max) ? size : max; @@ -97,8 +97,8 @@ u64_t off; /* file offset */ RPC_REQUEST(HGFS_REQ_WRITE); RPC_NEXT32 = (u32_t)handle; RPC_NEXT8 = 0; /* append flag */ - RPC_NEXT32 = ex64lo(off); - RPC_NEXT32 = ex64hi(off); + RPC_NEXT32 = (unsigned long)(off); + RPC_NEXT32 = (unsigned long)(off>>32); RPC_NEXT32 = len; /* Only copy in data if we're not operating directly on the RPC buffer. */ diff --git a/lib/libhgfs/info.c b/lib/libhgfs/info.c index f6d9258e2..a9e270dfd 100644 --- a/lib/libhgfs/info.c +++ b/lib/libhgfs/info.c @@ -28,11 +28,11 @@ u64_t *total; lo = RPC_NEXT32; hi = RPC_NEXT32; - *free = make64(lo, hi); + *free = (u64_t)lo | ((u64_t)hi << 32); lo = RPC_NEXT32; hi = RPC_NEXT32; - *total = make64(lo, hi); + *total = (u64_t)lo | ((u64_t)hi << 32); return OK; } diff --git a/lib/libhgfs/time.c b/lib/libhgfs/time.c index ba3085f14..8ee952a21 100644 --- a/lib/libhgfs/time.c +++ b/lib/libhgfs/time.c @@ -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,11 +33,11 @@ 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); - RPC_NEXT32 = ex64hi(hgfstime); + RPC_NEXT32 = (unsigned long)(hgfstime); + RPC_NEXT32 = (unsigned long)(hgfstime>>32); } else { RPC_NEXT32 = 0; RPC_NEXT32 = 0; @@ -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 = ((u64_t)time_lo | ((u64_t)time_hi<<32)) - 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); } diff --git a/lib/libminixfs/cache.c b/lib/libminixfs/cache.c index 02d496aa9..8b727563b 100644 --- a/lib/libminixfs/cache.c +++ b/lib/libminixfs/cache.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #define BUFHASH(b) ((b) % nr_bufs) @@ -75,8 +74,8 @@ u32_t fs_bufs_heuristic(int minbufs, u32_t btotal, u32_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 @@ -510,7 +509,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 vaddr = (vir_bytes) bp->data; @@ -687,7 +686,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 @@ -924,7 +923,7 @@ int lmfs_do_bpeek(message *m) { block_t startblock, b, limitblock; dev_t dev = m->REQ_DEV2; - u64_t extra, pos = make64(m->REQ_SEEK_POS_LO, m->REQ_SEEK_POS_HI); + u64_t extra, pos = (u64_t)m->REQ_SEEK_POS_LO | ((u64_t)m->REQ_SEEK_POS_HI<<32); size_t len = m->REQ_NBYTES; struct buf *bp; diff --git a/lib/libminlib/Makefile b/lib/libminlib/Makefile index af025661c..c6874e422 100644 --- a/lib/libminlib/Makefile +++ b/lib/libminlib/Makefile @@ -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 # svrctl SRCS+= svrctl.c diff --git a/lib/libminlib/read_tsc_64.c b/lib/libminlib/read_tsc_64.c index 63faa10ad..4d2240e24 100644 --- a/lib/libminlib/read_tsc_64.c +++ b/lib/libminlib/read_tsc_64.c @@ -1,5 +1,4 @@ -#include #include /* Utility function to work directly with u64_t @@ -10,6 +9,6 @@ u64_t* t; { u32_t lo, hi; read_tsc (&hi, &lo); - *t = make64 (lo, hi); + *t = (u64_t)lo | ((u64_t)hi<<32); } diff --git a/lib/libminlib/u64util.c b/lib/libminlib/u64util.c deleted file mode 100644 index bcddb067f..000000000 --- a/lib/libminlib/u64util.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Few u64 utils implemented in C - * Author: Gautam BT - */ -#include - -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; -} diff --git a/lib/libpuffs/read.c b/lib/libpuffs/read.c index 641a41972..5222c0c9e 100644 --- a/lib/libpuffs/read.c +++ b/lib/libpuffs/read.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/libsffs/link.c b/lib/libsffs/link.c index be877cc7f..9e102399f 100644 --- a/lib/libsffs/link.c +++ b/lib/libsffs/link.c @@ -117,8 +117,8 @@ int do_create() m_out.RES_INODE_NR = INODE_NR(ino); m_out.RES_MODE = get_mode(ino, attr.a_mode); - m_out.RES_FILE_SIZE_HI = ex64hi(attr.a_size); - m_out.RES_FILE_SIZE_LO = ex64lo(attr.a_size); + m_out.RES_FILE_SIZE_HI = (unsigned long)(attr.a_size>>32); + m_out.RES_FILE_SIZE_LO = (unsigned long)(attr.a_size); m_out.RES_UID = sffs_params->p_uid; m_out.RES_GID = sffs_params->p_gid; m_out.RES_DEV = NO_DEV; diff --git a/lib/libsffs/lookup.c b/lib/libsffs/lookup.c index b94b6a0fd..1142feed2 100644 --- a/lib/libsffs/lookup.c +++ b/lib/libsffs/lookup.c @@ -322,8 +322,8 @@ int do_lookup() m_out.RES_INODE_NR = INODE_NR(cur_ino); m_out.RES_MODE = get_mode(cur_ino, attr.a_mode); - m_out.RES_FILE_SIZE_HI = ex64hi(attr.a_size); - m_out.RES_FILE_SIZE_LO = ex64lo(attr.a_size); + m_out.RES_FILE_SIZE_HI = (unsigned long)(attr.a_size>>32); + m_out.RES_FILE_SIZE_LO = (unsigned long)(attr.a_size); m_out.RES_UID = sffs_params->p_uid; m_out.RES_GID = sffs_params->p_gid; m_out.RES_DEV = NO_DEV; diff --git a/lib/libsffs/misc.c b/lib/libsffs/misc.c index fe48d84cf..0798af768 100644 --- a/lib/libsffs/misc.c +++ b/lib/libsffs/misc.c @@ -62,8 +62,8 @@ int do_statvfs() */ statvfs.f_bsize = BLOCK_SIZE; statvfs.f_frsize = 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_files = 0; statvfs.f_ffree = 0; diff --git a/lib/libsffs/mount.c b/lib/libsffs/mount.c index 1649f2c5c..c49e0736b 100644 --- a/lib/libsffs/mount.c +++ b/lib/libsffs/mount.c @@ -57,8 +57,8 @@ int do_readsuper() m_out.RES_INODE_NR = INODE_NR(ino); m_out.RES_MODE = get_mode(ino, attr.a_mode); - m_out.RES_FILE_SIZE_HI = ex64hi(attr.a_size); - m_out.RES_FILE_SIZE_LO = ex64lo(attr.a_size); + m_out.RES_FILE_SIZE_HI = (unsigned long)(attr.a_size>>32); + m_out.RES_FILE_SIZE_LO = (unsigned long)(attr.a_size); m_out.RES_UID = sffs_params->p_uid; m_out.RES_GID = sffs_params->p_gid; m_out.RES_DEV = NO_DEV; diff --git a/lib/libsffs/read.c b/lib/libsffs/read.c index d27d9839d..10d919980 100644 --- a/lib/libsffs/read.c +++ b/lib/libsffs/read.c @@ -36,7 +36,7 @@ int do_read() if ((r = get_handle(ino)) != OK) return r; - pos = make64(m_in.REQ_SEEK_POS_LO, m_in.REQ_SEEK_POS_HI); + pos = (u64_t)m_in.REQ_SEEK_POS_LO | ((u64_t)m_in.REQ_SEEK_POS_HI<<32); count = m_in.REQ_NBYTES; assert(count > 0); @@ -67,8 +67,8 @@ int do_read() if (r < 0) return r; - m_out.RES_SEEK_POS_HI = ex64hi(pos); - m_out.RES_SEEK_POS_LO = ex64lo(pos); + m_out.RES_SEEK_POS_HI = (unsigned long)(pos>>32); + m_out.RES_SEEK_POS_LO = (unsigned long)(pos); m_out.RES_NBYTES = off; return OK; diff --git a/lib/libsffs/stat.c b/lib/libsffs/stat.c index b0aa4550f..537f1d384 100644 --- a/lib/libsffs/stat.c +++ b/lib/libsffs/stat.c @@ -70,10 +70,10 @@ 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 > (u64_t)(LONG_MAX)) stat.st_size = LONG_MAX; else - stat.st_size = ex64lo(attr.a_size); + stat.st_size = (unsigned long)(attr.a_size); stat.st_atimespec = attr.a_atime; stat.st_mtimespec = attr.a_mtime; stat.st_ctimespec = attr.a_ctime; diff --git a/lib/libsffs/write.c b/lib/libsffs/write.c index bd571a337..e31dbe60b 100644 --- a/lib/libsffs/write.c +++ b/lib/libsffs/write.c @@ -97,7 +97,7 @@ int do_write() if (IS_DIR(ino)) return EISDIR; - pos = make64(m_in.REQ_SEEK_POS_LO, m_in.REQ_SEEK_POS_HI); + pos = (u64_t)m_in.REQ_SEEK_POS_LO | ((u64_t)m_in.REQ_SEEK_POS_HI<<32); count = m_in.REQ_NBYTES; grant = m_in.REQ_GRANT; @@ -106,8 +106,8 @@ int do_write() if ((r = write_file(ino, &pos, &count, &grant)) != OK) return r; - m_out.RES_SEEK_POS_HI = ex64hi(pos); - m_out.RES_SEEK_POS_LO = ex64lo(pos); + m_out.RES_SEEK_POS_HI = (unsigned long)(pos>>32); + m_out.RES_SEEK_POS_LO = (unsigned long)(pos); m_out.RES_NBYTES = count; return OK; @@ -135,10 +135,10 @@ int do_ftrunc() if (IS_DIR(ino)) return EISDIR; - 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); + start = (u64_t)m_in.REQ_TRC_START_LO | ((u64_t)m_in.REQ_TRC_START_HI<<32); + end = (u64_t)m_in.REQ_TRC_END_LO | ((u64_t)m_in.REQ_TRC_END_HI<<32); - if (cmp64u(end, 0) == 0) { + if (end == (u64_t)(0)) { /* Truncate or expand the file. */ if ((r = verify_inode(ino, path, NULL)) != OK) return r; @@ -149,13 +149,13 @@ 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; + if ((unsigned long)(delta>>32) != 0) return EINVAL; - count = ex64lo(delta); + count = (unsigned long)(delta); r = write_file(ino, &start, &count, NULL); } diff --git a/lib/libsys/arch/earm/tsc_util.c b/lib/libsys/arch/earm/tsc_util.c index 4f973e9a1..40d9cf74d 100644 --- a/lib/libsys/arch/earm/tsc_util.c +++ b/lib/libsys/arch/earm/tsc_util.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,6 @@ u32_t tsc_64_to_micros(u64_t tsc) u32_t tsc_to_micros(u32_t low, u32_t high) { - return tsc_64_to_micros(make64(low, high)); + return tsc_64_to_micros((u64_t)low | ((u64_t)high<<32)); } diff --git a/lib/libsys/arch/i386/getidle.c b/lib/libsys/arch/i386/getidle.c index 8fc225e7c..8f366be64 100644 --- a/lib/libsys/arch/i386/getidle.c +++ b/lib/libsys/arch/i386/getidle.c @@ -17,7 +17,6 @@ #define _SYSTEM 1 #include -#include #include #include #include @@ -33,11 +32,11 @@ static double make_double(u64_t d) double value; size_t i; - value = (double) ex64hi(d); + value = (double) (unsigned long)(d>>32); for (i = 0; i < sizeof(unsigned long); i += 2) value *= 65536.0; - value += (double) ex64lo(d); + value += (double) (unsigned long)(d); return value; } @@ -67,10 +66,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); diff --git a/lib/libsys/arch/i386/profile.c b/lib/libsys/arch/i386/profile.c index 6f795c1fc..7de6106ab 100644 --- a/lib/libsys/arch/i386/profile.c +++ b/lib/libsys/arch/i386/profile.c @@ -17,7 +17,6 @@ #include #include #include -#include #include static char cpath[CPROF_CPATH_MAX_LEN]; /* current call path string */ @@ -178,7 +177,7 @@ void procexit (char *UNUSED(name)) /* First thing: read CPU cycle count into local variable. */ read_tsc(&tsc_hi, &tsc_lo); - stop = make64(tsc_lo, tsc_hi); + stop = (u64_t)tsc_lo | ((u64_t)tsc_hi<<32); /* Only continue if sane. */ if (control.err) return; @@ -191,9 +190,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)); @@ -213,10 +212,10 @@ void procexit (char *UNUSED(name)) /* Read CPU cycle count. */ read_tsc(&tsc_hi, &tsc_lo); - stop = make64(tsc_lo, tsc_hi); + stop = (u64_t)tsc_lo | ((u64_t)tsc_hi<<32); /* 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; @@ -265,7 +264,7 @@ static void clear_tbl() memset(cprof_tbl[i].cpath, '\0', CPROF_CPATH_MAX_LEN); cprof_tbl[i].next = 0; cprof_tbl[i].calls = 0; - cprof_tbl[i].cycles = make64(0, 0); + cprof_tbl[i].cycles = (u64_t)0; } } diff --git a/lib/libsys/arch/i386/spin.c b/lib/libsys/arch/i386/spin.c index 2724f1447..e379d8bdf 100644 --- a/lib/libsys/arch/i386/spin.c +++ b/lib/libsys/arch/i386/spin.c @@ -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); diff --git a/lib/libsys/arch/i386/tsc_util.c b/lib/libsys/arch/i386/tsc_util.c index 9897efcad..83cca1578 100644 --- a/lib/libsys/arch/i386/tsc_util.c +++ b/lib/libsys/arch/i386/tsc_util.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -63,7 +62,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 +74,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,18 +86,18 @@ u32_t tsc_64_to_micros(u64_t tsc) CALIBRATE; - tmp = div64u64(tsc, calib_mhz); - if (ex64hi(tmp)) { + tmp = tsc / calib_mhz; + if ((unsigned long)(tmp>>32)) { printf("tsc_64_to_micros: more than 2^32ms\n"); return ~0UL; } else { - return ex64lo(tmp); + return (unsigned long)(tmp); } } u32_t tsc_to_micros(u32_t low, u32_t high) { - return tsc_64_to_micros(make64(low, high)); + return tsc_64_to_micros((u64_t)low | ((u64_t)high<<32)); } u32_t tsc_get_khz(void) diff --git a/lib/libsys/sys_hz.c b/lib/libsys/sys_hz.c index 33c9c6aad..a7d3dec0a 100644 --- a/lib/libsys/sys_hz.c +++ b/lib/libsys/sys_hz.c @@ -2,7 +2,6 @@ #include #include #include -#include #include #include @@ -31,7 +30,7 @@ micros_to_ticks(u32_t micros) { u32_t ticks; - ticks = div64u(mul64u(micros, sys_hz()), 1000000); + ticks = (unsigned long)(((u64_t)micros * sys_hz()) / 1000000); if(ticks < 1) ticks = 1; return ticks; diff --git a/lib/libvboxfs/attr.c b/lib/libvboxfs/attr.c index cef9c8a82..d6dc34d22 100644 --- a/lib/libvboxfs/attr.c +++ b/lib/libvboxfs/attr.c @@ -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; } /* diff --git a/servers/devman/buf.c b/servers/devman/buf.c index e7f0024e5..c2bfeea97 100755 --- a/servers/devman/buf.c +++ b/servers/devman/buf.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/servers/devman/devman.h b/servers/devman/devman.h index df8cd6282..a2240cfc4 100644 --- a/servers/devman/devman.h +++ b/servers/devman/devman.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/servers/devman/main.c b/servers/devman/main.c index 78521cdc1..d77aa9cbc 100644 --- a/servers/devman/main.c +++ b/servers/devman/main.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/servers/ext2/balloc.c b/servers/ext2/balloc.c index bef14964c..ccf45fd8a 100644 --- a/servers/ext2/balloc.c +++ b/servers/ext2/balloc.c @@ -13,7 +13,6 @@ #include #include #include -#include #include "buf.h" #include "inode.h" #include "super.h" diff --git a/servers/ext2/ialloc.c b/servers/ext2/ialloc.c index 6cb18106d..4a03ada5c 100644 --- a/servers/ext2/ialloc.c +++ b/servers/ext2/ialloc.c @@ -12,7 +12,6 @@ #include #include #include -#include #include "buf.h" #include "inode.h" #include "super.h" diff --git a/servers/ext2/read.c b/servers/ext2/read.c index 4988d9545..6371dcc76 100644 --- a/servers/ext2/read.c +++ b/servers/ext2/read.c @@ -7,7 +7,6 @@ #include #include #include -#include #include "buf.h" #include "inode.h" #include "super.h" @@ -159,8 +158,8 @@ int fs_breadwrite(void) /* Get the values from the request message */ rw_flag = (fs_m_in.m_type == REQ_BREAD ? READING : WRITING); gid = (cp_grant_id_t) fs_m_in.REQ_GRANT; - position = make64((unsigned long) fs_m_in.REQ_SEEK_POS_LO, - (unsigned long) fs_m_in.REQ_SEEK_POS_HI); + position = (u64_t)fs_m_in.REQ_SEEK_POS_LO | + ((u64_t)fs_m_in.REQ_SEEK_POS_HI<<32); nrbytes = (size_t) fs_m_in.REQ_NBYTES; block_size = get_block_size( (dev_t) fs_m_in.REQ_DEV2); @@ -174,7 +173,7 @@ int fs_breadwrite(void) cum_io = 0; /* Split the transfer into chunks that don't span two blocks. */ while (nrbytes > 0) { - off = rem64u(position, block_size); /* offset in blk*/ + off = (unsigned)(position % block_size); /* offset in blk*/ chunk = min(nrbytes, block_size - off); /* Read or write 'chunk' bytes. */ @@ -190,8 +189,8 @@ int fs_breadwrite(void) position += chunk; /* position within the file */ } - fs_m_out.RES_SEEK_POS_LO = ex64lo(position); - fs_m_out.RES_SEEK_POS_HI = ex64hi(position); + fs_m_out.RES_SEEK_POS_LO = (unsigned long)(position); + fs_m_out.RES_SEEK_POS_HI = (unsigned long)(position>>32); if (rdwt_err != OK) r = rdwt_err; /* check for disk error */ if (rdwt_err == END_OF_FILE) r = OK; @@ -239,12 +238,12 @@ int *completed; /* number of bytes copied */ block_spec = (rip->i_mode & I_TYPE) == I_BLOCK_SPECIAL; if (block_spec) { - b = div64u(position, block_size); + b = (unsigned long)(position / block_size); dev = (dev_t) rip->i_block[0]; } else { - if (ex64hi(position) != 0) + if ((unsigned long)(position>>32) != 0) panic("rw_chunk: position too high"); - b = read_map(rip, (off_t) ex64lo(position), 0); + b = read_map(rip, (off_t) (unsigned long)(position), 0); dev = rip->i_dev; ino = rip->i_num; assert(ino != VMC_NO_INODE); @@ -263,7 +262,7 @@ int *completed; /* number of bytes copied */ /* Writing to or peeking a nonexistent block. * Create and enter in inode. */ - if ((bp = new_block(rip, (off_t) ex64lo(position))) == NULL) + if ((bp = new_block(rip, (off_t) (unsigned long)(position))) == NULL) return(err_code); } } else if (rw_flag == READING || rw_flag == PEEKING) { @@ -275,7 +274,7 @@ int *completed; /* number of bytes copied */ * the cache, acquire it, otherwise just acquire a free buffer. */ n = (chunk == block_size ? NO_READ : NORMAL); - if (!block_spec && off == 0 && (off_t) ex64lo(position) >= rip->i_size) + if (!block_spec && off == 0 && (off_t) (unsigned long)(position) >= rip->i_size) n = NO_READ; if(block_spec) { assert(ino == VMC_NO_INODE); @@ -292,7 +291,7 @@ int *completed; /* number of bytes copied */ panic("bp not valid in rw_chunk, this can't happen"); if (rw_flag == WRITING && chunk != block_size && !block_spec && - (off_t) ex64lo(position) >= rip->i_size && off == 0) { + (off_t) (unsigned long)(position) >= rip->i_size && off == 0) { zero_block(bp); } @@ -552,13 +551,13 @@ unsigned bytes_ahead; /* bytes beyond position for immediate use */ if (block_spec && rip->i_size == 0) { blocks_left = (block_t) NR_IOREQS; } else { - blocks_left = (block_t) (rip->i_size-ex64lo(position)+(block_size-1)) / + blocks_left = (block_t) (rip->i_size-(unsigned long)(position)+(block_size-1)) / block_size; /* Go for the first indirect block if we are in its neighborhood. */ if (!block_spec) { ind1_pos = (EXT2_NDIR_BLOCKS) * block_size; - if ((off_t) ex64lo(position) <= ind1_pos && rip->i_size > ind1_pos) { + if ((off_t) (unsigned long)(position) <= ind1_pos && rip->i_size > ind1_pos) { blocks_ahead++; blocks_left++; } @@ -591,7 +590,7 @@ unsigned bytes_ahead; /* bytes beyond position for immediate use */ position_running += block_size; if(!block_spec && - (thisblock = read_map(rip, (off_t) ex64lo(position_running), 1)) != NO_BLOCK) { + (thisblock = read_map(rip, (off_t) (unsigned long)(position_running), 1)) != NO_BLOCK) { bp = lmfs_get_block_ino(dev, thisblock, PREFETCH, rip->i_num, position_running); } else { bp = get_block(dev, block, PREFETCH); diff --git a/servers/ext2/super.c b/servers/ext2/super.c index 5fb69c5f5..e843e2b3e 100644 --- a/servers/ext2/super.c +++ b/servers/ext2/super.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "buf.h" #include "inode.h" diff --git a/servers/iso9660fs/read.c b/servers/iso9660fs/read.c index 045fddfe3..c1ad6147b 100644 --- a/servers/iso9660fs/read.c +++ b/servers/iso9660fs/read.c @@ -95,7 +95,7 @@ int fs_bread(void) rw_flag = (fs_m_in.m_type == REQ_BREAD ? READING : WRITING); gid = fs_m_in.REQ_GRANT; - position = make64(fs_m_in.REQ_SEEK_POS_LO, fs_m_in.REQ_SEEK_POS_HI); + position = (u64_t)fs_m_in.REQ_SEEK_POS_LO | ((u64_t)fs_m_in.REQ_SEEK_POS_HI<<32); nrbytes = (unsigned) fs_m_in.REQ_NBYTES; block_size = v_pri.logical_block_size_l; dir = v_pri.dir_rec_root; @@ -106,7 +106,7 @@ int fs_bread(void) cum_io = 0; /* Split the transfer into chunks that don't span two blocks. */ while (nrbytes != 0) { - off = rem64u(position, block_size); /* offset in blk*/ + off = (unsigned)(position % block_size); /* offset in blk*/ chunk = MIN(nrbytes, block_size - off); if (chunk < 0) chunk = block_size - off; @@ -124,8 +124,8 @@ int fs_bread(void) position += chunk; /* position within the file */ } - fs_m_out.RES_SEEK_POS_LO = ex64lo(position); - fs_m_out.RES_SEEK_POS_HI = ex64hi(position); + fs_m_out.RES_SEEK_POS_LO = (unsigned long)(position); + fs_m_out.RES_SEEK_POS_HI = (unsigned long)(position>>32); if (rdwt_err != OK) r = rdwt_err; /* check for disk error */ if (rdwt_err == END_OF_FILE) r = OK; @@ -307,23 +307,24 @@ int rw; /* READING or PEEKING */ *completed = 0; - if ((ex64lo(position) <= dir->d_file_size) && - (ex64lo(position) > dir->data_length_l)) { - while ((dir->d_next != NULL) && (ex64lo(position) > dir->data_length_l)) { - position = sub64ul(position, dir->data_length_l); + if (((unsigned long)(position) <= dir->d_file_size) && + ((unsigned long)(position) > dir->data_length_l)) { + while ((dir->d_next != NULL) && + ((unsigned long)(position) > dir->data_length_l)) { + position -= dir->data_length_l; dir = dir->d_next; } } if (dir->inter_gap_size != 0) { - rel_block = div64u(position, block_size); + rel_block = (unsigned long)(position / block_size); file_unit = rel_block / dir->data_length_l; offset = rel_block % dir->file_unit_size; b = dir->loc_extent_l + (dir->file_unit_size + dir->inter_gap_size) * file_unit + offset; } else { - b = dir->loc_extent_l + div64u(position, block_size); /* Physical position - * to read. */ + /* Physical position to read. */ + b = dir->loc_extent_l + (unsigned long)(position / block_size); } bp = get_block(b); diff --git a/servers/iso9660fs/super.c b/servers/iso9660fs/super.c index 3f9bcfab8..642640ae9 100644 --- a/servers/iso9660fs/super.c +++ b/servers/iso9660fs/super.c @@ -4,7 +4,6 @@ #include "inc.h" #include #include -#include #include /* This function is called when the filesystem is umounted. It releases the diff --git a/servers/mfs/cache.c b/servers/mfs/cache.c index 147332c40..2270a8baf 100644 --- a/servers/mfs/cache.c +++ b/servers/mfs/cache.c @@ -15,7 +15,6 @@ */ #include "fs.h" -#include #include #include #include diff --git a/servers/mfs/read.c b/servers/mfs/read.c index 704776261..644ada3cb 100644 --- a/servers/mfs/read.c +++ b/servers/mfs/read.c @@ -3,7 +3,6 @@ #include #include #include -#include #include "buf.h" #include "inode.h" #include "super.h" @@ -164,8 +163,8 @@ int fs_breadwrite(void) /* Get the values from the request message */ rw_flag = (fs_m_in.m_type == REQ_BREAD ? READING : WRITING); gid = (cp_grant_id_t) fs_m_in.REQ_GRANT; - position = make64((unsigned long) fs_m_in.REQ_SEEK_POS_LO, - (unsigned long) fs_m_in.REQ_SEEK_POS_HI); + position = (u64_t)fs_m_in.REQ_SEEK_POS_LO | + ((u64_t)fs_m_in.REQ_SEEK_POS_HI<<32); nrbytes = (size_t) fs_m_in.REQ_NBYTES; block_size = get_block_size(target_dev); @@ -183,7 +182,7 @@ int fs_breadwrite(void) cum_io = 0; /* Split the transfer into chunks that don't span two blocks. */ while (nrbytes > 0) { - off = rem64u(position, block_size); /* offset in blk*/ + off = (unsigned)(position % block_size); /* offset in blk*/ chunk = min(nrbytes, block_size - off); /* Read or write 'chunk' bytes. */ @@ -199,8 +198,8 @@ int fs_breadwrite(void) position += chunk; /* position within the file */ } - fs_m_out.RES_SEEK_POS_LO = ex64lo(position); - fs_m_out.RES_SEEK_POS_HI = ex64hi(position); + fs_m_out.RES_SEEK_POS_LO = (unsigned long)(position); + fs_m_out.RES_SEEK_POS_HI = (unsigned long)(position>>32); if (lmfs_rdwt_err() != OK) r = lmfs_rdwt_err(); /* check for disk error */ if (lmfs_rdwt_err() == END_OF_FILE) r = OK; @@ -248,12 +247,12 @@ int *completed; /* number of bytes copied */ block_spec = (rip->i_mode & I_TYPE) == I_BLOCK_SPECIAL; if (block_spec) { - b = div64u(position, block_size); + b = (unsigned long)(position / block_size); dev = (dev_t) rip->i_zone[0]; } else { - if (ex64hi(position) != 0) + if ((unsigned long)(position>>32) != 0) panic("rw_chunk: position too high"); - b = read_map(rip, (off_t) ex64lo(position), 0); + b = read_map(rip, (off_t) (unsigned long)(position), 0); dev = rip->i_dev; ino = rip->i_num; assert(ino != VMC_NO_INODE); @@ -272,7 +271,7 @@ int *completed; /* number of bytes copied */ /* Writing to or peeking a nonexistent block. * Create and enter in inode. */ - if ((bp = new_block(rip, (off_t) ex64lo(position))) == NULL) + if ((bp = new_block(rip, (off_t) (unsigned long)(position))) == NULL) return(err_code); } } else if (rw_flag == READING || rw_flag == PEEKING) { @@ -284,7 +283,7 @@ int *completed; /* number of bytes copied */ * the cache, acquire it, otherwise just acquire a free buffer. */ n = (chunk == block_size ? NO_READ : NORMAL); - if (!block_spec && off == 0 && (off_t) ex64lo(position) >= rip->i_size) + if (!block_spec && off == 0 && (off_t) (unsigned long)(position) >= rip->i_size) n = NO_READ; if(block_spec) { assert(ino == VMC_NO_INODE); @@ -300,7 +299,7 @@ int *completed; /* number of bytes copied */ assert(bp != NULL); if (rw_flag == WRITING && chunk != block_size && !block_spec && - (off_t) ex64lo(position) >= rip->i_size && off == 0) { + (off_t) (unsigned long)(position) >= rip->i_size && off == 0) { zero_block(bp); } @@ -539,14 +538,14 @@ unsigned bytes_ahead; /* bytes beyond position for immediate use */ if (block_spec && rip->i_size == 0) { blocks_left = (block_t) NR_IOREQS; } else { - blocks_left = (block_t) (rip->i_size-ex64lo(position)+(block_size-1)) / + blocks_left = (block_t) (rip->i_size-(unsigned long)(position)+(block_size-1)) / block_size; /* Go for the first indirect block if we are in its neighborhood. */ if (!block_spec) { scale = rip->i_sp->s_log_zone_size; ind1_pos = (off_t) rip->i_ndzones * (block_size << scale); - if ((off_t) ex64lo(position) <= ind1_pos && + if ((off_t) (unsigned long)(position) <= ind1_pos && rip->i_size > ind1_pos) { blocks_ahead++; blocks_left++; @@ -581,7 +580,7 @@ unsigned bytes_ahead; /* bytes beyond position for immediate use */ position_running += block_size; if(!block_spec && - (thisblock = read_map(rip, (off_t) ex64lo(position_running), 1)) != NO_BLOCK) { + (thisblock = read_map(rip, (off_t) (unsigned long)(position_running), 1)) != NO_BLOCK) { bp = lmfs_get_block_ino(dev, thisblock, PREFETCH, rip->i_num, position_running); } else { bp = get_block(dev, block, PREFETCH); diff --git a/servers/mfs/stats.c b/servers/mfs/stats.c index 871576359..3e019bf6d 100644 --- a/servers/mfs/stats.c +++ b/servers/mfs/stats.c @@ -2,7 +2,6 @@ #include #include #include -#include #include "buf.h" #include "inode.h" #include "super.h" diff --git a/servers/mfs/super.c b/servers/mfs/super.c index 6f8903dcb..f9d4e12d6 100644 --- a/servers/mfs/super.c +++ b/servers/mfs/super.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "buf.h" #include "inode.h" diff --git a/servers/procfs/inc.h b/servers/procfs/inc.h index 342694a60..3e4ed8859 100644 --- a/servers/procfs/inc.h +++ b/servers/procfs/inc.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/servers/procfs/pid.c b/servers/procfs/pid.c index f37e049a1..1b6787623 100644 --- a/servers/procfs/pid.c +++ b/servers/procfs/pid.c @@ -103,8 +103,8 @@ static void pid_psinfo(int i) (int) proc[i].p_priority, /* process priority */ (long) proc[i].p_user_time, /* user time */ (long) proc[i].p_sys_time, /* system time */ - ex64hi(proc[i].p_cycles), /* execution cycles */ - ex64lo(proc[i].p_cycles) + (unsigned long)(proc[i].p_cycles>>32), /* execution cycles */ + (unsigned long)(proc[i].p_cycles) ); memset(&vui, 0, sizeof(vui)); @@ -160,10 +160,10 @@ static void pid_psinfo(int i) /* always add kernel cycles */ buf_printf(" %lu %lu %lu %lu", - ex64hi(proc[i].p_kipc_cycles), - ex64lo(proc[i].p_kipc_cycles), - ex64hi(proc[i].p_kcall_cycles), - ex64lo(proc[i].p_kcall_cycles)); + (unsigned long)(proc[i].p_kipc_cycles>>32), + (unsigned long)(proc[i].p_kipc_cycles), + (unsigned long)(proc[i].p_kcall_cycles>>32), + (unsigned long)(proc[i].p_kcall_cycles)); /* add total memory for tasks at the end */ if(task) buf_printf(" %lu", vui.vui_total); diff --git a/servers/vfs/device.c b/servers/vfs/device.c index ab42a2238..2a083d53f 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -29,7 +29,6 @@ #include #include #include -#include #include "file.h" #include "fproc.h" #include "scratchpad.h" @@ -411,8 +410,8 @@ int dev_io( endpoint_t ioproc; int ret, is_asyn; - pos_lo = ex64lo(pos); - pos_high = ex64hi(pos); + pos_lo = (unsigned long)(pos); + pos_high = (unsigned long)(pos>>32); major_dev = major(dev); minor_dev = minor(dev); diff --git a/servers/vfs/exec.c b/servers/vfs/exec.c index 638d1d404..8d03da0b8 100644 --- a/servers/vfs/exec.c +++ b/servers/vfs/exec.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/servers/vfs/filedes.c b/servers/vfs/filedes.c index c8c5f4c77..2b7eb3c9a 100644 --- a/servers/vfs/filedes.c +++ b/servers/vfs/filedes.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include "fs.h" diff --git a/servers/vfs/lock.c b/servers/vfs/lock.c index 0551a8401..4df65b5e6 100644 --- a/servers/vfs/lock.c +++ b/servers/vfs/lock.c @@ -7,7 +7,6 @@ #include "fs.h" #include -#include #include #include #include "file.h" @@ -51,9 +50,9 @@ int req; /* either F_SETLK or F_SETLKW */ switch (flock.l_whence) { case SEEK_SET: first = 0; break; case SEEK_CUR: - if (ex64hi(f->filp_pos) != 0) + if ((unsigned long)(f->filp_pos>>32) != 0) panic("lock_op: position in file too high"); - first = ex64lo(f->filp_pos); + first = (unsigned long)(f->filp_pos); break; case SEEK_END: first = f->filp_vno->v_size; break; default: return(EINVAL); diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index 8d1a4499c..65e99c98d 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -199,9 +198,9 @@ int do_fcntl(message *UNUSED(m_out)) switch(flock_arg.l_whence) { case SEEK_SET: start = 0; break; case SEEK_CUR: - if (ex64hi(f->filp_pos) != 0) + if ((unsigned long)(f->filp_pos>>32) != 0) panic("do_fcntl: position in file too high"); - start = ex64lo(f->filp_pos); + start = (unsigned long)(f->filp_pos); break; case SEEK_END: start = f->filp_vno->v_size; break; default: r = EINVAL; @@ -376,8 +375,8 @@ int do_vm_call(message *m_out) int req_fd = job_m_in.VFS_VMCALL_FD; u32_t req_id = job_m_in.VFS_VMCALL_REQID; endpoint_t ep = job_m_in.VFS_VMCALL_ENDPOINT; - u64_t offset = make64(job_m_in.VFS_VMCALL_OFFSET_LO, - job_m_in.VFS_VMCALL_OFFSET_HI); + u64_t offset = (u64_t)job_m_in.VFS_VMCALL_OFFSET_LO | + ((u64_t)job_m_in.VFS_VMCALL_OFFSET_HI<<32); u32_t length = job_m_in.VFS_VMCALL_LENGTH; int result = OK; int slot; diff --git a/servers/vfs/open.c b/servers/vfs/open.c index 3b1b5b9b0..87ffff89f 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -17,7 +17,6 @@ #include #include #include -#include #include "file.h" #include "fproc.h" #include "scratchpad.h" @@ -614,21 +613,18 @@ int actual_lseek(message *m_out, int seekfd, int seekwhence, off_t offset) default: unlock_filp(rfilp); return(EINVAL); } - if (offset >= 0) - newpos = pos + offset; - else - newpos = sub64ul(pos, -offset); + newpos = pos + offset; /* Check for overflow. */ - if (ex64hi(newpos) != 0) { + if ((unsigned long)(newpos>>32) != 0) { r = EOVERFLOW; - } else if ((off_t) ex64lo(newpos) < 0) { /* no negative file size */ + } else if ((off_t) (unsigned long)(newpos) < 0) { /* no negative file size */ r = EOVERFLOW; } else { /* insert the new position into the output message */ - m_out->reply_l1 = ex64lo(newpos); + m_out->reply_l1 = (unsigned long)(newpos); - if (cmp64(newpos, rfilp->filp_pos) != 0) { + if (newpos != rfilp->filp_pos) { rfilp->filp_pos = newpos; /* Inhibit read ahead request */ @@ -660,7 +656,7 @@ int actual_llseek(struct fproc *rfp, message *m_out, int seekfd, int seekwhence, register struct filp *rfilp; u64_t pos, newpos; int r = OK; - long off_hi = ex64hi(offset); + long off_hi = (unsigned long)(offset>>32); /* Check to see if the file descriptor is valid. */ if ( (rfilp = get_filp2(rfp, seekfd, VNODE_READ)) == NULL) { @@ -684,16 +680,16 @@ int actual_llseek(struct fproc *rfp, message *m_out, int seekfd, int seekwhence, newpos = pos + offset; /* Check for overflow. */ - if ((off_hi > 0) && cmp64(newpos, pos) < 0) + if ((off_hi > 0) && newpos < pos) r = EINVAL; - else if ((off_hi < 0) && cmp64(newpos, pos) > 0) + else if ((off_hi < 0) && newpos > pos) r = EINVAL; else { /* insert the new position into the output message */ - m_out->reply_l1 = ex64lo(newpos); - m_out->reply_l2 = ex64hi(newpos); + m_out->reply_l1 = (unsigned long)(newpos); + m_out->reply_l2 = (unsigned long)(newpos>>32); - if (cmp64(newpos, rfilp->filp_pos) != 0) { + if (newpos != rfilp->filp_pos) { rfilp->filp_pos = newpos; /* Inhibit read ahead request */ @@ -709,7 +705,7 @@ int actual_llseek(struct fproc *rfp, message *m_out, int seekfd, int seekwhence, int do_llseek(message *m_out) { return actual_llseek(fp, m_out, job_m_in.ls_fd, job_m_in.whence, - make64(job_m_in.offset_lo, job_m_in.offset_high)); + (u64_t)job_m_in.offset_lo | ((u64_t)job_m_in.offset_high<<32)); } /*===========================================================================* diff --git a/servers/vfs/path.c b/servers/vfs/path.c index 3d94215db..ce714d461 100644 --- a/servers/vfs/path.c +++ b/servers/vfs/path.c @@ -620,7 +620,7 @@ char ename[NAME_MAX + 1]; char buf[DIR_ENTRY_SIZE * DIR_ENTRIES]; struct dirent *cur; - pos = make64(0, 0); + pos = (u64_t)0; if (!S_ISDIR(dirp->v_mode)) return(EBADF); diff --git a/servers/vfs/pipe.c b/servers/vfs/pipe.c index 8f4fd7036..a07ca8de2 100644 --- a/servers/vfs/pipe.c +++ b/servers/vfs/pipe.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include "file.h" diff --git a/servers/vfs/read.c b/servers/vfs/read.c index 173e4ee00..1d3eb2738 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "file.h" #include "fproc.h" #include "scratchpad.h" @@ -217,7 +216,7 @@ int read_write(struct fproc *rfp, int rw_flag, struct filp *f, rw_flag, for_e, buf, size, &new_pos, &cum_io_incr); if (r >= 0) { - if (ex64hi(new_pos)) + if ((unsigned long)(new_pos>>32)) panic("read_write: bad new pos"); position = new_pos; @@ -229,11 +228,11 @@ int read_write(struct fproc *rfp, int rw_flag, struct filp *f, /* On write, update file size and access time. */ if (rw_flag == WRITING) { if (S_ISREG(vp->v_mode) || S_ISDIR(vp->v_mode)) { - if (cmp64ul(position, vp->v_size) > 0) { - if (ex64hi(position) != 0) { + if (position > (u64_t)(vp->v_size)) { + if ((unsigned long)(position>>32) != 0) { panic("read_write: file size too big "); } - vp->v_size = ex64lo(position); + vp->v_size = (unsigned long)(position); } } } @@ -279,7 +278,7 @@ int do_getdents(message *UNUSED(m_out)) r = EBADF; if (r == OK) { - if (ex64hi(rfilp->filp_pos) != 0) + if ((unsigned long)(rfilp->filp_pos>>32) != 0) panic("do_getdents: can't handle large offsets"); r = req_getdents(rfilp->filp_vno->v_fs_e, rfilp->filp_vno->v_inode_nr, @@ -346,14 +345,14 @@ size_t req_size; return(r); } - if (ex64hi(new_pos)) + if ((unsigned long)(new_pos>>32)) panic("rw_pipe: bad new pos"); cum_io += cum_io_incr; buf += cum_io_incr; req_size -= cum_io_incr; - vp->v_size = ex64lo(new_pos); + vp->v_size = (unsigned long)(new_pos); if (partial_pipe) { /* partial write on pipe with */ diff --git a/servers/vfs/request.c b/servers/vfs/request.c index 71ea86ae2..c19857869 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include "fproc.h" @@ -53,8 +52,8 @@ int req_breadwrite( m.m_type = rw_flag == READING ? REQ_BREAD : REQ_BWRITE; m.REQ_DEV2 = dev; m.REQ_GRANT = grant_id; - m.REQ_SEEK_POS_LO = ex64lo(pos); - m.REQ_SEEK_POS_HI = ex64hi(pos); + m.REQ_SEEK_POS_LO = (unsigned long)(pos); + m.REQ_SEEK_POS_HI = (unsigned long)(pos>>32); m.REQ_NBYTES = num_of_bytes; /* Send/rec request */ @@ -63,7 +62,7 @@ int req_breadwrite( if (r != OK) return(r); /* Fill in response structure */ - *new_posp = make64(m.RES_SEEK_POS_LO, m.RES_SEEK_POS_HI); + *new_posp = (u64_t)m.RES_SEEK_POS_LO | ((u64_t)m.RES_SEEK_POS_HI<<32); *cum_iop = m.RES_NBYTES; return(OK); @@ -81,8 +80,8 @@ int req_bpeek(endpoint_t fs_e, dev_t dev, u64_t pos, unsigned int num_of_bytes) /* Fill in request message */ m.m_type = REQ_BPEEK; m.REQ_DEV2 = dev; - m.REQ_SEEK_POS_LO = ex64lo(pos); - m.REQ_SEEK_POS_HI = ex64hi(pos); + m.REQ_SEEK_POS_LO = (unsigned long)(pos); + m.REQ_SEEK_POS_HI = (unsigned long)(pos>>32); m.REQ_NBYTES = num_of_bytes; /* Send/rec request */ @@ -323,7 +322,7 @@ int req_getdents( m.REQ_INODE_NR = inode_nr; m.REQ_GRANT = grant_id; m.REQ_MEM_SIZE = size; - m.REQ_SEEK_POS_LO = ex64lo(pos); + m.REQ_SEEK_POS_LO = (unsigned long)(pos); m.REQ_SEEK_POS_HI = 0; /* Not used for now, so clear it. */ r = fs_sendrec(fs_e, &m); @@ -786,7 +785,7 @@ unsigned int *cum_iop; cp_grant_id_t grant_id; message m; - if (ex64hi(pos) != 0) + if ((unsigned long)(pos>>32) != 0) panic("req_readwrite: pos too large"); grant_id = cpf_grant_magic(fs_e, user_e, (vir_bytes) user_addr, num_of_bytes, @@ -798,7 +797,7 @@ unsigned int *cum_iop; m.m_type = rw_flag == READING ? REQ_READ : REQ_WRITE; m.REQ_INODE_NR = inode_nr; m.REQ_GRANT = grant_id; - m.REQ_SEEK_POS_LO = ex64lo(pos); + m.REQ_SEEK_POS_LO = (unsigned long)(pos); m.REQ_SEEK_POS_HI = 0; /* Not used for now, so clear it. */ m.REQ_NBYTES = num_of_bytes; @@ -824,14 +823,14 @@ int req_peek(endpoint_t fs_e, ino_t inode_nr, u64_t pos, unsigned int bytes) memset(&m, 0, sizeof(m)); - if (ex64hi(pos) != 0) + if ((unsigned long)(pos>>32) != 0) panic("req_peek: pos too large"); /* Fill in request message */ m.m_type = REQ_PEEK; m.REQ_INODE_NR = inode_nr; m.REQ_GRANT = -1; - m.REQ_SEEK_POS_LO = ex64lo(pos); + m.REQ_SEEK_POS_LO = (unsigned long)(pos); m.REQ_SEEK_POS_HI = 0; /* Not used for now, so clear it. */ m.REQ_NBYTES = bytes; diff --git a/servers/vfs/select.c b/servers/vfs/select.c index 53f183bf9..612a16c4e 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/servers/vfs/stadir.c b/servers/vfs/stadir.c index 09763f41b..eeb2372f8 100644 --- a/servers/vfs/stadir.c +++ b/servers/vfs/stadir.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include "file.h" #include "fproc.h" diff --git a/servers/vm/cache.c b/servers/vm/cache.c index fd6be5ab3..579e163bc 100644 --- a/servers/vm/cache.c +++ b/servers/vm/cache.c @@ -75,7 +75,7 @@ void cache_lru_touch(struct cached_page *hb) static __inline u32_t makehash(u32_t p1, u64_t p2) { - u32_t offlo = ex64lo(p2), offhi = ex64hi(p2), + u32_t offlo = (unsigned long)(p2), offhi = (unsigned long)(p2>>32), v = 0x12345678; hash_mix(p1, offlo, offhi); hash_final(offlo, offhi, v); diff --git a/servers/vm/mmap.c b/servers/vm/mmap.c index aa2ad2b16..6c6f3aac3 100644 --- a/servers/vm/mmap.c +++ b/servers/vm/mmap.c @@ -97,7 +97,7 @@ static int mmap_file(struct vmproc *vmp, if(flags & MAP_THIRDPARTY) { file_offset = off_lo; } else { - file_offset = make64(off_lo, off_hi); + file_offset = (u64_t)off_lo | ((u64_t)off_hi << 32); if(off_hi && !off_lo) { /* XXX clang compatability hack */ off_hi = file_offset = 0; diff --git a/servers/vm/regionavl.c b/servers/vm/regionavl.c index 2214e669f..b7ab87c2f 100644 --- a/servers/vm/regionavl.c +++ b/servers/vm/regionavl.c @@ -1,6 +1,5 @@ #include -#include #include "proto.h" #include "sanitycheck.h" diff --git a/servers/vm/regionavl_defs.h b/servers/vm/regionavl_defs.h index 2811bce61..1459683fb 100644 --- a/servers/vm/regionavl_defs.h +++ b/servers/vm/regionavl_defs.h @@ -1,4 +1,3 @@ -#include #define AVL_UNIQUE(id) region_ ## id #define AVL_HANDLE region_t * diff --git a/servers/vm/vfs.c b/servers/vm/vfs.c index 92b2fb6ff..15a92037b 100644 --- a/servers/vm/vfs.c +++ b/servers/vm/vfs.c @@ -85,8 +85,8 @@ int vfs_request(int reqno, int fd, struct vmproc *vmp, u64_t offset, u32_t len, m->VFS_VMCALL_FD = fd; m->VFS_VMCALL_REQID = reqid; m->VFS_VMCALL_ENDPOINT = vmp->vm_endpoint; - m->VFS_VMCALL_OFFSET_LO = ex64lo(offset); - m->VFS_VMCALL_OFFSET_HI = ex64hi(offset); + m->VFS_VMCALL_OFFSET_LO = (unsigned long)(offset); + m->VFS_VMCALL_OFFSET_HI = (unsigned long)(offset>>32); m->VFS_VMCALL_LENGTH = len; reqnode->who = vmp->vm_endpoint; diff --git a/test/blocktest/blocktest.c b/test/blocktest/blocktest.c index e512d93e9..069103f47 100644 --- a/test/blocktest/blocktest.c +++ b/test/blocktest/blocktest.c @@ -251,8 +251,8 @@ static void raw_xfer(dev_t minor, u64_t pos, iovec_s_t *iovec, int nr_req, memset(&m, 0, sizeof(m)); m.m_type = write ? BDEV_SCATTER : BDEV_GATHER; m.BDEV_MINOR = minor; - m.BDEV_POS_LO = ex64lo(pos); - m.BDEV_POS_HI = ex64hi(pos); + m.BDEV_POS_LO = (unsigned long)(pos); + m.BDEV_POS_HI = (unsigned long)(pos>>32); m.BDEV_COUNT = nr_req; m.BDEV_GRANT = grant; m.BDEV_ID = lrand48(); @@ -1541,7 +1541,7 @@ static void real_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs) if (res.type == RESULT_OK && subpart.size != 0) { res.type = RESULT_BADVALUE; - res.value = ex64lo(subpart.size); + res.value = (unsigned long)(subpart.size); } got_result(&res, "ioctl to get first subpartition"); @@ -1550,7 +1550,7 @@ static void real_limits(dev_t sub0_minor, dev_t sub1_minor, int part_secs) if (res.type == RESULT_OK && subpart.size != 0) { res.type = RESULT_BADVALUE; - res.value = ex64lo(subpart.size); + res.value = (unsigned long)(subpart.size); } got_result(&res, "ioctl to get second subpartition"); diff --git a/test/test53.c b/test/test53.c index d7d14e583..6aac0a353 100644 --- a/test/test53.c +++ b/test/test53.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -23,9 +22,9 @@ static void err(int line) /* print error information */ printf("error line %d; i=0x%.8lx%.8lx; j=0x%.8lx%.8lx; k=0x%.8lx%.8lx\n", line, - ex64hi(i), ex64lo(i), - ex64hi(j), ex64lo(j), - ex64hi(k), ex64lo(k)); + (unsigned long)(i>>32), (unsigned long) i, + (unsigned long)(j>>32), (unsigned long) j, + (unsigned long)(k>>32), (unsigned long) k); /* quit after too many errors */ e(7); @@ -65,27 +64,28 @@ static u64_t getargval(int index, int *done) /* values with corner case and random 32-bit components */ if (index < LENGTHOF(values) * LENGTHOF(values)) - return make64(values[index / LENGTHOF(values)], values[index % LENGTHOF(values)]); + return ((u64_t)(values[index / LENGTHOF(values)]) << 32) | + (u64_t)(values[index % LENGTHOF(values)]); index -= LENGTHOF(values) * LENGTHOF(values); /* small numbers */ - if (index < 16) return make64(index + 2, 0); + if (index < 16) return ((u64_t)(index + 2) << 32) | (u64_t)0; index -= 16; /* big numbers */ - if (index < 16) return make64(-index - 2, -1); + if (index < 16) return ((u64_t)(-index - 2) << 32) | (u64_t)-1; index -= 16; /* powers of two */ - if (index < 14) return make64(1 << (index * 2 + 5), 0); + if (index < 14) return ((u64_t)(1 << (index * 2 + 5)) << 32) | (u64_t)0; index -= 14; - if (index < 16) return make64(0, 1 << (index * 2 + 1)); + if (index < 16) return ((u64_t) 0 << 32) | (u64_t)(1 << (index * 2 + 1)); index -= 16; /* done */ *done = 1; - return make64(0, 0); + return ((u64_t) 0 << 32) | (u64_t) 0; } static void handler_SIGFPE(int signum) @@ -110,54 +110,68 @@ static void handler_SIGFPE(int signum) exit(-1); } +static inline int bsr64(u64_t i) +{ + int index; + u64_t mask; + + for (index = 63, mask = 1ULL << 63; index >= 0; --index, mask >>= 1) { + if (i & mask) + return index; + } + + return -1; +} + static void testmul(void) { int kdone, kidx; - u32_t ilo = ex64lo(i), jlo = ex64lo(j); - u64_t prod = mul64(i, j); + u32_t ilo = (unsigned long) i, jlo = (unsigned long) j; + u64_t prod = i * j; int prodbits; /* compute maximum index of highest-order bit */ prodbits = bsr64(i) + bsr64(j) + 1; - if (cmp64u(i, 0) == 0 || cmp64u(j, 0) == 0) prodbits = -1; + if (i == 0 || j == 0) prodbits = -1; if (bsr64(prod) > prodbits) ERR; /* compare to 32-bit multiplication if possible */ - if (ex64hi(i) == 0 && ex64hi(j) == 0) { - if (cmp64(prod, mul64u(ilo, jlo)) != 0) ERR; + if ((unsigned long)(i>>32) == 0 && (unsigned long)(j>>32) == 0) { + if (prod != (u64_t)ilo * jlo) ERR; /* if there is no overflow we can check against pure 32-bit */ - if (prodbits < 32 && cmp64u(prod, ilo * jlo) != 0) ERR; + if (prodbits < 32 && prod != ilo * jlo) ERR; } /* in 32-bit arith low-order DWORD matches regardless of overflow */ - if (ex64lo(prod) != ilo * jlo) ERR; + if ((unsigned long) prod != ilo * jlo) ERR; /* multiplication by zero yields zero */ - if (prodbits < 0 && cmp64u(prod, 0) != 0) ERR; + if (prodbits < 0 && prod != 0) ERR; /* if there is no overflow, check absence of zero divisors */ - if (prodbits >= 0 && prodbits < 64 && cmp64u(prod, 0) == 0) ERR; + if (prodbits >= 0 && prodbits < 64 && prod == 0) ERR; /* commutativity */ - if (cmp64(prod, mul64(j, i)) != 0) ERR; + if (prod != j * i) ERR; /* loop though all argument value combinations for third argument */ for (kdone = 0, kidx = 0; k = getargval(kidx, &kdone), !kdone; kidx++) { /* associativity */ - if (cmp64(mul64(mul64(i, j), k), mul64(i, mul64(j, k))) != 0) ERR; + if (((i * j) * k) != (i * (j * k))) ERR; /* left and right distributivity */ - 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; + if ((i + j) * k != (i * k) + (j * k)) ERR; + if ((i * (j + k)) != (i * j) + (i * k)) ERR; } } static void testdiv0(void) { int funcidx; + u64_t res; /* for the div 0 tests */ - assert(cmp64u(j, 0) == 0); + assert(j == 0); /* loop through the 5 different division functions */ for (funcidx = 0; funcidx < 5; funcidx++) { @@ -165,12 +179,12 @@ static void testdiv0(void) if (setjmp(jmpbuf_SIGFPE) == 0) { /* divide by zero using various functions */ switch (funcidx) { - case 0: div64(i, j); ERR; break; - case 1: div64u64(i, ex64lo(j)); ERR; break; - case 2: div64u(i, ex64lo(j)); ERR; break; - case 3: rem64(i, j); ERR; break; - case 4: rem64u(i, ex64lo(j)); ERR; break; - default: assert(0); ERR; break; + case 0: res = i / j; ERR; break; + case 1: res = i / (unsigned long) j; ERR; break; + case 2: res = i / (unsigned long) j; ERR; break; + case 3: res = i % j; ERR; break; + case 4: res = i % (unsigned long) j; ERR; break; + default: assert(0); ERR; break; } /* if we reach this point there was no signal and an @@ -193,21 +207,21 @@ static void testdiv(void) struct timeval tvstart, tvend; printf("i=0x%.8x%.8x; j=0x%.8x%.8x\n", - ex64hi(i), ex64lo(i), - ex64hi(j), ex64lo(j)); + (unsigned long)(i>>32), (unsigned long) i, + (unsigned long)(j>>32), (unsigned long) j); fflush(stdout); if (gettimeofday(&tvstart, NULL) < 0) ERR; #endif /* division by zero has a separate test */ - if (cmp64u(j, 0) == 0) { + if (j == 0) { testdiv0(); return; } /* perform division, store q in k to make ERR more informative */ - q = div64(i, j); - r = rem64(i, j); + q = i / j; + r = i % j; k = q; #if TIMED @@ -219,30 +233,30 @@ static void testdiv(void) tvend.tv_usec += 1000000; } printf("q=0x%.8x%.8x; r=0x%.8x%.8x; time=%d.%.6d\n", - ex64hi(q), ex64lo(q), - ex64hi(r), ex64lo(r), + (unsigned long)(q>>32), (unsigned long) q, + (unsigned long)(r>>32), (unsigned long) r, tvend.tv_sec, tvend.tv_usec); fflush(stdout); #endif /* compare to 64/32-bit division if possible */ - if (!ex64hi(j)) { - if (cmp64(q, div64u64(i, ex64lo(j))) != 0) ERR; - if (!ex64hi(q)) { - if (cmp64u(q, div64u(i, ex64lo(j))) != 0) ERR; + if (!(unsigned long)(j>>32)) { + if (q != i / (unsigned long) j) ERR; + if (!(unsigned long)(q>>32)) { + if (q != i / (unsigned long) j) ERR; } - if (cmp64u(r, rem64u(i, ex64lo(j))) != 0) ERR; + if (r != i % (unsigned long) j) ERR; /* compare to 32-bit division if possible */ - if (!ex64hi(i)) { - if (cmp64u(q, ex64lo(i) / ex64lo(j)) != 0) ERR; - if (cmp64u(r, ex64lo(i) % ex64lo(j)) != 0) ERR; + if (!(unsigned long)(i>>32)) { + if (q != (unsigned long) i / (unsigned long) j) ERR; + if (r != (unsigned long) i % (unsigned long) j) ERR; } } /* check results using i = q j + r and r < j */ - if (cmp64(i, mul64(q, j) + r) != 0) ERR; - if (cmp64(r, j) >= 0) ERR; + if (i != (q * j) + r) ERR; + if (r >= j) ERR; } static void test(void) diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index b82c69157..dc9620664 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -145,7 +144,7 @@ static void parse_file(pid_t pid) if (state != STATE_RUN) p->p_flags |= BLOCKED; - p->p_cpucycles[0] = make64(cycles_lo, cycles_hi); + p->p_cpucycles[0] = (u64_t)cycles_lo | ((u64_t)cycles_hi<<32); p->p_memory = 0L; if (!(p->p_flags & IS_TASK)) { @@ -163,7 +162,7 @@ static void parse_file(pid_t pid) for(i = 1; i < CPUTIMENAMES; i++) { if(fscanf(fp, " %lu %lu", &cycles_hi, &cycles_lo) == 2) { - p->p_cpucycles[i] = make64(cycles_lo, cycles_hi); + p->p_cpucycles[i] = (u64_t)cycles_lo | ((u64_t)cycles_hi<<32); } else { p->p_cpucycles[i] = 0; } diff --git a/usr.sbin/mkfs.mfs/mkfs.c b/usr.sbin/mkfs.mfs/mkfs.c index 36f506cf4..a9f55254d 100644 --- a/usr.sbin/mkfs.mfs/mkfs.c +++ b/usr.sbin/mkfs.mfs/mkfs.c @@ -13,7 +13,6 @@ #if defined(__minix) #include #include -#include #include #elif defined(__linux__) #include @@ -50,10 +49,6 @@ #define BIN 2 #define BINGRP 2 -#if !defined(__minix) -#define mul64u(a,b) ((uint64_t)(a) * (b)) -#endif - /* some Minix specific types that do not conflict with Posix */ #ifndef block_t typedef uint32_t block_t; /* block number */ @@ -380,13 +375,13 @@ main(int argc, char *argv[]) testb = alloc_block(); /* Try writing the last block of partition or diskette. */ - mkfs_seek(mul64u(blocks - 1, block_size), SEEK_SET); + mkfs_seek((uint64_t)(blocks - 1) * block_size, SEEK_SET); testb[0] = 0x3245; testb[1] = 0x11FF; testb[block_size/2-1] = 0x1F2F; w=mkfs_write(testb, block_size); sync(); /* flush write, so if error next read fails */ - mkfs_seek(mul64u(blocks - 1, block_size), SEEK_SET); + mkfs_seek((uint64_t)(blocks - 1) * block_size, SEEK_SET); testb[0] = 0; testb[1] = 0; testb[block_size/2-1] = 0; @@ -398,7 +393,7 @@ main(int argc, char *argv[]) testb[0], testb[1], testb[block_size-1]); errx(1, "File system is too big for minor device (read)"); } - mkfs_seek(mul64u(blocks - 1, block_size), SEEK_SET); + mkfs_seek((uint64_t)(blocks - 1) * block_size, SEEK_SET); testb[0] = 0; testb[1] = 0; testb[block_size/2-1] = 0; @@ -534,7 +529,7 @@ sizeup(char * device) { block_t d; #if defined(__minix) - u64_t bytes, resize; + uint64_t bytes, resize; u32_t rem; #else off_t size; @@ -553,11 +548,11 @@ sizeup(char * device) return 0; } - d = div64u(bytes, block_size); - rem = rem64u(bytes, block_size); + d = (unsigned long)(bytes / block_size); + rem = (unsigned)(bytes % block_size); - resize = mul64u(d, block_size) + rem; - if(cmp64(resize, bytes) != 0) { + resize = ((uint64_t)d * block_size) + rem; + if (resize != bytes) { /* Assume block_t is unsigned */ d = (block_t)(-1ul); fprintf(stderr, "%s: truncating FS at %lu blocks\n", @@ -1570,7 +1565,7 @@ get_block(block_t n, void *buf) memcpy(buf, zero, block_size); return; } - mkfs_seek(mul64u(n, block_size), SEEK_SET); + mkfs_seek((uint64_t)n * block_size, SEEK_SET); k = read(fd, buf, block_size); if (k != block_size) pexit("get_block couldn't read block #%u", (unsigned)n); @@ -1595,7 +1590,7 @@ put_block(block_t n, void *buf) (void) read_and_set(n); - mkfs_seek(mul64u(n, block_size), SEEK_SET); + mkfs_seek((uint64_t)n * block_size, SEEK_SET); mkfs_write(buf, block_size); }