This makes no functional difference, but does tidy up the code style a
bit. All other internal headers are included using quotes in other
files.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
The macros don’t seem to make things sufficiently much clearer that it
makes sense to provide them.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
This is a straightforward replacement using a single allocation, as the
number of array elements is always known ahead of time.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
This imposes an arbitrary limit of 2048B on the length of printf-ed log
messages, but is otherwise equivalent.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
This means we lose support for local timezones other than UTC, but is
otherwise equivalent.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Use `UINTPTR_MAX` to calculate the size of a pointer instead. This
assumes that all pointers are the same width.
It also means that the sysprof-capture code uses the pointer size of the
platform that libsysprof-capture was compiled on, rather than the
pointer size of the platform that GLib was compiled on. They seem
unlikely to differ.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
This is more of a direct port than previous replacements of `GArray`
(which have had linear growth): this one implements exponential growth
of the allocated array, as `GArray` does.
It uses `qsort()` to sort the array so that it can be binary searched as
before.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
There are typically 0 or 1 conditions applied to a cursor, and they’re
only applied at construction time, so it makes sense to only grow the
conditions array linearly when it’s used. This means the array may stay
as `NULL` throughout the lifetime of the cursor.
There’s currently no way to return an error from
`sysprof_capture_cursor_add_condition()`, so an allocation failure
results in an abort.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
libsysprof-capture no longer calls any of the GLib logging functions
which make use of it.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Calling this function without having registered the counter beforehand
seems reasonable to call a programmer error.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Use `strcmp()` and `strdup()` rather than `g_strcmp0()` and
`g_strdup()`. In the latter case, this makes no difference. In the
former case it means we potentially need to do some additional `NULL`
checks before calling it; although most of the call sites use
fixed-length arrays, so no `NULL` check is needed.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
The code is well-suited to directly using `calloc()` instead, since the
arrays never grow dynamically.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
This doesn’t change any of the sites which call
`sysprof_capture_condition_*()` in other files, but does change
`SysprofCaptureCondition` internally to handle OOM and return an error
code.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Another step away from GLib. This changes the OOM behaviour of the
library — previously it would immediately `abort()` on OOM. However, it
seems likely that given the small number of allocations
libsysprof-capture does, it should be able to recover from an OOM
situation more gracefully than larger libraries can — so the new
implementation tries to do that.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
If the system doesn’t provide `strlcpy()` (FreeBSD does, Linux doesn’t),
use an inbuilt copy instead.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Use the intrinsic atomics provided by the compiler, instead of GLib’s
wrapper around them. This should work for all modern compilers.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Another step towards dropping GLib as a dependency of
libsysprof-capture.
Unlike the previous commit which replaced GLib integer types with the
bitwise equivalent C standard types, `stdbool` is potentially a different
width from `gboolean`, so this is an ABI break.
It therefore involves some changes to callback functions in the tests
and tools, and in libsysprof.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
This is an almost entirely mechanical* conversion from (for example)
`gint` → `int`, `guint8` → `uint8_t`, etc.
It is not entirely complete, as many GLib functions are still used in
libsysprof-capture, which necessitate some use of GLib types.
It also avoids renaming `gboolean` → `bool` as that’s a slightly more
controversial change which will happen in the following commit.
*Code was manually realigned afterwards.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
As preparation for dropping the GLib dependency from libsysprof-capture,
move the `GSource` which links a `MappedRingBuffer` to a `GMainContext`
from libsysprof-capture to libsysprof.
This requires adding one new piece of API to libsysprof-capture to check
whether the `MappedRingBuffer` is empty.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
In preparation for dropping the GLib dependency from libsysprof-capture,
move the autocleanup definitions up to libsysprof. Add a new header for
them.
This is slightly awkward in the tools, which depend on
libsysprof-capture but not libsysprof. Rather than make them depend on
libsysprof (which might be disabled at configure time), include the
`sysprof-capture-autocleanups.h` file between source directories.
`SYSPROF_COMPILATION` needs to be defined for this to work.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
It has previously been implicitly pulled in by libsysprof-capture, but
that will change in future.
Correspondingly, add some missing `glib.h` includes.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
It has previously been implicitly pulled in by libsysprof-capture, but
that will change in future.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
`reader` can be `NULL`, but the `NULL` check was done after potentially
dereferencing it.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
It has previously been implicitly pulled in by libsysprof-capture, but
that will change in future.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Helps: #40
Add a button to open capture files in headerbar. This caters to the
suggested usage of 'sysprof-cli' by exposing the funcitonality in a
prominent place.