Commit to implement property os.arch for use in bug 8574

I had thought about using other means, ie using sysctl or utsname for
osx/linux....but this solution is more universal between OS's as well as
provided by the compiler, not via system operations
This commit is contained in:
jent
2009-07-28 10:16:27 -06:00
parent 30be3945ae
commit c2e9b3ed76

View File

@ -32,6 +32,7 @@
# define SO_PREFIX "" # define SO_PREFIX ""
#else #else
# define SO_PREFIX "lib" # define SO_PREFIX "lib"
#include <sys/sysctl.h>
#include "sys/utsname.h" #include "sys/utsname.h"
#include "sys/wait.h" #include "sys/wait.h"
#endif #endif
@ -359,6 +360,36 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
::GetVersionEx(&OSversion); ::GetVersionEx(&OSversion);
snprintf(buffer, size, "%i.%i", (int)OSversion.dwMajorVersion, (int)OSversion.dwMinorVersion); snprintf(buffer, size, "%i.%i", (int)OSversion.dwMajorVersion, (int)OSversion.dwMinorVersion);
r = e->NewStringUTF(buffer); r = e->NewStringUTF(buffer);
} else if (strcmp(chars, "os.arch") == 0) {
#ifdef __i386__
r = e->NewStringUTF("x86");
#else
#ifdef __x86_64__
r = e->NewStringUTF("x86_64");
#else
#if defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__) || defined(__powerpc64__)
r = e->NewStringUTF("ppc");
#else
#ifdef __ia64__
r = e->NewStringUTF("ia64");
#else
#ifdef __arm__
r = e->NewStringUTF("arm");
#else
#ifdef __alpha__
r = e->NewStringUTF("alpha");
#else
#ifdef __sparc64__
r = e->NewStringUTF("sparc64");
#else
r = e->NewStringUTF("unknown");
#endif
#endif
#endif
#endif
#endif
#endif
#endif
} else if (strcmp(chars, "java.io.tmpdir") == 0) { } else if (strcmp(chars, "java.io.tmpdir") == 0) {
TCHAR buffer[MAX_PATH]; TCHAR buffer[MAX_PATH];
GetTempPath(MAX_PATH, buffer); GetTempPath(MAX_PATH, buffer);
@ -393,6 +424,36 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
struct utsname system_id; struct utsname system_id;
uname(&system_id); uname(&system_id);
r = e->NewStringUTF(system_id.release); r = e->NewStringUTF(system_id.release);
#endif
} else if (strcmp(chars, "os.arch") == 0) {
#ifdef __i386__
r = e->NewStringUTF("x86");
#else
#ifdef __x86_64__
r = e->NewStringUTF("x86_64");
#else
#if defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__) || defined(__powerpc64__)
r = e->NewStringUTF("ppc");
#else
#ifdef __ia64__
r = e->NewStringUTF("ia64");
#else
#ifdef __arm__
r = e->NewStringUTF("arm");
#else
#ifdef __alpha__
r = e->NewStringUTF("alpha");
#else
#ifdef __sparc64__
r = e->NewStringUTF("sparc64");
#else
r = e->NewStringUTF("unknown");
#endif
#endif
#endif
#endif
#endif
#endif
#endif #endif
} else if (strcmp(chars, "java.io.tmpdir") == 0) { } else if (strcmp(chars, "java.io.tmpdir") == 0) {
r = e->NewStringUTF("/tmp"); r = e->NewStringUTF("/tmp");