1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #include <errno.h>
- #include <stdlib.h>
- #include <limits.h>
- #include <stdint.h>
- #include <sys/types.h>
- struct drand48_data __libc_drand48_data attribute_hidden;
- #ifdef __UCLIBC_MJN3_ONLY__
- #warning turn int __drand48_iterate into void
- #endif
- int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer) attribute_hidden;
- int __drand48_iterate (unsigned short int xsubi[3], struct drand48_data *buffer)
- {
- uint64_t X;
- uint64_t result;
-
- if (unlikely(!buffer->__init))
- {
- buffer->__a = 0x5deece66dull;
- buffer->__c = 0xb;
- buffer->__init = 1;
- }
-
- X = (uint64_t) xsubi[2] << 32 | (uint32_t) xsubi[1] << 16 | xsubi[0];
- result = X * buffer->__a + buffer->__c;
- xsubi[0] = result & 0xffff;
- xsubi[1] = (result >> 16) & 0xffff;
- xsubi[2] = (result >> 32) & 0xffff;
- return 0;
- }
|