Ticket #218: 0001-random.diff.txt

File 0001-random.diff.txt, 978 bytes (added by Jim Ursetto, 12 years ago)
Line 
1diff --git a/chicken.h b/chicken.h
2index 73de3b5..bbeab72 100644
3--- a/chicken.h
4+++ b/chicken.h
5@@ -1109,8 +1109,15 @@ extern double trunc(double);
6                                                  C_unfix(end1) - C_unfix(start1) ), C_SCHEME_UNDEFINED)
7 #define C_words(n)                      C_fix(C_bytestowords(C_unfix(n)))
8 #define C_bytes(n)                      C_fix(C_wordstobytes(C_unfix(n)))
9+
10+#if defined(__linux__) || defined(C_XXXBSD)
11+#define C_random_fixnum(n)              C_fix(random() % C_unfix(n))
12+#define C_randomize(n)                  (srandom(C_unfix(n)), C_SCHEME_UNDEFINED)
13+#else
14 #define C_random_fixnum(n)              C_fix((int)(((double)rand())/(RAND_MAX + 1.0) * C_unfix(n)))
15 #define C_randomize(n)                  (srand(C_unfix(n)), C_SCHEME_UNDEFINED)
16+#endif
17+
18 #define C_block_size(x)                 C_fix(C_header_size(x))
19 #define C_pointer_address(x)            ((C_byte *)C_block_item((x), 0))
20 #define C_block_address(ptr, n, x)      C_a_unsigned_int_to_num(ptr, n, x)