`sizeof` was incorrectly used to get the length of an string in an array
of char pointers (array of strings), which always returns the system's
pointer size (8 on 64bit) instead of the actual string length.
Was fixed by using `strlen` instead.
Additionally the final step that appended the returning array of strings
with another array of strings, also used an incorrect `memcpy` function
to copy the elements.
Was fixed by using an explicit for loop.
And I also replaced the 'length' variables' type's with the proper
`size_t` type instead of `int`, where possible.
Issue and patch from:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299077
Signed-off-by: b-aaz <b-aazbsd@proton.me>
These code pathes have never been actually used, thus no need to
carry them around for any longer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
* didn't compile since 2014 (commit 21b216ad6)
* based on vm86(), which is only availble on Linux i386/i686
* obsoleted by x86emu
Thus no need to carry around broken code pathes any longer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
It seems that ancient DG/UX systems needed some special workarounds,
which of we only have some remains left that are never compiled.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Since commit a94dd9536 ("modesetting: add support for TearFree page flips"),
whenever TearFree and PageFlip is simultaneously enabled (which is the
default now), the driver does enable DRM universal plane support, just
as when atomic modesetting is enabled.
Leasing RandR / DRM outputs with universal planes enabled requires
also adding the drm_plane object to the set of leased objects,
otherwise the drmModeCreateLease() ioctl will fail.
Adding a drm_plane object under this condition was omitted, so fix
this omission, and thereby fix RandR output leasing.
Fixes: a94dd9536 ("modesetting: add support for TearFree page flips")
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2332>
(cherry picked from commit f37bd8de26)
Two if conditions compressed into one.
Two open() marked as ignored by SIM115 (use context manager for opening files)
because it'd require too much restructuring.
And one open() ... close() changed to a context manager, the diff
is the reindentation of everything between open and close.
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2327>
(cherry picked from commit eb9292efdb)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Don't have it open another one
This fixes a segfault when the render card is different from
the scanout card, and glamor uses the fast gbm import path.
If https://github.com/X11Libre/xserver/issues/2645
applies to Xmodesetting, this probably fixes it.
This is also a resource usage optimization,
since glamor doesn't allocate another gbm device
when Xmodesetting already allocates a perfectly usable one.
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
It's just an ancient relic from previous century, that's ever been helpful
in a few corner cases - and can be easily replaced by -config / -configdir
cmdline options.
OTOH, it's a potential security risk for Xservers running with suid root
(eg. if it somehow fails to detect/switch to the restricted mode)
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Without HAS_LIBDISPATCH (macOS < 10.6) these static callbacks are
never referenced, which triggers -Wunused-function and breaks the
build with -Dwerror=true:
- sendX11NSEvent_fptr() in X11Application.m
- socketHandoff_fptr() in bundle-main.c
- windowHashInsert(), windowHashRemove(), windowLookup() and
windowGet() in xprFrame.c
socketHandoff_fptr() calls socket_handoff(), which only exists with libdispatch
(otherwise it's socket_handoff_thread()).
Also move the WindowLookupCtx in xprRestackFrame() into the
libdispatch branch, since it's unused otherwise, like it's already
done in xprGetXWindow().
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
The _fptr suffix marked helpers that were only called as function
pointers through libdispatch. With the pre-10.6 fallbacks they're
now also called directly, so the suffix is misleading.
sendX11NSEvent_fptr() keeps its name: it's still only used through
dispatch_async_f().
Suggested-by: Aggelos Tselios <aggelostselios777@gmail.com>
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
xprCreateFrame() passed &pFrame->wid, a (void *), straight to
xp_create_window() through a (xp_window_id *) cast. xp_window_id is
32 bits, so only half of the 64-bit RootlessFrameID word was written;
the other half was left uninitialized. window_hash is created with
x_hash_table_new(NULL, NULL, NULL, NULL), so keys are compared by exact
pointer identity -- a dirty high word therefore makes subsequent
lookups miss, and also trips the
assert(sv == uv);
in x_cvt_vptr_to_uint(). On a big-endian LP64 target (ppc64) it is
worse still: the 32-bit id is written into the high half of the word,
so the truncating conversions used everywhere else (MAKE_WINDOW_ID(),
x_cvt_vptr_to_uint()) read the wrong half entirely.
This is invisible on ILP32 (32-bit ppc/i386), where void * and
unsigned int are the same width and the raw store and the converted
value have identical bit patterns -- which is why 10.6/ppc worked while
10.5/ppc64 crashed launching a client.
Write the id through a real xp_window_id and zero-extend it into
pFrame->wid, so the word is fully defined regardless of ABI or byte
order, and key window_hash consistently in both the libdispatch and
non-libdispatch paths. With pFrame->wid clean at its single point of
origin, the downstream MAKE_WINDOW_ID()/x_cvt_vptr_to_uint()
truncations are correct and the assert no longer needs to be disabled
on ppc64.
Signed-off-by: Sergey Fedorov <vital.had@gmail.com>
XvMC is only helpful for old MPEG2 decoding (and here only some specific
part, the motion compensation). It's only supported by few cards, and needs
special client-side drivers, which need to have direct and pretty low-level
(non-DRI) GPU access (usually involving root access).
Since it's local-only anyways, modern clients can use generic GPU shaders
for various video formats (via standard DRI/mesa) and send whole frames.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Tab indentation, missing spaces before braces and after commas, a
function brace on the declaration line, stray blank lines and a
misaligned comment end.
Also end the "failed to open" error with a newline, so the next log
message doesn't start on the same line.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
ms_try_open() falls back to seatd_libseat_open_graphics() when the
driver can't open the node itself, but every FD from open_hw() is
closed with a plain close(). seatd keeps its own reference to the
device, and the FD stays in seatd-libseat.c's list, where a later open
that reuses the FD number can be mistaken for it.
Export seatd_libseat_close_graphics() and call it before closing an FD
that may have come from open_hw(). It does nothing for an FD that
wasn't opened through seatd, so the driver doesn't have to remember
where each FD came from. drmOpen() FDs of PCI entities and server FDs
aren't closed on these paths.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
xf86_remove_platform_device() frees the attributes with
config_odev_free_attributes(), which gives a server FD back through
systemd_logind_release_fd(): a plain close() without a logind session.
seatd keeps the device open, and the tracked entry is left pointing at
an FD number that can be reused.
Close the device through libseat there, next to the logind release.
config.c is also linked into the kdrive servers, which never open a
device through seatd, so they get an empty stub like the logind ones.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
seatd_libseat_open_graphics() hands the probed GPU's FD to the platform
bus as a server FD. For a driver without SUPPORTS_SERVER_FDS,
doPlatformProbe() gives it back with systemd_logind_release_fd(), which
without a logind session is a plain close(). seatd keeps its own
reference to the same open file and with it DRM master, so the driver's
own open of the node is not master which will cause it to fail.
The libseat device ID was also kept in a single slot that every
seatd_libseat_open_graphics() call overwrote, so with more than one GPU
there was no way to close the right device.
Track the libseat ID per FD and close the device through libseat before
the server FD is dropped.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
ms_gbm.c uses GBM_BO_USE_FRONT_RENDERING, which older libgbm versions
accepted by meson don't provide, so Xmodesetting fails to build against
them. Include drm_defines.h, which defines it to 0 in that case, as the
Xorg modesetting driver does.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
GBM_BO_USE_FRONT_RENDERING is a gbm_bo_flags enum value, so this
#ifndef always redefines it to 0. Nothing in drmmode_display.c has used
it since the front buffer allocation moved to drmmode_bo.c, which gets
the correct fallback from drm_defines.h, as does this file.
Remove it, so a later use here doesn't silently get 0.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
Commit ee9cb28c3 switched the trampoline's error reporting to
os_log_error(), which only exists on macOS 10.12 and later, breaking the
build for older deployment targets.
Add HAS_OS_LOG to osxcompat.h, keyed on MAC_OS_X_VERSION_MIN_REQUIRED
like the other compat checks, and route logging through
a trampoline_log_error() macro that uses asl_log() when os_log is not
available. The os_log-only %{public}s specifier is wrapped in a PUBLIC_S
macro that expands to plain %s for ASL.
Signed-off-by: Sergey Fedorov <barracuda@macos-powerpc.org>
An OutputClass with neither Driver nor Module ends up in the branch that
extends the default module search path, which dereferences
cl->modulepath without checking it. A class that only sets options, such
as PrimaryGPU, crashes the server during the bus probe.
Leave the search path alone when the class has no ModulePath, as before
per-driver search paths were introduced.
Fixes: 9f25f5d3f1 ("xfree86: make search paths configurable for certain modules")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: galternat <galternat.twins223@simplelogin.com>
Callers of LoaderSetPath(), eg. xf86PlatformProbe, might pass empty strings
instead of NULL, but those also meaning "not present" (IOW: use default path).
That's leading to spurious "Failed to store module search path" error log
messages for modules that don't have a search path yet.
Instead of adding extra complexity there for transforming empty strings
to NULL pointers, just deal with those here and so make the interface
a bit more robust.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
If a dumb gbm buffer cannot be created for a given depth,
but a tiled buffer works, use the tiled buffer and hope it works
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
When the front buffer is tiled, this untextures the root pixmap,
and replaces the tiled bo with a cpu-mapped bo (+ ShadowFB if needed)
In the future, we should probably create a tiled shadow buffer,
and use gl for rotations
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
We change the shadow update on the happy path.
If we later need to bail, we need to restore the old shadow update proc.
This can happen for example when we can't texture the front bo,
and we need to bail back to the cpu-mapped front bo,
and the cpu-mapped front bo was using ShadowFB
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
For most uses, a 64x64 cursor is large enough.
If we are asked for a larger cursor, we allocate and use it then.
A 64x64 should be a good compromise between power usage and complexity.
See: 1f41320e1c
See: https://gitlab.freedesktop.org/xorg/xserver/-/work_items/1922
Signed-off-by: stefan11111 <stefan11111github@gmail.com>
We don't tell RandR about the initial rotation, so it thinks that it needs to
constrains the cursor position to the intersection of the rotated screen and unrotated screen
Wrap `pScreen->ConstrainCursorHarder` and return early when we are initially rotated.
We could instead just tell RandR about out initial rotation and assign new rotations directly
in RRSetConfig.
For now do it like this, revisit later if needed/desired.
Signed-off-by: stefan11111 <stefan11111github@gmail.com>