Ignore:
Timestamp:
Aug 21, 2018, 6:01:01 PM (6 years ago)
Author:
alain
Message:

Fix several GCC warning related to the -Wextra compilation option.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/mini-libc/stdlib.c

    r457 r473  
    2828#include <almosmkh.h>
    2929#include <stdio.h>
     30
     31//////////////////////////////////////////////////////////////////////////////////////////
     32//           Global variables                   
     33//////////////////////////////////////////////////////////////////////////////////////////
     34
     35unsigned int  rand_seed_value = 1;   // set by srand() , used by rand()
    3036
    3137//////////////////////////
     
    121127    get_cycle( &cycle );
    122128
    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);
    128134    }
    129135    else
    130136    {
    131         return (x*x*x & 0xFFFF);
     137        return (x*x*x & RAND_MAX);
    132138    }
    133139}
     
    136142void srand( unsigned int seed )
    137143{
    138     printf("\n[ERROR] in %s : not implemented yet : do nothing\n", __FUNCTION__ );
     144    rand_seed_value = seed;
    139145}
    140146
Note: See TracChangeset for help on using the changeset viewer.