From ad80a203dbe8dfd72afcba56c4335320c60b2e5a Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Sun, 24 Aug 2014 10:00:06 +0000 Subject: [PATCH] Move clock_time into libsys Change-Id: Ibc5034617e6f6581de7c4a166ca075b3c357fa82 --- lib/libpuffs/link.c | 6 ++--- lib/libpuffs/open.c | 11 +++++---- lib/libpuffs/protect.c | 4 ++-- lib/libpuffs/proto.h | 2 -- lib/libpuffs/read.c | 5 ++++- lib/libpuffs/time.c | 3 +-- lib/libpuffs/utility.c | 34 ++++------------------------ minix/fs/ext2/inode.c | 2 +- minix/fs/ext2/misc.c | 2 +- minix/fs/ext2/mount.c | 4 ++-- minix/fs/ext2/proto.h | 1 - minix/fs/ext2/utility.c | 22 ------------------ minix/fs/mfs/inode.c | 2 +- minix/fs/mfs/proto.h | 1 - minix/fs/mfs/utility.c | 22 ------------------ minix/fs/pfs/inode.c | 2 +- minix/fs/pfs/proto.h | 1 - minix/fs/pfs/utility.c | 22 ------------------ minix/include/minix/sysutil.h | 3 +++ minix/lib/libsys/Makefile | 1 + minix/lib/libsys/clock_time.c | 42 +++++++++++++++++++++++++++++++++++ minix/lib/libvtreefs/stadir.c | 2 +- minix/servers/pm/time.c | 18 +++++---------- minix/servers/vfs/proto.h | 1 - minix/servers/vfs/time.c | 2 +- minix/servers/vfs/utility.c | 29 ------------------------ 26 files changed, 80 insertions(+), 164 deletions(-) create mode 100644 minix/lib/libsys/clock_time.c diff --git a/lib/libpuffs/link.c b/lib/libpuffs/link.c index a3bb7991d..936d2023c 100644 --- a/lib/libpuffs/link.c +++ b/lib/libpuffs/link.c @@ -123,7 +123,7 @@ int fs_link(ino_t dir_nr, char *name, ino_t ino_nr) if (r != OK) return(EINVAL); - cur_time = clock_timespec(); + (void)clock_time(&cur_time); update_timens(pn, CTIME, &cur_time); update_timens(pn_dir, MTIME | CTIME, &cur_time); @@ -308,7 +308,7 @@ int fs_rename(ino_t old_dir_nr, char *old_name, ino_t new_dir_nr, } } - cur_time = clock_timespec(); + (void)clock_time(&cur_time); update_timens(old_dirp, MTIME | CTIME, &cur_time); update_timens(new_dirp, MTIME | CTIME, &cur_time); @@ -366,7 +366,7 @@ int fs_unlink(ino_t dir_nr, char *name, int call) } if (pn->pn_va.va_nlink != 0) { - cur_time = clock_timespec(); + (void)clock_time(&cur_time); update_timens(pn, CTIME, &cur_time); update_timens(pn_dir, MTIME | CTIME, &cur_time); } diff --git a/lib/libpuffs/open.c b/lib/libpuffs/open.c index 855bc27a6..c551a7e5e 100644 --- a/lib/libpuffs/open.c +++ b/lib/libpuffs/open.c @@ -43,7 +43,7 @@ int fs_create(ino_t dir_nr, char *name, mode_t mode, uid_t uid, gid_t gid, memset(&pni, 0, sizeof(pni)); pni.pni_cookie = (void** )&pn; - cur_time = clock_timespec(); + (void)clock_time(&cur_time); memset(&va, 0, sizeof(va)); va.va_type = VREG; @@ -127,7 +127,7 @@ int fs_mknod(ino_t dir_nr, char *name, mode_t mode, uid_t uid, gid_t gid, memset(&pni, 0, sizeof(pni)); pni.pni_cookie = (void** )&pn; - cur_time = clock_timespec(); + (void)clock_time(&cur_time); memset(&va, 0, sizeof(va)); va.va_type = VDIR; @@ -196,7 +196,7 @@ int fs_mkdir(ino_t dir_nr, char *name, mode_t mode, uid_t uid, gid_t gid) if ((pn_dir = puffs_pn_nodewalk(global_pu, 0, &dir_nr)) == NULL) return(ENOENT); - cur_time = clock_timespec(); + (void)clock_time(&cur_time); memset(&pni, 0, sizeof(pni)); pni.pni_cookie = (void** )&pn; @@ -254,6 +254,7 @@ int fs_slink(ino_t dir_nr, char *name, uid_t uid, gid_t gid, PUFFS_MAKECRED(pcr, &global_kcred); struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}}; struct vattr va; + struct timespec cur_time; /* Copy the link name's last component */ pcn.pcn_namelen = strlen(name); @@ -287,12 +288,14 @@ int fs_slink(ino_t dir_nr, char *name, uid_t uid, gid_t gid, memset(&pni, 0, sizeof(pni)); pni.pni_cookie = (void** )&pn; + (void)clock_time(&cur_time); + memset(&va, 0, sizeof(va)); va.va_type = VLNK; va.va_mode = (I_SYMBOLIC_LINK | RWX_MODES); va.va_uid = uid; va.va_gid = gid; - va.va_atime = va.va_mtime = va.va_ctime = clock_timespec(); + va.va_atime = va.va_mtime = va.va_ctime = cur_time; if (buildpath) { r = puffs_path_pcnbuild(global_pu, &pcn, pn_dir); diff --git a/lib/libpuffs/protect.c b/lib/libpuffs/protect.c index 818180692..b612552fc 100644 --- a/lib/libpuffs/protect.c +++ b/lib/libpuffs/protect.c @@ -27,7 +27,7 @@ int fs_chmod(ino_t ino_nr, mode_t *mode) puffs_vattr_null(&va); /* Clear setgid bit if file is not in caller's grp */ va.va_mode = (pn->pn_va.va_mode & ~ALL_MODES) | (*mode & ALL_MODES); - va.va_ctime = clock_timespec(); + (void)clock_time(&va.va_ctime); if (global_pu->pu_ops.puffs_node_setattr(global_pu, pn, &va, pcr) != 0) return(EINVAL); @@ -55,7 +55,7 @@ int fs_chown(ino_t ino_nr, uid_t uid, gid_t gid, mode_t *mode) va.va_uid = uid; va.va_gid = gid; va.va_mode = pn->pn_va.va_mode & ~(I_SET_UID_BIT | I_SET_GID_BIT); - va.va_ctime = clock_timespec(); + (void)clock_time(&va.va_ctime); if (global_pu->pu_ops.puffs_node_setattr(global_pu, pn, &va, pcr) != 0) return(EINVAL); diff --git a/lib/libpuffs/proto.h b/lib/libpuffs/proto.h index e67b7b4a4..35a14826d 100644 --- a/lib/libpuffs/proto.h +++ b/lib/libpuffs/proto.h @@ -3,7 +3,6 @@ struct puffs_usermount; struct puffs_node; -struct timespec; /* Function prototypes. */ @@ -62,7 +61,6 @@ int fs_statvfs(struct statvfs *st); int fs_utime(ino_t ino_nr, struct timespec *atime, struct timespec *mtime); /* utility.c */ -struct timespec clock_timespec(void); int update_timens(struct puffs_node *pn, int fl, struct timespec *); void lpuffs_debug(const char *format, ...) __attribute__((__format__(__printf__, 1, 2))); diff --git a/lib/libpuffs/read.c b/lib/libpuffs/read.c index f7484033d..a528a708b 100644 --- a/lib/libpuffs/read.c +++ b/lib/libpuffs/read.c @@ -73,6 +73,7 @@ ssize_t fs_write(ino_t ino_nr, struct fsdriver_data *data, size_t bytes, size_t bytes_left; struct puffs_node *pn; struct vattr va; + struct timespec cur_time; PUFFS_MAKECRED(pcr, &global_kcred); if ((pn = puffs_pn_nodewalk(global_pu, 0, &ino_nr)) == NULL) { @@ -88,10 +89,12 @@ ssize_t fs_write(ino_t ino_nr, struct fsdriver_data *data, size_t bytes, if (global_pu->pu_ops.puffs_node_setattr == NULL) return(EINVAL); + (void)clock_time(&cur_time); + puffs_vattr_null(&va); if ((u_quad_t)(pos + bytes_left) > pn->pn_va.va_size) va.va_size = bytes_left + pos; - va.va_ctime = va.va_mtime = clock_timespec(); + va.va_ctime = va.va_mtime = cur_time; va.va_atime = pn->pn_va.va_atime; r = global_pu->pu_ops.puffs_node_setattr(global_pu, pn, &va, pcr); diff --git a/lib/libpuffs/time.c b/lib/libpuffs/time.c index bc57ab07a..4edcca59f 100644 --- a/lib/libpuffs/time.c +++ b/lib/libpuffs/time.c @@ -22,11 +22,10 @@ int fs_utime(ino_t ino_nr, struct timespec *atime, struct timespec *mtime) if( (pn = puffs_pn_nodewalk(global_pu, 0, &ino_nr)) == NULL) return(EINVAL); - /* FIXME: shouldn't this check the special UTIME_ values? */ puffs_vattr_null(&va); va.va_atime = *atime; va.va_mtime = *mtime; - va.va_ctime = clock_timespec(); + (void)clock_time(&va.va_ctime); if (global_pu->pu_ops.puffs_node_setattr(global_pu, pn, &va, pcr) != 0) return(EINVAL); diff --git a/lib/libpuffs/utility.c b/lib/libpuffs/utility.c index e4607344b..bbd5123e2 100644 --- a/lib/libpuffs/utility.c +++ b/lib/libpuffs/utility.c @@ -11,35 +11,6 @@ #include "puffs_priv.h" -/*===========================================================================* - * clock_timespec * - *===========================================================================*/ -struct timespec clock_timespec(void) -{ -/* This routine returns the time in seconds since 1.1.1970. MINIX is an - * astrophysically naive system that assumes the earth rotates at a constant - * rate and that such things as leap seconds do not exist. - */ - static long system_hz = 0; - - register int k; - struct timespec tv; - clock_t uptime; - clock_t realtime; - time_t boottime; - - if (system_hz == 0) system_hz = sys_hz(); - if ((k=getuptime(&uptime, &realtime, &boottime)) != OK) - panic("clock_timespec: getuptime failed: %d", k); - - tv.tv_sec = (time_t) (boottime + (realtime/system_hz)); - /* We do not want to overflow, and system_hz can be as high as 50kHz */ - assert(system_hz < LONG_MAX/40000); - tv.tv_nsec = (realtime%system_hz) * 40000 / system_hz * 25000; - return tv; -} - - /*===========================================================================* * update_timens * *===========================================================================*/ @@ -56,7 +27,10 @@ int update_timens(struct puffs_node *pn, int flags, struct timespec *t) if (global_pu->pu_ops.puffs_node_setattr == NULL) return EINVAL; - new_time = t != NULL ? *t : clock_timespec(); + if (t != NULL) + new_time = *t; + else + (void)clock_time(&new_time); puffs_vattr_null(&va); /* librefuse modifies atime and mtime together, diff --git a/minix/fs/ext2/inode.c b/minix/fs/ext2/inode.c index 945363426..6396bb006 100644 --- a/minix/fs/ext2/inode.c +++ b/minix/fs/ext2/inode.c @@ -289,7 +289,7 @@ void update_times( if (sp->s_rd_only) return; /* no updates for read-only file systems */ - cur_time = clock_time(); + cur_time = clock_time(NULL); if (rip->i_update & ATIME) rip->i_atime = cur_time; if (rip->i_update & CTIME) diff --git a/minix/fs/ext2/misc.c b/minix/fs/ext2/misc.c index 2405ad338..c3eb6718f 100644 --- a/minix/fs/ext2/misc.c +++ b/minix/fs/ext2/misc.c @@ -33,7 +33,7 @@ int fs_sync() lmfs_flushall(); if (superblock->s_dev != NO_DEV) { - superblock->s_wtime = clock_time(); + superblock->s_wtime = clock_time(NULL); write_super(superblock); } diff --git a/minix/fs/ext2/mount.c b/minix/fs/ext2/mount.c index 3dca64bd9..24f6a5984 100644 --- a/minix/fs/ext2/mount.c +++ b/minix/fs/ext2/mount.c @@ -149,7 +149,7 @@ int fs_readsuper() if (!readonly) { superblock->s_state = EXT2_ERROR_FS; superblock->s_mnt_count++; - superblock->s_mtime = clock_time(); + superblock->s_mtime = clock_time(NULL); write_super(superblock); /* Commit info, we just set above */ } @@ -234,7 +234,7 @@ int fs_unmount() put_inode(root_ip); if (!superblock->s_rd_only) { - superblock->s_wtime = clock_time(); + superblock->s_wtime = clock_time(NULL); superblock->s_state = EXT2_VALID_FS; write_super(superblock); /* Commit info, we just set above */ } diff --git a/minix/fs/ext2/proto.h b/minix/fs/ext2/proto.h index f7f890d52..868d8a9fe 100644 --- a/minix/fs/ext2/proto.h +++ b/minix/fs/ext2/proto.h @@ -95,7 +95,6 @@ struct group_desc* get_group_desc(unsigned int bnum); int fs_utime(void); /* utility.c */ -time_t clock_time(void); unsigned conv2(int norm, int w); long conv4(int norm, long x); void mfs_nul_f(const char *file, int line, const char *str, unsigned int len, diff --git a/minix/fs/ext2/utility.c b/minix/fs/ext2/utility.c index 915d14483..db1ba1580 100644 --- a/minix/fs/ext2/utility.c +++ b/minix/fs/ext2/utility.c @@ -51,28 +51,6 @@ long x; /* 32-bit long to be byte swapped */ } -/*===========================================================================* - * clock_time * - *===========================================================================*/ -time_t clock_time() -{ -/* This routine returns the time in seconds since 1.1.1970. MINIX is an - * astrophysically naive system that assumes the earth rotates at a constant - * rate and that such things as leap seconds do not exist. - */ - - register int k; - clock_t uptime; - clock_t realtime; - time_t boottime; - - if ( (k=getuptime(&uptime, &realtime, &boottime)) != OK) - panic("clock_time: getuptme2 failed: %d", k); - - return( (time_t) (boottime + (realtime/sys_hz()))); -} - - /*===========================================================================* * mfs_min * *===========================================================================*/ diff --git a/minix/fs/mfs/inode.c b/minix/fs/mfs/inode.c index 3cabfe749..95a05e535 100644 --- a/minix/fs/mfs/inode.c +++ b/minix/fs/mfs/inode.c @@ -369,7 +369,7 @@ register struct inode *rip; /* pointer to inode to be read/written */ sp = rip->i_sp; /* get pointer to super block. */ if (sp->s_rd_only) return; /* no updates for read-only file systems */ - cur_time = clock_time(); + cur_time = clock_time(NULL); if (rip->i_update & ATIME) rip->i_atime = cur_time; if (rip->i_update & CTIME) rip->i_ctime = cur_time; if (rip->i_update & MTIME) rip->i_mtime = cur_time; diff --git a/minix/fs/mfs/proto.h b/minix/fs/mfs/proto.h index 6d9557692..3b16c3088 100644 --- a/minix/fs/mfs/proto.h +++ b/minix/fs/mfs/proto.h @@ -98,7 +98,6 @@ bit_t count_free_bits(struct super_block *sp, int map); int fs_utime(void); /* utility.c */ -time_t clock_time(void); unsigned conv2(int norm, int w); long conv4(int norm, long x); void mfs_nul_f(char *file, int line, char *str, unsigned int len, diff --git a/minix/fs/mfs/utility.c b/minix/fs/mfs/utility.c index 8a521f7f8..31b68f989 100644 --- a/minix/fs/mfs/utility.c +++ b/minix/fs/mfs/utility.c @@ -47,28 +47,6 @@ long x; /* 32-bit long to be byte swapped */ } -/*===========================================================================* - * clock_time * - *===========================================================================*/ -time_t clock_time() -{ -/* This routine returns the time in seconds since 1.1.1970. MINIX is an - * astrophysically naive system that assumes the earth rotates at a constant - * rate and that such things as leap seconds do not exist. - */ - - register int k; - clock_t uptime; - clock_t realtime; - time_t boottime; - - if ( (k=getuptime(&uptime, &realtime, &boottime)) != OK) - panic("clock_time: getuptme2 failed: %d", k); - - return( (time_t) (boottime + (realtime/sys_hz()))); -} - - /*===========================================================================* * mfs_min * *===========================================================================*/ diff --git a/minix/fs/pfs/inode.c b/minix/fs/pfs/inode.c index e988cd8dc..442f824dc 100644 --- a/minix/fs/pfs/inode.c +++ b/minix/fs/pfs/inode.c @@ -329,7 +329,7 @@ struct inode *rip; /* pointer to inode to be read/written */ time_t cur_time; - cur_time = clock_time(); + cur_time = clock_time(NULL); if (rip->i_update & ATIME) rip->i_atime = cur_time; if (rip->i_update & CTIME) rip->i_ctime = cur_time; if (rip->i_update & MTIME) rip->i_mtime = cur_time; diff --git a/minix/fs/pfs/proto.h b/minix/fs/pfs/proto.h index d19151f0b..6a5bc90d5 100644 --- a/minix/fs/pfs/proto.h +++ b/minix/fs/pfs/proto.h @@ -47,7 +47,6 @@ int fs_newnode(message *fs_m_in, message *fs_m_out); int fs_readwrite(message *fs_m_in, message *fs_m_out); /* utility.c */ -time_t clock_time(void); int no_sys(message *pfs_m_in, message *pfs_m_out); /* stadir.c */ diff --git a/minix/fs/pfs/utility.c b/minix/fs/pfs/utility.c index 4109d83d0..468f46d9e 100644 --- a/minix/fs/pfs/utility.c +++ b/minix/fs/pfs/utility.c @@ -10,25 +10,3 @@ int no_sys(message *pfs_m_in, message *pfs_m_out) printf("no_sys: invalid call 0x%x to pfs\n", pfs_m_in->m_type); return(EINVAL); } - - -/*===========================================================================* - * clock_time * - *===========================================================================*/ -time_t clock_time() -{ -/* This routine returns the time in seconds since 1.1.1970. MINIX is an - * astrophysically naive system that assumes the earth rotates at a constant - * rate and that such things as leap seconds do not exist. - */ - - int r; - clock_t uptime; /* Uptime in ticks */ - clock_t realtime; - time_t boottime; - - if ((r = getuptime(&uptime, &realtime, &boottime)) != OK) - panic("clock_time: getuptme2 failed: %d", r); - - return( (time_t) (boottime + (realtime/sys_hz()))); -} diff --git a/minix/include/minix/sysutil.h b/minix/include/minix/sysutil.h index f0741382d..81a3c4492 100644 --- a/minix/include/minix/sysutil.h +++ b/minix/include/minix/sysutil.h @@ -46,6 +46,8 @@ int env_parse(const char *env, const char *fmt, int field, #define fkey_events(fkeys, sfkeys) fkey_ctl(FKEY_EVENTS, (fkeys), (sfkeys)) int fkey_ctl(int req, int *fkeys, int *sfkeys); +struct timespec; + int printf(const char *fmt, ...); void kputc(int c); __dead void panic(const char *fmt, ...) @@ -64,6 +66,7 @@ u32_t tsc_64_to_micros(u64_t tsc); u32_t tsc_to_micros(u32_t low, u32_t high); u32_t tsc_get_khz(void); u32_t micros_to_ticks(u32_t micros); +time_t clock_time(struct timespec *tv); #if defined(__arm__) void read_frclock(u32_t *frclk); u32_t delta_frclock(u32_t base, u32_t cur); diff --git a/minix/lib/libsys/Makefile b/minix/lib/libsys/Makefile index e926f6906..ea3bb9752 100644 --- a/minix/lib/libsys/Makefile +++ b/minix/lib/libsys/Makefile @@ -17,6 +17,7 @@ SRCS+= \ assert.c \ asynsend.c \ checkperms.c \ + clock_time.c \ copyfd.c \ ds.c \ env_get_prm.c \ diff --git a/minix/lib/libsys/clock_time.c b/minix/lib/libsys/clock_time.c new file mode 100644 index 000000000..2bea82f96 --- /dev/null +++ b/minix/lib/libsys/clock_time.c @@ -0,0 +1,42 @@ + +#include "sysutil.h" +#include + +/* + * This routine returns the time in seconds since 1.1.1970. MINIX is an + * astrophysically naive system that assumes the earth rotates at a constant + * rate and that such things as leap seconds do not exist. If a non-NULL + * pointer to a timespec structure is given, that structure is filled with + * the current time in subsecond precision. + */ +time_t +clock_time(struct timespec *tv) +{ + uint32_t system_hz; + clock_t uptime, realtime; + time_t boottime, sec; + int r; + + if ((r = getuptime(&uptime, &realtime, &boottime)) != OK) + panic("clock_time: getuptime failed: %d", r); + + system_hz = sys_hz(); /* sys_hz() caches its return value */ + + sec = boottime + realtime / system_hz; + + if (tv != NULL) { + tv->tv_sec = sec; + + /* + * We do not want to overflow, and system_hz can be as high as + * 50kHz. + */ + if (system_hz < LONG_MAX / 40000) + tv->tv_nsec = (realtime % system_hz) * 40000 / + system_hz * 25000; + else + tv->tv_nsec = 0; /* bad, but what's better? */ + } + + return sec; +} diff --git a/minix/lib/libvtreefs/stadir.c b/minix/lib/libvtreefs/stadir.c index f29e3e6d1..6bb7a0a99 100644 --- a/minix/lib/libvtreefs/stadir.c +++ b/minix/lib/libvtreefs/stadir.c @@ -37,7 +37,7 @@ int fs_stat(ino_t ino_nr, struct stat *buf) } /* Take the current time as file time for all files. */ - cur_time = time(NULL); + cur_time = clock_time(NULL); buf->st_atime = cur_time; buf->st_mtime = cur_time; buf->st_ctime = cur_time; diff --git a/minix/servers/pm/time.c b/minix/servers/pm/time.c index c002ba671..d2f169081 100644 --- a/minix/servers/pm/time.c +++ b/minix/servers/pm/time.c @@ -89,21 +89,13 @@ int do_settime() *===========================================================================*/ int do_time() { -/* Perform the time(tp) system call. This returns the time in seconds since - * 1.1.1970. MINIX is an astrophysically naive system that assumes the earth - * rotates at a constant rate and that such things as leap seconds do not - * exist. - */ - clock_t ticks, realtime; - time_t boottime; - int s; +/* Perform the time(tp) system call. */ + struct timespec tv; - if ( (s=getuptime(&ticks, &realtime, &boottime)) != OK) - panic("do_time couldn't get uptime: %d", s); + (void)clock_time(&tv); - mp->mp_reply.m_pm_lc_time.sec = boottime + (realtime / system_hz); - mp->mp_reply.m_pm_lc_time.nsec = - (uint32_t) ((realtime % system_hz) * 1000000000ULL / system_hz); + mp->mp_reply.m_pm_lc_time.sec = tv.tv_sec; + mp->mp_reply.m_pm_lc_time.nsec = tv.tv_nsec; return(OK); } diff --git a/minix/servers/vfs/proto.h b/minix/servers/vfs/proto.h index 051a807b6..62f622508 100644 --- a/minix/servers/vfs/proto.h +++ b/minix/servers/vfs/proto.h @@ -275,7 +275,6 @@ int tll_unlock(tll_t *tllp); void tll_upgrade(tll_t *tllp); /* utility.c */ -struct timespec clock_timespec(void); int copy_path(char *dest, size_t size); int fetch_name(vir_bytes path, size_t len, char *dest); int isokendpt_f(const char *f, int l, endpoint_t e, int *p, int ft); diff --git a/minix/servers/vfs/time.c b/minix/servers/vfs/time.c index 1f890d213..9017bbd73 100644 --- a/minix/servers/vfs/time.c +++ b/minix/servers/vfs/time.c @@ -98,7 +98,7 @@ int do_utimens(void) || actim.tv_nsec == UTIME_OMIT || modtim.tv_nsec == UTIME_NOW || modtim.tv_nsec == UTIME_OMIT) { - now = clock_timespec(); + (void)clock_time(&now); } /* Build the request */ diff --git a/minix/servers/vfs/utility.c b/minix/servers/vfs/utility.c index ce531096f..f68bf38be 100644 --- a/minix/servers/vfs/utility.c +++ b/minix/servers/vfs/utility.c @@ -1,7 +1,6 @@ /* This file contains a few general purpose utility routines. * * The entry points into this file are - * clock_timespec: ask the clock task for the real time * copy_path: copy a path name from a path request from userland * fetch_name: go get a path name from user space * panic: something awful has occurred; MINIX cannot continue @@ -123,34 +122,6 @@ int isokendpt_f(const char *file, int line, endpoint_t endpoint, int *proc, return(failed ? EDEADEPT : OK); } - -/*===========================================================================* - * clock_timespec * - *===========================================================================*/ -struct timespec clock_timespec(void) -{ -/* This routine returns the time in seconds since 1.1.1970. MINIX is an - * astrophysically naive system that assumes the earth rotates at a constant - * rate and that such things as leap seconds do not exist. - */ - - register int r; - struct timespec tv; - clock_t uptime; - clock_t realtime; - time_t boottime; - - r = getuptime(&uptime, &realtime, &boottime); - if (r != OK) - panic("clock_timespec err: %d", r); - - tv.tv_sec = boottime + (realtime/system_hz); - /* We do not want to overflow, and system_hz can be as high as 50kHz */ - assert(system_hz < LONG_MAX/40000); - tv.tv_nsec = (realtime%system_hz) * 40000 / system_hz * 25000; - return tv; -} - /*===========================================================================* * in_group * *===========================================================================*/