This switches over to using the portability helpers that may
be needed on some platforms other than Linux. On Linux, however,
they are just macros to the standard implementation provided
by (g)libc.
If we're on non-Linux, we can use some portability fallbacks to
get similar behavior to Linux. I'm sure we can optimize this a
bit more for FreeBSD if someone with that installed wants to
come look at things and improve them.
There were some GCC'isms here that don't port well to mingw
(and likely other win32 compilers). Of note are the removal
of #pragma pack to instead use the GCC attributes or MSVC
declarations. Also we cannot be so liberal in our use of
bitflags, we need to use common types from neighbors.
We still generally only build on Linux from the Sysprof
project, but we can start to support other systems in the
capture format (with the possibility of being more general
for the UI later on too).
We want the capture format to be usable on systems other than
Linux so that it can be used in places like GTK. To do this,
we need a sendfile() fallback that can be portable/useful on
those systems.
FreeBSD has sendfile(), but the semantics differ slightly. This
implementation will walk up to the nearest page size and then
do page aligned pread()/write() which is likely good enough of
an implementation anyway.
Simple discovery of memory counters to display in the capture set. We will
want to refactor this type of stuff in the future into recording "gadgets"
that combine a data-collector with a visualization layer.
If we have not received a y-lower/upper value, then we can discover that
from the data set at the cost of an extra capture linear scan.
This is useful for the meomry source which can change the upper value
during the lifetime of a process.