Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 382ff21

Browse files
committed
Fix up lame idea of not using autoconf to determine if platform has scandir().
Should fix buildfarm failures.
1 parent 2a73ee5 commit 382ff21

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18494,7 +18494,8 @@ fi
1849418494

1849518495

1849618496

18497-
for ac_func in cbrt dlopen fcvt fdatasync getifaddrs getpeereid getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs
18497+
18498+
for ac_func in cbrt dlopen fcvt fdatasync getifaddrs getpeereid getpeerucred getrlimit memmove poll pstat readlink scandir setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs
1849818499
do
1849918500
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1850018501
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5

configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.626 2010/04/30 03:16:58 scrappy Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.627 2010/05/13 22:07:42 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1167,7 +1167,7 @@ PGAC_VAR_INT_TIMEZONE
11671167
AC_FUNC_ACCEPT_ARGTYPES
11681168
PGAC_FUNC_GETTIMEOFDAY_1ARG
11691169

1170-
AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getifaddrs getpeereid getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs])
1170+
AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getifaddrs getpeereid getpeerucred getrlimit memmove poll pstat readlink scandir setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs])
11711171

11721172
AC_REPLACE_FUNCS(fseeko)
11731173
case $host_os in

contrib/pg_upgrade/file.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int win32_pghardlink(const char *src, const char *dst);
3333
static int copy_dir(const char *from, const char *to, bool force);
3434
#endif
3535

36-
#if defined(sun) || defined(WIN32)
36+
#ifndef HAVE_SCANDIR
3737
static int pg_scandir_internal(migratorContext *ctx, const char *dirname,
3838
struct dirent *** namelist,
3939
int (*selector) (const struct dirent *));
@@ -235,26 +235,25 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
235235
* pg_scandir()
236236
*
237237
* Wrapper for portable scandir functionality
238-
*
239238
*/
240239
int
241240
pg_scandir(migratorContext *ctx, const char *dirname,
242241
struct dirent ***namelist,
243242
int (*selector) (const struct dirent *))
244243
{
245-
#if defined(sun) || defined(WIN32)
244+
#ifndef HAVE_SCANDIR
246245
return pg_scandir_internal(ctx, dirname, namelist, selector);
247246

248247
/*
248+
* scandir() is originally from BSD 4.3, which had the third argument as
249+
* non-const. Linux and other C libraries have updated it to use a const.
250+
* http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg00214.html
251+
*
249252
* Here we try to guess which libc's need const, and which don't. The net
250-
* goal here is to try to supress a compiler warning due to a prototype
253+
* goal here is to try to suppress a compiler warning due to a prototype
251254
* mismatch of const usage. Ideally we would do this via autoconf, but
252-
* Postgres's autoconf doesn't test for this and it is overkill to add
253-
* autoconf just for this. scandir() is from BSD 4.3, which had the third
254-
* argument as non-const. Linux and other C libraries have updated it to
255-
* use a const.
256-
* http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg002
257-
* 14.html
255+
* autoconf doesn't have a suitable builtin test and it seems overkill
256+
* to add one just to avoid a warning.
258257
*/
259258
#elif defined(freebsd) || defined(bsdi) || defined(darwin) || defined(openbsd)
260259
/* no const */
@@ -266,19 +265,18 @@ pg_scandir(migratorContext *ctx, const char *dirname,
266265
}
267266

268267

269-
#if defined(sun) || defined(WIN32)
268+
#ifndef HAVE_SCANDIR
270269
/*
271270
* pg_scandir_internal()
272271
*
273-
* We'll provide our own scandir function for sun, since it is not
274-
* part of the standard system library.
272+
* Implement our own scandir() on platforms that don't have it.
275273
*
276274
* Returns count of files that meet the selection criteria coded in
277275
* the function pointed to by selector. Creates an array of pointers
278276
* to dirent structures. Address of array returned in namelist.
279277
*
280278
* Note that the number of dirent structures needed is dynamically
281-
* allocated using realloc. Realloc can be inneficient if invoked a
279+
* allocated using realloc. Realloc can be inefficient if invoked a
282280
* large number of times. Its use in pg_upgrade is to find filesystem
283281
* filenames that have extended beyond the initial segment (file.1,
284282
* .2, etc.) and should therefore be invoked a small number of times.

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@
409409
/* Define to 1 if you have the `rl_filename_completion_function' function. */
410410
#undef HAVE_RL_FILENAME_COMPLETION_FUNCTION
411411

412+
/* Define to 1 if you have the `scandir' function. */
413+
#undef HAVE_SCANDIR
414+
412415
/* Define to 1 if you have the <security/pam_appl.h> header file. */
413416
#undef HAVE_SECURITY_PAM_APPL_H
414417

0 commit comments

Comments
 (0)