diff -Nur systemc_2_1.oct_12_2004.beta/Makefile systemc-amd64/Makefile
--- systemc_2_1.oct_12_2004.beta/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ systemc-amd64/Makefile	2005-05-09 17:27:47.000000000 +0100
@@ -0,0 +1,463 @@
+# #------------------------------------------------------------------------#
+# |                                                                        |
+# |   Makefile                                                             |
+# |                                                                        |
+# |   Build SystemC 2.1 on Linux (i386 or AMD64) and Windows.              |
+# |                                                                        |
+# |   Copyright 2005, Frank A. Kingswood. Licensed under OSCI license.     |
+# |                                                                        |
+# #------------------------------------------------------------------------#
+#
+# $Id$ 
+
+# You need the following to be able to run this Makefile:
+#    GNU make 3.80
+#    For Windows Cygwin
+#    	Cygwin development tools (i.e. gcc, binutils with UNIX compatibility)
+#    For Windows MinGW
+#    	MinGW development tools (i.e. gcc, binutils for Win32)
+#    	sh.exe rm.exe, mkdir.exe or MSYS environment
+#    For UNIX or Linux
+#    	gcc, g++
+#    	standard shell tools
+#
+# This Makefile needs the OSTYPE variable. For Cygwin, MSYS and UNIX-like
+# systems you need to export OSTYPE, or add OSTYPE=$OSTYPE to the make
+# commandline. For MinGW without MSYS add OSTYPE=win32 on the commandline.
+
+# SUBDIRS should list all the subdirectories we read for source and header files
+SUBDIRS:=	src/systemc/kernel \
+		src/systemc/communication \
+		src/systemc/tracing \
+		src/systemc/utils \
+		src/systemc/datatypes/bit  \
+		src/systemc/datatypes/fx   \
+		src/systemc/datatypes/int  \
+		src/systemc/datatypes/misc \
+		src/systemc/qt \
+		src/systemc/qt/md
+
+# Calculate the source file lookup path from the list of subdirectories
+VPATH:=		$(subst $(subst :, ,:),:,$(SUBDIRS))
+
+# ===== rules, should go into their own file ===============================
+
+# ----- top level targets --------------------------------------------------
+
+# These targets never produce any files
+.PHONY:		all clean targetclean _mkdir _clean _targetclean
+
+# Make everything
+all:            _mkdir _all
+
+# Cleanup object files and targets
+clean:		_clean
+
+# Cleanup targets but leave object files
+targetclean:	_targetclean
+
+# ----- detect operating system and compiler options -----------------------
+
+OS:=$(OSTYPE)
+
+ifeq "$(OSTYPE)" ""
+   $(warning OSTYPE not set, assuming you are compiling with MinGW)
+   OS:=win32
+endif
+
+ifeq "$(OSTYPE)" "msys"
+  # MSYS is the unix-like environment on top of MinGW
+  OS:=win32
+endif
+
+ifeq "$(OSTYPE)" "linux-gnu"
+   # some systems call it linux, others linux-gnu. We pick the short one.
+   OS:=linux
+endif
+
+# Common tools
+CC:=gcc
+CXX:=g++
+LD:=g++
+AR:=ar
+RANLIB:=ranlib
+
+ifeq "$(OS)" "win32"
+   X:=.exe
+   GCCVERSION:=3.4.2
+   TARGET:=i386-win32
+   SUFFIX:=-win
+   	
+   # Compiler flags
+   CFLAGS:=-c -Wall
+   CC_DEBUG:=-g
+   CC_NODEBUG:=-DNDEBUG -O7
+      
+   # Autodeps
+   CFLAGS+=-MMD
+
+   # multithreading
+   CFLAGS+=-mthreads
+   
+   # compatibility
+   CFLAGS+=-mms-bitfields
+   
+   # Avoid the overhead of setting up a frame pointer in leaf functions
+   CFLAGS+=-momit-leaf-frame-pointer
+   
+   # Linker flags
+   LDFLAGS:=
+else
+   ifeq "$(OS)" "xwin"
+      OS=win32
+      X:=.exe
+      GCCVERSION:=3.4.2
+      TARGET:=i386-win32
+      SUFFIX:=-win
+      PREFIX:=i586-mingw32msvc-
+      CC:=$(PREFIX)$(CC)
+      CXX:=$(PREFIX)$(CXX)
+      LD:=$(PREFIX)$(LD)
+      AR:=$(PREFIX)$(AR)
+      RANLIB:=$(PREFIX)$(RANLIB)
+
+      # Compiler flags
+      CFLAGS:=-c -Wall
+      CC_DEBUG:=-g
+      CC_NODEBUG:=-DNDEBUG -O7
+      
+      # Autodeps
+      CFLAGS+=-MMD
+
+      # multithreading
+      CFLAGS+=-mthreads
+   
+      # compatibility
+      CFLAGS+=-mms-bitfields
+   
+      # Avoid the overhead of setting up a frame pointer in leaf functions
+      CFLAGS+=-momit-leaf-frame-pointer
+   
+      # Linker flags
+      LDFLAGS:=
+   else
+      ifeq "$(OS)" "cygwin"
+         X:=.exe
+         GCCVERSION:=$(shell $(CC) -v 2>&1 | awk '/gcc version/ { print $$3; }' )
+         TARGET:=i386-$(OS)
+         SUFFIX=-$(TARGET)-gcc$(GCCVERSION)
+   	
+         # Compiler flags
+         CFLAGS:=-c -Wall
+         CC_DEBUG:=-g # -fverbose-asm -v -save-temps
+         CC_NODEBUG:=-DNDEBUG -O7
+      
+         # Autodeps
+         CFLAGS+=-MMD
+
+         # Linker flags
+         LDFLAGS:=-lpthread
+      else # not win32 or xwin or cygwin
+         X:=
+         GCCVERSION:=$(shell $(CC) -v 2>&1 | awk '/gcc version/ { print $$3; }' )
+         TARGET:=$(shell arch)-$(OS)
+         SUFFIX=-$(TARGET)-gcc$(GCCVERSION)
+
+         ifeq "$(OS)" "solaris"
+            # Compiler flags
+            CFLAGS:=-c -Wall
+            CC_DEBUG:=-g
+            CC_NODEBUG:=-DNDEBUG -O7
+         
+            # Autodeps
+            CFLAGS+=-MMD
+         
+            # Linker flags
+            LDFLAGS:=-lpthread
+         endif # Solaris
+
+         ifeq "$(OS)" "linux"
+            # Compiler flags
+            CFLAGS:=-c -Wall
+            CC_DEBUG:=-g # -fverbose-asm -v -save-temps
+            CC_NODEBUG:=-DNDEBUG -O7
+         
+            # Autodeps
+            CFLAGS+=-MMD
+         
+            # Avoid the overhead of setting up a frame pointer in leaf functions
+            CFLAGS+=-momit-leaf-frame-pointer
+
+            ifeq "$(TARGET)" "x86_64-linux"
+               # 64-bit
+               CFLAGS+=-m64
+	    endif
+
+            # Linker flags
+            LDFLAGS:=-lpthread
+         endif # linux
+
+      endif # cygwin or not
+   endif # xwin or not
+endif # win32 or not
+
+CFLAGS+=-I$(LIBRARIES)
+
+LIBSEARCH=	.
+
+o-release=o/release$(SUFFIX)
+o-debug=o/debug$(SUFFIX)
+
+# ----- generic build rules ------------------------------------------------
+
+# Delete default suffixes, and therefore eliminate most implicit rules
+.SUFFIXES:
+
+$(o-release)/%.o:%.cc
+		@echo g++ $<
+		@$(CXX) $(CFLAGS) $(CC_NODEBUG) $< -o $@
+		              
+$(o-release)/%.o:%.cpp
+		@echo g++ $<
+		@$(CXX) $(CFLAGS) $(CC_NODEBUG) $< -o $@
+		              
+$(o-release)/%.o:%.c
+		@echo gcc $<
+		@$(CC) $(CFLAGS) $(CC_NODEBUG) $< -o $@
+		              
+$(o-release)/%.o:%.s
+		@echo as $<
+		@$(CC) $(CFLAGS) $(CC_NODEBUG) $< -o $@
+		              
+$(o-debug)/%.o:%.cc
+		@echo g++ -g $<
+		@$(CXX) $(CFLAGS) $(CC_DEBUG)   $< -o $@
+		              
+$(o-debug)/%.o:%.cpp
+		@echo g++ -g $<
+		@$(CXX) $(CFLAGS) $(CC_DEBUG)   $< -o $@
+		              
+$(o-debug)/%.o:%.c
+		@echo gcc -g $<
+		@$(CC) $(CFLAGS) $(CC_DEBUG)   $< -o $@
+
+$(o-debug)/%.o:%.s
+		@echo as -g $<
+		@$(CC) $(CFLAGS) $(CC_DEBUG)   $< -o $@
+
+
+# ----- frequently used commands -------------------------------------------
+
+define LINK-D
+   @echo ld -g $@...
+   @g++ -o $@ $(LDFLAGS) -g $(filter-out $(LIBTARGETS),$^) $(patsubst %,-L%/$(o-debug),$(LIBSEARCH))
+endef
+
+define LINK-DEBUG
+   @echo ld -g $@...
+   @g++ -o $@ $(LDFLAGS) -g $(filter-out $(LIBTARGETS),$^) $(patsubst %,-L%/$(o-debug),$(LIBSEARCH))
+endef
+
+define LINK
+   @echo ld $@...
+   @g++ -Wl,-O1 -o $@ $(LDFLAGS) $(filter-out $(LIBTARGETS),$^) $(patsubst %,-L%/$(o-release),$(LIBSEARCH))
+endef
+
+define MAKELIB
+   @echo ar $@...
+   @ar -r $@ $?
+   @ranlib $@
+endef
+
+# ----- clear variables ----------------------------------------------------
+
+LIBTARGETS=
+TARGETS=
+TESTTARGETS=
+PROGRAMS=
+TESTPROGRAMS=
+CLEAN=
+
+# ===== end rules =====
+# ----- specific build rules -----------------------------------------------
+
+CFLAGS+=	-DSC_INCLUDE_FX -Isrc
+
+ifeq "$(TARGET)" "x86_64-linux"
+CFLAGS+=	-DSC_USE_PTHREADS
+endif
+ifeq "$(OS)" "cygwin"
+CFLAGS+=	-DSC_USE_PTHREADS
+endif
+
+		# kernel
+LIBFILES:=	sc_attribute.o          \
+		sc_cor_fiber.o          \
+		sc_cor_pthread.o	\
+		sc_cor_qt.o		\
+		sc_event.o              \
+		sc_join.o		\
+		sc_lambda.o             \
+		sc_main.o               \
+		sc_main_main.o          \
+		sc_module.o             \
+		sc_module_name.o        \
+		sc_module_registry.o    \
+		sc_name_gen.o           \
+		sc_object.o             \
+		sc_object_manager.o     \
+		sc_process_base.o       \
+		sc_process_int.o        \
+		sc_sensitive.o          \
+		sc_simcontext.o         \
+		sc_time.o               \
+		sc_ver.o                \
+		sc_wait.o               \
+		sc_wait_cthread.o       
+
+		# communication
+LIBFILES+=	sc_clock.o              \
+		sc_event_finder.o       \
+		sc_event_queue.o        \
+		sc_export.o             \
+		sc_interface.o          \
+		sc_mutex.o              \
+		sc_port.o               \
+		sc_prim_channel.o       \
+		sc_semaphore.o          \
+		sc_signal.o             \
+		sc_signal_ports.o       \
+		sc_signal_resolved.o    \
+		sc_signal_resolved_ports.o
+
+		# tracing
+LIBFILES+=	sc_trace.o              \
+		sc_vcd_trace.o          \
+		sc_wif_trace.o
+
+		# utils
+LIBFILES+=	sc_exception.o          \
+		sc_hash.o               \
+		sc_list.o               \
+		sc_mempool.o            \
+		sc_pq.o                 \
+		sc_report.o             \
+		sc_report_handler.o     \
+		sc_stop_here.o          \
+		sc_string.o             \
+		sc_utils_ids.o          \
+		sc_vector.o
+
+		# datatypes/bit
+LIBFILES+=	sc_bit.o                \
+		sc_bv_base.o            \
+		sc_logic.o              \
+		sc_lv_base.o
+
+		# datatypes/fx
+LIBFILES+=	sc_fxcast_switch.o      \
+		sc_fxdefs.o             \
+		sc_fxnum.o              \
+		sc_fxnum_observer.o     \
+		sc_fxtype_params.o      \
+		sc_fxval.o              \
+		sc_fxval_observer.o     \
+		scfx_mant.o             \
+		scfx_pow10.o            \
+		scfx_rep.o              \
+		scfx_utils.o
+
+		# datatypes/int
+LIBFILES+=	sc_int_base.o           \
+		sc_int32_mask.o         \
+		sc_int64_io.o           \
+		sc_int64_mask.o         \
+		sc_length_param.o       \
+		sc_nbdefs.o             \
+		sc_nbexterns.o          \
+		sc_nbutils.o            \
+		sc_signed.o             \
+		sc_uint_base.o          \
+		sc_unsigned.o
+
+		# datatypes/misc
+LIBFILES+=	sc_concatref.o          \
+		sc_value_base.o
+
+ifeq "$(TARGET)" "i686-linux"
+		# qt
+LIBFILES+=	qt.o                    \
+		i386.o
+endif
+
+LIBTARGETS:=	$(o-debug)/libsystemc.a $(o-release)/libsystemc.a
+
+#ifeq "$(OS)" "win32"
+#	LIBFILES+=
+#endif
+
+# ..........................................................................
+
+$(o-release)/libsystemc.a:	$(patsubst %,$(o-release)/%,$(LIBFILES))
+		$(MAKELIB)
+
+$(o-debug)/libsystemc.a:	$(patsubst %,$(o-debug)/%,$(LIBFILES))
+		$(MAKELIB)
+
+# ===== more rules, should go into their own file ==========================
+
+TARGETS+=	$(patsubst %,%$(X),$(PROGRAMS))
+TESTTARGETS+=	$(patsubst %,%$(X),$(TESTPROGRAMS))
+
+$(TARGETS):	$(LIBTARGETS)
+$(TESTTARGETS):	$(LIBTARGETS)
+
+# ----- normal build -------------------------------------------------------
+
+_all:		$(LIBTARGETS)                 \
+		$(TARGETS)                    \
+		$(TESTTARGETS)
+
+# ----- make only libraries ------------------------------------------------
+
+libs:		$(LIBTARGETS)
+
+# ----- clean up -----------------------------------------------------------
+
+_clean:
+		@echo Cleaning up...
+		@-rm $(o-debug)/*.o $(o-debug)/*.d $(o-release)/*.o $(o-release)/*.d \
+		$(wildcard $(LIBTARGETS))     \
+		$(wildcard $(TARGETS))        \
+		$(wildcard $(TESTTARGETS))    \
+		$(wildcard $(CLEAN))
+
+_targetclean:
+		@echo Cleaning up targets...
+		@-rm $(wildcard $(LIBTARGETS))  \
+		$(wildcard $(TARGETS))          \
+		$(wildcard $(TESTTARGETS))
+
+_test:		$(TESTTARGETS) $(patsubst %,%.run,$(TESTPROGRAMS))
+
+# ----- Make object directories --------------------------------------------
+
+_mkdir:
+		@$(MAKE) $(MAKEFILES) --quiet --no-print-directory -j1 OSTYPE=$(OSTYPE) _mkdir2
+
+_mkdir2:	o $(o-release) $(o-debug)
+
+o:
+		mkdir o
+
+$(o-release):
+		mkdir $(o-release)
+
+$(o-debug):
+		mkdir $(o-debug)
+
+
+-include $(wildcard $(o-debug)/*.d) $(wildcard $(o-release)/*.d)
+
+# ===== end more rules =====
+# ----- EOF Makefile -----
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_bv_base.h systemc-amd64/src/systemc/datatypes/bit/sc_bv_base.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_bv_base.h	2004-06-03 00:55:11.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/bit/sc_bv_base.h	2005-05-09 17:27:47.000000000 +0100
@@ -293,7 +293,7 @@
     int bi = i % UL_SIZE;
     unsigned long mask = UL_ONE << bi;
     m_data[wi] |= mask; // set bit to 1
-    m_data[wi] &= value << bi | ~mask;
+    m_data[wi] &= (unsigned long)value << bi | ~mask;
 }
 
 
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_logic.h systemc-amd64/src/systemc/datatypes/bit/sc_logic.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_logic.h	2004-06-03 00:55:11.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/bit/sc_logic.h	2005-05-09 17:27:47.000000000 +0100
@@ -98,8 +98,10 @@
 	{ return ( b ? Log_1 : Log_0 ); }
 
     static sc_logic_value_t to_value( char c )
-	{
-	    sc_logic_value_t v = char_to_logic[(int)c];
+        {   unsigned i=c;
+            if(i>sizeof(char_to_logic)/sizeof(char_to_logic[0]))
+                invalid_value( c );
+            sc_logic_value_t v = char_to_logic[i];
 	    if( v < Log_0 || v > Log_X ) {
 		invalid_value( c );
 	    }
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_lv_base.cpp systemc-amd64/src/systemc/datatypes/bit/sc_lv_base.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_lv_base.cpp	2004-06-03 00:55:11.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/bit/sc_lv_base.cpp	2005-05-09 17:27:47.000000000 +0100
@@ -87,8 +87,9 @@
     int min_len = sc_min( len, s_len );
     int i = 0;
     for( ; i < min_len; ++ i ) {
-	char c = s[s_len - i - 1];
-	set_bit( i, sc_logic::char_to_logic[(int)c] );
+	unsigned c = s[s_len - i - 1];
+        if(c<sizeof(sc_logic::char_to_logic)/sizeof(sc_logic::char_to_logic[0]))
+           set_bit( i, sc_logic::char_to_logic[c] );
     }
     // if formatted, fill the rest with sign(s), otherwise fill with zeros
     sc_logic_value_t fill = (s[s_len] == 'F' ? sc_logic_value_t( s[0] - '0' )
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_lv_base.h systemc-amd64/src/systemc/datatypes/bit/sc_lv_base.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_lv_base.h	2004-10-12 18:25:29.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/bit/sc_lv_base.h	2005-05-09 17:27:47.000000000 +0100
@@ -300,11 +300,11 @@
 {
     int wi = i / UL_SIZE; // word index
     int bi = i % UL_SIZE; // bit index
-    unsigned long mask = UL_ONE << bi;
+    unsigned long mask = UL_ONE << bi, ulvalue=value;
     m_data[wi] |= mask; // set bit to 1
     m_ctrl[wi] |= mask; // set bit to 1
-    m_data[wi] &= value << bi | ~mask;
-    m_ctrl[wi] &= value >> 1 << bi | ~mask;
+    m_data[wi] &= ulvalue << bi | ~mask;
+    m_ctrl[wi] &= ulvalue >> 1 << bi | ~mask;
 }
 
 
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_proxy.h systemc-amd64/src/systemc/datatypes/bit/sc_proxy.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/bit/sc_proxy.h	2004-10-05 00:33:21.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/bit/sc_proxy.h	2005-05-09 17:27:47.000000000 +0100
@@ -708,8 +708,9 @@
     int min_len = sc_min( len, s_len );
     int i = 0;
     for( ; i < min_len; ++ i ) {
-	char c = s[s_len - i - 1];
-	x.set_bit( i, sc_logic::char_to_logic[c] );
+	unsigned c = s[s_len - i - 1];
+        if(c<sizeof(sc_logic::char_to_logic)/sizeof(sc_logic::char_to_logic[0]))
+            x.set_bit( i, sc_logic::char_to_logic[c]);
     }
     // if formatted, fill the rest with sign(s), otherwise fill with zeros
     sc_logic_value_t fill = (s[s_len] == 'F' ? sc_logic_value_t( s[0] - '0' )
@@ -781,13 +782,15 @@
 {
     X& x = back_cast();
     set_words_( x, 0, ((unsigned long) a & ~UL_ZERO), UL_ZERO );
+    #ifndef __x86_64__
     if( x.size() > 1 ) {
 	set_words_( x, 1,
-		    ((unsigned long) (a >> UL_SIZE) & ~UL_ZERO),
+          ((unsigned long) ((uint64) a >> UL_SIZE) & ~UL_ZERO),
 		    UL_ZERO );
 	// extend with zeros
 	extend_sign_w_( x, 2, false );
     }
+    #endif
     x.clean_tail();
     return x;
 }
@@ -799,13 +802,16 @@
 {
     X& x = back_cast();
     set_words_( x, 0, ((unsigned long) a & ~UL_ZERO), UL_ZERO );
+    #ifndef __x86_64__
     if( x.size() > 1 ) {
+       sc_assert(0 && "should never happen on AMD64");
 	set_words_( x, 1,
 		    ((unsigned long) ((uint64) a >> UL_SIZE) & ~UL_ZERO),
 		    UL_ZERO );
 	// extend with sign(a)
 	extend_sign_w_( x, 2, (a < 0) );
     }
+    #endif
     x.clean_tail();
     return x;
 }
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/fx/sc_context.h systemc-amd64/src/systemc/datatypes/fx/sc_context.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/fx/sc_context.h	2004-06-03 00:55:11.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/fx/sc_context.h	2005-05-09 17:27:47.000000000 +0100
@@ -224,6 +224,7 @@
 {
     // this method should never be called
     SC_REPORT_FATAL( SC_ID_INTERNAL_ERROR_, "should never be called" );
+    return 0;  // stop warnings
 }
 
 
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/fx/scfx_ieee.h systemc-amd64/src/systemc/datatypes/fx/scfx_ieee.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/fx/scfx_ieee.h	2004-06-03 00:55:12.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/fx/scfx_ieee.h	2005-05-09 17:27:47.000000000 +0100
@@ -54,7 +54,8 @@
 //  Little or big endian machine?
 // ----------------------------------------------------------------------------
 
-#if defined( i386 ) || defined(WIN32)
+#if defined( i386 ) || defined(WIN32) || defined(__x86_64__)
+   /* slightly bogus to check for WIN32 here, better check for MSVC on 386 */
 # define SCFX_LITTLE_ENDIAN
 #elif defined( __ppc__ ) || defined( sparc ) || defined( __hppa )
 # define SCFX_BIG_ENDIAN
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/fx/scfx_mant.cpp systemc-amd64/src/systemc/datatypes/fx/scfx_mant.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/fx/scfx_mant.cpp	2004-06-03 00:55:12.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/fx/scfx_mant.cpp	2005-05-09 17:27:47.000000000 +0100
@@ -29,8 +29,8 @@
   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
   changes you are making here.
 
-      Name, Affiliation, Date:
-  Description of Modification:
+      Name, Affiliation, Date: Frank Vorstenbosch, TML, 20050314                 
+  Description of Modification: Removed some horrendous pointer-vs-int cast bugs. 
 
  *****************************************************************************/
 
@@ -57,11 +57,16 @@
     return index;
 }
 
+#if !defined(__x86_64__)
 static word* free_words[32] = { 0 };
+#endif
 
 word*
 scfx_mant::alloc_word( size_t size )
 {
+#if defined(__x86_64__)
+    return new word[size];
+#else
     const int ALLOC_SIZE = 128;
 
     int slot_index = next_pow2_index( size );
@@ -84,11 +89,15 @@
     word* result = slot;
     slot = reinterpret_cast<word*>( slot[0] );
     return result;
+#endif
 }
 
 void
 scfx_mant::free_word( word* array, size_t size )
 {
+#if defined(__x86_64__)
+    delete [] array;
+#else
     if( array && size )
     {
         int slot_index = next_pow2_index( size );
@@ -98,6 +107,7 @@
 	array[0] = reinterpret_cast<word>( slot );
 	slot = array;
     }
+#endif
 }
 
 } // namespace sc_dt
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/fx/scfx_mant.h systemc-amd64/src/systemc/datatypes/fx/scfx_mant.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/fx/scfx_mant.h	2004-06-03 00:55:12.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/fx/scfx_mant.h	2005-05-09 17:27:47.000000000 +0100
@@ -29,8 +29,8 @@
   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
   changes you are making here.
 
-      Name, Affiliation, Date:
-  Description of Modification:
+      Name, Affiliation, Date: Frank Vorstenbosch, TML, 20050314
+  Description of Modification: Removed some horrendous pointer-vs-int cast bugs.
 
  *****************************************************************************/
 
@@ -51,7 +51,7 @@
 class scfx_mant_ref;
 
 
-typedef unsigned long  word;
+typedef unsigned word;              /* changed to be portable to __x86_64__ too */
 typedef unsigned short half_word;
 
 
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_int64_mask.cpp systemc-amd64/src/systemc/datatypes/int/sc_int64_mask.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_int64_mask.cpp	2004-06-03 00:55:13.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/int/sc_int64_mask.cpp	2005-05-09 17:27:47.000000000 +0100
@@ -50,7 +50,7 @@
 namespace sc_dt
 {
 
-#ifndef WIN32
+#ifndef _MSC_VER
 
 const uint_type mask_int[SC_INTWIDTH][SC_INTWIDTH] = 
 {
@@ -2264,7 +2264,7 @@
 }
 };
 
-#else //end of #ifndef WIN32
+#else //end of #ifndef _MSC_VER
 
 const uint_type mask_int[SC_INTWIDTH][SC_INTWIDTH] = 
 {
@@ -4478,7 +4478,7 @@
 }
 };
 
-#endif // end of #ifndef WIN32
+#endif // end of #ifndef _MSC_VER
 
 } // namespace sc_dt
 
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_nbdefs.cpp systemc-amd64/src/systemc/datatypes/int/sc_nbdefs.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_nbdefs.cpp	2004-06-03 00:55:13.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/int/sc_nbdefs.cpp	2005-05-09 17:27:47.000000000 +0100
@@ -53,7 +53,7 @@
 
 // Support for the long long type. This type is not in the standard
 // but is usually supported by compilers.
-#ifndef WIN32
+#ifndef _MSC_VER
 const uint64 UINT64_ZERO   = 0ULL;
 const uint64 UINT64_ONE    = 1ULL;
 const uint64 UINT64_32ONES = 0x00000000ffffffffULL;
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_nbdefs.h systemc-amd64/src/systemc/datatypes/int/sc_nbdefs.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_nbdefs.h	2004-06-03 00:55:13.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/int/sc_nbdefs.h	2005-05-09 17:27:47.000000000 +0100
@@ -115,7 +115,7 @@
 
 // Support for the long long type. This type is not in the standard
 // but is usually supported by compilers.
-#ifndef WIN32
+#ifndef _MSC_VER
     typedef long long          int64;
     typedef unsigned long long uint64;
     extern const uint64        UINT64_ZERO;
@@ -152,7 +152,7 @@
 // Above, BITS_PER_X is mainly used for sc_signed, and BITS_PER_UX is
 // mainly used for sc_unsigned.
 
-#if defined( WIN32 ) || defined( __SUNPRO_CC ) || defined( __HP_aCC )
+#if defined( _MSC_VER ) || defined( __SUNPRO_CC ) || defined( __HP_aCC )
 typedef unsigned long fmtflags;
 #else
 typedef ios::fmtflags fmtflags;
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_nbutils.h systemc-amd64/src/systemc/datatypes/int/sc_nbutils.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_nbutils.h	2004-06-03 00:55:13.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/int/sc_nbutils.h	2005-05-09 17:27:47.000000000 +0100
@@ -38,7 +38,7 @@
 #define SC_NBUTILS_H
 
 
-#if !defined(__ppc__) && !defined(_MSC_VER) && !defined(i386) && !defined(__hpux) && !defined( __BORLANDC__ )
+#if !defined(__ppc__) && !defined(_MSC_VER) && !defined(i386) && !defined(__hpux) && !defined( __BORLANDC__ ) && !defined( __GNUC__ )
 #include <ieeefp.h>
 #else
 #include <math.h>
@@ -543,7 +543,7 @@
   register int i = 0;
 
   while (v && (i < ulen)) {
-#ifndef WIN32
+#ifndef _MSC_VER
     u[i++] = static_cast<unsigned long>( v & DIGIT_MASK );
 #else
     u[i++] = ((unsigned long) v) & DIGIT_MASK;
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_signed.cpp systemc-amd64/src/systemc/datatypes/int/sc_signed.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_signed.cpp	2004-06-03 00:55:13.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/int/sc_signed.cpp	2005-05-09 17:27:47.000000000 +0100
@@ -492,7 +492,7 @@
     sgn = SC_POS;
   register int i = 0;
   while (floor(v) && (i < ndigits)) {
-#ifndef WIN32
+#ifndef _MSC_VER
     digit[i++] = (unsigned long) floor(remainder(v, DIGIT_RADIX));
 #else
     digit[i++] = (unsigned long) floor(fmod(v, DIGIT_RADIX));
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_signed_subref.inc systemc-amd64/src/systemc/datatypes/int/sc_signed_subref.inc
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_signed_subref.inc	2004-09-07 21:41:32.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/int/sc_signed_subref.inc	2005-05-09 17:27:47.000000000 +0100
@@ -255,7 +255,7 @@
     register int i = 0;
 
     while (floor(v) && (i < nd)) {
-#ifndef WIN32
+#ifndef _MSC_VER
 	d[i++] = (unsigned long) floor(remainder(v, DIGIT_RADIX));
 #else
 	d[i++] = (unsigned long) floor(fmod(v, DIGIT_RADIX));
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_unsigned.cpp systemc-amd64/src/systemc/datatypes/int/sc_unsigned.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_unsigned.cpp	2004-06-03 00:55:13.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/int/sc_unsigned.cpp	2005-05-09 17:27:47.000000000 +0100
@@ -415,7 +415,7 @@
   sgn = SC_POS;
   register int i = 0;
   while (floor(v) && (i < ndigits)) {
-#ifndef WIN32
+#ifndef _MSC_VER
     digit[i++] = (unsigned long) floor(remainder(v, DIGIT_RADIX));
 #else
     digit[i++] = (unsigned long) floor(fmod(v, DIGIT_RADIX));
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_unsigned_subref.inc systemc-amd64/src/systemc/datatypes/int/sc_unsigned_subref.inc
--- systemc_2_1.oct_12_2004.beta/src/systemc/datatypes/int/sc_unsigned_subref.inc	2004-09-07 21:43:03.000000000 +0100
+++ systemc-amd64/src/systemc/datatypes/int/sc_unsigned_subref.inc	2005-05-09 17:27:47.000000000 +0100
@@ -254,7 +254,7 @@
     register int i = 0;
 
     while (floor(v) && (i < nd)) {
-#ifndef WIN32
+#ifndef _MSC_VER
 	d[i++] = (unsigned long) floor(remainder(v, DIGIT_RADIX));
 #else
 	d[i++] = (unsigned long) floor(fmod(v, DIGIT_RADIX));
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/kernel/sc_cor_fiber.cpp systemc-amd64/src/systemc/kernel/sc_cor_fiber.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/kernel/sc_cor_fiber.cpp	2004-06-03 00:55:13.000000000 +0100
+++ systemc-amd64/src/systemc/kernel/sc_cor_fiber.cpp	2005-05-09 17:27:47.000000000 +0100
@@ -36,10 +36,10 @@
 
 #ifdef WIN32
 
+#include <windows.h>
 #include "systemc/kernel/sc_cor_fiber.h"
 #include "systemc/kernel/sc_simcontext.h"
 
-
 // ----------------------------------------------------------------------------
 //  File static variables.
 // ----------------------------------------------------------------------------
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/kernel/sc_cor_fiber.h systemc-amd64/src/systemc/kernel/sc_cor_fiber.h
--- systemc_2_1.oct_12_2004.beta/src/systemc/kernel/sc_cor_fiber.h	2004-06-03 00:55:14.000000000 +0100
+++ systemc-amd64/src/systemc/kernel/sc_cor_fiber.h	2005-05-09 17:27:47.000000000 +0100
@@ -42,6 +42,11 @@
 #include "systemc/kernel/sc_cor.h"
 #include "systemc/kernel/sc_cmnhdr.h"
 
+#ifndef _WINBASE_
+   // we avoid pulling in all of windows.h here just to get PVOID
+   typedef void *PVOID;
+#endif
+
 class sc_cor_pkg_fiber;
 
 
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/kernel/sc_cor_pthread.cpp systemc-amd64/src/systemc/kernel/sc_cor_pthread.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/kernel/sc_cor_pthread.cpp	2004-09-22 00:59:00.000000000 +0100
+++ systemc-amd64/src/systemc/kernel/sc_cor_pthread.cpp	2005-05-09 17:27:47.000000000 +0100
@@ -50,6 +50,17 @@
 
 #define DEBUGF if (0) printf
 
+/*
+ * Any use of the ptr_to_int function is a BUG. Left here because they were
+ * only used in error reporting, but this really should be fixed. The C/C++
+ * standards make no guarantees on pointer vs int sizes.
+ */
+#if defined(__x86_64__)
+static inline int ptr_to_int(const void *p) { return int(reinterpret_cast<long>(p)); }
+#else
+static inline int ptr_to_int(const void *p) { return reinterpret_cast<int>(p); }
+#endif
+
 // ----------------------------------------------------------------------------
 //  File static variables.
 //
@@ -76,7 +87,7 @@
 sc_cor_pthread::sc_cor_pthread()
     : m_cor_fn_arg( 0 ), m_pkg_p( 0 )
 {
-    DEBUGF("%08x: sc_cor_pthread::sc_cor_pthread()\n", (int)this);
+    DEBUGF("%08x: sc_cor_pthread::sc_cor_pthread()\n", ptr_to_int(this));
     pthread_cond_init( &m_pt_condition, PTHREAD_NULL );
     pthread_mutex_init( &m_mutex, PTHREAD_NULL );
 }
@@ -98,7 +109,7 @@
 void* sc_cor_pthread::invoke_module_method(void* context_p)
 {
     sc_cor_pthread* p = (sc_cor_pthread*)context_p;
-    DEBUGF("%08x: sc_cor_pthread::invoke_module_method()\n", (int)p);
+    DEBUGF("%08x: sc_cor_pthread::invoke_module_method()\n", ptr_to_int(p));
 
 
     // SUSPEND THE THREAD SO WE CAN GAIN CONTROL FROM THE PTHREAD PACKAGE:
@@ -113,16 +124,16 @@
     pthread_cond_signal( &create_condition );
     pthread_mutex_lock( &p->m_mutex );
     pthread_mutex_unlock( &create_mutex );
-    // DEBUGF("%08x: wait %d\n", (int)p, __LINE__);
+    // DEBUGF("%08x: wait %d\n", ptr_to_int(p), __LINE__);
     pthread_cond_wait( &p->m_pt_condition, &p->m_mutex );
-    // DEBUGF("%08x: back from wait %d\n", (int)p, __LINE__);
+    // DEBUGF("%08x: back from wait %d\n", ptr_to_int(p), __LINE__);
     pthread_mutex_unlock( &p->m_mutex );
 
 
     // CALL THE SYSTEMC CODE THAT WILL ACTUALLY START THE THREAD OFF:
 
-    DEBUGF("%08x: about to invoke real method %08x\n", (int)p, 
-        (int)active_cor_p);
+    DEBUGF("%08x: about to invoke real method %08x\n", ptr_to_int(p), 
+        ptr_to_int(active_cor_p));
     active_cor_p = p;
     (p->m_cor_fn)(p->m_cor_fn_arg);
 
@@ -172,7 +183,7 @@
 sc_cor_pkg_pthread::create( size_t stack_size, sc_cor_fn* fn, void* arg )
 {
     sc_cor_pthread* cor_p = new sc_cor_pthread;
-    DEBUGF("%08x: sc_cor_pkg_pthread::create\n", (int)cor_p);
+    DEBUGF("%08x: sc_cor_pkg_pthread::create\n", ptr_to_int(cor_p));
 
 
     // INITIALIZE OBJECT'S FIELDS FROM ARGUMENT LIST:
@@ -195,17 +206,18 @@
     // the main thread continues execution.
 
     pthread_mutex_lock( &create_mutex );
+
     if ( pthread_create( &cor_p->m_thread, PTHREAD_NULL,
-             &sc_cor_pthread::invoke_module_method, (void*)cor_p ) )
+             &sc_cor_pthread::invoke_module_method, (void*)cor_p ) )    /* this pthread_create segfaults */
     {
         fprintf(stderr, "ERROR - could not create thread\n");
     }
 
-    DEBUGF("%08x: wait %d\n", (int)cor_p, __LINE__);
+    DEBUGF("%08x: wait %d\n", ptr_to_int(cor_p), __LINE__);
     pthread_cond_wait( &create_condition, &create_mutex );
-    DEBUGF("%08x: back from wait %d\n", (int)cor_p, __LINE__);
+    DEBUGF("%08x: back from wait %d\n", ptr_to_int(cor_p), __LINE__);
     pthread_mutex_unlock( &create_mutex );
-    DEBUGF("%08x: exiting sc_cor_pkg_pthread::create\n", (int)cor_p);
+    DEBUGF("%08x: exiting sc_cor_pkg_pthread::create\n", ptr_to_int(cor_p));
 
     return cor_p;
 }
@@ -222,16 +234,16 @@
     sc_cor_pthread* from_p = active_cor_p;
     sc_cor_pthread* to_p = (sc_cor_pthread*)next_cor_p;
 
-    DEBUGF("%08x: switching to %08x\n", (int)from_p, (int)to_p);
+    DEBUGF("%08x: switching to %08x\n", ptr_to_int(from_p), ptr_to_int(to_p));
     if ( to_p != from_p )
     {
         pthread_mutex_lock( &to_p->m_mutex );
         pthread_cond_signal( &to_p->m_pt_condition );
         pthread_mutex_lock( &from_p->m_mutex );
         pthread_mutex_unlock( &to_p->m_mutex );
-        DEBUGF("%08x: wait %d %08x\n", (int)from_p, __LINE__, (int)&from_p);
+        DEBUGF("%08x: wait %d %08x\n", ptr_to_int(from_p), __LINE__, ptr_to_int(&from_p));
         pthread_cond_wait( &from_p->m_pt_condition, &from_p->m_mutex );
-        DEBUGF("%08x: back from wait %d %08x\n", (int)from_p, __LINE__, (int)&from_p);
+        DEBUGF("%08x: back from wait %d %08x\n", ptr_to_int(from_p), __LINE__, ptr_to_int(&from_p));
         pthread_mutex_unlock( &from_p->m_mutex );
     }
 
@@ -246,7 +258,7 @@
 {
     sc_cor_pthread* n_p = (sc_cor_pthread*)next_cor_p;
 
-    DEBUGF("%08x: aborting, switching to %08x\n", (int)active_cor_p, (int)n_p);
+    DEBUGF("%08x: aborting, switching to %08x\n", ptr_to_int(active_cor_p), ptr_to_int(n_p));
     pthread_mutex_lock( &n_p->m_mutex );
     pthread_cond_signal( &n_p->m_pt_condition );
     pthread_mutex_unlock( &n_p->m_mutex );
diff -Nur systemc_2_1.oct_12_2004.beta/src/systemc/utils/sc_report_handler.cpp systemc-amd64/src/systemc/utils/sc_report_handler.cpp
--- systemc_2_1.oct_12_2004.beta/src/systemc/utils/sc_report_handler.cpp	2004-06-03 00:55:21.000000000 +0100
+++ systemc-amd64/src/systemc/utils/sc_report_handler.cpp	2005-05-09 17:27:48.000000000 +0100
@@ -45,6 +45,17 @@
 namespace std {}
 using namespace std;
 
+/*
+ * Any use of the ptr_to_int function is a BUG. Left here because they were
+ * only used in error reporting, but this really should be fixed. The C/C++
+ * standards make no guarantees on pointer vs int sizes.
+ */
+#if defined(__x86_64__)
+static inline int ptr_to_int(const void *p) { return int(reinterpret_cast<long>(p)); }
+#else
+static inline int ptr_to_int(const void *p) { return reinterpret_cast<int>(p); }
+#endif
+
 const sc_string sc_report_compose_message(const sc_report&);
 bool sc_report_close_default_log();
 
@@ -86,11 +97,11 @@
     }
     if ( actions & SC_STOP )
     {
-	sc_stop_here((int)rep.get_msg_type(), rep.get_severity());
+	sc_stop_here(ptr_to_int(rep.get_msg_type()), rep.get_severity());
 	sc_stop();
     }
     if ( actions & SC_INTERRUPT )
-	sc_interrupt_here((int)rep.get_msg_type(), rep.get_severity());
+	sc_interrupt_here(ptr_to_int(rep.get_msg_type()), rep.get_severity());
 
     if ( actions & SC_ABORT )
 	abort();
