Bug 1399679 - Expand the NextRequest macro from Xlib.h in nsX11ErrorHandler.cpp draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 27 Dec 2017 07:30:44 +0900
changeset 722003 363d1661518a729d4c2e3933db0f4b60fa4161bd
parent 722002 0b0bd86eac97de9a428b144abaaec70cee0cdf4c
child 722004 2068b1b7c07de99f32911c375fddbdb79f56656d
push id96025
push userbmo:mh+mozilla@glandium.org
push dateThu, 18 Jan 2018 09:37:19 +0000
bugs1399679
milestone59.0a1
Bug 1399679 - Expand the NextRequest macro from Xlib.h in nsX11ErrorHandler.cpp On CentOS 6, the macro expands to: (((_XPrivDisplay)(dpy))->request + 1) On Debian wheezy, it expands to: (((_XPrivDisplay)dpy)->request + 1) where dpy is the argument it's given in both cases. This could make a difference if dpy was a non trivial expression, but in nsX11ErrorHandler.cpp, it's simply "display", which is a `Display*`. So both expansions have the same semantics, but for some reason, in nsX11ErrorHandler.cpp, using one or the other causes the compiler to reorder some of the instructions it emits.
toolkit/xre/nsX11ErrorHandler.cpp
--- a/toolkit/xre/nsX11ErrorHandler.cpp
+++ b/toolkit/xre/nsX11ErrorHandler.cpp
@@ -15,17 +15,17 @@
 
 #define BUFSIZE 2048 // What Xlib uses with XGetErrorDatabaseText
 
 extern "C" {
 int
 X11Error(Display *display, XErrorEvent *event) {
   // Get an indication of how long ago the request that caused the error was
   // made.
-  unsigned long age = NextRequest(display) - event->serial;
+  unsigned long age = (((_XPrivDisplay)(display))->request + 1) - event->serial;
 
   // Get a string to represent the request that caused the error.
   nsAutoCString message;
   if (event->request_code < 128) {
     // Core protocol request
     message.AppendInt(event->request_code);
   } else {
     // Extension request