aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2022-08-13 23:35:24 +1200
committerThomas Munro <tmunro@postgresql.org>2022-08-14 00:09:47 +1200
commit36b3d52459aecd4f8bc39a4604e42186c48aa9d2 (patch)
tree15a7b1211cac9a9fcb193e3eb4984cbe73cb1b8a /src/include
parent37a65d1db14658bc75faa3aea7bd5a064118d135 (diff)
downloadpostgresql-36b3d52459aecd4f8bc39a4604e42186c48aa9d2.tar.gz
postgresql-36b3d52459aecd4f8bc39a4604e42186c48aa9d2.zip
Remove configure probe for sys/resource.h and refactor.
<sys/resource.h> is in SUSv2 and is on all targeted Unix systems. We have a replacement for getrusage() on Windows, so let's just move its declarations into src/include/port/win32/sys/resource.h so that we can use a standard-looking #include. Also remove an obsolete reference to CLK_TCK. Also rename src/port/getrusage.c to win32getrusage.c, following the convention for Windows-only fallback code. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CA%2BhUKG%2BL_3brvh%3D8e0BW_VfX9h7MtwgN%3DnFHP5o7X2oZucY9dg%40mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/pg_config.h.in3
-rw-r--r--src/include/port/win32/sys/resource.h20
-rw-r--r--src/include/rusagestub.h31
-rw-r--r--src/include/utils/pg_rusage.h7
4 files changed, 21 insertions, 40 deletions
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 5f96f71896d..45faf051219 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -505,9 +505,6 @@
/* Define to 1 if you have the <sys/procctl.h> header file. */
#undef HAVE_SYS_PROCCTL_H
-/* Define to 1 if you have the <sys/resource.h> header file. */
-#undef HAVE_SYS_RESOURCE_H
-
/* Define to 1 if you have the <sys/signalfd.h> header file. */
#undef HAVE_SYS_SIGNALFD_H
diff --git a/src/include/port/win32/sys/resource.h b/src/include/port/win32/sys/resource.h
new file mode 100644
index 00000000000..a14feeb5844
--- /dev/null
+++ b/src/include/port/win32/sys/resource.h
@@ -0,0 +1,20 @@
+/*
+ * Replacement for <sys/resource.h> for Windows.
+ */
+#ifndef WIN32_SYS_RESOURCE_H
+#define WIN32_SYS_RESOURCE_H
+
+#include <sys/time.h> /* for struct timeval */
+
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN (-1)
+
+struct rusage
+{
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+};
+
+extern int getrusage(int who, struct rusage *rusage);
+
+#endif /* WIN32_SYS_RESOURCE_H */
diff --git a/src/include/rusagestub.h b/src/include/rusagestub.h
deleted file mode 100644
index be26f849a59..00000000000
--- a/src/include/rusagestub.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * rusagestub.h
- * Stubs for getrusage(3).
- *
- *
- * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * src/include/rusagestub.h
- *
- *-------------------------------------------------------------------------
- */
-#ifndef RUSAGESTUB_H
-#define RUSAGESTUB_H
-
-#include <sys/time.h> /* for struct timeval */
-#include <limits.h> /* for CLK_TCK */
-
-#define RUSAGE_SELF 0
-#define RUSAGE_CHILDREN (-1)
-
-struct rusage
-{
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
-};
-
-extern int getrusage(int who, struct rusage *rusage);
-
-#endif /* RUSAGESTUB_H */
diff --git a/src/include/utils/pg_rusage.h b/src/include/utils/pg_rusage.h
index a6344abd107..b2c4d36ced8 100644
--- a/src/include/utils/pg_rusage.h
+++ b/src/include/utils/pg_rusage.h
@@ -14,13 +14,8 @@
#ifndef PG_RUSAGE_H
#define PG_RUSAGE_H
-#include <sys/time.h>
-
-#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
-#else
-#include "rusagestub.h"
-#endif
+#include <sys/time.h>
/* State structure for pg_rusage_init/pg_rusage_show */