[PATCH 1/3] Add erand48() implementation for non-unixoid systems.

Поиск
Список
Период
Сортировка
Искать

[PATCH 1/3] Add erand48() implementation for non-unixoid systems.

От:
Andres Freund <andres@anarazel.de>
Дата:
---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


FAQ