You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/06/08 15:51:07 UTC
svn commit: r782623 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/ native/include/ native/os/win32/
native/shared/
Author: mturk
Date: Mon Jun 8 13:51:07 2009
New Revision: 782623
URL: http://svn.apache.org/viewvc?rev=782623&view=rev
Log:
Init Windows IOH from the provided Property value
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java
commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h
commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
commons/sandbox/runtime/trunk/src/main/native/shared/string.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties?rev=782623&r1=782622&r2=782623&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/DefaultProperties.properties Mon Jun 8 13:51:07 2009
@@ -33,3 +33,5 @@
cpu.cache.ttl = 100
cpu.cache.ttl.min = 1
+# Maximum number of opened OS descriptors
+os.open.max = 65536
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java?rev=782623&r1=782622&r2=782623&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java Mon Jun 8 13:51:07 2009
@@ -44,6 +44,8 @@
static {
int [] i = new int[32];
+
+ i[0] = Properties.OS_OPEN_MAX;
init0(i);
SIZEOF_INT = i[0];
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java?rev=782623&r1=782622&r2=782623&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java Mon Jun 8 13:51:07 2009
@@ -139,6 +139,13 @@
public static final long CPU_CACHE_TTL_MIN = getL("cpu.cache.ttl.min", 1L);
//
+ // File system section.
+ //
+ /** Maximum number of opened OS descriptors.
+ */
+ public static final int OS_OPEN_MAX = getI("os.open.max");
+
+ //
// Version info section.
//
/** Major version of the runtime library
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h?rev=782623&r1=782622&r2=782623&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_string.h Mon Jun 8 13:51:07 2009
@@ -47,15 +47,14 @@
*/
ACR_DECLARE(const char *) ACR_FilePathNameGet(const char *pathname);
-/** Convert JNI integer value to string
+/** Convert 32-bit integer (jint) value to string
* @param n Number to convert.
* @remark The function allocates the string from memory, so it must
* be released after use.
*/
ACR_DECLARE(char *) ACR_Itoa(acr_int_t n);
-
-/** Convert JNI long value to string
+/** Convert 64-bit integer (jlong) value to string
* @param n Number to convert.
* @remark The function allocates the string from memory, so it must
* be released after use.
@@ -88,18 +87,24 @@
*/
ACR_DECLARE(char *) ACR_GetJavaStringU(JNIEnv *env, jstring s);
+/** Convert java string to platform char string.
+ * @param env Current JNI environment.
+ * @param s String to convert.
+ * @remark When done use ACR_Free to free the allocated memory.
+ */
+ACR_DECLARE(char *)ACR_GetJavaStringA(JNIEnv *_E, jstring s);
+
/** Convert wchar_t to java string
* @param env Current JNI environment.
* @param s String to convert.
*/
ACR_DECLARE(jstring) ACR_NewJavaStringW(JNIEnv *_E, const wchar_t *s);
-/** Convert java string to platform char string.
+/** Convert UTF-8 encoded string to java string
* @param env Current JNI environment.
* @param s String to convert.
- * @remark When done use ACR_Free to free the allocated memory.
*/
-ACR_DECLARE(char *)ACR_GetJavaStringA(JNIEnv *_E, jstring s);
+ACR_DECLARE(jstring) ACR_NewJavaStringU(JNIEnv *_E, const char *s);
/** Convert platform string to java string
* @param env Current JNI environment.
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=782623&r1=782622&r2=782623&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Mon Jun 8 13:51:07 2009
@@ -19,18 +19,29 @@
#include "acr_arch.h"
#include "acr_string.h"
#include "acr_platform.h"
+#include "acr_error.h"
static const char unknown[] = "unknown";
extern PSID acr_everyone_sid;
extern PSID acr_adminsgr_sid;
+extern int acr_ioh_init(int);
ACR_JNI_EXPORT_DECLARE(void, Platform, init0)(ACR_JNISTDARGS,
jintArray p)
{
- jint ia[32];
+ int e;
+ jint ia[32] = { 0, 0, 0, 0 };
UNREFERENCED_O;
+ (*_E)->GetIntArrayRegion(_E, p, 0, 16, &ia[0]);
+ if ((e = acr_ioh_init(ia[0]))) {
+ /* Error initializing descriptor map table.
+ * We cannot continue.
+ */
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR, e);
+ return;
+ }
ia[0] = sizeof(int);
ia[1] = sizeof(long);
ia[2] = sizeof(size_t);
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/string.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/string.c?rev=782623&r1=782622&r2=782623&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/string.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/string.c Mon Jun 8 13:51:07 2009
@@ -285,29 +285,6 @@
return rv;
}
-ACR_DECLARE(jstring) ACR_NewJavaStringW(JNIEnv *_E, const wchar_t *s)
-{
- jstring r = NULL;
- if (s) {
- size_t len = wcslen(s);
-#if CC_SIZEOF_WCHAR_T == 2
- r = (*_E)->NewString(_E, (const jchar *)s, (jsize)len);
-#else
- jchar *cc;
- if ((cc = ACR_Malloc(_E, THROW_FMARK, (len + 1) * sizeof(jchar)))) {
- size_t i;
- for (i = 0; i < len; i++) {
- /* Simply assign utf32 to utf16 */
- cc[i] = (jchar)s[i];
- }
- r = (*_E)->NewString(_E, cc, len);
- free(cc);
- }
-#endif
- }
- return r;
-}
-
ACR_DECLARE(char *) ACR_GetJavaStringA(JNIEnv *_E, jstring str)
{
jbyteArray sb = NULL;
@@ -337,6 +314,36 @@
return rs;
}
+ACR_DECLARE(jstring) ACR_NewJavaStringW(JNIEnv *_E, const wchar_t *s)
+{
+ jstring r = NULL;
+ if (s) {
+ size_t len = wcslen(s);
+#if CC_SIZEOF_WCHAR_T == 2
+ r = (*_E)->NewString(_E, (const jchar *)s, (jsize)len);
+#else
+ jchar *cc;
+ if ((cc = ACR_Malloc(_E, THROW_FMARK, (len + 1) * sizeof(jchar)))) {
+ size_t i;
+ for (i = 0; i < len; i++) {
+ /* Simply assign utf32 to utf16 */
+ cc[i] = (jchar)s[i];
+ }
+ r = (*_E)->NewString(_E, cc, len);
+ free(cc);
+ }
+#endif
+ }
+ return r;
+}
+
+ACR_DECLARE(jstring) ACR_NewJavaStringU(JNIEnv *_E, const char *str)
+{
+ if (!str)
+ return NULL;
+ return (*_E)->NewStringUTF(_E, str);
+}
+
ACR_DECLARE(jstring) ACR_NewJavaStringA(JNIEnv *_E, const char *str)
{
jstring rs;
@@ -361,7 +368,6 @@
}
-
/* Match = 0, NoMatch = 1, Abort = -1
* Based loosely on sections of wildmat.c by Rich Salz
*/