Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/common/jdk_util.c
38825 views
/*1* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 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 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include <stdlib.h>26#include <string.h>27#include <ctype.h>28#include <assert.h>2930#include "jvm.h"31#include "jdk_util.h"3233#ifndef JDK_UPDATE_VERSION34/* if not defined set to 00 */35#define JDK_UPDATE_VERSION "00"36#endif3738JNIEXPORT void39JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {40/* These JDK_* macros are set at Makefile or the command line */41const unsigned int jdk_major_version =42(unsigned int) atoi(JDK_MAJOR_VERSION);43const unsigned int jdk_minor_version =44(unsigned int) atoi(JDK_MINOR_VERSION);45const unsigned int jdk_micro_version =46(unsigned int) atoi(JDK_MICRO_VERSION);4748const char* jdk_build_string = JDK_BUILD_NUMBER;49char build_number[4];50unsigned int jdk_build_number = 0;5152const char* jdk_update_string = JDK_UPDATE_VERSION;53unsigned int jdk_update_version = 0;54int len_update_ver = 0;55char update_ver[5];56char jdk_special_version = '\0';5758/* If the JDK_BUILD_NUMBER is of format bXX and XX is an integer59* XX is the jdk_build_number.60*/61int len = strlen(jdk_build_string);62if (jdk_build_string[0] == 'b' && len >= 2) {63int i = 0;64for (i = 1; i < len; i++) {65if (isdigit(jdk_build_string[i])) {66build_number[i-1] = jdk_build_string[i];67} else {68// invalid build number69i = -1;70break;71}72}73if (i == len) {74build_number[len-1] = '\0';75jdk_build_number = (unsigned int) atoi(build_number) ;76}77}7879assert(jdk_build_number >= 0 && jdk_build_number <= 255);8081len_update_ver = strlen(jdk_update_string);82if (len_update_ver >= 2 && len_update_ver <= 4) {83int update_digits = len_update_ver;8485if (!isdigit(jdk_update_string[len_update_ver - 1])) {86jdk_special_version = jdk_update_string[len_update_ver -1];87update_digits = len_update_ver - 1;88}89strncpy(update_ver, jdk_update_string, update_digits);90update_ver[update_digits] = '\0';91jdk_update_version = (unsigned int) atoi(update_ver);92}9394memset(info, 0, info_size);95info->jdk_version = ((jdk_major_version & 0xFF) << 24) |96((jdk_minor_version & 0xFF) << 16) |97((jdk_micro_version & 0xFF) << 8) |98(jdk_build_number & 0xFF);99info->update_version = jdk_update_version;100info->special_update_version = (unsigned int) jdk_special_version;101info->thread_park_blocker = 1;102// Advertise presence of sun.misc.PostVMInitHook:103// future optimization: detect if this is enabled.104info->post_vm_init_hook_enabled = 1;105info->pending_list_uses_discovered_field = 1;106}107108109