1*26ba8048Schristos /* $NetBSD: compat_random.c,v 1.3 2015/01/20 18:31:24 christos Exp $ */
21eb0dcbbSchristos
31eb0dcbbSchristos /*-
41eb0dcbbSchristos * Copyright (c) 2014 The NetBSD Foundation, Inc.
51eb0dcbbSchristos * All rights reserved.
61eb0dcbbSchristos *
71eb0dcbbSchristos * This code is derived from software contributed to The NetBSD Foundation
81eb0dcbbSchristos * by Christos Zoulas.
91eb0dcbbSchristos *
101eb0dcbbSchristos * Redistribution and use in source and binary forms, with or without
111eb0dcbbSchristos * modification, are permitted provided that the following conditions
121eb0dcbbSchristos * are met:
131eb0dcbbSchristos * 1. Redistributions of source code must retain the above copyright
141eb0dcbbSchristos * notice, this list of conditions and the following disclaimer.
151eb0dcbbSchristos * 2. Redistributions in binary form must reproduce the above copyright
161eb0dcbbSchristos * notice, this list of conditions and the following disclaimer in the
171eb0dcbbSchristos * documentation and/or other materials provided with the distribution.
181eb0dcbbSchristos *
191eb0dcbbSchristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201eb0dcbbSchristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211eb0dcbbSchristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221eb0dcbbSchristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231eb0dcbbSchristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241eb0dcbbSchristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251eb0dcbbSchristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261eb0dcbbSchristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271eb0dcbbSchristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281eb0dcbbSchristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291eb0dcbbSchristos * POSSIBILITY OF SUCH DAMAGE.
301eb0dcbbSchristos */
311eb0dcbbSchristos #include <sys/cdefs.h>
321eb0dcbbSchristos #if defined(LIBC_SCCS) && !defined(lint)
33*26ba8048Schristos __RCSID("$NetBSD: compat_random.c,v 1.3 2015/01/20 18:31:24 christos Exp $");
341eb0dcbbSchristos #endif /* LIBC_SCCS and not lint */
351eb0dcbbSchristos
361eb0dcbbSchristos #define __LIBC12_SOURCE__
371eb0dcbbSchristos #include "namespace.h"
381eb0dcbbSchristos
391eb0dcbbSchristos #include <assert.h>
401eb0dcbbSchristos #include <stdlib.h>
411eb0dcbbSchristos #include <compat/include/stdlib.h>
421eb0dcbbSchristos
431eb0dcbbSchristos #include "env.h"
441eb0dcbbSchristos #include "local.h"
451eb0dcbbSchristos
461eb0dcbbSchristos #ifdef __weak_alias
__weak_alias(initstate,_initstate)471eb0dcbbSchristos __weak_alias(initstate,_initstate)
481eb0dcbbSchristos __weak_alias(srandom,_srandom)
491eb0dcbbSchristos #endif
501eb0dcbbSchristos
511eb0dcbbSchristos __warn_references(initstate,
521eb0dcbbSchristos "warning: reference to compatibility initstate();"
531eb0dcbbSchristos " include <stdlib.h> for correct reference")
541eb0dcbbSchristos __warn_references(srandom,
551eb0dcbbSchristos "warning: reference to compatibility srandom();"
561eb0dcbbSchristos " include <stdlib.h> for correct reference")
571eb0dcbbSchristos
581eb0dcbbSchristos char *
591eb0dcbbSchristos initstate(unsigned long seed, char * buf, size_t len) {
60b27e1354Schristos return __initstate60((unsigned int)seed, buf, len);
611eb0dcbbSchristos }
621eb0dcbbSchristos
631eb0dcbbSchristos void
srandom(unsigned long seed)641eb0dcbbSchristos srandom(unsigned long seed) {
65b27e1354Schristos __srandom60((unsigned int)seed);
661eb0dcbbSchristos }
67