From: Bart Van Assche Date: Tue, 29 Dec 2009 14:11:38 +0000 (+0000) Subject: Changes: X-Git-Tag: svn/VALGRIND_3_6_0~447 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=244793329b32cf05474382e35f62d7c93a65aea5;p=thirdparty%2Fvalgrind.git Changes: - Made sure that C++ compilers do not complain about the header files include/pub_tool_libcassert.h and include/pub_tool_basics.h. - Added the source file none/tests/valgrind_cpp_test.cpp. This source file is compiled together with the regression tests in order to verify that Valgrind's public header files compile cleanly with a C++ compiler. These modifications are based on a patch provided by Konstantin Serebryany. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10970 --- diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h index e66456136d..b2bf08ea5f 100644 --- a/include/pub_tool_basics.h +++ b/include/pub_tool_basics.h @@ -192,16 +192,19 @@ typedef } SysRes; #elif defined(VGO_darwin) +typedef + enum { + SysRes_MACH=40, // MACH, result is _wLO + SysRes_MDEP, // MDEP, result is _wLO + SysRes_UNIX_OK, // UNIX, success, result is _wHI:_wLO + SysRes_UNIX_ERR // UNIX, error, error is _wHI:_wLO + } + SysResMode; typedef struct { UWord _wLO; UWord _wHI; - enum { - SysRes_MACH=40, // MACH, result is _wLO - SysRes_MDEP, // MDEP, result is _wLO - SysRes_UNIX_OK, // UNIX, success, result is _wHI:_wLO - SysRes_UNIX_ERR // UNIX, error, error is _wHI:_wLO - } _mode; + SysResMode _mode; } SysRes; #else diff --git a/include/pub_tool_libcassert.h b/include/pub_tool_libcassert.h index 6e4f69a08b..c5609388f5 100644 --- a/include/pub_tool_libcassert.h +++ b/include/pub_tool_libcassert.h @@ -33,15 +33,17 @@ #define tl_assert(expr) \ ((void) ((expr) ? 0 : \ - (VG_(assert_fail) (/*isCore?*/False, #expr, \ - __FILE__, __LINE__, __PRETTY_FUNCTION__, \ - ""), \ + (VG_(assert_fail) (/*isCore?*/False, (const Char*)#expr, \ + (const Char*)__FILE__, __LINE__, \ + (const Char*)__PRETTY_FUNCTION__, \ + (const HChar*)""), \ 0))) #define tl_assert2(expr, format, args...) \ ((void) ((expr) ? 0 : \ - (VG_(assert_fail) (/*isCore?*/False, #expr, \ - __FILE__, __LINE__, __PRETTY_FUNCTION__, \ + (VG_(assert_fail) (/*isCore?*/False, (const Char*)#expr, \ + (const Char*)__FILE__, __LINE__, \ + (const Char*)__PRETTY_FUNCTION__, \ format, ##args), \ 0))) diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index 3d4507ac74..1ada7964c3 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -175,6 +175,7 @@ check_PROGRAMS = \ tls \ tls.so \ tls2.so \ + valgrind_cpp_test \ vgprintf \ coolo_sigaction \ gxx304 @@ -262,6 +263,9 @@ else tls2_so_LDFLAGS = -shared endif +valgrind_cpp_test_SOURCES = valgrind_cpp_test.cpp +valgrind_cpp_test_LDADD = -lstdc++ + # C++ tests coolo_sigaction_SOURCES = coolo_sigaction.cpp gxx304_SOURCES = gxx304.cpp diff --git a/none/tests/valgrind_cpp_test.cpp b/none/tests/valgrind_cpp_test.cpp new file mode 100644 index 0000000000..f4edade70a --- /dev/null +++ b/none/tests/valgrind_cpp_test.cpp @@ -0,0 +1,47 @@ +// Test program to verify whether the Valgrind header files compile fine +// with a C++ compiler. + + +#include +#include +#include "pub_tool_basics.h" +#include "pub_tool_libcassert.h" +#include "pub_tool_libcbase.h" +#include "pub_tool_mallocfree.h" +#include "pub_tool_libcprint.h" +#include "pub_tool_libcfile.h" +#include "pub_tool_libcproc.h" +#include "pub_tool_vki.h" +#include "pub_tool_threadstate.h" +#include "pub_tool_errormgr.h" +#include "pub_tool_options.h" +#include "pub_tool_machine.h" +#include "pub_tool_debuginfo.h" +#include "pub_tool_seqmatch.h" +#include "pub_tool_tooliface.h" +#include "pub_tool_options.h" + +#if defined(VGO_darwin) +int CheckSys() +{ + return SysRes_MACH; +} +#endif + +void CheckAssert(int x) +{ + tl_assert(x); + tl_assert2(x, "fail"); +} + +int main(int argc, char** argv) +{ + fprintf(stderr, "Compilation succeeded.\n"); + return 0; +} + +void VG_(assert_fail)(Bool isCore, const Char* expr, const Char* file, + Int line, const Char* fn, const HChar* format, ... ) +{ + abort(); +}