Ignore:
Timestamp:
Jun 2, 2020, 11:37:23 AM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
04b4a71
Parents:
3d46f01
Message:

comment random function about returning int, and reduce includes for stdlib.hfa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/stdlib.hfa

    r3d46f01 r4e7c0fc0  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 26 22:50:08 2020
    13 // Update Count     : 439
     12// Last Modified On : Tue Jun  2 09:05:16 2020
     13// Update Count     : 450
    1414//
    1515
     
    1919#include "bits/align.hfa"
    2020
    21 #include <malloc.h>
    2221#include <stdlib.h>                                                                             // *alloc, strto*, ato*
     22#include <heap.hfa>
    2323
    2424// Reduce includes by explicitly defining these routines.
    2525extern "C" {
     26        void * memalign( size_t alignment, size_t size );       // malloc.h
     27        void * pvalloc( size_t size );                                          // malloc.h
    2628        void * memset( void * dest, int fill, size_t size ); // string.h
    2729        void * memcpy( void * dest, const void * src, size_t size ); // string.h
     
    299301extern "C" {                                                                                    // override C version
    300302        void srandom( unsigned int seed );
    301         long int random( void );
     303        long int random( void );                                                        // GENERATES POSITIVE AND NEGATIVE VALUES
     304        // For positive values, use unsigned int, e.g., unsigned int r = random() % 100U;
    302305} // extern "C"
    303306
     
    306309        long int random( long int u ) { if ( u < 0 ) return random( u, 0 ); else return random( 0, u ); } // [0,u)
    307310        unsigned long int random( void ) { return lrand48(); }
     311        unsigned long int random( unsigned long int u ) { return lrand48() % u; } // [0,u)
    308312        unsigned long int random( unsigned long int l, unsigned long int u ) { if ( u < l ) [u, l] = [l, u]; return lrand48() % (u - l) + l; } // [l,u)
    309         unsigned long int random( unsigned long int u ) { return lrand48() % u; } // [0,u)
    310313
    311314        char random( void ) { return (unsigned long int)random(); }
Note: See TracChangeset for help on using the changeset viewer.