author | dsimms |
Wed, 11 Jun 2014 12:09:12 +0200 | |
changeset 25056 | 5ad92b0d1beb |
parent 10895 | 7434064aba55 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
9286 | 2 |
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#include <stdlib.h> |
|
27 |
#include <string.h> |
|
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
28 |
#include <ctype.h> |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
29 |
#include <assert.h> |
2 | 30 |
|
31 |
#include "jvm.h" |
|
32 |
#include "jdk_util.h" |
|
33 |
||
34 |
#ifndef JDK_UPDATE_VERSION |
|
35 |
/* if not defined set to 00 */ |
|
36 |
#define JDK_UPDATE_VERSION "00" |
|
37 |
#endif |
|
38 |
||
39 |
JNIEXPORT void |
|
40 |
JDK_GetVersionInfo0(jdk_version_info* info, size_t info_size) { |
|
41 |
/* These JDK_* macros are set at Makefile or the command line */ |
|
42 |
const unsigned int jdk_major_version = |
|
43 |
(unsigned int) atoi(JDK_MAJOR_VERSION); |
|
44 |
const unsigned int jdk_minor_version = |
|
45 |
(unsigned int) atoi(JDK_MINOR_VERSION); |
|
46 |
const unsigned int jdk_micro_version = |
|
47 |
(unsigned int) atoi(JDK_MICRO_VERSION); |
|
48 |
||
49 |
const char* jdk_build_string = JDK_BUILD_NUMBER; |
|
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
50 |
char build_number[4]; |
2 | 51 |
unsigned int jdk_build_number = 0; |
52 |
||
53 |
const char* jdk_update_string = JDK_UPDATE_VERSION; |
|
54 |
unsigned int jdk_update_version = 0; |
|
55 |
char update_ver[3]; |
|
56 |
char jdk_special_version = '\0'; |
|
57 |
||
58 |
/* If the JDK_BUILD_NUMBER is of format bXX and XX is an integer |
|
59 |
* XX is the jdk_build_number. |
|
60 |
*/ |
|
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
61 |
int len = strlen(jdk_build_string); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
62 |
if (jdk_build_string[0] == 'b' && len >= 2) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
63 |
int i = 0; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
64 |
for (i = 1; i < len; i++) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
65 |
if (isdigit(jdk_build_string[i])) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
66 |
build_number[i-1] = jdk_build_string[i]; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
67 |
} else { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
68 |
// invalid build number |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
69 |
i = -1; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
70 |
break; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
71 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
72 |
} |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
73 |
if (i == len) { |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
74 |
build_number[len-1] = '\0'; |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
75 |
jdk_build_number = (unsigned int) atoi(build_number) ; |
2 | 76 |
} |
77 |
} |
|
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
78 |
|
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
79 |
assert(jdk_build_number >= 0 && jdk_build_number <= 255); |
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
80 |
|
2 | 81 |
if (strlen(jdk_update_string) == 2 || strlen(jdk_update_string) == 3) { |
7042
56e990297bc5
6994413: JDK_GetVersionInfo0 only expects a two digit build number
mchung
parents:
6850
diff
changeset
|
82 |
if (isdigit(jdk_update_string[0]) && isdigit(jdk_update_string[1])) { |
2 | 83 |
update_ver[0] = jdk_update_string[0]; |
84 |
update_ver[1] = jdk_update_string[1]; |
|
85 |
update_ver[2] = '\0'; |
|
86 |
jdk_update_version = (unsigned int) atoi(update_ver); |
|
87 |
if (strlen(jdk_update_string) == 3) { |
|
88 |
jdk_special_version = jdk_update_string[2]; |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
||
6850
56966b0a6a0d
6989466: Miscellaneous compiler warnings in java/lang, java/util, java/io, sun/misc native code
alanb
parents:
5506
diff
changeset
|
93 |
memset(info, 0, info_size); |
2 | 94 |
info->jdk_version = ((jdk_major_version & 0xFF) << 24) | |
95 |
((jdk_minor_version & 0xFF) << 16) | |
|
96 |
((jdk_micro_version & 0xFF) << 8) | |
|
97 |
(jdk_build_number & 0xFF); |
|
98 |
info->update_version = jdk_update_version; |
|
99 |
info->special_update_version = (unsigned int) jdk_special_version; |
|
100 |
info->thread_park_blocker = 1; |
|
9286 | 101 |
// Advertise presence of sun.misc.PostVMInitHook: |
102 |
// future optimization: detect if this is enabled. |
|
103 |
info->post_vm_init_hook_enabled = 1; |
|
10895 | 104 |
info->pending_list_uses_discovered_field = 1; |
2 | 105 |
} |