harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r382065 [6/10] - in /incubator/harmony/enhanced/classlib/trunk: modules/security/make/ modules/security/make/native/linux/ modules/security/make/native/windows/ native-src/ native-src/linux.IA32/ native-src/linux.IA32/archive/ native-src/li...
Date Wed, 01 Mar 2006 15:43:11 GMT
Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/socket.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/socket.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/socket.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/nio/socket.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,54 @@
+/* Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed 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.
+ */
+
+#if !defined(socket_h)
+#define socket_h
+#define BROKEN_MULTICAST_IF 1
+#define BROKEN_MULTICAST_TTL 2
+#define BROKEN_TCP_NODELAY 4
+/* signals that when SO_LINGER is enabled and shutdown() is called, a subsequent call to closesocket() will unnecessarily hang */
+#define BROKEN_SO_LINGER_SHUTDOWN 8
+
+jobject getByteSocketOption (JNIEnv * env, hysocket_t hysocketP, int option);
+void setIPV6McastInterface (JNIEnv * env, hysocket_t hysocketP,
+          jobject optVal);
+void setByteSocketOption (JNIEnv * env, hysocket_t hysocketP, int option,
+        jobject optVal);
+jobject getIPV6McastInterface (JNIEnv * env, hysocket_t hysocketP);
+void setSendBufferSize (JNIEnv * env, hysocket_t hysocketP, jobject optVal);
+jobject getReceiveBufferSize (JNIEnv * env, hysocket_t hysocketP);
+jobject getMcastInterface (JNIEnv * env, hysocket_t hysocketP);
+void mcastAddMembership (JNIEnv * env, hysocket_t hysocketP, jobject optVal,
+       BOOLEAN ignoreIF);
+void setIntegerSocketOption (JNIEnv * env, hysocket_t hysocketP, int level,
+           int option, jobject optVal);
+jobject getSendBufferSize (JNIEnv * env, hysocket_t hysocketP);
+void mcastDropMembership (JNIEnv * env, hysocket_t hysocketP, jobject optVal,
+        BOOLEAN ignoreIF);
+void setReuseAddrAndReusePort (JNIEnv * env, hysocket_t hysocketP,
+             jobject optVal);
+void setBoolSocketOption (JNIEnv * env, hysocket_t hysocketP, int level,
+        int option, jobject optVal);
+void setMcastInterface (JNIEnv * env, hysocket_t hysocketP, jobject optVal);
+jobject getIntegerValue (JNIEnv * env, hysocket_t hysocketP, int level,
+       int option);
+void setLingerOption (JNIEnv * env, hysocket_t hysocketP, jobject optVal);
+jobject getBooleanValue (JNIEnv * env, hysocket_t hysocketP, int level,
+       int option);
+jobject getLingerOption (JNIEnv * env, hysocket_t hysocketP);
+void setReceiveBufferSize (JNIEnv * env, hysocket_t hysocketP,
+         jobject optVal);
+#endif /* socket_h */
+

Propchange: incubator/harmony/enhanced/classlib/trunk/native-src/shared/pool/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar  1 07:42:53 2006
@@ -0,0 +1 @@
+*.obj

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/pool/pool_cap.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/pool/pool_cap.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/pool/pool_cap.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/pool/pool_cap.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,107 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/**
+ * @file
+ * @ingroup Pool
+ * @brief Pool-capacity functions
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "hypool.h"
+
+#define ROUND_TO(granularity, number) ( (((number) % (granularity)) ? ((number) + (granularity) - ((number) % (granularity))) : (number)))
+
+#define MIN_GRANULARITY		sizeof(UDATA)
+
+#define MALLOC_ALIGNMENT sizeof(UDATA)
+
+/* read this if a port library call becomes available that gives out the OS page size */
+#if 0
+#define OS_PAGE_SIZE		(EsGetAddressSpacePageSize())
+#else
+
+#define OS_PAGE_SIZE		4096
+#endif
+
+/**
+ * Ensures that the pool is large enough for newCapacity elements.
+ * This has the side effect of setting the POOL_NEVER_FREE_PUDDLES flag.
+ * Without this, the pool could shrink back down to its original size.
+ * Note that this does not take into account the number of elements already
+ * used in the pool.
+ *
+ * @param[in] aPool The pool
+ * @param[in] newCapacity The desired new-size of the pool
+ *
+ * @return 0 on success
+ * @return -1 on failure
+ * 
+ */
+UDATA VMCALL
+pool_ensureCapacity (HyPool * aPool, UDATA newCapacity)
+{
+  UDATA numElements = pool_capacity (aPool);
+
+  /* find the last pool and mark each pool as POOL_NEVER_FREE_PUDDLES */
+  for (;;)
+    {
+      aPool->flags |= POOL_NEVER_FREE_PUDDLES;
+      if (aPool->nextPool == NULL)
+        break;
+      aPool = aPool->nextPool;
+    }
+
+  if (newCapacity > numElements)
+    {
+      UDATA newSize = newCapacity - numElements;
+      if (newSize < aPool->numberOfElements)
+        {
+          newSize = aPool->numberOfElements;
+        }
+
+      aPool->nextPool =
+        pool_new (aPool->elementSize, newSize, aPool->alignment, aPool->flags,
+                  aPool->memAlloc, aPool->memFree, aPool->userData);
+      if (aPool->nextPool == NULL)
+        return -1;
+    }
+
+  return 0;
+}
+
+/**
+ * Returns the total capacity of a pool
+ *
+ * @param[in] aPool The pool
+ *
+ * @return 0 on error
+ * @return numElements in aPool otherwise
+ *
+ */
+UDATA VMCALL
+pool_capacity (HyPool * aPool)
+{
+  UDATA numElements = 0;
+  while (aPool)
+    {
+      numElements += aPool->numberOfElements;
+      aPool = aPool->nextPool;
+    }
+  return numElements;
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Mar  1 07:42:53 2006
@@ -0,0 +1 @@
+*.obj

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyerror.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyerror.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyerror.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyerror.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,324 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/**
+ * @file 
+ * @ingroup Port
+ * @brief Error Handling
+ *
+ * If an OS system call fails the error code reported by the OS needs to be saved for future reference.
+ * The OS error code as well as the corresponding portable error code are stored in the per thread
+ * buffers @ref hyportptb.h via a call the @ref hyerror_set_last_error or @ref hyerror_set_last_error_with_message.
+ * These functions are meant for private use by the port library, to set the error related to a system call failure.
+ * They are in the port library table as people overriding port library functions may need to set the error
+ * message accordingly.
+ *
+ * The majority of applications are not interested in the human readable error message corresponding to
+ * the error.  As a result the error message is not stored at time of the reported error, but can be looked
+ * up at a later time.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "portpriv.h"
+#include "portnls.h"
+#include "hyportptb.h"
+
+static const char *
+swapMessageBuffer (PortlibPTBuffers_t ptBuffers, const char *message)
+{
+  char *tempBuffer = ptBuffers->reportedMessageBuffer;
+  U_32 tempBufferSize = ptBuffers->reportedMessageBufferSize;
+
+  if (message == NULL)
+    {
+      return "";
+    }
+
+  /* Can't swap unknown message buffer */
+  if (message != ptBuffers->errorMessageBuffer)
+    {
+      return message;
+    }
+
+  /* Save reported information */
+  ptBuffers->reportedErrorCode = ptBuffers->portableErrorCode;
+  ptBuffers->reportedMessageBuffer = ptBuffers->errorMessageBuffer;
+  ptBuffers->reportedMessageBufferSize = ptBuffers->errorMessageBufferSize;
+
+  if (tempBufferSize > 0)
+    {
+      tempBuffer[0] = '\0';
+    }
+
+  /* Clear pending fields ready for next error */
+  ptBuffers->portableErrorCode = 0;
+  ptBuffers->errorMessageBuffer = tempBuffer;
+  ptBuffers->errorMessageBufferSize = tempBufferSize;
+
+  return ptBuffers->reportedMessageBuffer;
+}
+
+/**
+ * PortLibrary startup.
+ *
+ * This function is called during startup of the portLibrary.  Any resources that are required for
+ * the error handling operations may be created here.  All resources created here should be destroyed
+ * in @ref hyerror_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_ERROR
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hyerror_startup (struct HyPortLibrary * portLibrary)
+{
+  return 0;
+}
+
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any resources that were created by @ref hyerror_startup
+ * should be destroyed here.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hyerror_shutdown (struct HyPortLibrary *portLibrary)
+{
+}
+
+/**
+ *  @brief Error Handling
+ *
+ * Return the error message as reported by the OS for the last saved error.
+ * If no error has been saved then an empty message is returned.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @return The error message for the last OS failure, empty message on failure.
+ */
+const char *VMCALL
+hyerror_last_error_message (struct HyPortLibrary *portLibrary)
+{
+  PortlibPTBuffers_t ptBuffers;
+
+  /* Was an error saved ? */
+  ptBuffers = hyport_tls_peek (portLibrary);
+  if (NULL == ptBuffers)
+    {
+      return "";
+    }
+
+  /* New error ? */
+  if (ptBuffers->portableErrorCode != 0)
+    {
+      const char *message = NULL;
+
+      /* Customized message stored ? */
+      if (ptBuffers->errorMessageBufferSize > 0)
+        {
+          if ('\0' != ptBuffers->errorMessageBuffer[0])
+            {
+              message = ptBuffers->errorMessageBuffer;
+            }
+        }
+
+      /* Call a helper to get the last message from the OS.  */
+      if (message == NULL)
+        {
+          message = errorMessage (portLibrary, ptBuffers->platformErrorCode);
+        }
+
+      /* Avoid overwrite by internal portlib errors */
+      return swapMessageBuffer (ptBuffers, message);
+    }
+
+  /* Previous message stored ? */
+  if (ptBuffers->reportedMessageBufferSize > 0)
+    {
+      if ('\0' != ptBuffers->reportedMessageBuffer[0])
+        {
+          return ptBuffers->reportedMessageBuffer;
+        }
+    }
+
+  /* No error.  */
+  return "";
+}
+
+/**
+ * @brief Error Handling
+ *
+ * Look up the reason for the last stored failure.  If no error code has been
+ * stored then failure is returned.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @return The negative portable error code on success, 0 on failure.
+ *
+ * @note Does not clear the reason for the last failure.
+ */
+I_32 VMCALL
+hyerror_last_error_number (struct HyPortLibrary * portLibrary)
+{
+  PortlibPTBuffers_t ptBuffers;
+
+  /* get the buffers, return failure if not present */
+  ptBuffers = hyport_tls_peek (portLibrary);
+  if (NULL == ptBuffers)
+    {
+      return 0;
+    }
+
+  /* New error ? */
+  if (ptBuffers->portableErrorCode != 0)
+    {
+      return ptBuffers->portableErrorCode;
+    }
+  else
+    {
+      return ptBuffers->reportedErrorCode;
+    }
+}
+
+/**
+ * @brief Error Handling
+ *
+ * Save the platform specific error code and the portable error code for future reference.  Once stored an 
+ * application may obtain the error message describing the last stored error by calling hyerror_last_error_message.  
+ * Likewise the last portable error code can be obtained by calling hyerror_last_error_number. 
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] platformCode The error code reported by the OS
+ * @param[in] portableCode The corresponding portable error code as determined by the caller
+ *
+ * @return portable error code
+ *
+ * @note There is no way to access the last platform specific error code.
+ *
+ * @note If per thread buffers @see hyportptb.h are not available the error code is not stored.
+ * This event would only occur if the per thread buffers could not be allocated, which is highly unlikely.  In this 
+ * case an application will receive a generic message/errorCode when querying for the last stored values.
+ */
+I_32 VMCALL
+hyerror_set_last_error (struct HyPortLibrary * portLibrary, I_32 platformCode,
+                        I_32 portableCode)
+{
+  PortlibPTBuffers_t ptBuffers;
+
+  /* get the buffers, allocate if necessary.
+   * Silently return if not present, what else would the caller do anyway? 
+   */
+  ptBuffers = hyport_tls_get (portLibrary);
+  if (NULL == ptBuffers)
+    {
+      return portableCode;
+    }
+
+  /* Save the last error */
+  ptBuffers->platformErrorCode = platformCode;
+  ptBuffers->portableErrorCode = portableCode;
+
+  /* Overwrite any customized messages stored */
+  if (ptBuffers->errorMessageBufferSize > 0)
+    {
+      ptBuffers->errorMessageBuffer[0] = '\0';
+    }
+
+  return portableCode;
+}
+
+/**
+ * @brief Error Handling
+ *
+ * Save the platform specific error code and the portable error code for future reference.  Once stored an 
+ * application may obtain the error message describing the last stored error by calling hyerror_last_error_message.  
+ * Likewise the last portable error code can be obtained by calling hyerror_last_error_number. 
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] portableCode The corresponding portable error code as determined by the caller
+ * @param[in] errorMessage The customized error message to be stored
+ *
+ * @return portable error code
+ *
+ * @note There is no way to access the last platform specific error code.
+ *
+ * @note If per thread buffers @see hyportptb.h are not available the error code is not stored.
+ * This event would only occur if the per thread buffers could not be allocated, which is highly unlikely.  In this 
+ * case an application will receive a generic message/errorCode when querying for the last stored values.
+ */
+I_32 VMCALL
+hyerror_set_last_error_with_message (struct HyPortLibrary * portLibrary,
+                                     I_32 portableCode,
+                                     const char *errorMessage)
+{
+  PortlibPTBuffers_t ptBuffers;
+  U_32 requiredSize;
+
+  /* get the buffers, allocate if necessary.
+   * Silently return if not present, what else would the caller do anyway? 
+   */
+  ptBuffers = hyport_tls_get (portLibrary);
+  if (NULL == ptBuffers)
+    {
+      return portableCode;
+    }
+
+  /* Save the last error */
+  ptBuffers->platformErrorCode = -1;
+  ptBuffers->portableErrorCode = portableCode;
+
+  /* Store the message, allocate a bigger buffer if required.  Keep the old buffer around
+   * just in case memory can not be allocated
+   */
+  requiredSize = strlen (errorMessage) + 1;
+  requiredSize =
+    requiredSize <
+    HYERROR_DEFAULT_BUFFER_SIZE ? HYERROR_DEFAULT_BUFFER_SIZE : requiredSize;
+  if (requiredSize > ptBuffers->errorMessageBufferSize)
+    {
+      char *newBuffer =
+        portLibrary->mem_allocate_memory (portLibrary, requiredSize);
+      if (NULL != newBuffer)
+        {
+          if (ptBuffers->errorMessageBuffer != NULL)
+            {
+              portLibrary->mem_free_memory (portLibrary,
+                                            ptBuffers->errorMessageBuffer);
+            }
+          ptBuffers->errorMessageBuffer = newBuffer;
+          ptBuffers->errorMessageBufferSize = requiredSize;
+        }
+    }
+
+  /* Save the message */
+  if (ptBuffers->errorMessageBufferSize > 0)
+    {
+      portLibrary->str_printf (portLibrary, ptBuffers->errorMessageBuffer,
+                               ptBuffers->errorMessageBufferSize,
+                               errorMessage);
+      ptBuffers->errorMessageBuffer[ptBuffers->errorMessageBufferSize - 1] =
+        '\0';
+    }
+
+  return portableCode;
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyexit.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyexit.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyexit.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyexit.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,96 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/**
+ * @file
+ * @ingroup Port
+ * @brief Process shutdown.
+ */
+#include <stdlib.h>
+
+#include "hyport.h"
+
+extern void VMCALL hysig_chain_at_shutdown_and_exit (struct HyPortLibrary
+                                                     *portLibrary);
+
+/**
+ * Block until the portlibary has been exited and return the error code.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @return exit code.
+ * @note Most implementations will be empty.
+ */
+I_32 VMCALL
+hyexit_get_exit_code (struct HyPortLibrary *portLibrary)
+{
+  return 0;
+}
+
+/**
+ * Terminate a process.
+ *
+ * Perform any shutdown which is absolutely necessary before terminating the process,
+ * and terminate the process.  Unblock any callers to @ref hyexit_get_exit_code
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] exitCode The exit code to be used to terminate the process.
+ */
+void VMCALL
+hyexit_shutdown_and_exit (struct HyPortLibrary *portLibrary, I_32 exitCode)
+{
+
+#if !defined(WIN32)
+  hysig_chain_at_shutdown_and_exit (portLibrary);
+#endif
+
+
+  exit ((int) exitCode);
+}
+
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any resources that were created by @ref hyexit_startup
+ * should be destroyed here.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hyexit_shutdown (struct HyPortLibrary *portLibrary)
+{
+}
+
+/**
+ * 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 hyexit_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_EXIT
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hyexit_startup (struct HyPortLibrary *portLibrary)
+{
+  return 0;
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hygp.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hygp.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hygp.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hygp.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,158 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/**
+ * @ingroup Port
+ * @file
+ * Provides platform-neutral signal handling functions.  
+ * The @ref hygp_register_handler function is partially dependent on internal VM structures, and must be called with NULL as a third (userData) parameter.
+ * <br><br>
+ */
+
+#include "hyport.h"
+#include "hycomp.h"
+#include "gp.h"
+
+/**
+ * Kicks off the new thread by calling the function provided in protected_fn fn.
+ *
+ * All threads spawned by the vm start here and all OS signals that will be handled
+ * by fn must be registered to the OS here. 
+ * Upon receiving a signal from the OS, fn is responsible for calling the function 
+ * specified in @ref hygp_register_handler if it is determined that a shutdown is required.
+ * 
+ * @param[in] portLibrary The port library
+ * @param[in] fn the function that will be used to kick off the thread
+ * @param[in] arg arguments to protected_fn fn
+ *
+ * @return the return value of the function provided in fn
+ * 
+ * @note it is a good idea to save the portLibrary in case a registered exception handler 
+ * cannot be found
+ */
+UDATA VMCALL
+hygp_protect (struct HyPortLibrary * portLibrary, protected_fn fn, void *arg)
+{
+  /* sorry!  No way to protect it generically.  Just run it. */
+  return fn (arg);
+}
+
+/**
+ * Sets the function that is responsible for preserving/outputting the state of the vm and
+ * initiating a graceful shutdown resulting from a gp.
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] fn function responsible for preserving/outputting the state of the vm and 
+ * initiating a graceful shutdown resulting from a gp.
+ * @param[in] aUserData The HyJavaVM or NULL for non-HY consumers.
+ *
+ * @note vmGPHandler in gphandle.c is currently the only function used for handling gps. 
+ * @note  fn is not called by the OS but by the gp handler function specified in the call
+ * to @ref hygp_protect gp module
+ * @note above occurs after the OS has passed a signal along to us and it is determined 
+ * that a shutdown is required.
+ */
+void VMCALL
+hygp_register_handler (struct HyPortLibrary *portLibrary, handler_fn fn,
+                       void *aUserData)
+{
+}
+
+/**
+ * Provides the name and value, specified by category/index of the gp information in info. 
+ * Returns the kind of information found at category/index specified, or undefined 
+ * if the category/index are invalid.  The number of items in the category specified must 
+ * equal the count @ref hygp_info_count returns for that category. 
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] info struct containing all available signal information. Normally includes 
+ * register values, name of module where crash occured and its base address.
+ * @param[in] category the category of signal information that you are querying. 
+ * @param[in] index the index of the item in the specified category. The number of items 
+ * for each category are defined in the sourceTemplate.
+ * @param[out] name the name of the item at the specified index.  
+ * @param[out] value the value of the item at the specified index
+ *
+ * @return the kind of info at the specified index. For example, this allows the caller to 
+ * determine whether the item placed in **value corresponds to a 32/64-bit integer or a pointer to a string. 
+ *
+ * @note The program counter and module name also have negative indexes as defined by 
+ * HYGP_CONTROL_PC and HYGP_MODULE_NAME respectively.
+ * @note Above allows the handler function registered in @ref hygp_register_handler to 
+ * distinguish (and use) them from the other gp items.
+ * @note The caller is responsible for allocating and freeing any buffers used by **name, **value.
+ */
+U_32 VMCALL
+hygp_info (struct HyPortLibrary *portLibrary, void *info, U_32 category,
+           I_32 index, const char **name, void **value)
+{
+  /* default implementation can't do anything */
+  return 0;
+}
+
+/**
+ * Returns the number of items that exist in the category specified, or zero if the category is undefined.
+ *
+ * @param[in] portLibrary The port library
+ * @param[in] info struct containing all available signal information. Normally includes register values, 
+ * name of module where crash occured and its base address. 
+ * @param[in] category the category in which we want to find the number of items that exist.
+ *
+ * @note Return value must agree with the number of items that @ref hygp_info makes available for the 
+ * category specified. 
+*/
+U_32 VMCALL
+hygp_info_count (struct HyPortLibrary * portLibrary, void *info,
+                 U_32 category)
+{
+  /* default implementation can't do anything */
+  return 0;
+}
+
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  
+ * Any resources that were created by @ref hygp_startup
+ * should be destroyed here.
+ *
+ * @param[in] portLibrary The port library
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hygp_shutdown (struct HyPortLibrary *portLibrary)
+{
+}
+
+/**
+ * PortLibrary startup.
+ *
+ * This function is called during startup of the portLibrary.  Any resources that are required for
+ * the shared library operation may be created here.  All resources created here should be destroyed
+ * in @ref hygp_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_GP
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hygp_startup (struct HyPortLibrary *portLibrary)
+{
+  return 0;
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hygp.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hygp.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hygp.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hygp.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,29 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+#if !defined(hygp_h)
+#define hygp_h
+void VMCALL hygp_register_handler (struct HyPortLibrary *portLibrary,
+                                   handler_fn fn, void *aUserData);
+I_32 VMCALL hygp_startup (struct HyPortLibrary *portLibrary);
+void VMCALL hygp_shutdown (struct HyPortLibrary *portLibrary);
+UDATA VMCALL hygp_protect (struct HyPortLibrary *portLibrary, protected_fn fn,
+                           void *arg);
+U_32 VMCALL hygp_info_count (struct HyPortLibrary *portLibrary, void *info,
+                             U_32 category);
+U_32 VMCALL hygp_info (struct HyPortLibrary *portLibrary, void *info,
+                       U_32 category, I_32 index, const char **name,
+                       void **value);
+#endif /* hygp_h */

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hynlshelpers.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hynlshelpers.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hynlshelpers.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hynlshelpers.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,20 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+#if !defined(hynlshelpers_h)
+#define hynlshelpers_h
+void nls_determine_locale (struct HyPortLibrary *portLibrary);
+#endif /* hynlshelpers_h */
+

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyportcontrol.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyportcontrol.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyportcontrol.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hyportcontrol.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,71 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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 <string.h>
+#include "hyport.h"
+#include "portpriv.h"
+
+#define _UTE_STATIC_
+#include "ut_hyprt.h"
+
+I_32 VMCALL
+hyport_control (struct HyPortLibrary * portLibrary, char *key, UDATA value)
+{
+  /* return value of 0 is success */
+  if (!strcmp (HYPORT_CTLDATA_SIG_FLAGS, key))
+    {
+      portLibrary->portGlobals->control.sig_flags = value;
+      return 0;
+    }
+
+  if (!strcmp (HYPORT_CTLDATA_SHMEM_GROUP_PERM, key))
+    {
+      portLibrary->portGlobals->control.shmem_group_perm = value;
+      return 0;
+    }
+
+  if (!strcmp (HYPORT_CTLDATA_TRACE_START, key) && value)
+    {
+      UtInterface *utIntf = (UtInterface *) value;
+      utIntf->module->TraceInit (NULL, &UT_MODULE_INFO);
+      Trc_PRT_PortInitStages_Event1 ();
+      return 0;
+    }
+  if (!strcmp (HYPORT_CTLDATA_TRACE_STOP, key) && value)
+    {
+      UtInterface *utIntf = (UtInterface *) value;
+      utIntf->module->TraceTerm (NULL, &UT_MODULE_INFO);
+      return 0;
+    }
+
+#if defined(WIN32)
+  if (!strcmp ("SIG_INTERNAL_HANDLER", key))
+    {
+      /* used by optimized code to implement fast signal handling on Windows */
+      extern int structuredExceptionHandler (struct HyPortLibrary
+                                             *portLibrary,
+                                             hysig_handler_fn handler,
+                                             void *handler_arg, U_32 flags,
+                                             EXCEPTION_POINTERS *
+                                             exceptionInfo);
+      *(int (**)
+        (struct HyPortLibrary *, hysig_handler_fn, void *, U_32,
+         EXCEPTION_POINTERS *)) value = structuredExceptionHandler;
+      return 0;
+    }
+#endif
+
+  return 1;
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hystrftime.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hystrftime.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hystrftime.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hystrftime.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,364 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/**
+ * @file
+ * @ingroup Port
+ * @brief Time formatting utilities.
+ */
+
+#include <string.h>
+#include "hycomp.h"
+#include "hyport.h"
+
+typedef struct HyTimeInfo
+{
+  U_32 second;
+  U_32 minute;
+  U_32 hour;
+  U_32 day;
+  U_32 month;
+  U_32 year;
+} HyTimeInfo;
+
+static void gettimestruct (I_64 millis, struct HyTimeInfo *tm);
+
+/**
+ * Returns the current time in as a formatted string.  Formatted according to the 'format' parameter.
+ *
+ * @param[in] portLibrary  The port library.
+ * @param[in,out] buf A pointer to a character buffer where the resulting time string will be stored.
+ * @param[in] bufLen The length of the 'buf' character buffer.
+ * @param[in] format The format string, ordinary characters placed in the format string are copied.
+ * to buf without conversion.  Conversion specifiers are introduced by a '%' character, and are replaced in buf as follows:.
+ * <ul>
+ * <li>%b The abbreviated month name in english
+ * <li>%d The  day  of the month as a decimal number (range 0 to 31).
+ * <li>%H The hour as a decimal number using a 24-hour  clock (range 00 to 23).
+ * <li>%m The month as a decimal number (range 01 to 12).
+ * <li>%M The minute as a decimal number.
+ * <li>%S The second as a decimal number.
+ * <li>%Y The year as a decimal number including the century.
+ * <li>%% A literal '%' character.
+ * <li>all other '%' specifiers will be ignored
+ * </ul>
+ *
+ * @return The number of characters placed in the array buf, not including NULL terminator.
+ * If the value equals 'bufLen', it means that the array was too small.
+ */
+U_32 VMCALL
+hystrftime (struct HyPortLibrary *portLibrary, char *buf, U_32 bufLen,
+            const char *format)
+{
+  I_64 millis;
+  U_32 index = 0;
+  HyTimeInfo tm;
+  static const char abbMonthName[12][4] =
+    { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT",
+    "NOV", "DEC"
+  };
+
+  if (buf == NULL || bufLen < 1)
+    {
+      return 0;
+    }
+
+  millis = portLibrary->time_current_time_millis (portLibrary);
+
+  gettimestruct (millis, &tm);
+
+  /* format the date/time information according to the format string */
+  while (*format && index < bufLen - 1)
+    {
+      switch (*format)
+        {
+        case '%':
+          format++;
+          switch (*format)
+            {
+            case '\0':
+              /* end of the format string */
+              break;
+            case '%':
+              /* literal '%' */
+              buf[index] = '%';
+              index++;
+              format++;
+              break;
+            case 'Y':
+              if (index + 4 >= bufLen - 1)
+                {
+                  return bufLen;
+                }
+              index +=
+                portLibrary->str_printf (portLibrary, buf + index,
+                                         bufLen - index, "%04u", tm.year);
+              format++;
+              break;
+            case 'm':
+              if (index + 2 >= bufLen - 1)
+                {
+                  return bufLen;
+                }
+              index +=
+                portLibrary->str_printf (portLibrary, buf + index,
+                                         bufLen - index, "%02u", tm.month);
+              format++;
+              break;
+            case 'b':
+              if (index + strlen (abbMonthName[tm.month - 1]) >= bufLen - 1)
+                {
+                  return bufLen;
+                }
+              index +=
+                portLibrary->str_printf (portLibrary, buf + index,
+                                         bufLen - index, "%s",
+                                         abbMonthName[tm.month - 1]);
+              format++;
+              break;
+            case 'd':
+              if (index + 2 >= bufLen - 1)
+                {
+                  return bufLen;
+                }
+              index +=
+                portLibrary->str_printf (portLibrary, buf + index,
+                                         bufLen - index, "%02u", tm.day);
+              format++;
+              break;
+            case 'H':
+              if (index + 2 >= bufLen - 1)
+                {
+                  return bufLen;
+                }
+              index +=
+                portLibrary->str_printf (portLibrary, buf + index,
+                                         bufLen - index, "%02u", tm.hour);
+              format++;
+              break;
+            case 'M':
+              if (index + 2 >= bufLen - 1)
+                {
+                  return bufLen;
+                }
+              index +=
+                portLibrary->str_printf (portLibrary, buf + index,
+                                         bufLen - index, "%02u", tm.minute);
+              format++;
+              break;
+            case 'S':
+              if (index + 2 >= bufLen - 1)
+                {
+                  return bufLen;
+                }
+              index +=
+                portLibrary->str_printf (portLibrary, buf + index,
+                                         bufLen - index, "%02u", tm.second);
+              format++;
+              break;
+            default:
+              /* ignore unsupported format specifiers */
+              format++;
+              break;
+            }
+          break;
+        default:
+          buf[index] = *format++;
+          index++;
+          break;
+        }
+    }
+
+  buf[index] = 0;
+
+  return index;
+}
+
+static void
+gettimestruct (I_64 millis, struct HyTimeInfo *tm)
+{
+#define HYSFT_NUM_MONTHS         (12)
+#define HYSFT_NUM_SECS_IN_MINUTE (60)
+#define HYSFT_NUM_SECS_IN_HOUR   (60*HYSFT_NUM_SECS_IN_MINUTE)
+#define HYSFT_NUM_SECS_IN_DAY    (24*(I_32)HYSFT_NUM_SECS_IN_HOUR)
+#define HYSFT_NUM_SECS_IN_YEAR   (365*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_LEAP_YEAR (366*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_JAN (31*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_FEB (28*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_MAR (31*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_APR (30*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_MAY (31*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_JUN (30*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_JUL (31*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_AUG (31*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_SEP (30*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_OCT (31*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_NOV (30*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_DEC (31*HYSFT_NUM_SECS_IN_DAY)
+#define HYSFT_NUM_SECS_IN_LEAP_FEB (29*HYSFT_NUM_SECS_IN_DAY)
+
+  I_64 timeLeft;
+  I_32 i;
+  I_32 *secondsInMonth;
+  I_32 normalSecondsInMonth[12] = {
+    HYSFT_NUM_SECS_IN_JAN,
+    HYSFT_NUM_SECS_IN_FEB,
+    HYSFT_NUM_SECS_IN_MAR,
+    HYSFT_NUM_SECS_IN_APR,
+    HYSFT_NUM_SECS_IN_MAY,
+    HYSFT_NUM_SECS_IN_JUN,
+    HYSFT_NUM_SECS_IN_JUL,
+    HYSFT_NUM_SECS_IN_AUG,
+    HYSFT_NUM_SECS_IN_SEP,
+    HYSFT_NUM_SECS_IN_OCT,
+    HYSFT_NUM_SECS_IN_NOV,
+    HYSFT_NUM_SECS_IN_DEC
+  };
+  I_32 leapYearSecondsInMonth[12] = {
+    HYSFT_NUM_SECS_IN_JAN,
+    HYSFT_NUM_SECS_IN_LEAP_FEB,
+    HYSFT_NUM_SECS_IN_MAR,
+    HYSFT_NUM_SECS_IN_APR,
+    HYSFT_NUM_SECS_IN_MAY,
+    HYSFT_NUM_SECS_IN_JUN,
+    HYSFT_NUM_SECS_IN_JUL,
+    HYSFT_NUM_SECS_IN_AUG,
+    HYSFT_NUM_SECS_IN_SEP,
+    HYSFT_NUM_SECS_IN_OCT,
+    HYSFT_NUM_SECS_IN_NOV,
+    HYSFT_NUM_SECS_IN_DEC
+  };
+  BOOLEAN leapYear = FALSE;
+
+  if (!tm)
+    return;
+
+  memset (tm, 0, sizeof (struct HyTimeInfo));
+
+  tm->year = 1970;
+
+  /* -- obtain the current time in seconds */
+  timeLeft = millis / 1000;
+  /* -- determine the year */
+  while (timeLeft)
+    {
+      I_64 numSecondsInAYear = HYSFT_NUM_SECS_IN_YEAR;
+      leapYear = FALSE;
+      if (tm->year % 4 == 0)
+        {
+          /* potential leap year */
+          if ((tm->year % 100 != 0) || (tm->year % 400 == 0))
+            {
+              /* we have leap year! */
+              leapYear = TRUE;
+              numSecondsInAYear = HYSFT_NUM_SECS_IN_LEAP_YEAR;
+            }
+        }
+      if (timeLeft < numSecondsInAYear)
+        {
+          /* under a year's time left */
+          break;
+        }
+      /* increment the year and take the appropriate number 
+         of seconds off the timeLeft */
+      tm->year++;
+      timeLeft -= numSecondsInAYear;
+    }
+  /* -- determine the month */
+  if (leapYear)
+    {
+      secondsInMonth = leapYearSecondsInMonth;
+    }
+  else
+    {
+      secondsInMonth = normalSecondsInMonth;
+    }
+  for (i = 0; i < HYSFT_NUM_MONTHS; i++)
+    {
+      if (timeLeft >= secondsInMonth[i])
+        {
+          timeLeft -= secondsInMonth[i];
+        }
+      else
+        {
+          break;
+        }
+    }
+  tm->month = i + 1;
+  /* -- determine the day of the month */
+  tm->day = 1;
+  while (timeLeft)
+    {
+      if (timeLeft >= HYSFT_NUM_SECS_IN_DAY)
+        {
+          timeLeft -= HYSFT_NUM_SECS_IN_DAY;
+        }
+      else
+        {
+          break;
+        }
+      tm->day++;
+    }
+  /* -- determine the hour of the day */
+  tm->hour = 0;
+  while (timeLeft)
+    {
+      if (timeLeft >= HYSFT_NUM_SECS_IN_HOUR)
+        {
+          timeLeft -= HYSFT_NUM_SECS_IN_HOUR;
+        }
+      else
+        {
+          break;
+        }
+      tm->hour++;
+    }
+  /* -- determine the minute of the hour */
+  tm->minute = 0;
+  while (timeLeft)
+    {
+      if (timeLeft >= HYSFT_NUM_SECS_IN_MINUTE)
+        {
+          timeLeft -= HYSFT_NUM_SECS_IN_MINUTE;
+        }
+      else
+        {
+          break;
+        }
+      tm->minute++;
+    }
+  /* -- and the rest is seconds */
+  tm->second = (U_32) timeLeft;
+
+#undef HYSFT_NUM_MONTHS
+#undef HYSFT_NUM_SECS_IN_MINUTE
+#undef HYSFT_NUM_SECS_IN_HOUR
+#undef HYSFT_NUM_SECS_IN_DAY
+#undef HYSFT_NUM_SECS_IN_YEAR
+#undef HYSFT_NUM_SECS_IN_LEAP_YEAR
+#undef HYSFT_NUM_SECS_IN_JAN
+#undef HYSFT_NUM_SECS_IN_FEB
+#undef HYSFT_NUM_SECS_IN_MAR
+#undef HYSFT_NUM_SECS_IN_APR
+#undef HYSFT_NUM_SECS_IN_MAY
+#undef HYSFT_NUM_SECS_IN_JUN
+#undef HYSFT_NUM_SECS_IN_JUL
+#undef HYSFT_NUM_SECS_IN_AUG
+#undef HYSFT_NUM_SECS_IN_SEP
+#undef HYSFT_NUM_SECS_IN_OCT
+#undef HYSFT_NUM_SECS_IN_NOV
+#undef HYSFT_NUM_SECS_IN_DEC
+#undef HYSFT_NUM_SECS_IN_LEAP_FEB
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hystsl.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hystsl.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hystsl.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hystsl.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,238 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/**
+ * @file
+ * @ingroup Port
+ * @brief Static shared library
+ */
+#include <string.h>
+#include <stdlib.h>
+#include "hyport.h"
+
+#if defined(HYVM_STATIC_LINKAGE)
+#include "hystatic.h"
+extern HyPrimitiveTable HyLinkedNatives;
+void *
+upLookupName (char *name, HyPrimitiveTableSlot * table)
+{
+  void *result;
+  while (!((table->name == (char *) 0) && (table->funcOrTable == (void *) 0)))
+    {
+      if (table->name == (char *) 0)
+        {
+          result =
+            upLookupName (name,
+                          (HyPrimitiveTableSlot *) (table->funcOrTable));
+          if (result != (void *) 0 /*HyDefaultFailPrimitive */ )
+            return result;
+        }
+      else
+        {
+          if (strcmp (name, table->name) == 0)
+            return table->funcOrTable;
+        }
+      table++;
+    }
+  return (void *) 0 /*HyDefaultFailPrimitive */ ;
+}
+
+/**
+ * Close a static library.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] descriptor Static library handle to close.
+ *
+ * @return 0 on success, any other value on failure.
+ */
+UDATA VMCALL
+hysl_up_close_shared_library (struct HyPortLibrary *portLibrary,
+                              UDATA descriptor)
+{
+  return 0;
+}
+
+/** 
+ * Opens a static library .
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] name path Null-terminated string containing the static library.
+ * @param[out] descriptor Pointer to memory which is filled in with static-library handle on success.
+ * @param[in] decorate Boolean value indicates whether name should be decorated if it contains path information and cannot be found.
+ *
+ * @return 0 on success, any other value on failure.
+ *
+ * @note contents of descriptor are undefined on failure.
+ */
+UDATA VMCALL
+hysl_up_open_shared_library (struct HyPortLibrary * portLibrary, char *name,
+                             UDATA * descriptor, BOOLEAN decorate)
+{
+  void *result;
+  if (result = upLookupName (name, &HyLinkedNatives[0]))
+    {
+      *descriptor = (UDATA) result;
+      return 0;
+    }
+  else
+    {
+      return portLibrary->error_set_last_error_with_message (portLibrary,
+                                                             HYPORT_SL_NOT_FOUND,
+                                                             "Not statically linked");
+    }
+}
+
+/**
+ * Search for a function named 'name' taking argCount in the static library 'descriptor'.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] descriptor Static library to search.
+ * @param[in] name Function to look up.
+ * @param[out] func Pointer to the function.
+ * @param[in] argSignature Argument signature.
+ *
+ * @return 0 on success, any other value on failure.
+ *
+ * @note contents of func are undefined on failure.
+ */
+UDATA VMCALL
+hysl_up_lookup_name (struct HyPortLibrary * portLibrary, UDATA descriptor,
+                     char *name, UDATA * func, const char *argSignature)
+{
+  void *result;
+  if (result = upLookupName (name, (HyPrimitiveTableSlot *) descriptor))
+    {
+      *func = (UDATA) result;
+      return 0;
+    }
+  else
+    {
+      return 1;
+    }
+}
+typedef struct
+{
+  UDATA descriptor;
+  UDATA tag;
+} hysplit_sl_handle;
+#define HYFLAG_SL_LINKED 0
+#define HYFLAG_SL_LOADED 1
+/* support BOTH types of libraries */
+/** 
+ * Opens a static/shared library .
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] name path Null-terminated string containing the library.
+ * @param[out] descriptor Pointer to memory which is filled in with library handle on success.
+ * @param[in] decorate Boolean value indicates whether name should be decorated if it contains path information and cannot be found.
+ *
+ * @return 0 on success, any other value on failure.
+ *
+ * @note contents of descriptor are undefined on failure.
+ */
+UDATA VMCALL
+hysl_split_open_shared_library (struct HyPortLibrary *portLibrary, char *name,
+                                UDATA * descriptor, BOOLEAN decorate)
+{
+  UDATA result;
+  UDATA tag;
+  tag = HYFLAG_SL_LINKED;
+  result =
+    hysl_up_open_shared_library (portLibrary, name, descriptor, decorate);
+  if (result == HYPORT_SL_NOT_FOUND)
+    {
+      result =
+        hysl_open_shared_library (portLibrary, name, descriptor, decorate);
+      tag = HYFLAG_SL_LOADED;
+    }
+  if (result == 0)
+    {
+      hysplit_sl_handle *handle;
+      handle =
+        portLibrary->mem_allocate_memory (portLibrary,
+                                          sizeof (hysplit_sl_handle));
+      if (handle == NULL)
+        {
+          if (tag == HYFLAG_SL_LOADED)
+            {
+              hysl_close_shared_library (portLibrary, *descriptor);
+            }
+          return portLibrary->error_set_last_error_with_message (portLibrary,
+                                                                 HYPORT_SL_INVALID,
+                                                                 "Out of memory");
+        }
+      handle->descriptor = *descriptor;
+      handle->tag = tag;
+      *descriptor = (UDATA) handle;
+    }
+  return result;
+}
+
+/**
+ * Close a static or shared library.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] descriptor Library handle to close.
+ *
+ * @return 0 on success, any other value on failure.
+ */
+UDATA VMCALL
+hysl_split_close_shared_library (struct HyPortLibrary * portLibrary,
+                                 UDATA descriptor)
+{
+  hysplit_sl_handle *handle = (hysplit_sl_handle *) descriptor;
+  UDATA result;
+  if (handle->tag == HYFLAG_SL_LOADED)
+    {
+      result = hysl_close_shared_library (portLibrary, handle->descriptor);
+    }
+  else
+    {
+      result = hysl_up_close_shared_library (portLibrary, handle->descriptor);
+    }
+  portLibrary->mem_free_memory (portLibrary, handle);
+  return result;
+}
+
+/**
+ * Search for a function named 'name' taking argCount in the static/shared library 'descriptor'.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] descriptor Library to search.
+ * @param[in] name Function to look up.
+ * @param[out] func Pointer to the function.
+ * @param[in] argSignature Argument signature.
+ *
+ * @return 0 on success, any other value on failure.
+ *
+ * @note contents of func are undefined on failure.
+ */
+UDATA VMCALL
+hysl_split_lookup_name (struct HyPortLibrary * portLibrary, UDATA descriptor,
+                        char *name, UDATA * func, const char *argSignature)
+{
+  hysplit_sl_handle *handle = (hysplit_sl_handle *) descriptor;
+  if (handle->tag == HYFLAG_SL_LOADED)
+    {
+      return hysl_lookup_name (portLibrary, handle->descriptor, name, func,
+                               argSignature);
+    }
+  else
+    {
+      return hysl_up_lookup_name (portLibrary, handle->descriptor, name, func,
+                                  argSignature);
+    }
+}
+#endif

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hytlshelpers.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hytlshelpers.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hytlshelpers.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/hytlshelpers.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,210 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/**
+ * @file
+ * @ingroup Port
+ * @brief Per Thread Buffer Support
+ *
+ * Per thread buffers are used to store information that is not sharable among the threads.  
+ * For example when an OS system call fails the error code associated with that error is
+ * relevant to the thread that called the OS function; it has no meaning to any other thread.
+ *
+ * This file contains the functions supported by the port library for creating, accessing and
+ * destroying per thread buffers.@see hyportptb.h for details on the per thread buffer structure.
+ *
+ * Only the function @hyport_tls_free is available via the port library function table.  The rest of
+ * the functions are helpers for the port library only.
+ */
+#include <string.h>
+#include "hyport.h"
+#include "portpriv.h"
+#include "hythread.h"
+#include "hyportptb.h"
+
+/**
+ * @internal
+ * @brief Per Thread Buffer Support
+ *
+ * Get a per thread buffer.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @return The per thread buffer on success, NULL on failure.
+ */
+void *VMCALL
+hyport_tls_get (struct HyPortLibrary *portLibrary)
+{
+  PortlibPTBuffers_t ptBuffers;
+
+  ptBuffers =
+    hythread_tls_get (hythread_self (), portLibrary->portGlobals->tls_key);
+  if (NULL == ptBuffers)
+    {
+      MUTEX_ENTER (portLibrary->portGlobals->tls_mutex);
+
+      ptBuffers =
+        portLibrary->mem_allocate_memory (portLibrary,
+                                          sizeof (PortlibPTBuffers_struct));
+      if (NULL != ptBuffers)
+        {
+          if (0 ==
+              hythread_tls_set (hythread_self (),
+                                portLibrary->portGlobals->tls_key, ptBuffers))
+            {
+              memset (ptBuffers, 0, sizeof (PortlibPTBuffers_struct));
+              ptBuffers->next = portLibrary->portGlobals->buffer_list;
+              if (portLibrary->portGlobals->buffer_list)
+                {
+                  ((PortlibPTBuffers_t) portLibrary->portGlobals->
+                   buffer_list)->previous = ptBuffers;
+                }
+              portLibrary->portGlobals->buffer_list = ptBuffers;
+            }
+          else
+            {
+              portLibrary->mem_free_memory (portLibrary, ptBuffers);
+              ptBuffers = NULL;
+            }
+        }
+
+      MUTEX_EXIT (portLibrary->portGlobals->tls_mutex);
+    }
+  return ptBuffers;
+}
+
+/**
+ * @brief Per Thread Buffer Support
+ * 
+ * Free the per thread buffers.
+ *
+ * @param[in] portLibrary The port library.
+ */
+void VMCALL
+hyport_tls_free (struct HyPortLibrary *portLibrary)
+{
+  PortlibPTBuffers_t ptBuffers;
+
+  MUTEX_ENTER (portLibrary->portGlobals->tls_mutex);
+  ptBuffers =
+    hythread_tls_get (hythread_self (), portLibrary->portGlobals->tls_key);
+  if (ptBuffers)
+    {
+      hythread_tls_set (hythread_self (), portLibrary->portGlobals->tls_key,
+                        NULL);
+
+      /* Unlink */
+      if (ptBuffers->next)
+        {
+          ptBuffers->next->previous = ptBuffers->previous;
+        }
+      if (portLibrary->portGlobals->buffer_list == ptBuffers)
+        {
+          portLibrary->portGlobals->buffer_list = ptBuffers->next;
+        }
+      else
+        {
+          if (ptBuffers->previous)
+            {
+              ptBuffers->previous->next = ptBuffers->next;
+            }
+        }
+
+      hyport_free_ptBuffer (portLibrary, ptBuffers);
+    }
+  MUTEX_EXIT (portLibrary->portGlobals->tls_mutex);
+}
+
+/**
+ * @internal
+ * @brief PortLibrary startup.
+ * 
+ * This function is called during startup of the portLibrary.  Any resources that are required for
+ * the portl library thread local storage operations may be created here.  All resources created here should be destroyed
+ * in @ref hyport_tls_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_TLS
+ * \arg HYPORT_ERROR_STARTUP_TLS_ALLOC
+ * \arg HYPORT_ERROR_STARTUP_TLS_MUTEX
+ */
+I_32 VMCALL
+hyport_tls_startup (struct HyPortLibrary *portLibrary)
+{
+  if (hythread_tls_alloc (&portLibrary->portGlobals->tls_key))
+    {
+      return HYPORT_ERROR_STARTUP_TLS_ALLOC;
+    }
+
+  if (!MUTEX_INIT (portLibrary->portGlobals->tls_mutex))
+    {
+      return HYPORT_ERROR_STARTUP_TLS_MUTEX;
+    }
+
+  return 0;
+}
+
+/**
+ * @internal
+ * @brief PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any resources that were created by 
+ * @ref hyport_tls_startup should be destroyed here.
+ *
+ * @param[in] HyPortLibrary The port library
+ */
+void VMCALL
+hyport_tls_shutdown (struct HyPortLibrary *portLibrary)
+{
+  PortlibPTBuffers_t ptBuffers, next;
+
+  /* Free all remaining buffer sets */
+  MUTEX_ENTER (portLibrary->portGlobals->tls_mutex);
+  ptBuffers = portLibrary->portGlobals->buffer_list;
+  while (NULL != ptBuffers)
+    {
+      next = ptBuffers->next;
+      hyport_free_ptBuffer (portLibrary, ptBuffers);
+      ptBuffers = next;
+    }
+  portLibrary->portGlobals->buffer_list = NULL;
+  MUTEX_EXIT (portLibrary->portGlobals->tls_mutex);
+
+  /* Now dispose of the tls_key and the mutex */
+  hythread_tls_free (portLibrary->portGlobals->tls_key);
+  MUTEX_DESTROY (portLibrary->portGlobals->tls_mutex);
+}
+
+/**
+ * @internal
+ * @brief Per Thread Buffer Support
+ * 
+ * Get the per thread buffer for a thread. If the buffer has not been allocated do not allocate a new
+ * one, the function @ref hyport_tls_get is used for that purpose. This function is not exported outside 
+ * the port library as most applications will want a per thread buffer created to store their data.  This 
+ * function is used to access existing data in the per thread buffers.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @return The per thread buffer, may be NULL.
+ */
+void *VMCALL
+hyport_tls_peek (struct HyPortLibrary *portLibrary)
+{
+  return hythread_tls_get (hythread_self (),
+                           portLibrary->portGlobals->tls_key);
+}

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/port_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/port_copyright.c?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/port_copyright.c (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/port_copyright.c Wed Mar  1 07:42:53 2006
@@ -0,0 +1,19 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+/* A copyright string included in each DLL and executable */
+
+const char hyCopyright[] =
+  "(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable.";

Added: incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/portnls.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/portnls.h?rev=382065&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/portnls.h (added)
+++ incubator/harmony/enhanced/classlib/trunk/native-src/shared/port/portnls.h Wed Mar  1 07:42:53 2006
@@ -0,0 +1,43 @@
+/* Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+#if !defined(portnls_h)
+#define portnls_h
+#include "hyport.h"
+/* 0x504f5254 = PORT */
+#define HYNLS_PORT_NLS_FAILURE__PREFIX "PORT000"
+
+#define HYNLS_PORT_FILE_MEMORY_ALLOCATE_FAILURE__MODULE 0x504f5254
+#define HYNLS_PORT_FILE_MEMORY_ALLOCATE_FAILURE__ID 1
+#define HYNLS_PORT_FILE_MEMORY_ALLOCATE_FAILURE HYNLS_PORT_FILE_MEMORY_ALLOCATE_FAILURE__MODULE, HYNLS_PORT_FILE_MEMORY_ALLOCATE_FAILURE__ID
+
+#define HYNLS_PORT_SL_UNKOWN_ERROR__MODULE 0x504f5254
+#define HYNLS_PORT_SL_UNKOWN_ERROR__ID 2
+#define HYNLS_PORT_SL_UNKOWN_ERROR HYNLS_PORT_SL_UNKOWN_ERROR__MODULE, HYNLS_PORT_SL_UNKOWN_ERROR__ID
+
+#define HYNLS_PORT_ERROR_OPERATION_FAILED__MODULE 0x504f5254
+#define HYNLS_PORT_ERROR_OPERATION_FAILED__ID 17
+#define HYNLS_PORT_ERROR_OPERATION_FAILED HYNLS_PORT_ERROR_OPERATION_FAILED__MODULE, HYNLS_PORT_ERROR_OPERATION_FAILED__ID
+
+#define HYNLS_PORT_SL_UNABLE_TO_RESOLVE_REFERENCES__MODULE 0x504f5254
+#define HYNLS_PORT_SL_UNABLE_TO_RESOLVE_REFERENCES__ID 15
+#define HYNLS_PORT_SL_UNABLE_TO_RESOLVE_REFERENCES HYNLS_PORT_SL_UNABLE_TO_RESOLVE_REFERENCES__MODULE, HYNLS_PORT_SL_UNABLE_TO_RESOLVE_REFERENCES__ID
+
+#define HYNLS_PORT_SL_INTERNAL_ERROR__MODULE 0x504f5254
+#define HYNLS_PORT_SL_INTERNAL_ERROR__ID 16
+#define HYNLS_PORT_SL_INTERNAL_ERROR HYNLS_PORT_SL_INTERNAL_ERROR__MODULE, HYNLS_PORT_SL_INTERNAL_ERROR__ID
+
+#endif
+



Mime
View raw message