1DRAND48_R(3) Linux Programmer's Manual DRAND48_R(3)
2
3
4
6 drand48_r, erand48_r, lrand48_r, nrand48_r, mrand48_r, jrand48_r,
7 srand48_r, seed48_r, lcong48_r - generate uniformly distributed pseudo-
8 random numbers reentrantly
9
11 #include <stdlib.h>
12
13 int drand48_r(struct drand48_data *restrict buffer,
14 double *restrict result);
15 int erand48_r(unsigned short xsubi[3],
16 struct drand48_data *restrict buffer,
17 double *restrict result);
18
19 int lrand48_r(struct drand48_data *restrict buffer,
20 long *restrict result);
21 int nrand48_r(unsigned short xsubi[3],
22 struct drand48_data *restrict buffer,
23 long *restrict result);
24
25 int mrand48_r(struct drand48_data *restrict buffer,
26 long *restrict result);
27 int jrand48_r(unsigned short xsubi[3],
28 struct drand48_data *restrict buffer,
29 long *restrict result);
30
31 int srand48_r(long int seedval, struct drand48_data *buffer);
32 int seed48_r(unsigned short seed16v[3], struct drand48_data *buffer);
33 int lcong48_r(unsigned short param[7], struct drand48_data *buffer);
34
35 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
36
37 All functions shown above:
38 /* Glibc since 2.19: */ _DEFAULT_SOURCE
39 || /* Glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
40
42 These functions are the reentrant analogs of the functions described in
43 drand48(3). Instead of modifying the global random generator state,
44 they use the supplied data buffer.
45
46 Before the first use, this struct must be initialized, for example, by
47 filling it with zeros, or by calling one of the functions srand48_r(),
48 seed48_r(), or lcong48_r().
49
51 The return value is 0.
52
54 For an explanation of the terms used in this section, see at‐
55 tributes(7).
56
57 ┌────────────────────────────────┬───────────────┬─────────────────────┐
58 │Interface │ Attribute │ Value │
59 ├────────────────────────────────┼───────────────┼─────────────────────┤
60 │drand48_r(), erand48_r(), │ Thread safety │ MT-Safe race:buffer │
61 │lrand48_r(), nrand48_r(), │ │ │
62 │mrand48_r(), jrand48_r(), │ │ │
63 │srand48_r(), seed48_r(), │ │ │
64 │lcong48_r() │ │ │
65 └────────────────────────────────┴───────────────┴─────────────────────┘
66
68 These functions are GNU extensions and are not portable.
69
71 drand48(3), rand(3), random(3)
72
74 This page is part of release 5.12 of the Linux man-pages project. A
75 description of the project, information about reporting bugs, and the
76 latest version of this page, can be found at
77 https://www.kernel.org/doc/man-pages/.
78
79
80
81GNU 2021-03-22 DRAND48_R(3)