jehanne: add sys/resource.h and getrusage
This commit is contained in:
parent
ed6683643a
commit
08c85f7606
|
@ -5,7 +5,7 @@ AM_CCASFLAGS = $(INCLUDES)
|
|||
noinst_LIBRARIES = lib.a
|
||||
|
||||
if MAY_SUPPLY_SYSCALLS
|
||||
extra_objs = syscalls.o libposix_conf.o chown.o
|
||||
extra_objs = syscalls.o libposix_conf.o chown.o getrusage.o
|
||||
else
|
||||
extra_objs =
|
||||
endif
|
||||
|
@ -14,7 +14,7 @@ lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
|||
calloc.c callocr.c realloc.c reallocr.c
|
||||
|
||||
lib_a_LIBADD = $(extra_objs)
|
||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c
|
||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c
|
||||
lib_a_DEPENDENCIES = $(extra_objs)
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
|
|
|
@ -52,7 +52,7 @@ LIBRARIES = $(noinst_LIBRARIES)
|
|||
ARFLAGS = cru
|
||||
lib_a_AR = $(AR) $(ARFLAGS)
|
||||
@MAY_SUPPLY_SYSCALLS_TRUE@am__DEPENDENCIES_1 = syscalls.o \
|
||||
@MAY_SUPPLY_SYSCALLS_TRUE@ libposix_conf.o chown.o
|
||||
@MAY_SUPPLY_SYSCALLS_TRUE@ libposix_conf.o chown.o getrusage.o
|
||||
am_lib_a_OBJECTS = lib_a-getenv_r.$(OBJEXT) lib_a-getenv.$(OBJEXT) \
|
||||
lib_a-malloc.$(OBJEXT) lib_a-mallocr.$(OBJEXT) \
|
||||
lib_a-free.$(OBJEXT) lib_a-freer.$(OBJEXT) \
|
||||
|
@ -177,12 +177,12 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
|
|||
AM_CCASFLAGS = $(INCLUDES)
|
||||
noinst_LIBRARIES = lib.a
|
||||
@MAY_SUPPLY_SYSCALLS_FALSE@extra_objs =
|
||||
@MAY_SUPPLY_SYSCALLS_TRUE@extra_objs = syscalls.o libposix_conf.o chown.o
|
||||
@MAY_SUPPLY_SYSCALLS_TRUE@extra_objs = syscalls.o libposix_conf.o chown.o getrusage.o
|
||||
lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
|
||||
calloc.c callocr.c realloc.c reallocr.c
|
||||
|
||||
lib_a_LIBADD = $(extra_objs)
|
||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c
|
||||
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c
|
||||
lib_a_DEPENDENCIES = $(extra_objs)
|
||||
lib_a_CCASFLAGS = $(AM_CCASFLAGS)
|
||||
lib_a_CFLAGS = $(AM_CFLAGS)
|
||||
|
@ -328,6 +328,12 @@ lib_a-chown.o: chown.c
|
|||
lib_a-chown.obj: chown.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-chown.obj `if test -f 'chown.c'; then $(CYGPATH_W) 'chown.c'; else $(CYGPATH_W) '$(srcdir)/chown.c'; fi`
|
||||
|
||||
lib_a-getrusage.o: getrusage.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getrusage.o `test -f 'getrusage.c' || echo '$(srcdir)/'`getrusage.c
|
||||
|
||||
lib_a-getrusage.obj: getrusage.c
|
||||
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getrusage.obj `if test -f 'getrusage.c'; then $(CYGPATH_W) 'getrusage.c'; else $(CYGPATH_W) '$(srcdir)/getrusage.c'; fi`
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include <posix.h>
|
||||
#include <reent.h>
|
||||
|
||||
int
|
||||
getrusage(int who, struct rusage *r_usage)
|
||||
{
|
||||
PosixRUsages u;
|
||||
int *errnop = &_REENT->_errno;
|
||||
switch(who){
|
||||
case 0:
|
||||
u = PosixRUsageSelf;
|
||||
break;
|
||||
case 1:
|
||||
u = PosixRUsageChildren;
|
||||
break;
|
||||
default:
|
||||
u = PosixRUsageUnknown;
|
||||
break;
|
||||
}
|
||||
return POSIX_getrusage(errnop, u, r_usage);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _SYS_RESOURCE_H_
|
||||
#define _SYS_RESOURCE_H_
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#define RUSAGE_SELF 0 /* calling process */
|
||||
#define RUSAGE_CHILDREN 1 /* terminated child processes */
|
||||
|
||||
struct rusage {
|
||||
struct timeval ru_utime; /* user time used */
|
||||
struct timeval ru_stime; /* system time used */
|
||||
};
|
||||
|
||||
extern int getrusage(int, struct rusage *);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue