Annotation of parser3/src/include/pa_random.h, revision 1.1

1.1     ! misha       1: /** @file
        !             2:        Parser: random related functions.
        !             3: 
        !             4:        Copyright (c) 2001-2008 ArtLebedev Group (http://www.artlebedev.com)
        !             5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
        !             6: */
        !             7: 
        !             8: #ifndef PA_RANDOM_H
        !             9: #define PA_RANDOM_H
        !            10: 
        !            11: static const char * const IDENT_RANDOM_H="$Date: 2009-01-12 07:42:44 $";
        !            12: 
        !            13: #include "pa_types.h"
        !            14: 
        !            15: #define MAX_UINT 0xFFFFFFFFu
        !            16: 
        !            17: void random(void *buffer, size_t size);
        !            18: 
        !            19: static inline int _random(uint top) {
        !            20:        uint raw;
        !            21:        random(&raw, sizeof(raw));
        !            22:        return int(double(raw) / MAX_UINT * top );
        !            23: }
        !            24: 
        !            25: /// to hell with extra bytes on 64bit platforms
        !            26: struct uuid {
        !            27:        unsigned int    time_low;
        !            28:        unsigned short  time_mid;
        !            29:        unsigned short  time_hi_and_version;
        !            30:        unsigned short  clock_seq;
        !            31:        unsigned char   node[6];
        !            32: };
        !            33: 
        !            34: uuid get_uuid();
        !            35: 
        !            36: #endif

E-mail: