As the ringbuffer is now in use for audio it makes sense to provide bulk
append and consume functions that are thread safe instead of adding
locking over all of the functions. This partially reverts the prior
commit that added the extra locking.
Sometimes, e.g. when xdg-open has to start the browser, the xdg-open
process can stay around until the browser exits, which freezes the
client. Instead, we should not wait for xdg-open to exit.
However, we can't simply not call wait, as that would leave the
xdg-open process around as a zombie. We could turn off the SIGCHLD
handler, but that's a global solution to a local problem. Instead, we
call setsid and fork again to detach the xdg-open process as if it's a
daemon, and let init take care of the reaping process.
Co-Authored-By: Tudor Brindus <me@tbrindus.ca>
The old code will not correctly report the number of threads on CPUs with
more than one processor group, i.e. when there are more than 64 logical
processors (threads).
This new function dumps all options marked as preset instead of dumping
individual sections. This should allow filter options to not be all grouped
into the [eglFilter] section.
This makes vector_push return a pointer to the pushed element.
It also allows the user to push a NULL pointer, which means allocating the
memory for the element but do not copy anything into it.
The signature for calloc is void *calloc(size_t num, size_t size), where num
is the number of elements to allocate, and size is the size. Therefore, to
allocate a single struct, we should pass 1 for num and the size of the struct
as size.
In some places, we use the opposite order, and we should flip it.
This lets us mark code as unreachable and signals the compiler that this
is the case with __builtin_unreachable().
We also mark DEBUG_FATAL as unreachable.
This, unlike the standard assert macro, is guaranteed to print the failed
assertion to our log file, and tests the assertion even with NDEBUG defined
so we can more easily catch failures in production binaries without crashing
the program.
The motivation of this is how MinGW handles assertion failures: it creates a
dialog window that the headless user will not be able to see, and blocks the
program from being restarted by the service. Since the failed assertion is
displayed in the dialog, it doesn't print anything to the log, making it
impossible to diagnose issues.