summaryrefslogtreecommitdiffstats
path: root/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2
diff options
context:
space:
mode:
Diffstat (limited to 'rubbos/app/httpd-2.0.64/srclib/apr/locks/os2')
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/Makefile.in18
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/proc_mutex.c234
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_cond.c60
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_mutex.c102
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_rwlock.c200
5 files changed, 614 insertions, 0 deletions
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/Makefile.in b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/Makefile.in
new file mode 100644
index 00000000..e22f85c9
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/Makefile.in
@@ -0,0 +1,18 @@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+TARGETS = \
+ thread_mutex.lo \
+ thread_rwlock.lo \
+ thread_cond.lo \
+ proc_mutex.lo
+
+# bring in rules.mk for standard functionality
+@INCLUDE_RULES@
+
+INCDIR=../../include
+OSDIR=$(INCDIR)/arch/@OSDIR@
+DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
+INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR)
+
+# DO NOT REMOVE
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/proc_mutex.c b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/proc_mutex.c
new file mode 100644
index 00000000..5a493563
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/proc_mutex.c
@@ -0,0 +1,234 @@
+/* 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 "apr_general.h"
+#include "apr_lib.h"
+#include "apr_strings.h"
+#include "apr_portable.h"
+#include "apr_arch_proc_mutex.h"
+#include "apr_arch_file_io.h"
+#include <string.h>
+#include <stddef.h>
+
+#define CurrentTid (*_threadid)
+
+static char *fixed_name(const char *fname, apr_pool_t *pool)
+{
+ char *semname;
+
+ if (fname == NULL)
+ semname = NULL;
+ else {
+ // Semaphores don't live in the file system, fix up the name
+ while (*fname == '/' || *fname == '\\') {
+ fname++;
+ }
+
+ semname = apr_pstrcat(pool, "/SEM32/", fname, NULL);
+
+ if (semname[8] == ':') {
+ semname[8] = '$';
+ }
+ }
+
+ return semname;
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *vmutex)
+{
+ apr_proc_mutex_t *mutex = vmutex;
+ return apr_proc_mutex_destroy(mutex);
+}
+
+APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex)
+{
+ return NULL;
+}
+
+APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex)
+{
+ return "os2sem";
+}
+
+APR_DECLARE(const char *) apr_proc_mutex_defname(void)
+{
+ return "os2sem";
+}
+
+
+APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex,
+ const char *fname,
+ apr_lockmech_e mech,
+ apr_pool_t *pool)
+{
+ apr_proc_mutex_t *new;
+ ULONG rc;
+ char *semname;
+
+ if (mech != APR_LOCK_DEFAULT) {
+ return APR_ENOTIMPL;
+ }
+
+ new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t));
+ new->pool = pool;
+ new->owner = 0;
+ new->lock_count = 0;
+ *mutex = new;
+
+ semname = fixed_name(fname, pool);
+ rc = DosCreateMutexSem(semname, &(new->hMutex), DC_SEM_SHARED, FALSE);
+
+ if (!rc) {
+ apr_pool_cleanup_register(pool, new, apr_proc_mutex_cleanup, apr_pool_cleanup_null);
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex,
+ const char *fname,
+ apr_pool_t *pool)
+{
+ apr_proc_mutex_t *new;
+ ULONG rc;
+ char *semname;
+
+ new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t));
+ new->pool = pool;
+ new->owner = 0;
+ new->lock_count = 0;
+
+ semname = fixed_name(fname, pool);
+ rc = DosOpenMutexSem(semname, &(new->hMutex));
+ *mutex = new;
+
+ if (!rc) {
+ apr_pool_cleanup_register(pool, new, apr_proc_mutex_cleanup, apr_pool_cleanup_null);
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex)
+{
+ ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_INDEFINITE_WAIT);
+
+ if (rc == 0) {
+ mutex->owner = CurrentTid;
+ mutex->lock_count++;
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
+{
+ ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN);
+
+ if (rc == 0) {
+ mutex->owner = CurrentTid;
+ mutex->lock_count++;
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex)
+{
+ ULONG rc;
+
+ if (mutex->owner == CurrentTid && mutex->lock_count > 0) {
+ mutex->lock_count--;
+ rc = DosReleaseMutexSem(mutex->hMutex);
+ return APR_FROM_OS_ERROR(rc);
+ }
+
+ return APR_SUCCESS;
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex)
+{
+ ULONG rc;
+ apr_status_t status = APR_SUCCESS;
+
+ if (mutex->owner == CurrentTid) {
+ while (mutex->lock_count > 0 && status == APR_SUCCESS) {
+ status = apr_proc_mutex_unlock(mutex);
+ }
+ }
+
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ if (mutex->hMutex == 0) {
+ return APR_SUCCESS;
+ }
+
+ rc = DosCloseMutexSem(mutex->hMutex);
+
+ if (!rc) {
+ mutex->hMutex = 0;
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
+
+
+
+/* Implement OS-specific accessors defined in apr_portable.h */
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
+ apr_proc_mutex_t *pmutex)
+{
+ *ospmutex = pmutex->hMutex;
+ return APR_ENOTIMPL;
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t *ospmutex,
+ apr_pool_t *pool)
+{
+ apr_proc_mutex_t *new;
+
+ new = (apr_proc_mutex_t *)apr_palloc(pool, sizeof(apr_proc_mutex_t));
+ new->pool = pool;
+ new->owner = 0;
+ new->lock_count = 0;
+ new->hMutex = *ospmutex;
+ *pmutex = new;
+
+ return APR_SUCCESS;
+}
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_cond.c b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_cond.c
new file mode 100644
index 00000000..ec6034f5
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_cond.c
@@ -0,0 +1,60 @@
+/* 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 "apr_general.h"
+#include "apr_lib.h"
+#include "apr_strings.h"
+#include "apr_portable.h"
+#include "apr_arch_thread_mutex.h"
+#include "apr_arch_thread_cond.h"
+#include "apr_arch_file_io.h"
+#include <string.h>
+
+APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
+ apr_pool_t *pool)
+{
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
+ apr_thread_mutex_t *mutex)
+{
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond,
+ apr_thread_mutex_t *mutex,
+ apr_interval_time_t timeout){
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
+{
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
+{
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
+{
+ return APR_ENOTIMPL;
+}
+
+APR_POOL_IMPLEMENT_ACCESSOR(thread_cond)
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_mutex.c b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_mutex.c
new file mode 100644
index 00000000..5d8436be
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_mutex.c
@@ -0,0 +1,102 @@
+/* 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 "apr_general.h"
+#include "apr_lib.h"
+#include "apr_strings.h"
+#include "apr_portable.h"
+#include "apr_arch_thread_mutex.h"
+#include "apr_arch_file_io.h"
+#include <string.h>
+#include <stddef.h>
+
+static apr_status_t thread_mutex_cleanup(void *themutex)
+{
+ apr_thread_mutex_t *mutex = themutex;
+ return apr_thread_mutex_destroy(mutex);
+}
+
+
+
+/* XXX: Need to respect APR_THREAD_MUTEX_[UN]NESTED flags argument
+ * or return APR_ENOTIMPL!!!
+ */
+APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex,
+ unsigned int flags,
+ apr_pool_t *pool)
+{
+ apr_thread_mutex_t *new_mutex;
+ ULONG rc;
+
+ new_mutex = (apr_thread_mutex_t *)apr_palloc(pool, sizeof(apr_thread_mutex_t));
+ new_mutex->pool = pool;
+
+ rc = DosCreateMutexSem(NULL, &(new_mutex->hMutex), 0, FALSE);
+ *mutex = new_mutex;
+
+ if (!rc)
+ apr_pool_cleanup_register(pool, new_mutex, thread_mutex_cleanup, apr_pool_cleanup_null);
+
+ return APR_OS2_STATUS(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex)
+{
+ ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_INDEFINITE_WAIT);
+ return APR_OS2_STATUS(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
+{
+ ULONG rc = DosRequestMutexSem(mutex->hMutex, SEM_IMMEDIATE_RETURN);
+ return APR_OS2_STATUS(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex)
+{
+ ULONG rc = DosReleaseMutexSem(mutex->hMutex);
+ return APR_OS2_STATUS(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex)
+{
+ ULONG rc;
+
+ if (mutex->hMutex == 0)
+ return APR_SUCCESS;
+
+ while (DosReleaseMutexSem(mutex->hMutex) == 0);
+
+ rc = DosCloseMutexSem(mutex->hMutex);
+
+ if (!rc) {
+ mutex->hMutex = 0;
+ return APR_SUCCESS;
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex)
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_rwlock.c b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_rwlock.c
new file mode 100644
index 00000000..195a56bd
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/locks/os2/thread_rwlock.c
@@ -0,0 +1,200 @@
+/* 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 "apr_general.h"
+#include "apr_lib.h"
+#include "apr_strings.h"
+#include "apr_portable.h"
+#include "apr_arch_thread_rwlock.h"
+#include "apr_arch_file_io.h"
+#include <string.h>
+
+static apr_status_t thread_rwlock_cleanup(void *therwlock)
+{
+ apr_thread_rwlock_t *rwlock = therwlock;
+ return apr_thread_rwlock_destroy(rwlock);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock,
+ apr_pool_t *pool)
+{
+ apr_thread_rwlock_t *new_rwlock;
+ ULONG rc;
+
+ new_rwlock = (apr_thread_rwlock_t *)apr_palloc(pool, sizeof(apr_thread_rwlock_t));
+ new_rwlock->pool = pool;
+ new_rwlock->readers = 0;
+
+ rc = DosCreateMutexSem(NULL, &(new_rwlock->write_lock), 0, FALSE);
+
+ if (rc)
+ return APR_FROM_OS_ERROR(rc);
+
+ rc = DosCreateEventSem(NULL, &(new_rwlock->read_done), 0, FALSE);
+
+ if (rc)
+ return APR_FROM_OS_ERROR(rc);
+
+ *rwlock = new_rwlock;
+
+ if (!rc)
+ apr_pool_cleanup_register(pool, new_rwlock, thread_rwlock_cleanup,
+ apr_pool_cleanup_null);
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock)
+{
+ ULONG rc, posts;
+
+ rc = DosRequestMutexSem(rwlock->write_lock, SEM_INDEFINITE_WAIT);
+
+ if (rc)
+ return APR_FROM_OS_ERROR(rc);
+
+ /* We've successfully acquired the writer mutex so we can't be locked
+ * for write which means it's ok to add a reader lock. The writer mutex
+ * doubles as race condition protection for the readers counter.
+ */
+ rwlock->readers++;
+ DosResetEventSem(rwlock->read_done, &posts);
+ rc = DosReleaseMutexSem(rwlock->write_lock);
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock)
+{
+ /* As above but with different wait time */
+ ULONG rc, posts;
+
+ rc = DosRequestMutexSem(rwlock->write_lock, SEM_IMMEDIATE_RETURN);
+
+ if (rc)
+ return APR_FROM_OS_ERROR(rc);
+
+ rwlock->readers++;
+ DosResetEventSem(rwlock->read_done, &posts);
+ rc = DosReleaseMutexSem(rwlock->write_lock);
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock)
+{
+ ULONG rc;
+
+ rc = DosRequestMutexSem(rwlock->write_lock, SEM_INDEFINITE_WAIT);
+
+ if (rc)
+ return APR_FROM_OS_ERROR(rc);
+
+ /* We've got the writer lock but we have to wait for all readers to
+ * unlock before it's ok to use it
+ */
+
+ if (rwlock->readers) {
+ rc = DosWaitEventSem(rwlock->read_done, SEM_INDEFINITE_WAIT);
+
+ if (rc)
+ DosReleaseMutexSem(rwlock->write_lock);
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock)
+{
+ ULONG rc;
+
+ rc = DosRequestMutexSem(rwlock->write_lock, SEM_IMMEDIATE_RETURN);
+
+ if (rc)
+ return APR_FROM_OS_ERROR(rc);
+
+ /* We've got the writer lock but we have to wait for all readers to
+ * unlock before it's ok to use it
+ */
+
+ if (rwlock->readers) {
+ /* There are readers active, give up */
+ DosReleaseMutexSem(rwlock->write_lock);
+ rc = ERROR_TIMEOUT;
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock)
+{
+ ULONG rc;
+
+ /* First, guess that we're unlocking a writer */
+ rc = DosReleaseMutexSem(rwlock->write_lock);
+
+ if (rc == ERROR_NOT_OWNER) {
+ /* Nope, we must have a read lock */
+ if (rwlock->readers) {
+ DosEnterCritSec();
+ rwlock->readers--;
+
+ if (rwlock->readers == 0) {
+ DosPostEventSem(rwlock->read_done);
+ }
+
+ DosExitCritSec();
+ rc = 0;
+ }
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+
+
+APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock)
+{
+ ULONG rc;
+
+ if (rwlock->write_lock == 0)
+ return APR_SUCCESS;
+
+ while (DosReleaseMutexSem(rwlock->write_lock) == 0);
+
+ rc = DosCloseMutexSem(rwlock->write_lock);
+
+ if (!rc) {
+ rwlock->write_lock = 0;
+ DosCloseEventSem(rwlock->read_done);
+ return APR_SUCCESS;
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock)
+