Use <sys/select.h> to get select

POSIX mandates that select is declared in <sys/select.h> (and in the header
<sys/time.h> for compatibility). It would be best to include the new header
if it is available. This is already done throughout the source tree, though
not in all instances.

This change is released under the MIT/X11 license.
Use <poll.h> to get poll rather than <sys/poll.h>

POSIX specifies <poll.h> as the standard header that declares the poll
function. Many systems provide <sys/poll.h> to be compatible with historical
practice. Prefer the <poll.h> header over <sys/poll.h> if it is available.

This change is released under the MIT/X11 license.
Only include the <sys/param.h> header if available

The <sys/param.h> header is non-standard and usually not required if it isn't
available.

This change is released under the MIT/X11 license.
Remove unnecessary <sys/syscall.h> inclusion

Only mono/metadata/icall.c and mono/metadata/filewatcher.c include the
mono/metadata/filewatcher.h header and none of them depend on the contents
of the non-standard header <sys/syscall.h>.

This change is released under the MIT/X11 license.
Get struct timespec from <time.h> in mono/io-layer/misc-private.h

POSIX defines struct timespec in time.h and struct timeval in sys/time.h.
Some operating systems have merged these headers, but this isn't required or
encouraged by POSIX.

This change is released under the MIT/X11 license.
Use S_IWUSR instead of S_IWRITE

The S_IWRITE macro is a non-standard macro provided by some operating
systems for compatibility with BSD. POSIX specifics a standard macro with
identical semantics with the name S_IWUSR.

This change is released under the MIT/X11 license.
Avoid unused function warning in mono/io-layer/io.c

The get_fstypename function is only used by the GetVolumeInformation
function. It should be wrapped in the same #if conditional to avoid a
warning if the preprocessor conditional isn't true.

This change is released under the MIT/X11 license.
Avoid unused function warning in mono/profiler/proflog.c

The dump_ubin function is only used by the elf_dl_callback function. It
should be wrapped in the same #if conditional to avoid a warning if the
preprocessor conditional isn't true.

This change is released under the MIT/X11 license.
Use MAP_FAILED instead of (void*)-1

The MAP_FAILED macro is the standard return value of mmap() upon failure and
it is allowed to have other values than (void*)-1.

This change is released under the MIT/X11 license.
Avoid non-standard BSD types in mono/io-layer/wapi_glob.c

The u_char, u_short and u_int types are non-standard and no system headers
are required to provide them. There are no particular use for them and the
builtin standard types will do just as well.

This change is released under the MIT/X11 license.
Remove MONO_SIZEOF_SUNPATH

The configure script determines the size of the sun_path member in struct
sockaddr_un. However the test is broken during cross-compilation (with a
comment that there is no macro to determine the size of struct members at
configure time) and MONO_SIZEOF_SUNPATH defaults to 0 (leading to buffer
underflows and overflows). There is no reason to determine this at configure
time when a simple traditional sizeof will do the job at compile time.

This change is released under the MIT/X11 license.
Use memset instead of bzero

There is no standard bzero function, only the standard memset function, and
Mono does not declare its own bzero function.

This change is released under the MIT/X11 license.
Use SIGPROF only if it is available

The SIGPROF signal is an XSI option and obsolescent in XSI. POSIX systems
are not required to have it.

This change is released under the MIT/X11 license.
Don't touch internal feature macros in eglib

The __USE_GNU macro is an internal macro used by glibc to enable the GNU
extensions. Programs are instead meant to use the _GNU_SOURCE macro before
including any system header.

This change is released under the MIT/X11 license.
Print pid_t's portably in mono/metadata/attach.c

The pid_t type is required by POSIX to be a signed integer type (and that it
isn't wider than long in at least one programming environment). Mono has a
bunch of issues with 64-bit pids at the present, this is a start. Cast the
pid to the largest available signed type before printing it.

This change is released under the MIT/X11 license.
Remove test whether thread-local storage works in shared libraries

This test was added in 2004 to work around buggy Linux distributions and is
not needed today. The test caused problems as it also ran on non-Linux
operating systems and assumed dynamic linking was available. This caused it
to mistakenly decide thread-local storage was unavailable on operating
systems with no dynamic linking (but perfectly usable thread-local storage).

This change is released under the MIT/X11 license.
Remove Mono_Posix_Syscall_utimes_bad

Welcome to the world of tomorrow! It's been almost a decade since this was
made obsolete in 2005. Nothing uses this function any longer. Additionally
it is completely broken as utimes takes a pointer to an array with two
timevals, but the code passes only a pointer to a single timeval.

This change is released under the MIT/X11 license.
define MONO_ARCH_NOMAP32BIT if !defined(MAP_32BIT)

Mono uses MAP_32BIT if available to ensure that the result of mmap is always
below 2 GiB. This is used to emit shorter call sequences that are faster
than a full 64-bit jump. However, MAP_32BIT was previously #defined to 0 if
it is unavailable. The MONO_ARCH_NOMAP32BIT macro must be defined if the
MAP_32BIT constant is unavailable, otherwise 32-bit relative jumps will be
generated even if the distance is more than 2 GiB (leading to crashes and
assertion failures due to pointer truncation).

However, the MONO_ARCH_NOMAP32BIT macro was only defined for particular
operating systems rather being determined by whether MAP_32BIT is present.
This causes the pointer truncation problems when ported to new operating
systems for amd64. This commit removes the per-operating-system declaration
of MONO_ARCH_NOMAP32BIT. This will work as long as these operating systems
did not have MAP_32BIT, or if they had MAP_32BIT and it makes mmap to always
return a pointer below 2 GiB (as opposed to being a hint or preference).

This change is released under the MIT/X11 license.
Restore the null garbage collector

I had to use the null garbage collector due to boehm being troublesome. The
code appears unmaintained but I can see a recent git commit enabled support
again. However, I had to do more than that to get it working. I'm really not
sure how semantically correct this is and it needs review from an expert in
how threads and garbage collection interplay in Mono. It seems very odd that
various attributes (such as its short id) about the main thread is
initialized as a side effect of initializing the garbage collection. The
mono_thread_info_attach was needed to prevent a crash.

This change is released under the MIT/X11 license.