void ReportErrorMessage(char * message, jboolean always) {
if (always) {
fprintf(stderr, "%s\n", message);
}
}
void ReportErrorMessage2(char * format, char * string, jboolean always) {
if (always) {
fprintf(stderr, format, string);
fprintf(stderr, "\n");
}
}
void ReportExceptionDescription(JNIEnv * env) {
(*env)->ExceptionDescribe(env);
}
/*
* Return JNI_TRUE for an option string that has no effect but should
* _not_ be passed on to the vm; return JNI_FALSE otherwise. On
* Solaris SPARC, this screening needs to be done if:
* 1) LD_LIBRARY_PATH does _not_ need to be reset and
* 2) -d32 or -d64 is passed to a binary with a matching data model
* (the exec in SetLibraryPath removes -d<n> options and points the
* exec to the proper binary). When this exec is not done, these options
* would end up getting passed onto the vm.
*/
jboolean RemovableMachineDependentOption(char * option) {
/*
* Unconditionally remove both -d32 and -d64 options since only
* the last such options has an effect; e.g.
* java -d32 -d64 -d32 -version
* is equivalent to
* java -d32 -version
*/
if( (strcmp(option, "-d32") == 0 ) ||
(strcmp(option, "-d64") == 0 ))
return JNI_TRUE;
else
return JNI_FALSE;
}
void PrintMachineDependentOptions() {
fprintf(stdout,
" -d32 use a 32-bit data model if available\n"
"\n"
" -d64 use a 64-bit data model if available\n");
return;
}
/*
* The following methods (down to ServerClassMachine()) answer
* the question about whether a machine is a "server-class"
* machine. A server-class machine is loosely defined as one
* with 2 or more processors and 2 gigabytes or more physical
* memory. The definition of a processor is a physical package,
* not a hyperthreaded chip masquerading as a multi-processor.
* The definition of memory is also somewhat fuzzy, since x86
* machines seem not to report all the memory in their DIMMs, we
* think because of memory mapping of graphics cards, etc.
*
* This code is somewhat more confused with #ifdef's than we'd
* like because this file is used by both Solaris and Linux
* platforms, and so needs to be parameterized for SPARC and
* i586 hardware. The other Linux platforms (amd64 and ia64)
* don't even ask this question, because they only come with
* server JVMs. */
# define KB (1024UL)
# define MB (1024UL * KB)
# define GB (1024UL * MB)
/* Compute physical memory by asking the OS */
uint64_t
physical_memory(void) {
const uint64_t pages = (uint64_t) sysconf(_SC_PHYS_PAGES);
const uint64_t page_size = (uint64_t) sysconf(_SC_PAGESIZE);
const uint64_t result = pages * page_size;
# define UINT64_FORMAT "%" PRIu64
if (_launcher_debug) {
printf("pages: " UINT64_FORMAT
" page_size: " UINT64_FORMAT
" physical memory: " UINT64_FORMAT " (%.3fGB)\n",
pages, page_size, result, result / (double) GB);
}
return result;
}
#if defined(__sun) && defined(__sparc)
/* Methods for solaris-sparc: these are easy. */
/* Ask the OS how many processors there are. */
unsigned long
physical_processors(void) {
const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
if (_launcher_debug) {
=10= |