diff --git a/scripts/coccinelle/bit-macro.cocci b/scripts/coccinelle/bit-macro.cocci new file mode 100644 index 0000000..bfaf5da --- /dev/null +++ b/scripts/coccinelle/bit-macro.cocci @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-3.0-only +// Replace shifts with BIT macro + +@@ expression val; @@ +-(1 << val) ++BIT(val) + +@@ expression val; @@ +-(1U << val) ++BIT(val) + +@@ expression val; @@ +-1 << val ++BIT(val) diff --git a/scripts/coccinelle/macros.h b/scripts/coccinelle/macros.h new file mode 100644 index 0000000..c5e5493 --- /dev/null +++ b/scripts/coccinelle/macros.h @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-3.0-only +// SDCC extenstions that need to be defined away for spatch + +#define __at(x) +#define __code +#define __critical +#define __data +#define __reentrant +#define ___ diff --git a/scripts/spatch.sh b/scripts/spatch.sh new file mode 100755 index 0000000..817f67b --- /dev/null +++ b/scripts/spatch.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-3.0-only + +spatch \ + --sp-file ./scripts/coccinelle/bit-macro.cocci \ + --macro-file ./scripts/coccinelle/macros.h \ + --no-includes \ + --include-headers \ + --preprocess \ + --in-place \ + --dir src/