on x86_64 use long instead of long long for 64bit posix types

following glibc use the lowest rank 64bit integer type for ino_t etc.
this is eg. useful for printf format compatibility
fix ioctl _IOR, _IOW, etc macros to avoid signed overflow (2<<30)
fix the prototype of settimeofday to follow the original BSD declaration
Merge remote-tracking branch 'nsz/review'
ensure that thread dtv pointer is never null to optimize __tls_get_addr
align stack properly for calling global ctors/dtors on x86[_64]

failure to do so was causing crashes on x86_64 when ctors used SSE,
which was first observed when ctors called variadic functions due to
the SSE prologue code inserted into every variadic function.
refactor scanf core to use common code path for all string formats

the concept here is that %s and %c are essentially special-cases of
%[, with some minimal additional special-casing.

aside from simplifying the code and reducing the number of complex
code-paths that would need changing to make optimizations later, the
main purpose of this change is to simplify addition of the 'm'
modifier which causes scanf to allocate storage for the string being
read.
simplify some logic in scanf and remove redundant invalid-format check