scripts: Add coccinelle file to use BIT macro
This commit is contained in:
parent
7888f214bb
commit
9a3ecba010
14
scripts/coccinelle/bit-macro.cocci
Normal file
14
scripts/coccinelle/bit-macro.cocci
Normal file
@ -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)
|
9
scripts/coccinelle/macros.h
Normal file
9
scripts/coccinelle/macros.h
Normal file
@ -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 ___
|
11
scripts/spatch.sh
Executable file
11
scripts/spatch.sh
Executable file
@ -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/
|
Loading…
x
Reference in New Issue
Block a user