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

Commit0aa1e0e

Browse files
committed
Fix detection of the result type of strerror_r().
The method we've traditionally used, of redeclaring strerror_r() tosee if the compiler complains of inconsistent declarations, turns outnot to work reliably because some compilers only report a warning,not an error. Amazingly, this has gone undetected for years, eventhough it certainly breaks our detection of whether strerror_rsucceeded.Let's instead test whether the compiler will take the result ofstrerror_r() as a switch() argument. It's possible this won'twork universally either, but it's the best idea I could come up withon the spur of the moment.Back-patch of commit751f532. Buildfarm results indicate that onlyicc-on-Linux actually has an issue here; perhaps the lack of fieldreports indicates that people don't build PG for production that way.Discussion:https://postgr.es/m/10877.1537993279@sss.pgh.pa.us
1 parent8256d7a commit0aa1e0e

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

‎config/c-library.m4

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,23 @@ AH_VERBATIM(GETTIMEOFDAY_1ARG_,
8282

8383
# PGAC_FUNC_STRERROR_R_INT
8484
# ---------------------------
85-
# Check if strerror_r() returns an int (SUSv3) rather than a char * (GNU libc)
86-
# If so, define STRERROR_R_INT
85+
# Check if strerror_r() returns int (POSIX) rather than char * (GNU libc).
86+
# If so, define STRERROR_R_INT.
87+
# The result is uncertain if strerror_r() isn't provided,
88+
# but we don't much care.
8789
AC_DEFUN([PGAC_FUNC_STRERROR_R_INT],
8890
[AC_CACHE_CHECK(whetherstrerror_rreturnsint,
8991
pgac_cv_func_strerror_r_int,
9092
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <string.h>],
91-
[#ifndef _AIX
92-
int strerror_r(int, char *, size_t);
93-
#else
94-
/* Older AIX has 'int' for the third argument so we don't test the args. */
95-
int strerror_r();
96-
#endif])],
93+
[[char buf[100];
94+
switch (strerror_r(1, buf, sizeof(buf)))
95+
{ case 0: break; default: break; }
96+
]])],
9797
[pgac_cv_func_strerror_r_int=yes],
9898
[pgac_cv_func_strerror_r_int=no])])
9999
if test x"$pgac_cv_func_strerror_r_int" = xyes ; then
100100
AC_DEFINE(STRERROR_R_INT,1,
101-
[Define to 1 if strerror_r() returnsaint.])
101+
[Define to 1 if strerror_r() returns int.])
102102
fi
103103
])# PGAC_FUNC_STRERROR_R_INT
104104

‎configure

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8985,12 +8985,10 @@ else
89858985
int
89868986
main ()
89878987
{
8988-
#ifndef _AIX
8989-
int strerror_r(int, char *, size_t);
8990-
#else
8991-
/* Older AIX has 'int' for the third argument so we don't test the args. */
8992-
int strerror_r();
8993-
#endif
8988+
char buf[100];
8989+
switch (strerror_r(1, buf, sizeof(buf)))
8990+
{ case 0: break; default: break; }
8991+
89948992
;
89958993
return 0;
89968994
}

‎src/include/pg_config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@
810810
/* Define to 1 if you have the ANSI C header files. */
811811
#undef STDC_HEADERS
812812

813-
/* Define to 1 if strerror_r() returnsaint. */
813+
/* Define to 1 if strerror_r() returns int. */
814814
#undef STRERROR_R_INT
815815

816816
/* Define to 1 if your <sys/time.h> declares `struct tm'. */

‎src/include/pg_config.h.win32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@
617617
/* Define to 1 if you have the ANSI C header files. */
618618
#define STDC_HEADERS 1
619619

620-
/* Define to 1 if strerror_r() returnsaint. */
620+
/* Define to 1 if strerror_r() returns int. */
621621
/* #undef STRERROR_R_INT */
622622

623623
/* Define to 1 if your <sys/time.h> declares `struct tm'. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp