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.
Before, if the size is exactly the multiple of the page size, an extra padding
page is added for no reason. This commit fixes the logic and also uses the
page size obtained dynamically.
This is currently only implemented for Linux.
On Windows, ShellExecute should be used, but that should be done when it's
actually needed so it could be tested.
This replaces the scaled `destRect` with a version that uses doubles
correcting the rounding error that is causing a failure to properly
clear the black bar areas.
We used to increment the source buffer index by width * bpp, not by pitch.
This is incorrect and the root cause behind #670.
This is a regression that appeared in 196050bd23.
We now enumerate all IVSHMEM devices, sort them based on PCI bus, slot,
and function numbers, then index from the resulting order. This should
be consistent across boots.
To help the user identify the correct IVSHMEM device, we also print the
list of IVSHMEM devices on startup.
We implement nanotime by converting QueryPerformanceTimer output with
floating point arithmetic. This is necessary to preserve precision on
platforms where each tick is not an integer number of nanoseconds.
Furthermore, struct timespec is included C11 and appears to be supported
on Windows, so we no longer need to #ifdef it out.
When our window is destroyed, our timers are also destroyed. This causes our
attempt at destruction to fail. Instead, set MessageHWND to NULL in the
WM_DESTROY handler and don't try destroying the timers if the window is gone.
This allows us to set a callback to read a value out before it's about
to be overwritten which can be useful for things like calculating a
running average.
This so called "enhanced" event logic is completely flawed and can never
work correctly, better to strip it out and put our faith in windows to
handle the events for us.
And yes, I am fully aware I wrote the utter trash in the first place :)
Due to a failure to understand atomics when this code was originally
written it has a critical flaw with the fast path where an event could
be signalled when it should not be. This change set corrects this issue
by using atomic operations.
People often miss the warnings about invalid arguments in their command
line, this last minute patch attempts to address this by making
warnings, errors, fixme's and fatal errors stand out if stdout is a TTY.
We receive values as int64_t, but when we compute the sum, we store it as
int. This doesn't make sense as we eventually cast it to double when
computing the average. We should instead store the sum as int64_t.
Extensive profiling reveals that the glibc memcpy performs up to 2x
faster then the existing SIMD implementation that was in use here. This
patch also will copy large 1MB chunks if the pitch of the source and
destination match further increasing throughput.
Under windows text editors like to default to saving in UTF8 with a byte
order mask prefix preventing proper parsing of any option that is on the
first line of the file. Since the configuration file is only intended to
be plain ascii this change ignores all non-ascii characters solving this
issue.
This change adds an average function to time how long it takes the GPU
to copy and map the texture, and then uses this average to sleep for 80%
of this average lowering CPU usage and potentially decreasing lock
contention.
We previously used strstr, which can be prone to false positives when
the name of one extension is a substring of another extension.
This commit creates the helper function util_hasGLExt, which asserts
that the substring found in extension list is bounded by either spaces
or the beginning/end of the string.
Corners of table have '+' added, and adds new command line flag --rst-help,
which adds some extra formatting to the make it an rST compliant table for the
in-line docs.
When linking against libbfd.so, just passing libbfd.so to the compiler is
sufficient. When linking against the static version libbfd.a, however,
we must additionally link against libiberty.a and libz.a.
This commit adds a CMake helper to find the correct libraries that need
to be passed to link against libbfd correctly.
Essentially, debug.h defines printTrace as an empty macro when the macro
ENABLE_BACKTRACE is not defined, breaking the compilation of crash.c.
Fixed by defining a private macro for debug.h only to avoid clashing.
Calling abort() instead of exit() will generate a core dump, allowing gdb
to be used when the client crashes. This is desirable for the following
reasons:
1. gdb can be used to inspect the call stack with far more detail than the
our quick stack trace code, and also allows the access to the heap.
2. Our SIGSEGV handler is unable to use debug symbols for shared libraries,
making it impossible to debug bugs involving drivers and similar.
Clang doesn't know the warning option `format-truncation`, which GCC
falsely triggers on when calling vsnprintf. Further to this, GCC doesn't
understand the warning group `unknown-warning-option`, as such we must
disable these warnings in the cmake.
The Wayland display server is getting unwieldy due to the sheer size.
To make it easier to edit in the future, I split it into many components
based on logical boundaries.
This allows buffers to be shared between different asynchronous operations.
Once all users no longer need the buffer, it will be freed.
The motivation for this is being able to stream Wayland clipboard data
asynchronously to multiple clients. The buffer should only be freed after
the clipboard has changed and all ongoing transfer completes.
It used to be the case that you need to create dmabuf for kvmfr devices
to be able to mmap them. But after #457, this is no longer needed.
Directly mmaping the kvmfr device has the advantage of avoiding the
creation of a dmabuf, which has cost (e.g. the list of pages, the
scatterlist, etc.).
This will allow us to add an option to disable the screensaver on the client
when an application in the guest requests it. This behaviour may be useful
when the guest is doing media playback.
This commit uses the DbgHelp library which is shipped with Windows to
generate stack traces with function names and line number information.
It takes advantage of the pdb file generated by cv2pdb that is now
installed with looking-glass-host.exe.
These two functions were added in 9ff1859dc1
for Windows, but were never used on Linux.
Adding stubs will allow the host to compile on Linux.
These should be fixed later.
This makes it a compile-time error to call a function that semantically
takes no parameters with a nonzero number of arguments.
Previously, such code would still compile, but risk blowing up the stack
if a compiler chose to use something other than caller-cleanup calling
conventions.
Note: This only works with the KVMFR kernel module in a VM->VM
configuration. If this causes issues it can be disabled with the new
option `app:allowDMA`