Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Akeroyd, FA (Freddie) <F.A.Akeroyd <at> rl.ac.uk>
Subject: Building GNU Smalltalk-2.3.5 with MinGW
Newsgroups: gmane.comp.lang.smalltalk.gnu.general
Date: Thursday 14th June 2007 16:27:31 UTC (over 10 years ago)
Hi,

I've been playing with compiling GNU Smalltalk-2.3.5 on MinGW and had
some success. I have been able to build the code and "make check" passes
with only one failure (quit.st), but some issues remain with paths that
need further work and, probably, more knowledge of the internals of GNU
Smalltalk than I have. With the enclosed changes applied, remaking the
documentation will fail due to path issues and any paths supplied need
to be in c:/some/where format rather than c:\some\where. I haven't
extensively tested the program further than "make check" so other issues
may be present too, but I'm posting my changes in the hope that they
might be useful towards a full MinGW port.

The build sequence I used was:

* Run    ./configure --without-readline --without-gmp
* Edit the top Makefile and change  `cygpath -w gsticon.ico`  to just
gsticon.ico
* in the tests directory run     unix2dos -o *.ok
* Apply the enclosed changes to lib-src/poll.c, libgst/cint.c,
libgst/sysdep.c, kernel/Directory.st, kernel/File.st and
kernel/FileDescr.st 
* type  make
* type  make  again (the first make fails when rebuilding the classes
doc)
* make check (maybe more than once if it tries to rebuild the doc again)

Freddie



## ---------------------- ##
## Detailed failed tests. ##
## ---------------------- ##

#                             -*- compilation -*-
22. testsuite.at:48: testing ...
./testsuite.at:48: cd $abs_srcdir && $GST -r quit.st 2>&1
--- expout      Thu Jun 14 13:21:23 2007
+++ /home/faa59/smalltalk-2.3.5/tests/testsuite.dir/at-stdout   Thu Jun
14 13:21
:23 2007
@@ -1,2 +0,0 @@
-^M
-Execution begins...^M
22. testsuite.at:48: 22. quit.st (testsuite.at:48): FAILED
(testsuite.at:48)


## ---------------------- ##
## Code changes           ##
## ---------------------- ##

--- ../smalltalk-2.3.5-orig/lib-src/poll.c	Wed Jan  3 10:51:30 2007
+++ lib-src/poll.c	Thu Jun 14 13:55:29 2007
@@ -19,14 +19,45 @@
    with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
 
+
 #include "config.h"
 
 #include 
 #include "poll.h"
 #include 
+#include 
 #include 
-#include 
-#include 
+#include 
+#include 
+#include 
+
+#undef FD_ISSET
+#define FD_ISSET(fd, set) my_fd_isset(fd, set)  /* to avoid a WSA call
*/
+
+static int my_fd_isset(int fd, fd_set* set)
+{
+	int i;
+	if (set == NULL)
+	{
+	    return 0;
+	}
+	for(i=0; i < set->fd_count; i++)
+	{
+		if (set->fd_array[i] == fd)
+		{
+			return 1;
+		}
+	}
+	return 0;
+}
+
+#define ESHUTDOWN WSAESHUTDOWN
+#define ENOTCONN WSAENOTCONN
+#define ECONNRESET WSAECONNRESET
+#define ECONNABORTED WSAECONNABORTED
+#define ENETRESET WSAENETRESET
+
+typedef int nfds_t;
 #include 
 
 #ifdef HAVE_SYS_IOCTL_H
@@ -55,6 +86,76 @@
 #define EOVERFLOW EINVAL
 #endif
 
+// n = maxfd + 1
+#define MAX_WIN_HANDLES	300
+static int win_select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds,
struct timeval *ptv)
+{
+	HANDLE handle_array[MAX_WIN_HANDLES];
+        int handle_fd[MAX_WIN_HANDLES];
+	fd_set* handle_set[MAX_WIN_HANDLES];
+	int i;
+	DWORD ret, wait_timeout, nhandles = 0;
+	int nset, done;
+	done = 0;
+	nset = 0;
+	_flushall();
+		for(i=0; i 0)) // nothing set, so
wait full time
+		{
+		    if (ptv == NULL)
+		    {
+			wait_timeout = INFINITE;
+		    }
+		    else
+		    {
+			wait_timeout = ptv->tv_sec * 1000 + ptv->tv_usec
/ 1000;
+		    }
+/* Need to use MsgWaitForMultipleObjects and maybe pump messages if a
GUI application? */
+
+			ret = WaitForMultipleObjectsEx(nhandles,
handle_array, FALSE, wait_timeout, FALSE);
+			i = ret - WAIT_OBJECT_0;
+			if (i >= 0 && i < nhandles)
+			{
+				FD_SET(handle_fd[i], handle_set[i]);
+				nset++;
+			}
+		}
+	return nset;
+}
+
 int
 poll (pfd, nfd, timeout)
      struct pollfd *pfd;
@@ -142,8 +243,9 @@
     }
 
   /* examine fd sets */
-  rc = select (maxfd + 1, &rfds, &wfds, &efds, ptv);
-  if (rc < 0)
+   rc = win_select (maxfd + 1, &rfds, &wfds, &efds, ptv);
+    
+	if (rc < 0)
     return rc;
 
   /* establish results */
@@ -158,6 +260,7 @@
 	  {
 	    int r;
 	    
+	    char data[64];
 #if defined __MACH__ && defined __APPLE__
 	    /* There is a bug in Mac OS X that causes it to ignore
MSG_PEEK
 	       for some kinds of descriptors.  Detect if this descriptor
is a
@@ -167,9 +270,9 @@
 	    if (r == 0 || errno == ENOTSOCK)
 	      ioctl(pfd[i].fd, FIONREAD, &r);
 #else
-	    char data[64];
-	    r = recv (pfd[i].fd, data, sizeof (data), MSG_PEEK);
+//	    r = recv (pfd[i].fd, data, sizeof (data), MSG_PEEK);
 #endif
+	    r = 1;
 	    if (r == 0)
 	      happened |= POLLHUP;
 	    
--- ../smalltalk-2.3.5-orig/libgst/cint.c	Thu Dec  7 08:09:12 2006
+++ libgst/cint.c	Thu Jun 14 12:19:44 2007
@@ -341,7 +341,8 @@
   times[0].tv_sec = new_atime + 86400 * 10957;
   times[1].tv_sec = new_mtime + 86400 * 10957;
   times[0].tv_usec = times[1].tv_usec = 0;
-  result = utimes (name, times);
+  result = 0;
+  printf("utimes called\n"); /* needs fixing */
   if (!result)
     errno = 0;
   return (result);
--- ../smalltalk-2.3.5-orig/libgst/sysdep.c	Mon May  7 14:12:04 2007
+++ libgst/sysdep.c	Thu Jun 14 12:18:17 2007
@@ -710,7 +710,7 @@
   char *cwd;
   char *ret;
   unsigned path_max;
-  int save_errno;
+  int i, save_errno;
 
   path_max = (unsigned) PATH_MAX;
   path_max += 2;		/* The getcwd docs say to do this.  */
@@ -721,6 +721,11 @@
   do
     {
       ret = getcwd (cwd, path_max);
+      for(i=0; i= 3) and: [ ((fileName at: 2) = $:) and: [
((fileName at: 3) = $/) ]]) ifTrue: [ ^fileName ].
     (self pathSeparator = $\ and: [ fileName size >= 2 and: [
 	(fileName at: 2) = $: ]]) ifTrue: [ ^fileName ].
     ^(directory at: directory size) = self pathSeparator
--- ../smalltalk-2.3.5-orig/kernel/File.st	Sun Feb  5 18:41:26 2006
+++ kernel/File.st	Thu Jun 14 12:17:00 2007
@@ -132,9 +132,19 @@
     "Answer the full path to a file called `aString', resolving the `.'
and
      `..' directory entries, and answer the result.  `/..' is the same
as '/'."
 
-    | path substrings |
+    | path substrings respath isAbsolute |
+    isAbsolute _ false.
+    "Windows paths starting X:/ are absolute"
+    (aString size >= 3) ifTrue: [ 
+	( ((aString at: 2) = $:) & ((aString at: 3) = $/) ) ifTrue: [
+	    isAbsolute _ true
+	]
+    ].
+    ((aString at: 1) = Directory pathSeparator) ifTrue: [
+        isAbsolute _ true.
+    ].
     path := OrderedCollection new.
-    (aString at: 1) = Directory pathSeparator ifFalse: [
+    isAbsolute ifFalse: [
 	path addAll: (Directory working substrings: Directory
pathSeparator).
     ].
     substrings := aString substrings: Directory pathSeparator.
@@ -148,9 +158,16 @@
 	]
     ].
 
-    ^path inject: '/' into: [ :old :each |
+    respath _ path inject: '/' into: [ :old :each |
 	Directory append: each to: old
-    ]
+    ].
+    "remove initial / from /C:/"
+    (respath size >= 4) ifTrue: [ 
+	( ((respath at: 1) = $/) & ((respath at: 3) = $:) & ((respath
at: 4) = $/) ) ifTrue: [
+	    respath _ respath copyFrom: 2
+	]
+    ].
+    ^respath
 ! !
 
 
--- ../smalltalk-2.3.5-orig/kernel/FileDescr.st	Fri May 18 12:35:09 2007
+++ kernel/FileDescr.st	Thu Jun 14 12:16:21 2007
@@ -103,7 +103,8 @@
      finished with it anyway, using #close. To keep a file open even
when
      no references exist anymore, send it #removeToBeFinalized"
 
-    ((fileName indexOfSubCollection: ':/') > 0 and: [
+"look for :// rather than :/ to avoid matching C:/some/where on
windows"
+    ((fileName indexOfSubCollection: '://') > 0 and: [
         fileMode = FileStream read ]) ifTrue: [
            ^NetClients.URIResolver openStreamOn: fileName ].
 
CD: 4ms