} else {
return "ERROR";
}
}
jvmidx = nextIdx;
jvmtype = knownVMs[jvmidx].name+1;
loopCount++;
}
}
switch (knownVMs[jvmidx].flag) {
case VM_WARN:
if (!speculative) {
fprintf(stderr, "Warning: %s VM not supported; %s VM will be used\n",
jvmtype, knownVMs[0].name + 1);
}
/* fall through */
case VM_IGNORE:
jvmtype = knownVMs[jvmidx=0].name + 1;
/* fall through */
case VM_KNOWN:
break;
case VM_ERROR:
if (!speculative) {
ReportErrorMessage2("Error: %s VM not supported", jvmtype, JNI_TRUE);
exit(1);
} else {
return "ERROR";
}
}
return jvmtype;
}
# define KB (1024UL)
# define MB (1024UL * KB)
# define GB (1024UL * MB)
/* copied from HotSpot function "atomll()" */
static int
parse_stack_size(const char *s, jlong *result) {
jlong n = 0;
int args_read = sscanf(s, jlong_format_specifier(), &n);
if (args_read != 1) {
return 0;
}
while (*s != '\0' && *s >= '0' && *s <= '9') {
s++;
}
// 4705540: illegal if more characters are found after the first non-digit
if (strlen(s) > 1) {
return 0;
}
switch (*s) {
case 'T': case 't':
*result = n * GB * KB;
return 1;
case 'G': case 'g':
*result = n * GB;
return 1;
case 'M': case 'm':
*result = n * MB;
return 1;
case 'K': case 'k':
*result = n * KB;
return 1;
case '\0':
*result = n;
return 1;
default:
/* Create JVM with default stack and let VM handle malformed -Xss string*/
return 0;
}
}
/*
* Adds a new VM option with the given given name and value.
*/
void
AddOption(char *str, void *info)
{
/*
* Expand options array if needed to accommodate at least one more
* VM option.
*/
if (numOptions >= maxOptions) {
if (options == 0) {
maxOptions = 4;
options = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
} else {
JavaVMOption *tmp;
maxOptions *= 2;
tmp = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
memcpy(tmp, options, numOptions * sizeof(JavaVMOption));
JLI_MemFree(options);
options = tmp;
}
}
options[numOptions].optionString = str;
options[numOptions++].extraInfo = info;
=8= |