From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#15880: Compute C declarations for DEFSYMs automatically. Date: Fri, 09 Jan 2015 08:33:53 -0800 Organization: UCLA Computer Science Department Message-ID: <54B002F1.4030305@cs.ucla.edu> References: <5282C8F4.5010806@cs.ucla.edu> <5494D719.4040507@cs.ucla.edu> <5499FFF1.9050106@cs.ucla.edu> <54AAC905.1020906@cs.ucla.edu> <54AAD51C.7020207@cs.ucla.edu> <83lhlh83a3.fsf@gnu.org> <54AAE504.5090701@cs.ucla.edu> <83egr980v9.fsf@gnu.org> <54AB0E11.5050908@cs.ucla.edu> <837fx08u67.fsf@gnu.org> <54ADDA79.3050105@cs.ucla.edu> <83387l7670.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020205000000000705000003" X-Trace: ger.gmane.org 1420821361 16796 80.91.229.3 (9 Jan 2015 16:36:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Jan 2015 16:36:01 +0000 (UTC) Cc: 15880@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 09 17:35:54 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y9cWl-0007lM-Tg for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Jan 2015 17:35:12 +0100 Original-Received: from localhost ([::1]:51298 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9cWl-0001F8-CI for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Jan 2015 11:35:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55640) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9cWg-0001Cx-VX for bug-gnu-emacs@gnu.org; Fri, 09 Jan 2015 11:35:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9cWc-0003Gv-MY for bug-gnu-emacs@gnu.org; Fri, 09 Jan 2015 11:35:06 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9cWc-0003GG-Is for bug-gnu-emacs@gnu.org; Fri, 09 Jan 2015 11:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Y9cWc-0005vu-Bn for bug-gnu-emacs@gnu.org; Fri, 09 Jan 2015 11:35:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Jan 2015 16:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15880 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 15880-submit@debbugs.gnu.org id=B15880.142082124222725 (code B ref 15880); Fri, 09 Jan 2015 16:35:02 +0000 Original-Received: (at 15880) by debbugs.gnu.org; 9 Jan 2015 16:34:02 +0000 Original-Received: from localhost ([127.0.0.1]:41065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y9cVd-0005uB-P4 for submit@debbugs.gnu.org; Fri, 09 Jan 2015 11:34:02 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:32778) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Y9cVb-0005u0-2a for 15880@debbugs.gnu.org; Fri, 09 Jan 2015 11:34:00 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id ABA18A6009C; Fri, 9 Jan 2015 08:33:57 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vxdq122t23jC; Fri, 9 Jan 2015 08:33:57 -0800 (PST) Original-Received: from [192.168.1.9] (pool-173-55-11-52.lsanca.fios.verizon.net [173.55.11.52]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 19DD6A6003B; Fri, 9 Jan 2015 08:33:57 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: <83387l7670.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:98134 Archived-At: This is a multi-part message in MIME format. --------------020205000000000705000003 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Eli Zaretskii wrote: > Could we instead just keep the previous semantics of XIL and XLI, > please? They are used in a few places outside lisp.h, so now all of > those places need to be audited and most probably changed. Why isn't > it better to change the implementation of just 2 macros instead? XIL and XLI haven't changed, and have the same semantics as before: they convert between Lisp_Object and EMACS_INT without altering the bits (i.e., they are no-ops at the machine level). I expect it's better to keep them no-ops, for efficiency in the kernel of the Emacs Lisp interpreter. I audited all the places XIL and XLI are used, and the uses in non-w32 code are all fine. I don't know the w32 code, but most likely some or all of its uses need to be changed. I moved the new conversion operations to lisp.h (installed on master) and wrote the attached untested patch for the w32 code. --------------020205000000000705000003 Content-Type: text/x-patch; name="0001-Fix-pointer-to-integer-conversion-in-w32-code.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Fix-pointer-to-integer-conversion-in-w32-code.patch" >From 126c396d0b780742c785461d82d3b1127d492086 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 9 Jan 2015 08:21:19 -0800 Subject: [PATCH] Fix pointer-to-integer conversion in w32 code * w32fns.c (w32_msg_pump, Fw32_register_hot_key) (Fw32_unregister_hot_key, Fw32_toggle_lock_key): * w32inevt.c (handle_file_notifications): * w32menu.c (add_menu_item, w32_menu_display_help): * w32notify.c (Fw32notify_add_watch, Fw32notify_rm_watch) (w32_get_watch_object): * w32term.c (queue_notifications): Use make_pointer_integer and XINTPTR rather than XIL and XLI. --- src/ChangeLog | 10 ++++++++++ src/w32fns.c | 10 +++++----- src/w32inevt.c | 4 +++- src/w32menu.c | 6 ++++-- src/w32notify.c | 6 +++--- src/w32term.c | 5 +++-- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c11ba11..22e690c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,15 @@ 2015-01-09 Paul Eggert + Fix pointer-to-integer conversion in w32 code + * w32fns.c (w32_msg_pump, Fw32_register_hot_key) + (Fw32_unregister_hot_key, Fw32_toggle_lock_key): + * w32inevt.c (handle_file_notifications): + * w32menu.c (add_menu_item, w32_menu_display_help): + * w32notify.c (Fw32notify_add_watch, Fw32notify_rm_watch) + (w32_get_watch_object): + * w32term.c (queue_notifications): + Use make_pointer_integer and XINTPTR rather than XIL and XLI. + Refactor pointer-to-integer conversion * gfilenotify.c (monitor_to_lisp, lisp_to_monitor): Rename and move to lisp.h. All uses changed. diff --git a/src/w32fns.c b/src/w32fns.c index ced3d87..c6cdf96 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -2540,7 +2540,7 @@ w32_msg_pump (deferred_msg * msg_buf) thread-safe. The next line is okay because the cons cell is never made into garbage and is not relocated by GC. */ - XSETCAR (XIL ((EMACS_INT) msg.lParam), Qnil); + XSETCAR (make_pointer_integer (msg.lParam), Qnil); if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) emacs_abort (); break; @@ -2548,7 +2548,7 @@ w32_msg_pump (deferred_msg * msg_buf) { int vk_code = (int) msg.wParam; int cur_state = (GetKeyState (vk_code) & 1); - Lisp_Object new_state = XIL ((EMACS_INT) msg.lParam); + Lisp_Object new_state = make_pointer_integer (msg.lParam); /* NB: This code must be thread-safe. It is safe to call NILP because symbols are not relocated by GC, @@ -7235,7 +7235,7 @@ The return value is the hotkey-id if registered, otherwise nil. */) /* Notify input thread about new hot-key definition, so that it takes effect without needing to switch focus. */ PostThreadMessage (dwWindowsThreadId, WM_EMACS_REGISTER_HOT_KEY, - (WPARAM) XLI (key), 0); + XINTPTR (key), 0); } return key; @@ -7258,7 +7258,7 @@ DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key, /* Notify input thread about hot-key definition being removed, so that it takes effect without needing focus switch. */ if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_UNREGISTER_HOT_KEY, - (WPARAM) XINT (XCAR (item)), (LPARAM) XLI (item))) + (WPARAM) XINT (XCAR (item)), XINTPTR (item))) { MSG msg; GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); @@ -7331,7 +7331,7 @@ is set to off if the low bit of NEW-STATE is zero, otherwise on. */) return make_number (w32_console_toggle_lock_key (vk_code, new_state)); if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_TOGGLE_LOCK_KEY, - (WPARAM) vk_code, (LPARAM) XLI (new_state))) + (WPARAM) vk_code, XINTPTR (new_state))) { MSG msg; GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); diff --git a/src/w32inevt.c b/src/w32inevt.c index daf4a5c..ef2ec35 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c @@ -655,9 +655,11 @@ handle_file_notifications (struct input_event *hold_quit) Lisp_Object fname = code_convert_string_norecord (utf_16_fn, cs, 0); Lisp_Object action = lispy_file_action (fni->Action); + Lisp_Object descriptor + = make_pointer_integer (notifications_desc); inev.kind = FILE_NOTIFY_EVENT; - inev.code = (ptrdiff_t)XINT (XIL ((EMACS_INT)notifications_desc)); + inev.code = XINT (descriptor); inev.timestamp = GetTickCount (); inev.modifiers = 0; inev.frame_or_window = callback; diff --git a/src/w32menu.c b/src/w32menu.c index 7a946d2..3ec6b54 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -1412,7 +1412,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) be ULONG_PTR, which is correct for 32-bit and 64-bit Windows alike. MSVC headers get it right; hopefully, MinGW headers will, too. */ - info.dwItemData = (ULONG_PTR) XLI (wv->help); + info.dwItemData = XINTPTR (wv->help); } if (wv->button_type == BUTTON_TYPE_RADIO) { @@ -1488,7 +1488,9 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags) info.fMask = MIIM_DATA; get_menu_item_info (menu, item, FALSE, &info); - help = info.dwItemData ? XIL (info.dwItemData) : Qnil; + help = (info.dwItemData + ? make_pointer_integer (info.dwItemData) + : Qnil); } /* Store the help echo in the keyboard buffer as the X toolkit diff --git a/src/w32notify.c b/src/w32notify.c index a0d555b..27d0aa1 100644 --- a/src/w32notify.c +++ b/src/w32notify.c @@ -580,7 +580,7 @@ generate notifications correctly, though. */) report_file_error ("Cannot watch file", Fcons (file, Qnil)); } /* Store watch object in watch list. */ - watch_descriptor = XIL ((EMACS_INT)dirwatch); + watch_descriptor = make_pointer_integer (dirwatch); watch_object = Fcons (watch_descriptor, callback); watch_list = Fcons (watch_object, watch_list); @@ -605,7 +605,7 @@ WATCH-DESCRIPTOR should be an object returned by `w32notify-add-watch'. */) if (!NILP (watch_object)) { watch_list = Fdelete (watch_object, watch_list); - dirwatch = (struct notification *)XLI (watch_descriptor); + dirwatch = XINTPTR (watch_descriptor); if (w32_valid_pointer_p (dirwatch, sizeof(struct notification))) status = remove_watch (dirwatch); } @@ -620,7 +620,7 @@ WATCH-DESCRIPTOR should be an object returned by `w32notify-add-watch'. */) Lisp_Object w32_get_watch_object (void *desc) { - Lisp_Object descriptor = XIL ((EMACS_INT)desc); + Lisp_Object descriptor = make_pointer_integer (desc); /* This is called from the input queue handling code, inside a critical section, so we cannot possibly QUIT if watch_list is not diff --git a/src/w32term.c b/src/w32term.c index 8a53a58..7ac3120 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -3245,10 +3245,11 @@ queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f, Lisp_Object fname = code_convert_string_norecord (utf_16_fn, cs, 0); Lisp_Object action = lispy_file_action (fni->Action); + Lisp_Object descriptor + = make_pointer_integer (notifications_desc); event->kind = FILE_NOTIFY_EVENT; - event->code - = (ptrdiff_t)XINT (XIL ((EMACS_INT)notifications_desc)); + event->code = XINT (descriptor); event->timestamp = msg->msg.time; event->modifiers = 0; event->frame_or_window = callback; -- 2.1.0 --------------020205000000000705000003--