You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2008/03/20 17:09:03 UTC

svn commit: r639339 - in /harmony/enhanced/drlvm/trunk: ./ make/vm/ vm/include/open/ vm/port/build/ vm/port/include/ vm/port/src/crash_handler/linux/ vm/port/src/misc/linux/ vm/port/src/misc/win/ vm/port/src/signals/include/ vm/port/src/signals/linux/ ...

Author: gshimansky
Date: Thu Mar 20 09:08:58 2008
New Revision: 639339

URL: http://svn.apache.org/viewvc?rev=639339&view=rev
Log:
Patch to make crash handler library dynamic from HARMONY-5606
[drlvm][port] Make Crash Handler shared library


Added:
    harmony/enhanced/drlvm/trunk/make/vm/port_ch.xml   (with props)
    harmony/enhanced/drlvm/trunk/vm/port/build/ch.exp
    harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/execname.c   (with props)
    harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/execname.c   (with props)
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_asm_em64t.s
      - copied, changed from r639256, harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_asm_em64t.s
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_asm_ia32.s
      - copied unchanged from r639256, harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_asm_ia32.s
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_em64t.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_ia32.cpp   (with props)
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_asm_em64t.asm
      - copied, changed from r639256, harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.asm
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_asm_ia32.asm
      - copied unchanged from r639256, harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_asm_ia32.asm
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.cpp   (with props)
Removed:
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.asm
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_asm_em64t.s
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_asm_ia32.s
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_asm_em64t.asm
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_asm_ia32.asm
Modified:
    harmony/enhanced/drlvm/trunk/build.xml
    harmony/enhanced/drlvm/trunk/make/vm/port.xml
    harmony/enhanced/drlvm/trunk/make/vm/vmcore.xml
    harmony/enhanced/drlvm/trunk/vm/include/open/types.h
    harmony/enhanced/drlvm/trunk/vm/port/include/port_crash_handler.h
    harmony/enhanced/drlvm/trunk/vm/port/include/port_memaccess.h
    harmony/enhanced/drlvm/trunk/vm/port/include/port_modules.h
    harmony/enhanced/drlvm/trunk/vm/port/include/port_thread.h
    harmony/enhanced/drlvm/trunk/vm/port/include/port_unwind.h
    harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/linux/gdb_crash_handler.cpp
    harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c
    harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/include/signals_internal.h
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ia32.c
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ipf.c
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_em64t.c
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_ia32.c
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c

Modified: harmony/enhanced/drlvm/trunk/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build.xml?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/build.xml (original)
+++ harmony/enhanced/drlvm/trunk/build.xml Thu Mar 20 09:08:58 2008
@@ -109,22 +109,26 @@
     <!-- ================================================================
             build individual components
          ================================================================-->
-    
+
     <target name="build-extra" depends=""
         description="Compiles external dependencies">
         <ant antfile="make/extra/apr.xml"/>
         <ant antfile="make/extra/aprutil.xml"/>
         <ant antfile="make/extra/log4cxx.xml"/>
     </target>
-    
+
     <target name="encoder">
         <ant antfile="make/vm/encoder.xml"/>
     </target>
-    
+
     <target name="port" depends="build-extra">
         <ant antfile="make/vm/port.xml"/>
     </target>
-    
+
+    <target name="port_ch" depends="port">
+        <ant antfile="make/vm/port_ch.xml"/>
+    </target>
+
     <target name="hythr" depends="port">
         <ant antfile="make/vm/hythr.xml"/>
     </target>
@@ -137,7 +141,7 @@
         <ant antfile="make/vm/verifier-ext.xml"/>
     </target>
 
-    <target name="vmcore" depends="encoder, port, hythr, verifier">
+    <target name="vmcore" depends="encoder, port, port_ch, hythr, verifier">
         <ant antfile="make/vm/vmcore.xml"/>
     </target>
 
@@ -148,7 +152,7 @@
     <target name="interpreter" depends="vmcore">
         <ant antfile="make/vm/interpreter.xml"/>
     </target>
-    
+
     <target name="kernel">
         <ant antfile="make/vm/kernel.xml"/>
     </target>
@@ -164,7 +168,7 @@
     <target name="gc_gen" depends="vmcore,kernel">
         <ant antfile="make/vm/gc_gen.xml"/>
     </target>
-    
+
 
     <!-- ================================================================
             import the deploy stuff from hdk / classlib

Modified: harmony/enhanced/drlvm/trunk/make/vm/port.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/make/vm/port.xml?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/make/vm/port.xml (original)
+++ harmony/enhanced/drlvm/trunk/make/vm/port.xml Thu Mar 20 09:08:58 2008
@@ -29,14 +29,11 @@
             <dirset dir="${vm.home}">
                 <include name="include" />
                 <include name="port/include" />
-                <include name="port/src/signals/include" />
-                <include name="port/src/crash_handler/include" />
-                <include name="port/src/encoder/ia32_em64t" unless="is.ia64"/>
             </dirset>
             <pathelement location="${drlvm.include.dir}"/>
             <pathelement location="${hy.hdk}/include" />
         </path>
-        <patternset id="port.src">
+        <patternset id="port.src.c">
             <include name="disasm/linux/*.c" if="is.unix"/>
             <include name="file_io/linux/*.c" if="is.unix"/>
             <include name="misc/linux/*.c" if="is.unix"/>
@@ -52,19 +49,21 @@
             <include name="vmem/win/*.c" if="is.windows"/>
             <include name="file_io/*.c"/>
 
-            <include name="modules/*.c"/>
-            <include name="modules/linux/*.c" if="is.unix"/>
-            <include name="modules/win/*.c" if="is.windows"/>
-
-            <include name="thread/linux/*_os.c" if="is.unix"/>
+            <include name="thread/linux/thread_os.c" if="is.unix"/>
             <include name="thread/linux/*ia32.c" if="is.unix.x86"/>
             <include name="thread/linux/*em64t.c" if="is.unix.x86_64"/>
             <include name="thread/linux/*ipf.c" if="is.unix.ia64"/>
-            <include name="thread/win/*_os.c" if="is.windows"/>
+            <include name="thread/win/thread_os.c" if="is.windows"/>
             <include name="thread/win/*ia32.c" if="is.windows.x86"/>
             <include name="thread/win/*em64t.c" if="is.windows.x86_64"/>
         </patternset>
 
+        <patternset id="port.src.cpp">
+            <include name="logger/**.cpp" />
+            <include name="tl/*.cpp" />
+            <include name="time/*.cpp" />
+        </patternset>
+
         <depend-includes paths="port.includes"/>
         <depend-selector rebuild-flag="port.includes.uptodate" id="port.depends.cpp"/>
         <depend-selector rebuild-flag="port.includes.uptodate" type="c" id="port.depends.c"/>
@@ -74,13 +73,6 @@
                 <include name="atomic/win/*.asm" if="is.windows.x86_64"/>
                 <include name="atomic/linux_ipf/port_atomic_asm.asm" if="is.unix.ia64"/>
                 <include name="barriers/linux_ipf/port_barriers.asm" if="is.unix.ia64"/>
-                <include name="thread/win/thread_asm_ia32.asm" if="is.windows.x86"/>
-                <include name="thread/win/thread_asm_em64t.asm" if="is.windows.x86_64"/>
-                <include name="thread/linux/thread_asm_ia32.s" if="is.unix.x86"/>
-                <include name="thread/linux/thread_asm_em64t.s" if="is.unix.x86_64"/>
-                <include name="memaccess/linux/memaccess_ia32.s" if="is.unix.x86"/>
-                <include name="memaccess/linux/memaccess_em64t.s" if="is.unix.x86_64"/>
-                <include name="signals/win/signals_em64t.asm" if="is.windows.x86_64"/>
             </fileset>
         </compile-asm>
         
@@ -92,34 +84,15 @@
 
             <compiler id="c.compiler" extends="common.c.compiler">
                 <fileset dir="${vm.home}/port/src" >
-                    <patternset refid="port.src"/>
+                    <patternset refid="port.src.c"/>
                     <selector refid="port.depends.c"/>
                 </fileset>
             </compiler>
 
             <compiler id="cpp.compiler" extends="common.cpp.compiler">
-                <fileset dir="${vm.home}/port/src">
+                <fileset dir="${vm.home}/port/src" >
+                    <patternset refid="port.src.cpp"/>
                     <selector refid="port.depends.cpp"/>
-                    <include name="logger/**.cpp" />
-                    <include name="tl/*.cpp" />
-                    <include name="time/*.cpp" />
-
-                    <include name="crash_handler/*.cpp"/>
-                    <include name="crash_handler/linux/*.cpp" if="is.unix"/>
-                    <include name="crash_handler/win/*.cpp" if="is.windows"/>
-                    <include name="crash_handler/ia32/*.cpp" if="is.x86"/>
-                    <include name="crash_handler/em64t/*.cpp" if="is.x86_64"/>
-                    <include name="crash_handler/ipf/*.cpp" if="is.ia64"/>
-
-                    <include name="memaccess/win/memaccess.cpp" if="is.windows"/>
-                    <include name="memaccess/linux/memaccess.cpp" if="is.unix" unless="is.ia64"/>
-                    <include name="memaccess/linux/*ipf.cpp" if="is.unix.ia64"/>
-
-                    <include name="signals/*.cpp"/>
-                    <include name="signals/linux/*common.cpp" if="is.unix" unless="is.ia64"/>
-                    <include name="signals/linux/*ipf.cpp" if="is.unix.ia64"/>
-                    <include name="signals/win/*common.cpp" if="is.windows"/>
-                    <include name="signals/win/*ia32.cpp" if="is.windows.x86"/>
                 </fileset>
 
                 <compilerarg value="/EHsc" if="is.windows"/>

Added: harmony/enhanced/drlvm/trunk/make/vm/port_ch.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/make/vm/port_ch.xml?rev=639339&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/make/vm/port_ch.xml (added)
+++ harmony/enhanced/drlvm/trunk/make/vm/port_ch.xml Thu Mar 20 09:08:58 2008
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<project name="port_ch" default="build" basedir="../..">
+
+    <property name="component" value="port_ch"/>
+
+    <import file="common-vm.xml"/>
+
+    <target name="build" depends="-common-vm">
+        <init-native/>
+
+        <path id="ch.includes">
+            <dirset dir="${vm.home}">
+                <include name="include" />
+                <include name="port/include" />
+                <include name="port/src/signals/include" />
+                <include name="port/src/crash_handler/include" />
+                <include name="port/src/encoder/ia32_em64t" unless="is.ia64"/>
+            </dirset>
+            <pathelement location="${drlvm.include.dir}"/>
+            <pathelement location="${hy.hdk}/include" />
+        </path>
+
+        <patternset id="ch.src.c">
+            <include name="modules/*.c"/>
+            <include name="modules/linux/*.c" if="is.unix"/>
+            <include name="modules/win/*.c" if="is.windows"/>
+
+            <include name="thread/linux/*ia32.c" if="is.unix.x86"/>
+            <include name="thread/linux/*em64t.c" if="is.unix.x86_64"/>
+            <include name="thread/linux/*ipf.c" if="is.unix.ia64"/>
+            <include name="thread/win/*ia32.c" if="is.windows.x86"/>
+            <include name="thread/win/*em64t.c" if="is.windows.x86_64"/>
+
+            <include name="misc/linux/execname.c" if="is.unix"/>
+            <include name="misc/win/execname.c" if="is.windows"/>
+        </patternset>
+
+        <patternset id="ch.src.cpp">
+            <include name="crash_handler/*.cpp"/>
+            <include name="crash_handler/linux/*.cpp" if="is.unix"/>
+            <include name="crash_handler/win/*.cpp" if="is.windows"/>
+            <include name="crash_handler/ia32/*.cpp" if="is.x86"/>
+            <include name="crash_handler/em64t/*.cpp" if="is.x86_64"/>
+            <include name="crash_handler/ipf/*.cpp" if="is.ia64"/>
+
+            <include name="memaccess/win/memaccess.cpp" if="is.windows"/>
+            <include name="memaccess/linux/memaccess.cpp" if="is.unix" unless="is.ia64"/>
+            <include name="memaccess/linux/*ipf.cpp" if="is.unix.ia64"/>
+
+            <include name="signals/*.cpp"/>
+            <include name="signals/linux/*common.cpp" if="is.unix" unless="is.ia64"/>
+            <include name="signals/linux/*ia32.cpp" if="is.unix.x86"/>
+            <include name="signals/linux/*em64t.cpp" if="is.unix.x86_64"/>
+            <include name="signals/linux/*ipf.cpp" if="is.unix.ia64"/>
+            <include name="signals/win/*common.cpp" if="is.windows"/>
+            <include name="signals/win/*ia32.cpp" if="is.windows.x86"/>
+            <include name="signals/win/*em64t.cpp" if="is.windows.x86_64"/>
+        </patternset>
+
+        <depend-includes paths="ch.includes"/>
+        <depend-selector rebuild-flag="ch.includes.uptodate" id="ch.depends.cpp"/>
+        <depend-selector rebuild-flag="ch.includes.uptodate" type="c" id="ch.depends.c"/>
+
+        <compile-asm>
+            <fileset id="ch.asm" dir="${vm.home}/port/src">
+                <include name="memaccess/linux/memaccess_ia32.s" if="is.unix.x86"/>
+                <include name="memaccess/linux/memaccess_em64t.s" if="is.unix.x86_64"/>
+
+                <include name="signals/win/signals_asm_ia32.asm" if="is.windows.x86"/>
+                <include name="signals/win/signals_asm_em64t.asm" if="is.windows.x86_64"/>
+                <include name="signals/linux/signals_asm_ia32.s" if="is.unix.x86"/>
+                <include name="signals/linux/signals_asm_em64t.s" if="is.unix.x86_64"/>
+            </fileset>
+        </compile-asm>
+
+        <compile-cc>
+            <includepath><path refid="ch.includes"/></includepath>
+
+            <defineset define="APR_DECLARE_EXPORT" />
+            <defineset define="BUILDING_VM" />
+
+            <compiler id="c.compiler" extends="common.c.compiler">
+                <fileset dir="${vm.home}/port/src" >
+                    <patternset refid="ch.src.c"/>
+                    <selector refid="ch.depends.c"/>
+                </fileset>
+            </compiler>
+
+            <compiler id="cpp.compiler" extends="common.cpp.compiler">
+                <fileset dir="${vm.home}/port/src" >
+                    <patternset refid="ch.src.cpp"/>
+                    <selector refid="ch.depends.cpp"/>
+                </fileset>
+
+                <compilerarg value="/EHsc" if="is.windows"/>
+                <compilerarg value="-fexceptions" if="is.unix"/>
+            </compiler>
+        </compile-cc>
+
+        <link-lib name="ch" type="shared">
+            <linker id="linker" extends="common.linker">
+                <libset libs="encoder" dir="${drlvm.lib.dir}" />
+
+                <linkerarg value="--version-script=${vm.home}/port/build/ch.exp" if="is.unix"/>
+
+                <syslibset type="shared" libs="dl,stdc++,pthread,rt" if="is.linux"/>
+                <syslibset type="shared" libs="stdc++,pthread" if="is.freebsd"/>
+                <linkerarg value="--export-dynamic" if="is.freebsd"/>
+            </linker>
+        </link-lib>
+    </target>
+
+    <target name="clean" >
+        <clean-native/>
+    </target>
+
+</project>

Propchange: harmony/enhanced/drlvm/trunk/make/vm/port_ch.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/make/vm/vmcore.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/make/vm/vmcore.xml?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/make/vm/vmcore.xml (original)
+++ harmony/enhanced/drlvm/trunk/make/vm/vmcore.xml Thu Mar 20 09:08:58 2008
@@ -217,7 +217,8 @@
                 <libset libs="hythr" dir="${drlvm.shlib.dir}" />
                 <libset libs="icuuc" dir="${drlvm.shlib.dir}"/>
                 <libset libs="zdll" dir="${drlvm.lib.dir}" if="is.windows"/>
-    
+                <libset libs="ch" dir="${drlvm.shlib.dir}" />
+
                 <linkerarg value="/DEF:${vm.home}/vmcore/src/harmonyvm64.def" if="is.windows.x86_64"/>
                 <linkerarg value="/DEF:${vm.home}/vmcore/src/harmonyvm.def" if="is.windows.x86"/>
                 <linkerarg value="--version-script=${vm.home}/vmcore/build/vmcore.exp" if="is.unix"/>

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/types.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/types.h?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/types.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/types.h Thu Mar 20 09:08:58 2008
@@ -18,7 +18,7 @@
 #ifndef _VM_TYPES_H_
 #define _VM_TYPES_H_
 
-#include "platform_types.h"
+#include "open/platform_types.h"
 #include <stddef.h>
 
 

Added: harmony/enhanced/drlvm/trunk/vm/port/build/ch.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/build/ch.exp?rev=639339&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/build/ch.exp (added)
+++ harmony/enhanced/drlvm/trunk/vm/port/build/ch.exp Thu Mar 20 09:08:58 2008
@@ -0,0 +1,21 @@
+PORT_0.1 {
+  global :
+#
+    port_init_crash_handler;
+    port_shutdown_crash_handler;
+    port_crash_handler_*;
+    port_set_breakpoint;
+    port_clear_breakpoint;
+    port_is_breakpoint_set;
+    port_read_memory;
+    port_write_memory;
+    port_get_all_modules;
+    port_dump_modules;
+    port_clear_modules;
+    port_find_module;
+    port_init_unwind_context;
+    port_clean_unwind_context;
+    port_unwind_frame;
+#
+  local : *;
+};

Modified: harmony/enhanced/drlvm/trunk/vm/port/include/port_crash_handler.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/include/port_crash_handler.h?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/include/port_crash_handler.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/include/port_crash_handler.h Thu Mar 20 09:08:58 2008
@@ -135,7 +135,7 @@
  * @return <code>TRUE</code> if initalization is successful.
  * <code>FALSE</code> if initialization failed.
  */
-Boolean port_init_crash_handler(
+VMEXPORT Boolean port_init_crash_handler(
     port_signal_handler_registration *registrations,
     unsigned count,
     port_unwind_compiled_frame unwind_callback);
@@ -201,7 +201,7 @@
  *
  * @returns  supported crash handler features.
  */
-unsigned port_crash_handler_get_capabilities();
+VMEXPORT unsigned port_crash_handler_get_capabilities();
 
 /**
  * Set crash handler output flags. Default mode is <code>
@@ -212,7 +212,7 @@
  *
  * @param flags - crash handler output flags.
  */
-void port_crash_handler_set_flags(unsigned flags);
+VMEXPORT void port_crash_handler_set_flags(unsigned flags);
 
 /**
  * Callback function that is called at the end of shutdown sequence.
@@ -243,7 +243,7 @@
  * <code>FALSE</code> if action was not added because no memory could
  * be allocated.
  */
-Boolean port_crash_handler_add_action(port_crash_handler_action action);
+VMEXPORT Boolean port_crash_handler_add_action(port_crash_handler_action action);
 
 /**
  * Shutdown signals and crash handler. All signals are assigned their
@@ -255,7 +255,7 @@
  * @return <code>TRUE</code> if shutdown is
  * successful. <code>FALSE</code> if shutdown failed.
  */
-Boolean port_shutdown_crash_handler();
+VMEXPORT Boolean port_shutdown_crash_handler();
 
 
 /**
@@ -267,7 +267,7 @@
 * @note Caller should keep store previous byte to restore
 * the location in future.
 */
-int port_set_breakpoint(void* addr, unsigned char* prev);
+VMEXPORT int port_set_breakpoint(void* addr, unsigned char* prev);
 
 /**
 * Restores original byte in the location previously instrumented
@@ -277,14 +277,14 @@
 * @return <code>0</code> if OK; nonzero if the location was not
 * instrumented yet or if an error occured.
 */
-int port_clear_breakpoint(void* addr, unsigned char prev);
+VMEXPORT int port_clear_breakpoint(void* addr, unsigned char prev);
 
 /**
 * Checks if the location is instrumented.
 * @param [in] addr  - memory location to deinstrument.
 * @return <code>TRUE</code> if instrumented; FALSE otherwise.
 */
-Boolean port_is_breakpoint_set(void* addr);
+VMEXPORT Boolean port_is_breakpoint_set(void* addr);
 
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/port/include/port_memaccess.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/include/port_memaccess.h?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/include/port_memaccess.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/include/port_memaccess.h Thu Mar 20 09:08:58 2008
@@ -20,6 +20,7 @@
 
 #include <stddef.h>
 #include "open/platform_types.h"
+#include "port_general.h"
 
 
 #ifdef __cplusplus
@@ -34,7 +35,7 @@
 * @param buf    - buffer to read to.
 * @return <code>0</code> if OK; nonzero if an error occured.
 */
-int port_read_memory(void* addr, size_t size, void* buf);
+VMEXPORT int port_read_memory(void* addr, size_t size, void* buf);
 
 /**
 * Tries to write specified number of bytes from buffer to given address.
@@ -43,7 +44,7 @@
 * @param buf    - buffer to write from.
 * @return <code>0</code> if OK; nonzero if an error occured.
 */
-int port_write_memory(void* addr, size_t size, void* buf);
+VMEXPORT int port_write_memory(void* addr, size_t size, void* buf);
 
 
 #ifdef __cplusplus

Modified: harmony/enhanced/drlvm/trunk/vm/port/include/port_modules.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/include/port_modules.h?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/include/port_modules.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/include/port_modules.h Thu Mar 20 09:08:58 2008
@@ -25,6 +25,7 @@
 #include <stddef.h>
 #include <stdio.h>
 #include "open/platform_types.h"
+#include "port_general.h"
 
 
 typedef enum {
@@ -61,20 +62,20 @@
 * @param count_ptr - count of modules in the returned list
 * @return <code>TRUE</code> if OK; FALSE if error occured.
 */
-Boolean port_get_all_modules(native_module_t** list_ptr, int* count_ptr);
+VMEXPORT Boolean port_get_all_modules(native_module_t** list_ptr, int* count_ptr);
 
 /**
 * Dumps the list of modules loaded to the current process..
 * @param modules  - pointer to the list of modules to dump.
 * @param out      - stream for printing the dump.
 */
-void port_dump_modules(native_module_t* modules, FILE *out);
+VMEXPORT void port_dump_modules(native_module_t* modules, FILE *out);
 
 /**
 * Clears the list of modules passed, writes NULL to the poiner.
 * @param modules  - pointer to the list of modules to clear.
 */
-void port_clear_modules(native_module_t** list_ptr);
+VMEXPORT void port_clear_modules(native_module_t** list_ptr);
 
 /**
 * Searches for the specific address in the list of modules.
@@ -82,7 +83,7 @@
 * @param code_ptr  - the address to look for.
 * @return <code>native_module_t</code> pointer if OK; otherwise, NULL.
 */
-native_module_t* port_find_module(native_module_t* modules, void* code_ptr);
+VMEXPORT native_module_t* port_find_module(native_module_t* modules, void* code_ptr);
 
 
 #ifdef __cplusplus

Modified: harmony/enhanced/drlvm/trunk/vm/port/include/port_thread.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/include/port_thread.h?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/include/port_thread.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/include/port_thread.h Thu Mar 20 09:08:58 2008
@@ -85,53 +85,6 @@
 void port_thread_context_to_regs(Registers* regs, thread_context_t* context);
 void port_thread_regs_to_context(thread_context_t* context, Registers* regs);
 
-/* Transfer control to specified register context */
-void port_transfer_to_regs(Registers* regs);
-
-/**
-* Prepares 'Registers' structure and stack area pointed in for calling
-* 'fn' function with a set of arguments provided in variable args list.
-* THe 'fn' function is called through a special stub function with
-* preserving 'red zone' on Linux and clearing direction flag on Windows.
-* After returning from 'fn' and stub, processor registers are restored
-* with a values provided in 'regs' argument.
-* The function can be used to prepare register context for transfering
-* a control to a signal/exception handling function out of the OS handler.
-*
-* When the first argument passed to 'fn' is the same 'regs' pointer, its
-* value is substituted with the pointer stored 'Registers' structure used
-* to restore register context. If 'fn' function modifies the context
-* pointed by the first argument, these changes will take effect after
-* returning from 'fn'.
-*
-* The stub for calling 'fn' is written in assembler language; 'Registers'
-* fields and size are hardcoded. It would be better to rewrite it using
-* encoder in future, to keep control on 'Registers' structure and size.
-*
-* @param [in] fn    - the address of the function to be called
-* @param [in] regs  - the register context
-* @param [in] num   - the number of parameters passed to the 'fn' function
-*                     in the variable args list (6 args at maximum)
-* @param [in] ...   - the parameters for 'fn'; should all be void* or of
-*                     the same size (pointer-sized)
-*/
-void port_set_longjump_regs(void* fn, Registers* regs, int num, ...);
-
-/**
-* The same as 'port_set_longjump_regs', but transfers a control to the
-* prepared registers context by itself.
-* Actually it's a combination of 'port_set_longjump_regs' and
-* 'port_transfer_to_regs' functions, but 'regs' fields are kept unchanged.
-*
-* @param [in] fn    - the address of the function to be called
-* @param [in] regs  - the register context
-* @param [in] num   - the number of parameters passed to the 'fn' function
-*                     in the variable args list (6 args at maximum)
-* @param [in] ...   - the parameters for 'fn'; should all be void* or of
-*                     the same size (pointer-sized)
-*/
-void port_transfer_to_function(void* fn, Registers* regs, int num, ...);
-
 
 
 //@}

Modified: harmony/enhanced/drlvm/trunk/vm/port/include/port_unwind.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/include/port_unwind.h?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/include/port_unwind.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/include/port_unwind.h Thu Mar 20 09:08:58 2008
@@ -18,6 +18,7 @@
 #ifndef __PORT_UNWIND_H__
 #define __PORT_UNWIND_H__
 
+#include "port_general.h"
 #include "port_modules.h"
 
 typedef struct UnwindContext {
@@ -31,10 +32,10 @@
 #endif
 
 
-bool port_init_unwind_context(UnwindContext* context, native_module_t* modules, Registers* regs);
-void port_clean_unwind_context(UnwindContext* context);
+VMEXPORT bool port_init_unwind_context(UnwindContext* context, native_module_t* modules, Registers* regs);
+VMEXPORT void port_clean_unwind_context(UnwindContext* context);
 
-bool port_unwind_frame(UnwindContext* context, Registers* regs);
+VMEXPORT bool port_unwind_frame(UnwindContext* context, Registers* regs);
 
 
 #ifdef __cplusplus

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/linux/gdb_crash_handler.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/linux/gdb_crash_handler.cpp?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/linux/gdb_crash_handler.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/crash_handler/linux/gdb_crash_handler.cpp Thu Mar 20 09:08:58 2008
@@ -98,6 +98,6 @@
 
 void cleanup_gdb_crash_handler()
 {
-    STD_FREE(g_executable);
+//    STD_FREE(g_executable);
     g_prepared = false;
 }

Added: harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/execname.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/execname.c?rev=639339&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/execname.c (added)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/execname.c Thu Mar 20 09:08:58 2008
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+* @author Alexey V. Varlamov
+* @version $Revision: 1.1.2.1.4.3 $
+*/
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/utsname.h>
+#include <limits.h>
+#include <errno.h>
+#include "port_malloc.h"
+#include "port_sysinfo.h"
+#if defined(FREEBSD)
+#define _GNU_SOURCE
+#include <dlfcn.h>
+extern int main (int argc, char **argv, char **envp);
+#endif
+
+APR_DECLARE(apr_status_t) port_executable_name(char** self_name) {
+
+    char* buf;
+
+#if defined(FREEBSD)
+    Dl_info info;
+
+    if (dladdr( (const void*)&main, &info) == 0) {
+        return APR_ENOENT;
+    }
+
+    buf = (char*)STD_MALLOC(strlen(info.dli_fname) + 1);
+
+    if (!buf)
+        return APR_ENOMEM;
+
+    strcpy(buf, info.dli_fname);
+#else
+    char tmpbuf[PATH_MAX + 1];
+
+    int n = readlink("/proc/self/exe", tmpbuf, PATH_MAX);
+
+    if (n == -1) {
+        return apr_get_os_error();
+    }
+
+    tmpbuf[n] = '\0';
+
+    buf = (char*)STD_MALLOC(n + 1);
+
+    if (!buf)
+        return APR_ENOMEM;
+
+    strcpy(buf, tmpbuf);
+#endif
+
+    *self_name = buf;
+    return APR_SUCCESS;
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/execname.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/misc/linux/sysinfo.c Thu Mar 20 09:08:58 2008
@@ -24,54 +24,8 @@
 #include <sys/utsname.h>
 #include <limits.h>
 #include <errno.h>
-#include "port_malloc.h"
 #include "port_sysinfo.h"
 #include <apr_strings.h>
-#if defined(FREEBSD)
-#define _GNU_SOURCE
-#include <dlfcn.h>
-extern int main (int argc, char **argv, char **envp);
-#endif
-
-APR_DECLARE(apr_status_t) port_executable_name(char** self_name) {
-
-    char* buf;
-
-#if defined(FREEBSD)
-    Dl_info info;
-
-    if (dladdr( (const void*)&main, &info) == 0) {
-        return APR_ENOENT;
-    }
-
-    buf = (char*)STD_MALLOC(strlen(info.dli_fname) + 1);
-
-    if (!buf)
-        return APR_ENOMEM;
-
-    strcpy(buf, info.dli_fname);
-#else
-    char tmpbuf[PATH_MAX + 1];
-
-    int n = readlink("/proc/self/exe", tmpbuf, PATH_MAX);
-
-    if (n == -1) {
-        return apr_get_os_error();
-    }
-
-    tmpbuf[n] = '\0';
-
-    buf = (char*)STD_MALLOC(n + 1);
-
-    if (!buf)
-        return APR_ENOMEM;
-
-    strcpy(buf, tmpbuf);
-#endif
-
-    *self_name = buf;
-    return APR_SUCCESS;
-}
 
 APR_DECLARE(int) port_CPUs_number(void) {
 	return (int)sysconf(_SC_NPROCESSORS_CONF);

Added: harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/execname.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/execname.c?rev=639339&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/execname.c (added)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/execname.c Thu Mar 20 09:08:58 2008
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include "port_malloc.h"
+#include "port_sysinfo.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+
+APR_DECLARE(apr_status_t) port_executable_name(char** self_name){
+
+    char buf[_MAX_PATH*2]; /*XXX result in TCHARs */
+    int len = GetModuleFileName(0, buf, _MAX_PATH);
+    if (0 == len) {
+        return apr_get_os_error();
+    }
+
+    *self_name = STD_MALLOC(strlen(buf) + 1);
+    if (*self_name)
+        strcpy(*self_name, buf);
+
+    return APR_SUCCESS;
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/execname.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c Thu Mar 20 09:08:58 2008
@@ -96,21 +96,6 @@
 	return APR_SUCCESS;
 }
 
-APR_DECLARE(apr_status_t) port_executable_name(char** self_name){
-
-    char buf[_MAX_PATH*2]; /*XXX result in TCHARs */
-    int len = GetModuleFileName(0, buf, _MAX_PATH);
-    if (0 == len) {
-        return apr_get_os_error();
-    }
-
-    *self_name = STD_MALLOC(strlen(buf) + 1);
-    if (*self_name)
-        strcpy(*self_name, buf);
-
-    return APR_SUCCESS;
-}
-
 APR_DECLARE(const char *) port_CPU_architecture(void){
 #if defined(_IPF_)
 	return "ia64";

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/signals/include/signals_internal.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/include/signals_internal.h?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/signals/include/signals_internal.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/include/signals_internal.h Thu Mar 20 09:08:58 2008
@@ -82,6 +82,55 @@
 }
 
 
+/* Transfer control to specified register context */
+void port_transfer_to_regs(Registers* regs);
+
+/**
+* Prepares 'Registers' structure and stack area pointed in for calling
+* 'fn' function with a set of arguments provided in variable args list.
+* THe 'fn' function is called through a special stub function with
+* preserving 'red zone' on Linux and clearing direction flag on Windows.
+* After returning from 'fn' and stub, processor registers are restored
+* with a values provided in 'regs' argument.
+* The function can be used to prepare register context for transfering
+* a control to a signal/exception handling function out of the OS handler.
+*
+* When the first argument passed to 'fn' is the same 'regs' pointer, its
+* value is substituted with the pointer stored 'Registers' structure used
+* to restore register context. If 'fn' function modifies the context
+* pointed by the first argument, these changes will take effect after
+* returning from 'fn'.
+*
+* The stub for calling 'fn' is written in assembler language; 'Registers'
+* fields and size are hardcoded. It would be better to rewrite it using
+* encoder in future, to keep control on 'Registers' structure and size.
+*
+* @param [in] fn    - the address of the function to be called
+* @param [in] regs  - the register context
+* @param [in] num   - the number of parameters passed to the 'fn' function
+*                     in the variable args list (6 args at maximum)
+* @param [in] ...   - the parameters for 'fn'; should all be void* or of
+*                     the same size (pointer-sized)
+*/
+void port_set_longjump_regs(void* fn, Registers* regs, int num, ...);
+
+/**
+* The same as 'port_set_longjump_regs', but transfers a control to the
+* prepared registers context by itself.
+* Actually it's a combination of 'port_set_longjump_regs' and
+* 'port_transfer_to_regs' functions, but 'regs' fields are kept unchanged.
+*
+* @param [in] fn    - the address of the function to be called
+* @param [in] regs  - the register context
+* @param [in] num   - the number of parameters passed to the 'fn' function
+*                     in the variable args list (6 args at maximum)
+* @param [in] ...   - the parameters for 'fn'; should all be void* or of
+*                     the same size (pointer-sized)
+*/
+void port_transfer_to_function(void* fn, Registers* regs, int num, ...);
+
+
+
 #define INSTRUMENTATION_BYTE_HLT 0xf4 // HLT instruction
 #define INSTRUMENTATION_BYTE_CLI 0xfa // CLI instruction
 #define INSTRUMENTATION_BYTE_INT3 0xcc // INT 3 instruction

Copied: harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_asm_em64t.s (from r639256, harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_asm_em64t.s)
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_asm_em64t.s?p2=harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_asm_em64t.s&p1=harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_asm_em64t.s&r1=639256&r2=639339&rev=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_asm_em64t.s (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_asm_em64t.s Thu Mar 20 09:08:58 2008
@@ -41,11 +41,11 @@
 // uint32 eflags;; 88h
 // };
 //
-// void port_transfer_to_regs(Registers* regs)
+// void port_transfer_to_regs_asm(Registers* regs)
 
-.globl port_transfer_to_regs
-	.type	port_transfer_to_regs, @function
-port_transfer_to_regs:
+.globl port_transfer_to_regs_asm
+       .type   port_transfer_to_regs_asm, @function
+port_transfer_to_regs_asm:
     movq    %rdi, %rdx // regs pointer (1st param - RDI) -> RDX
 
     movq    0x08(%rdx), %rbp // RBP field
@@ -116,5 +116,5 @@
 port_longjump_stub:
 //    movq    128(%rsp), %rdi // load RDI with the address of saved Registers
     movq    (%rsp), %rdi // load RDI with the address of saved Registers
-    callq   port_transfer_to_regs   // restore context
+    callq   port_transfer_to_regs_asm // restore context
     ret                             // dummy RET - unreachable

Added: harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_em64t.cpp?rev=639339&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_em64t.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_em64t.cpp Thu Mar 20 09:08:58 2008
@@ -0,0 +1,149 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+#include <stdarg.h>
+#include "signals_internal.h"
+
+
+extern "C" void port_longjump_stub(void);
+#define DIR_FLAG ((uint32)0x00000400)
+
+void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
+{
+    void** sp;
+    va_list ap;
+    int i;
+    size_t align;
+    void** p_pregs;
+    size_t rcount =
+        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
+
+    if (!regs)
+        return;
+
+    sp = (void**)regs->rsp - 16 - 1; /* preserve 128-bytes 'red zone' */
+    *sp = (void*)regs->rip;
+    align = !((rcount & 1) ^ (((uint64)sp & sizeof(void*)) != 0));
+    p_pregs = sp - rcount - align - 1;
+    sp = sp - rcount;
+    *((Registers*)sp) = *regs;
+    *p_pregs = (void*)sp;
+
+//    sp = p_pregs - 16 - 1; /* preserve 128-bytes 'red zone' */
+    sp = p_pregs - 1; /* set sp to return address */
+
+    va_start(ap, num);
+
+    if (num > 0)
+    {
+        void* arg = va_arg(ap, void*);
+        if (arg == regs)
+            regs->rdi = (uint64)(*p_pregs); /* Replace 1st arg */
+        else
+            regs->rdi = (uint64)arg;
+    }
+
+    if (num > 1)
+        regs->rsi = (uint64)va_arg(ap, void*);
+
+    if (num > 2)
+        regs->rdx = (uint64)va_arg(ap, void*);
+
+    if (num > 3)
+        regs->rcx = (uint64)va_arg(ap, void*);
+
+    if (num > 4)
+        regs->r8 = (uint64)va_arg(ap, void*);
+
+    if (num > 5)
+        regs->r9 = (uint64)va_arg(ap, void*);
+
+    *sp = (void*)&port_longjump_stub;
+    regs->rsp = (uint64)sp;
+    regs->rip = (uint64)fn;
+    regs->eflags = regs->eflags & ~DIR_FLAG;
+}
+
+void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
+{
+    void** sp;
+    va_list ap;
+    int i;
+    size_t align;
+    void** p_pregs;
+    size_t rcount =
+        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
+    Registers regs;
+
+    if (!pregs)
+        return;
+
+    regs = *pregs;
+
+    sp = (void**)regs.rsp - 16 - 1; /* preserve 128-bytes 'red zone' */
+    *sp = (void*)regs.rip;
+    align = !((rcount & 1) ^ (((uint64)sp & sizeof(void*)) != 0));
+    p_pregs = sp - rcount - align - 1;
+    sp = sp - rcount;
+    *((Registers*)sp) = regs;
+    *p_pregs = (void*)sp;
+
+//    sp = p_pregs - 16 - 1; /* preserve 128-bytes 'red zone' */
+    sp = p_pregs - 1; /* set sp to return address */
+
+    va_start(ap, num);
+
+    if (num > 0)
+    {
+        void* arg = va_arg(ap, void*);
+        if (arg == pregs)
+            regs.rdi = (uint64)(*p_pregs); /* Replace 1st arg */
+        else
+            regs.rdi = (uint64)arg;
+    }
+
+    if (num > 1)
+        regs.rsi = (uint64)va_arg(ap, void*);
+
+    if (num > 2)
+        regs.rdx = (uint64)va_arg(ap, void*);
+
+    if (num > 3)
+        regs.rcx = (uint64)va_arg(ap, void*);
+
+    if (num > 4)
+        regs.r8 = (uint64)va_arg(ap, void*);
+
+    if (num > 5)
+        regs.r9 = (uint64)va_arg(ap, void*);
+
+    *sp = (void*)&port_longjump_stub;
+    regs.rsp = (uint64)sp;
+    regs.rip = (uint64)fn;
+    regs.eflags = regs.eflags & ~DIR_FLAG;
+
+    port_transfer_to_regs(&regs);
+}
+
+// Workaround for improper -fPIC processing for assembler files
+extern "C" void port_transfer_to_regs_asm(Registers* regs);
+
+void port_transfer_to_regs(Registers* regs)
+{
+    port_transfer_to_regs_asm(regs);
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_em64t.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_ia32.cpp?rev=639339&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_ia32.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_ia32.cpp Thu Mar 20 09:08:58 2008
@@ -0,0 +1,105 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+
+#include <stdarg.h>
+#include "signals_internal.h"
+
+
+extern "C" void port_longjump_stub(void);
+#define DIR_FLAG ((uint32)0x00000400)
+
+void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
+{
+    void** sp;
+    va_list ap;
+    int i;
+    size_t rcount =
+        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
+
+    if (!regs)
+        return;
+
+    sp = (void**)regs->esp - 1;
+    *sp = (void*)regs->eip;
+    sp = sp - rcount - 1;
+    *((Registers*)(sp + 1)) = *regs;
+    *sp = (void*)(sp + 1);
+    regs->ebp = (uint32)sp;
+
+    sp = sp - num - 1;
+
+    va_start(ap, num);
+
+    for (i = 1; i <= num; i = i + 1)
+    {
+        void* arg = va_arg(ap, void*);
+
+        if (i == 1 && arg == regs)
+            sp[i] = *((void**)regs->ebp); /* Replace 1st arg */
+        else
+            sp[i] = arg;
+    }
+
+    *sp = (void*)&port_longjump_stub;
+    regs->esp = (uint32)sp;
+    regs->eip = (uint32)fn;
+    regs->eflags = regs->eflags & ~DIR_FLAG;
+}
+
+void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
+{
+    void** sp;
+    va_list ap;
+    int i;
+    size_t rcount =
+        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
+    Registers regs;
+
+    if (!pregs)
+        return;
+
+    regs = *pregs;
+
+    sp = (void**)regs.esp - 1;
+    *sp = (void*)regs.eip;
+    sp = sp - rcount - 1;
+    *((Registers*)(sp + 1)) = regs;
+    *sp = (void*)(sp + 1);
+    regs.ebp = (uint32)sp;
+
+    sp = sp - num - 1;
+
+    va_start(ap, num);
+
+    for (i = 1; i <= num; i = i + 1)
+    {
+        void* arg = va_arg(ap, void*);
+
+        if (i == 1 && arg == pregs)
+            sp[i] = *((void**)regs.ebp); /* Replace 1st arg */
+        else
+            sp[i] = arg;
+    }
+
+    *sp = (void*)&port_longjump_stub;
+    regs.esp = (uint32)sp;
+    regs.eip = (uint32)fn;
+    regs.eflags = regs.eflags & ~DIR_FLAG;
+
+    port_transfer_to_regs(&regs);
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/port/src/signals/linux/signals_ia32.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_asm_em64t.asm (from r639256, harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.asm)
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_asm_em64t.asm?p2=harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_asm_em64t.asm&p1=harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.asm&r1=639256&r2=639339&rev=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.asm (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_asm_em64t.asm Thu Mar 20 09:08:58 2008
@@ -1,8 +1,10 @@
-PUBLIC  vectored_exception_handler
-EXTRN   vectored_exception_handler_internal:PROC
 
 _TEXT   SEGMENT
 
+
+PUBLIC  vectored_exception_handler
+EXTRN   vectored_exception_handler_internal:PROC
+
 vectored_exception_handler PROC
 
 ; LONG NTAPI vectored_exception_handler(LPEXCEPTION_POINTERS nt_exception)
@@ -21,6 +23,118 @@
     ret
 
 vectored_exception_handler ENDP
+
+
+; struct Registers {
+; uint64 rsp;   ; 00h
+; uint64 rbp;   ; 08h
+; uint64 rip;   ; 10h
+; // callee-saved
+; uint64 rbx;   ; 18h
+; uint64 r12;   ; 20h
+; uint64 r13;   ; 28h
+; uint64 r14;   ; 30h
+; uint64 r15;   ; 38h
+; // scratched
+; uint64 rax;   ; 40h
+; uint64 rcx;   ; 48h
+; uint64 rdx;   ; 50h
+; uint64 rsi;   ; 58h
+; uint64 rdi;   ; 60h
+; uint64 r8;    ; 68h
+; uint64 r9;    ; 70h
+; uint64 r10;   ; 78h
+; uint64 r11;   ; 80h
+;
+; uint32 eflags;; 88h
+; };
+;
+; void port_transfer_to_regs(Registers* regs)
+
+PUBLIC  port_transfer_to_regs
+
+port_transfer_to_regs PROC
+
+    mov     rdx, rcx ; regs pointer (1st param - RCX) -> RDX
+
+    mov     rbp, qword ptr [rdx+08h] ; RBP field
+    mov     rbx, qword ptr [rdx+18h] ; RBX field
+    mov     r12, qword ptr [rdx+20h] ; R12 field
+    mov     r13, qword ptr [rdx+28h] ; R13 field
+    mov     r14, qword ptr [rdx+30h] ; R14 field
+    mov     r15, qword ptr [rdx+38h] ; R15 field
+    mov     rsi, qword ptr [rdx+58h] ; RSI field
+    mov     rdi, qword ptr [rdx+60h] ; RDI field
+    mov     r8,  qword ptr [rdx+68h] ; R8 field
+    mov     r9,  qword ptr [rdx+70h] ; R9 field
+    mov     r10, qword ptr [rdx+78h] ; R10 field
+    mov     r11, qword ptr [rdx+80h] ; R11 field
+
+    mov     rax, qword ptr [rdx+00h] ; (new RSP) -> RAX
+    mov     qword ptr [rsp], rax     ; (new RSP) -> [RSP] for future use
+    mov     rcx, qword ptr [rdx+10h] ; (new RIP) -> RCX
+    mov     qword ptr [rax-88h],rcx  ; (new RIP) -> [(new RSP) - 128 - 8]
+    mov     rax, qword ptr [rdx+40h] ; RAX field
+
+    movzx   rcx, word ptr [rdx+88h]  ; (word)EFLAGS -> RCX
+    test    rcx, rcx
+    je      __skipefl__
+    pushfq
+    and     dword ptr [rsp], 003F7202h ; Clear OF, DF, TF, SF, ZF, AF, PF, CF
+    and     ecx, 00000CD5h           ; Clear all except OF, DF, SF, ZF, AF, PF, CF
+    or      dword ptr [rsp], ecx
+    popfq                            ; restore RFLAGS
+__skipefl__:
+
+    mov     rcx, qword ptr [rdx+48h] ; RCX field
+    mov     rdx, qword ptr [rdx+50h] ; RDX field
+
+    mov     rsp, qword ptr [rsp]     ; load new RSP
+    jmp     qword ptr [rsp-88h]      ; JMP to new RIP
+
+port_transfer_to_regs ENDP
+
+
+; void port_longjump_stub(void)
+;
+; after returning from the called function, RSP points to the 2 argument
+; slots in the stack. Saved Registers structure pointer is (RSP + 48)
+;
+; | interrupted |
+; |  program    | <- RSP where the program was interrupted by exception
+; |-------------|
+; | 0x80 bytes  | <- preserved stack area - we will not change it
+; |-------------|
+; | return addr |
+; | from stub   | <- for using in port_transfer_to_regs as [(new RSP) - 128 - 8]
+; |-------------|
+; |    saved    |
+; |  Registers  | <- to restore register context
+; |-------------|
+; | [alignment] | <- align Regs pointer to 16-bytes boundary
+; |-------------|
+; |  pointer to |
+; |  saved Regs | <- (RSP + 48)
+; |-------------|
+; |    arg 5    | <- present even if not used
+; |-------------|
+; |    arg 4    | <- present even if not used
+; |-------------|
+; |  32 bytes   | <- 'red zone' for argument registers flushing
+; |-------------|
+; | return addr |
+; |  from 'fn'  | <- address to return to the port_longjump_stub
+; |-------------|
+
+PUBLIC  port_longjump_stub
+
+port_longjump_stub PROC
+
+    mov     rcx, qword ptr [rsp + 48] ; load RCX with the address of saved Registers
+    call    port_transfer_to_regs   ; restore context
+    ret                             ; dummy RET - unreachable
+port_longjump_stub ENDP
+
 
 _TEXT   ENDS
 

Added: harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.cpp?rev=639339&view=auto
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.cpp (added)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.cpp Thu Mar 20 09:08:58 2008
@@ -0,0 +1,137 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include "signals_internal.h"
+#define ANSI
+#include <stdarg.h>
+
+
+extern "C" void port_longjump_stub(void);
+#define DIR_FLAG ((uint32)0x00000400)
+
+void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
+{
+    void** sp;
+    va_list ap;
+    int i;
+    size_t align;
+    void** p_pregs;
+    size_t rcount =
+        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
+
+    if (!regs)
+        return;
+
+    sp = (void**)regs->rsp - 16 - 1; /* preserve 128-bytes area */
+    *sp = (void*)regs->rip;
+    align = !((rcount & 1) ^ (((uint64)sp & sizeof(void*)) != 0));
+    p_pregs = sp - rcount - align - 1;
+    sp = sp - rcount;
+    *((Registers*)sp) = *regs;
+    *p_pregs = (void*)sp;
+
+    sp = p_pregs - 6 - 1;
+
+    va_start(ap, num);
+
+    if (num > 0)
+    {
+        void* arg = va_arg(ap, void*);
+        if (arg == regs)
+            regs->rcx = (uint64)(*p_pregs); /* Replace 1st arg */
+        else
+            regs->rcx = (uint64)arg;
+    }
+
+    if (num > 1)
+        regs->rdx = (uint64)va_arg(ap, void*);
+
+    if (num > 2)
+        regs->r8 = (uint64)va_arg(ap, void*);
+
+    if (num > 3)
+        regs->r9 = (uint64)va_arg(ap, void*);
+
+    for (i = 5; i <= num; i = i + 1)
+    {
+        sp[i] = va_arg(ap, void*);
+    }
+
+    *sp = (void*)&port_longjump_stub;
+    regs->rsp = (uint64)sp;
+    regs->rip = (uint64)fn;
+    regs->eflags = regs->eflags & ~DIR_FLAG;
+}
+
+void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
+{
+    void** sp;
+    va_list ap;
+    int i;
+    size_t align;
+    void** p_pregs;
+    size_t rcount =
+        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
+    Registers regs;
+
+    if (!pregs)
+        return;
+
+    regs = *pregs;
+
+    sp = (void**)regs.rsp - 16 - 1; /* preserve 128-bytes area */
+    *sp = (void*)regs.rip;
+    align = !((rcount & 1) ^ (((uint64)sp & sizeof(void*)) != 0));
+    p_pregs = sp - rcount - align - 1;
+    sp = sp - rcount;
+    *((Registers*)sp) = regs;
+    *p_pregs = (void*)sp;
+
+    sp = p_pregs - 6 - 1;
+
+    va_start(ap, num);
+
+    if (num > 0)
+    {
+        void* arg = va_arg(ap, void*);
+        if (arg == pregs)
+            regs.rcx = (uint64)(*p_pregs); /* Replace 1st arg */
+        else
+            regs.rcx = (uint64)arg;
+    }
+
+    if (num > 1)
+        regs.rdx = (uint64)va_arg(ap, void*);
+
+    if (num > 2)
+        regs.r8 = (uint64)va_arg(ap, void*);
+
+    if (num > 3)
+        regs.r9 = (uint64)va_arg(ap, void*);
+
+    for (i = 5; i <= num; i = i + 1)
+    {
+        sp[i] = va_arg(ap, void*);
+    }
+
+    *sp = (void*)&port_longjump_stub;
+    regs.rsp = (uint64)sp;
+    regs.rip = (uint64)fn;
+    regs.eflags = regs.eflags & ~DIR_FLAG;
+
+    port_transfer_to_regs(&regs);
+}

Propchange: harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_em64t.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_ia32.cpp?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_ia32.cpp Thu Mar 20 09:08:58 2008
@@ -16,6 +16,8 @@
  */
 
 #include "signals_internal.h"
+#define ANSI
+#include <stdarg.h>
 
 
 LONG __declspec(naked) NTAPI vectored_exception_handler(LPEXCEPTION_POINTERS nt_exception)
@@ -32,4 +34,89 @@
     pop     ebp
     ret     4
     }
+}
+
+
+extern "C" void port_longjump_stub(void);
+#define DIR_FLAG ((uint32)0x00000400)
+
+void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
+{
+    void** sp;
+    va_list ap;
+    int i;
+    size_t rcount =
+        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
+
+    if (!regs)
+        return;
+
+    sp = (void**)regs->esp - 1;
+    *sp = (void*)regs->eip;
+    sp = sp - rcount - 1;
+    *((Registers*)(sp + 1)) = *regs;
+    *sp = (void*)(sp + 1);
+    regs->ebp = (uint32)sp;
+
+    sp = sp - num - 1;
+
+    va_start(ap, num);
+
+    for (i = 1; i <= num; i = i + 1)
+    {
+        void* arg = va_arg(ap, void*);
+
+        if (i == 1 && arg == regs)
+            sp[i] = *((void**)regs->ebp); /* Replace 1st arg */
+        else
+            sp[i] = arg;
+    }
+
+    *sp = (void*)&port_longjump_stub;
+    regs->esp = (uint32)sp;
+    regs->eip = (uint32)fn;
+    regs->eflags = regs->eflags & ~DIR_FLAG;
+}
+
+void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
+{
+    void** sp;
+    va_list ap;
+    int i;
+    size_t rcount =
+        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
+    Registers regs;
+
+    if (!pregs)
+        return;
+
+    regs = *pregs;
+
+    sp = (void**)regs.esp - 1;
+    *sp = (void*)regs.eip;
+    sp = sp - rcount - 1;
+    *((Registers*)(sp + 1)) = regs;
+    *sp = (void*)(sp + 1);
+    regs.ebp = (uint32)sp;
+
+    sp = sp - num - 1;
+
+    va_start(ap, num);
+
+    for (i = 1; i <= num; i = i + 1)
+    {
+        void* arg = va_arg(ap, void*);
+
+        if (i == 1 && arg == pregs)
+            sp[i] = *((void**)regs.ebp); /* Replace 1st arg */
+        else
+            sp[i] = arg;
+    }
+
+    *sp = (void*)&port_longjump_stub;
+    regs.esp = (uint32)sp;
+    regs.eip = (uint32)fn;
+    regs.eflags = regs.eflags & ~DIR_FLAG;
+
+    port_transfer_to_regs(&regs);
 }

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c Thu Mar 20 09:08:58 2008
@@ -64,124 +64,3 @@
     uc->uc_mcontext.gregs[REG_R15] = regs->r15;
     uc->uc_mcontext.gregs[REG_EFL] = regs->eflags;
 }
-
-
-void port_longjump_stub(void);
-#define DIR_FLAG ((uint32)0x00000400)
-
-void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
-{
-    void** sp;
-    va_list ap;
-    int i;
-    size_t align;
-    void** p_pregs;
-    size_t rcount =
-        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
-
-    if (!regs)
-        return;
-
-    sp = (void**)regs->rsp - 16 - 1; /* preserve 128-bytes 'red zone' */
-    *sp = (void*)regs->rip;
-    align = !((rcount & 1) ^ (((uint64)sp & sizeof(void*)) != 0));
-    p_pregs = sp - rcount - align - 1;
-    sp = sp - rcount;
-    *((Registers*)sp) = *regs;
-    *p_pregs = (void*)sp;
-
-//    sp = p_pregs - 16 - 1; /* preserve 128-bytes 'red zone' */
-    sp = p_pregs - 1; /* set sp to return address */
-
-    va_start(ap, num);
-
-    if (num > 0)
-    {
-        void* arg = va_arg(ap, void*);
-        if (arg == regs)
-            regs->rdi = (uint64)(*p_pregs); /* Replace 1st arg */
-        else
-            regs->rdi = (uint64)arg;
-    }
-
-    if (num > 1)
-        regs->rsi = (uint64)va_arg(ap, void*);
-
-    if (num > 2)
-        regs->rdx = (uint64)va_arg(ap, void*);
-
-    if (num > 3)
-        regs->rcx = (uint64)va_arg(ap, void*);
-
-    if (num > 4)
-        regs->r8 = (uint64)va_arg(ap, void*);
-
-    if (num > 5)
-        regs->r9 = (uint64)va_arg(ap, void*);
-
-    *sp = (void*)&port_longjump_stub;
-    regs->rsp = (uint64)sp;
-    regs->rip = (uint64)fn;
-    regs->eflags = regs->eflags & ~DIR_FLAG;
-}
-
-void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
-{
-    void** sp;
-    va_list ap;
-    int i;
-    size_t align;
-    void** p_pregs;
-    size_t rcount =
-        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
-    Registers regs;
-
-    if (!pregs)
-        return;
-
-    regs = *pregs;
-
-    sp = (void**)regs.rsp - 16 - 1; /* preserve 128-bytes 'red zone' */
-    *sp = (void*)regs.rip;
-    align = !((rcount & 1) ^ (((uint64)sp & sizeof(void*)) != 0));
-    p_pregs = sp - rcount - align - 1;
-    sp = sp - rcount;
-    *((Registers*)sp) = regs;
-    *p_pregs = (void*)sp;
-
-//    sp = p_pregs - 16 - 1; /* preserve 128-bytes 'red zone' */
-    sp = p_pregs - 1; /* set sp to return address */
-
-    va_start(ap, num);
-
-    if (num > 0)
-    {
-        void* arg = va_arg(ap, void*);
-        if (arg == pregs)
-            regs.rdi = (uint64)(*p_pregs); /* Replace 1st arg */
-        else
-            regs.rdi = (uint64)arg;
-    }
-
-    if (num > 1)
-        regs.rsi = (uint64)va_arg(ap, void*);
-
-    if (num > 2)
-        regs.rdx = (uint64)va_arg(ap, void*);
-
-    if (num > 3)
-        regs.rcx = (uint64)va_arg(ap, void*);
-
-    if (num > 4)
-        regs.r8 = (uint64)va_arg(ap, void*);
-
-    if (num > 5)
-        regs.r9 = (uint64)va_arg(ap, void*);
-
-    *sp = (void*)&port_longjump_stub;
-    regs.rsp = (uint64)sp;
-    regs.rip = (uint64)fn;
-    regs.eflags = regs.eflags & ~DIR_FLAG;
-
-    port_transfer_to_regs(&regs);
-}

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ia32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ia32.c?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ia32.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ia32.c Thu Mar 20 09:08:58 2008
@@ -83,88 +83,3 @@
 #else
 #error need to add correct mcontext_t lookup for registers
 #endif
-
-
-void port_longjump_stub(void);
-#define DIR_FLAG ((uint32)0x00000400)
-
-void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
-{
-    void** sp;
-    va_list ap;
-    int i;
-    size_t rcount =
-        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
-
-    if (!regs)
-        return;
-
-    sp = (void**)regs->esp - 1;
-    *sp = (void*)regs->eip;
-    sp = sp - rcount - 1;
-    *((Registers*)(sp + 1)) = *regs;
-    *sp = (void*)(sp + 1);
-    regs->ebp = (uint32)sp;
-
-    sp = sp - num - 1;
-
-    va_start(ap, num);
-
-    for (i = 1; i <= num; i = i + 1)
-    {
-        void* arg = va_arg(ap, void*);
-
-        if (i == 1 && arg == regs)
-            sp[i] = *((void**)regs->ebp); /* Replace 1st arg */
-        else
-            sp[i] = arg;
-    }
-
-    *sp = (void*)&port_longjump_stub;
-    regs->esp = (uint32)sp;
-    regs->eip = (uint32)fn;
-    regs->eflags = regs->eflags & ~DIR_FLAG;
-}
-
-void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
-{
-    void** sp;
-    va_list ap;
-    int i;
-    size_t rcount =
-        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
-    Registers regs;
-
-    if (!pregs)
-        return;
-
-    regs = *pregs;
-
-    sp = (void**)regs.esp - 1;
-    *sp = (void*)regs.eip;
-    sp = sp - rcount - 1;
-    *((Registers*)(sp + 1)) = regs;
-    *sp = (void*)(sp + 1);
-    regs.ebp = (uint32)sp;
-
-    sp = sp - num - 1;
-
-    va_start(ap, num);
-
-    for (i = 1; i <= num; i = i + 1)
-    {
-        void* arg = va_arg(ap, void*);
-
-        if (i == 1 && arg == pregs)
-            sp[i] = *((void**)regs.ebp); /* Replace 1st arg */
-        else
-            sp[i] = arg;
-    }
-
-    *sp = (void*)&port_longjump_stub;
-    regs.esp = (uint32)sp;
-    regs.eip = (uint32)fn;
-    regs.eflags = regs.eflags & ~DIR_FLAG;
-
-    port_transfer_to_regs(&regs);
-}

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ipf.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ipf.c?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ipf.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_ipf.c Thu Mar 20 09:08:58 2008
@@ -22,14 +22,6 @@
 #include "port_thread.h"
 
 
-void port_transfer_to_regs(Registers* regs)
-{
-    // FIXME: not implemented
-    fprintf(stderr, "FIXME: port_transfer_to_regs: not implemented\n");
-    assert(0);
-    abort();
-}
-
 void port_thread_context_to_regs(Registers* regs, ucontext_t* uc)
 {
     memcpy(regs->gr, uc->uc_mcontext.sc_gr, sizeof(regs->gr));
@@ -54,20 +46,4 @@
     uc->uc_mcontext.sc_ar_pfs  = regs->pfs;
     uc->uc_mcontext.sc_ar_bsp  = (uint64)regs->bsp;
     uc->uc_mcontext.sc_ip      = regs->ip;
-}
-
-void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
-{
-    // FIXME: not implemented
-    fprintf(stderr, "FIXME: port_set_longjump_regs: not implemented\n");
-    assert(0);
-    abort();
-}
-
-void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
-{
-    // FIXME: not implemented
-    fprintf(stderr, "FIXME: port_transfer_to_function: not implemented\n");
-    assert(0);
-    abort();
 }

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_em64t.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_em64t.c?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_em64t.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_em64t.c Thu Mar 20 09:08:58 2008
@@ -67,125 +67,3 @@
 
     pcontext->EFlags = regs->eflags;
 }
-
-void* regs_get_sp(Registers* pregs)
-{
-    return (void*)pregs->rsp;
-}
-
-
-void port_longjump_stub(void);
-#define DIR_FLAG ((uint32)0x00000400)
-
-void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
-{
-    void** sp;
-    va_list ap;
-    int i;
-    size_t align;
-    void** p_pregs;
-    size_t rcount =
-        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
-
-    if (!regs)
-        return;
-
-    sp = (void**)regs->rsp - 16 - 1; /* preserve 128-bytes area */
-    *sp = (void*)regs->rip;
-    align = !((rcount & 1) ^ (((uint64)sp & sizeof(void*)) != 0));
-    p_pregs = sp - rcount - align - 1;
-    sp = sp - rcount;
-    *((Registers*)sp) = *regs;
-    *p_pregs = (void*)sp;
-
-    sp = p_pregs - 6 - 1;
-
-    va_start(ap, num);
-
-    if (num > 0)
-    {
-        void* arg = va_arg(ap, void*);
-        if (arg == regs)
-            regs->rcx = (uint64)(*p_pregs); /* Replace 1st arg */
-        else
-            regs->rcx = (uint64)arg;
-    }
-
-    if (num > 1)
-        regs->rdx = (uint64)va_arg(ap, void*);
-
-    if (num > 2)
-        regs->r8 = (uint64)va_arg(ap, void*);
-
-    if (num > 3)
-        regs->r9 = (uint64)va_arg(ap, void*);
-
-    for (i = 5; i <= num; i = i + 1)
-    {
-        sp[i] = va_arg(ap, void*);
-    }
-
-    *sp = (void*)&port_longjump_stub;
-    regs->rsp = (uint64)sp;
-    regs->rip = (uint64)fn;
-    regs->eflags = regs->eflags & ~DIR_FLAG;
-}
-
-void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
-{
-    void** sp;
-    va_list ap;
-    int i;
-    size_t align;
-    void** p_pregs;
-    size_t rcount =
-        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
-    Registers regs;
-
-    if (!pregs)
-        return;
-
-    regs = *pregs;
-
-    sp = (void**)regs.rsp - 16 - 1; /* preserve 128-bytes area */
-    *sp = (void*)regs.rip;
-    align = !((rcount & 1) ^ (((uint64)sp & sizeof(void*)) != 0));
-    p_pregs = sp - rcount - align - 1;
-    sp = sp - rcount;
-    *((Registers*)sp) = regs;
-    *p_pregs = (void*)sp;
-
-    sp = p_pregs - 6 - 1;
-
-    va_start(ap, num);
-
-    if (num > 0)
-    {
-        void* arg = va_arg(ap, void*);
-        if (arg == pregs)
-            regs.rcx = (uint64)(*p_pregs); /* Replace 1st arg */
-        else
-            regs.rcx = (uint64)arg;
-    }
-
-    if (num > 1)
-        regs.rdx = (uint64)va_arg(ap, void*);
-
-    if (num > 2)
-        regs.r8 = (uint64)va_arg(ap, void*);
-
-    if (num > 3)
-        regs.r9 = (uint64)va_arg(ap, void*);
-
-    for (i = 5; i <= num; i = i + 1)
-    {
-        sp[i] = va_arg(ap, void*);
-    }
-
-    *sp = (void*)&port_longjump_stub;
-    regs.rsp = (uint64)sp;
-    regs.rip = (uint64)fn;
-    regs.eflags = regs.eflags & ~DIR_FLAG;
-
-    port_transfer_to_regs(&regs);
-}

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_ia32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_ia32.c?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_ia32.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_ia32.c Thu Mar 20 09:08:58 2008
@@ -47,88 +47,3 @@
     context->Edx = regs->edx;
     context->EFlags = regs->eflags;
 }
-
-
-void port_longjump_stub(void);
-#define DIR_FLAG ((uint32)0x00000400)
-
-void port_set_longjump_regs(void* fn, Registers* regs, int num, ...)
-{
-    void** sp;
-    va_list ap;
-    int i;
-    size_t rcount =
-        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
-
-    if (!regs)
-        return;
-
-    sp = (void**)regs->esp - 1;
-    *sp = (void*)regs->eip;
-    sp = sp - rcount - 1;
-    *((Registers*)(sp + 1)) = *regs;
-    *sp = (void*)(sp + 1);
-    regs->ebp = (uint32)sp;
-
-    sp = sp - num - 1;
-
-    va_start(ap, num);
-
-    for (i = 1; i <= num; i = i + 1)
-    {
-        void* arg = va_arg(ap, void*);
-
-        if (i == 1 && arg == regs)
-            sp[i] = *((void**)regs->ebp); /* Replace 1st arg */
-        else
-            sp[i] = arg;
-    }
-
-    *sp = (void*)&port_longjump_stub;
-    regs->esp = (uint32)sp;
-    regs->eip = (uint32)fn;
-    regs->eflags = regs->eflags & ~DIR_FLAG;
-}
-
-void port_transfer_to_function(void* fn, Registers* pregs, int num, ...)
-{
-    void** sp;
-    va_list ap;
-    int i;
-    size_t rcount =
-        (sizeof(Registers) + sizeof(void*) - 1) / sizeof(void*);
-    Registers regs;
-
-    if (!pregs)
-        return;
-
-    regs = *pregs;
-
-    sp = (void**)regs.esp - 1;
-    *sp = (void*)regs.eip;
-    sp = sp - rcount - 1;
-    *((Registers*)(sp + 1)) = regs;
-    *sp = (void*)(sp + 1);
-    regs.ebp = (uint32)sp;
-
-    sp = sp - num - 1;
-
-    va_start(ap, num);
-
-    for (i = 1; i <= num; i = i + 1)
-    {
-        void* arg = va_arg(ap, void*);
-
-        if (i == 1 && arg == pregs)
-            sp[i] = *((void**)regs.ebp); /* Replace 1st arg */
-        else
-            sp[i] = arg;
-    }
-
-    *sp = (void*)&port_longjump_stub;
-    regs.esp = (uint32)sp;
-    regs.eip = (uint32)fn;
-    regs.eflags = regs.eflags & ~DIR_FLAG;
-
-    port_transfer_to_regs(&regs);
-}

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c?rev=639339&r1=639338&r2=639339&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c Thu Mar 20 09:08:58 2008
@@ -16,7 +16,7 @@
  */
 
 
-#include <apr_atomic.h>
+#include <port_atomic.h>
 #include "port_thread.h"
 
 
@@ -297,13 +297,13 @@
 
 static int suspend_init_lock()
 {
-    static uint32 initialized = 0;
+    static uint16 initialized = 0;
 
     if (!initialized)
     {
         // Critical section should be initialized only once,
         // do nothing in case someone else already initialized it.
-        if (apr_atomic_cas32((volatile uint32*)&initialized, 1, 0) == 0)
+        if (port_atomic_cas16((volatile uint16*)&initialized, 1, 0) == 0)
             InitializeCriticalSectionAndSpinCount(&g_crit_section, 400);
     }