all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Pip Cet <pipcet@gmail.com>, tom@tromey.com
Cc: emacs-devel@gnu.org
Subject: Re: Merging bignum to master
Date: Mon, 13 Aug 2018 15:58:14 -0700	[thread overview]
Message-ID: <611579fd-52f2-0104-ef82-a7a4a3929700@cs.ucla.edu> (raw)
In-Reply-To: <CAOqdjBcW8Nop30=wFaM+7zeKGWw=C6CQoYY_xr-rA3jzmkxLgQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

Pip Cet wrote:

> I notice that there are a few places where you use XFIXNUMPTR
> directly, rather than make_mint_ptr. Is that intentional? I think now
> would be a good time to fix it and make XFIXNUMPTR internal to lisp.h.

It's intentional since those few places don't need the full power of 
make_mint_ptr (often the pointers are already aligned) and there might be 
trouble if storage allocation fails if the pointer is not aligned. Perhaps 
you're right and this is overkill; it is confusing at any rate. In the meantime 
I installed the attached first patch to fix a glitch I saw in this area while 
looking at the current XFIXNUMPTR uses.

> Also, the doc comments for most_negative_fixnum and
> most_positive_fixnum in data.c still need updating.

Thanks, done in the second attached patch.

[-- Attachment #2: 0001-Fix-check-for-unsafe-watch-descriptor.patch --]
[-- Type: text/x-patch, Size: 2168 bytes --]

From 76101698a770d389f22b547c331ec78473040c47 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 13 Aug 2018 15:45:17 -0700
Subject: [PATCH 1/2] Fix check for unsafe watch descriptor

* src/lisp.h (make_pointer_integer_unsafe): New function.
(make_pointer_integer): Use it.
* src/gfilenotify.c (dir_monitor_callback): Omit redundant eassert.
(Fgfile_add_watch): Signal an error instead of failing an
assertion if the pointer does not work.
---
 src/gfilenotify.c | 7 +++----
 src/lisp.h        | 8 +++++++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 7eea2cfac1..798f308b31 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -77,7 +77,6 @@ dir_monitor_callback (GFileMonitor *monitor,
 
   /* Determine callback function.  */
   monitor_object = make_pointer_integer (monitor);
-  eassert (FIXNUMP (monitor_object));
   watch_object = assq_no_quit (monitor_object, watch_list);
 
   if (CONSP (watch_object))
@@ -203,10 +202,10 @@ will be reported only in case of the `moved' event.  */)
   if (! monitor)
     xsignal2 (Qfile_notify_error, build_string ("Cannot watch file"), file);
 
-  Lisp_Object watch_descriptor = make_pointer_integer (monitor);
+  Lisp_Object watch_descriptor = make_pointer_integer_unsafe (monitor);
 
-  /* Check the dicey assumption that make_pointer_integer is safe.  */
-  if (! FIXNUMP (watch_descriptor))
+  if (! (FIXNUMP (watch_descriptor)
+	 && XFIXNUMPTR (watch_descriptor) == monitor))
     {
       g_object_unref (monitor);
       xsignal2 (Qfile_notify_error, build_string ("Unsupported file watcher"),
diff --git a/src/lisp.h b/src/lisp.h
index b7ef8dc63a..18d53537cc 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1188,10 +1188,16 @@ XFIXNUMPTR (Lisp_Object a)
   return XUNTAG (a, Lisp_Int0, char);
 }
 
+INLINE Lisp_Object
+make_pointer_integer_unsafe (void *p)
+{
+  return TAG_PTR (Lisp_Int0, p);
+}
+
 INLINE Lisp_Object
 make_pointer_integer (void *p)
 {
-  Lisp_Object a = TAG_PTR (Lisp_Int0, p);
+  Lisp_Object a = make_pointer_integer_unsafe (p);
   eassert (FIXNUMP (a) && XFIXNUMPTR (a) == p);
   return a;
 }
-- 
2.17.1


[-- Attachment #3: 0002-Update-doc-strings-for-fixnum-constants.patch --]
[-- Type: text/x-patch, Size: 1454 bytes --]

From dc18a0917a5531ef3e1c9b4921bb4d8f317bc7a4 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 13 Aug 2018 15:55:06 -0700
Subject: [PATCH 2/2] Update doc strings for fixnum constants

* src/data.c (most-positive-fixnum, most-negative-fixnum):
Update doc strings in the light of fixnums.
---
 src/data.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/data.c b/src/data.c
index 7b8dd45c94..a1215b9d6b 100644
--- a/src/data.c
+++ b/src/data.c
@@ -4260,13 +4260,13 @@ syms_of_data (void)
   set_symbol_function (Qwholenump, XSYMBOL (Qnatnump)->u.s.function);
 
   DEFVAR_LISP ("most-positive-fixnum", Vmost_positive_fixnum,
-	       doc: /* The largest value that is representable in a Lisp integer.
+	       doc: /* The greatest integer that is represented efficiently.
 This variable cannot be set; trying to do so will signal an error.  */);
   Vmost_positive_fixnum = make_fixnum (MOST_POSITIVE_FIXNUM);
   make_symbol_constant (intern_c_string ("most-positive-fixnum"));
 
   DEFVAR_LISP ("most-negative-fixnum", Vmost_negative_fixnum,
-	       doc: /* The smallest value that is representable in a Lisp integer.
+	       doc: /* The least integer that is represented efficiently.
 This variable cannot be set; trying to do so will signal an error.  */);
   Vmost_negative_fixnum = make_fixnum (MOST_NEGATIVE_FIXNUM);
   make_symbol_constant (intern_c_string ("most-negative-fixnum"));
-- 
2.17.1


  parent reply	other threads:[~2018-08-13 22:58 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-11 19:47 Merging bignum to master Tom Tromey
2018-08-11 21:28 ` Basil L. Contovounesios
2018-08-12 16:34   ` Tom Tromey
2018-08-13 12:21     ` Basil L. Contovounesios
2018-08-14  0:21     ` Andy Moreton
2018-08-15 23:41       ` Andy Moreton
2018-08-16 15:38         ` Basil L. Contovounesios
2018-08-19  8:26         ` Paul Eggert
2018-08-17 14:58   ` Eli Zaretskii
2018-08-12  6:29 ` Ulrich Mueller
2018-08-12  8:09   ` Paul Eggert
2018-08-12 17:21     ` Ulrich Mueller
2018-08-12 18:20       ` Eli Zaretskii
2018-08-12 19:30         ` Ulrich Mueller
2018-08-13  0:15           ` Paul Eggert
2018-08-12 18:05     ` Eli Zaretskii
2018-08-12 23:53       ` Paul Eggert
2018-08-13  0:20         ` Tom Tromey
2018-08-13  7:51         ` Andreas Schwab
2018-08-13  8:06           ` Ulrich Mueller
2018-08-13  9:14             ` Paul Eggert
2018-08-14 23:09               ` Paul Eggert
2018-08-16  2:46                 ` Richard Stallman
2018-08-13 23:31         ` Richard Stallman
2018-08-14  1:41           ` Paul Eggert
2018-08-16  2:41             ` Richard Stallman
2018-08-16 19:31               ` Paul Eggert
2018-08-16 22:02               ` Stefan Monnier
2018-08-12  7:37 ` John Wiegley
2018-08-12 18:21   ` Eli Zaretskii
2018-08-12 11:48 ` Pip Cet
2018-08-12 16:02   ` Tom Tromey
2018-08-13 22:58   ` Paul Eggert [this message]
2018-08-14  1:12     ` Noam Postavsky
2018-08-14 13:04     ` Pip Cet
2018-08-14 18:01       ` Paul Eggert
2018-08-15 15:20         ` Pip Cet
2018-08-15 16:17           ` Paul Eggert
2018-08-15 23:57           ` Andy Moreton
2018-08-16 22:00             ` Stefan Monnier
2018-08-20 16:28         ` Some vars now limited to fixnum size. (Was: Merging bignum to master) Karl Fogel
2018-08-20 16:54           ` Paul Eggert
2018-08-20 17:27             ` Eli Zaretskii
2018-08-20 17:27             ` Paul Eggert
2018-08-20 18:00               ` Eli Zaretskii
2018-08-20 19:55                 ` Pip Cet
2018-08-20 23:15                   ` Paul Eggert
2018-08-21 15:01               ` Some vars now limited to fixnum size Tom Tromey
2018-08-21 16:36                 ` Andy Moreton
2018-08-21 18:46                 ` Paul Eggert
2018-08-22 15:39                   ` Tom Tromey
2018-08-21  3:38             ` Some vars now limited to fixnum size. (Was: Merging bignum to master) Richard Stallman
2018-08-21  4:09               ` Paul Eggert
2018-08-22  4:03                 ` Richard Stallman
2018-08-22  4:53                   ` Paul Eggert
2018-08-20 17:25           ` Eli Zaretskii
2018-08-14  0:51 ` Merging bignum to master Andy Moreton
2018-08-15 15:46 ` Andy Moreton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=611579fd-52f2-0104-ef82-a7a4a3929700@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=pipcet@gmail.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.