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 2011/04/18 21:40:14 UTC
svn commit: r1094705 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/platform/windows/Win32.java
native/os/win32/winapi.c
Author: mturk
Date: Mon Apr 18 19:40:14 2011
New Revision: 1094705
URL: http://svn.apache.org/viewvc?rev=1094705&view=rev
Log:
More Win32 API
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java
commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java?rev=1094705&r1=1094704&r2=1094705&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java Mon Apr 18 19:40:14 2011
@@ -35,6 +35,7 @@ final class Win32
// No instance.
}
+ /* ACR protection mappings */
public static final int FPROT_USETID = 0x8000; /**< Set user id */
public static final int FPROT_UREAD = 0x0400; /**< Read by user */
public static final int FPROT_UWRITE = 0x0200; /**< Write by user */
@@ -60,13 +61,30 @@ final class Win32
public static final int INFINITE = 0xFFFFFFFF;
-
public static final int WAIT_FAILED = 0xFFFFFFFF;
public static final int WAIT_OBJECT_O = 0;
public static final int WAIT_ABANDONED = 0x00000080;
public static final int WAIT_TIMEOUT = 0x00000102;
+
+ /* Standard access rights */
+ public static final int DELETE = 0x00010000;
+ public static final int READ_CONTROL = 0x00020000;
+ public static final int SYNCHRONIZE = 0x00100000;
+ public static final int WRITE_DAC = 0x00040000;
+ public static final int WRITE_OWNER = 0x00080000;
+ /* Mutex access rights */
+ public static final int MUTEX_ALL_ACCESS = 0x001F0001;
+ public static final int MUTEX_MODIFY_STATE = 0x00000001;
+ /* semaphore access rights */
+ public static final int SEMAPHORE_ALL_ACCESS = 0x001F0003;
+ public static final int SEMAPHORE_MODIFY_STATE = 0x00000002;
+
+
public static native int CloseHandle(long handle);
public static native int LocalFree(long ptr);
public static native int WaitForSingleObject(long handle, int timeout);
+ public static native long CreateMutex(long sa, boolean initialOwner, String name);
+ public static native long OpenMutex(int access, boolean inheritHandle, String name);
+
}
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c?rev=1094705&r1=1094704&r2=1094705&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c Mon Apr 18 19:40:14 2011
@@ -54,3 +54,30 @@ ACR_WIN_EXPORT(jint, Win32, WaitForSingl
else
return ACR_GET_OS_ERROR();
}
+
+ACR_WIN_EXPORT(jlong, Win32, CreateMutex)(JNI_STDARGS, jlong sa, jboolean owner, jstring name)
+{
+ HANDLE h = 0;
+
+ WITH_WSTR(name) {
+ LPSECURITY_ATTRIBUTES psa = J2P(sa, LPSECURITY_ATTRIBUTES);
+ h = CreateMutexW(psa, owner, J2S(name));
+ if (h == 0)
+ ACR_SAVE_OS_ERROR();
+ } DONE_WITH_STR(name);
+
+ return P2J(h);
+}
+
+ACR_WIN_EXPORT(jlong, Win32, OpenMutex)(JNI_STDARGS, jint access, jboolean inherit, jstring name)
+{
+ HANDLE h = 0;
+
+ WITH_WSTR(name) {
+ h = OpenMutexW(access, inherit, J2S(name));
+ if (h == 0)
+ ACR_SAVE_OS_ERROR();
+ } DONE_WITH_STR(name);
+
+ return P2J(h);
+}