diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -1094,8 +1094,8 @@ static void warnfon (void *ud, const char *message, int tocont) { | |||
1094 | 1094 | ||
1095 | /* | 1095 | /* |
1096 | ** A function to compute an unsigned int with some level of | 1096 | ** A function to compute an unsigned int with some level of |
1097 | ** randomness. Rely on Address Space Layout Randomization (if present), | 1097 | ** randomness. Rely on Address Space Layout Randomization (if present) |
1098 | ** current time, and clock. | 1098 | ** and the current time. |
1099 | */ | 1099 | */ |
1100 | #if !defined(luai_makeseed) | 1100 | #if !defined(luai_makeseed) |
1101 | 1101 | ||
@@ -1115,18 +1115,16 @@ static void warnfon (void *ud, const char *message, int tocont) { | |||
1115 | 1115 | ||
1116 | 1116 | ||
1117 | static unsigned int luai_makeseed (void) { | 1117 | static unsigned int luai_makeseed (void) { |
1118 | unsigned int buff[sof(void*) + sof(clock_t) + sof(time_t)]; | 1118 | unsigned int buff[sof(void*) + sof(time_t)]; |
1119 | unsigned int res; | 1119 | unsigned int res; |
1120 | unsigned int *b = buff; | 1120 | unsigned int *b = buff; |
1121 | clock_t c = clock(); | ||
1122 | time_t t = time(NULL); | 1121 | time_t t = time(NULL); |
1123 | void *h = buff; | 1122 | void *h = buff; |
1124 | addbuff(b, h); /* local variable's address */ | 1123 | addbuff(b, h); /* local variable's address */ |
1125 | addbuff(b, c); /* clock */ | ||
1126 | addbuff(b, t); /* time */ | 1124 | addbuff(b, t); /* time */ |
1127 | res = buff[0]; | 1125 | res = buff[0]; |
1128 | for (b = buff + 1; b < buff + sof(buff); b++) | 1126 | for (b = buff + 1; b < buff + sof(buff); b++) |
1129 | res += *b; | 1127 | res ^= (res >> 3) + (res << 7) + *b; |
1130 | return res; | 1128 | return res; |
1131 | } | 1129 | } |
1132 | 1130 | ||