Skip to content

Commit 655473a

Browse files
committed
Add commentary about Cygwin's broken erand48, per report from Andrew Dunstan.
1 parent dc7aa36 commit 655473a

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-
static int linear(PlannerInfo *root, int max, double bias);
45+
static int linear_rand(PlannerInfo *root, int max, double bias);
4646

4747

4848
/*
@@ -57,21 +57,29 @@ geqo_selection(PlannerInfo *root, Chromosome *momma, Chromosome *daddy,
5757
int first,
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
static int
84-
linear(PlannerInfo *root, int pool_size, double bias)
92+
linear_rand(PlannerInfo *root, int pool_size, double bias)
8593
{
8694
double index; /* index between 0 and pop_size */
8795
double max = (double) pool_size;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy