Commit 3cb3024fea removed pScratchPixmap field
in ScreenRec, which broke legacy Nvidia (proprietary) drivers (470.x), thus
we should add an empty/dummy field here, to ensure correct padding. But this
would break ABI again - can't do that within minor release line.
As compromise, adding a *build time* option CONFIG_LEGACY_NVIDIA_PADDING for
this, so operators/packagers can opt-in to this change.
As it breaks ABI, the option is disabled by default until the next major release
and intended for EXPERTS ONLY who need nvidia390 or nvidia470 drivers.
Note that ALL DRIVERS should be rebuild if it is applied!
This compile-time option, along with the hacks needed to support it
in a non-abi-breaking way, should be droppen in the next major release.
Co-authored-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
Signed-off-by: Oleh Nykyforchyn <oleh.nyk@gmail.com>
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Add and use macro X_REPLY_HEADER_UNITS() for computing how many
extra protocol units are needed for a reply header (for .length field)
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The `RECTANGLE` PDU is pretty common, so it's good to have a helper for
writing this, so it doesn't need to be open-coded everywhere.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This is writing the contents of source rpcbuf into the target one,
pads it and finally clears the source buffer.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Add a helper for writing pascal-type strings: the counter is written
as CARD16, then followed by the string characters (w/o zero), and
finally everything padded up to full protocol units.
This encoding is used in various places throughout the Xserver,
eg. in xkb.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
We need to call bytes_to_int32() instead of pad_to_int32(),
otherwise our computation is totally broken.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This macro is sending a reply header struct and rpcbuf payload
all in one shot. It also automatically computes the payload lengths
as well as also filling common fields like `type` and `sequenceNumber`
A typical call site looks like this:
> int ProcFooRequest(ClientPtr client) {
>
> [ ... ]
>
> X_SEND_REPLY_WITH_RPCBUF(client, rep, rpcbuf);
> return Success;
> }
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
When iterating screen lists, consistently use the same variable name
`walkScreen` for holding current screen pointer everywhere.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Add macro X_REPLY_HEADER_UNITS() for computing how many extra
protocol units are needed for a reply header (for .length field)
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Just a convenience wrapper for writing an INT16.
Technically it's really the same as CARD16, but we still need a typecast
in order to not getting a compiler warning on int signedness mismatch.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
New function for padding the buffer to full protocol units granularity:
If the current write position isn't at 4-byte granularity, it reserves
the remaining number of bytes (ie. writing zeros), in order to make the
next write align to 4-byte granularity again.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
in preparation of upcoming new iterator macros, phase out
FOR_NSCREENS_FORWARD_SKIP, so we don't need an additional macro
for just the case where first screen is skipped.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The global (exported) serverGeneration field is `unsigned long`, while
many other places copy it and compare it two other integer types, eg.
plain `int` (which is signed). Even if it's unlikely ever reaching such
high number of generations that it will ever make trouble, it's still
a good idea to clean this up and use the same type everywhere.
For clearity, introducing a typedef `x_server_generation_t` which is
used everywhere, instead of raw `unsigned long`.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
It's only caller already has the ScreenPtr, so it doesn't make any sense
passing in the screen number and let that function retrieve the pointer
on its own again.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
It's only caller already has the ScreenPtr, so it doesn't make any sense
passing in the screen number and let that function retrieve the pointer
on its own again.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Practically all callers need to assign to a CARD32 field, so let it
directly compute and return as CARD32.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Use explicit cast to match WriteToClient()'s expectation and
return ssize_t, as coming from WriteToClient()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The client index (in the client table) can never be negative, thus
make it an unsigned short.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Reduce complexity for things that really don't matter much:
The ddxBeforeReset() function is called when the Xserver going to reset
(new server generation). Right now, the only DDX really needing that is
Xwin, on all the others it's just no-op.
We've got an extra complicated build logic, which ifdef's out this all when
Xwin isn't built at all. The saving is extremely minimal - just skipping
few stub functions, which in most sessions aren't even called.
Therefore, get rid of this extra complexity that isn't giving us any
notable gain.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
mingw's printf() doesn't understand it yet, and it's not really
important here, so just use `%hx` instead.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The X protocol types from xorgproto all have corresponding sz_<typename>
defines with their actual network payload size (this can be checked via
SIZEOF() macro).
In theory, this should always be the same as sizeof(), but just to be sure,
adding a macro for a static assert on that.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
The swapping is so trivial, we don't need several extra functions
for that - just do it right where the header fields are swapped.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Instead of always zero'ing out the whole buffer at allocation time, only
do it where really necessary. Also adding x_rpcbuf_reserve0() for reserving
buffer space that's explicitly cleared.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Both are the same types, the `struct x_rpcbuf` still remains, but it
seems more clear to use the `x_rpcbuf_t` as the canonical name.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>