Changeset 473 for trunk/libs/mini-libc/stdlib.c
- Timestamp:
- Aug 21, 2018, 6:01:01 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/mini-libc/stdlib.c
r457 r473 28 28 #include <almosmkh.h> 29 29 #include <stdio.h> 30 31 ////////////////////////////////////////////////////////////////////////////////////////// 32 // Global variables 33 ////////////////////////////////////////////////////////////////////////////////////////// 34 35 unsigned int rand_seed_value = 1; // set by srand() , used by rand() 30 36 31 37 ////////////////////////// … … 121 127 get_cycle( &cycle ); 122 128 123 unsigned int x = (unsigned int)cycle ;124 125 if ((x & 0xF ) > 7)126 { 127 return (x*x & 0xFFFF);129 unsigned int x = (unsigned int)cycle * rand_seed_value; 130 131 if ((x & 0xFF) > 0x7F) 132 { 133 return (x*x & RAND_MAX); 128 134 } 129 135 else 130 136 { 131 return (x*x*x & 0xFFFF);137 return (x*x*x & RAND_MAX); 132 138 } 133 139 } … … 136 142 void srand( unsigned int seed ) 137 143 { 138 printf("\n[ERROR] in %s : not implemented yet : do nothing\n", __FUNCTION__ );144 rand_seed_value = seed; 139 145 } 140 146
Note: See TracChangeset
for help on using the changeset viewer.