Skip to content

Commit e7cf25c

Browse files
committed
8340801: Disable ubsan checks in some awt/2d coding
Reviewed-by: ihse, lucy, goetz, jwaters
1 parent 577babf commit e7cf25c

File tree

2 files changed

+45
-0
lines changed
  • src
    • java.base/share/native/libjava
    • java.desktop/share/native/libawt/java2d/loops

2 files changed

+45
-0
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2024 SAP SE. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation.
9+
*
10+
* This code is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* version 2 for more details (a copy is included in the LICENSE file that
14+
* accompanied this code).
15+
*
16+
* You should have received a copy of the GNU General Public License version
17+
* 2 along with this work; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21+
* or visit www.oracle.com if you need additional information or have any
22+
* questions.
23+
*
24+
*/
25+
26+
#ifndef _UB_H_
27+
#define _UB_H_
28+
29+
/* ATTRIBUTE_NO_UBSAN - Function attribute which informs the compiler to disable UBSan checks in the
30+
* following function or method.
31+
*/
32+
#ifdef UNDEFINED_BEHAVIOR_SANITIZER
33+
#if defined(__clang__) || defined(__GNUC__)
34+
#define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined")))
35+
#endif
36+
#endif
37+
38+
#ifndef ATTRIBUTE_NO_UBSAN
39+
#define ATTRIBUTE_NO_UBSAN
40+
#endif
41+
42+
#endif

src/java.desktop/share/native/libawt/java2d/loops/IntRgb.c

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#include "ByteGray.h"
3535
#include "Index12Gray.h"
3636

37+
#include "ub.h"
38+
3739
/*
3840
* This file declares, registers, and defines the various graphics
3941
* primitive loops to manipulate surfaces of type "IntRgb".
@@ -166,6 +168,7 @@ DEFINE_ALPHA_MASKBLIT(IntArgbPre, IntRgb, 4ByteArgb)
166168

167169
DEFINE_ALPHA_MASKBLIT(IntRgb, IntRgb, 4ByteArgb)
168170

171+
ATTRIBUTE_NO_UBSAN
169172
DEFINE_SOLID_DRAWGLYPHLISTAA(IntRgb, 3ByteRgb)
170173

171174
DEFINE_SOLID_DRAWGLYPHLISTLCD(IntRgb, 3ByteRgb)

0 commit comments

Comments
 (0)