Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit86e5eb4

Browse files
committed
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 manymore fields without any kind of configure probe, but that predates thiscommit.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
1 parentb431dc5 commit86e5eb4

File tree

7 files changed

+20
-70
lines changed

7 files changed

+20
-70
lines changed

‎configure

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16797,19 +16797,6 @@ esac
1679716797

1679816798
fi
1679916799

16800-
ac_fn_c_check_func "$LINENO" "getrusage" "ac_cv_func_getrusage"
16801-
if test "x$ac_cv_func_getrusage" = xyes; then :
16802-
$as_echo "#define HAVE_GETRUSAGE 1" >>confdefs.h
16803-
16804-
else
16805-
case " $LIBOBJS " in
16806-
*" getrusage.$ac_objext "* ) ;;
16807-
*) LIBOBJS="$LIBOBJS getrusage.$ac_objext"
16808-
;;
16809-
esac
16810-
16811-
fi
16812-
1681316800
ac_fn_c_check_func "$LINENO" "inet_aton" "ac_cv_func_inet_aton"
1681416801
if test "x$ac_cv_func_inet_aton" = xyes; then :
1681516802
$as_echo "#define HAVE_INET_ATON 1" >>confdefs.h
@@ -17125,6 +17112,12 @@ esac
1712517112
;;
1712617113
esac
1712717114

17115+
case " $LIBOBJS " in
17116+
*" getrusage.$ac_objext "* ) ;;
17117+
*) LIBOBJS="$LIBOBJS getrusage.$ac_objext"
17118+
;;
17119+
esac
17120+
1712817121
case " $LIBOBJS " in
1712917122
*" kill.$ac_objext "* ) ;;
1713017123
*) LIBOBJS="$LIBOBJS kill.$ac_objext"

‎configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,6 @@ AC_REPLACE_FUNCS(m4_normalize([
19111911
explicit_bzero
19121912
getopt
19131913
getpeereid
1914-
getrusage
19151914
inet_aton
19161915
link
19171916
mkdtemp
@@ -1986,6 +1985,7 @@ if test "$PORTNAME" = "win32"; then
19861985
AC_REPLACE_FUNCS(gettimeofday)
19871986
AC_LIBOBJ(dirmod)
19881987
AC_LIBOBJ(fdatasync)
1988+
AC_LIBOBJ(getrusage)
19891989
AC_LIBOBJ(kill)
19901990
AC_LIBOBJ(open)
19911991
AC_LIBOBJ(system)

‎src/backend/tcop/postgres.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include<sys/resource.h>
3333
#endif
3434

35-
#ifndefHAVE_GETRUSAGE
35+
#ifdefWIN32
3636
#include"rusagestub.h"
3737
#endif
3838

@@ -4860,7 +4860,14 @@ ShowUsage(const char *title)
48604860
(long)user.tv_usec,
48614861
(long)sys.tv_sec,
48624862
(long)sys.tv_usec);
4863-
#if defined(HAVE_GETRUSAGE)
4863+
#ifndefWIN32
4864+
4865+
/*
4866+
* The following rusage fields are not defined by POSIX, but they're
4867+
* present on all current Unix-like systems so we use them without any
4868+
* special checks. Some of these could be provided in our Windows
4869+
* emulation in src/port/getrusage.c with more work.
4870+
*/
48644871
appendStringInfo(&str,
48654872
"!\t%ld kB max resident size\n",
48664873
#if defined(__darwin__)
@@ -4896,7 +4903,7 @@ ShowUsage(const char *title)
48964903
r.ru_nvcsw-Save_r.ru_nvcsw,
48974904
r.ru_nivcsw-Save_r.ru_nivcsw,
48984905
r.ru_nvcsw,r.ru_nivcsw);
4899-
#endif/*HAVE_GETRUSAGE */
4906+
#endif/*!WIN32 */
49004907

49014908
/* remove trailing newline */
49024909
if (str.data[str.len-1]=='\n')

‎src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,6 @@
250250
/* Define to 1 if you have the `getrlimit' function. */
251251
#undef HAVE_GETRLIMIT
252252

253-
/* Define to 1 if you have the `getrusage' function. */
254-
#undef HAVE_GETRUSAGE
255-
256253
/* Define to 1 if you have the `gettimeofday' function. */
257254
#undef HAVE_GETTIMEOFDAY
258255

‎src/include/rusagestub.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
#defineRUSAGESTUB_H
1616

1717
#include<sys/time.h>/* for struct timeval */
18-
#ifndefWIN32
19-
#include<sys/times.h>/* for struct tms */
20-
#endif
2118
#include<limits.h>/* for CLK_TCK */
2219

2320
#defineRUSAGE_SELF0

‎src/port/getrusage.c

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,14 @@
1717

1818
#include"rusagestub.h"
1919

20-
/* This code works on:
21-
*solaris_i386
22-
*solaris_sparc
23-
*win32
24-
* which currently is all the supported platforms that don't have a
25-
* native version of getrusage(). So, if configure decides to compile
26-
* this file at all, we just use this version unconditionally.
20+
/*
21+
* This code works on Windows, which is the only supported platform without a
22+
* native version of getrusage().
2723
*/
2824

2925
int
3026
getrusage(intwho,structrusage*rusage)
3127
{
32-
#ifdefWIN32
3328
FILETIMEstarttime;
3429
FILETIMEexittime;
3530
FILETIMEkerneltime;
@@ -66,44 +61,6 @@ getrusage(int who, struct rusage *rusage)
6661
li.QuadPart /=10L;/* Convert to microseconds */
6762
rusage->ru_utime.tv_sec=li.QuadPart /1000000L;
6863
rusage->ru_utime.tv_usec=li.QuadPart %1000000L;
69-
#else/* all but WIN32 */
70-
71-
structtmstms;
72-
inttick_rate=CLK_TCK;/* ticks per second */
73-
clock_tu,
74-
s;
75-
76-
if (rusage== (structrusage*)NULL)
77-
{
78-
errno=EFAULT;
79-
return-1;
80-
}
81-
if (times(&tms)<0)
82-
{
83-
/* errno set by times */
84-
return-1;
85-
}
86-
switch (who)
87-
{
88-
caseRUSAGE_SELF:
89-
u=tms.tms_utime;
90-
s=tms.tms_stime;
91-
break;
92-
caseRUSAGE_CHILDREN:
93-
u=tms.tms_cutime;
94-
s=tms.tms_cstime;
95-
break;
96-
default:
97-
errno=EINVAL;
98-
return-1;
99-
}
100-
#defineTICK_TO_SEC(T,RATE)((T)/(RATE))
101-
#defineTICK_TO_USEC(T,RATE)(((T)%(RATE)*1000000)/RATE)
102-
rusage->ru_utime.tv_sec=TICK_TO_SEC(u,tick_rate);
103-
rusage->ru_utime.tv_usec=TICK_TO_USEC(u,tick_rate);
104-
rusage->ru_stime.tv_sec=TICK_TO_SEC(s,tick_rate);
105-
rusage->ru_stime.tv_usec=TICK_TO_USEC(u,tick_rate);
106-
#endif/* WIN32 */
10764

10865
return0;
10966
}

‎src/tools/msvc/Solution.pm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ sub GenerateFiles
277277
HAVE_GETPEERUCRED=>undef,
278278
HAVE_GETPWUID_R=>undef,
279279
HAVE_GETRLIMIT=>undef,
280-
HAVE_GETRUSAGE=>undef,
281280
HAVE_GETTIMEOFDAY=>undef,
282281
HAVE_GSSAPI_GSSAPI_H=>undef,
283282
HAVE_GSSAPI_H=>undef,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp