summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/erand48.c
blob: d1c792472bdeb4fa2d7d0db5d1cdc8ec4410d3fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*	$NetBSD: erand48.c,v 1.7 2000/01/22 22:19:19 mycroft Exp $	*/

/*
 * Copyright (c) 1993 Martin Birgmeier
 * All rights reserved.
 *
 * You may redistribute unmodified or modified versions of this source
 * code provided that the above copyright notice and this and the
 * following conditions are retained.
 *
 * This software is provided ``as is'', and comes with no warranties
 * of any kind. I shall in no event be liable for anything that happens
 * to anyone/anything when using this software.
 */

#include "namespace.h"

#include <assert.h>

#include "rand48.h"

#ifdef __weak_alias
__weak_alias(erand48,_erand48)
#endif

double
erand48(unsigned short xseed[3])
{

	_DIAGASSERT(xseed != NULL);

	__dorand48(xseed);
	return ldexp((double) xseed[0], -48) +
	       ldexp((double) xseed[1], -32) +
	       ldexp((double) xseed[2], -16);
}
ass='logsubject'>Add a mutex to protect the state.kleink 1998-07-26constify some tables.mycroft 1998-02-28changes to (partially) quiet lint.perry 1998-02-06Cast size_t to long for printing.kleink 1998-02-04Per XPG4.2, change the `n' argument of initstate() to size_t. (Since it waskleink recently changed from int to long (lite-2 import), I saw no reason to delay this `alignment'.) 1998-02-03remove obsolete register declarationsperry 1998-01-30update to lite-2perry 1997-07-21If port provides __weak_alias(), provide an Standard C and POSIX purejtc identifier namespace by renaming non standard functions and variables such that they have a leading underscore. The library will use those names internally. Weak aliases are used to provide the original names to the API. This is only the first part of this change. It is most of the functions which are implemented in C for all NetBSD ports. Subsequent changes are to add the same support to the remaining C files, to assembly files, and to the automagically generated assembly source used for system calls. When all of the above is done, ports with weak alias support should add a definition for __weak_alias to <sys/cdefs.h>. 1997-07-13Add local.h for local prototypes.christos Fix namespace issues for strtoq and strtouq Fix gcc warnings. Fix RCSID's 1995-12-28New-style RCS ids.thorpej