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/08/19 10:51:07 UTC
svn commit: r805706 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/ native/os/darwin/ native/os/hpux/
native/os/unix/ native/os/win32/ native/shared/
Author: mturk
Date: Wed Aug 19 08:51:07 2009
New Revision: 805706
URL: http://svn.apache.org/viewvc?rev=805706&view=rev
Log:
Add Mutex and Semaphore class prototypes
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java (with props)
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c
commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java?rev=805706&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java Wed Aug 19 08:51:07 2009
@@ -0,0 +1,49 @@
+/* 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 java.io.IOException;
+import org.apache.commons.runtime.io.File;
+import org.apache.commons.runtime.exception.OperatingSystemException;
+import org.apache.commons.runtime.exception.UnsupportedOperatingSystemException;
+
+/**
+ * Mutex class.
+ * <p>
+ * </p>
+ *
+ * @since Runtime 1.0
+ */
+public final class Mutex
+{
+
+ /*
+ * Reference to the OS process mutex descriptor
+ */
+ private Descriptor mutex;
+
+ private Mutex()
+ {
+ // No Instance
+ }
+
+ private Mutex(Descriptor mutex)
+ {
+ this.mutex = mutex;
+ }
+
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java?rev=805706&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java Wed Aug 19 08:51:07 2009
@@ -0,0 +1,49 @@
+/* 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 java.io.IOException;
+import org.apache.commons.runtime.io.File;
+import org.apache.commons.runtime.exception.OperatingSystemException;
+import org.apache.commons.runtime.exception.UnsupportedOperatingSystemException;
+
+/**
+ * Semaphoreclass.
+ * <p>
+ * </p>
+ *
+ * @since Runtime 1.0
+ */
+public final class Semaphore
+{
+
+ /*
+ * Reference to the OS process mutex descriptor
+ */
+ private Descriptor sem;
+
+ private Semaphore()
+ {
+ // No Instance
+ }
+
+ private Semaphore(Descriptor sem)
+ {
+ this.sem = sem;
+ }
+
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Semaphore.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java Wed Aug 19 08:51:07 2009
@@ -41,6 +41,11 @@
// No Instance
}
+ private SharedMemory(Descriptor shm)
+ {
+ this.shm = shm;
+ }
+
/**
* Create and make accessable anonymous shared memory segment.
* <p>
Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c Wed Aug 19 08:51:07 2009
@@ -17,16 +17,29 @@
#include "acr.h"
#include "acr_private.h"
#include "acr_arch.h"
+#include "acr_clazz.h"
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
#include "acr_descriptor.h"
-#include "acr_file.h"
+#include "acr_pointer.h"
#include "acr_procmutex.h"
#include <sys/ipc.h>
#include <sys/file.h>
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "Mutex"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;)V"
+};
+
struct acr_pmutex_t {
int filedes;
int locked;
@@ -227,3 +240,19 @@
return acr_ioh_close(mutex);
}
+ACR_CLASS_LDEF(Mutex)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(Mutex)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c Wed Aug 19 08:51:07 2009
@@ -17,10 +17,12 @@
#include "acr.h"
#include "acr_private.h"
#include "acr_arch.h"
+#include "acr_clazz.h"
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
#include "acr_descriptor.h"
+#include "acr_pointer.h"
#include "acr_shm.h"
#include <sys/mman.h>
@@ -38,6 +40,18 @@
#define ACR_SHM_OWNER 0
#define ACR_SHM_CHILD 1
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "SharedMemory"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;)V"
+};
+
typedef struct memblock_t {
acr_uint32_t magic; /* Is this our memeory */
pid_t creator; /* Creator's process ID */
@@ -513,3 +527,19 @@
return m->reqsize;
}
+ACR_CLASS_LDEF(SharedMemory)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(SharedMemory)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c Wed Aug 19 08:51:07 2009
@@ -17,16 +17,30 @@
#include "acr.h"
#include "acr_private.h"
#include "acr_arch.h"
+#include "acr_clazz.h"
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
#include "acr_descriptor.h"
+#include "acr_pointer.h"
#include "acr_procmutex.h"
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/file.h>
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "Mutex"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;)V"
+};
+
union semun {
int val;
struct semid_ds *buf;
@@ -212,3 +226,19 @@
return acr_ioh_close(mutex);
}
+ACR_CLASS_LDEF(Mutex)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(Mutex)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c Wed Aug 19 08:51:07 2009
@@ -17,10 +17,12 @@
#include "acr.h"
#include "acr_private.h"
#include "acr_arch.h"
+#include "acr_clazz.h"
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
#include "acr_descriptor.h"
+#include "acr_pointer.h"
#include "acr_semaphore.h"
#include <semaphore.h>
@@ -29,6 +31,18 @@
#define SEM_FAILED (-1)
#endif
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "Semaphore"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;)V"
+};
+
static volatile unsigned int _sem_counter = 1;
struct acr_semaphore_t {
@@ -247,3 +261,19 @@
}
+ACR_CLASS_LDEF(Semaphore)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(Semaphore)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c Wed Aug 19 08:51:07 2009
@@ -17,10 +17,12 @@
#include "acr.h"
#include "acr_private.h"
#include "acr_arch.h"
+#include "acr_clazz.h"
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
#include "acr_descriptor.h"
+#include "acr_pointer.h"
#include "acr_shm.h"
#include <sys/mman.h>
@@ -38,6 +40,18 @@
#define ACR_SHM_OWNER 0
#define ACR_SHM_CHILD 1
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "SharedMemory"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;)V"
+};
+
typedef struct memblock_t {
acr_uint32_t magic; /* Is this our memeory */
pid_t creator; /* Creator's process ID */
@@ -494,3 +508,19 @@
return m->reqsize;
}
+ACR_CLASS_LDEF(SharedMemory)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(SharedMemory)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c Wed Aug 19 08:51:07 2009
@@ -17,12 +17,26 @@
#include "acr.h"
#include "acr_private.h"
#include "acr_arch.h"
+#include "acr_clazz.h"
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
#include "acr_descriptor.h"
+#include "acr_pointer.h"
#include "acr_procmutex.h"
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "Mutex"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;)V"
+};
+
static int mutex_cleanup(void *mutex, int type, unsigned int flags)
{
if (type == ACR_DT_MUTEX) {
@@ -183,3 +197,19 @@
return acr_ioh_close(mutex);
}
+ACR_CLASS_LDEF(Mutex)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(Mutex)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c Wed Aug 19 08:51:07 2009
@@ -17,12 +17,26 @@
#include "acr.h"
#include "acr_private.h"
#include "acr_arch.h"
+#include "acr_clazz.h"
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
#include "acr_descriptor.h"
+#include "acr_pointer.h"
#include "acr_semaphore.h"
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "Semaphore"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;)V"
+};
+
static int semaphore_cleanup(void *sema, int type, unsigned int flags)
{
if (type == ACR_DT_SEMAPHORE) {
@@ -199,3 +213,19 @@
}
+ACR_CLASS_LDEF(Semaphore)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(Semaphore)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c Wed Aug 19 08:51:07 2009
@@ -17,15 +17,29 @@
#include "acr.h"
#include "acr_private.h"
#include "acr_arch.h"
+#include "acr_clazz.h"
#include "acr_error.h"
#include "acr_memory.h"
#include "acr_string.h"
#include "acr_descriptor.h"
+#include "acr_pointer.h"
#include "acr_shm.h"
#define ACR_SHM_OWNER 0
#define ACR_SHM_CHILD 1
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ ACR_CLASS_PATH "SharedMemory"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "(L" ACR_CLASS_PATH "Descriptor;)V"
+};
+
typedef struct memblock_t {
acr_uint32_t magic; /* Is this our memeory */
DWORD creator; /* Creator's process ID */
@@ -375,3 +389,19 @@
return m->length;
}
+ACR_CLASS_LDEF(SharedMemory)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(SharedMemory)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=805706&r1=805705&r2=805706&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Wed Aug 19 08:51:07 2009
@@ -377,6 +377,9 @@
ACR_CLASS_LDEC(MbString);
ACR_CLASS_LDEC(Group);
ACR_CLASS_LDEC(User);
+ACR_CLASS_LDEC(Mutex);
+ACR_CLASS_LDEC(Semaphore);
+ACR_CLASS_LDEC(SharedMemory);
ACR_CLASS_LDEC(io_File);
ACR_DECLARE(int) ACR_LoadRuntimeClasses(JNIEnv *_E)
@@ -389,6 +392,9 @@
ACR_CLASS_LRUN(MbString);
ACR_CLASS_LRUN(Group);
ACR_CLASS_LRUN(User);
+ ACR_CLASS_LRUN(Mutex);
+ ACR_CLASS_LRUN(Semaphore);
+ ACR_CLASS_LRUN(SharedMemory);
ACR_CLASS_LRUN(io_File);
#ifdef WIN32
@@ -407,6 +413,9 @@
ACR_CLASS_URUN(MbString);
ACR_CLASS_URUN(Group);
ACR_CLASS_URUN(User);
+ ACR_CLASS_URUN(Mutex);
+ ACR_CLASS_URUN(Semaphore);
+ ACR_CLASS_URUN(SharedMemory);
ACR_CLASS_URUN(io_File);
#ifdef WIN32