Index: libjava/java/lang/natObject.cc =================================================================== RCS file: /cvs/gcc/gcc/libjava/java/lang/natObject.cc,v retrieving revision 1.26 diff -u -r1.26 natObject.cc --- libjava/java/lang/natObject.cc 2 Mar 2003 00:02:52 -0000 1.26 +++ libjava/java/lang/natObject.cc 7 Mar 2003 01:38:28 -0000 @@ -313,11 +313,23 @@ // spinning may be profitable. // This should really use a suitable autoconf macro. // False is the conservative answer, though the right one is much better. +#if defined(__i386__) && defined(__linux__) + // FIXME - Needed only for the hack below. + extern "C" int GC_get_nprocs(); +#endif + static bool is_mp() { #ifdef _SC_NPROCESSORS_ONLN - long nprocs = sysconf(_SC_NPROCESSORS_ONLN); +# if defined(__i386__) && defined(__linux__) + // FIXME - sysconf(_SC_NPROCESSORS_ONLN) fails for statically linked + // executables under linux/i386 in e.g. RH 8.0. This hack should go away + // when that problem is fixed. + int nprocs = GC_get_nprocs(); +# else + long nprocs = sysconf(_SC_NPROCESSORS_ONLN); +# endif return (nprocs > 1); #else return false; @@ -351,7 +363,7 @@ obj_addr_t address; // Object to which this lock corresponds. // Should not be traced by GC. // Cleared as heavy_lock is destroyed. - // Together with the rest of the hevy lock + // Together with the rest of the heavy lock // chain, this is protected by the lock // bit in the hash table entry to which // the chain is attached. @@ -457,12 +469,12 @@ }; #ifndef JV_SYNC_TABLE_SZ -# define JV_SYNC_TABLE_SZ 2048 +# define JV_SYNC_TABLE_SZ 2048 // Must be power of 2. #endif hash_entry light_locks[JV_SYNC_TABLE_SZ]; -#define JV_SYNC_HASH(p) (((long)p ^ ((long)p >> 10)) % JV_SYNC_TABLE_SZ) +#define JV_SYNC_HASH(p) (((long)p ^ ((long)p >> 10)) & (JV_SYNC_TABLE_SZ-1)) // Note that the light_locks table is scanned conservatively by the // collector. It is essential the the heavy_locks field is scanned. Index: boehm-gc/linux_threads.c =================================================================== RCS file: /cvs/gcc/gcc/boehm-gc/linux_threads.c,v retrieving revision 1.20 diff -u -r1.20 linux_threads.c --- boehm-gc/linux_threads.c 29 Mar 2002 22:52:12 -0000 1.20 +++ boehm-gc/linux_threads.c 7 Mar 2003 01:38:28 -0000 @@ -1021,7 +1021,14 @@ for (i = 0; i < len - 100; ++i) { if (stat_buf[i] == '\n' && stat_buf[i+1] == 'c' && stat_buf[i+2] == 'p' && stat_buf[i+3] == 'u') { - int cpu_no = atoi(stat_buf + i + 4); + /* int cpu_no = atoi(stat_buf + i + 4); */ + int cpu_no = 0; + int j = i + 4; + while (stat_buf[j] >= '0' & stat_buf[j] <= '9') { + cpu_no *= 10; + cpu_no += (stat_buf[j] - '0'); + ++j; + } if (cpu_no >= result) result = cpu_no + 1; } }