|
From: <sv...@va...> - 2005-06-28 19:44:13
|
Author: njn
Date: 2005-06-28 20:44:10 +0100 (Tue, 28 Jun 2005)
New Revision: 4044
Log:
Don't use non-ansi features in valgrind.h in case it's used in a file
compiled with -ansi. Added a regtest for it. Fixed bug #103182.
Added:
trunk/none/tests/ansi.c
trunk/none/tests/ansi.stderr.exp
trunk/none/tests/ansi.vgtest
Modified:
trunk/include/valgrind.h
trunk/none/tests/Makefile.am
Modified: trunk/include/valgrind.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/valgrind.h 2005-06-28 19:20:46 UTC (rev 4043)
+++ trunk/include/valgrind.h 2005-06-28 19:44:10 UTC (rev 4044)
@@ -74,6 +74,10 @@
=20
#include <stdarg.h>
=20
+/* Nb: this file might be included in a file compiled with -ansi. So
+ we can't use C++ style "//" comments nor the "asm" keyword (instead
+ use "__asm__"). */
+
/* If we're not compiling for our target architecture, don't generate
any inline asms. Note that in this file we're using the compiler's
CPP symbols for identifying architectures, which are different to
@@ -132,15 +136,15 @@
_zzq_args[2] =3D (volatile unsigned long long)(_zzq_arg2); \
_zzq_args[3] =3D (volatile unsigned long long)(_zzq_arg3); \
_zzq_args[4] =3D (volatile unsigned long long)(_zzq_arg4); \
- asm volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
- "rorl $27, %%eax ; rorl $5, %%eax\n\t" \
- "roll $13, %%eax ; roll $19, %%eax" \
- : "=3Dd" (_zzq_rlval) \
- : "a" (&_zzq_args[0]), "0" (_zzq_default) \
- : "cc", "memory" \
- ); \
+ __asm__ volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
+ "rorl $27, %%eax ; rorl $5, %%eax\n\t" \
+ "roll $13, %%eax ; roll $19, %%eax" \
+ : "=3Dd" (_zzq_rlval) \
+ : "a" (&_zzq_args[0]), "0" (_zzq_default) \
+ : "cc", "memory" \
+ ); \
}
-#endif // __x86_64__
+#endif /* __x86_64__ */
=20
#ifdef __i386__
#define VALGRIND_MAGIC_SEQUENCE( \
@@ -153,18 +157,18 @@
_zzq_args[2] =3D (unsigned int)(_zzq_arg2); \
_zzq_args[3] =3D (unsigned int)(_zzq_arg3); \
_zzq_args[4] =3D (unsigned int)(_zzq_arg4); \
- asm volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
- "rorl $27, %%eax ; rorl $5, %%eax\n\t" \
- "roll $13, %%eax ; roll $19, %%eax" \
- : "=3Dd" (_zzq_rlval) \
- : "a" (&_zzq_args[0]), "0" (_zzq_default) \
- : "cc", "memory" \
- ); \
+ __asm__ volatile("roll $29, %%eax ; roll $3, %%eax\n\t" \
+ "rorl $27, %%eax ; rorl $5, %%eax\n\t" \
+ "roll $13, %%eax ; roll $19, %%eax" \
+ : "=3Dd" (_zzq_rlval) \
+ : "a" (&_zzq_args[0]), "0" (_zzq_default) \
+ : "cc", "memory" \
+ ); \
}
-#endif // __i386__
+#endif /* __i386__ */
=20
#ifdef __arm__
-// XXX: temporary, until MAGIC_SEQUENCE is written properly
+/* XXX: temporary, until MAGIC_SEQUENCE is written properly */
extern int printf (__const char *__restrict __format, ...);
extern void exit (int __status);
#define VALGRIND_MAGIC_SEQUENCE( =
\
@@ -179,11 +183,11 @@
_zzq_args[4] =3D (volatile unsigned int)(_zzq_arg4); =
\
(_zzq_rlval) =3D (_zzq_default);/* temporary only */ \
printf("argh: MAGIC_SEQUENCE"); exit(1); \
- asm volatile(""); =
\
+ __asm__ volatile(""); =
\
}
-// XXX: make sure that the register holding the args and the register ta=
king
-// the return value match what the scheduler is expecting.
-#endif // __arm__
+/* XXX: make sure that the register holding the args and the register ta=
king
+ * the return value match what the scheduler is expecting. */
+#endif /* __arm__ */
=20
#ifdef __powerpc__
#define VALGRIND_MAGIC_SEQUENCE( =
\
@@ -199,20 +203,20 @@
_zzq_args[3] =3D (volatile unsigned int)(_zzq_arg3); =
\
_zzq_args[4] =3D (volatile unsigned int)(_zzq_arg4); =
\
_zzq_ptr =3D _zzq_args; =
\
- asm volatile("tw 0,3,27\n\t" =
\
- "rlwinm 0,0,29,0,0\n\t" =
\
- "rlwinm 0,0,3,0,0\n\t" =
\
- "rlwinm 0,0,13,0,0\n\t" =
\
- "rlwinm 0,0,19,0,0\n\t" =
\
- "nop\n\t" =
\
- : "=3Dr" (_zzq_tmp) =
\
- : "0" (_zzq_default), "r" (_zzq_ptr) =
\
- : "memory"); =
\
+ __asm__ volatile("tw 0,3,27\n\t" =
\
+ "rlwinm 0,0,29,0,0\n\t" =
\
+ "rlwinm 0,0,3,0,0\n\t" =
\
+ "rlwinm 0,0,13,0,0\n\t" =
\
+ "rlwinm 0,0,19,0,0\n\t" =
\
+ "nop\n\t" =
\
+ : "=3Dr" (_zzq_tmp) =
\
+ : "0" (_zzq_default), "r" (_zzq_ptr) =
\
+ : "memory"); =
\
_zzq_rlval =3D (__typeof__(_zzq_rlval)) _zzq_tmp; =
\
}
-#endif // __powerpc__
+#endif /* __powerpc__ */
=20
-// Insert assembly code for other architectures here...
+/* Insert assembly code for other architectures here... */
=20
#endif /* NVALGRIND */
=20
@@ -229,8 +233,8 @@
start at 0x2000.
*/
=20
-// These macros are used by tools -- they must be public, but don't embe=
d them
-// into other programs.
+/* These macros are used by tools -- they must be public, but don't embe=
d them
+ * into other programs. */
#define VG_USERREQ_TOOL_BASE(a,b) \
((unsigned int)(((a)&0xff) << 24 | ((b)&0xff) << 16))
#define VG_IS_TOOL_USERREQ(a, b, v) \
Modified: trunk/none/tests/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/Makefile.am 2005-06-28 19:20:46 UTC (rev 4043)
+++ trunk/none/tests/Makefile.am 2005-06-28 19:44:10 UTC (rev 4044)
@@ -4,6 +4,7 @@
noinst_SCRIPTS =3D filter_none_discards filter_stderr
=20
EXTRA_DIST =3D $(noinst_SCRIPTS) \
+ ansi.stderr.exp ansi.vgtest \
args.stderr.exp args.stdout.exp args.vgtest \
async-sigs.stderr.exp async-sigs.stdout.exp async-sigs.vgtest \
bitfield1.stderr.exp bitfield1.vgtest \
@@ -65,7 +66,7 @@
yield.stderr.exp yield.stdout.exp yield.vgtest
=20
check_PROGRAMS =3D \
- args async-sigs bitfield1 blockfault closeall coolo_strlen \
+ ansi args async-sigs bitfield1 blockfault closeall coolo_strlen \
discard exec-sigmask execve faultstatus fcntl_setown floored fork \
fucomip \
manythreads \
@@ -84,6 +85,8 @@
AM_CXXFLAGS =3D $(AM_CFLAGS)
=20
# generic C ones
+ansi_SOURCES =3D ansi.c
+ansi_CFLAGS =3D -ansi
args_SOURCES =3D args.c
async_sigs_SOURCES =3D async-sigs.c
bitfield1_SOURCES =3D bitfield1.c
Added: trunk/none/tests/ansi.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/ansi.c 2005-06-28 19:20:46 UTC (rev 4043)
+++ trunk/none/tests/ansi.c 2005-06-28 19:44:10 UTC (rev 4044)
@@ -0,0 +1,14 @@
+/* It's possible that people #include valgrind.h in files compiled with
+ * -ansi. So valgrind.h shouldn't contain any code that won't pass -ans=
i,
+ * such as C++ style "//" comments. This test ensures that. So the tes=
t is
+ * really that it compiles ok, rather than it runs ok. From bug report
+ * #103182. */
+
+#include "valgrind.h"
+#include "../../memcheck/memcheck.h"
+#include "../../helgrind/helgrind.h"
+
+int main(void)
+{
+ return 0;
+}
Added: trunk/none/tests/ansi.stderr.exp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/ansi.stderr.exp 2005-06-28 19:20:46 UTC (rev 4043)
+++ trunk/none/tests/ansi.stderr.exp 2005-06-28 19:44:10 UTC (rev 4044)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/ansi.vgtest
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/none/tests/ansi.vgtest 2005-06-28 19:20:46 UTC (rev 4043)
+++ trunk/none/tests/ansi.vgtest 2005-06-28 19:44:10 UTC (rev 4044)
@@ -0,0 +1 @@
+prog: ansi
|