emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/alloc.c


From: Kim F . Storm
Subject: [Emacs-diffs] Changes to emacs/src/alloc.c
Date: Tue, 29 Nov 2005 19:04:51 -0500

Index: emacs/src/alloc.c
diff -c emacs/src/alloc.c:1.383 emacs/src/alloc.c:1.384
*** emacs/src/alloc.c:1.383     Tue Nov 15 13:53:26 2005
--- emacs/src/alloc.c   Wed Nov 30 00:04:51 2005
***************
*** 66,71 ****
--- 66,79 ----
  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>
***************
*** 4497,4516 ****
  valid_lisp_object_p (obj)
       Lisp_Object obj;
  {
  #if !GC_MARK_STACK
!   /* Cannot determine this.  */
!   return -1;
  #else
-   void *p;
    struct mem_node *m;
  
    if (INTEGERP (obj))
      return 1;
  
    p = (void *) XPNTR (obj);
- 
    if (PURE_POINTER_P (p))
      return 1;
  
    m = mem_find (p);
  
--- 4505,4540 ----
  valid_lisp_object_p (obj)
       Lisp_Object obj;
  {
+   void *p;
  #if !GC_MARK_STACK
!   int fd;
  #else
    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);
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]