Skip to content

Commit 96c74af

Browse files
committed
Backport 89dd23f2fab0d98879e68f817923656e113087e3
1 parent e7ab1de commit 96c74af

File tree

6 files changed

+98
-7
lines changed

6 files changed

+98
-7
lines changed

make/hotspot/lib/JvmFlags.gmk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ JVM_CFLAGS_TARGET_DEFINES += \
6767
#
6868

6969
ifeq ($(DEBUG_LEVEL), release)
70+
# release builds disable uses of assert macro from <assert.h>.
71+
JVM_CFLAGS_DEBUGLEVEL := -DNDEBUG
7072
# For hotspot, release builds differ internally between "optimized" and "product"
7173
# in that "optimize" does not define PRODUCT.
7274
ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized)
73-
JVM_CFLAGS_DEBUGLEVEL := -DPRODUCT
75+
JVM_CFLAGS_DEBUGLEVEL += -DPRODUCT
7476
endif
7577
else ifeq ($(DEBUG_LEVEL), fastdebug)
7678
JVM_CFLAGS_DEBUGLEVEL := -DASSERT
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
// Intentionally no #include guard. May be included multiple times for effect.
26+
27+
// See vmassert_uninstall.hpp for usage.
28+
29+
// Remove possible stdlib assert macro (or any others, for that matter).
30+
#undef assert
31+
32+
// Reinstall HotSpot's assert macro, if previously defined.
33+
#ifdef vmassert
34+
#define assert(p, ...) vmassert(p, __VA_ARGS__)
35+
#endif
36+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*
23+
*/
24+
25+
// Intentionally no #include guard. May be included multiple times for effect.
26+
27+
// The files vmassert_uninstall.hpp and vmassert_reinstall.hpp provide a
28+
// workaround for the name collision between HotSpot's assert macro and the
29+
// Standard Library's assert macro. When including a 3rd-party header that
30+
// uses (and so includes) the standard assert macro, wrap that inclusion with
31+
// includes of these two files, e.g.
32+
//
33+
// #include "utilities/vmassert_uninstall.hpp"
34+
// #include <header including standard assert macro>
35+
// #include "utilities/vmassert_reinstall.hpp"
36+
//
37+
// This removes the HotSpot macro definition while pre-processing the
38+
// 3rd-party header, then reinstates the HotSpot macro (if previously defined)
39+
// for following code.
40+
41+
// Remove HotSpot's assert macro, if present.
42+
#ifdef vmassert
43+
#undef assert
44+
#endif // vmassert
45+

test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,13 @@
2424
#include "precompiled.hpp"
2525
#include "gc/shared/memset_with_concurrent_readers.hpp"
2626
#include "utilities/globalDefinitions.hpp"
27-
#include "unittest.hpp"
2827

28+
#include "utilities/vmassert_uninstall.hpp"
2929
#include <string.h>
3030
#include <sstream>
31+
#include "utilities/vmassert_reinstall.hpp"
32+
33+
#include "unittest.hpp"
3134

3235
static unsigned line_byte(const char* line, size_t i) {
3336
return unsigned(line[i]) & 0xFF;

test/hotspot/gtest/jfr/test_networkUtilization.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -42,11 +42,13 @@
4242
#include "utilities/globalDefinitions.hpp"
4343
#include "utilities/growableArray.hpp"
4444

45-
#include "unittest.hpp"
46-
45+
#include "utilities/vmassert_uninstall.hpp"
4746
#include <vector>
4847
#include <list>
4948
#include <map>
49+
#include "utilities/vmassert_reinstall.hpp"
50+
51+
#include "unittest.hpp"
5052

5153
namespace {
5254

test/hotspot/gtest/unittest.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,10 @@
2828
#include <stdio.h>
2929

3030
#define GTEST_DONT_DEFINE_TEST 1
31+
32+
#include "utilities/vmassert_uninstall.hpp"
3133
#include "gtest/gtest.h"
34+
#include "utilities/vmassert_reinstall.hpp"
3235

3336
// gtest/gtest.h includes assert.h which will define the assert macro, but hotspot has its
3437
// own standards incompatible assert macro that takes two parameters.

0 commit comments

Comments
 (0)