(destructuring-bind (c-name &rest elements) c-struct
(format stream "printf(\"(sb-grovel::define-c-struct ~A %d)\\n\",sizeof (~A));~%" lisp-name c-name)
(dolist (e elements)
- (destructuring-bind (lisp-type lisp-el-name c-type c-el-name) e
+ (destructuring-bind (lisp-type lisp-el-name c-type c-el-name &key distrust-length) e
;; FIXME: this format string doesn't actually guarantee
;; non-multilined-string-constantness, it just makes it more
;; likely. Sort out the required behaviour (and maybe make
(format stream "{ ~A t;printf(\"%d \",((unsigned long)&(t.~A)) - ((unsigned long)&(t)) ); }~%"
c-name c-el-name)
;; length
- (format stream "{ ~A t;printf(\"%d\",(sizeof t.~A));}~%"
- c-name c-el-name)
+ (if distrust-length
+ (format stream "printf(\"|CL|:|NIL|\");")
+ (format stream "{ ~A t;printf(\"%d\",(sizeof t.~A));}~%"
+ c-name c-el-name))
(format stream "printf(\")\\n\");~%")))))
(defun c-for-function (stream lisp-name alien-defn)
(destructuring-bind (type lispname cname &optional doc) def
(cond ((eq type :integer)
(format stream
- "printf(\"(cl:defconstant ~A %d \\\"~A\\\")\\\n\",~A);~%"
- lispname doc cname))
+ "#ifdef ~A~%~
+ printf(\"(cl:defconstant ~A %d \\\"~A\\\")\\\n\",~A);~%~
+ #else~%~
+ printf(\"(sb-int:style-warn \\\"Couln't grovel definition for ~A (unknown to the C compiler).\\\")\\n\");~%~
+ #endif~%"
+ cname lispname doc cname cname))
((eq type :type)
(format stream
"printf(\"(sb-alien:define-alien-type ~A (sb-alien:%ssigned %d))\\\n\",SIGNED_(~A),8*(sizeof(~A)));~%"