Added several missing functions - some of them work, some of them don't.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8759 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-09-01 10:14:12 +00:00
parent 6eb80c55ea
commit 866a87e2b5
6 changed files with 166 additions and 7 deletions
+12 -7
View File
@@ -1,12 +1,17 @@
SubDir OBOS_TOP src kernel libroot posix sys ;
KernelMergeObject posix_sys.o :
<$(SOURCE_GRIST)>chmod.c
<$(SOURCE_GRIST)>stat.c
<$(SOURCE_GRIST)>mkdir.c
<$(SOURCE_GRIST)>select.c
<$(SOURCE_GRIST)>sysctl.c
<$(SOURCE_GRIST)>gettimeofday.c
<$(SOURCE_GRIST)>wait.c
chmod.c
getrusage.c
gettimeofday.c
itimer.c
mkdir.c
mkfifo.c
rlimit.c
select.c
stat.c
sysctl.c
umask.c
wait.c
: -fPIC -DPIC
;
+19
View File
@@ -0,0 +1,19 @@
/*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
#include <sys/resource.h>
#include <syscalls.h>
#include <errno.h>
int
getrusage(int who, struct rusage *rusage)
{
// ToDo: implement me!
errno = B_BAD_VALUE;
return -1;
}
+50
View File
@@ -0,0 +1,50 @@
/*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
#include <OS.h>
#include <sys/time.h>
#include <string.h>
#define USEC_PER_SECOND 1000000
int
getitimer(int which, struct itimerval *value)
{
// ToDo: implement me!
return -1;
}
int
setitimer(int which, const struct itimerval *value, struct itimerval *oldValue)
{
// ToDo: implement me properly!
// We probably need a better internal set_alarm() implementation to do this
bigtime_t interval = value->it_interval.tv_sec * USEC_PER_SECOND + value->it_interval.tv_usec;
if (interval != 0)
set_alarm(interval, B_PERIODIC_ALARM);
else {
bigtime_t timeout = value->it_value.tv_sec * USEC_PER_SECOND + value->it_value.tv_usec;
if (timeout != 0)
set_alarm(timeout, B_ONE_SHOT_RELATIVE_ALARM);
else {
// cancel alarm
set_alarm(B_INFINITE_TIMEOUT, B_PERIODIC_ALARM);
}
}
// whatever set_alarm() returns (not documented in the BeBook, and I haven't
// investigated this yet), maybe we can maintain the oldValue with it.
memset(oldValue, 0, sizeof(struct itimerval));
return 0;
}
+25
View File
@@ -0,0 +1,25 @@
/*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
#include <sys/stat.h>
#include <syscalls.h>
#include <errno.h>
#define RETURN_AND_SET_ERRNO(err) \
if (err < 0) { \
errno = err; \
return -1; \
} \
return err;
int
mkfifo(const char *path, mode_t mode)
{
// ToDo: implement me for real!
RETURN_AND_SET_ERRNO(B_BAD_VALUE);
}
+36
View File
@@ -0,0 +1,36 @@
/*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
#include <sys/resource.h>
#include <syscalls.h>
#include <errno.h>
#define RETURN_AND_SET_ERRNO(err) \
if (err < 0) { \
errno = err; \
return -1; \
} \
return err;
int
getrlimit(int resource, struct rlimit *rlimit)
{
int status = _kern_getrlimit(resource, rlimit);
RETURN_AND_SET_ERRNO(status);
}
int
setrlimit(int resource, const struct rlimit *rlimit)
{
int status = _kern_setrlimit(resource, rlimit);
RETURN_AND_SET_ERRNO(status);
}
+24
View File
@@ -0,0 +1,24 @@
/*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the Haiku License.
*/
#include <sys/stat.h>
#include <syscalls.h>
#include <errno.h>
mode_t __gUmask = 022;
// this must be made available to open() and friends
mode_t
umask(mode_t newMask)
{
mode_t oldMask = __gUmask;
__gUmask = newMask;
return oldMask;
}