From 8ab0bca0c6066dbf723c65e8bcd6837a3267a77d Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 16 Mar 2011 07:16:21 +0100 Subject: [PATCH 1/1] Provide a getrusage() stub for Windows --- src/lib/w32/getrusage.c | 51 ++++++++++++++++++++++++++++++++++++++ src/lib/w32/sys/resource.h | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 src/lib/w32/getrusage.c create mode 100644 src/lib/w32/sys/resource.h diff --git a/src/lib/w32/getrusage.c b/src/lib/w32/getrusage.c new file mode 100644 index 000000000..1733f2fbe --- /dev/null +++ b/src/lib/w32/getrusage.c @@ -0,0 +1,51 @@ +/* + * Empire - A multi-player, client/server Internet based war game. + * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak, + * Ken Stevens, Steve McClure + * + * This program 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; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * --- + * + * See files README, COPYING and CREDITS in the root of the source + * tree for related information and legal notices. It is expected + * that future projects/authors will amend these files as needed. + * + * --- + * + * getrusage.c: POSIX getrusage() emulation for Windows + * + * Known contributors to this file: + * Markus Armbruster, 2011 + */ + +#include + +#include +#include "sys/resource.h" + +int +getrusage(int who, struct rusage *rus) +{ + if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN) { + errno = EINVAL; + return -1; + } + + /* FIXME stub */ + rus->ru_utime.tv_sec = rus->ru_utime.tv_usec = 0; + rus->ru_stime.tv_sec = rus->ru_stime.tv_usec = 0; + return 0; +} diff --git a/src/lib/w32/sys/resource.h b/src/lib/w32/sys/resource.h new file mode 100644 index 000000000..85a159857 --- /dev/null +++ b/src/lib/w32/sys/resource.h @@ -0,0 +1,49 @@ +/* + * Empire - A multi-player, client/server Internet based war game. + * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak, + * Ken Stevens, Steve McClure + * + * This program 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; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * --- + * + * See files README, COPYING and CREDITS in the root of the source + * tree for related information and legal notices. It is expected + * that future projects/authors will amend these files as needed. + * + * --- + * + * sys/resource.h: POSIX resource emulation for WIN32 + * + * Known contributors to this file: + * Markus Armbruster, 2011 + */ + +#ifndef SYS_RESOURCE_H +#define SYS_RESOURCE_H + +#include "sys/time.h" + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN 1 + +struct rusage { + struct timeval ru_utime; + struct timeval ru_stime; +}; + +extern int getrusage(int, struct rusage *); + +#endif /* SYS_RESOURCE_H */ -- 2.43.0