]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Changes:
authorBart Van Assche <bvanassche@acm.org>
Tue, 29 Dec 2009 14:11:38 +0000 (14:11 +0000)
committerBart Van Assche <bvanassche@acm.org>
Tue, 29 Dec 2009 14:11:38 +0000 (14:11 +0000)
- 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

include/pub_tool_basics.h
include/pub_tool_libcassert.h
none/tests/Makefile.am
none/tests/valgrind_cpp_test.cpp [new file with mode: 0644]

index e66456136d68a2860c4ea17500e10be2307c95f5..b2bf08ea5f6a0d1f8ce75019fffe6c559dbaa6b1 100644 (file)
@@ -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
index 6e4f69a08bcb2e998c7eaf37eddeb6b6d4394e63..c5609388f567d24aa52af9a3c96e68bbffa14c1b 100644 (file)
 
 #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)))
 
index 3d4507ac746f6a7901f11a8a2696597e24a62ebc..1ada7964c3c3d739a77aabb8bb73d1b386dc4c02 100644 (file)
@@ -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 (file)
index 0000000..f4edade
--- /dev/null
@@ -0,0 +1,47 @@
+// Test program to verify whether the Valgrind header files compile fine
+// with a C++ compiler.
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#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();
+}