diff options
Diffstat (limited to 'lib/libX11/src/xcb_io.c')
-rw-r--r-- | lib/libX11/src/xcb_io.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/libX11/src/xcb_io.c b/lib/libX11/src/xcb_io.c index dff441ff5..fd33f4383 100644 --- a/lib/libX11/src/xcb_io.c +++ b/lib/libX11/src/xcb_io.c @@ -32,8 +32,12 @@ #define throw_thread_fail_assert(_message, _var) { \ fprintf(stderr, "[xcb] " _message "\n"); \ - fprintf(stderr, "[xcb] Most likely this is a multi-threaded client " \ - "and XInitThreads has not been called\n"); \ + if (_Xglobal_lock) { \ + fprintf(stderr, "[xcb] You called XInitThreads, this is not your fault\n"); \ + } else { \ + fprintf(stderr, "[xcb] Most likely this is a multi-threaded client " \ + "and XInitThreads has not been called\n"); \ + } \ xcb_fail_assert(_message, _var); \ } @@ -214,7 +218,12 @@ static int handle_error(Display *dpy, xError *err, Bool in_XReply) static void widen(uint64_t *wide, unsigned int narrow) { uint64_t new = (*wide & ~((uint64_t)0xFFFFFFFFUL)) | narrow; - *wide = new + (((uint64_t)(new < *wide)) << 32); + /* If just copying the upper dword of *wide makes the number + * go down by more than 2^31, then it means that the lower + * dword has wrapped (or we have skipped 2^31 requests, which + * is hopefully improbable), so we add a carry. */ + uint64_t wraps = new + (1UL << 31) < *wide; + *wide = new + (wraps << 32); } /* Thread-safety rules: |