Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/cassume/basesize.c
5986 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2014 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#include "ctest.h"
24
25
void verifyJNISizes(void) {
26
PORT_ACCESS_FROM_PORT(cTestPortLib);
27
j9tty_printf(PORTLIB, "Verifying JNI Sizes\n");
28
j9_assume(sizeof(jbyte), 1);
29
j9_assume(sizeof(jchar), 2);
30
j9_assume(sizeof(jshort), 2);
31
j9_assume(sizeof(jint), 4);
32
j9_assume(sizeof(jlong), 8);
33
j9_assume(sizeof(jfloat), 4);
34
j9_assume(sizeof(jdouble), 8);
35
}
36
37
38
39
void
40
verifyUDATASizes(void)
41
{
42
PORT_ACCESS_FROM_PORT(cTestPortLib);
43
/* 64 bit are a bit harder to test since we can't encode the constants easily without causing warnings */
44
U_64 testU64Max = ((U_64)0xffffffff) << 32 | (U_64)0xffffffff;
45
I_64 testI64Max = (I_64)(((U_64)0x7fffffff) << 32 | (U_64)0xffffffff);
46
I_64 testI64Min = (I_64)(((U_64)0x80000000) << 32 | (U_64)0x00000000);
47
U_32 testU32Max = 0xffffffff;
48
I_32 testI32Max = 0x7fffffff;
49
I_32 testI32Min = 0x80000000;
50
51
j9tty_printf(PORTLIB, "Verifying VM Type Sizes\n");
52
/* check VM type sizes */
53
j9_assume(sizeof(U_8), 1);
54
j9_assume(sizeof(I_8), 1);
55
j9_assume(sizeof(U_16), 2);
56
j9_assume(sizeof(I_16), 2);
57
j9_assume(sizeof(U_32), 4);
58
j9_assume(sizeof(I_32), 4);
59
j9_assume(sizeof(U_64), 8);
60
j9_assume(sizeof(I_64), 8);
61
j9_assume(sizeof(UDATA), sizeof(void*));
62
j9_assume(sizeof(IDATA), sizeof(void*));
63
64
/* the VM j9_assumes that a fn pointer can be stored in a void pointer */
65
j9_assume(sizeof(void*), sizeof( void(*)(void) ));
66
67
/* check constants */
68
j9_assume(U_8_MAX, 0xff);
69
j9_assume(I_8_MAX, 0x7f);
70
j9_assume(I_8_MIN, 0x80);
71
72
j9_assume(U_16_MAX, 0xffff);
73
j9_assume(I_16_MAX, 0x7fff);
74
j9_assume(I_16_MIN, 0x8000);
75
76
j9_assume(U_32_MAX, testU32Max);
77
j9_assume(I_32_MAX, testI32Max);
78
j9_assume(I_32_MIN, testI32Min);
79
80
j9_assume(U_64_MAX, testU64Max);
81
j9_assume(I_64_MAX, testI64Max);
82
j9_assume(I_64_MIN, testI64Min);
83
}
84
85