This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[SPATCH] Use __glibc_likely and __glibc_unlikely.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Mon, 20 May 2013 21:28:53 +0200
- Subject: [SPATCH] Use __glibc_likely and __glibc_unlikely.
Hi,
I as Andy suggested tried coccinette. I decided as first example
rewrite builtin_expect to glibc_likely/unlikely.
The script I ran is below (could take hour to run).
Generated patches are here, they are 100kb and 500kb files.
http://kam.mff.cuni.cz/~ondra/expect.patch
http://kam.mff.cuni.cz/~ondra/expect2.patch
Comments?
---
scripts/expect.cocci | 4 ++++
scripts/expect2.cocci | 4 ++++
scripts/sempatch | 3 +++
3 files changed, 11 insertions(+), 0 deletions(-)
create mode 100644 scripts/expect.cocci
create mode 100644 scripts/expect2.cocci
create mode 100644 scripts/sempatch
diff --git a/scripts/expect.cocci b/scripts/expect.cocci
new file mode 100644
index 0000000..de759de
--- /dev/null
+++ b/scripts/expect.cocci
@@ -0,0 +1,4 @@
+@@ expression e; @@
+
+- __builtin_expect(e, 1)
++ __glibc_likely(e)
diff --git a/scripts/expect2.cocci b/scripts/expect2.cocci
new file mode 100644
index 0000000..ad015e1
--- /dev/null
+++ b/scripts/expect2.cocci
@@ -0,0 +1,4 @@
+@@ expression e; @@
+
+- __builtin_expect(e, 0)
++ __glibc_unlikely(e)
diff --git a/scripts/sempatch b/scripts/sempatch
new file mode 100644
index 0000000..fdb7257
--- /dev/null
+++ b/scripts/sempatch
@@ -0,0 +1,3 @@
+cd ..
+spatch -sp_file expect2.cocci -dir . > expect2.patch
+spatch -sp_file expect.cocci -dir . > expect.patch
--
1.7.4.4