libc/libstdc++ sanity checks

Addresses #4081.

These are always enabled on all platforms, with the exception of the FD_SET test, which is irrelevant on platforms that don't use select().

Great care was taken to ensure that the tests (memcpy in particular) are not optimized away by the compiler, which would obviously defeat the purpose of the runtime checks.