Re: Porting to Darwin

Brian de Alwis <[email protected]> Mon, 30 Jun 2008 22:50:57 -0700 (PDT)
Newsgroups gmane.comp.lang.smalltalk.strongtalk
Message-ID <6d295bcc-9f14-4e2a-927e-22df6eb07b16@f36g2000hsa.googlegroups.com>
Hi Steve.  I've attached my Darwin patches here.  I've rearranged your
posting slightly to explain Darwin first.  I think that will help in
interpreting my comments about the patches.

> Pardon my ignorance, but I have no knowledge of the Darwin
> environment. Is StatBuffer relevant to Darwin? Does Darwin have a libc
> equivalent? If so, one option would be to create a DarwinStatBuffer,
> which may or not subclass the existing StatBuffer, and just override
> the offset and length accessors with appropriate values for Darwin.

You can think of Darwin as a BSD Unix user space overlaid on top of
the Mach microkernel.  From a development perspective, it looks like a
Unix/POSIX world with a bunch of extra libraries, called frameworks,
that provide windowing, inter-app communication, preferences,
accelerated graphics, etc.  That's why the Darwin port was so easy: it
leveraged the heavy lifting from the Linux port, with the help of
gcc's -mstackrealign.

So Darwin has stat/fstat and a 'struct stat', just like any other
Unix.  It has a libc, though it's really called libSystem.dylib, but
there's a symlink to libc.dylib too.  So the calling interface is the
same, with the same structures, etc.  But the order of a structure's
elements may be different, and that's true of other unices too.  So
Darwin will likely need a StatBuffer and so will any other new OS.

My concern with having a DarwinStatBuffer (and a NetBSDStatBuffer, and
FreeBSDStatBuffer, ...) is that we suffer an explosion and start
pushing environment details into the Smalltalk code.  But that's
something that can be dealt with later.

> > Unfortunately my Darwin-patched sources leads to a
> > failed assertion when filing in code, such as your ANSI exceptions.
>
> Which assertion fails? Is it an assertion in Smalltalk or an assertion
> in the VM? Can you send me your patches?

It's a VM assertion in Klass::local_lookup(symbolOop) at line 271:

     assert(mixin()->is_mixin(), "mixin must exist");

I've attached my patches here; the changes are in two parts, and are
straightforward:

  1. darwin independent: fixing minor issues to do with the build
process
     a) there are two copies of makedeps, in /makedeps and /tools/
makedeps:
        I removed /makedeps
     b) some minor win32 build issues, and use /tools/makedeps
     c) some additions to header files to get them to build
  2. darwin related:
     a) patched /tools/makedeps for Darwin/MacOSX
     b) cp -r build.linux build.darwin; hack appropriately
     c) cp vm/runtime/os_linux.cpp vm/runtime/os_darwin.cpp and hack
appropriately
     d) some Darwin-related #ifdefs to header files to get them to
build

You'll see in vm/prims/prim.cpp that I commented out the ebx stack
checking -- this was causing compilation issues on Darwin.

But there's nothing that jumps out at me as to why the Win32 VM is
failing that assertion.

> > But a VM built from a fresh set of sources works fine.  So I'm in the
> > middle of figuring out what part of my patches causes the issue.  (I
> > can't seem to figure out how to get VisualStudio to load the .pdb file
> > for debugging symbols though.)
>
> Strange about the symbols. Are you using the solution file under the
> build.win32 directory?

Yes.

The patches follow.

Brian.

=== removed directory 'makedeps'
=== removed directory 'build.win32/makedeps'

=== added directory 'build.darwin'
=== added file 'build.darwin/makedeps-platform.txt'
--- build.darwin/makedeps-platform.txt	1970-01-01 00:00:00 +0000
+++ build.darwin/makedeps-platform.txt	2008-06-19 04:19:50 +0000
@@ -0,0 +1,1 @@
+os = darwin

=== added file 'build.darwin/makefile'
--- build.darwin/makefile	1970-01-01 00:00:00 +0000
+++ build.darwin/makefile	2008-06-19 04:19:50 +0000
@@ -0,0 +1,94 @@
+# makefile for Strongtalk
+#
+# revision history
+#
-----------------------------------------------------------------------
+# 2007.02.20	[email protected]		file created
+#
-----------------------------------------------------------------------
+
+include ../build.darwin/makefile-macros.incl
+
+LIB_DIR = $(BIN_DIR)/asm_objs/COFF/converted
+TEST_DIRECTORIES	= $(TEST_SRC_DIR)/utilities \
+$(TEST_SRC_DIR)/runtime \
+$(TEST_SRC_DIR)/prims \
+$(TEST_SRC_DIR)/main \
+$(EASYUNIT_DIR)/src
+TEST-EXECUTABLE = $(BUILD_DIR)/strongtalk-test
+TEST_SHARED_LIB = $(BUILD_DIR)/strongtalk-test.so
+EXECUTABLE = $(BUILD_DIR)/strongtalk
+SHARED_LIB = $(BUILD_DIR)/strongtalk.so
+DIRECTORIES	= $(TEST_DIRECTORIES) \
+$(VM_SRC_DIR)/asm \
+$(VM_SRC_DIR)/code \
+$(VM_SRC_DIR)/compiler \
+$(VM_SRC_DIR)/disasm \
+$(VM_SRC_DIR)/interpreter \
+$(VM_SRC_DIR)/lookup \
+$(VM_SRC_DIR)/memory \
+$(VM_SRC_DIR)/oops \
+$(VM_SRC_DIR)/prims \
+$(VM_SRC_DIR)/recompiler \
+$(VM_SRC_DIR)/runtime \
+$(VM_SRC_DIR)/utilities
+WRK=$(shell pwd)
+
+ifneq ($(WRK),$(BUILD_DIR))
+$(warning "Running in $(WRK)")
+$(error "Must be run from build directory: $(BUILD_DIR)")
+endif
+
+#default: dependencies objects link test
+default: objects link test
+
+test:
+	export LD_LIBRARY_PATH=$(WRK)
+	$(TEST-EXECUTABLE) -b ../strongtalk.bst
+
+link:
+	g++ $(OPT) -o $(EXECUTABLE) -L/usr/lib `find $(VM_SRC_DIR) -name
"*.o"` -lpthread
+	g++ $(OPT) -o $(TEST-EXECUTABLE) $(TEST_SRC_DIR)/main/main.o \
+	    `find $(VM_SRC_DIR) -name "*.o"|grep -v main.o` \
+	    `find $(TEST_SRC_DIR) -name "*.o"|grep -v main.o` $
(EASYUNIT_DIR)/src/*.o \
+	    -lpthread
+
+#	g++ -v $(OPT) -shared -o $(SHARED_LIB) -L/usr/lib `find $
(VM_SRC_DIR) -name "*.o"|grep -v main.o` -lpthread
+#	g++ -v $(OPT) -o $(EXECUTABLE) -L/usr/lib $(VM_SRC_DIR)/*/main.o $
(SHARED_LIB)
+#	g++ -v $(OPT) -shared -o $(TEST_SHARED_LIB) -L/usr/lib `find $
(TEST_SRC_DIR) -name "*.o"|grep -v main.o` $(EASYUNIT_DIR)/src/*.o
+#	g++ -v $(OPT) -o $(TEST-EXECUTABLE) $(SHARED_LIB) $
(TEST_SHARED_LIB) $(TEST_SRC_DIR)/main/main.o
+
+objects: incls/_precompiled.incl.gch
+	for i in $(DIRECTORIES);\
+	do \
+		$(MAKE) $(MAKEFLAGS) -C $$i -f $(MAKE_DIR)/makefile.incl $@ || exit
$$?;\
+	done
+
+incls/_precompiled.incl.gch: $(BUILD_DIR)/includeDB.all
+	$(C++) -c -x c++-header -o $(BUILD_DIR)/incls/_precompiled.incl.gch -
g $(OPT) $(C++OPTIONS) $(DEFINES) $(INCL_PATH) incls/_precompiled.incl
+
+$(BUILD_DIR)/makedeps: $(TOOLS_SRC_DIR)/makedeps/makeDeps.cpp
+	$(C++) -o $@ $^
+#	$(C++) -fno-write-strings -o $@ $^
+
+dependencies: $(BUILD_DIR)/makedeps $(INCL_PLATFORM) $(BUILD_DIR)/
includeDB.all
+	$(BUILD_DIR)/makedeps $(INCL_PLATFORM) $(BUILD_DIR)/includeDB.all
+
+$(BUILD_DIR)/includeDB.all: $(INCL_DB1) $(INCL_DB2)
+	$(RMDIR) $(INCL_DIR)
+	$(RM) Dependencies.hh $(BUILD_DIR)/includeDB.all includeDB.current
+	$(MKDIR) $(INCL_DIR)
+	$(CAT) $(INCL_DB1) $(INCL_DB2) >> $(BUILD_DIR)/includeDB.all
+
+$(INCL_PLATFORM):
+	$(TOUCH) $@
+
+clean:
+	$(RMDIR) $(INCL_DIR)
+	$(RM) Dependencies.hh $(BUILD_DIR)/includeDB.all includeDB.current
+	$(RM) *~
+	for i in $(DIRECTORIES);\
+	do \
+		$(MAKE) $(MAKEFLAGS) -C $$i -f $(MAKE_DIR)/makefile.incl clean;\
+	done
+
+pristine: clean
+	$(RM) $(BUILD_DIR)/makedeps

=== added file 'build.darwin/makefile-macros.incl'
--- build.darwin/makefile-macros.incl	1970-01-01 00:00:00 +0000
+++ build.darwin/makefile-macros.incl	2008-06-19 04:19:50 +0000
@@ -0,0 +1,52 @@
+# common defs for makefiles
+
+
+# ROOT_DIR	= $(HOME)/strongtalk-r36-noasm6
+TEST_SRC_DIR 	= $(ROOT_DIR)/test
+VM_SRC_DIR 	= $(ROOT_DIR)/vm
+EASYUNIT_DIR	= $(ROOT_DIR)/easyunit
+TOOLS_SRC_DIR	= $(ROOT_DIR)/tools
+MAKE_DIR      	= $(ROOT_DIR)/build.darwin
+BUILD_DIR	= $(ROOT_DIR)/build
+BIN_DIR		= $(ROOT_DIR)/bin
+OPT=
+
+#C++OPTIONS= -fno-rtti -Wno-write-strings -fno-for-scope -fno-
operator-names -fms-extensions -ffriend-injection
+C++OPTIONS= -fno-rtti -Wno-write-strings -fno-for-scope -fno-operator-
names -fms-extensions
+
+INCL_PATH	= -I$(BUILD_DIR) \
+		    -I$(VM_SRC_DIR)/asm -I$(VM_SRC_DIR)/code \
+		    -I$(VM_SRC_DIR)/compiler -I$(VM_SRC_DIR)/disasm \
+		    -I$(VM_SRC_DIR)/interpreter -I$(VM_SRC_DIR)/lookup \
+		    -I$(VM_SRC_DIR)/memory -I$(VM_SRC_DIR)/oops \
+		    -I$(VM_SRC_DIR)/prims -I$(VM_SRC_DIR)/recompiler \
+		    -I$(VM_SRC_DIR)/runtime -I$(VM_SRC_DIR)/topIncludes \
+		    -I$(VM_SRC_DIR)/utilities \
+		    -I$(EASYUNIT_DIR)/easyunit
+
+INCL_DIR	= $(BUILD_DIR)/incls
+
+OS		= $(shell uname)
+
+RMDIR		= rm -rf
+MKDIR		= mkdir
+RM		= rm -rf
+CAT		= cat
+MV		= mv
+TOUCH		= touch
+
+ifeq ($(OS),Linux)
+OS_DEF		= -D__LINUX__
+else ifeq ($(OS),Darwin)
+OS_DEF		= -D__DARWIN__
+endif
+DEFINES		= -DDELTA_COMPILER -DASSERT -DDEBUG $(OS_DEF)
+
+CC	= gcc -mstackrealign
+C++	= g++ -mstackrealign
+ASM	= gcc -mstackrealign
+CFLAGS  = -Wall
+
+INCL_DB1	= $(VM_SRC_DIR)/deps/includeDB
+INCL_DB2	= $(VM_SRC_DIR)/deps/includeDB2
+INCL_PLATFORM	= $(MAKE_DIR)/makedeps-platform.txt

=== added file 'build.darwin/makefile.incl'
--- build.darwin/makefile.incl	1970-01-01 00:00:00 +0000
+++ build.darwin/makefile.incl	2008-06-19 04:19:50 +0000
@@ -0,0 +1,27 @@
+# makefile for strongtalk object files
+#
+# revision history
+#
----------------------------------------------------------------------
+# 2007.02.20	[email protected]		file created
+#	based on on work by [email protected] as posted to strongtalk
+#	mailing list
+#
----------------------------------------------------------------------
+
+include ../../build.darwin/makefile-macros.incl
+
+SRCS	= $(wildcard *.cpp)
+OBJS	= $(patsubst %.cpp,%.o,$(SRCS))
+
+#CXXOPTS= -fno-rtti -fno-const-strings -fno-for-scope -fno-operator-
names \
+#	    -fms-extensions -ffriend-injection
+CXXOPTS= -fno-rtti -fno-const-strings -fno-for-scope -fno-operator-
names \
+	    -fms-extensions
+
+%o: %cpp
+	$(C++) -c -g $(OPT) $(CXXOPTS) $(DEFINES) $(INCL_PATH) $<
+
+objects: $(OBJS)
+
+clean:
+	$(RM) $(OBJS)
+	$(RM) *~

=== modified file 'build.linux/makefile'
--- build.linux/makefile	2008-05-28 23:33:59 +0000
+++ build.linux/makefile	2008-06-19 04:19:50 +0000
@@ -52,7 +52,7 @@
 objects: incls/_precompiled.incl.gch
 	for i in $(DIRECTORIES);\
 	do \
-		make -C $$i -f $(MAKE_DIR)/makefile.incl $@;\
+		$(MAKE) $(MAKEFLAGS) -C $$i -f $(MAKE_DIR)/makefile.incl $@ || exit
$?;\
 	done

 incls/_precompiled.incl.gch: includeDB.all
@@ -79,7 +79,7 @@
 	$(RM) *~
 	for i in $(DIRECTORIES);\
 	do \
-		make -C $$i -f $(MAKE_DIR)/makefile.incl clean;\
+		$(MAKE) $(MAKEFLAGS) -C $$i -f $(MAKE_DIR)/makefile.incl clean ||
exit $?;\
 	done

 pristine: clean

=== modified file 'build.win32/strongtalk.sln'
--- build.win32/strongtalk.sln	2008-05-29 00:55:59 +0000
+++ build.win32/strongtalk.sln	2008-06-28 16:27:46 +0000
@@ -8,12 +8,10 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EasyUnit",
"easyunit\EasyUnit.vcproj", "{C594C167-71C2-4019-8A3B-F8C28069A0E6}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makedeps",
"makedeps\makedeps.vcproj", "{4C63951D-97E7-4846-8DD0-764CC4753D73}"
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strongtalk",
"strongtalk\strongtalk.vcproj", "{BFE5409B-5B2B-4667-A91A-
D5A5E7DC8A83}"
 	ProjectSection(ProjectDependencies) = postProject
-		{4C63951D-97E7-4846-8DD0-764CC4753D73} =
{4C63951D-97E7-4846-8DD0-764CC4753D73}
 		{C594C167-71C2-4019-8A3B-F8C28069A0E6} = {C594C167-71C2-4019-8A3B-
F8C28069A0E6}
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233} = {FD5B94F7-55C2-4C96-
B89E-32DC1A737233}
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "strongtalk-
test", "strongtalk-test\strongtalk-test.vcproj",
"{DDDCEC02-9CCF-4178-9596-E00D6F71C083}"
@@ -22,6 +20,8 @@
 		{BFE5409B-5B2B-4667-A91A-D5A5E7DC8A83} = {BFE5409B-5B2B-4667-A91A-
D5A5E7DC8A83}
 	EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "makedeps", "..
\tools\makedeps\makedeps.vcproj", "{FD5B94F7-55C2-4C96-
B89E-32DC1A737233}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32
@@ -46,14 +46,6 @@
 		{C594C167-71C2-4019-8A3B-F8C28069A0E6}.Product|Win32.Build.0 =
Release|Win32
 		{C594C167-71C2-4019-8A3B-F8C28069A0E6}.Release|Win32.ActiveCfg =
Release|Win32
 		{C594C167-71C2-4019-8A3B-F8C28069A0E6}.Release|Win32.Build.0 =
Release|Win32
-		{4C63951D-97E7-4846-8DD0-764CC4753D73}.Debug|Win32.ActiveCfg =
Debug|Win32
-		{4C63951D-97E7-4846-8DD0-764CC4753D73}.Debug|Win32.Build.0 = Debug|
Win32
-		{4C63951D-97E7-4846-8DD0-764CC4753D73}.Fast|Win32.ActiveCfg =
Release|Win32
-		{4C63951D-97E7-4846-8DD0-764CC4753D73}.Fast|Win32.Build.0 = Release|
Win32
-		{4C63951D-97E7-4846-8DD0-764CC4753D73}.Product|Win32.ActiveCfg =
Release|Win32
-		{4C63951D-97E7-4846-8DD0-764CC4753D73}.Product|Win32.Build.0 =
Release|Win32
-		{4C63951D-97E7-4846-8DD0-764CC4753D73}.Release|Win32.ActiveCfg =
Release|Win32
-		{4C63951D-97E7-4846-8DD0-764CC4753D73}.Release|Win32.Build.0 =
Release|Win32
 		{BFE5409B-5B2B-4667-A91A-D5A5E7DC8A83}.Debug|Win32.ActiveCfg =
Debug|Win32
 		{BFE5409B-5B2B-4667-A91A-D5A5E7DC8A83}.Debug|Win32.Build.0 = Debug|
Win32
 		{BFE5409B-5B2B-4667-A91A-D5A5E7DC8A83}.Fast|Win32.ActiveCfg = Fast|
Win32
@@ -70,6 +62,14 @@
 		{DDDCEC02-9CCF-4178-9596-E00D6F71C083}.Product|Win32.Build.0 =
Release|Win32
 		{DDDCEC02-9CCF-4178-9596-E00D6F71C083}.Release|Win32.ActiveCfg =
Release|Win32
 		{DDDCEC02-9CCF-4178-9596-E00D6F71C083}.Release|Win32.Build.0 =
Release|Win32
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233}.Debug|Win32.ActiveCfg =
Debug|Win32
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233}.Debug|Win32.Build.0 = Debug|
Win32
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233}.Fast|Win32.ActiveCfg =
Release|Win32
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233}.Fast|Win32.Build.0 = Release|
Win32
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233}.Product|Win32.ActiveCfg =
Release|Win32
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233}.Product|Win32.Build.0 =
Release|Win32
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233}.Release|Win32.ActiveCfg =
Release|Win32
+		{FD5B94F7-55C2-4C96-B89E-32DC1A737233}.Release|Win32.Build.0 =
Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

=== modified file 'build.win32/strongtalk/Makefile.win32'
--- build.win32/strongtalk/Makefile.win32	2008-05-29 00:55:59 +0000
+++ build.win32/strongtalk/Makefile.win32	2008-06-28 16:27:25 +0000
@@ -40,7 +40,7 @@
 	-@$(RMDIR) /s/q incls
 	@$(MKDIR) incls
 	@$(CP) $(DB1) +$(DB2) includeDB.all
-	..\build.win32\makedeps\debug\makedeps $(PLATFORM) includeDB.all
+	..\tools\makedeps $(PLATFORM) includeDB.all
 	@$(MV) includeDB.all includeDB.current

 # numbers:

=== modified file 'build.win32/strongtalk/makedeps.bat'
--- build.win32/strongtalk/makedeps.bat	2008-05-29 00:55:59 +0000
+++ build.win32/strongtalk/makedeps.bat	2008-06-28 17:01:34 +0000
@@ -1,2 +1,2 @@
 @cd ..\..\build
-nmake /f ../build.win32/strongtalk/Makefile.win32
\ No newline at end of file
+nmake /nologo /f ../build.win32/strongtalk/Makefile.win32

=== modified file 'contributorLicenses.html'
--- contributorLicenses.html	2007-12-08 10:31:24 +0000
+++ contributorLicenses.html	2008-06-19 04:19:46 +0000
@@ -23,6 +23,7 @@
 	<li>Dave Raymer - [email protected]</li>
 	<li>Marc Fauconneau Dufresne - [email protected]</li>
 	<li>Stephen Rees - [email protected]</li>
+	<li>Brian de Alwis - [email protected]</li>
 	</ul>
   </body>
 </html>

=== modified file 'easyunit/easyunit/alloceasy.h'
--- easyunit/easyunit/alloceasy.h	2008-05-28 23:33:59 +0000
+++ easyunit/easyunit/alloceasy.h	2008-06-19 04:19:50 +0000
@@ -1,7 +1,9 @@
 #ifndef _EASYUNIT_ALLOC_
 #define _EASYUNIT_ALLOC_
 #include <string.h>
+#ifndef __DARWIN__
 #include <malloc.h>
+#endif
 #include <stdlib.h>

 namespace easyunit {

=== modified file 'tools/makedeps/makeDeps.cpp'
--- tools/makedeps/makeDeps.cpp	2008-05-28 23:33:59 +0000
+++ tools/makedeps/makeDeps.cpp	2008-06-19 04:19:51 +0000
@@ -313,7 +313,8 @@
  public:
   void setupFileTemplates() {
     InclFileTemplate = new FileName( "incls/", "_", "",  ".incl", "",
"");
-      GIFileTemplate = new FileName( "incls/", "",  "_precompiled",
".h", "", ".p");
+      //GIFileTemplate = new FileName( "incls/", "",  "_precompiled",
".h", "", ".p");
+      GIFileTemplate = new FileName( "incls/", "",  "_precompiled",
".incl", "", "");
       GDFileTemplate = new FileName( "", "",  "Dependencies.hh",
"",      "", "");
   }


=== modified file 'tools/makedeps/makedeps.vcproj'
--- tools/makedeps/makedeps.vcproj	2006-11-01 13:53:10 +0000
+++ tools/makedeps/makedeps.vcproj	2008-06-28 16:20:24 +0000
@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8.00"
+	Version="9.00"
 	Name="makedeps"
 	ProjectGUID="{FD5B94F7-55C2-4C96-B89E-32DC1A737233}"
+	TargetFrameworkVersion="131072"
 	>
 	<Platforms>
 		<Platform
@@ -48,6 +49,8 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -68,9 +71,6 @@
 				Name="VCAppVerifierTool"
 			/>
 			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
@@ -108,6 +108,8 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -128,9 +130,6 @@
 				Name="VCAppVerifierTool"
 			/>
 			<Tool
-				Name="VCWebDeploymentTool"
-			/>
-			<Tool
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>

=== modified file 'vm/code/stubRoutines.cpp'
--- vm/code/stubRoutines.cpp	2008-01-15 00:22:13 +0000
+++ vm/code/stubRoutines.cpp	2008-06-19 04:20:34 +0000
@@ -509,6 +509,14 @@
   //slr mod: push a fake stack frame to support cdecl calls
   masm->enter();
   //slr mod end
+  // following is to allow 16-byte stack alignment for Darwin (OSX)
+  masm->movl(eax, ebx);
+  masm->negl(eax);
+  masm->leal(eax, Address(esp, eax, Address::times_4)); // esp - 4 x
nargs
+  masm->andl(eax, 0xf); // padding required for 16-byte alignment
+  masm->subl(esp, eax); // align stack
+  // end stack alignment mod
+
   masm->testl(ebx, ebx);			// if number of arguments != 0 then
   masm->jcc(MacroAssembler::notZero, loop_entry);// convert arguments

@@ -823,6 +831,7 @@

   masm->pushl(edi);	// save registers for C calling convetion
   masm->pushl(esi);
+  //masm->pushl(ebx);

   // reset last Delta frame
   masm->reset_last_Delta_frame();
@@ -863,6 +872,7 @@

  masm->bind(_return);
   masm->leal(esp, Address(ebp, -4*oopSize));
+  //masm->popl(ebx);
   masm->popl(esi);	// restore registers for C calling convetion
   masm->popl(edi);
   masm->popl(Address((int)&last_Delta_sp,
relocInfo::external_word_type)); // reset _last_Delta_sp

=== modified file 'vm/deps/includeDB'
--- vm/deps/includeDB	2008-05-29 00:55:59 +0000
+++ vm/deps/includeDB	2008-06-19 04:19:51 +0000
@@ -948,6 +948,7 @@
 oop_prims.cpp			memOop.inline.hpp
 oop_prims.cpp			lookupCache.hpp
 oop_prims.cpp			delta.hpp
+oop_prims.cpp			associationOop.hpp

 oopFactory.cpp			associationKlass.hpp
 oopFactory.cpp			oopFactory.hpp
@@ -967,11 +968,11 @@
 os.hpp				longInt.hpp

 os.cpp				no_precompiled_headers
+os.cpp				os.hpp
 os.cpp				allocation.hpp
 os.cpp				error.hpp
 os.cpp				lprintf.hpp
 os.cpp				macros.hpp
-os.cpp				os.hpp
 os.cpp				growableArray.hpp

 ostream.hpp			std_includes.hpp
@@ -1374,6 +1375,7 @@
 timer.cpp			os.hpp

 timer.hpp			top.hpp
+timer.hpp			longInt.hpp

 top.hpp				asserts.hpp
 top.hpp				allocation.hpp

=== modified file 'vm/memory/error.cpp'
--- vm/memory/error.cpp	2006-10-26 16:36:34 +0000
+++ vm/memory/error.cpp	2008-06-19 04:19:51 +0000
@@ -69,7 +69,7 @@
   }
 }

-void report_assertion_failure(char* code_str, char* file_name, int
line_no, char* message) {
+void report_assertion_failure(const char* code_str, const char*
file_name, int line_no, const char* message) {
   report_error("Assertion Failure", "assert(%s, \"%s\")\n%s, %d",
 	        code_str, message, file_name, line_no);
 }

=== modified file 'vm/memory/error.hpp'
--- vm/memory/error.hpp	2008-05-28 23:33:59 +0000
+++ vm/memory/error.hpp	2008-06-19 04:19:51 +0000
@@ -65,7 +65,7 @@
 #define Unimplemented()          { report_unimplemented
(FILE_INFO, LINE_INFO); DEBUG_EXCEPTION; }


-void report_assertion_failure(char* code_str, char* file_name, int
line_no, char* message);
+void report_assertion_failure(const char* code_str, const char*
file_name, int line_no, const char* message);
 void report_fatal(char* file_name, int line_no, char* format, ...);
 void report_should_not_call(char* file_name, int line_no);
 void report_should_not_reach_here(char* file_name, int line_no);

=== modified file 'vm/prims/prim.cpp'
--- vm/prims/prim.cpp	2008-04-23 01:48:41 +0000
+++ vm/prims/prim.cpp	2008-06-19 04:19:52 +0000
@@ -47,6 +47,7 @@
 oop primitive_desc::eval(oop* a) {
   const bool reverseArgs = true;	// change this when changing
primitive calling convention
   oop res;
+#ifdef DEBUG_CHECK_EBX
   int ebx_on_stack;

   // %hack: see below
@@ -55,6 +56,7 @@
 #else
   asm("movl %%ebx, %0" : "=b"(ebx_on_stack));
 #endif
+#endif
   if (reverseArgs) {
     switch (number_of_parameters()) {
     case  0: res = ((prim_fntype0)_fn)(); break;
@@ -85,6 +87,7 @@
     }
   }

+#ifdef DEBUG_CHECK_EBX
   // %hack: some primitives alter EBX and crash the compiler's
constant propagation
   int ebx_now;
 #ifndef __GNUC__
@@ -99,6 +102,7 @@
     std->print_cr("ebx changed (%X -> %X) in :", ebx_on_stack,
ebx_now);
     print();
   }
+#endif

   return res;
 }

=== modified file 'vm/runtime/main.cpp'
--- vm/runtime/main.cpp	2008-05-28 23:33:59 +0000
+++ vm/runtime/main.cpp	2008-06-28 17:19:04 +0000
@@ -10,7 +10,7 @@
 	os::set_args(__argc, __argv);
 	return vm_main(__argc, __argv);
 }
-#elif defined(__LINUX__) || defined(WIN32)
+#elif defined(__DARWIN__) || defined(__LINUX__) || defined(WIN32)
 int main(int argc, char* argv[]) {
 	os::set_args(argc, argv);
 	return vm_main(argc, argv);

=== modified file 'vm/runtime/os.hpp'
--- vm/runtime/os.hpp	2008-04-23 01:48:41 +0000
+++ vm/runtime/os.hpp	2008-06-19 04:19:53 +0000
@@ -21,6 +21,8 @@

 */

+#ifndef __OS_HPP__
+#define __OS_HPP__
 // os defines the interface to operating system

 typedef void (*dll_func)(...);
@@ -127,3 +129,5 @@
   ThreadCritical();
   ~ThreadCritical();
 };
+
+#endif /* __OS_HPP__ */

=== added file 'vm/runtime/os_darwin.cpp'
--- vm/runtime/os_darwin.cpp	1970-01-01 00:00:00 +0000
+++ vm/runtime/os_darwin.cpp	2008-06-30 05:20:54 +0000
@@ -0,0 +1,690 @@
+/* Copyright 1994 - 1996 LongView Technologies L.L.C. $Revision: 1.50
$ */
+/* Copyright (c) 2006, Sun Microsystems, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the
+following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
+	  disclaimer in the documentation and/or other materials provided
with the distribution.
+    * Neither the name of Sun Microsystems nor the names of its
contributors may be used to endorse or promote products derived
+	  from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
+NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+
+
+*/
+#ifndef __OS_DARWIN__
+#define __OS_DARWIN__
+#ifdef __DARWIN__
+# include <pthread.h>
+# include <unistd.h>
+# include <semaphore.h>
+# include <sys/times.h>
+# include <sys/time.h>
+# include <time.h>
+# include <stdio.h>
+# include <dlfcn.h>
+# include <signal.h>
+# include <ucontext.h>
+# include "incls/_precompiled.incl"
+# include "incls/_os.cpp.incl"
+
+void os_dump_context2(ucontext_t *context) {
+#if 0
+    mcontext_t mcontext = context->uc_mcontext;
+    printf("\nEAX: %x", mcontext.gregs[REG_EAX]);
+    printf("\nEBX: %x", mcontext.gregs[REG_EBX]);
+    printf("\nECX: %x", mcontext.gregs[REG_ECX]);
+    printf("\nEDX: %x", mcontext.gregs[REG_EDX]);
+    printf("\nEIP: %x", mcontext.gregs[REG_EIP]);
+    printf("\nESP: %x", mcontext.gregs[REG_ESP]);
+    printf("\nEBP: %x", mcontext.gregs[REG_EBP]);
+    printf("\nEDI: %x", mcontext.gregs[REG_EDI]);
+    printf("\nESI: %x", mcontext.gregs[REG_ESI]);
+#endif
+}
+void os_dump_context() {
+	ucontext_t context;
+	getcontext(&context);
+	os_dump_context2(&context);
+}
+
+static int    main_thread_id;
+class Lock {
+    private:
+        pthread_mutex_t* mutex;
+
+    public:
+        Lock(pthread_mutex_t* mutex) : mutex(mutex) {
+            pthread_mutex_lock(mutex);
+        }
+        ~Lock() {
+            pthread_mutex_unlock(mutex);
+        }
+};
+
+static int _argc;
+static char** _argv;
+
+int os::argc() {
+  return _argc;
+}
+
+char** os::argv() {
+  return _argv;
+}
+
+void os::set_args(int argc, char* argv[]) {
+    _argc = argc;
+    _argv = argv;
+}
+
+class Event: public CHeapObj {
+    private:
+        bool _signalled;
+        pthread_mutex_t mutex;
+        pthread_cond_t notifier;
+    public:
+        void inline signal() {
+            Lock mark(&mutex);
+            _signalled = true;
+            pthread_cond_signal(&notifier);
+        }
+        void inline reset() {
+            Lock mark(&mutex);
+            _signalled = false;
+            pthread_cond_signal(&notifier);
+        }
+        bool inline waitFor() {
+            Lock mark(&mutex);
+            while (!_signalled)
+              pthread_cond_wait(&notifier, &mutex);
+        }
+        Event(bool state) {
+            _signalled = state;
+            pthread_mutex_init(&mutex, NULL);
+            pthread_cond_init(&notifier, NULL);
+        }
+        ~Event() {
+            pthread_mutex_destroy(&mutex);
+            pthread_cond_destroy(&notifier);
+        }
+};
+
+class Thread : CHeapObj {
+	public:
+        static Thread* find(pthread_t threadId) {
+          for (int index = 0; index < _threads->length(); index++) {
+            Thread* candidate = _threads->at(index);
+            if (candidate == NULL) continue;
+            if (pthread_equal(threadId, candidate->_threadId))
+              return candidate;
+          }
+          return NULL;
+        }
+        void suspend() {
+        	suspendEvent.waitFor();
+        }
+        void resume() {
+        	suspendEvent.signal();
+        }
+    private:
+        Event suspendEvent;
+        static GrowableArray<Thread*>* _threads;
+        pthread_t _threadId;
+        int _thread_index;
+
+        static void init() {
+          ThreadCritical lock;
+          _threads = new(true) GrowableArray<Thread*>(10, true);
+
+        }
+        Thread(pthread_t threadId) : _threadId(threadId),
suspendEvent(false) {
+          ThreadCritical lock;
+          _thread_index = _threads->length();
+#if 0
+	   pthread_getcpuclockid(_threadId, &_clockId);
+#endif
+          _threads->push(this);
+        };
+        ~Thread() {
+          ThreadCritical lock;
+          _threads->at_put(_thread_index, NULL);
+        }
+        double get_cpu_time() {
+#if 0
+          struct timespec cpu;
+          clock_gettime(_clockId, &cpu);
+          return ((double)cpu.tv_sec) + ((double)cpu.tv_nsec)/
1000000000.0;
+#else
+	return 0;
+#endif
+        }
+        friend class os;
+};
+
+GrowableArray<Thread*>* Thread::_threads = NULL;
+static Thread* main_thread;
+
+extern void intercept_for_single_step();
+
+// No references in VM
+int os::getenv(char* name,char* buffer,int len) {
+ return 0;
+}
+
+// 1 reference (lprintf.cpp)
+bool os::move_file(char* from, char* to) {
+	return false;
+}
+
+// 1 reference (inliningdb.cpp)
+bool os::check_directory(char* dir_name) {
+  return false;
+}
+
+// 1 reference (memory/util.cpp)
+void os::breakpoint() {
+}
+
+// 1 reference process.cpp
+Thread* os::starting_thread(int* id_addr) {
+  *id_addr = main_thread->_thread_index;
+  return main_thread;
+}
+
+typedef struct {
+  int (*main)(void* parameter);
+  void* parameter;
+} thread_args_t;
+
+void* mainWrapper(void* args) {
+  thread_args_t* wrapperArgs = (thread_args_t*) args;
+  int* result = (int*) malloc(sizeof(int));
+  *result = wrapperArgs->main(wrapperArgs->parameter);
+  free(args);
+  return (void *) result;
+}
+
+// 1 reference process.cpp
+Thread* os::create_thread(int threadStart(void* parameter), void*
parameter, int* id_addr) {
+  pthread_t threadId;
+  thread_args_t* threadArgs = (thread_args_t*)
malloc(sizeof(thread_args_t));
+  threadArgs->main = threadStart;
+  threadArgs->parameter = parameter;
+  int status = pthread_create(&threadId, NULL, &mainWrapper,
threadArgs);
+  if (status != 0) {
+    fatal("Unable to create thread");
+  }
+  Thread* thread = new Thread(threadId);
+  *id_addr = thread->_thread_index;
+  return thread;
+}
+
+// 1 reference process.cpp
+void os::terminate_thread(Thread* thread) {
+}
+
+// 1 reference process.cpp
+void os::delete_event(Event* event) {
+    delete event;
+}
+
+// 1 reference process.cpp
+Event* os::create_event(bool initial_state) {
+  return new Event(initial_state);
+}
+
+tms processTimes;
+
+// 2 references - prims/system_prims.cpp, timer.cpp
+int os::updateTimes() {
+  return times(&processTimes) != (clock_t) -1;
+}
+
+// 2 references - prims/system_prims.cpp, timer.cpp
+double os::userTime() {
+  return ((double) processTimes.tms_utime)/ CLOCKS_PER_SEC;
+}
+
+// 2 references - prims/system_prims.cpp, timer.cpp
+double os::systemTime() {
+  return ((double) processTimes.tms_stime)/ CLOCKS_PER_SEC;
+}
+
+// 1 reference - process.cpp
+double os::user_time_for(Thread* thread) {
+  //Hack warning - assume half time is spent in kernel, half in user
code
+  return thread->get_cpu_time()/2;
+}
+
+// 1 reference - process.cpp
+double os::system_time_for(Thread* thread) {
+  //Hack warning - assume half time is spent in kernel, half in user
code
+  return thread->get_cpu_time()/2;
+}
+
+static int      has_performance_count = 0;
+static long_int initial_performance_count(0,0);
+static long_int performance_frequency(0,0);
+
+// 2 references - memory/error.cpp, evaluator.cpp
+void os::fatalExit(int num) {
+    exit(num);
+}
+
+class DLLLoadError {
+};
+
+class DLL : CHeapObj {
+  private:
+    char* _name;
+    void* _handle;
+
+    DLL(char* name) {
+      _handle = dlopen(name, RTLD_LAZY);
+      checkHandle(_handle, "could not find library: %s");
+      _name = (char*)malloc(strlen(name) + 1);
+      strcpy(_name, name);
+    }
+    void checkHandle(void* handle, const char* format) {
+      if (handle == NULL) {
+        char* message = (char*) malloc(200);
+        sprintf(message, format, dlerror());
+        assert(handle != NULL, message);
+        free(message);
+      }
+    }
+    ~DLL() {
+      if (_handle) dlclose(_handle);
+      if (_name) free(_name);
+    }
+    bool isValid() {
+      return (_handle != NULL) && (_name != NULL);
+    }
+    dll_func lookup(char* funcname) {
+      dll_func function = dll_func(dlsym(_handle, funcname));
+      checkHandle((void*) function, "could not find function: %s");
+      return function;
+    }
+  friend class os;
+};
+
+// 1 reference - prims/dll.cpp
+dll_func os::dll_lookup(char* name, DLL* library) {
+  return library->lookup(name);
+}
+
+// 1 reference - prims/dll.cpp
+DLL* os::dll_load(char* name) {
+  DLL* library = new DLL(name);
+  if (library->isValid()) return library;
+  delete library;
+  return NULL;
+}
+
+// 1 reference - prims/dll.cpp
+bool os::dll_unload(DLL* library) {
+  delete library;
+  return true;
+}
+
+int       nCmdShow      = 0;
+
+// 1 reference - prims/system_prims.cpp
+void* os::get_hInstance()    { return (void*) NULL;     }
+// 1 reference - prims/system_prims.cpp
+void* os::get_prevInstance() { return (void*) NULL; }
+// 1 reference - prims/system_prims.cpp
+int   os::get_nCmdShow()     { return 0;            }
+
+extern int bootstrapping;
+
+// 1 reference - prims/debug_prims.cpp
+void os::timerStart() {}
+
+// 1 reference - prims/debug_prims.cpp
+void os::timerStop() {}
+
+// 1 reference - prims/debug_prims.cpp
+void os::timerPrintBuffer() {}
+
+// Virtual Memory
+class Allocations {
+  private:
+    int allocationSize;
+    char** allocations;
+    char** reallocBoundary;
+    char** next;
+    bool released;
+
+    void checkCapacity() {
+      if (next == reallocBoundary) {
+        reallocate();
+      }
+    }
+    void reallocate() {
+        char** oldAllocations = allocations;
+        int oldSize = allocationSize;
+        allocationSize *= 2;
+        allocations = (char**)malloc(sizeof(char*) * allocationSize);
+        memcpy(allocations, oldAllocations, oldSize * sizeof(char*));
+        next = allocations + oldSize;
+        reallocBoundary = allocations + allocationSize;
+        free(oldAllocations);
+    }
+    void initialize() {
+      allocationSize = 10;
+      allocations = (char**)malloc(sizeof(char*) * allocationSize);
+      reallocBoundary = allocations + allocationSize;
+      next = allocations;
+    }
+    void release() {
+      if (released) return;
+      for (char** current = allocations; current < next; current++)
+        free(*current);
+      free(allocations);
+      allocations = next = reallocBoundary = NULL;
+      released = true;
+    }
+  public:
+    Allocations() {
+      initialize();
+    }
+    ~Allocations() {
+      release();
+    }
+    void remove(char* allocation) {
+      if (released) return;
+      for (char** current = allocations; current < next; current++)
+        if (*current == allocation) {
+          for (char** to_move = current; to_move < next; to_move++)
+            to_move[0] = to_move[1];
+          next--;
+          return;
+        }
+    }
+    void add(char* allocation) {
+      if (released) return;
+      checkCapacity();
+      *next = allocation;
+      next++;
+    }
+    bool contains(char* allocation) {
+      if (released) return false;
+      for (char** current = allocations; current < (allocations +
allocationSize); current++)
+        if (*current == allocation) return true;
+      return false;
+    }
+};
+
+Allocations allocations;
+
+// 1 reference - virtualspace.cpp
+char* os::reserve_memory(int size) {
+  ThreadCritical tc;
+  char* allocation = (char*) valloc(size);
+  allocations.add(allocation);
+  return allocation;
+}
+
+// 1 reference - virtualspace.cpp
+bool os::commit_memory(char* addr, int size) {
+  return true;
+}
+
+// 1 reference - virtualspace.cpp
+bool os::uncommit_memory(char* addr, int size) {
+  return true;
+}
+
+// 1 reference - virtualspace.cpp
+bool os::release_memory(char* addr, int size) {
+  ThreadCritical tc;
+  if (allocations.contains(addr)) {
+      allocations.remove(addr);
+      free(addr);
+  }
+  return true;
+}
+
+// No references
+bool os::guard_memory(char* addr, int size) {
+  return false;
+}
+
+// 1 reference - process.cpp
+void os::transfer(Thread* from_thread, Event* from_event, Thread*
to_thread, Event* to_event) {
+  from_event->reset();
+  to_event->signal();
+  from_event->waitFor();
+}
+
+// 1 reference - process.cpp
+void os::transfer_and_continue(Thread* from_thread, Event*
from_event, Thread* to_thread, Event* to_event) {
+  from_event->reset();
+  to_event->signal();
+}
+
+// 1 reference - process.cpp
+void os::suspend_thread(Thread* thread) {
+	os_dump_context();
+	pthread_kill(thread->_threadId, SIGUSR1);
+}
+
+void suspendHandler(int signum) {
+	Thread* current = Thread::find(pthread_self());
+	assert(current, "Suspended thread not found!");
+	current->suspend();
+}
+// 1 reference - process.cpp
+void os::resume_thread(Thread* thread) {
+	thread->resume();
+}
+
+// No references
+void os::sleep(int ms) {
+}
+
+// 1 reference - process.cpp
+void os::fetch_top_frame(Thread* thread, int** sp, int** fp, char**
pc) {
+}
+
+// 1 reference - callBack.cpp
+int os::current_thread_id() {
+  Thread* currentThread = Thread::find(pthread_self());
+  if (currentThread == NULL) return -1;
+  return currentThread->_thread_index;
+}
+
+// 1 reference - process.cpp
+void os::wait_for_event(Event* event) {
+    event->waitFor();
+}
+
+// 1 reference - process.cpp
+void os::reset_event(Event* event) {
+    event->reset();
+}
+
+// 1 reference - process.cpp
+void os::signal_event(Event* event) {
+    event->signal();
+}
+
+// 1 reference - process.cpp
+bool os::wait_for_event_or_timer(Event* event, int timeout_in_ms) {
+  return false;
+}
+
+extern "C" bool WizardMode;
+
+void process_settings_file(char* file_name, bool quiet);
+
+static int number_of_ctrl_c = 0;
+
+// 2 references - memory/universe, runtime/virtualspace
+int os::_vm_page_size = getpagesize();
+
+// 1 reference - timer.cpp
+long_int os::elapsed_counter() {
+#if 0
+  struct timespec current_time;
+  clock_gettime(CLOCK_REALTIME, &current_time);
+  int64_t current64 = ((int64_t)current_time.tv_sec) * 1000000000 +
current_time.tv_nsec;
+#else
+  struct timeval current_time;
+  gettimeofday(&current_time, NULL);
+  int64_t current64 = ((int64_t)current_time.tv_sec) * 1000000000
+      + current_time.tv_usec * 1000;
+#endif
+  uint high = current64 >> 32;
+  uint low  = current64 & 0xffffffff;
+  long_int current(low, high);
+  return current;
+}
+
+// 1 reference - timer.cpp
+long_int os::elapsed_frequency() {
+  return long_int(1000000000, 0);
+}
+
+static struct timespec initial_time;
+
+// 1 reference - prims/system_prims.cpp
+double os::elapsedTime() {
+#if 0
+  struct timespec current_time;
+  clock_gettime(CLOCK_REALTIME, &current_time);
+  long int secs = current_time.tv_sec - initial_time.tv_sec;
+  long int nsecs = current_time.tv_nsec - initial_time.tv_nsec;
+  if (nsecs < 0) {
+    secs--;
+    nsecs += 1000000000;
+  }
+  return secs + (nsecs / 1000000000.0);
+#else
+  return 0.0;
+#endif
+}
+
+// No references
+double os::currentTime() {
+  return 0;
+}
+
+static void initialize_performance_counter() {
+#if 0
+  clock_gettime(CLOCK_REALTIME, &initial_time);
+#endif
+}
+
+// No references
+void os::initialize_system_info() {
+    Thread::init();
+    main_thread = new Thread(pthread_self());
+    initialize_performance_counter();
+}
+
+// 1 reference - memory/error.cpp
+int os::message_box(char* title, char* message) {
+  return 0;
+}
+
+char* os::platform_class_name() { return "DarwinPlatform"; }
+
+extern "C" bool EnableTasks;
+
+pthread_mutex_t ThreadSection;
+
+void ThreadCritical::intialize() { pthread_mutex_init(&ThreadSection,
NULL); }
+void ThreadCritical::release()
{ pthread_mutex_destroy(&ThreadSection);     }
+
+ThreadCritical::ThreadCritical() {
+  pthread_mutex_lock(&ThreadSection);
+}
+
+ThreadCritical::~ThreadCritical() {
+  pthread_mutex_unlock(&ThreadSection);
+}
+
+void real_time_tick(int delay_time);
+
+void* watcherMain(void* ignored) {
+  const struct timespec delay = { 0, 10 * 1000 * 1000 };
+  const int delay_interval = 10; // Delay 10 ms
+  while(1) {
+    int status = nanosleep(&delay, NULL);
+    if (!status) return 0;
+    real_time_tick(delay_interval);
+  }
+  return 0;
+}
+
+void segv_repeated(int signum, siginfo_t* info, void* context) {
+	printf("SEGV during signal handling. Aborting.");
+	exit(-2);
+}
+
+void install_dummy_handler() {
+	  struct sigaction sa;
+
+	  sigemptyset(&sa.sa_mask);
+	  sa.sa_flags = SA_RESTART |SA_SIGINFO;
+	  sa.sa_sigaction = segv_repeated;
+	  if (sigaction(SIGSEGV, &sa, NULL) == -1)
+	      /* Handle error */;
+}
+
+void trace_stack(int thread_id);
+
+static void handler(int signum, siginfo_t* info, void* context) {
+//	install_dummy_handler();
+//	trace_stack(os::current_thread_id());
+    printf("\nsignal: %d\ninfo: %x\ncontext: %x", signum, (int) info,
(int) context);
+	os_dump_context2((ucontext_t*) context);
+    exit(-1);
+}
+
+void install_signal_handlers() {
+	  struct sigaction sa;
+
+	  sigemptyset(&sa.sa_mask);
+	  sa.sa_flags = SA_RESTART; /* Restart functions if
+	                               interrupted by handler */
+	  sa.sa_handler = suspendHandler;
+	  if (sigaction(SIGUSR1, &sa, NULL) == -1)
+	      /* Handle error */;
+	  sa.sa_flags |= SA_SIGINFO;
+	  sa.sa_sigaction = handler;
+	  if (sigaction(SIGSEGV, &sa, NULL) == -1)
+	      /* Handle error */;
+}
+
+void os_init() {
+  ThreadCritical::intialize();
+
+  install_signal_handlers();
+  os::initialize_system_info();
+
+  if (EnableTasks) {
+    pthread_t watcherThread;
+    int status = pthread_create(&watcherThread, NULL, &watcherMain,
NULL);
+    if (status != 0) {
+      fatal("Unable to create thread");
+    }
+  }
+}
+
+void os_exit() {
+  ThreadCritical::release();
+}
+#endif /* __DARWIN__ */
+#endif

=== modified file 'vm/topIncludes/types.hpp'
--- vm/topIncludes/types.hpp	2007-11-12 22:26:32 +0000
+++ vm/topIncludes/types.hpp	2008-06-19 04:19:53 +0000
@@ -34,6 +34,7 @@
 // most portable way of dealing with bools is to treat them as ints;
 // the new basic bool type isn't goodness.
 typedef int _bool_type_;
+#undef bool
 #define bool _bool_type_

 typedef int smi;



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Strongtalk-general" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/strongtalk-general?hl=en
-~----------~----~----~----~------~----~------~--~---