XInitThreads in library constructor breaks Motif!

Po Lu luangruo at yahoo.com
Tue Nov 1 00:55:50 UTC 2022


Carsten Haitzler <raster at rasterman.com> writes:

> no it doesn't. the contract is simply to not use motif from multiple threads.
> it has nothing to do with xlib itself becoming threadsafe. i think the PR/MR
> for xlib has all the details you want listed in it.

No, it doesn't, see below:

> it has nothing to do with it. xcb is an artefact of how xlib is implemented
> today - it absolutely is not part of the spec or design or requirements.

If my program does not use XCB (or even link with X11-xcb), why should
it be subject to constraints placed by XCB?  XCB is just one transport
for the X library.

> has nothing to do with it. having xlib just be threadsafe always when it is as
> easy as xinitthreads being the default anyway is nice. it doesn't violate the
> xlib contract with users of it if they are correctly implemented.

Nonsense.  The X library has worked how I (and Motif) expect it to since
at least the early 90s.

The X11R5 manual page says:

    The XIfEvent function completes only when the specified predicate
    procedure returns  True for an event,  which indicates an event
    in the queue matches.  XIfEvent flushes the output buffer if it
    blocks waiting for additional events.  XIfEvent removes the
    matching event from the queue  and copies the structure into the
    client-supplied XEvent structure.

    When the predicate procedure finds a match, XCheckIfEvent copies
    the matched event into the client-supplied XEvent structure and
    returns  True.  (This event is removed from the queue.)  If the
    predicate procedure finds no match, XCheckIfEvent returns False,
    and the output buffer will have been flushed.  All earlier events
    stored in the queue are not discarded.

    The XPeekIfEvent function returns only when the specified
    predicate procedure returns  True for an event.  After the
    predicate procedure finds a match, XPeekIfEvent copies the
    matched event into the client-supplied XEvent structure without
    removing the event from the queue.  XPeekIfEvent flushes the
    output buffer if it blocks waiting for additional events.

Notice how there is no mention of calling Xlib functions being unsafe,
as at that point the X library did not have thread support at all.


More information about the xorg-devel mailing list