From 71f5a915d8c0543e90270cdc26715f222bdab14e Mon Sep 17 00:00:00 2001
From: Juan Jose Garcia Ripoll <jjgarcia@users.sourceforge.net>
Date: Sun, 25 Apr 2010 19:41:05 +0200
Subject: [PATCH] In cffi-ecl.lisp, provide inline expansions for the pointer operations.

---
 src/cffi-ecl.lisp |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/src/cffi-ecl.lisp b/src/cffi-ecl.lisp
index f76fdb6..73866d7 100644
--- a/src/cffi-ecl.lisp
+++ b/src/cffi-ecl.lisp
@@ -112,7 +112,8 @@ SIZE-VAR is supplied, it will be bound to SIZE during BODY."
 
 (defun pointer-eq (ptr1 ptr2)
   "Return true if PTR1 and PTR2 point to the same address."
-  (= (ffi:pointer-address ptr1) (ffi:pointer-address ptr2)))
+  ;; In ECL two pointers are EQUAL if they point to the same address.
+  (equal ptr1 ptr2))
 
 (defun make-pointer (address)
   "Return a pointer pointing to ADDRESS."
@@ -122,6 +123,27 @@ SIZE-VAR is supplied, it will be bound to SIZE during BODY."
   "Return the address pointed to by PTR."
   (ffi:pointer-address ptr))
 
+;;;# Inline expansions for the former
+
+(define-compiler-macro null-pointer ()
+  '(si::allocate-foreign-data :void 0))
+
+(define-compiler-macro inc-pointer (ptr offset)
+  `(ffi:c-inline (,ptr ,offset) (:pointer-void :cl-index) :pointer-void
+                 "((char*)#0)+#1" :one-liner t))
+
+(define-compiler-macro pointerp (ptr)
+  `(typep ,ptr 'si:foreign-data))
+
+(define-compiler-macro pointer-eq (ptr1 ptr2)
+  `(equal ,ptr1 ,ptr2))
+
+(define-compiler-macro make-pointer (address)
+  `(ffi:make-pointer ,address :void))
+
+(define-compiler-macro pointer-address (ptr)
+  `(ffi:pointer-address ,ptr))
+
 ;;;# Shareable Vectors
 ;;;
 ;;; This interface is very experimental.  WITH-POINTER-TO-VECTOR-DATA
-- 
1.6.6.1


