diff -urN ../tom-19980917/config/i386/i386.h ./config/i386/i386.h --- ../tom-19980917/config/i386/i386.h Wed Aug 19 02:04:16 1998 +++ ./config/i386/i386.h Fri Sep 18 13:08:22 1998 @@ -174,7 +174,7 @@ "pushl 8(%0)\n\t" \ "pushl 4(%0)\n\t" \ "pushl 20(%0)\n\t" \ - "call memcpy\n\t" \ + "call _memcpy\n\t" \ "addl $12, %%esp\n\t" \ "ffree %%st\n\t" \ "call *(%0)\n\t" \ diff -urN ../tom-19980917/config/i386/trt_send.S ./config/i386/trt_send.S --- ../tom-19980917/config/i386/trt_send.S Tue Sep 01 02:06:05 1998 +++ ./config/i386/trt_send.S Fri Sep 18 13:08:22 1998 @@ -57,7 +57,8 @@ movl %ecx,%eax andl $15,%eax movl (%edx,%eax,4),%eax - jmp %eax + pushl %eax + ret #ifndef NeXT .Lfe1: .size TRT_SEND,.Lfe1-TRT_SEND @@ -67,6 +68,5 @@ .text .align 4 .globl memcpy - .type memcpy,@function memcpy: jmp _memcpy #endif diff -urN ../tom-19980917/config/win32/i386.h ./config/win32/i386.h --- ../tom-19980917/config/win32/i386.h Wed Dec 31 17:00:00 1969 +++ ./config/win32/i386.h Fri Sep 18 13:08:22 1998 @@ -0,0 +1,17 @@ +/* + Written by Matt Kimball + + Copyright (C) 1998 Matt Kimball. + + This file is part of TOM. TOM is distributed under the terms of the + TOM License, a copy of which can be found in the TOM distribution; see + the file LICENSE. + + $Id: i386.h,v 1.7 1998/01/05 00:46:03 tiggr Exp $ */ + +#include +#include + +#define NeXT +#define AS_LABEL_UNDERSCORES + diff -urN ../tom-19980917/config/win32/os.c ./config/win32/os.c --- ../tom-19980917/config/win32/os.c Wed Dec 31 17:00:00 1969 +++ ./config/win32/os.c Fri Sep 18 13:08:22 1998 @@ -0,0 +1,27 @@ +/* + Written by Matt Kimball + + Copyright (C) 1998 Matt Kimball. + + This file is part of TOM. TOM is distributed under the terms of the + TOM License, a copy of which can be found in the TOM distribution; see + the file LICENSE. + + $Id: os.c,v 1.6 1998/02/23 13:22:46 tiggr Exp $ */ + +void +dload_initialize () +{ +} + +void * +dload_load (char *name) +{ + return NULL; +} + +void * +dload_lookup (void *handle, char *name) +{ + return NULL; +} diff -urN ../tom-19980917/config/win32/target.h ./config/win32/target.h --- ../tom-19980917/config/win32/target.h Wed Dec 31 17:00:00 1969 +++ ./config/win32/target.h Fri Sep 18 13:08:22 1998 @@ -0,0 +1,24 @@ +/* Win32 target OS. + Written by Matt Kimball + + Copyright (C) 1998 Matt Kimball. + + This file is part of TOM. TOM is distributed under the terms of the + TOM License, a copy of which can be found in the TOM distribution; see + the file LICENSE. + + $Id: target.h,v 1.5 1998/01/05 00:46:06 tiggr Exp $ */ + +#ifndef __ASSEMBLER__ +#define DEFAULT_LOAD_PATH 1, @"/tom" +#define BZERO(A, N) memset ((A), 0, (N)) + +#include +#include +#ifndef YYBISON +#include +#endif +#undef vm_page_size + +#define SOMETHINGS_VERY_WRONG_WITH_THE_GNU_RUNTIME +#endif diff -urN ../tom-19980917/trt/alloc.c ./trt/alloc.c --- ../tom-19980917/trt/alloc.c Tue Jul 28 05:36:22 1998 +++ ./trt/alloc.c Fri Sep 18 13:08:22 1998 @@ -840,10 +840,13 @@ tom_double time_since_unix_epoch (void) { - struct timeval tv; + SYSTEMTIME stime; + FILETIME time; - gettimeofday (&tv, NULL); - return tv.tv_sec + tv.tv_usec / 1e6; + GetLocalTime(&stime); + SystemTimeToFileTime(&stime, &time); + + return (time.dwHighDateTime * 256.0 * 256.0 * 256.0 * 256.0 + time.dwLowDateTime) * 1.0e-7; } void diff -urN ../tom-19980917/trt/main.c ./trt/main.c --- ../tom-19980917/trt/main.c Wed Aug 19 02:04:35 1998 +++ ./trt/main.c Fri Sep 18 13:08:22 1998 @@ -555,7 +555,8 @@ char *s = alloca (1024); /* This can only fail if S is an invalid address, which it isn't. */ - gethostname (s, 1024); +/* gethostname (s, 1024); */ + strcpy(s, "nowhere"); c_tom_Runtime_hostname = byte_string_with_c_string (s); } diff -urN ../tom-19980917/trt/perform.c ./trt/perform.c --- ../tom-19980917/trt/perform.c Wed Aug 19 02:04:37 1998 +++ ./trt/perform.c Fri Sep 18 13:08:22 1998 @@ -1170,8 +1170,8 @@ { DECL_SR (i_tom_InvocationResult, i_tom_State); - trt_lookup_super (SR (i_tom_InvocationResult, i_tom_State), - SEL (v_encodeUsingCoder_r)) (self, cmd, coder); +/* trt_lookup_super (SR (i_tom_InvocationResult, i_tom_State), + SEL (v_encodeUsingCoder_r)) (self, cmd, coder); */ { struct _es_i_tom_InvocationResult *this diff -urN ../tom-19980917/trt/thread.c ./trt/thread.c --- ../tom-19980917/trt/thread.c Tue Feb 24 15:56:54 1998 +++ ./trt/thread.c Fri Sep 18 13:08:22 1998 @@ -50,7 +50,7 @@ void *data; /* Timestamp. */ - struct timeval stamp; +/* struct timeval stamp; */ }; /* Head and tail of the delayed free list. */ @@ -66,7 +66,7 @@ struct free_delayed *f = xmalloc (sizeof (*f)); f->data = p; - gettimeofday (&f->stamp, 0); +/* gettimeofday (&f->stamp, 0); */ f->next = 0; *delay_tail = f; delay_tail = &f->next; diff -urN ../tom-19980917/trt/timespace.c ./trt/timespace.c --- ../tom-19980917/trt/timespace.c Wed May 13 04:19:08 1998 +++ ./trt/timespace.c Fri Sep 18 13:08:22 1998 @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -73,7 +72,8 @@ void c_tom_Date_v_load_r (tom_object self, selector cmd, tom_object args) { - struct timeval tv; +/* + struct timeval tv; gettimeofday (&tv, NULL); c_tom_Date_relative_offset = UNIX_OFFSET + tv.tv_sec; @@ -84,26 +84,26 @@ c_tom_Date_distant_past = TRT_SEND (_PI_, self, SEL (r_alloc)); TRT_SEND (_PI_, c_tom_Date_distant_past, SEL (r_initWithTimeIntervalSinceReferenceDate_d), - (tom_double) -1e+100); + (tom_double) -1e+100); */ } double c_tom_Date_d_timeIntervalSinceReferenceDate (tom_object self, selector cmd) { - struct timeval tv; +/* struct timeval tv; gettimeofday (&tv, NULL); - return UNIX_OFFSET + tv.tv_sec + tv.tv_usec * 1e-6; + return UNIX_OFFSET + tv.tv_sec + tv.tv_usec * 1e-6; */ } double c_tom_Date_d_relativeTimeIntervalSinceNow (tom_object self, selector cmd) { - struct timeval tv; +/* struct timeval tv; gettimeofday (&tv, NULL); return ((UNIX_OFFSET - c_tom_Date_relative_offset) - + tv.tv_sec + tv.tv_usec * 1e-6); + + tv.tv_sec + tv.tv_usec * 1e-6); */ } tom_object @@ -192,13 +192,13 @@ static tom_int tom_file_type (struct stat *st) { - if (S_ISSOCK (st->st_mode)) + /* if (S_ISSOCK (st->st_mode)) return c_tom_Constants_FILE_TYPE_SOCKET; if (S_ISLNK (st->st_mode)) return c_tom_Constants_FILE_TYPE_LINK; - if (S_ISREG (st->st_mode)) + if (S_ISREG (st->st_mode)) */ return c_tom_Constants_FILE_TYPE_REGULAR; - if (S_ISBLK (st->st_mode)) +/* if (S_ISBLK (st->st_mode)) return c_tom_Constants_FILE_TYPE_BLOCK; if (S_ISDIR (st->st_mode)) return c_tom_Constants_FILE_TYPE_DIRECTORY; @@ -206,7 +206,7 @@ return c_tom_Constants_FILE_TYPE_CHARACTER; if (S_ISFIFO (st->st_mode)) return c_tom_Constants_FILE_TYPE_FIFO; - return c_tom_Constants_FILE_TYPE_OTHER; + return c_tom_Constants_FILE_TYPE_OTHER; */ } tom_int @@ -219,7 +219,7 @@ char *s; C_STRING_WITH_TOM_STRING (s, len, name); - if (follow_link ? stat (s, &st) : lstat (s, &st)) + if(stat(s, &st)) { trt_raise (1, self, cmd, c_tom_Conditions_file_error, "%s", OS_ERROR_MSG); @@ -256,7 +256,7 @@ struct _es_i_tom_File *fs = trt_ext_address (self, _ei_i_tom_File); struct _es_i_tom_Descriptor *bs; char input_p, output_p, exists; - int flags = 0; + int flags = O_BINARY; tom_int l; char *s; diff -urN ../tom-19980917/win32mk.pl ./win32mk.pl --- ../tom-19980917/win32mk.pl Wed Dec 31 17:00:00 1969 +++ ./win32mk.pl Fri Sep 18 13:08:22 1998 @@ -0,0 +1,340 @@ +#!/usr/local/bin/perl +# +# This script will build TOM for win32. This script is necessary +# because autoconf doesn't appear to work correctly under win32. +# (It's win32's fault for not being Unix-like enough, really). +# +# Written by Matt Kimball +# +# Copyright (C) 1998 Matt Kimball. +# +# This file is part of TOM. TOM is distributed under the terms of the +# TOM License, a copy of which can be found in the TOM distribution; see +# the file LICENSE. +# + +#### +# +# Some environment defines +# +#### +$GNU_RUNTIME = 1; + +$HAVE_DIRENT_H = 1; +$HAVE_ERRNO_H = 1; +$HAVE_STRING_H = 1; +$HAVE_STRINGS_H = 1; +$HAVE_UNISTD_H = 1; + +$HAVE_BZERO = 1; +$HAVE_GETCWD = 1; +$HAVE_GETPAGESIZE = 1; +$HAVE_MEMMOVE = 1; +$HAVE_STRDUP = 1; +$HAVE_STRERROR = 1; +$HAVE_RANDOM = 1; +$HAVE_GETWD = 1; + +$NEED_SYS_ERRLIST = 1; +$PATH_PREFIX = '/tom'; +$THREADS_PACKAGE = 'THREADS_NO_THREADS'; + +$LOOKUP_DEFAULT = 'LOOKUP_LOOKUP'; +$OS_ERRNO = 'errno'; +$C_BYTE = 'unsigned char'; +$C_CHAR = 'unsigned short'; +$C_INT = 'int'; +$C_LONG = 'long long'; +$C_FLOAT = 'float'; +$C_DOUBLE = 'double'; +$POINTER_INT_TYPE = 'int'; +$GENERIC_RETURN_TYPE = 'void'; + +$CLASS_INTERFACE = "objc/Object.h"; +$CLASS = "Object"; +$PATCH_INTERFACE = "tl/TLPatchedRoots.h"; + +$CC = "/cygnus/h-i386-cygwin32/bin/gcc"; +$MINGWCC = "/ming/bin/gcc"; + +$CFLAGS = "-g -Wno-import -I. -Itl -I.. -I../config -I../tl -I../trt -DVERSION=\"\\\"0.99.2\\\"\" -DHOSTNAME=\"\\\"nowhere\\\"\" -Dltt -DDEBUG"; +$LDFLAGS = "../lti/liblti.a ../ltt/libltt.a ../tl/libtl.a -lobjc"; + +#### +# +# The targets we are building are listed here, along with the source files +# +#### + +$target = [ + [ "config", "config.h", "config.h.in" ], + [ "trt/tom", "trt.h", "trt.h.in" ], + + [ "tl", "config.h", "tl/config.h.in" ], + [ "tl", "tl/TLPatchedRoots.h", "TLRootPatch.h.in" ], + [ "tl", "TLPatchObject.m", "TLRootPatch.m.in" ], + [ "tl", "libtl.a", "*.m", ["predicates.m", "StringMethods.m", "TLPatchRoots.m"] ], + + [ "ltt", "libltt.a", "*.m" ], + [ "lti", "liblti.a", "*.m" ], + + [ "gi", "parse.in", "parse.y" ], + [ "gi", "parse.m", "parse.in" ], + [ "gi", "parse.h", "parse.in.h" ], + [ "gi", "lex.m", "lex.l" ], + [ "gi", "libgi.a", "*.m" ], + [ "gi", "gi.exe", "*.o" ], + + [ "tomc", "libtomc.a", "*.m" ], + [ "tomc", "tomc.exe", "*.o" ], + + [ "tomr", "libtomr.a", "*.m" ], + [ "tomr", "tomr.exe", "*.o" ], + + [ "", "switch-to-mingw", "switch-to-mingw" ], + + [ "tom", "tom.u", ".t" ], + [ "tom", ".cs", "*.t" ], + [ "tom", "tom-r.c", "tom.u" ], + [ "tom", "libtom.a", "*.c" ], + + [ "trt", "trt_send.o", "trt_send.S" ], + [ "trt", ".os", "*.c", ["arraydef.c", "numberdef.c", "set.c"] ], + [ "trt", "libtrt.a", "*.o" ], +]; + +$rules = [ + [ ".in", ".h", "&subst" ], + [ ".in", ".m", "&subst" ], + [ ".h", ".h", "copy " ], + [ ".y", ".in", "bison -d -v -p gi_ -o " ], + [ ".l", ".m", "flex -s -o " ], + [ ".m", ".o", " $CFLAGS -c -o " ], + [ ".c", ".o", " $CFLAGS -c -o " ], + [ ".S", ".o", " $CFLAGS -c -o " ], + [ ".t", ".u", "../gi/gi -u tom *.t" ], + [ ".t", ".c", "../tomc/tomc -1 -u tom " ], + [ ".u", ".c", "../tomr/tomr -1 -u tom" ], + [ "*.c", ".cs", "" ], + [ "*.o", ".os", "" ], + [ "*.o", ".a", "ar rc " ], + [ "*.o", ".exe", " -o $LDFLAGS" ], + + [ "switch-to-mingw", "switch-to-mingw", "&mingw" ], +]; + +system("copy config\\win32\\i386.h config\\target.h"); +system("mkdir config\\os"); +system("copy config\\win32\\*.* config\\os"); +system("mkdir config\\cpu"); +system("copy config\\i386\\*.* config\\cpu"); + +open(CONFIG, ">tom/config.t"); +print CONFIG <<"EOF"; + implementation class Constants extension config + { + const TOM_RESOURCES = "$PATH_PREFIX/charmaps"; + const TOM_PREFIX = "$PATH_PREFIX"; + + } + end; + + implementation instance Constants extension config end; +EOF +close(CONFIG); + +open(CONFIG, ">tl/TLPatchedRoots.m"); +print CONFIG <<"EOF"; + REFERENCE(__objc_class_name_TLPatchObject); +EOF +close(CONFIG); + +sub mingw { + $CC = $MINGWCC; + + 1; +} + +#### +# +# Build procedures begin here +# +#### + +sub subst { + my ($outfn, $infn) = @_; + + open(IN, $infn); + open(OUT, ">$outfn"); + + while() { + if(/^#define (.*) 0$/) { + my $r = eval("\$$1"); + if(defined($r)) { + s/0$/$r/; + } else { + $_ = "#define $1 0\n"; + } + } + + if(/^#define (.*) @(.*)@;$/) { + my $r = eval("\$$2"); + if(defined($r)) { + $_ = "#define $1 $r\n"; + } + } + + my $pre = ''; + while(/\@([a-zA-Z_]*)\@/) { + my $r = eval("\$$1"); + if(defined($r)) { + $_ = $` . $r . $'; + } else { + $pre = $pre . $`. '@' . $1; + $_ = '@' . $'; + } + } + $_ = $pre . $_; + + s/AT"/@"/g; + + print OUT; + } + + close(IN); + close(OUT); + + return 0; +} + +sub cmdvar { + my ($cmd, $item, $name) = @_; + + $cmd =~ s//$item/g; + $cmd =~ s//$name/g; + $cmd =~ s//$CC/g; + + return $cmd; +} + +sub build_multi { + my ($name, $list, $rule) = @_; + my ($from, $to, $cmd) = @$rule; + + $from = substr($from, 1); + $lst = ''; + foreach $item (@$list) { + my $target = $item; + $target =~ s/\.[^.]*$/$from/; + + if($target eq $item) { + $lst = $lst . ' ' . $item; + } else { + build_from($target, [ $item ]); + $lst = $lst . ' ' . $target; + } + } + + if(-e $name) { + return 1; + } + + $cmd = cmdvar($cmd, $lst, $name); + print "$cmd\n"; + + if(system($cmd)) { + exit 1; + } +} + +sub build_single { + my ($name, $item, $rule) = @_; + my ($from, $to, $cmd) = @$rule; + + if(substr($item, -length($from)) ne $from) { + print "Can't build $name from $item ($from)\n"; + exit 1; + } + + if($cmd =~ /^\&/) { + if(!defined(eval (substr($cmd, 1) . "('$name', '$item')"))) { + print "Error building $name with $cmd\n"; + exit 1; + } + } else { + if(-e $name) { + return 1; + } + + $cmd = cmdvar($cmd, $item, $name); + print "$cmd\n"; + + if(system($cmd)) { + exit 1; + } + } +} + +sub build_from { + my ($name, $list) = @_; + + foreach $rule (@$rules) { + my ($from, $to, $cmd) = @$rule; + + if(substr($name, -length($to)) eq $to) { + if($from =~ /^\*/) { + build_multi($name, $list, $rule); + } elsif($#$list != 0) { + print "Can't apply a single rule to multiple sources.\n"; + exit 1; + } elsif(substr($list->[0], -length($from)) eq $from) { + build_single($name, $list->[0], $rule); + } else { + next; + } + return; + } + } + + print "No rule found to build $name\n"; + exit 1; +} + +sub build_glob { + my ($dir, $name, $glob, $except) = @{$_[0]}; + + print " Building $name...\n"; + my $lastdir = Win32::GetCwd; + Win32::SetCwd $dir; + + my $list = []; +ITEM: + while(glob $glob) { + if(defined($except)) { + foreach $exception (@$except) { + if($exception eq $_) { + next ITEM; + } + } + } + + push(@$list, $_); + } + + build_from($name, $list); + + Win32::SetCwd $lastdir; +} + + +#### +# +# Main loop +# +#### + +foreach $t (@$target) { + build_glob($t); +} + +