]> xenbits.xensource.com Git - people/liuw/rumprun.git/commitdiff
Make getrusage() a non-stub. It's still fictional, though.
authorAntti Kantee <pooka@iki.fi>
Thu, 23 Apr 2015 16:14:03 +0000 (16:14 +0000)
committerAntti Kantee <pooka@iki.fi>
Thu, 23 Apr 2015 16:14:03 +0000 (16:14 +0000)
It still returns ENOTSUP, since the NetBSD clock bits that enable times()
to work have not yet been pulled up to src-netbsd.  I'm pushing this
now to allow for easy testing of times() with NetBSD HEAD.

lib/librumprun_base/libc_stubs.c
lib/librumprun_base/syscall_misc.c

index 524107f26a07d3fa9d1344f778944a4172d32a1f..0c133ca35e93ecd77c4316f7b0f48699445ad66f 100644 (file)
@@ -55,8 +55,6 @@ STUB_SILENT_IGNORE(__sigaction_sigtramp);
 
 STUB_RETURN(posix_spawn);
 
-STUB_ERRNO(__getrusage50);
-
 STUB_ERRNO(__fork);
 STUB_ERRNO(__vfork14);
 STUB_ERRNO(kill);
index 34f741e3372af8613fbdfa5dff27fddfadcd89e0..4fe5f18817f7773c9d91a163734fac316324f197 100644 (file)
@@ -34,6 +34,8 @@
 
 #include <sys/cdefs.h>
 #include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/time.h>
 
 #include <errno.h>
 #include <fcntl.h>
@@ -42,6 +44,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <time.h>
 #include <unistd.h>
 
@@ -159,3 +162,30 @@ ____sigtimedwait50(const sigset_t *set, siginfo_t *info,
 
        return -1;
 }
+
+/* XXX: manual proto.  plug into libc internals some other day */
+int __getrusage50(int, struct rusage *);
+int
+__getrusage50(int who, struct rusage *usage)
+{
+
+       /* We fake something.  We should query the scheduler some day */
+       memset(usage, 0, sizeof(*usage));
+       if (who == RUSAGE_SELF) {
+               usage->ru_utime.tv_sec = 1;
+               usage->ru_utime.tv_usec = 1;
+               usage->ru_stime.tv_sec = 1;
+               usage->ru_stime.tv_usec = 1;
+       }
+
+       usage->ru_maxrss = 1024;
+       usage->ru_ixrss = 1024;
+       usage->ru_idrss = 1024;
+       usage->ru_isrss = 1024;
+
+       usage->ru_nvcsw = 1;
+       usage->ru_nivcsw = 1;
+
+       /* XXX: wrong in many ways */
+       return ENOTSUP;
+}