summaryrefslogtreecommitdiff
path: root/pthread_support.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-01-24 05:39:47 +0100
committerIvan Maidanski <ivmai@mail.ru>2012-01-26 17:46:47 +0100
commitd55ae3329cc612715b0506ed814601123a58d4e7 (patch)
tree1a2bc53add154332af4d69745763ac3ef0c9e7c7 /pthread_support.c
parent90b20555e3737ac09cdd9c7333136aceafb939cd (diff)
Fix GC_get_nprocs (Linux) returned variable type
* pthread_support.c (GC_get_nprocs): Change "result" local variable type to int from word (to match returned value type); remove redundant cast; initialize "result" variable just before its use.
Diffstat (limited to 'pthread_support.c')
-rw-r--r--pthread_support.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/pthread_support.c b/pthread_support.c
index 90af826..82db8ea 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -719,11 +719,7 @@ STATIC void GC_remove_all_threads_but_me(void)
/* the real one. */
char stat_buf[STAT_BUF_SIZE];
int f;
- word result = 1;
- /* Some old kernels only have a single "cpu nnnn ..." */
- /* entry in /proc/stat. We identify those as */
- /* uniprocessors. */
- int i, len;
+ int result, i, len;
f = open("/proc/stat", O_RDONLY);
if (f < 0) {
@@ -733,17 +729,22 @@ STATIC void GC_remove_all_threads_but_me(void)
len = STAT_READ(f, stat_buf, STAT_BUF_SIZE);
close(f);
+ result = 1;
+ /* Some old kernels only have a single "cpu nnnn ..." */
+ /* entry in /proc/stat. We identify those as */
+ /* uniprocessors. */
+
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]);
- if (cpu_no >= (int)result)
+ if (cpu_no >= result)
result = cpu_no + 1;
}
}
return result;
}
-#endif /* GC_LINUX_THREADS && !NACL */
+#endif /* GC_LINUX_THREADS && !PLATFORM_ANDROID && !NACL */
/* We hold the GC lock. Wait until an in-progress GC has finished. */
/* Repeatedly RELEASES GC LOCK in order to wait. */