summaryrefslogtreecommitdiff
path: root/src/port
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2022-07-24 09:21:57 +1200
committerThomas Munro <tmunro@postgresql.org>2022-07-24 09:29:48 +1200
commit86e5eb4f58a276870fbd29e3711b36e4a4280979 (patch)
tree1be63aedf830585e9385e60a5a6e3e854da676b7 /src/port
parentb431dc5c3d7207ffb56b6045eb04265a53f63a03 (diff)
downloadpostgresql-86e5eb4f58a276870fbd29e3711b36e4a4280979.tar.gz
Remove dead getrusage replacement code.
getrusage() is in SUSv2 and all targeted Unix systems have it. Note that POSIX only covers ru_utime and ru_stime and we rely on many more fields without any kind of configure probe, but that predates this commit. The only supported system we need replacement code for now is Windows, and that can be done without a configure probe. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Greg Stark <stark@mit.edu> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Discussion: https://postgr.es/m/CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
Diffstat (limited to 'src/port')
-rw-r--r--src/port/getrusage.c49
1 files changed, 3 insertions, 46 deletions
diff --git a/src/port/getrusage.c b/src/port/getrusage.c
index 02665f4032..2ba59ade2c 100644
--- a/src/port/getrusage.c
+++ b/src/port/getrusage.c
@@ -17,19 +17,14 @@
#include "rusagestub.h"
-/* This code works on:
- * solaris_i386
- * solaris_sparc
- * win32
- * which currently is all the supported platforms that don't have a
- * native version of getrusage(). So, if configure decides to compile
- * this file at all, we just use this version unconditionally.
+/*
+ * This code works on Windows, which is the only supported platform without a
+ * native version of getrusage().
*/
int
getrusage(int who, struct rusage *rusage)
{
-#ifdef WIN32
FILETIME starttime;
FILETIME exittime;
FILETIME kerneltime;
@@ -66,44 +61,6 @@ getrusage(int who, struct rusage *rusage)
li.QuadPart /= 10L; /* Convert to microseconds */
rusage->ru_utime.tv_sec = li.QuadPart / 1000000L;
rusage->ru_utime.tv_usec = li.QuadPart % 1000000L;
-#else /* all but WIN32 */
-
- struct tms tms;
- int tick_rate = CLK_TCK; /* ticks per second */
- clock_t u,
- s;
-
- if (rusage == (struct rusage *) NULL)
- {
- errno = EFAULT;
- return -1;
- }
- if (times(&tms) < 0)
- {
- /* errno set by times */
- return -1;
- }
- switch (who)
- {
- case RUSAGE_SELF:
- u = tms.tms_utime;
- s = tms.tms_stime;
- break;
- case RUSAGE_CHILDREN:
- u = tms.tms_cutime;
- s = tms.tms_cstime;
- break;
- default:
- errno = EINVAL;
- return -1;
- }
-#define TICK_TO_SEC(T, RATE) ((T)/(RATE))
-#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE)
- rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate);
- rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate);
- rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate);
- rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate);
-#endif /* WIN32 */
return 0;
}