ALL_CFLAGS += $(call check_gcc,-Wdeclaration-after-statement,)
ALL_CFLAGS += $(call check_gcc,-Wpadded,)
+ALL_CFLAGS += $(call check_gcc,-Wstrict-aliasing=2,)
+
+# Adding -fno-gcse might be good for those files which
+# use computed goto.
+#ALL_CFLAGS += $(call check_gcc,-fno-gcse,)
+
+# These are part of -O3 but we dislike -finline-functions.
+# Using -fno-inline-functions with -O3 would work too.
+ALL_CFLAGS += $(call check_gcc,-fweb,)
+ALL_CFLAGS += $(call check_gcc,-frename-registers,)
# Be 64-bit if at all possible. In a cross-compiling situation, one may
# do "make m64=-m32 lib64=lib" to produce 32-bit executables. DO NOT
static unsigned Page_size;
static unsigned page_to_kb_shift;
- /* SMP, Irix/Solaris mode, Linux 2.5.xx support */
-static int Cpu_tot,
- *Cpu_map;
+ /* SMP Irix/Solaris mode */
+static int Cpu_tot;
/* assume no IO-wait stats, overridden if linux 2.5.41 */
static const char *States_fmts = STATES_line2x4;
if (!fgets(buf, sizeof(buf), fp)) std_err("failed /proc/stat read");
cpus[Cpu_tot].x = 0; // FIXME: can't tell by kernel version number
cpus[Cpu_tot].y = 0; // FIXME: can't tell by kernel version number
- num = sscanf(buf, CPU_FMTS_JUST1,
+ num = sscanf(buf, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu",
&cpus[Cpu_tot].u,
&cpus[Cpu_tot].n,
&cpus[Cpu_tot].s,
);
if (num < 4)
std_err("failed /proc/stat read");
+
// and just in case we're 2.2.xx compiled without SMP support...
- if (Cpu_tot == 1) memcpy(cpus, &cpus[1], sizeof(CPU_t));
+ if (Cpu_tot == 1) {
+ cpus[1].id = 0;
+ memcpy(cpus, &cpus[1], sizeof(CPU_t));
+ }
// now value each separate cpu's tics
for (i = 0; 1 < Cpu_tot && i < Cpu_tot; i++) {
-#ifdef PRETEND4CPUS
- rewind(fp);
-#endif
if (!fgets(buf, sizeof(buf), fp)) std_err("failed /proc/stat read");
cpus[i].x = 0; // FIXME: can't tell by kernel version number
cpus[i].y = 0; // FIXME: can't tell by kernel version number
- num = sscanf(buf, CPU_FMTS_MULTI,
+ num = sscanf(buf, "cpu%u %Lu %Lu %Lu %Lu %Lu %Lu %Lu",
+ &cpus[i].id,
&cpus[i].u, &cpus[i].n, &cpus[i].s, &cpus[i].i, &cpus[i].w, &cpus[i].x, &cpus[i].y
);
if (num < 4)
/*###### Startup routines ##############################################*/
-#ifdef PRETEND4CPUS
-#define smp_num_cpus 4
-#endif
-
- /*
- * No mater what *they* say, we handle the really really BIG and
- * IMPORTANT stuff upon which all those lessor functions depend! */
+// No mater what *they* say, we handle the really really BIG and
+// IMPORTANT stuff upon which all those lessor functions depend!
static void before (char *me)
{
int i;
/* establish cpu particulars -- even bigger! */
Cpu_tot = smp_num_cpus;
- Cpu_map = alloc_r(NULL, sizeof(int) * Cpu_tot);
- for (i = 0; i < Cpu_tot; i++)
- Cpu_map[i] = i;
if (linux_version_code > LINUX_VERSION(2, 5, 41))
States_fmts = STATES_line2x5;
if (linux_version_code >= LINUX_VERSION(2, 6, 0)) // grrr... only some 2.6.0-testX :-(
char tmp[SMLBUFSIZ];
// display each cpu's states separately
for (i = 0; i < Cpu_tot; i++) {
- snprintf(tmp, sizeof(tmp), " Cpu%-2d:", Rc.mode_irixps ? i : Cpu_map[i]);
+ snprintf(tmp, sizeof(tmp), "Cpu%-3d:", smpcpu[i].id);
summaryhlp(&smpcpu[i], tmp);
}
}
// Development/Debugging defines -----------------------------------
//#define ATEOJ_REPORT // report a bunch of stuff, at end-of-job
//#define PRETEND2_5_X // pretend we're linux 2.5.x (for IO-wait)
-//#define PRETEND4CPUS // pretend we're smp with 4 ticsers (sic)
//#define PRETENDNOCAP // use a terminal without essential caps
//#define STDOUT_IOLBF // disable our own stdout _IOFBF override
typedef struct CPU_t {
TIC_t u, n, s, i, w, x, y; // as represented in /proc/stat
TIC_t u_sav, s_sav, n_sav, i_sav, w_sav, x_sav, y_sav; // in the order of our display
+ unsigned id; // the CPU ID number
} CPU_t;
// These 2 types support rcfile compatibility
"Usr", USR_FIELDS } \
} }
-// These are the possible fscanf formats used in /proc/stat
-// reads during history processing.
-// ( 5th number only for Linux 2.5.41 and above ) */
-#define CPU_FMTS_JUST1 "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu"
-#ifdef PRETEND4CPUS
-#define CPU_FMTS_MULTI CPU_FMTS_JUST1
-#else
-#define CPU_FMTS_MULTI "cpu%*d %Lu %Lu %Lu %Lu %Lu %Lu %Lu"
-#endif
// Summary Lines specially formatted string(s) --
// see 'show_special' for syntax details + other cautions.