pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:2072:       default:    SIMPLE_ARG_TYPE_ERROR("function_program", 1, "function");    }    pop_n_elems(args);    push_int(0);   }      PIKECLASS RandomInterface   { -  CVAR INT64 int_buffer; +  CVAR UINT64 int_buffer;    CVAR int buffer_bits;       INIT    {    THIS->int_buffer = 0;    THIS->buffer_bits = 0;    }       PIKEFUN string(8bit) random_string(int(0..))    prototype;
pike.git/src/builtin.cmod:2113:    }       /* Generates a number 0<=c<limit from random bits taken from the    int_buffer. Follows the NIST SP800-90A method for converting bit    sequences into bound numbers, described in section B.5.1.1, and    summarized as "throw away attempts that are too large". */    static INT_TYPE read_int(INT_TYPE limit)    {    if(limit <= 1) return 0;    int bits = my_log2(limit-1)+1; -  INT64 mask = (1L<<bits)-1; +  UINT64 mask = (((UINT64)1)<<bits)-1;    for(int i=0; i<1000; i++)    {    if(THIS->buffer_bits < bits)    fill_int_buffer();    INT_TYPE ret = THIS->int_buffer&mask;    THIS->int_buffer >>= bits;    THIS->buffer_bits -= bits;    if( ret < limit )    return ret;    }