8000 Remove configure probe for sys/resource.h and refactor. · postgrespro/postgres@36b3d52 · GitHub
[go: up one dir, main page]

Skip to content

Commit 36b3d52

Browse files
committed
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
1 parent 37a65d1 commit 36b3d52

File tree

16 files changed

+42
-89
lines changed

16 files changed

+42
-89
lines changed

configure

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13874,7 +13874,7 @@ $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h
1387413874
fi
1387513875

1387613876

13877-
for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h net/if.h netinet/tcp.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/resource.h sys/signalfd.h sys/sockio.h sys/ucred.h termios.h ucred.h
13877+
for ac_header in atomic.h copyfile.h execinfo.h getopt.h ifaddrs.h langinfo.h mbarrier.h net/if.h netinet/tcp.h sys/epoll.h sys/event.h sys/personality.h sys/prctl.h sys/procctl.h sys/signalfd.h sys/sockio.h sys/ucred.h termios.h ucred.h
1387813878
do :
1387913879
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
1388013880
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -16734,12 +16734,6 @@ done
1673416734
;;
1673516735
esac
1673616736

16737-
case " $LIBOBJS " in
16738-
*" getrusage.$ac_objext "* ) ;;
16739-
*) LIBOBJS="$LIBOBJS getrusage.$ac_objext"
16740-
;;
16741-
esac
16742-
1674316737
case " $LIBOBJS " in
1674416738
*" kill.$ac_objext "* ) ;;
1674516739
*) LIBOBJS="$LIBOBJS kill.$ac_objext"
@@ -16782,6 +16776,12 @@ esac
1678216776
;;
1678316777
esac
1678416778

16779+
case " $LIBOBJS " in
16780+
*" win32getrusage.$ac_objext "* ) ;;
16781+
*) LIBOBJS="$LIBOBJS win32getrusage.$ac_objext"
16782+
;;
16783+
esac
16784+
1678516785
case " $LIBOBJS " in
1678616786
*" win32link.$ac_objext "* ) ;;
1678716787
*) LIBOBJS="$LIBOBJS win32link.$ac_objext"

configure.ac

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,6 @@ AC_CHECK_HEADERS(m4_normalize([
14591459
sys/personality.h
14601460
sys/prctl.h
14611461
sys/procctl.h
1462-
sys/resource.h
14631462
sys/signalfd.h
14641463
sys/sockio.h
14651464
sys/ucred.h
@@ -1897,14 +1896,14 @@ fi
18971896
if test "$PORTNAME" = "win32"; then
18981897
AC_CHECK_FUNCS(_configthreadlocale)
18991898
AC_LIBOBJ(dirmod)
1900-
AC_LIBOBJ(getrusage)
19011899
AC_LIBOBJ(kill)
19021900
AC_LIBOBJ(open)
19031901
AC_LIBOBJ(system)
19041902
AC_LIBOBJ(win32dlopen)
19051903
AC_LIBOBJ(win32env)
19061904
AC_LIBOBJ(win32error)
19071905
AC_LIBOBJ(win32fdatasync)
1906+
AC_LIBOBJ(win32getrusage)
19081907
AC_LIBOBJ(win32link)
19091908
AC_LIBOBJ(win32ntdll)
19101909
AC_LIBOBJ(win32pread)

src/backend/storage/file/fd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#include <dirent.h>
7676
#include <sys/file.h>
7777
#include <sys/param.h>
78+
#include <sys/resource.h> /* for getrlimit */
7879
#include <sys/stat.h>
7980
#include <sys/types.h>
8081
#ifndef WIN32
@@ -83,9 +84,6 @@
8384
#include <limits.h>
8485
#include <unistd.h>
8586
#include <fcntl.h>
86-
#ifdef HAVE_SYS_RESOURCE_H
87-
#include <sys/resource.h> /* for getrlimit */
88-
#endif
8987

9088
#include "access/xact.h"
9189
#include "access/xlog.h"

src/backend/tcop/postgres.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,10 @@
2323
#include <limits.h>
2424
#include <signal.h>
2525
#include <unistd.h>
26+
#include <sys/resource.h>
2627
#include <sys/select.h>
2728
#include <sys/socket.h>
28-
#ifdef HAVE_SYS_RESOURCE_H
2929
#include <sys/time.h>
30-
#include <sys/resource.h>
31-
#endif
32-
33-
#ifdef WIN32
34-
#include "rusagestub.h"
35-
#endif
3630

3731
#include "access/parallel.h"
3832
#include "access/printtup.h"
@@ -4860,7 +4854,7 @@ ShowUsage(const char *title)
48604854
* The following rusage fields are not defined by POSIX, but they're
48614855
* present on all current Unix-like systems so we use them without any
48624856
* special checks. Some of these could be provided in our Windows
4863-
* emulation in src/port/getrusage.c with more work.
4857+
* emulation in src/port/win32getrusage.c with more work.
48644858
*/
48654859
appendStringInfo(&str,
48664860
"!\t%ld kB max resident size\n",

src/bin/pg_ctl/pg_ctl.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
#include <fcntl.h>
1515
#include <signal.h>
1616
#include <time.h>
17+
#include <sys/resource.h>
1718
#include <sys/stat.h>
19+
#include <sys/time.h>
1820
#include <sys/wait.h>
1921
#include <unistd.h>
2022

21-
#ifdef HAVE_SYS_RESOURCE_H
22-
#include <sys/time.h>
23-
#include <sys/resource.h>
24-
#endif
2523

2624
#include "catalog/pg_control.h"
2725
#include "common/controldata_utils.h"

src/bin/pgbench/pgbench.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
#include <signal.h>
4141
#include <time.h>
4242
#include <sys/time.h>
43-
#ifdef HAVE_SYS_RESOURCE_H
4443
#include <sys/resource.h> /* for getrlimit */
45-
#endif
4644

4745
/* For testing, PGBENCH_USE_SELECT can be defined to force use of that code */
4846
#if defined(HAVE_PPOLL) && !defined(PGBENCH_USE_SELECT)

src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,6 @@
505505
/* Define to 1 if you have the <sys/procctl.h> header file. */
506506
#undef HAVE_SYS_PROCCTL_H
507507

508-
/* Define to 1 if you have the <sys/resource.h> header file. */
509-
#undef HAVE_SYS_RESOURCE_H
510-
511508
/* Define to 1 if you have the <sys/signalfd.h> header file. */
512509
#undef HAVE_SYS_SIGNALFD_H
513510

src/include/port/win32/sys/resource.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Replacement for <sys/resource.h> for Windows.
3+
*/
4+
#ifndef WIN32_SYS_RESOURCE_H
5+
#define WIN32_SYS_RESOURCE_H
6+
7+
#include <sys/time.h> /* for struct timeval */
8+
9+
#define RUSAGE_SELF 0
10+
#define RUSAGE_CHILDREN (-1)
11+
12+
struct rusage
13+
{
14+
struct timeval ru_utime; /* user time used */
15+
struct timeval ru_stime; /* system time used */
16+
};
17+
18+
extern int getrusage(int who, struct rusage *rusage);
19+
20+
#endif /* WIN32_SYS_RESOURCE_H */

src/include/rusagestub.h

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/include/utils/pg_rusage.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@
1414
#ifndef PG_RUSAGE_H
1515
#define PG_RUSAGE_H
1616

17-
#include <sys/time.h>
18-
19-
#ifdef HAVE_SYS_RESOURCE_H
2017
#include <sys/resource.h>
21-
#else
22-
#include "rusagestub.h"
23-
#endif
18+
#include <sys/time.h>
2419

2520

2621
/* State structure for pg_rusage_init/pg_rusage_show */

0 commit comments

Comments
 (0)
0