160fd3450bf5cd081e019ea50616032e1447aeeb3Elliott Hughes/*	$NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $	*/
2774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes
31dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/*
41dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Copyright (c) 1993 Martin Birgmeier
51dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * All rights reserved.
61dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *
71dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * You may redistribute unmodified or modified versions of this source
81dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * code provided that the above copyright notice and this and the
91dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * following conditions are retained.
101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *
111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * This software is provided ``as is'', and comes with no warranties
121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * of any kind. I shall in no event be liable for anything that happens
131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * to anyone/anything when using this software.
141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */
151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
16774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes#include <sys/cdefs.h>
17774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes#if defined(LIBC_SCCS) && !defined(lint)
1860fd3450bf5cd081e019ea50616032e1447aeeb3Elliott Hughes__RCSID("$NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $");
19774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes#endif /* LIBC_SCCS and not lint */
20774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes
21774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes#include "namespace.h"
221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include "rand48.h"
231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
24774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes#ifdef __weak_alias
25774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes__weak_alias(lrand48,_lrand48)
26774c7f54ff375d71106283d42779b0cc5f238f87Elliott Hughes#endif
271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectlong
291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectlrand48(void)
301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project{
311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project	__dorand48(__rand48_seed);
3260fd3450bf5cd081e019ea50616032e1447aeeb3Elliott Hughes	return __rand48_seed[2] * 32768 + (__rand48_seed[1] >> 1);
331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project}
34