X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=gacela_misc.lisp;h=ac7b479db805ded3532e7725e0cc4bd87168a74e;hb=a559c9a47d17f1a7ca0a4dff3edcd39449d1821e;hp=6ebcf38ddde8e1e299c8cd68c335a22df38f17d0;hpb=678a1561ca858c34fecf04792831caf68559c2ac;p=gacela.git diff --git a/gacela_misc.lisp b/gacela_misc.lisp index 6ebcf38..ac7b479 100755 --- a/gacela_misc.lisp +++ b/gacela_misc.lisp @@ -63,6 +63,20 @@ (cond ((or (numberp list) (numberp pattern)) (and (numberp list) (numberp pattern))) (t t))))) +(defun nearest-power-of-two (n) + (labels ((power (p n) + (cond ((> (* p 2) n) p) + (t (power (* p 2) n))))) + (power 1 n))) + +(defmacro mapcconst (type c-type name) + `(progn + (defcfun ,(concatenate 'string c-type " gacela_" name " (void)") 0 + ,(concatenate 'string "return " name ";")) + (defentry ,(intern (string-upcase name)) () + (,type ,(concatenate 'string "gacela_" name))))) + + ;Geometry (defun dotp (dot) (match-pattern dot '(0 0)))