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

Commitc43feef

Browse files
committed
Add erand48() to the set of functions supported by our src/port/ library,
and extend configure to test for it properly instead of hard-wiringan assumption that everybody but Windows has the rand48 functions.(We do cheat to the extent of assuming that probing for erand48 will dofor the entire rand48 family.)erand48() is unused as of this commit, but a followon patch will causeGEQO to depend on it.Andres Freund, additional hacking by Tom
1 parentfe1cc1e commitc43feef

File tree

6 files changed

+48
-30
lines changed

6 files changed

+48
-30
lines changed

‎configure

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18594,7 +18594,8 @@ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
1859418594

1859518595

1859618596

18597-
for ac_func in crypt getopt getrusage inet_aton random rint srandom strdup strerror strlcat strlcpy strtol strtoul
18597+
18598+
for ac_func in crypt erand48 getopt getrusage inet_aton random rint srandom strdup strerror strlcat strlcpy strtol strtoul
1859818599
do
1859918600
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1860018601
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -19207,12 +19208,6 @@ case " $LIBOBJS " in
1920719208
;;
1920819209
esac
1920919210

19210-
case " $LIBOBJS " in
19211-
*" rand.$ac_objext "* ) ;;
19212-
*) LIBOBJS="$LIBOBJS rand.$ac_objext"
19213-
;;
19214-
esac
19215-
1921619211
case " $LIBOBJS " in
1921719212
*" win32env.$ac_objext "* ) ;;
1921819213
*) LIBOBJS="$LIBOBJS win32env.$ac_objext"

‎configure.in

Lines changed: 2 additions & 3 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.604 2009/07/02 18:55:40 petere Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.605 2009/07/16 17:43:52 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1249,7 +1249,7 @@ fi
12491249
pgac_save_LIBS="$LIBS"
12501250
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
12511251

1252-
AC_REPLACE_FUNCS([crypt getopt getrusage inet_aton random rint srandom strdup strerror strlcat strlcpy strtol strtoul])
1252+
AC_REPLACE_FUNCS([crypterand48getopt getrusage inet_aton random rint srandom strdup strerror strlcat strlcpy strtol strtoul])
12531253

12541254
case $host_os in
12551255

@@ -1294,7 +1294,6 @@ if test "$PORTNAME" = "win32"; then
12941294
AC_REPLACE_FUNCS(gettimeofday)
12951295
AC_LIBOBJ(kill)
12961296
AC_LIBOBJ(open)
1297-
AC_LIBOBJ(rand)
12981297
AC_LIBOBJ(win32env)
12991298
AC_LIBOBJ(win32error)
13001299
AC_DEFINE([HAVE_SYMLINK], 1,

‎src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
/* Define to 1 if you have the <editline/readline.h> header file. */
138138
#undef HAVE_EDITLINE_READLINE_H
139139

140+
/* Define to 1 if you have the `erand48' function. */
141+
#undef HAVE_ERAND48
142+
140143
/* Define to 1 if you have the `ERR_set_mark' function. */
141144
#undef HAVE_ERR_SET_MARK
142145

‎src/include/port.h

Lines changed: 8 additions & 5 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/include/port.h,v 1.125 2009/06/11 14:49:08 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.126 2009/07/16 17:43:52 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -316,10 +316,6 @@ extern FILE *pgwin32_fopen(const char *, const char *);
316316
#definepopen(a,b) _popen(a,b)
317317
#definepclose(a) _pclose(a)
318318

319-
/* Missing rand functions */
320-
externlonglrand48(void);
321-
externvoidsrand48(longseed);
322-
323319
/* New versions of MingW have gettimeofday, old mingw and msvc don't */
324320
#ifndefHAVE_GETTIMEOFDAY
325321
/* Last parameter not used */
@@ -351,6 +347,13 @@ extern off_t ftello(FILE *stream);
351347
#endif
352348
#endif
353349

350+
#ifndefHAVE_ERAND48
351+
/* we assume all of these are present or missing together */
352+
externdoubleerand48(unsigned shortxseed[3]);
353+
externlonglrand48(void);
354+
externvoidsrand48(longseed);
355+
#endif
356+
354357
#ifndefHAVE_FSEEKO
355358
#definefseeko(a,b,c) fseek(a, b, c)
356359
#defineftello(a)ftell(a)

‎src/port/rand.crenamed to‎src/port/erand48.c

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
/*
2-
* $PostgreSQL: pgsql/src/port/rand.c,v 1.6 2009/06/11 14:49:15 momjian Exp $
1+
/*-------------------------------------------------------------------------
32
*
4-
*-------------------------------------------------------------------------
3+
* erand48.c
4+
*
5+
* This file supplies versions of erand48(), lrand48(), and srand48()
6+
* for machines that lack them. (These are all the members of the drand48
7+
* family that Postgres currently requires. We name the file after erand48
8+
* because that is the one that configure tests for.)
59
*
6-
* rand.c
7-
* Missing rand implementations for Win32
810
*
9-
*-------------------------------------------------------------------------
10-
*/
11-
#include"c.h"
12-
13-
/*
1411
* Copyright (c) 1993 Martin Birgmeier
1512
* All rights reserved.
1613
*
@@ -21,7 +18,17 @@
2118
* This software is provided ``as is'', and comes with no warranties
2219
* of any kind. I shall in no event be liable for anything that happens
2320
* to anyone/anything when using this software.
21+
*
22+
* IDENTIFICATION
23+
* $PostgreSQL: pgsql/src/port/erand48.c,v 1.1 2009/07/16 17:43:52 tgl Exp $
24+
*
25+
*-------------------------------------------------------------------------
2426
*/
27+
28+
#include"c.h"
29+
30+
#include<math.h>
31+
2532
#defineRAND48_SEED_0(0x330e)
2633
#defineRAND48_SEED_1(0xabcd)
2734
#defineRAND48_SEED_2(0x1234)
@@ -30,17 +37,18 @@
3037
#defineRAND48_MULT_2(0x0005)
3138
#defineRAND48_ADD(0x000b)
3239

33-
unsigned short_rand48_seed[3]= {
40+
staticunsigned short_rand48_seed[3]= {
3441
RAND48_SEED_0,
3542
RAND48_SEED_1,
3643
RAND48_SEED_2
3744
};
38-
unsigned short_rand48_mult[3]= {
45+
staticunsigned short_rand48_mult[3]= {
3946
RAND48_MULT_0,
4047
RAND48_MULT_1,
4148
RAND48_MULT_2
4249
};
43-
unsigned short_rand48_add=RAND48_ADD;
50+
staticunsigned short_rand48_add=RAND48_ADD;
51+
4452

4553
staticvoid
4654
_dorand48(unsigned shortxseed[3])
@@ -62,6 +70,16 @@ _dorand48(unsigned short xseed[3])
6270
xseed[2]= (unsigned short)accu;
6371
}
6472

73+
74+
double
75+
erand48(unsigned shortxseed[3])
76+
{
77+
_dorand48(xseed);
78+
returnldexp((double)xseed[0],-48)+
79+
ldexp((double)xseed[1],-32)+
80+
ldexp((double)xseed[2],-16);
81+
}
82+
6583
long
6684
lrand48(void)
6785
{

‎src/tools/msvc/Mkvcbuild.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Mkvcbuild;
33
#
44
# Package that generates build files for msvc build
55
#
6-
# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.40 2009/06/05 18:29:56 adunstan Exp $
6+
# $PostgreSQL: pgsql/src/tools/msvc/Mkvcbuild.pm,v 1.41 2009/07/16 17:43:52 tgl Exp $
77
#
88
use Carp;
99
use Win32;
@@ -44,7 +44,7 @@ sub mkvcbuild
4444

4545
our@pgportfiles =qw(
4646
chklocale.c crypt.c fseeko.c getrusage.c inet_aton.c random.c srandom.c
47-
getaddrinfo.c gettimeofday.c kill.c open.crand.c
47+
getaddrinfo.c gettimeofday.c kill.c open.cerand48.c
4848
snprintf.c strlcat.c strlcpy.c copydir.c dirmod.c exec.c noblock.c path.c pipe.c
4949
pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c sprompt.c thread.c
5050
getopt.c getopt_long.c dirent.c rint.c win32env.c win32error.c);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp