X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-posix%2Fmacros.lisp;h=dd22a7c943bdf7c3d906f3bd4542228261f475ad;hb=8e9908b6f79b7bb52a281cfcbf0712d4b914f3cf;hp=c69182694aa8246a7d932df11402409a9ffbeeda;hpb=607f3e366b0e5b5fb4606202a6a5f625c05c3838;p=sbcl.git diff --git a/contrib/sb-posix/macros.lisp b/contrib/sb-posix/macros.lisp index c691826..dd22a7c 100644 --- a/contrib/sb-posix/macros.lisp +++ b/contrib/sb-posix/macros.lisp @@ -17,8 +17,28 @@ (null (sb-alien:sap-alien (sb-sys:int-sap 0) (* t))) ((alien (* t)) alien-pointer-to-anything-or-nil)) -(defun lisp-for-c-symbol (s) - (intern (substitute #\- #\_ (string-upcase s)) :sb-posix)) +(defun lisp-for-c-symbol (name) + (etypecase name + (list + (lisp-for-c-symbol (car name))) + (string + (let ((root (if (eql #\_ (char name 0)) (subseq name 1) name))) + (intern (substitute #\- #\_ (string-upcase root)) :sb-posix))))) + +(defun real-c-name (name) + (etypecase name + (list + (destructuring-bind (name &key c-name options) name + (if c-name + c-name + (cond #+largefile + ((or (eql options :largefile) + (member :largefile options)) + (format nil "~a_largefile" name)) + (t + name))))) + (string + name))) (defmacro define-call-internally (lisp-name c-name return-type error-predicate &rest arguments) @@ -49,11 +69,12 @@ `(sb-int:style-warn "Didn't find definition for ~S" ,c-name))) (defmacro define-call (name return-type error-predicate &rest arguments) - (let ((lisp-name (lisp-for-c-symbol name))) + (let ((lisp-name (lisp-for-c-symbol name)) + (real-c-name (real-c-name name))) `(progn (export ',lisp-name :sb-posix) (define-call-internally ,lisp-name - ,name + ,real-c-name ,return-type ,error-predicate ,@arguments))))