aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorKaroly Lorentey2005-12-03 14:25:50 +0000
committerKaroly Lorentey2005-12-03 14:25:50 +0000
commit9ef706664e98e37e9633712126bae99869904677 (patch)
tree193bce7424700e4c7d70f54b04f7f81d64525554 /src/alloc.c
parent950bed4bb96d2a580818bdaab64a164c7c9a1c1e (diff)
parent9f6efa0c78099f2f028c4db1db5a58567a1cfb4e (diff)
downloademacs-9ef706664e98e37e9633712126bae99869904677.tar.gz
emacs-9ef706664e98e37e9633712126bae99869904677.zip
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. */
66extern POINTER_TYPE *sbrk (); 66extern POINTER_TYPE *sbrk ();
67#endif 67#endif
68 68
69#ifdef HAVE_FCNTL_H
70#define INCLUDED_FCNTL
71#include <fcntl.h>
72#endif
73#ifndef O_WRONLY
74#define O_WRONLY 1
75#endif
76
69#ifdef DOUG_LEA_MALLOC 77#ifdef DOUG_LEA_MALLOC
70 78
71#include <malloc.h> 79#include <malloc.h>
@@ -4498,21 +4506,37 @@ int
4498valid_lisp_object_p (obj) 4506valid_lisp_object_p (obj)
4499 Lisp_Object obj; 4507 Lisp_Object obj;
4500{ 4508{
4509 void *p;
4501#if !GC_MARK_STACK 4510#if !GC_MARK_STACK
4502 /* Cannot determine this. */ 4511 int fd;
4503 return -1;
4504#else 4512#else
4505 void *p;
4506 struct mem_node *m; 4513 struct mem_node *m;
4514#endif
4507 4515
4508 if (INTEGERP (obj)) 4516 if (INTEGERP (obj))
4509 return 1; 4517 return 1;
4510 4518
4511 p = (void *) XPNTR (obj); 4519 p = (void *) XPNTR (obj);
4512
4513 if (PURE_POINTER_P (p)) 4520 if (PURE_POINTER_P (p))
4514 return 1; 4521 return 1;
4515 4522
4523#if !GC_MARK_STACK
4524 /* We need to determine whether it is safe to access memory at
4525 address P. Obviously, we cannot just access it (we would SEGV
4526 trying), so we trick the o/s to tell us whether p is a valid
4527 pointer. Unfortunately, we cannot use NULL_DEVICE here, as
4528 emacs_write may not validate p in that case. */
4529 if ((fd = emacs_open("__Valid__Lisp__Object__", O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0)
4530 {
4531 int valid = emacs_write(fd, (char *)p, 16) == 16;
4532 emacs_close(fd);
4533 unlink("__Valid__Lisp__Object__");
4534 return valid;
4535 }
4536
4537 return -1;
4538#else
4539
4516 m = mem_find (p); 4540 m = mem_find (p);
4517 4541
4518 if (m == MEM_NIL) 4542 if (m == MEM_NIL)