From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | andres(at)anarazel(dot)de, pgsql-hackers(at)postgresql(dot)org |
Subject: | [PATCH 1/3] Add erand48() implementation for non-unixoid systems. |
Date: | 2009-07-14 22:34:48 |
Message-ID: | 1247610890-8922-2-git-send-email-andres@anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
---
src/include/port.h | 2 ++
src/port/rand.c | 8 ++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/include/port.h b/src/include/port.h
index cbf9dcf..af96620 100644
*** a/src/include/port.h
--- b/src/include/port.h
*************** extern FILE *pgwin32_fopen(const char *,
*** 320,325 ****
--- 320,327 ----
extern long lrand48(void);
extern void srand48(long seed);
+ extern long erand48(unsigned short[3]);
+
/* New versions of MingW have gettimeofday, old mingw and msvc don't */
#ifndef HAVE_GETTIMEOFDAY
/* Last parameter not used */
diff --git a/src/port/rand.c b/src/port/rand.c
index 6c14a64..6904bb1 100644
*** a/src/port/rand.c
--- b/src/port/rand.c
*************** srand48(long seed)
*** 80,82 ****
--- 80,90 ----
_rand48_mult[2] = RAND48_MULT_2;
_rand48_add = RAND48_ADD;
}
+
+ double erand48(unsigned short xseed[3])
+ {
+ _dorand48(xseed);
+ return ldexp((double) xseed[0], -48) +
+ ldexp((double) xseed[1], -32) +
+ ldexp((double) xseed[2], -16);
+ }
--
1.6.3.3.335.ge09a8
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2009-07-14 22:34:49 | [PATCH 2/3] Support a 'geqo_seed' GUC to make planning via GEQO repeatable. |
Previous Message | Andres Freund | 2009-07-14 22:34:47 | Make planning via GEQO repeatable |