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/06 14:35:30 UTC
svn commit: r801628 - in /commons/sandbox/runtime/trunk/src/main/native: ./
include/ include/arch/darwin/ include/arch/hpux/ include/arch/linux/
include/arch/solaris/ os/unix/
Author: mturk
Date: Thu Aug 6 12:35:30 2009
New Revision: 801628
URL: http://svn.apache.org/viewvc?rev=801628&view=rev
Log:
Add dso support
Added:
commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h (with props)
commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.in
commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h
commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=801628&r1=801627&r2=801628&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Thu Aug 6 12:35:30 2009
@@ -96,6 +96,7 @@
$(SRCDIR)/modules/network/ssl/openssl.$(OBJ)
LINUX_OBJS= \
+ $(SRCDIR)/os/unix/dso.$(OBJ) \
$(SRCDIR)/os/unix/file.$(OBJ) \
$(SRCDIR)/os/unix/main.$(OBJ) \
$(SRCDIR)/os/unix/ios.$(OBJ) \
@@ -114,6 +115,7 @@
$(SRCDIR)/os/linux/os.$(OBJ)
SOLARIS_OBJS= \
+ $(SRCDIR)/os/unix/dso.$(OBJ) \
$(SRCDIR)/os/unix/execmem.$(OBJ) \
$(SRCDIR)/os/unix/file.$(OBJ) \
$(SRCDIR)/os/unix/main.$(OBJ) \
@@ -131,6 +133,7 @@
$(SRCDIR)/os/solaris/os.$(OBJ)
DARWIN_OBJS= \
+ $(SRCDIR)/os/unix/dso.$(OBJ) \
$(SRCDIR)/os/unix/execmem.$(OBJ) \
$(SRCDIR)/os/unix/file.$(OBJ) \
$(SRCDIR)/os/unix/main.$(OBJ) \
@@ -148,6 +151,7 @@
$(SRCDIR)/os/darwin/os.$(OBJ)
HPUX_OBJS= \
+ $(SRCDIR)/os/unix/dso.$(OBJ) \
$(SRCDIR)/os/unix/execmem.$(OBJ) \
$(SRCDIR)/os/unix/file.$(OBJ) \
$(SRCDIR)/os/unix/main.$(OBJ) \
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h?rev=801628&r1=801627&r2=801628&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_descriptor.h Thu Aug 6 12:35:30 2009
@@ -39,6 +39,7 @@
#define ACR_DT_SHM 0x00000005
#define ACR_DT_PIPE 0x00000006
#define ACR_DT_SOCKET 0x00000007
+#define ACR_DT_DSO 0x00000008
#define ACR_DT_MASK 0x000000FF
typedef enum {
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h?rev=801628&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h Thu Aug 6 12:35:30 2009
@@ -0,0 +1,65 @@
+/* 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.
+ */
+
+#ifndef _ACR_DSO_H
+#define _ACR_DSO_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_dso.h
+ * @brief
+ *
+ * ACR Dynamic Object Handling
+ *
+ */
+
+/**
+ * Load a DSO library.
+ * @param env JNI environment to use.
+ * @param path Path to the DSO library
+ * @bug We aught to provide an alternative to RTLD_GLOBAL, which
+ * is the only supported method of loading DSOs today.
+ * @return Handle to the DSO library or -1 on error.
+ */
+ACR_DECLARE(int) ACR_DsoLoad(JNIEnv *env, const acr_pchar_t *path);
+
+/**
+ * Close a DSO library.
+ * @param dso handle to close.
+ */
+ACR_DECLARE(int) ACR_DsoUnload(JNIEnv *env, int dso);
+
+/**
+ * Load a symbol from a DSO handle.
+ * @param env JNI environment to use.
+ * @param dso handle to load the symbol from.
+ * @param symname Name of the symbol to load.
+ */
+ACR_DECLARE(void *) ACR_DsoSym(JNIEnv *env, int dso,
+ const acr_pchar_t *symname);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_DSO_H */
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h?rev=801628&r1=801627&r2=801628&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/darwin/acr_arch_private.h Thu Aug 6 12:35:30 2009
@@ -63,6 +63,16 @@
#define APR_O_NONBLOCK_INHERITED 1
#define APR_HAS_LARGE_FILES 1
+/**
+ * Temporary APR private flags
+ */
+#define DEV_RANDOM "/dev/urandom"
+#define DSO_USE_DLFCN 1
+#define DIRENT_INODE d_fileno
+#define DIRENT_TYPE d_type
+#define HAVE_DECL_SYS_SIGLIST 1
+
+
#ifdef __cplusplus
}
#endif
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h?rev=801628&r1=801627&r2=801628&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/hpux/acr_arch_private.h Thu Aug 6 12:35:30 2009
@@ -59,6 +59,15 @@
#define APR_O_NONBLOCK_INHERITED 0
#define APR_HAS_LARGE_FILES 0
+/**
+ * Temporary APR private flags
+ */
+#define DEV_RANDOM "/dev/urandom"
+#define DSO_USE_DLFCN 1
+#define DIRENT_INODE d_fileno
+#undef DIRENT_TYPE
+#define HAVE_DECL_SYS_SIGLIST 0
+
#ifdef __cplusplus
}
#endif
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h?rev=801628&r1=801627&r2=801628&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/linux/acr_arch_private.h Thu Aug 6 12:35:30 2009
@@ -59,6 +59,15 @@
#define APR_O_NONBLOCK_INHERITED 0
#define APR_HAS_LARGE_FILES 0
+/**
+ * Temporary APR private flags
+ */
+#define DEV_RANDOM "/dev/urandom"
+#define DSO_USE_DLFCN 1
+#define DIRENT_INODE d_fileno
+#define DIRENT_TYPE d_type
+#define HAVE_DECL_SYS_SIGLIST 1
+
#ifdef __cplusplus
}
#endif
Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h?rev=801628&r1=801627&r2=801628&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/solaris/acr_arch_private.h Thu Aug 6 12:35:30 2009
@@ -59,6 +59,15 @@
#define APR_O_NONBLOCK_INHERITED 1
#define APR_HAS_LARGE_FILES 1
+/**
+ * Temporary APR private flags
+ */
+#define DEV_RANDOM "/dev/urandom"
+#define DSO_USE_DLFCN 1
+#define DIRENT_INODE d_ino
+#undef DIRENT_TYPE
+#define HAVE_DECL_SYS_SIGLIST 0
+
#ifdef __cplusplus
}
#endif
Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c?rev=801628&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c Thu Aug 6 12:35:30 2009
@@ -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 "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_string.h"
+#include "acr_descriptor.h"
+#include "acr_dso.h"
+
+static int dso_cleanup(void *dso, int type, unsigned int flags)
+{
+ if (type != ACR_DT_DSO) {
+ if (dlclose(dso) != 0)
+ return ACR_EINIT;
+ else
+ return ACR_SUCCESS;
+ }
+ return ACR_EINVAL;
+}
+
+ACR_DECLARE(int) ACR_DsoLoad(JNIEnv *_E, const acr_pchar_t *path)
+{
+ int rc;
+ int flags = RTLD_NOW | RTLD_GLOBAL;
+ void *handle;
+
+#ifdef _AIX
+ if (strchr(path + 1, '(') && path[strlen(path) - 1] == ')') {
+ /* This special archive.a(dso.so) syntax is required for
+ * the way libtool likes to build shared libraries on AIX.
+ * dlopen() support for such a library requires that the
+ * RTLD_MEMBER flag be enabled.
+ */
+ flags |= RTLD_MEMBER;
+ }
+#endif
+ handle = dlopen(path, flags);
+ if (handle == NULL) {
+ rc = ACR_GET_OS_ERROR();
+ if (!IS_INVALID_HANDLE(_E)) {
+ ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_EIO, dlerror());
+ }
+ ACR_SET_OS_ERROR(rc);
+ return -1;
+ }
+
+ rc = acr_ioh_open(handle, ACR_DT_DSO, 0, dso_cleanup);
+ return rc;
+}
+
+ACR_DECLARE(int) ACR_DsoUnload(JNIEnv *_E, int dso)
+{
+ int rv;
+
+ rv = acr_ioh_close(dso);
+ if (rv && !IS_INVALID_HANDLE(_E)) {
+ if (rv == EACCES)
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
+ else
+ ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rv);
+ }
+ return rv;
+}
+
+ACR_DECLARE(void *) ACR_DsoSym(JNIEnv *_E, int dso, const acr_pchar_t *symname)
+{
+ int rc;
+ void *handle = ACR_IOH(dso);
+
+ if (IS_INVALID_HANDLE(handle) || ACR_IOH_TYPE(dso) != ACR_DT_DSO) {
+ ACR_SET_OS_ERROR(ACR_EINVAL);
+ return NULL;
+ }
+ else {
+ void *retval = dlsym(handle, symname);
+ if (retval == NULL) {
+ rc = ACR_GET_OS_ERROR();
+ if (!IS_INVALID_HANDLE(_E)) {
+ ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_EIO, dlerror());
+ }
+ ACR_SET_OS_ERROR(rc);
+ }
+ return retval;
+ }
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c
------------------------------------------------------------------------------
svn:eol-style = native