From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: valid_pointer_p Date: Sat, 29 Jul 2006 13:27:07 +0300 Message-ID: Reply-To: Eli Zaretskii NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1154168860 3420 80.91.229.2 (29 Jul 2006 10:27:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 29 Jul 2006 10:27:40 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jul 29 12:27:34 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G6m2W-0007vm-1t for ged-emacs-devel@m.gmane.org; Sat, 29 Jul 2006 12:27:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6m2V-0006Wl-Gi for ged-emacs-devel@m.gmane.org; Sat, 29 Jul 2006 06:27:23 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1G6m2J-0006VM-Vl for emacs-devel@gnu.org; Sat, 29 Jul 2006 06:27:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1G6m2H-0006TW-CB for emacs-devel@gnu.org; Sat, 29 Jul 2006 06:27:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6m2H-0006TL-70 for emacs-devel@gnu.org; Sat, 29 Jul 2006 06:27:09 -0400 Original-Received: from [192.114.186.20] (helo=nitzan.inter.net.il) by monty-python.gnu.org with esmtp (Exim 4.52) id 1G6m4T-0007jW-0u for emacs-devel@gnu.org; Sat, 29 Jul 2006 06:29:25 -0400 Original-Received: from HOME-C4E4A596F7 (IGLD-84-228-215-112.inter.net.il [84.228.215.112]) by nitzan.inter.net.il (MOS 3.7.3-GA) with ESMTP id EHG71218 (AUTH halo1); Sat, 29 Jul 2006 13:27:06 +0300 (IDT) Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:57776 Archived-At: 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; }