Archive for May, 2010

const in C and C++

The const keyword has “constant” and “read-only variable” semantics in C++, but only “read-only variable” semantics in C.

To illustrate this difference, try compiling the following code:

const int x = 2;
int y[x];

This is not legal C, because x is not a compile-time constant semantically.

But it is legal C++, because const also has constant semantics and thus x is a compile-time constant.

Tags:

CPU Frequency Governor

Kernel documentation recommends “conservative” for laptops, citing latency reasons.

However, Intel explicitly recommends “ondemand” in its powertop. So does at least one Intel kernel developer.

OK. I have been using “conservative.” I decide to switch to “ondemand” from now on.

Reference

Tags: ,

bc quit

Happened to see this in fortune:

quit   When the quit statement is read, the  bc  processor
       is  terminated, regardless of where the quit state-
       ment is found.  For example, "if  (0  ==  1)  quit"
       will cause bc to terminate.
        -- seen in the manpage for "bc". Note the "if" statement's logic.

Then I checked the man page of bc. It really says that.

NPTL_KERN_VER

In Gentoo, this variable can be used to specify the lowest kernel version we want glibc to support. For example, I am completely certain I will never use a kernel older than 2.6.30 on my Gentoo box, so I may want to add NPTL_KERN_VER="2.6.30" to /etc/make.conf. This way, glibc will assume the kernel supports all features that 2.6.30 supports and remove fallback codes written for old kernels.

The default value for NPTL_KERN_VER has been 2.6.9 for years.

That will not make a real difference, though. By switching from 2.6.9 to 2.6.30, the size of my /lib/libc.so.6 reduced by approximately 20KiB, or 1.3%.

Tags: