Kaynağa Gözat

use_starpu_macros.cocci : add support for STARPU_MIN and STARPU_MAX

Cyril Roelandt 13 yıl önce
ebeveyn
işleme
b65c0d1934

+ 19 - 0
tools/dev/experimental/use_starpu_macros.cocci

@@ -24,3 +24,22 @@
 -	assert(
 +	STARPU_ASSERT(
 ...)
+
+
+@min_max@
+identifier i;
+expression E1, E2;
+@@
+(
+- 	return E1<E2?E1:E2;
++ 	return STARPU_MIN(E1, E2);
+|
+-	i =  E1<E2?E1:E2            // No semi-colon at the end, so that it
++	i = STARPU_MIN(E1, E2)      // matches both "i = ..." and "t i = ..."
+|
+-	return E1>E2?E1:E2;
++	return STAPU_MAX(E1, E2);
+|
+-	i = E1>E2?E1:E2             // No semi-colon at the end, so that it
++	i = STARPU_MAX(E1, E2)      // matches both "i = ..." and "t i = ..."
+)

+ 91 - 2
tools/dev/experimental/use_starpu_macros_test.c

@@ -17,11 +17,100 @@
 static void
 foo(void)
 {
-	abort();
+	abort(); /* STARPU_ABORT() */
 }
 
 static void
 bar(struct starpu_task *task)
 {
-	assert(task && task->cl);
+	assert(task && task->cl); /* STARPU_ASSERT(task && task->cl) */
+}
+
+/*
+ * STARPU_MIN
+ */
+static int
+min(int a, int b)
+{
+	return a<b?a:b; /* return STARPU_MIN(a, b); */
+}
+
+static int
+min2(int a, int b)
+{
+	int res;
+	res = a<b?a:b; /* res = STARPU_MIN(a,b); */
+	return res;
+}
+
+static int
+min3(int a, int b)
+{
+	int res = a<b?a:b; /* int res = a<b?a:b; */
+	return res;
+}
+
+static int
+min4(int a, int b)
+{
+	return a>b?b:a; /* return STARPU_MIN(a,b); */
+}
+
+static int
+min5(int a, int b)
+{
+	int res;
+	res = a>b?b:a; /* res = STARPU_MIN(a,b); */
+}
+
+static int
+min6(int a, int b)
+{
+	int res = a>b?b:a; /* int res = STARPU_MIN(a, b); */
+	return res;
+}
+
+/*
+ * STARPU_MAX
+ */
+static int
+max(int a, int b)
+{
+	return a<b?b:a; /* return STARPU_MAX(a, b); */
+}
+
+static int
+max2(int a, int b)
+{
+	int res;
+	res = a<b?b:a; /* res = STARPU_MAX(a, b); */
+	return res;
+}
+
+static int
+max3(int a, int b)
+{
+	int res = a<b?b:a; /* int res = STARPU_MAX(a, b); */
+	return res;
+}
+
+static int
+max4(int a, int b)
+{
+	return a>b?a:b; /* return STARPU_MAX(a, b); */
+}
+
+static int
+max5(int a, int b)
+{
+	int res;
+	res = a>b?a:b; /* res = STARPU_MAX(a, b); */
+	return res;
+}
+
+static int
+max6(int a, int b)
+{
+	int res = a>b?a:b; /* int res = STARPU_MAX(a, b); */
+	return res;
 }