Fix QThread::idealThreadCount on Unix if sysconf or sysctl fails

The BSD4 code (including OS X) calls sysctl and if that fails, it sets
cores to -1. Similarly, the generic Unix code calls sysconf() and
assigns the returned value to cores, but sysconf can return -1 on
failure.

Change-Id: I9e521d366e9c42f36c2ba20a37e7a74539ddb8f4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Make sure we don't try to ask QByteArray to allocate too much

QFile::readAll could be asked to read a file that is over 1 GB in size
and thus cause an assertion:

ASSERT failure in qAllocMore: "Requested size is too large!", ...

The idea behind the existing code was correct, but the value was wrong.
It prevented overflow of the integer size request, but didn't prevent
overflowing the storage size.

Change-Id: I072e6e419f47b639454f3fd96deb0f88d03e960c
Reviewed-by: Martin Smith <martin.smith@digia.com>
Use the GCC and Clang __builtin_bswap intrinsics in qbswap

Glibc will use the intrinsics for 32- and 64-bit, but didn't for 16-bit
(probably because GCC didn't document it until version 4.8), so this
commit will make us access the intrinsics directly the intrisincs for
all type sizes.

Additionally, this will get us access to the compiler intrisics even
without Glibc, such as when building against uclibc or Bionic.

Another benefit is that both Clang and ICC will use the MOVBE
instruction on Atom and Haswell architectures.

Change-Id: I39d1891f479887d719d69ebe4ac92ac9bfeda8af
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>