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

Commit655473a

Browse files
committed
Add commentary about Cygwin's broken erand48, per report from Andrew Dunstan.
1 parentdc7aa36 commit655473a

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

‎configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19085,7 +19085,8 @@ esac
1908519085

1908619086
fi
1908719087

19088-
# Cygwin's erand48 sometimes hangs, so force use of ours
19088+
# Cygwin's erand48() is broken (always returns zero) in some releases,
19089+
# so force use of ours.
1908919090
if test "$PORTNAME" = "cygwin"; then
1909019091
case " $LIBOBJS " in
1909119092
*" erand48.$ac_objext "* ) ;;

‎configure.in

Lines changed: 3 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.606 2009/07/23 23:50:29 adunstan Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.607 2009/07/24 15:03:07 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1289,7 +1289,8 @@ if test "$PORTNAME" = "solaris"; then
12891289
AC_LIBOBJ(getopt)
12901290
fi
12911291

1292-
# Cygwin's erand48 sometimes hangs, so force use of ours
1292+
# Cygwin's erand48() is broken (always returns zero) in some releases,
1293+
# so force use of ours.
12931294
if test "$PORTNAME" = "cygwin"; then
12941295
AC_LIBOBJ(erand48)
12951296
fi

‎src/backend/optimizer/geqo/geqo_selection.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_selection.c,v 1.25 2009/07/16 20:55:44 tgl Exp $
9+
* $PostgreSQL: pgsql/src/backend/optimizer/geqo/geqo_selection.c,v 1.26 2009/07/24 15:03:07 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -42,7 +42,7 @@
4242
#include"optimizer/geqo_random.h"
4343
#include"optimizer/geqo_selection.h"
4444

45-
staticintlinear(PlannerInfo*root,intmax,doublebias);
45+
staticintlinear_rand(PlannerInfo*root,intmax,doublebias);
4646

4747

4848
/*
@@ -57,21 +57,29 @@ geqo_selection(PlannerInfo *root, Chromosome *momma, Chromosome *daddy,
5757
intfirst,
5858
second;
5959

60-
first=linear(root,pool->size,bias);
61-
second=linear(root,pool->size,bias);
60+
first=linear_rand(root,pool->size,bias);
61+
second=linear_rand(root,pool->size,bias);
6262

63+
/*
64+
* Ensure we have selected different genes, except if pool size is only
65+
* one, when we can't.
66+
*
67+
* This code has been observed to hang up in an infinite loop when the
68+
* platform's implementation of erand48() is broken. We consider that a
69+
* feature: it lets you know you'd better fix the random-number generator.
70+
*/
6371
if (pool->size>1)
6472
{
6573
while (first==second)
66-
second=linear(root,pool->size,bias);
74+
second=linear_rand(root,pool->size,bias);
6775
}
6876

6977
geqo_copy(root,momma,&pool->data[first],pool->string_length);
7078
geqo_copy(root,daddy,&pool->data[second],pool->string_length);
7179
}
7280

7381
/*
74-
*linear
82+
*linear_rand
7583
* generates random integer between 0 and input max number
7684
* using input linear bias
7785
*
@@ -81,7 +89,7 @@ geqo_selection(PlannerInfo *root, Chromosome *momma, Chromosome *daddy,
8189
* bias = (prob of first rule) / (prob of middle rule)
8290
*/
8391
staticint
84-
linear(PlannerInfo*root,intpool_size,doublebias)
92+
linear_rand(PlannerInfo*root,intpool_size,doublebias)
8593
{
8694
doubleindex;/* index between 0 and pop_size */
8795
doublemax= (double)pool_size;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp