comparison src/alloc.c @ 83405:1955a4462bf9

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
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 03 Dec 2005 14:25:50 +0000
parents 03934708f1e9 fc58516afccd
children 14a4eb789b45
comparison
equal deleted inserted replaced
83404:69e184bbba16 83405:1955a4462bf9
62 62
63 #ifdef HAVE_UNISTD_H 63 #ifdef HAVE_UNISTD_H
64 #include <unistd.h> 64 #include <unistd.h>
65 #else 65 #else
66 extern POINTER_TYPE *sbrk (); 66 extern POINTER_TYPE *sbrk ();
67 #endif
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
67 #endif 75 #endif
68 76
69 #ifdef DOUG_LEA_MALLOC 77 #ifdef DOUG_LEA_MALLOC
70 78
71 #include <malloc.h> 79 #include <malloc.h>
4496 4504
4497 int 4505 int
4498 valid_lisp_object_p (obj) 4506 valid_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;
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
4515 4539
4516 m = mem_find (p); 4540 m = mem_find (p);
4517 4541
4518 if (m == MEM_NIL) 4542 if (m == MEM_NIL)
4519 return 0; 4543 return 0;