# HG changeset patch # User jlarmour # Date 1079364142 0 # Node ID 8e86927fb40938952d25812969b117764d104f26 # Parent f8ef9a4bea92839488eb1de2cad8c6fcce18da59 * src/rand.cxx (srand): Use correct thread data type. (rand): Ditto. diff --git a/packages/language/c/libc/stdlib/current/ChangeLog b/packages/language/c/libc/stdlib/current/ChangeLog --- a/packages/language/c/libc/stdlib/current/ChangeLog +++ b/packages/language/c/libc/stdlib/current/ChangeLog @@ -1,3 +1,8 @@ +2004-02-17 Jonathan Larmour + + * src/rand.cxx (srand): Use correct thread data type. + (rand): Ditto. + 2003-02-24 Jonathan Larmour * cdl/stdlib.cdl: Fix doc link. diff --git a/packages/language/c/libc/stdlib/current/src/rand.cxx b/packages/language/c/libc/stdlib/current/src/rand.cxx --- a/packages/language/c/libc/stdlib/current/src/rand.cxx +++ b/packages/language/c/libc/stdlib/current/src/rand.cxx @@ -86,7 +86,9 @@ static int rand_trace = CYGNUM_LIBC_RAND // STATICS #ifdef CYGSEM_LIBC_PER_THREAD_RAND -static cyg_ucount32 rand_data_index=CYGNUM_KERNEL_THREADS_DATA_MAX; +static Cyg_Thread::cyg_data_index +rand_data_index=CYGNUM_KERNEL_THREADS_DATA_MAX; + static Cyg_Mutex rand_data_mutex CYGBLD_ATTRIB_INIT_PRI(CYG_INIT_LIBC); #else static unsigned int cyg_libc_rand_seed = CYGNUM_LIBC_RAND_SEED; @@ -113,10 +115,10 @@ rand( void ) rand_data_mutex.lock(); if (CYGNUM_KERNEL_THREADS_DATA_MAX==rand_data_index) { - // the kernel just throws an assert if this doesn't work // FIXME: Should use real CDL to pre-allocate a slot at compile // time to ensure there are enough slots rand_data_index = self->new_data_index(); + CYG_ASSERT(rand_data_index >= 0, "failed to allocate data index" ); // Initialize seed self->set_data(rand_data_index, CYGNUM_LIBC_RAND_SEED); @@ -228,11 +230,10 @@ srand( unsigned int seed ) rand_data_mutex.lock(); if (CYGNUM_KERNEL_THREADS_DATA_MAX==rand_data_index) { - // the kernel just throws an assert if this doesn't work // FIXME: Should use real CDL to pre-allocate a slot at compile // time to ensure there are enough slots rand_data_index = self->new_data_index(); - + CYG_ASSERT(rand_data_index >= 0, "failed to allocate data index" ); } rand_data_mutex.unlock(); } // if