home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2XLSP1.ZIP / SEGS.LSP < prev    next >
Lisp/Scheme  |  1988-07-19  |  889b  |  60 lines

  1. ; segs.lsp
  2. ; functions to examine code segments of XLISP
  3. ; Andrew Schulman 27-Feb-1988
  4.  
  5. ; address of C function stored in XLISP node
  6. (defun func-addr (x)
  7.     (peek (address-of x 2) 4))
  8.         
  9. ; segment/module where C function lived
  10. (defun func-seg (x)
  11.     (fp-seg (func-addr x)))
  12.         
  13. ; requested protection level
  14. (defun rpl (x)
  15.     (logand 3 x))
  16.         
  17. ; has segment been accessed?
  18. (defun accessedp (x)
  19.     (=
  20.         1
  21.         (logand
  22.             (lar x)
  23.             1)))
  24.  
  25. ; is segment present in memory?
  26. (defun presentp (x)
  27.     (=
  28.         128
  29.         (logand
  30.             (lar x)
  31.             128)))
  32.                 
  33. ; is segment code?
  34. (defun codep (x)
  35.     (=
  36.         8
  37.         (logand
  38.             (lar x)
  39.             8)))
  40.  
  41. ; is segment readable code?                
  42. (defun readp (x)
  43.     (and 
  44.         (codep x)
  45.         (=
  46.             2
  47.             (logand
  48.                 (lar x)
  49.                 2))))
  50.                     
  51. ; is segment writable code?                
  52. (defun writep (x)
  53.     (and 
  54.         (not (codep x))
  55.         (=
  56.             2
  57.             (logand
  58.                 (lar x)
  59.                 2))))
  60.