aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2013-09-20 13:23:20 -0700
committerPaul Eggert2013-09-20 13:23:20 -0700
commite3b29769a8b27bb0b727daa7445130ac256006d0 (patch)
treeec7cbd354fd27590a3c0dd6e685724e7a545cf7d /src
parent31dca772aded1c089b135d6335e4e444fd63078a (diff)
downloademacs-e3b29769a8b27bb0b727daa7445130ac256006d0.tar.gz
emacs-e3b29769a8b27bb0b727daa7445130ac256006d0.zip
Port recent change to hosts where pointers aren't 'long'.
* xterm.c (x_send_scroll_bar_event, x_scroll_bar_to_input_event): Don't assume that pointers are the same width as 'long'. Add a compile-time check that a pointer fits into two X slots.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/xterm.c51
2 files changed, 21 insertions, 35 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 5cce3ad3056..7b59b33c8bd 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
12013-09-20 Paul Eggert <eggert@cs.ucla.edu> 12013-09-20 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 Port recent change to hosts where pointers aren't 'long'.
4 * xterm.c (x_send_scroll_bar_event, x_scroll_bar_to_input_event):
5 Don't assume that pointers are the same width as 'long'.
6 Add a compile-time check that a pointer fits into two X slots.
7
3 A simpler, centralized INLINE. 8 A simpler, centralized INLINE.
4 * conf_post.h (INLINE): Define only if not already defined. 9 * conf_post.h (INLINE): Define only if not already defined.
5 This allows us to use a single INLINE, defined by one file 10 This allows us to use a single INLINE, defined by one file
diff --git a/src/xterm.c b/src/xterm.c
index 2633bf18d56..1ccc1ae649b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3967,7 +3967,7 @@ XTmouse_position (struct frame **fp, int insist, Lisp_Object *bar_window,
3967 3967
3968 /* From-window. */ 3968 /* From-window. */
3969 root, 3969 root,
3970 3970
3971 /* To-window. */ 3971 /* To-window. */
3972 FRAME_X_WINDOW (dpyinfo->last_mouse_frame), 3972 FRAME_X_WINDOW (dpyinfo->last_mouse_frame),
3973 3973
@@ -4250,6 +4250,10 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole)
4250 XClientMessageEvent *ev = &event.xclient; 4250 XClientMessageEvent *ev = &event.xclient;
4251 struct window *w = XWINDOW (window); 4251 struct window *w = XWINDOW (window);
4252 struct frame *f = XFRAME (w->frame); 4252 struct frame *f = XFRAME (w->frame);
4253 intptr_t iw = (intptr_t) w;
4254 enum { BITS_PER_INTPTR = CHAR_BIT * sizeof iw };
4255 verify (BITS_PER_INTPTR <= 64);
4256 int sign_shift = BITS_PER_INTPTR - 32;
4253 4257
4254 block_input (); 4258 block_input ();
4255 4259
@@ -4260,27 +4264,13 @@ x_send_scroll_bar_event (Lisp_Object window, int part, int portion, int whole)
4260 ev->window = FRAME_X_WINDOW (f); 4264 ev->window = FRAME_X_WINDOW (f);
4261 ev->format = 32; 4265 ev->format = 32;
4262 4266
4263 /* 32-bit X client on a 64-bit X server can pass window pointer 4267 /* A 32-bit X client on a 64-bit X server can pass a window pointer
4264 as is. 64-bit client on a 32-bit X server is in trouble 4268 as-is. A 64-bit client on a 32-bit X server is in trouble
4265 because pointer does not fit and will be truncated while 4269 because a pointer does not fit and would be truncated while
4266 passing through the server. So we should use two slots 4270 passing through the server. So use two slots and hope that X12
4267 and hope that X12 will resolve such an issues someday. */ 4271 will resolve such issues someday. */
4268 4272 ev->data.l[0] = iw >> 31 >> 1;
4269 if (BITS_PER_LONG > 32) 4273 ev->data.l[1] = sign_shift <= 0 ? iw : iw << sign_shift >> sign_shift;
4270 {
4271 union {
4272 int i[2];
4273 void *v;
4274 } val;
4275 val.v = w;
4276 ev->data.l[0] = val.i[0];
4277 ev->data.l[1] = val.i[1];
4278 }
4279 else
4280 {
4281 ev->data.l[0] = 0;
4282 ev->data.l[1] = (long) w;
4283 }
4284 ev->data.l[2] = part; 4274 ev->data.l[2] = part;
4285 ev->data.l[3] = portion; 4275 ev->data.l[3] = portion;
4286 ev->data.l[4] = whole; 4276 ev->data.l[4] = whole;
@@ -4311,19 +4301,10 @@ x_scroll_bar_to_input_event (const XEvent *event,
4311 struct window *w; 4301 struct window *w;
4312 4302
4313 /* See the comment in the function above. */ 4303 /* See the comment in the function above. */
4314 4304 intptr_t iw0 = ev->data.l[0];
4315 if (BITS_PER_LONG > 32) 4305 intptr_t iw1 = ev->data.l[1];
4316 { 4306 intptr_t iw = (iw0 << 31 << 1) + (iw1 & 0xffffffffu);
4317 union { 4307 w = (struct window *) iw;
4318 int i[2];
4319 void *v;
4320 } val;
4321 val.i[0] = ev->data.l[0];
4322 val.i[1] = ev->data.l[1];
4323 w = val.v;
4324 }
4325 else
4326 w = (void *) ev->data.l[1];
4327 4308
4328 XSETWINDOW (window, w); 4309 XSETWINDOW (window, w);
4329 4310