bug in mmap() and mremap() return value - and a fix

Luís Oliveira loliveira at common-lisp.net
Thu Jan 9 01:08:59 UTC 2014


On Thu, Jan 9, 2014 at 12:15 AM, Massimiliano Ghilardi
<massimiliano.ghilardi at gmail.com> wrote:
> 2) Thinking that (or actually defining) MAP_FAILED = -1 is misleading.
>    MAP_FAILED is (void *)-1.

Your patch looks good. Perhaps we could teach cffi-grovel how to
grovel pointers, then we'd be able to ditch the *map-failed-pointer*
bits. I've attached an untested patch that does that. Does using
(constant ... :type pointer) for the MAP_* constants solve the problem
you found?

Cheers,

-- 
Luís Oliveira
http://kerno.org/~luis/
-------------- next part --------------
diff --git a/grovel/grovel.lisp b/grovel/grovel.lisp
index a0c150c..0a0786c 100644
--- a/grovel/grovel.lisp
+++ b/grovel/grovel.lisp
@@ -363,10 +363,16 @@ int main(int argc, char**argv) {
   (dolist (c-name c-names)
     (format out "~&#ifdef ~A~%" c-name)
     (c-export out lisp-name)
-    (c-format out "(cl:defconstant ")
+    (c-format out (if (eq type 'pointer)
+                      "(cl:defparameter "
+                      "(cl:defconstant "))
     (c-print-symbol out lisp-name t)
     (c-format out " ")
     (ecase type
+      (pointer
+       (format out "~&  fprintf(output, ~
+                                \"(cffi:make-pointer %\"PRIuPTR\")\", ~
+                                ~A);" c-name))
       (integer
        (format out "~&  if(_64_BIT_VALUE_FITS_SIGNED_P(~A))~%" c-name)
        (format out "    fprintf(output, \"%lli\", (int64_t) ~A);" c-name)


More information about the osicat-devel mailing list