unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* valid_pointer_p
@ 2006-07-29 10:27 Eli Zaretskii
  2006-07-29 10:45 ` valid_pointer_p Andreas Schwab
  2006-07-30  0:05 ` valid_pointer_p Kim F. Storm
  0 siblings, 2 replies; 21+ messages in thread
From: Eli Zaretskii @ 2006-07-29 10:27 UTC (permalink / raw)


Can someone ``in the know'' please explain what clever idea is behind
the function valid_pointer_p, and whether that idea is supposed to be
portable?  This function was previously used only if !GC_MARK_STACK,
but now its use was extended to all configurations, so I think at the
very least its commentary should be expanded and clarified, even if it
turns out that its method is universally right.

Here's the code of the function, for your convenience:

    /* Determine whether it is safe to access memory at address P.  */
    int
    valid_pointer_p (p)
	 void *p;
    {
      int fd;

      /* Obviously, we cannot just access it (we would SEGV trying), so we
	 trick the o/s to tell us whether p is a valid pointer.
	 Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may
	 not validate p in that case.  */

      if ((fd = emacs_open ("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0)
	{
	  int valid = (emacs_write (fd, (char *)p, 16) == 16);
	  emacs_close (fd);
	  unlink ("__Valid__Lisp__Object__");
	  return valid;
	}

	return -1;
    }

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2006-08-12 21:56 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-29 10:27 valid_pointer_p Eli Zaretskii
2006-07-29 10:45 ` valid_pointer_p Andreas Schwab
2006-07-29 12:16   ` valid_pointer_p Eli Zaretskii
2006-07-30  0:05 ` valid_pointer_p Kim F. Storm
2006-07-30  3:16   ` valid_pointer_p Eli Zaretskii
2006-07-30 22:13     ` valid_pointer_p Kim F. Storm
2006-07-31  3:21       ` valid_pointer_p Eli Zaretskii
2006-07-31  8:30         ` valid_pointer_p Andreas Schwab
2006-07-31 17:10           ` valid_pointer_p Eli Zaretskii
2006-07-31 17:56             ` valid_pointer_p Andreas Schwab
2006-07-31  9:01         ` valid_pointer_p Kim F. Storm
2006-08-05 13:04           ` valid_pointer_p Eli Zaretskii
2006-08-05 13:09             ` valid_pointer_p Eli Zaretskii
2006-08-05 22:11             ` valid_pointer_p Kim F. Storm
2006-08-06  3:29               ` valid_pointer_p Eli Zaretskii
2006-08-11 22:58                 ` valid_pointer_p Kim F. Storm
2006-08-12 11:06                   ` valid_pointer_p Eli Zaretskii
2006-08-12 12:36                     ` valid_pointer_p Andreas Schwab
2006-08-12 14:39                       ` valid_pointer_p Eli Zaretskii
2006-08-12 20:19                         ` valid_pointer_p Kim F. Storm
2006-08-12 21:56                           ` valid_pointer_p Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).