uptime(2) now reports usecs instead of msecs.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-12-04 21:27:21 +01:00
parent 597e700618
commit 854d9b171a
6 changed files with 16 additions and 16 deletions

View File

@ -11,7 +11,7 @@ int main(int argc, char* argv[])
uintmax_t start;
if ( uptime(&start) ) { perror("uptime"); return 1; }
uintmax_t end = start + 1ULL * 1000ULL; // 1 second
uintmax_t end = start + 1ULL * 1000ULL * 1000ULL; // 1 second
size_t count = 0;
uintmax_t now;
while ( !uptime(&now) && now < end ) { usleep(0); count += 2; /* back and forth */ }

View File

@ -5,7 +5,7 @@ int main(int argc, char* argv[])
{
uintmax_t start;
if ( uptime(&start) ) { perror("uptime"); return 1; }
uintmax_t end = start + 1ULL * 1000ULL; // 1 second
uintmax_t end = start + 1ULL * 1000ULL * 1000ULL; // 1 second
size_t count = 0;
uintmax_t now;
while ( !uptime(&now) && now < end ) { count++; }

View File

@ -177,7 +177,7 @@ ssize_t write(int, const void*, size_t);
#ifdef SORTIX_EXTENSIONS
int memstat(size_t* memused, size_t* memtotal);
int uptime(uintmax_t* mssinceboot);
int uptime(uintmax_t* usecssinceboot);
int writeall(int fd, const void* buffer, size_t len);
#endif

View File

@ -33,9 +33,9 @@ namespace Maxsi
{
DEFN_SYSCALL1(int, SysUptime, 34, uintmax_t*);
extern "C" int uptime(uintmax_t* mssinceboot)
extern "C" int uptime(uintmax_t* usecssinceboot)
{
return SysUptime(mssinceboot);
return SysUptime(usecssinceboot);
}
}
}

View File

@ -85,10 +85,10 @@ namespace Sortix
bool didUglyIRQ0Hack;
int SysUptime(uintmax_t* mssinceboot)
int SysUptime(uintmax_t* usecssinceboot)
{
// TODO: HACK!
*mssinceboot = ((size_t)microsecondssinceboot) / 1000;
// TODO: Validate that usecssinceboot is a valid user-space pointer.
*usecssinceboot = microsecondssinceboot;
return 0;
}

View File

@ -1,24 +1,24 @@
#include <stdio.h>
#include <unistd.h>
size_t Seconds(size_t ms)
size_t Seconds(uintmax_t usecs)
{
return (ms / 1000UL) % (60UL);
return (usecs / (1000ULL * 1000ULL)) % (60ULL);
}
size_t Minutes(size_t ms)
size_t Minutes(uintmax_t usecs)
{
return (ms / (1000UL * 60UL)) % (60UL);
return (usecs / (1000ULL * 1000ULL * 60ULL)) % (60ULL);
}
size_t Hours(size_t ms)
size_t Hours(uintmax_t usecs)
{
return (ms / (1000UL * 60UL * 60UL)) % (24UL);
return (usecs / (1000ULL * 1000ULL * 60ULL * 60ULL)) % (24ULL);
}
size_t Days(size_t ms)
size_t Days(uintmax_t usecs)
{
return (ms / (1000UL * 60UL * 60UL * 24UL)) % (24UL);
return usecs / (1000ULL * 1000ULL * 60ULL * 60ULL * 24ULL);
}
void PrintElement(size_t num, const char* single, const char* multiple)