help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Building GNU Smalltalk-2.3.5 with MinGW


From: Akeroyd, FA \(Freddie\)
Subject: [Help-smalltalk] Building GNU Smalltalk-2.3.5 with MinGW
Date: Thu, 14 Jun 2007 17:27:31 +0100

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 <sys/types.h>
 #include "poll.h"
 #include <errno.h>
+#include <stdio.h>
 #include <limits.h>
-#include <sys/socket.h>
-#include <sys/select.h>
+#include <windows.h>
+#include <winsock2.h>
+#include <io.h>
+
+#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 <unistd.h>
 
 #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<n; i++)
+               {
+                       if ((efds != NULL) && FD_ISSET(i, efds))
+                       {
+                               FD_CLR(i, efds);                /*
assume no exceptions */
+                       }
+                       if ((wfds != NULL) && FD_ISSET(i, wfds))
+                       {
+                               handle_array[nhandles] =
(HANDLE)_get_osfhandle(i);
+                               handle_fd[nhandles] = i;
+                               handle_set[nhandles] = wfds;
+                               nhandles++;
+                               FD_CLR(i, wfds);                /* we
will set it later if there is output */
+                       }
+                       if ((rfds != NULL) && FD_ISSET(i, rfds))
+                       {
+                               handle_array[nhandles] =
(HANDLE)_get_osfhandle(i);
+                               handle_fd[nhandles] = i;
+                               handle_set[nhandles] = rfds;
+                               nhandles++;
+                               FD_CLR(i, rfds);                /* we
will set it later if there is input */
+                       }
+               }
+/* do a quick poll - WaitForMultipleObjects only tells us if 1 handle
+ is ready and there may be more */
+               for(i=0; i<nhandles; i++)
+               {
+                   ret = WaitForSingleObject(handle_array[i], 0);
+                   if (ret == WAIT_OBJECT_0)
+                   {
+                       FD_SET(handle_fd[i], handle_set[i]);
+                       nset++;
+                   }
+               }
+               if ((nset == 0) && (nhandles > 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<strlen(cwd); i++)
+      {
+        if (cwd[i] == '\\')
+          cwd[i] = '/';
+      }
       if (ret)
        return (cwd);
 
--- ../smalltalk-2.3.5-orig/kernel/Directory.st Sun Feb  5 18:41:26 2006
+++ kernel/Directory.st Thu Jun 14 12:17:52 2007
@@ -108,6 +108,10 @@
     directory isEmpty ifTrue: [ ^fileName ].
     (fileName at: 1) = self pathSeparator
        ifTrue: [ ^fileName ].
+    "Check to see if building up a windows absolute path from scratch
i.e. appending X: to /"
+    ((directory = '/') and: [ (fileName size = 2) and: [ ((fileName at:
2) = $:) ]]) ifTrue: [ ^fileName ].
+    "Check for a complete absolute windows path of form X:/"
+    ((fileName size >= 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 ].





reply via email to

[Prev in Thread] Current Thread [Next in Thread]