1drand48_r(3) Library Functions 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 Standard C library (libc, -lc)
12
14 #include <stdlib.h>
15
16 int drand48_r(struct drand48_data *restrict buffer,
17 double *restrict result);
18 int erand48_r(unsigned short xsubi[3],
19 struct drand48_data *restrict buffer,
20 double *restrict result);
21
22 int lrand48_r(struct drand48_data *restrict buffer,
23 long *restrict result);
24 int nrand48_r(unsigned short xsubi[3],
25 struct drand48_data *restrict buffer,
26 long *restrict result);
27
28 int mrand48_r(struct drand48_data *restrict buffer,
29 long *restrict result);
30 int jrand48_r(unsigned short xsubi[3],
31 struct drand48_data *restrict buffer,
32 long *restrict result);
33
34 int srand48_r(long int seedval, struct drand48_data *buffer);
35 int seed48_r(unsigned short seed16v[3], struct drand48_data *buffer);
36 int lcong48_r(unsigned short param[7], struct drand48_data *buffer);
37
38 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
39
40 All functions shown above:
41 /* glibc >= 2.19: */ _DEFAULT_SOURCE
42 || /* glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE
43
45 These functions are the reentrant analogs of the functions described in
46 drand48(3). Instead of modifying the global random generator state,
47 they use the supplied data buffer.
48
49 Before the first use, this struct must be initialized, for example, by
50 filling it with zeros, or by calling one of the functions srand48_r(),
51 seed48_r(), or lcong48_r().
52
54 The return value is 0.
55
57 For an explanation of the terms used in this section, see at‐
58 tributes(7).
59
60 ┌────────────────────────────────┬───────────────┬─────────────────────┐
61 │Interface │ Attribute │ Value │
62 ├────────────────────────────────┼───────────────┼─────────────────────┤
63 │drand48_r(), erand48_r(), │ Thread safety │ MT-Safe race:buffer │
64 │lrand48_r(), nrand48_r(), │ │ │
65 │mrand48_r(), jrand48_r(), │ │ │
66 │srand48_r(), seed48_r(), │ │ │
67 │lcong48_r() │ │ │
68 └────────────────────────────────┴───────────────┴─────────────────────┘
69
71 GNU.
72
74 drand48(3), rand(3), random(3)
75
76
77
78Linux man-pages 6.05 2023-07-20 drand48_r(3)