sharplispers / ironclad

A cryptographic toolkit written in Common Lisp
BSD 3-Clause "New" or "Revised" License
165 stars 28 forks source link

Avoid compiler macros on unsupported implementations? #76

Closed kilianmh closed 3 weeks ago

kilianmh commented 1 month ago

The compiler macro xor-block and copy-block in src/common are only for sbcl on x86 or x86-64.

So should we have a #+(and sbcl (or x86 x86-64)) before these compiler macros so other implementations do not bother?

This should avoid compiler warnings for unused variables and slightly increase compilation speed.

E.g. on CCL we get these warnings during compilation when loading with asdf:

;   In (COMPILER-MACRO-FUNCTION XOR-BLOCK): Unused lexical variable OUTPUT-BLOCK-START
;   In (COMPILER-MACRO-FUNCTION XOR-BLOCK): Unused lexical variable OUTPUT-BLOCK
;   In (COMPILER-MACRO-FUNCTION XOR-BLOCK): Unused lexical variable INPUT-BLOCK2-START
;   In (COMPILER-MACRO-FUNCTION XOR-BLOCK): Unused lexical variable INPUT-BLOCK2
;   In (COMPILER-MACRO-FUNCTION XOR-BLOCK): Unused lexical variable INPUT-BLOCK1-START
;   In (COMPILER-MACRO-FUNCTION XOR-BLOCK): Unused lexical variable INPUT-BLOCK1
;   In (COMPILER-MACRO-FUNCTION XOR-BLOCK): Unused lexical variable BLOCK-LENGTH
;   In (COMPILER-MACRO-FUNCTION XOR-BLOCK): Unused lexical variable ENV
;   In (COMPILER-MACRO-FUNCTION COPY-BLOCK): Unused lexical variable OUTPUT-BLOCK-START
;   In (COMPILER-MACRO-FUNCTION COPY-BLOCK): Unused lexical variable OUTPUT-BLOCK
;   In (COMPILER-MACRO-FUNCTION COPY-BLOCK): Unused lexical variable INPUT-BLOCK-START
;   In (COMPILER-MACRO-FUNCTION COPY-BLOCK): Unused lexical variable INPUT-BLOCK
;   In (COMPILER-MACRO-FUNCTION COPY-BLOCK): Unused lexical variable BLOCK-LENGTH
;   In (COMPILER-MACRO-FUNCTION COPY-BLOCK): Unused lexical variable ENV
glv2 commented 1 month ago

In fact, CCL and ECL have optimized ub64ref/le and ub32ref/le functions, so I tried adding support for CCL and ECL to the compiler macros, but it didn't really improve performances (it even made it much worse in some cases).

I added a (declare (ignorable env block-length ...)) form to remove the compiler warnings.

kilianmh commented 3 weeks ago

Thank you @glv2 Fixed in ca8880797cbe235a94c0178871807d7fe476330a