Browse Source

fix mrand48/jrand48 return value on 64-bit archs

POSIX specifies the result to have signed 32-bit range. on 32-bit
archs, the implicit conversion to long achieved the desired range
already, but when long is 64-bit, a cast is needed.

patch by Ed Schouten.
Rich Felker 8 years ago
parent
commit
adfe682eb0
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/prng/mrand48.c

+ 1 - 1
src/prng/mrand48.c

@@ -6,7 +6,7 @@ extern unsigned short __seed48[7];
 
 long jrand48(unsigned short s[3])
 {
-	return __rand48_step(s, __seed48+3) >> 16;
+	return (int32_t)(__rand48_step(s, __seed48+3) >> 16);
 }
 
 long mrand48(void)