Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c718bda in mainline


Ignore:
Timestamp:
2018-01-15T21:40:49Z (4 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
dbbbe75b
Parents:
ba29018
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-15 21:20:07)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-15 21:40:49)
Message:

Use standard names for rand() and srand().

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tetris/tetris.c

    rba29018 rc718bda  
    156156const struct shape *randshape(void)
    157157{
    158         const struct shape *tmp = &shapes[random() % 7];
     158        const struct shape *tmp = &shapes[rand() % 7];
    159159        int i;
    160         int j = random() % 4;
     160        int j = rand() % 4;
    161161       
    162162        for (i = 0; i < j; i++)
     
    171171       
    172172        gettimeofday(&tv, NULL);
    173         srandom(tv.tv_sec + tv.tv_usec / 100000);
     173        srand(tv.tv_sec + tv.tv_usec / 100000);
    174174}
    175175
  • uspace/dist/src/c/demos/tetris/tetris.c

    rba29018 rc718bda  
    157157const struct shape *randshape(void)
    158158{
    159         const struct shape *tmp = &shapes[random() % 7];
     159        const struct shape *tmp = &shapes[rand() % 7];
    160160        int i;
    161         int j = random() % 4;
     161        int j = rand() % 4;
    162162       
    163163        for (i = 0; i < j; i++)
     
    172172       
    173173        gettimeofday(&tv, NULL);
    174         srandom(tv.tv_sec + tv.tv_usec / 100000);
     174        srand(tv.tv_sec + tv.tv_usec / 100000);
    175175}
    176176
  • uspace/lib/c/generic/stdlib.c

    rba29018 rc718bda  
    3535#include <stdlib.h>
    3636
    37 static long glbl_seed = 1;
     37static int glbl_seed = 1;
    3838
    39 long int random(void)
     39int rand(void)
    4040{
    4141        return glbl_seed = ((1366 * glbl_seed + 150889) % RAND_MAX);
    4242}
    4343
    44 void srandom(unsigned int seed)
     44void srand(unsigned int seed)
    4545{
    4646        glbl_seed = seed % RAND_MAX;
  • uspace/lib/c/generic/uuid.c

    rba29018 rc718bda  
    5252        /* XXX This is a rather poor way of generating random numbers */
    5353        gettimeofday(&tv, NULL);
    54         srandom(tv.tv_sec ^ tv.tv_usec);
     54        srand(tv.tv_sec ^ tv.tv_usec);
    5555
    5656        for (i = 0; i < uuid_bytes; i++)
    57                 uuid->b[i] = random();
     57                uuid->b[i] = rand();
    5858
    5959        /* Version 4 UUID from random or pseudo-random numbers */
  • uspace/lib/c/include/stdlib.h

    rba29018 rc718bda  
    4242#define RAND_MAX  714025
    4343
    44 #define rand()       random()
    45 #define srand(seed)  srandom(seed)
    46 
    47 extern long int random(void);
    48 extern void srandom(unsigned int seed);
     44extern int rand(void);
     45extern void srand(unsigned int seed);
    4946
    5047extern void abort(void) __attribute__((noreturn));
  • uspace/lib/posix/source/stdlib.c

    rba29018 rc718bda  
    377377int posix_rand(void)
    378378{
    379         return (int) random();
     379        return (int) rand();
    380380}
    381381
     
    387387void posix_srand(unsigned int seed)
    388388{
    389         srandom(seed);
     389        srand(seed);
    390390}
    391391
  • uspace/srv/net/tcp/ncsim.c

    rba29018 rc718bda  
    8181        return;
    8282
    83         if (0 /*random() % 4 == 3*/) {
     83        if (0 /*rand() % 4 == 3*/) {
    8484                /* Drop segment */
    8585                log_msg(LOG_DEFAULT, LVL_ERROR, "NCSim dropping segment");
     
    9494        }
    9595
    96         sqe->delay = random() % (1000 * 1000);
     96        sqe->delay = rand() % (1000 * 1000);
    9797        sqe->epp = *epp;
    9898        sqe->seg = seg;
Note: See TracChangeset for help on using the changeset viewer.