You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2008/06/03 16:18:42 UTC

svn commit: r662811 - in /harmony/enhanced/classlib/trunk: make/ modules/portlib/src/main/native/port/unix/ modules/portlib/src/main/native/port/unix/stubs/

Author: hindessm
Date: Tue Jun  3 07:18:42 2008
New Revision: 662811

URL: http://svn.apache.org/viewvc?rev=662811&view=rev
Log:
A number of sets of portlib functions are not actually used (by classlib
today), in order to "lower the bar" for those wishing to do porting work
I've added some trivial stubs for these functions and a -Dhy.portlib.stubs=true
option to enable them.

We might even want to use them to reduce the hyprt dll footprint until
such time as this code is actually used - but this might not please
Ollie who has just written some tests to make sure this unused code
is working. ;-)

Added:
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hycpu.c   (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyipcmutex.c   (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshmem.c   (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshsem.c   (with props)
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyvmem.c   (with props)
Modified:
    harmony/enhanced/classlib/trunk/make/properties.xml
    harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/makefile

Modified: harmony/enhanced/classlib/trunk/make/properties.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/make/properties.xml?rev=662811&r1=662810&r2=662811&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/make/properties.xml (original)
+++ harmony/enhanced/classlib/trunk/make/properties.xml Tue Jun  3 07:18:42 2008
@@ -312,6 +312,8 @@
         </not>
      </condition>
 
+    <property name="hy.portlib.stubs" value="false" />
+
     <condition property="hy.libstdc++.suffix" value=".libstdc++6">
         <isset property="use.libstdc++6"/>
     </condition>
@@ -489,6 +491,7 @@
                   executable="${make.command}"
                   dir="@{dir}">
                 <env key="HY_ZIP_API" value="${hy.zip.api}" />
+                <env key="HY_PORTLIB_STUBS" value="${hy.portlib.stubs}" />
                 <env key="HY_HDK" value="${hy.hdk}" />
                 <env key="HY_CFG" value="${hy.cfg}" />
                 <env key="HY_ARCH" value="${hy.arch}" />

Modified: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/makefile?rev=662811&r1=662810&r2=662811&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/makefile (original)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/makefile Tue Jun  3 07:18:42 2008
@@ -22,19 +22,26 @@
 INCLUDES += -DHYPORT_LIBRARY_DEFINE -I$(HY_PLATFORM)
 
 BUILDFILES = \
-	$(SHAREDSUB)port_copyright.o hycpu.o $(SHAREDSUB)hyerror.o \
+	$(SHAREDSUB)port_copyright.o $(SHAREDSUB)hyerror.o \
 	hyerrorhelpers.o $(SHAREDSUB)hyexit.o hyfile.o hyfiletext.o \
-	$(SHAREDSUB)hygp.o hyipcmutex.o hymem.o \
+	$(SHAREDSUB)hygp.o hymem.o \
 	$(HY_OS)/hymmap.o $(SHAREDSUB)hynls.o hynlshelpers.o hyosdump.o \
 	$(SHAREDSUB)hyport.o $(SHAREDSUB)hyportcontrol.o hyportptb.o \
-	hysharedhelper.o hyshmem.o hyshsem.o $(HY_OS)/hysl.o hysock.o \
+	hysharedhelper.o $(HY_OS)/hysl.o hysock.o \
 	$(SHAREDSUB)hystr.o $(SHAREDSUB)hystrftime.o $(SHAREDSUB)hystsl.o \
-	hysysinfo.o hytime.o $(SHAREDSUB)hytlshelpers.o hytty.o $(HY_OS)/hyvmem.o
+	hysysinfo.o hytime.o $(SHAREDSUB)hytlshelpers.o hytty.o
 
 ifeq ($(HY_NO_SIG),false)
 BUILDFILES += hysignal.o $(HY_PLATFORM)/hysignal_context.o
 endif
 
+ifeq ($(HY_PORTLIB_STUBS),true)
+BUILDFILES += stubs/hycpu.o stubs/hyipcmutex.o stubs/hyshmem.o \
+              stubs/hyshsem.o stubs/hyvmem.o
+else
+BUILDFILES += hycpu.o hyipcmutex.o hyshmem.o hyshsem.o $(HY_OS)/hyvmem.o
+endif
+
 ifeq ($(HY_NO_THR),true)
 MDLLIBFILES += $(LIBPATH)libhythr$(HY_LINKLIB_SUFFIX)
 endif

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hycpu.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hycpu.c?rev=662811&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hycpu.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hycpu.c Tue Jun  3 07:18:42 2008
@@ -0,0 +1,91 @@
+/*
+ *  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.
+ */
+
+#define CDEV_CURRENT_FUNCTION _comment_
+/**
+ * @file
+ * @ingroup Port
+ * @brief CPU Control.
+ *
+ * Functions setting CPU attributes.
+ */
+
+#undef CDEV_CURRENT_FUNCTION
+
+#include "hyport.h"
+
+#define CDEV_CURRENT_FUNCTION hycpu_startup
+/**
+ * PortLibrary startup.
+ *
+ * This function is called during startup of the portLibrary.  Any
+ * resources that are required for the exit operations may be created
+ * here.  All resources created here should be destroyed in @ref
+ * hycpu_shutdown.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @return 0 on success, negative error code on failure.  Error code
+ * values returned are
+ * \arg HYPORT_ERROR_STARTUP_CPU
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hycpu_startup (struct HyPortLibrary *portLibrary)
+{
+  return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hycpu_shutdown
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any
+ * resources that were created by @ref hycpu_startup should be
+ * destroyed here.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hycpu_shutdown (struct HyPortLibrary *portLibrary)
+{
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hycpu_flush_icache
+/**
+ * @brief CPU Control operations.
+ *
+ * Flush the instruction cache to memory.
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] memoryPointer The base address of memory to flush.
+ * @param[in] byteAmount Number of bytes to flush.
+ */
+void VMCALL
+hycpu_flush_icache (struct HyPortLibrary *portLibrary, void *memoryPointer,
+                    UDATA byteAmount)
+{
+}
+
+#undef CDEV_CURRENT_FUNCTION

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hycpu.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyipcmutex.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyipcmutex.c?rev=662811&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyipcmutex.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyipcmutex.c Tue Jun  3 07:18:42 2008
@@ -0,0 +1,133 @@
+/*
+ *  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.
+ */
+
+#define CDEV_CURRENT_FUNCTION _comment_
+/**
+ * @file
+ * @ingroup Port
+ * @brief Shared Resource Mutex
+ *
+ * The HyIPCMutex is used to protect a shared resource from 
+ * simultaneous access by processes or threads executing in 
+ * the same or different VMs.
+ * Each process/thread must request and wait for the ownership 
+ * of the shared resource before it can use that resource. 
+ * It must also release the ownership
+ * of the resource as soon as it has finished using it so that 
+ * other processes competing for the same resource are not delayed.
+ */
+
+#undef CDEV_CURRENT_FUNCTION
+
+#include "hyport.h"
+
+#define CDEV_CURRENT_FUNCTION hyipcmutex_acquire
+/**
+ * Acquires a named mutex for the calling process.
+ *
+ * If a Mutex with the same Name already exists, the function opens
+ * the existing Mutex and tries to lock it.
+ * If another process already has the Mutex locked, the function will
+ * block indefinitely.
+ * If there is no Mutex with the same Name, the function will create
+ * it and lock it for the calling process of this function.
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] name Mutex to be acquired
+ *
+ * @return 0 on success, -1 on error.
+ *
+ * @note The Mutex must be explicitly released by calling the @ref
+ * hyipcmutex_release function as soon as the lock is no longer
+ * required.
+ */
+I_32 VMCALL
+hyipcmutex_acquire (struct HyPortLibrary *portLibrary, const char *name)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyipcmutex_release
+/**
+ * Releases a named Mutex from the calling process.
+ *
+ * If a Mutex with the same Name already exists, the function opens
+ * the existing Mutex and tries to unlock it.
+ * This function will fail if a Mutex with the given Name is not found
+ * or if the Mutex cannot be unlocked.
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] name Mutex to be released.
+ *
+ * @return 0 on success, -1 on error.
+ *
+ * @note Callers of this function must have called the function @ref
+ * hyipcmutex_acquire prior to calling this function.
+ */
+I_32 VMCALL
+hyipcmutex_release (struct HyPortLibrary * portLibrary, const char *name)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyipcmutex_shutdown
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any
+ * resources that were created by @ref hyipcmutex_startup should be
+ * destroyed here.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hyipcmutex_shutdown (struct HyPortLibrary *portLibrary)
+{
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyipcmutex_startup
+/**
+ * PortLibrary startup.
+ *
+ * This function is called during startup of the portLibrary.  Any
+ * resources that are required for the IPC mutex operations may be
+ * created here.  All resources created here should be destroyed in
+ * @ref hyipcmutex_shutdown.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @return 0 on success, negative error code on failure.  Error code
+ * values returned are
+ * \arg HYPORT_ERROR_STARTUP_IPCMUTEX
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hyipcmutex_startup (struct HyPortLibrary *portLibrary)
+{
+  return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyipcmutex.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshmem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshmem.c?rev=662811&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshmem.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshmem.c Tue Jun  3 07:18:42 2008
@@ -0,0 +1,270 @@
+/*
+ *  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.
+ */
+
+#define CDEV_CURRENT_FUNCTION _comment_
+/**
+ * @file
+ * @ingroup Port
+ * @brief Shared Memory Semaphores
+ */
+
+#undef CDEV_CURRENT_FUNCTION
+
+#include "hyport.h"
+#include "ut_hyprt.h"
+
+#include "portnls.h"
+#include "portpriv.h"
+#include "hysharedhelper.h"
+#define CDEV_CURRENT_FUNCTION include_header
+#include "hyshmem.h"
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_open
+/**
+ * Creates/open a shared memory region
+ * 
+ * The rootname will uniquely identify the shared memory region, 
+ * and is valid across different JVM instance. 
+ * 
+ * The shared memory region should persist across process, until OS reboots 
+ * or destroy call is being made.
+ * 
+ * @param[in] portLibrary The port Library
+ * @param[out] handle This handle is required for further
+ * attach/destroy of the memory region
+ * @param[in] rootname Shared name for the region, which used to
+ * identify the region.
+ * @param[in] size Size of the region in bytes
+ * @param[in] perm permission for the region.
+ * 
+ * @return
+ * \arg HYPORT_ERROR_SHMEM_OPFAILED Failure - Cannot open the shared
+ * memory region
+ * \arg HYPORT_INFO_SHMEM_OPENED Success - Existing memory region has
+ * been opened
+ * \arg HYPORT_INFO_SHMEM_CREATED Success - A new shared memory region
+ * has been created
+ */
+IDATA VMCALL
+hyshmem_open (HyPortLibrary * portLibrary, struct hyshmem_handle **handle,
+              const char *rootname, I_32 size, I_32 perm)
+{
+  return HYPORT_ERROR_SHMEM_OPFAILED;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_close
+/**
+ * Detach, Close and remove the shared memory handle.
+ * 
+ * @note This method does not remove the shared memory region from the
+ *	 OS use @ref hyshmem_destroy instead. However this will free
+ *	 all the memory resources used by the handle, and detach the
+ *	 region specified by the handle
+ *
+ * @param[in] portLibrary The port Library
+ * @param[in] handle Pointer to a valid shared memory handle
+ * 
+ */
+void VMCALL
+hyshmem_close (struct HyPortLibrary *portLibrary,
+               struct hyshmem_handle **handle)
+{
+}
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_attach
+/**
+ * Attaches the shared memory represented by the handle
+ * 
+ * @param[in] portLibrary The port Library
+ * @param[in] handle A valid shared memory handle
+ * 
+ * @return: A pointer to the shared memory region, NULL on failure
+ */
+void *VMCALL
+hyshmem_attach (struct HyPortLibrary *portLibrary,
+                struct hyshmem_handle *handle)
+{
+  return NULL;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_destroy
+/**
+ * Destroy and removes the shared memory region from OS.
+ * 
+ * The timing of which OS removes the memory is OS dependent. However
+ * when you make a call you can considered that you can no longer
+ * access the region through the handle. Memory allocated for handle
+ * structure is freed as well.
+ * 
+ * @param[in] portLibrary The port Library
+ * @param[in] handle Pointer to a valid shared memory handle
+ * 
+ * @return 0 on success, -1 on failure.
+ */
+IDATA VMCALL
+hyshmem_destroy (struct HyPortLibrary * portLibrary,
+                 struct hyshmem_handle ** handle)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_detach
+/**
+ * Detaches the shared memory region from the caller's process address space
+ * Use @ref hyshmem_destroy to actually remove the memory region from
+ * the Operating system
+ *
+ * @param[in] portLibrary the Port Library.
+ * @param[in] handle Pointer to the shared memory region.
+ * 
+ * @return 0 on success, -1 on failure.
+ */
+IDATA VMCALL
+hyshmem_detach (struct HyPortLibrary * portLibrary,
+                struct hyshmem_handle ** handle)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_findclose
+/**
+ * Close the handle returned from @ref hyshmem_findfirst.
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] findhandle  Handle returned from @ref hyshmem_findfirst.
+ */
+void VMCALL
+hyshmem_findclose (struct HyPortLibrary *portLibrary, UDATA findhandle)
+{
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_findfirst
+/**
+ * Find the name of a shared memory region on the system. Answers a
+ * handle to be used in subsequent calls to @ref hyshmem_findnext and
+ * @ref hyshmem_findclose.
+ *
+ * @param[in] portLibrary The port library
+ * @param[out] resultbuf filename and path matching path.
+ *
+ * @return valid handle on success, -1 on failure.
+ */
+UDATA VMCALL
+hyshmem_findfirst (struct HyPortLibrary *portLibrary, char *resultbuf)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_findnext
+/**
+ * Find the name of the next shared memory region.
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] findhandle handle returned from @ref hyshmem_findfirst.
+ * @param[out] resultbuf next filename and path matching findhandle.
+ *
+ * @return 0 on success, -1 on failure or if no matching entries.
+ */
+I_32 VMCALL
+hyshmem_findnext (struct HyPortLibrary * portLibrary, UDATA findHandle,
+                  char *resultbuf)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_stat
+/**
+ * Return the statistic for a shared memory region
+ *
+ * @note notice that the implementation can decided to put -1 in the
+ * fields of @ref statbuf if it does not make sense on this platform,
+ * or it is impossible to obtain.
+ * 
+ * @param[in] portLibrary The port library
+ * @param[in] name The name of the shared memory area.
+ * @param[out] statbuf the statistics returns by the operating system
+ *
+ * @return 0 on success, -1 on failure or if there is no matching entries.
+ */
+UDATA VMCALL
+hyshmem_stat (struct HyPortLibrary * portLibrary, const char *name,
+              struct HyPortShmemStatistic * statbuf)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_shutdown
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any
+ * resources that were created by @ref hyshsem_startup should be
+ * destroyed here.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hyshmem_shutdown (struct HyPortLibrary *portLibrary)
+{
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshmem_startup
+/**
+ * PortLibrary startup.
+ *
+ * This function is called during startup of the portLibrary.  Any
+ * resources that are required for the file operations may be created
+ * here.  All resources created here should be destroyed in @ref
+ * hyshsem_shutdown.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @return 0 on success, negative error code on failure.  Error code
+ * values returned are
+ * \arg HYPORT_ERROR_STARTUP_SHMEM
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hyshmem_startup (struct HyPortLibrary *portLibrary)
+{
+  return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshmem.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshsem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshsem.c?rev=662811&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshsem.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshsem.c Tue Jun  3 07:18:42 2008
@@ -0,0 +1,259 @@
+/*
+ *  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.
+ */
+
+#define CDEV_CURRENT_FUNCTION _comment_
+/**
+ * @file
+ * @ingroup Port
+ * @brief Shared Semaphores
+ */
+
+#undef CDEV_CURRENT_FUNCTION
+
+#include "portpriv.h"
+#include "hyport.h"
+
+#define CDEV_CURRENT_FUNCTION include_header
+#include "hyshsem.h"
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_open
+/**
+ * Open an existing semaphore set, or create a new one if it does not exist
+ * 
+ * @param[in] portLibrary The port library.
+ * @param[out] handle A semaphore handle is allocated and initialised
+ * for use with further calls, NULL on failure.
+ * @param[in] semname Unique identifier of the semaphore.
+ * @param[in] setSize Size of the semaphore set.
+ * @param[in] permission Permission to the semaphore set.
+ *
+ * @return
+ * \arg HYPORT_ERROR_SHSEM_OPFAILED   Failure - Error opening the semaphore
+ * \arg HYPORT_INFO_SHSEM_CREATED Success - Semaphore has been created
+ * \arg HYPORT_INFO_SHSEM_OPENED  Success - Existing semaphore has been opened
+ * \arg HYPORT_INFO_SHSEM_SEMID_DIFF Success - Existing semaphore
+ * opened, but OS Semaphore key is different
+ */
+IDATA VMCALL
+hyshsem_open (struct HyPortLibrary *portLibrary,
+              struct hyshsem_handle **handle, const char *semname,
+              int setSize, int permission)
+{
+  return HYPORT_ERROR_SHSEM_OPFAILED;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_post
+/**
+ * post operation increments the counter in the semaphore by 1 if
+ * there is no one in wait for the semaphore.  if there are other
+ * processes suspended by wait then one of them will become runnable
+ * and the counter remains the same.
+ * 
+ * @param[in] portLibrary The port library.
+ * @param[in] handle Semaphore set handle.
+ * @param[in] semset The no of semaphore in the semaphore set that you
+ * want to post.
+ * @param[in] flag The semaphore operation flag:
+ * \arg HYPORT_SHSEM_MODE_DEFAULT The default operation flag, same as 0
+ * \arg HYPORT_SHSEM_MODE_UNDO The changes made to the semaphore will
+ * be undone when this process finishes.
+ *
+ * @return 0 on success, -1 on failure.
+ */
+IDATA VMCALL
+hyshsem_post (struct HyPortLibrary * portLibrary,
+              struct hyshsem_handle * handle, UDATA semset, UDATA flag)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_wait
+/**
+ * Wait operation decrements the counter in the semaphore set if the counter > 0
+ * if counter == 0 then the caller will be suspended.
+ * 
+ * @param[in] portLibrary The port library.
+ * @param[in] handle Semaphore set handle.
+ * @param[in] semset The no of semaphore in the semaphore set that you
+ * want to post.
+ * @param[in] flag The semaphore operation flag:
+ * \arg HYPORT_SHSEM_MODE_DEFAULT The default operation flag, same as 0
+ * \arg HYPORT_SHSEM_MODE_UNDO The changes made to the semaphore will
+ * be undone when this process finishes.
+ * \arg HYPORT_SHSEM_MODE_NOWAIT The caller will not be suspended if
+ * sem == 0, a -1 is returned instead.
+ * 
+ * @return 0 on success, -1 on failure.
+ */
+IDATA VMCALL
+hyshsem_wait (struct HyPortLibrary * portLibrary,
+              struct hyshsem_handle * handle, UDATA semset, UDATA flag)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_getVal
+/**
+ * reading the value of the semaphore in the set. This function
+ * uses no synchronisation prmitives
+ * 
+ * @pre caller has to deal with synchronisation issue.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] handle Semaphore set handle.
+ * @param[in] semset The number of semaphore in the semaphore set that
+ * you want to post.
+ * 
+ * @return -1 on failure, the value of the semaphore on success
+ * 
+ * @warning: The user will need to make sure locking is done correctly
+ * when accessing semaphore values. This is because getValue simply
+ * reads the semaphore value without stopping the access to the
+ * semaphore. Therefore the value of the semaphore can change before
+ * the function returns.
+ */
+IDATA VMCALL
+hyshsem_getVal (struct HyPortLibrary * portLibrary,
+                struct hyshsem_handle * handle, UDATA semset)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_setVal
+/**
+ * 
+ * setting the value of the semaphore specified in semset. This function
+ * uses no synchronisation prmitives
+ * 
+ * @pre Caller has to deal with synchronisation issue.
+ * 
+ * @param[in] portLibrary The port Library.
+ * @param[in] handle Semaphore set handle.
+ * @param[in] semset The no of semaphore in the semaphore set that you
+ * want to post.
+ * @param[in] value The value that you want to set the semaphore to
+ * 
+ * @warning The user will need to make sure locking is done correctly
+ * when accessing semaphore values. This is because setValue simply
+ * set the semaphore value without stopping the access to the
+ * semaphore. Therefore the value of the semaphore can change before
+ * the function returns.
+ *
+ * @return 0 on success, -1 on failure.
+ */
+IDATA VMCALL
+hyshsem_setVal (struct HyPortLibrary * portLibrary,
+                struct hyshsem_handle * handle, UDATA semset, IDATA value)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_close
+/**
+ * Release the resources allocated for the semaphore handles.
+ * 
+ * @param[in] portLibrary The port library.
+ * @param[in] handle Semaphore set handle.
+ * 
+ * @note The actual semaphore is not destroyed.  Once the close
+ * operation has been performed on the semaphore handle, it is no
+ * longer valid and user needs to reissue @ref hyshsem_open call.
+ */
+void VMCALL
+hyshsem_close (struct HyPortLibrary *portLibrary,
+               struct hyshsem_handle **handle)
+{
+  return;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_destroy
+/**
+ * Destroy the semaphore and release the resources allocated for the
+ * semaphore handles.
+ * 
+ * @param[in] portLibrary The port library.
+ * @param[in] handle Semaphore set handle.
+ * 
+ * @return 0 on success, -1 on failure.
+ * @note Due to operating system restriction we may not be able to
+ * destroy the semaphore
+ */
+IDATA VMCALL
+hyshsem_destroy (struct HyPortLibrary * portLibrary,
+                 struct hyshsem_handle ** handle)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_startup
+/**
+ * PortLibrary startup.
+ *
+ * This function is called during startup of the portLibrary.  Any
+ * resources that are required for the file operations may be created
+ * here.  All resources created here should be destroyed in @ref
+ * hyshsem_shutdown.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @return 0 on success, negative error code on failure.  Error code
+ * values returned are
+ * \arg HYPORT_ERROR_STARTUP_SHSEM
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hyshsem_startup (struct HyPortLibrary * portLibrary)
+{
+  return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyshsem_shutdown
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any
+ * resources that were created by @ref hyshsem_startup should be
+ * destroyed here.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hyshsem_shutdown (struct HyPortLibrary *portLibrary)
+{
+}
+
+#undef CDEV_CURRENT_FUNCTION

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyshsem.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyvmem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyvmem.c?rev=662811&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyvmem.c (added)
+++ harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyvmem.c Tue Jun  3 07:18:42 2008
@@ -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.
+ */
+
+#define CDEV_CURRENT_FUNCTION _comment_
+/**
+ * @file
+ * @ingroup Port
+ * @brief Virtual memory
+ */
+
+#undef CDEV_CURRENT_FUNCTION
+
+#include "hyport.h"
+#include "portpriv.h"
+#include "hyportpg.h"
+#include "ut_hyprt.h"
+
+#define CDEV_CURRENT_FUNCTION hyvmem_shutdown
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any resources that were created by @ref hyvmem_startup
+ * should be destroyed here.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hyvmem_shutdown (struct HyPortLibrary *portLibrary)
+{
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyvmem_startup
+/**
+ * PortLibrary startup.
+ *
+ * This function is called during startup of the portLibrary.  Any
+ * resources that are required for the virtual memory operations may
+ * be created here.  All resources created here should be destroyed in
+ * @ref hyvmem_shutdown.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @return 0 on success, negative error code on failure.  Error code
+ * values returned are \arg HYPORT_ERROR_STARTUP_VMEM
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hyvmem_startup (struct HyPortLibrary *portLibrary)
+{
+  return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyvmem_commit_memory
+/**
+ * Commit memory in virtual address space.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] address The page aligned starting address of the memory to commit.
+ * @param[in] byteAmount The number of bytes to commit.
+ * @param[in] identifier Descriptor for virtual memory block.
+ *
+ * @return pointer to the allocated memory on success, NULL on failure.
+ */
+void *VMCALL
+hyvmem_commit_memory (struct HyPortLibrary *portLibrary, void *address,
+                      UDATA byteAmount,
+                      struct HyPortVmemIdentifier *identifier)
+{
+  return NULL;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyvmem_decommit_memory
+/**
+ * Decommit memory in virtual address space.
+ *
+ * Decommits physical storage of the size specified starting at the
+ * address specified.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] address The starting address of the memory to be decommitted.
+ * @param[in] byteAmount The number of bytes to be decommitted.
+ * @param[in] identifier Descriptor for virtual memory block.
+ *
+ * @return 0 on success, non zero on failure.
+ */
+IDATA VMCALL
+hyvmem_decommit_memory (struct HyPortLibrary * portLibrary, void *address,
+                        UDATA byteAmount,
+                        struct HyPortVmemIdentifier * identifier)
+{
+  return (IDATA) 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyvmem_free_memory
+/**
+ * Free memory in virtual address space.
+ *
+ * Frees physical storage of the size specified starting at the
+ * address specified.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] address The starting address of the memory to be de-allocated.
+ * @param[in] byteAmount The number of bytes to be allocated.
+ * @param[in] identifier Descriptor for virtual memory block.
+ *
+ * @return 0 on success, non zero on failure.
+ */
+I_32 VMCALL
+hyvmem_free_memory (struct HyPortLibrary * portLibrary, void *address,
+                    UDATA byteAmount,
+                    struct HyPortVmemIdentifier * identifier)
+{
+  return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyvmem_reserve_memory
+/**
+ * Reserve memory in virtual address space.
+ *
+ * Reserves a range of virtual address space without allocating any
+ * actual physical storage.
+ * The memory is not available for use until committed @ref
+ * hyvmem_commit_memory.
+ * The memory may not be used by other memory allocation routines
+ * until it is explicitly released.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] address The starting address of the memory to be reserved.
+ * @param[in] byteAmount The number of bytes to be reserved.
+ * @param[in] identifier Descriptor for virtual memory block.
+ * @param[in] mode Bitmap indicating how memory is to be reserved.
+ * Expected values combination of:
+ * \arg HYPORT_VMEM_MEMORY_MODE_READ memory is readable
+ * \arg HYPORT_VMEM_MEMORY_MODE_WRITE memory is writable
+ * \arg HYPORT_VMEM_MEMORY_MODE_EXECUTE memory is executable
+ * \arg HYPORT_VMEM_MEMORY_MODE_COMMIT commits memory as part of the reserve
+ * @param[in] pageSize Size of the page requested, a value returned by
+ * @ref hyvmem_supported_page_sizes, or the constant
+ * HYPORT_VMEM_PAGE_SIZE_DEFAULT for the system default page size.
+ *
+ * @return pointer to the reserved memory on success, NULL on failure.
+ *
+ * @internal @warning Do not call error handling code @ref hyerror
+ * upon error as the error handling code uses per thread buffers to
+ * store the last error.  If memory can not be allocated the result
+ * would be an infinite loop.
+ */
+void *VMCALL
+hyvmem_reserve_memory (struct HyPortLibrary *portLibrary, void *address,
+                       UDATA byteAmount,
+                       struct HyPortVmemIdentifier *identifier, UDATA mode,
+                       UDATA pageSize)
+{
+  return NULL;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hyvmem_supported_page_sizes
+/**
+ * Determine the page sizes supported.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @return A 0 terminated array of supported page sizes.  The first entry is the default page size, other entries
+ * are the large page sizes supported.
+ */
+UDATA *VMCALL
+hyvmem_supported_page_sizes (struct HyPortLibrary * portLibrary)
+{
+  return PPG_vmem_pageSize;
+}
+#undef CDEV_CURRENT_FUNCTION

Propchange: harmony/enhanced/classlib/trunk/modules/portlib/src/main/native/port/unix/stubs/hyvmem.c
------------------------------------------------------------------------------
    svn:eol-style = native