7 * Userspace RCU library - rand/rand_r Compatibility Header
9 * Copyright 1996 - Ulrich Drepper <drepper@cygnus.com >
10 * Copyright 2013 - Pierre-Luc St-Charles <pierre-luc.st-charles@polymtl.ca>
12 * Note: this file is only used to simplify the code required to
13 * use the 'rand_r(...)' system function across multiple platforms,
14 * which might not always be referenced the same way.
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 * Reentrant random function from POSIX.1c.
34 * Copyright (C) 1996, 1999 Free Software Foundation, Inc.
35 * This file is part of the GNU C Library.
36 * Contributed by Ulrich Drepper <drepper@cygnus.com <mailto:drepper@cygnus.com>>, 1996.
38 static inline int rand_r(unsigned int *seed
)
40 unsigned int next
= *seed
;
45 result
= (unsigned int) (next
/ 65536) % 2048;
50 result
^= (unsigned int) (next
/ 65536) % 1024;
55 result
^= (unsigned int) (next
/ 65536) % 1024;
61 #endif /* HAVE_RAND_R */
63 #endif /* _COMPAT_RAND_H */
This page took 0.029897 seconds and 4 git commands to generate.