blob: f26bb18d93a37a01f35c8fe596c31ea41a357985 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/* Implementation note: Mingw/Windows does not provide POSIX 'random', so
netpbm/pm_config.h makes that a macro for POSIX 'rand' on that platform
*/
#define _DEFAULT_SOURCE /* New name for SVID & BSD source defines */
#define _XOPEN_SOURCE 500 /* Make sure random() is in stdlib.h */
#define _BSD_SOURCE /* Make sure random() is in stdlib.h */
#include <stdlib.h>
#include "netpbm/pm_config.h"
#include "netpbm/rand.h"
static void
vinit(struct pm_randSt * const randStP) {
randStP->max = RAND_MAX;
randStP->stateP = NULL;
}
static void
vsrand(struct pm_randSt * const randStP,
unsigned int const seed) {
srandom(seed);
}
static unsigned long int
vrand(struct pm_randSt * const randStP) {
return random();
}
struct pm_rand_vtable const pm_randsysrandom_vtable = {
&vinit,
&vsrand,
&vrand
};
|