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.
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.
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.
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>.
Get struct timespec from <time.h> in mono/io-layer/misc-private.h

POSIX defines struct timespec in time.> and struct timeval in sys/time.h.
Some operating systems have merged these headers, but this isn't required or
encouraged by POSIX.
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.
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.
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.
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.
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.
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.
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.
Use SIGPROF only if it is available

The SIGPROG signal is an XSI option and obsolescent in XSI. POSIX systems
are not required to have it.
Don't touch internal feature macros in eglib

The __GNU_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.
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.
Reliably determine whether thread-local storage is available

The configure script contains this crude test that determines whether the
__thread keyword is broken on this particular Linux distribution. This has
particular problems, such as the test running on non-Linux operating systems
and that it assumes that dynamic linking is available. However, my operating
system has perfectly usable thread-local storage and only static linking.
A better test would only run for Linux systems and only thread-local storage
is broken in this case if shared libraries can be built.
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.
define MONO_ARCH_NOMAP32BIT if !defined(MAP_32BIT)

This was a huge source of pain with a hidden solution. Assuming that mmap
always returns below 2 GiB on 64-bit systems is absolutely crazy, unless
extra effort is taken to ensure this is true. Some operating systems provide
the ugly hack MAP_32BIT that guarantees this and Mono is able to use this
mmap flag if it is available. However, if it is unavailable and the
operating system is not specifically listed as not having MAP_32BIT, then
Mono #defines it to 0 and pretends it works. This leads to mysterious
crashes and assertion failures inside the JIT engine. Mono is already able
to deal with a full 64-bit mmap, but only if MONO_ARCH_NOMAP32BIT is
defined. Rather than explicitly listing the sane operating systems in an
header, MONO_ARCH_NOMAP32BIT should be automatically defined if MAP_32BIT is
not available.
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.