diff packages/kernel/current/src/common/thread.cxx @ 549:7002f6e48db9

* src/common/thread.cxx: Fix potential warning and overflow with CYGNUM_KERNEL_THREADS_DATA_MAX == 32.
author jlarmour
date Thu, 30 Jan 2003 07:02:53 +0000
parents a65a4055f146
children 5d7f57fd1729
line wrap: on
line diff
--- a/packages/kernel/current/src/common/thread.cxx
+++ b/packages/kernel/current/src/common/thread.cxx
@@ -1055,7 +1055,9 @@ Cyg_Thread::deliver_exception(
 
 // Set the data map bits for each free slot in the data array.
 cyg_ucount32 Cyg_Thread::thread_data_map = (~CYGNUM_KERNEL_THREADS_DATA_ALL) &
-                                           ((1<<CYGNUM_KERNEL_THREADS_DATA_MAX)-1);
+             (1+(((cyg_ucount32)(1<<(CYGNUM_KERNEL_THREADS_DATA_MAX-1))-1)<<1));
+// the second expression is equivalent to ((1<<CYGNUM_KERNEL_THREADS_DATA_MAX)-1);
+// but avoids overflow. The compiler will compile to a constant just fine.
 
 Cyg_Thread::cyg_data_index
 Cyg_Thread::new_data_index()