summaryrefslogtreecommitdiff
path: root/src/alloc.c
diff options
context:
space:
mode:
authorKaroly Lorentey <lorentey@elte.hu>2005-12-03 14:25:50 +0000
committerKaroly Lorentey <lorentey@elte.hu>2005-12-03 14:25:50 +0000
commit9ef706664e98e37e9633712126bae99869904677 (patch)
tree193bce7424700e4c7d70f54b04f7f81d64525554 /src/alloc.c
parent950bed4bb96d2a580818bdaab64a164c7c9a1c1e (diff)
parent9f6efa0c78099f2f028c4db1db5a58567a1cfb4e (diff)
downloademacs-9ef706664e98e37e9633712126bae99869904677.tar.gz
Merged from miles@gnu.org--gnu-2005 (patch 659-663)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-659 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-660 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-661 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-662 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-663 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-445
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/alloc.c b/src/alloc.c
index bc48f7bb3b4..5ab28bc0cde 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -66,6 +66,14 @@ Boston, MA 02110-1301, USA. */
extern POINTER_TYPE *sbrk ();
#endif
+#ifdef HAVE_FCNTL_H
+#define INCLUDED_FCNTL
+#include <fcntl.h>
+#endif
+#ifndef O_WRONLY
+#define O_WRONLY 1
+#endif
+
#ifdef DOUG_LEA_MALLOC
#include <malloc.h>
@@ -4498,21 +4506,37 @@ int
valid_lisp_object_p (obj)
Lisp_Object obj;
{
+ void *p;
#if !GC_MARK_STACK
- /* Cannot determine this. */
- return -1;
+ int fd;
#else
- void *p;
struct mem_node *m;
+#endif
if (INTEGERP (obj))
return 1;
p = (void *) XPNTR (obj);
-
if (PURE_POINTER_P (p))
return 1;
+#if !GC_MARK_STACK
+ /* We need to determine whether it is safe to access memory at
+ address P. 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;
+#else
+
m = mem_find (p);
if (m == MEM_NIL)