1 /*
 2  * Copyright (c) 2020, 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  * @test
26  * @modules jdk.incubator.jextract
27  * @library /test/lib
28  * @build BadBitfieldTest
29  * @run testng/othervm --enable-native-access=jdk.incubator.jextract BadBitfieldTest
30  */
31 
32 /*
33  * MSVC: (/d1reportSingleClassLayoutFoo)
34  * class Foo    size(24):
35  *      +---
36  *  0.    | a (bitstart=0,nbits=45)
37  *  8.    | b (bitstart=0,nbits=24)
38  *  8.    | c (bitstart=24,nbits=1)
39  * 16.    | d (bitstart=0,nbits=58)
40  *      +---
41  *
42  * SysV: (PAHole)
43  * struct Foo {
44  *     long long int a:45;                0:19   8
45  *     long long int b:24;                0:251  8
46  *     XXX 251 bits hole, try to pack
47  *     long long int c:1;                 8:58   8
48  *     long long int d:58;                8: 0   8
49  *
50  *     size: 16, cachelines: 1, members: 4
51  *     bit holes: 1, sum bit holes: 251 bits
52  *     bit_padding: 5 bits
53  *     last cacheline: 16 bytes
54  * };
55  *
56  */
57 
58 import org.testng.annotations.Test;
59 
60 public class BadBitfieldTest extends JextractToolRunner {
61     @Test
62     public void testBadBitfield() {
63         run("-d", getOutputFilePath("badBitfieldsGen").toString(),
64                 getInputFilePath("badBitfields.h").toString()).checkSuccess();
65     }
66 }