Commit 854d9b17 authored by Jonas Termansen's avatar Jonas Termansen

uptime(2) now reports usecs instead of msecs.

parent 597e7006
......@@ -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 */ }
......
......@@ -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++; }
......
......@@ -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
......
......@@ -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);
}
}
}
......@@ -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;
}
......
#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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment