kernel: move nsec to libc
This commit is contained in:
parent
2508de40ea
commit
4676c65a3d
|
@ -27,9 +27,9 @@ main(void)
|
|||
uint64_t start, end;
|
||||
char *msg;
|
||||
|
||||
start = sys_nsec();
|
||||
start = sys_remove("#c/time");
|
||||
sleep(1);
|
||||
end = sys_nsec();
|
||||
end = sys_remove("#c/time");
|
||||
|
||||
if (end <= start)
|
||||
ret = 1;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015 Giacomo Tesio <giacomo@tesio.it>
|
||||
* Copyright (C) 2015-2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* This file is part of the UCB release of Plan 9. It is subject to the license
|
||||
* terms in the LICENSE file found in the top-level directory of this
|
||||
|
@ -396,6 +396,7 @@ extern void longjmp(jmp_buf, int);
|
|||
extern char* mktemp(char*);
|
||||
extern double modf(double, double*);
|
||||
extern void notejmp(void*, jmp_buf, int);
|
||||
extern unsigned long nsec(void);
|
||||
extern int dup(int oldfd, int newfd);
|
||||
extern int ocreate(const char* path, unsigned int omode, unsigned int perm);
|
||||
extern void perror(const char*);
|
||||
|
|
|
@ -1039,6 +1039,17 @@ consread(Chan *c, void *buf, long n, int64_t off)
|
|||
return -1; /* never reached */
|
||||
}
|
||||
|
||||
static void
|
||||
consremove(Chan* c)
|
||||
{
|
||||
switch((uint32_t)c->qid.path){
|
||||
default:
|
||||
error(Eperm);
|
||||
case Qtime:
|
||||
errorl("fugit irreparabile tempus", todget(nil));
|
||||
}
|
||||
}
|
||||
|
||||
static long
|
||||
conswrite(Chan *c, void *va, long n, int64_t off)
|
||||
{
|
||||
|
@ -1198,7 +1209,7 @@ Dev consdevtab = {
|
|||
devbread,
|
||||
conswrite,
|
||||
devbwrite,
|
||||
devremove,
|
||||
consremove,
|
||||
devwstat,
|
||||
};
|
||||
|
||||
|
|
|
@ -1163,9 +1163,3 @@ syssemrelease(int* addr, int delta)
|
|||
|
||||
return semrelease(s, addr, delta);
|
||||
}
|
||||
|
||||
long
|
||||
sysnsec(void)
|
||||
{
|
||||
return todget(nil);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* This file is part of Jehanne.
|
||||
*
|
||||
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
|
||||
*
|
||||
* Jehanne is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 2 of the License.
|
||||
*
|
||||
* Jehanne is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#define PORTABLE_SYSCALLS
|
||||
#include <u.h>
|
||||
#include <libc.h>
|
||||
|
||||
unsigned long
|
||||
nsec(void)
|
||||
{
|
||||
long r;
|
||||
r = remove("/dev/time");
|
||||
if(r == -1)
|
||||
r = remove("#c/time");
|
||||
return r;
|
||||
}
|
|
@ -59,6 +59,7 @@
|
|||
"9sys/getppid.c",
|
||||
"9sys/getwd.c",
|
||||
"9sys/iounit.c",
|
||||
"9sys/nsec.c",
|
||||
"9sys/nulldir.c",
|
||||
"9sys/ocreate.c",
|
||||
"9sys/pipe.c",
|
||||
|
|
|
@ -202,19 +202,12 @@
|
|||
"int"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 16,
|
||||
"Name": "nsec",
|
||||
"Ret": [
|
||||
"long"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Args": [
|
||||
"const char*",
|
||||
"uint32_t"
|
||||
],
|
||||
"Id": 17,
|
||||
"Id": 16,
|
||||
"Name": "open",
|
||||
"Ret": [
|
||||
"long"
|
||||
|
@ -227,7 +220,7 @@
|
|||
"long",
|
||||
"long"
|
||||
],
|
||||
"Id": 18,
|
||||
"Id": 17,
|
||||
"Name": "pread",
|
||||
"Ret": [
|
||||
"long"
|
||||
|
@ -240,7 +233,7 @@
|
|||
"long",
|
||||
"long"
|
||||
],
|
||||
"Id": 19,
|
||||
"Id": 18,
|
||||
"Name": "pwrite",
|
||||
"Ret": [
|
||||
"long"
|
||||
|
@ -250,7 +243,7 @@
|
|||
"Args": [
|
||||
"const char*"
|
||||
],
|
||||
"Id": 20,
|
||||
"Id": 19,
|
||||
"Name": "remove",
|
||||
"Ret": [
|
||||
"long"
|
||||
|
@ -261,7 +254,7 @@
|
|||
"const void*",
|
||||
"void*"
|
||||
],
|
||||
"Id": 21,
|
||||
"Id": 20,
|
||||
"Name": "rendezvous",
|
||||
"Ret": [
|
||||
"void*"
|
||||
|
@ -271,7 +264,7 @@
|
|||
"Args": [
|
||||
"uint32_t"
|
||||
],
|
||||
"Id": 22,
|
||||
"Id": 21,
|
||||
"Name": "rfork",
|
||||
"Ret": [
|
||||
"int"
|
||||
|
@ -283,7 +276,7 @@
|
|||
"long",
|
||||
"int"
|
||||
],
|
||||
"Id": 23,
|
||||
"Id": 22,
|
||||
"Name": "seek",
|
||||
"Ret": [
|
||||
"long"
|
||||
|
@ -294,7 +287,7 @@
|
|||
"int*",
|
||||
"int"
|
||||
],
|
||||
"Id": 24,
|
||||
"Id": 23,
|
||||
"Name": "semacquire",
|
||||
"Ret": [
|
||||
"int"
|
||||
|
@ -305,7 +298,7 @@
|
|||
"int*",
|
||||
"int"
|
||||
],
|
||||
"Id": 25,
|
||||
"Id": 24,
|
||||
"Name": "semrelease",
|
||||
"Ret": [
|
||||
"int"
|
||||
|
@ -316,7 +309,7 @@
|
|||
"int*",
|
||||
"uint64_t"
|
||||
],
|
||||
"Id": 26,
|
||||
"Id": 25,
|
||||
"Name": "tsemacquire",
|
||||
"Ret": [
|
||||
"int"
|
||||
|
@ -327,7 +320,7 @@
|
|||
"const char*",
|
||||
"const char*"
|
||||
],
|
||||
"Id": 27,
|
||||
"Id": 26,
|
||||
"Name": "unmount",
|
||||
"Ret": [
|
||||
"int"
|
||||
|
@ -337,7 +330,7 @@
|
|||
"Args": [
|
||||
"unsigned long"
|
||||
],
|
||||
"Id": 28,
|
||||
"Id": 27,
|
||||
"Name": "alarm",
|
||||
"Ret": [
|
||||
"long"
|
||||
|
|
Loading…
Reference in New Issue