*/
int strncmp(char *Str1, char *Str2, size_t num)
{
- while(num-- && *Str1 && *Str1 == *Str2)
+ if(num == 0) return 0; // TODO: Check what should officially happen here
+ while(--num && *Str1 && *Str1 == *Str2)
Str1++, Str2++;
return *Str1-*Str2;
}
*/
Uint rand()
{
- #if 0
- Uint ret = giRandomState;
- int roll = randomState & 31;
- randomState = (randomState << roll) | (randomState >> (32-roll));
- randomState ^= 0x9A3C5E78;
- return ret;
- #else
Uint old = giRandomState;
+ // Get the next state value
giRandomState = (RANDOM_A*giRandomState + RANDOM_C) & 0xFFFFFFFF;
- if(giRandomState == old) {
- giRandomState += RANDOM_SPRUCE;
- }
- Log("giRandomState = 0x%x", giRandomState);
+ // Check if it has changed, and if it hasn't, change it
+ if(giRandomState == old) giRandomState += RANDOM_SPRUCE;
return giRandomState;
- #endif
}
EXPORT(timestamp);