harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r350181 [191/198] - in /incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core: ./ depends/ depends/files/ depends/jars/ depends/libs/ depends/libs/linux.IA32/ depends/libs/win.IA32/ depends/oss/ depends/oss/linux.IA32/ depends/oss/win....
Date Thu, 01 Dec 2005 06:04:00 GMT
Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/hytty.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/hytty.c?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/hytty.c
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/hytty.c
Wed Nov 30 21:29:27 2005
@@ -0,0 +1,286 @@
+/* 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.
+ */
+
+#define CDEV_CURRENT_FUNCTION _comment_
+/**
+  * @file
+  * @ingroup Port
+  * @brief TTY output
+  *
+  * All VM output goes to stderr by default.  These routines provide the helpers for such
output.
+  */
+#undef CDEV_CURRENT_FUNCTION
+
+#include <windows.h>
+#include <stdio.h>
+#include "hyport.h"
+#include "portpriv.h"
+#include "hyportpg.h"
+
+/* private-prototypes */
+#define CDEV_CURRENT_FUNCTION _prototypes_private
+/* none */
+#undef CDEV_CURRENT_FUNCTION
+
+#if defined(TTY_LOG_FILE)
+I_32 fd;
+#endif
+
+#define CDEV_CURRENT_FUNCTION hytty_char_ready
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_flush
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_gets
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_startup
+/**
+ * PortLibrary startup.
+ *
+ * This function is called during startup of the portLibrary.  Any resources that are required
for
+ * the TTY library operations may be created here.  All resources created here should be
destroyed
+ * in @ref hytty_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_TTY
+ * \arg HYPORT_ERROR_STARTUP_TTY_HANDLE
+ * \arg HYPORT_ERROR_STARTUP_TTY_CONSOLE
+ *
+ * @note Most implementations will simply return success.
+ */
+I_32 VMCALL
+hytty_startup (struct HyPortLibrary * portLibrary)
+{
+  HANDLE handle, dupHandle;
+  HANDLE proc = GetCurrentProcess ();
+
+  handle = GetStdHandle (STD_INPUT_HANDLE);
+  DuplicateHandle (proc, handle, proc, &dupHandle, 0, 0,
+		   DUPLICATE_SAME_ACCESS);
+  PPG_tty_consoleInputHd = dupHandle;
+
+#if defined(TTY_LOG_FILE)
+  fd =
+    portLibrary->file_open (portLibrary, TTY_LOG_FILE,
+			    HyOpenCreate | HyOpenWrite, 0);
+#define MSG "========== BEGIN ==========\n\n"
+  portLibrary->file_write (portLibrary, fd, MSG, sizeof (MSG) - 1);
+#undef MSG
+#else
+  handle = GetStdHandle (STD_OUTPUT_HANDLE);
+  DuplicateHandle (proc, handle, proc, &dupHandle, 0, 0,
+		   DUPLICATE_SAME_ACCESS);
+  PPG_tty_consoleOutputHd = dupHandle;
+  handle = GetStdHandle (STD_ERROR_HANDLE);
+  DuplicateHandle (proc, handle, proc, &dupHandle, 0, 0,
+		   DUPLICATE_SAME_ACCESS);
+  PPG_tty_consoleErrorHd = dupHandle;
+#endif
+
+  return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_shutdown
+/**
+ * PortLibrary shutdown.
+ *
+ * This function is called during shutdown of the portLibrary.  Any resources that were created
by @ref hytty_startup
+ * should be destroyed here.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @note Most implementations will be empty.
+ */
+void VMCALL
+hytty_shutdown (struct HyPortLibrary *portLibrary)
+{
+  CloseHandle (PPG_tty_consoleInputHd);
+#if defined(TTY_LOG_FILE)
+#define MSG "\n========== END ==========\n\n"
+  portLibrary->file_write (portLibrary, fd, MSG, sizeof (MSG) - 1);
+#undef MSG
+  portLibrary->file_close (portLibrary, fd);
+#else
+  CloseHandle (PPG_tty_consoleOutputHd);
+  CloseHandle (PPG_tty_consoleErrorHd);
+#endif
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_read_char
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_output_string
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_output_char
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_printf
+/** 
+ * Write characters to stderr.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] format The format string to be output.
+ * @param[in] ... arguments for format.
+ *
+ * @note Use hyfile_printf for stdout output.
+ */
+void VMCALL
+hytty_printf (struct HyPortLibrary *portLibrary, const char *format, ...)
+{
+  va_list args;
+
+  va_start (args, format);
+  portLibrary->tty_vprintf (portLibrary, format, args);
+  va_end (args);
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_get_chars
+/** 
+ * Read characters from stdin into buffer.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[out] s Buffer.
+ * @param[in] length Size of buffer (s).
+ *
+ * @return The number of characters read, -1 on error.
+ */
+IDATA VMCALL
+hytty_get_chars (struct HyPortLibrary *portLibrary, char *s, UDATA length)
+{
+  DWORD nCharsRead;
+  DWORD result;
+
+  result = ReadFile (PPG_tty_consoleInputHd, s, length, &nCharsRead, NULL);
+
+  /*only return -1 on error, return zero for EOF */
+  if (!result)
+    {
+      /*return EOF for broken pipe */
+      if (GetLastError () == ERROR_BROKEN_PIPE)
+	return 0;
+      return -1;
+    }
+  return nCharsRead;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_err_printf
+/**
+ * Output message to stderr.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] format The format String.
+ * @param[in] ... argument list.
+ *
+ * @deprecated All output goes to stderr, use hytty_printf()
+ */
+void VMCALL
+hytty_err_printf (struct HyPortLibrary *portLibrary, const char *format, ...)
+{
+  va_list args;
+
+  va_start (args, format);
+  portLibrary->tty_err_vprintf (portLibrary, format, args);
+  va_end (args);
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_available
+/**
+ * Determine the number of characters remaining to be read from stdin.
+ *
+ * @param[in] portLibrary The port library.
+ *
+ * @return number of characters remaining to be read.
+ */
+IDATA VMCALL
+hytty_available (struct HyPortLibrary *portLibrary)
+{
+  DWORD result, current, end;
+  /* First try stdin as a pipe */
+  if (PeekNamedPipe (PPG_tty_consoleInputHd, NULL, 0, NULL, &result, NULL))
+    {
+      return result;
+    }
+  else
+    {
+      /* See if stdin is a file */
+      current =
+	SetFilePointer (PPG_tty_consoleInputHd, 0, NULL, FILE_CURRENT);
+      if (current != 0xFFFFFFFF)
+	{
+	  end = SetFilePointer (PPG_tty_consoleInputHd, 0, NULL, FILE_END);
+	  SetFilePointer (PPG_tty_consoleInputHd, current, NULL, FILE_BEGIN);
+	  if (end != 0xFFFFFFFF)
+	    {
+	      return end - current;
+	    }
+	}
+    }
+  return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_vprintf
+/**
+ * Output message to stderr.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] format The format String.
+ * @param[in] args Variable argument list.
+ *
+ * @note Use hyfile_vprintf for stdout output.
+ */
+void VMCALL
+hytty_vprintf (struct HyPortLibrary *portLibrary, const char *format,
+	       va_list args)
+{
+  portLibrary->file_vprintf (portLibrary, HYPORT_TTY_ERR, format, args);
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION hytty_err_vprintf
+/**
+ * Output message to stderr.
+ *
+ * @param[in] portLibrary The port library.
+ * @param[in] format The format String.
+ * @param[in] args Variable argument list.
+ *
+ * @deprecated All output goes to stderr, use hytty_vprintf()
+ */
+void VMCALL
+hytty_err_vprintf (struct HyPortLibrary *portLibrary, const char *format,
+		   va_list args)
+{
+  portLibrary->file_vprintf (portLibrary, HYPORT_TTY_ERR, format, args);
+}
+
+#undef CDEV_CURRENT_FUNCTION

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/hyvmem.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/hyvmem.c?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/hyvmem.c
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/hyvmem.c
Wed Nov 30 21:29:27 2005
@@ -0,0 +1,480 @@
+/* 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.
+ */
+
+#define CDEV_CURRENT_FUNCTION _comment_
+/**
+ * @file
+ * @ingroup Port
+ * @brief Virtual memory
+ */
+#undef CDEV_CURRENT_FUNCTION
+
+#include <windows.h>
+
+#include "hyport.h"
+#include "portpriv.h"
+#include "hyportpg.h"
+#include "ut_hyprt.h"
+
+#define CDEV_CURRENT_FUNCTION _prototypes_private
+
+BOOL SetLockPagesPrivilege (HANDLE hProcess, BOOL bEnable);
+
+DWORD getProtectionBits (UDATA mode);
+void VMCALL update_vmemIdentifier (HyPortVmemIdentifier * identifier,
+				   void *address, void *handle,
+				   UDATA byteAmount, UDATA mode,
+				   UDATA pageSize);
+
+#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)
+{
+  void *ptr = NULL;
+
+  Trc_PRT_vmem_hyvmem_commit_memory_Entry (address, byteAmount);
+  if (PPG_vmem_pageSize[0] == identifier->pageSize)
+    {
+      ptr =
+	(void *) VirtualAlloc ((LPVOID) address, (size_t) byteAmount,
+			       MEM_COMMIT,
+			       getProtectionBits (identifier->mode));
+    }
+  else
+    {
+      ptr = address;
+    }
+  Trc_PRT_vmem_hyvmem_commit_memory_Exit (ptr);
+  return ptr;
+}
+
+#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)
+{
+  IDATA ret = 0;
+
+  Trc_PRT_vmem_hyvmem_decommit_memory_Entry (address, byteAmount);
+  if (PPG_vmem_pageSize[0] == identifier->pageSize)
+    {
+      ret =
+	(IDATA) VirtualFree ((LPVOID) address, (size_t) byteAmount,
+			     MEM_DECOMMIT);
+    }
+  else
+    {
+      ret = 0;
+    }
+  Trc_PRT_vmem_hyvmem_decommit_memory_Exit (ret);
+  return ret;
+}
+
+#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)
+{
+  I_32 ret = 0;
+
+  Trc_PRT_vmem_hyvmem_free_memory_Entry (address, byteAmount);
+  update_vmemIdentifier (identifier, NULL, NULL, 0, 0, 0);
+  ret = (I_32) VirtualFree ((LPVOID) address, (size_t) 0, MEM_RELEASE);
+  Trc_PRT_vmem_hyvmem_free_memory_Exit (ret);
+  return ret;
+}
+
+#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)
+{
+  LPVOID baseAddress = NULL;
+  DWORD protection = getProtectionBits (mode);
+
+  Trc_PRT_vmem_hyvmem_reserve_memory_Entry (address, byteAmount);
+  /* Invalid input */
+  if (0 == pageSize)
+    {
+      update_vmemIdentifier (identifier, NULL, NULL, 0, 0, 0);
+      Trc_PRT_vmem_hyvmem_reserve_memory_Exit1 ();
+      return NULL;
+    }
+
+  /* Handle default page size */
+  if ((HYPORT_VMEM_PAGE_SIZE_DEFAULT == pageSize)
+      || (PPG_vmem_pageSize[0] == pageSize))
+    {
+      DWORD allocationType;
+
+      /* Determine if a commit is required */
+      if (0 != (HYPORT_VMEM_MEMORY_MODE_COMMIT & mode))
+	{
+	  allocationType = MEM_COMMIT;
+	}
+      else
+	{
+	  /* 
+	   * If we don't reserve with PAGE_NOACCESS, CE won't give us large blocks. 
+	   * On Win32 the protection bits appear to be ignored for uncommitted memory. 
+	   */
+	  allocationType = MEM_RESERVE;
+	  protection = PAGE_NOACCESS;
+	}
+
+      baseAddress =
+	VirtualAlloc ((LPVOID) address, (size_t) byteAmount, allocationType,
+		      protection);
+      update_vmemIdentifier (identifier, (void *) baseAddress,
+			     (void *) baseAddress, byteAmount, mode,
+			     PPG_vmem_pageSize[0]);
+      Trc_PRT_vmem_hyvmem_reserve_memory_Exit2 (baseAddress);
+      return (void *) baseAddress;
+    }
+
+  /* Must be large pages, make sure size is correct, else return an error */
+  if (PPG_vmem_pageSize[1] == pageSize)
+    {
+      UDATA largePageSize = PPG_vmem_pageSize[1];
+      UDATA numOfPages = byteAmount / largePageSize;
+      UDATA leftOver = byteAmount - numOfPages * largePageSize;
+      UDATA totalAllocateSize = 0;
+
+      if (leftOver != 0)
+	{
+	  numOfPages++;
+	}
+      totalAllocateSize = numOfPages * largePageSize;
+
+      /* Allocate large pages in the process's virtual address space, must commit. */
+      SetLockPagesPrivilege (GetCurrentProcess (), TRUE);
+      baseAddress =
+	VirtualAlloc (NULL, totalAllocateSize, MEM_LARGE_PAGES | MEM_COMMIT,
+		      protection);
+      SetLockPagesPrivilege (GetCurrentProcess (), FALSE);
+
+      update_vmemIdentifier (identifier, (void *) baseAddress,
+			     (void *) baseAddress, totalAllocateSize, mode,
+			     largePageSize);
+      Trc_PRT_vmem_hyvmem_reserve_memory_Exit (baseAddress);
+      return (void *) baseAddress;
+    }
+
+  /* if here, error */
+  update_vmemIdentifier (identifier, NULL, NULL, 0, 0, 0);
+  Trc_PRT_vmem_hyvmem_reserve_memory_Exit4 ();
+  return NULL;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#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)
+{
+  /* empty */
+}
+
+#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)
+{
+  SYSTEM_INFO systemInfo;
+  UDATA handle;
+  UDATA (WINAPI * GetLargePageMinimumFunc) ();
+
+  /* 0 terminate the table */
+  memset (PPG_vmem_pageSize, 0, HYPORT_VMEM_PAGESIZE_COUNT * sizeof (UDATA));
+
+  /* Default page size */
+  GetSystemInfo (&systemInfo);
+  PPG_vmem_pageSize[0] = (UDATA) systemInfo.dwPageSize;
+
+  /* Determine if largePages are supported on this platform */
+  /* Look for GetLargePageMinimum in the Kernel32 DLL */
+  if (0 ==
+      portLibrary->sl_open_shared_library (portLibrary, "Kernel32", &handle,
+					   TRUE))
+    {
+      if (0 ==
+	  portLibrary->sl_lookup_name (portLibrary, handle,
+				       "GetLargePageMinimum",
+				       (UDATA *) & GetLargePageMinimumFunc,
+				       "PV"))
+	{
+	  PPG_vmem_pageSize[1] = GetLargePageMinimumFunc ();
+	  /* Safety check, best guess if necessary */
+	  if (PPG_vmem_pageSize[1] == 0)
+	    {
+	      PPG_vmem_pageSize[1] = 4194304;
+	    }
+	}
+
+      if (portLibrary->sl_close_shared_library (portLibrary, handle))
+	{
+	  /* NLS has not yet initialized */
+	  portLibrary->tty_printf (portLibrary,
+				   "Failed to close DLL Kernel32\n");
+	}
+    }
+
+  return 0;
+}
+
+#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
+
+#define CDEV_CURRENT_FUNCTION update_vmemIdentifier
+/**
+ * @internal
+ * Update HyPortVmIdentifier structure
+ *
+ * @param[in] identifier The structure to be updated
+ * @param[in] address Base address
+ * @param[in] handle Platform specific handle for reserved memory
+ * @param[in] byteAmount Size of allocated area
+ * @param[in] mode Access Mode
+ * @param[in] pageSize Constant describing pageSize
+ */
+void VMCALL
+update_vmemIdentifier (HyPortVmemIdentifier * identifier, void *address,
+		       void *handle, UDATA byteAmount, UDATA mode,
+		       UDATA pageSize)
+{
+  identifier->address = address;
+  identifier->handle = handle;
+  identifier->size = byteAmount;
+  identifier->pageSize = pageSize;
+  identifier->mode = mode;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION SetLockPagesPrivilege
+BOOL
+SetLockPagesPrivilege (HANDLE hProcess, BOOL bEnable)
+{
+  struct
+  {
+    DWORD Count;
+    LUID_AND_ATTRIBUTES Privilege[1];
+  } Info;
+
+  HANDLE Token;
+
+  /* Open the token. */
+  if (OpenProcessToken (hProcess, TOKEN_ADJUST_PRIVILEGES, &Token) != TRUE)
+    {
+      return FALSE;
+    }
+
+  /* Enable or disable? */
+  Info.Count = 1;
+  if (bEnable)
+    {
+      Info.Privilege[0].Attributes = SE_PRIVILEGE_ENABLED;
+    }
+  else
+    {
+      Info.Privilege[0].Attributes = 0;
+    }
+
+  /* Get the LUID. */
+  if (LookupPrivilegeValue
+      (NULL, SE_LOCK_MEMORY_NAME, &(Info.Privilege[0].Luid)) != TRUE)
+    {
+      return FALSE;
+    }
+
+  /* Adjust the privilege. */
+  if (AdjustTokenPrivileges
+      (Token, FALSE, (PTOKEN_PRIVILEGES) & Info, (DWORD) NULL, NULL,
+       NULL) != TRUE)
+    {
+      return FALSE;
+    }
+  else
+    {
+      if (GetLastError () != ERROR_SUCCESS)
+	{
+	  return FALSE;
+	}
+    }
+
+  CloseHandle (Token);
+
+  return TRUE;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION getProtectionBits
+DWORD
+getProtectionBits (UDATA mode)
+{
+  if (0 != (HYPORT_VMEM_MEMORY_MODE_EXECUTE & mode))
+    {
+      if (0 != (HYPORT_VMEM_MEMORY_MODE_READ & mode))
+	{
+	  if (0 != (HYPORT_VMEM_MEMORY_MODE_WRITE & mode))
+	    {
+	      return PAGE_EXECUTE_READWRITE;
+	    }
+	  else
+	    {
+	      return PAGE_EXECUTE_READ;
+	    }
+	}
+      else
+	{
+	  return PAGE_NOACCESS;
+	}
+    }
+  else
+    {
+      if (0 != (HYPORT_VMEM_MEMORY_MODE_READ & mode))
+	{
+	  if (0 != (HYPORT_VMEM_MEMORY_MODE_WRITE & mode))
+	    {
+	      return PAGE_READWRITE;
+	    }
+	  else
+	    {
+	      return PAGE_READONLY;
+	    }
+	}
+      else
+	{
+	  return PAGE_NOACCESS;
+	}
+    }
+}
+
+#undef CDEV_CURRENT_FUNCTION

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/makefile
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/makefile?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/makefile
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/makefile
Wed Nov 30 21:29:27 2005
@@ -0,0 +1,91 @@
+# Copyright 1998, 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.
+
+#
+# Makefile for module 'port'
+#
+
+APPVER=4.0
+TARGETOS=WIN95
+_WIN32_IE=0x0500
+SEHMAP = TRUE
+!include <win32.mak>
+
+DLLFILENAME=hyprt.dll# declaration
+
+DLLNAME=..\hyprt.dll # declaration
+
+LIBNAME=hyprt# declaration
+
+LIBPATH=..\lib\# declaration
+
+.c.obj:
+	$(cc) -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 $(cflags) -D_MT -D_DLL -MD -D_WINSOCKAPI_ -DWIN32
-Ogityb1 -Gs -GF -Zm400 -WX -Zi  -DHYPORT_LIBRARY_DEFINE /I..\include $(VMDEBUG) $*.c
+
+.cpp.obj:
+	$(cc) -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 $(cflags) -D_MT -D_DLL -MD -D_WINSOCKAPI_ -DWIN32
-Ogityb1 -Gs -GF -Zm400 -WX -Zi  -DHYPORT_LIBRARY_DEFINE /I..\include $(VMDEBUG) $*.cpp
+
+.asm.obj:
+	ml /c /Cp /W3 /nologo /coff /Zm /Zd /Zi /Gd $(VMASMDEBUG) -DWIN32  $<
+
+.rc.res:
+	rc -I..\include $<
+
+BUILDFILES1 = port_copyright.obj hycpu.obj hyerror.obj hyerrorhelpers.obj hyexit.obj
+BUILDFILES2 = hyfile.obj hyfiletext.obj hygp.obj hyipcmutex.obj hymem.obj
+BUILDFILES3 = hymmap.obj hynls.obj hynlshelpers.obj hyosdump.obj hyport.obj
+BUILDFILES4 = hyportcontrol.obj hyportptb.obj hyshmem.obj hyshsem.obj hysignal.obj
+BUILDFILES5 = hysl.obj hysock.obj hystr.obj hystrftime.obj hystsl.obj
+BUILDFILES6 = hysysinfo.obj hytime.obj hytlshelpers.obj hytty.obj hyvmem.obj
+
+VIRTFILES1 = hyprt.res
+
+SYSLIBFILES1 = ws2_32.lib Iphlpapi.lib shell32.lib
+
+MDLLIBFILES1 = ..\lib\hythr.lib ..\lib\hycommon.lib ..\lib\hysig.lib
+
+all: \
+	 ..\lib\$(LIBNAME).lib $(DLLNAME)
+
+BUILDLIB: $(LIBPATH)$(LIBNAME).lib
+
+$(LIBPATH)$(LIBNAME).lib:\
+	$(BUILDFILES1) $(BUILDFILES2) $(BUILDFILES3) $(BUILDFILES4) $(BUILDFILES5) \
+	$(BUILDFILES6) $(VIRTFILES1) $(MDLLIBFILES1) 
+	$(implib) /NOLOGO -subsystem:windows -out:$(LIBPATH)$(LIBNAME).lib -def:$(LIBNAME).def -machine:$(CPU)
\
+	$(BUILDFILES1) $(BUILDFILES2) $(BUILDFILES3) $(BUILDFILES4) $(BUILDFILES5) \
+	$(BUILDFILES6) $(VIRTFILES1) $(MDLLIBFILES1) 
+
+
+$(DLLNAME): $(LIBPATH)$(LIBNAME).lib \
+	$(BUILDFILES1) $(BUILDFILES2) $(BUILDFILES3) $(BUILDFILES4) $(BUILDFILES5) \
+	$(BUILDFILES6) $(VIRTFILES1) $(MDLLIBFILES1) 
+	link $(VMLINK) /NOLOGO /debug /opt:icf /opt:ref /INCREMENTAL:NO /NOLOGO -entry:_DllMainCRTStartup@12
\
+         -dll /BASE:0x11100000 -machine:$(CPU) \
+	/comment:"Platform port library. (c) Copyright 1993, 2005 The Apache Software Foundation
or its licensors, as applicable." \
+	-subsystem:windows -out:$(DLLNAME) -map:$(LIBNAME).map Delayimp.lib -delayload:shell32.dll
-delayload:Iphlpapi.dll \
+	$(BUILDFILES1) $(BUILDFILES2) $(BUILDFILES3) $(BUILDFILES4) $(BUILDFILES5) \
+	$(BUILDFILES6) $(VIRTFILES1) $(MDLLIBFILES1) $(SYSLIBFILES1)  \
+	kernel32.lib  ws2_32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib  $(LIBPATH)$(LIBNAME).exp
+
+clean:
+	-del *.map
+	-del *.obj
+	-del *.res
+	-del *.pdb
+	-del ..\lib\$(LIBNAME).lib
+	-del ..\lib\$(LIBNAME).exp
+	-del ..\$(LIBNAME).pdb
+	-del $(DLLNAME)
+	

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/port.nls
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/port.nls?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/port.nls
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/port.nls
Wed Nov 30 21:29:27 2005
@@ -0,0 +1,67 @@
+# 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.
+
+# Externalised messages for common elements of the port library
+#
+# Note to developers:
+#
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+#
+# Note to translators:
+#
+# This file uses printf style substitutions. Sequences such as %s, %.*s, %10d
+# etc. will be subsituted at runtime. The special case of %% is not a substitution.
+# It indicates a single percent sign. Please do not modify the format specifiers, or 
+# change their order. For instance, in a message like "from %d to %s", %d
+# MUST appear before %s in any translated message, or a run-time crash
+# could occur. This is a known limitation of the product.
+#
+# NLS_MESSAGEFORMAT_NONE
+#
+
+HYNLS.MODULE=PORT
+HYNLS.HEADER=portnls.h
+
+# Do not translate
+# used for unique number only
+HYNLS_PORT_NLS_FAILURE=
+
+HYNLS_PORT_FILE_MEMORY_ALLOCATE_FAILURE=Failed to allocate memory.
+
+HYNLS_PORT_SL_UNKOWN_ERROR=Unkown error loading shared library
+# Note: argument is the name of dependant the DLL
+HYNLS_PORT_SL_ERROR_LOADING_DEPENDANT_MODULE=Dependent module %s could not be loaded
+HYNLS_PORT_SL_SYMBOL_RESOLUTION_FAILURE=Symbol resolution failure
+HYNLS_PORT_SL_COULD_NOT_LOAD_MODULE=Could not load module
+HYNLS_PORT_SL_MODULE_FORMAT_INCORRECT=Module format incorrect
+HYNLS_PORT_SL_NOT_A_MODULE=Not a module
+HYNLS_PORT_SL_MODULE_ARCHITECTURE_INCORRECT=Module architecture incorrect
+HYNLS_PORT_SL_FILE_NOT_FOUND=File not found
+HYNLS_PORT_SL_PERMISSION_DENIED=Permission denied
+HYNLS_PORT_SL_OUT_OF_MEMORY=Out of memory
+HYNLS_PORT_SL_ERROR_PACE_BIT_SET=Error: 68K function has PACE bit set.
+HYNLS_PORT_SL_DLL_TABLE_NOT_FOUND=DLL table not found
+HYNLS_PORT_SL_DLL_NOT_FOUND=DLL not found
+HYNLS_PORT_SL_UNABLE_TO_RESOLVE_REFERENCES=Unable to resolve DLL references - a prerequisite
DLL may be missing
+HYNLS_PORT_SL_INTERNAL_ERROR=Internal Error %i
+
+#Note: argument is OS errorCode
+HYNLS_PORT_ERROR_OPERATION_FAILED=Operation Failed: %d
+#Note: argument is errorCodeBeingLookedUp, OS Function Call, errorCodeFromFunctionCall
+HYNLS_PORT_ERROR_MESSAGE_LOOKUP_FAILED=Operation Failed: %1$d (%2$s failed: %3$d)
+
+
+

Added: incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/port_copyright.c
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/port_copyright.c?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/port_copyright.c
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/port_copyright.c
Wed Nov 30 21:29:27 2005
@@ -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/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/portnls.h
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/portnls.h?rev=350181&view=auto
==============================================================================
--- incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/portnls.h
(added)
+++ incubator/harmony/enhanced/trunk/sandbox/contribs/ibm_core/native-src/win.IA32/port/portnls.h
Wed Nov 30 21:29:27 2005
@@ -0,0 +1,44 @@
+/* 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 /* portnls_h */



Mime
View raw message