/*******************************************************************************1* Copyright (c) 1991, 2014 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122#include "ctest.h"2324void verifyJNISizes(void) {25PORT_ACCESS_FROM_PORT(cTestPortLib);26j9tty_printf(PORTLIB, "Verifying JNI Sizes\n");27j9_assume(sizeof(jbyte), 1);28j9_assume(sizeof(jchar), 2);29j9_assume(sizeof(jshort), 2);30j9_assume(sizeof(jint), 4);31j9_assume(sizeof(jlong), 8);32j9_assume(sizeof(jfloat), 4);33j9_assume(sizeof(jdouble), 8);34}35363738void39verifyUDATASizes(void)40{41PORT_ACCESS_FROM_PORT(cTestPortLib);42/* 64 bit are a bit harder to test since we can't encode the constants easily without causing warnings */43U_64 testU64Max = ((U_64)0xffffffff) << 32 | (U_64)0xffffffff;44I_64 testI64Max = (I_64)(((U_64)0x7fffffff) << 32 | (U_64)0xffffffff);45I_64 testI64Min = (I_64)(((U_64)0x80000000) << 32 | (U_64)0x00000000);46U_32 testU32Max = 0xffffffff;47I_32 testI32Max = 0x7fffffff;48I_32 testI32Min = 0x80000000;4950j9tty_printf(PORTLIB, "Verifying VM Type Sizes\n");51/* check VM type sizes */52j9_assume(sizeof(U_8), 1);53j9_assume(sizeof(I_8), 1);54j9_assume(sizeof(U_16), 2);55j9_assume(sizeof(I_16), 2);56j9_assume(sizeof(U_32), 4);57j9_assume(sizeof(I_32), 4);58j9_assume(sizeof(U_64), 8);59j9_assume(sizeof(I_64), 8);60j9_assume(sizeof(UDATA), sizeof(void*));61j9_assume(sizeof(IDATA), sizeof(void*));6263/* the VM j9_assumes that a fn pointer can be stored in a void pointer */64j9_assume(sizeof(void*), sizeof( void(*)(void) ));6566/* check constants */67j9_assume(U_8_MAX, 0xff);68j9_assume(I_8_MAX, 0x7f);69j9_assume(I_8_MIN, 0x80);7071j9_assume(U_16_MAX, 0xffff);72j9_assume(I_16_MAX, 0x7fff);73j9_assume(I_16_MIN, 0x8000);7475j9_assume(U_32_MAX, testU32Max);76j9_assume(I_32_MAX, testI32Max);77j9_assume(I_32_MIN, testI32Min);7879j9_assume(U_64_MAX, testU64Max);80j9_assume(I_64_MAX, testI64Max);81j9_assume(I_64_MIN, testI64Min);82}838485