jdk_util.c revision 3001
0N/A/*
2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#include <stdlib.h>
0N/A#include <string.h>
3001N/A#include <ctype.h>
3001N/A#include <assert.h>
0N/A
0N/A#include "jvm.h"
0N/A#include "jdk_util.h"
0N/A
0N/A#ifndef JDK_UPDATE_VERSION
0N/A /* if not defined set to 00 */
0N/A #define JDK_UPDATE_VERSION "00"
0N/A#endif
0N/A
0N/AJNIEXPORT void
0N/AJDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) {
0N/A /* These JDK_* macros are set at Makefile or the command line */
0N/A const unsigned int jdk_major_version =
0N/A (unsigned int) atoi(JDK_MAJOR_VERSION);
0N/A const unsigned int jdk_minor_version =
0N/A (unsigned int) atoi(JDK_MINOR_VERSION);
0N/A const unsigned int jdk_micro_version =
0N/A (unsigned int) atoi(JDK_MICRO_VERSION);
0N/A
0N/A const char* jdk_build_string = JDK_BUILD_NUMBER;
3001N/A char build_number[4];
0N/A unsigned int jdk_build_number = 0;
0N/A
0N/A const char* jdk_update_string = JDK_UPDATE_VERSION;
0N/A unsigned int jdk_update_version = 0;
0N/A char update_ver[3];
0N/A char jdk_special_version = '\0';
0N/A
0N/A /* If the JDK_BUILD_NUMBER is of format bXX and XX is an integer
0N/A * XX is the jdk_build_number.
0N/A */
3001N/A int len = strlen(jdk_build_string);
3001N/A if (jdk_build_string[0] == 'b' && len >= 2) {
3001N/A int i = 0;
3001N/A for (i = 1; i < len; i++) {
3001N/A if (isdigit(jdk_build_string[i])) {
3001N/A build_number[i-1] = jdk_build_string[i];
3001N/A } else {
3001N/A // invalid build number
3001N/A i = -1;
3001N/A break;
3001N/A }
3001N/A }
3001N/A if (i == len) {
3001N/A build_number[len-1] = '\0';
3001N/A jdk_build_number = (unsigned int) atoi(build_number) ;
0N/A }
0N/A }
3001N/A
3001N/A assert(jdk_build_number >= 0 && jdk_build_number <= 255);
3001N/A
0N/A if (strlen(jdk_update_string) == 2 || strlen(jdk_update_string) == 3) {
3001N/A if (isdigit(jdk_update_string[0]) && isdigit(jdk_update_string[1])) {
0N/A update_ver[0] = jdk_update_string[0];
0N/A update_ver[1] = jdk_update_string[1];
0N/A update_ver[2] = '\0';
0N/A jdk_update_version = (unsigned int) atoi(update_ver);
0N/A if (strlen(jdk_update_string) == 3) {
0N/A jdk_special_version = jdk_update_string[2];
0N/A }
0N/A }
0N/A }
0N/A
2884N/A memset(info, 0, info_size);
0N/A info->jdk_version = ((jdk_major_version & 0xFF) << 24) |
0N/A ((jdk_minor_version & 0xFF) << 16) |
0N/A ((jdk_micro_version & 0xFF) << 8) |
0N/A (jdk_build_number & 0xFF);
0N/A info->update_version = jdk_update_version;
0N/A info->special_update_version = (unsigned int) jdk_special_version;
0N/A info->thread_park_blocker = 1;
0N/A}