| 1 | diff -u -r ../procps-ng-3.3.9/proc/sysinfo.c ./proc/sysinfo.c |
| 2 | --- ../procps-ng-3.3.9/proc/sysinfo.c 2013-09-11 13:57:56.000000000 +0200 |
| 3 | +++ ./proc/sysinfo.c 2014-07-06 08:35:27.678833325 +0200 |
| 4 | @@ -86,19 +86,27 @@ |
| 5 | /***********************************************************************/ |
| 6 | int uptime(double *restrict uptime_secs, double *restrict idle_secs) { |
| 7 | double up=0, idle=0; |
| 8 | +#ifndef __ANDROID__ |
| 9 | char *savelocale; |
| 10 | +#endif |
| 11 | |
| 12 | FILE_TO_BUF(UPTIME_FILE,uptime_fd); |
| 13 | +#ifndef __ANDROID__ |
| 14 | savelocale = strdup(setlocale(LC_NUMERIC, NULL)); |
| 15 | setlocale(LC_NUMERIC,"C"); |
| 16 | +#endif |
| 17 | if (sscanf(buf, "%lf %lf", &up, &idle) < 2) { |
| 18 | +#ifndef __ANDROID__ |
| 19 | setlocale(LC_NUMERIC,savelocale); |
| 20 | free(savelocale); |
| 21 | +#endif |
| 22 | fputs("bad data in " UPTIME_FILE "\n", stderr); |
| 23 | return 0; |
| 24 | } |
| 25 | +#ifndef __ANDROID__ |
| 26 | setlocale(LC_NUMERIC,savelocale); |
| 27 | free(savelocale); |
| 28 | +#endif |
| 29 | SET_IF_DESIRED(uptime_secs, up); |
| 30 | SET_IF_DESIRED(idle_secs, idle); |
| 31 | return up; /* assume never be zero seconds in practice */ |
| 32 | @@ -174,7 +182,9 @@ |
| 33 | double up_1, up_2, seconds; |
| 34 | unsigned long long jiffies; |
| 35 | unsigned h; |
| 36 | +#ifndef __ANDROID__ |
| 37 | char *savelocale; |
| 38 | +#endif |
| 39 | long hz; |
| 40 | |
| 41 | #ifdef _SC_CLK_TCK |
| 42 | @@ -185,8 +195,10 @@ |
| 43 | #endif |
| 44 | |
| 45 | wait_j = hirq_j = sirq_j = stol_j = 0; |
| 46 | +#ifndef __ANDROID__ |
| 47 | savelocale = strdup(setlocale(LC_NUMERIC, NULL)); |
| 48 | setlocale(LC_NUMERIC, "C"); |
| 49 | +#endif |
| 50 | do{ |
| 51 | FILE_TO_BUF(UPTIME_FILE,uptime_fd); sscanf(buf, "%lf", &up_1); |
| 52 | /* uptime(&up_1, NULL); */ |
| 53 | @@ -195,8 +207,10 @@ |
| 54 | FILE_TO_BUF(UPTIME_FILE,uptime_fd); sscanf(buf, "%lf", &up_2); |
| 55 | /* uptime(&up_2, NULL); */ |
| 56 | } while((long long)( (up_2-up_1)*1000.0/up_1 )); /* want under 0.1% error */ |
| 57 | +#ifndef __ANDROID__ |
| 58 | setlocale(LC_NUMERIC, savelocale); |
| 59 | free(savelocale); |
| 60 | +#endif |
| 61 | jiffies = user_j + nice_j + sys_j + other_j + wait_j + hirq_j + sirq_j + stol_j ; |
| 62 | seconds = (up_1 + up_2) / 2; |
| 63 | h = (unsigned)( (double)jiffies/seconds/smp_num_cpus ); |
| 64 | @@ -363,18 +377,26 @@ |
| 65 | /***********************************************************************/ |
| 66 | void loadavg(double *restrict av1, double *restrict av5, double *restrict av15) { |
| 67 | double avg_1=0, avg_5=0, avg_15=0; |
| 68 | +#ifndef __ANDROID__ |
| 69 | char *savelocale; |
| 70 | +#endif |
| 71 | |
| 72 | FILE_TO_BUF(LOADAVG_FILE,loadavg_fd); |
| 73 | +#ifndef __ANDROID__ |
| 74 | savelocale = strdup(setlocale(LC_NUMERIC, NULL)); |
| 75 | setlocale(LC_NUMERIC, "C"); |
| 76 | +#endif |
| 77 | if (sscanf(buf, "%lf %lf %lf", &avg_1, &avg_5, &avg_15) < 3) { |
| 78 | fputs("bad data in " LOADAVG_FILE "\n", stderr); |
| 79 | +#ifndef __ANDROID__ |
| 80 | free(savelocale); |
| 81 | +#endif |
| 82 | exit(1); |
| 83 | } |
| 84 | +#ifndef __ANDROID__ |
| 85 | setlocale(LC_NUMERIC, savelocale); |
| 86 | free(savelocale); |
| 87 | +#endif |
| 88 | SET_IF_DESIRED(av1, avg_1); |
| 89 | SET_IF_DESIRED(av5, avg_5); |
| 90 | SET_IF_DESIRED(av15, avg_15); |