Skip to content

Commit

Permalink
Improve rol and ror code for ECL
Browse files Browse the repository at this point in the history
It should avoid undefined behavior with some C compilers.
  • Loading branch information
glv2 committed Feb 26, 2024
1 parent a0220ba commit 6a80a6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/common.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ uint64_t r = (n << 56)
(ffi:c-inline (a s)
(:uint32-t :uint8-t)
:uint32-t
"(#0 << #1) | (#0 >> (32 - #1))"
"(#0 << #1) | (#0 >> (-#1 & 31))"
:one-liner t
:side-effects nil)

Expand All @@ -578,7 +578,7 @@ uint64_t r = (n << 56)
(ffi:c-inline (a s)
(:uint32-t :uint8-t)
:uint32-t
"(#0 << (32 - #1)) | (#0 >> #1)"
"(#0 << (-#1 & 31)) | (#0 >> #1)"
:one-liner t
:side-effects nil)

Expand Down Expand Up @@ -720,7 +720,7 @@ uint64_t r = (n << 56)
(ffi:c-inline (a s)
(:uint64-t :uint8-t)
:uint64-t
"(#0 << #1) | (#0 >> (64 - #1))"
"(#0 << #1) | (#0 >> (-#1 & 63))"
:one-liner t
:side-effects nil)

Expand All @@ -742,7 +742,7 @@ uint64_t r = (n << 56)
(ffi:c-inline (a s)
(:uint64-t :uint8-t)
:uint64-t
"(#0 << (64 - #1)) | (#0 >> #1)"
"(#0 << (-#1 & 63)) | (#0 >> #1)"
:one-liner t
:side-effects nil)

Expand Down

0 comments on commit 6a80a6a

Please sign in to comment.