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/14 21:09:50 UTC

svn commit: r1092441 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ java/org/apache/commons/runtime/platform/windows/ native/ native/os/unix/ native/os/win32/

Author: mturk
Date: Thu Apr 14 19:09:49 2011
New Revision: 1092441

URL: http://svn.apache.org/viewvc?rev=1092441&view=rev
Log:
Add Posix api class

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixApi.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java
      - copied, changed from r1092439, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Api.java
    commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c   (with props)
Removed:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Api.java
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
    commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixApi.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixApi.java?rev=1092441&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixApi.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixApi.java Thu Apr 14 19:09:49 2011
@@ -0,0 +1,41 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.runtime;
+
+import org.apache.commons.runtime.exception.AlreadyExistsException;
+import org.apache.commons.runtime.exception.NoSuchObjectException;
+import org.apache.commons.runtime.exception.ClosedDescriptorException;
+import org.apache.commons.runtime.exception.SystemException;
+
+/**
+ * Posix Api class.
+ * <p>
+ * </p>
+ *
+ * @since Runtime 1.0
+ */
+final class Posix
+{
+
+    private Posix()
+    {
+        // No Instance
+    }
+
+    public static native int            close(int fd);
+    public static native int            unlink(String name);
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixApi.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java (from r1092439, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Api.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java?p2=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java&p1=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Api.java&r1=1092439&r2=1092441&rev=1092441&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Api.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/Win32.java Thu Apr 14 19:09:49 2011
@@ -28,9 +28,9 @@ import org.apache.commons.runtime.except
  * Tries to bring the native Win32 API to Java with as little overhead as possible.
  * </p>
  */
-final class Api
+final class Win32
 {
-    private Api()
+    private Win32()
     {
         // No instance.
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in?rev=1092441&r1=1092440&r2=1092441&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in Thu Apr 14 19:09:49 2011
@@ -63,6 +63,7 @@ UNIX_SOURCES=\
 	$(TOPDIR)/os/unix/dso.c \
 	$(TOPDIR)/os/unix/init.c \
 	$(TOPDIR)/os/unix/platform.c \
+	$(TOPDIR)/os/unix/posixapi.c \
 	$(TOPDIR)/os/unix/semaphore.c \
 	$(TOPDIR)/os/unix/time.c \
 	$(TOPDIR)/os/unix/util.c

Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c?rev=1092441&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c Thu Apr 14 19:09:49 2011
@@ -0,0 +1,44 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr/string.h"
+#include "acr/port.h"
+
+ACR_JNI_EXPORT(jint, Posix, close)(JNI_STDARGS, jint fd)
+{
+    int rc;
+    do {
+        rc = close(fd);
+    } while (rc == -1 && errno == EINTR);
+    if (rc == -1)
+        return errno;
+    else
+        return 0;
+}
+
+ACR_JNI_EXPORT(jint, Posix, unlink)(JNI_STDARGS, jstring name)
+{
+    int rc = EINVAL;
+
+    WITH_CSTR(name) {
+        if (unlink(J2S(name)) == 0)
+            rc = 0;
+        else
+            rc = errno;
+    } DONE_WITH_STR(name);
+
+    return rc;
+}

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/unix/posixapi.c
------------------------------------------------------------------------------
    svn:eol-style = native

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=1092441&r1=1092440&r2=1092441&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 Thu Apr 14 19:09:49 2011
@@ -84,12 +84,12 @@ cleanup:
     return _null_SA[si];
 }
 
-ACR_WIN_EXPORT(jlong, Api, GetSaWithNullDacl)(JNI_STDARGS, jboolean inherit)
+ACR_WIN_EXPORT(jlong, Win32, GetSaWithNullDacl)(JNI_STDARGS, jboolean inherit)
 {
     return P2J(GetSaWithNullDacl(env, inherit));
 }
 
-ACR_WIN_EXPORT(jlong, Api, ConvertStringSecurityDescriptorToSecurityDescriptor)
+ACR_WIN_EXPORT(jlong, Win32, ConvertStringSecurityDescriptorToSecurityDescriptor)
               (JNI_STDARGS, jstring desc, jint rev)
 {
     PSECURITY_DESCRIPTOR pSD = 0;
@@ -103,7 +103,7 @@ ACR_WIN_EXPORT(jlong, Api, ConvertString
     return P2J(pSD);
 }
 
-ACR_WIN_EXPORT(jint, Api, CloseHandle)(JNI_STDARGS, jlong handle)
+ACR_WIN_EXPORT(jint, Win32, CloseHandle)(JNI_STDARGS, jlong handle)
 {
     if (CloseHandle(J2P(handle, HANDLE)))
         return 0;
@@ -111,13 +111,13 @@ ACR_WIN_EXPORT(jint, Api, CloseHandle)(J
         return ACR_GET_OS_ERROR();
 }
 
-ACR_WIN_EXPORT(void, Api, LocalFree)(JNI_STDARGS, jlong ptr)
+ACR_WIN_EXPORT(void, Win32, LocalFree)(JNI_STDARGS, jlong ptr)
 {
     if (ptr != 0LL)
         LocalFree(J2P(ptr, LPVOID));
 }
 
-ACR_WIN_EXPORT(jlong, Api, GetCurrentProcessToken)(JNI_STDARGS)
+ACR_WIN_EXPORT(jlong, Win32, GetCurrentProcessToken)(JNI_STDARGS)
 {
     HANDLE ptoken = 0;
     HANDLE dtoken = 0;
@@ -135,7 +135,7 @@ ACR_WIN_EXPORT(jlong, Api, GetCurrentPro
     return P2J(dtoken);
 }
 
-ACR_WIN_EXPORT(jlong, Api, AllocateWellKnownSid)(JNI_STDARGS, jint type)
+ACR_WIN_EXPORT(jlong, Win32, AllocateWellKnownSid)(JNI_STDARGS, jint type)
 {
     DWORD ss = SECURITY_MAX_SID_SIZE;
     PSID sid;
@@ -152,7 +152,7 @@ ACR_WIN_EXPORT(jlong, Api, AllocateWellK
 }
 
 
-ACR_WIN_EXPORT(jint, Api, WaitForSingleObject)(JNI_STDARGS, jlong handle, jint timeout)
+ACR_WIN_EXPORT(jint, Win32, WaitForSingleObject)(JNI_STDARGS, jlong handle, jint timeout)
 {
     DWORD ws = WaitForSingleObject(J2P(handle, HANDLE), (DWORD)timeout);
     if (ws == WAIT_OBJECT_0 || ws == WAIT_ABANDONED)