[Vm-dev] patch: fix build problems on Solaris

Andrew Gaylard ag at computer.org
Sun Sep 23 20:48:38 UTC 2007


Hi,

This patch fixes 4 problems which prevented the VM from building
on Solaris/SPARC.  They shouldn't cause problems for other
platforms (famous last words), so please would someone (Ian?)
confirm this before checking in.

The problems fixed by this patch are:

   1. "sun" is already defined by some header or other in Solaris;
   I've changed it to s_un.
   2. AF_LOCAL isn't defined on Solaris.  W Richard Stevens'
   "Advanced programming in the Unix environment" says that
   AF_UNIX is more standard anyway.
   3. Solaris' feof() call really wants a FILE*.
   4. A missing prototype is added for sound_AvailableSpace(void)

With this patch, the VM builds and runs fine if built with gcc-3.4.3.
I've checked both the stock 3.9a-7024 image as well as the
etoys image. (My motivation for this whole exercise is to fix the
problems with audio under Solaris for my young daughter to use
etoys: the first sound plays, but after that, no sounds ever play.)

With gcc-4.2.1 and -O2, the VM won't even start up (complains
about a missing vm-display-X11, even though it's there).  With
gcc-4.2.1 and no -O2, the VM starts, runs for a short while, and
then cores with a bus error.  gdb shows a corrupt stack.  I'm
about to build gcc-4.1.2 and give it a spin building the VM to
try to track this down.  But I do suspect bad code generation
with gcc-4.2.1.


Thanks,
Andrew

Index: platforms/unix/plugins/SocketPlugin/sqUnixSocket.c
===================================================================
--- platforms/unix/plugins/SocketPlugin/sqUnixSocket.c  (revision 1762)
+++ platforms/unix/plugins/SocketPlugin/sqUnixSocket.c  (working copy)
@@ -149,7 +149,7 @@
 union sockaddr_any
 {
   struct sockaddr      sa;
-  struct sockaddr_un   sun;
+  struct sockaddr_un   s_un;
   struct sockaddr_in   sin;
   struct sockaddr_in6  sin6;
 };
@@ -533,7 +533,7 @@
   switch (domain)
     {
     case 0:    domain= AF_INET;        break;  /*
SQ_SOCKET_DOMAIN_UNSPECIFIED */
-    case 1:    domain= AF_LOCAL;       break;  /* SQ_SOCKET_DOMAIN_LOCAL */
+    case 1:    domain= AF_UNIX;        break;  /* SQ_SOCKET_DOMAIN_LOCAL */
     case 2:    domain= AF_INET;        break;  /* SQ_SOCKET_DOMAIN_INET4 */
     case 3:    domain= AF_INET6;       break;  /* SQ_SOCKET_DOMAIN_INET6 */
     }
@@ -1563,16 +1563,16 @@
       struct stat st;
       if ((0 == stat(servName, &st)) && (st.st_mode & S_IFSOCK))
        {
-         struct sockaddr_un *sun= calloc(1, sizeof(struct sockaddr_un));
+         struct sockaddr_un *s_un= calloc(1, sizeof(struct sockaddr_un));
          localInfo= (struct addrinfo *)calloc(1, sizeof(struct addrinfo));
-         localInfo->ai_family= AF_LOCAL;
+         localInfo->ai_family= AF_UNIX;
          localInfo->ai_socktype= SOCK_STREAM;
          localInfo->ai_addrlen= sizeof(struct sockaddr_un);
-         localInfo->ai_addr= (struct sockaddr *)sun;
-         /*sun->sun_len= sizeof(struct sockaddr_un);*/
-         sun->sun_family= AF_LOCAL;
-         memcpy(sun->sun_path, servName, servSize);
-         sun->sun_path[servSize]= '\0';
+         localInfo->ai_addr= (struct sockaddr *)s_un;
+         /*s_un->sun_len= sizeof(struct sockaddr_un);*/
+         s_un->sun_family= AF_UNIX;
+         memcpy(s_un->sun_path, servName, servSize);
+         s_un->sun_path[servSize]= '\0';
          addrInfo= localInfo;
          interpreterProxy->signalSemaphoreWithIndex(resolverSema);
          return;
@@ -1586,7 +1586,7 @@

   switch (family)
     {
-    case SQ_SOCKET_FAMILY_LOCAL:       request.ai_family=AF_LOCAL;
        break;
+    case SQ_SOCKET_FAMILY_LOCAL:       request.ai_family=AF_UNIX;
        break;
     case SQ_SOCKET_FAMILY_INET4:       request.ai_family=AF_INET;
        break;
     case SQ_SOCKET_FAMILY_INET6:       request.ai_family=AF_INET6;
        break;
     }
@@ -1657,7 +1657,7 @@
   fprintf(stderr, " ");
   switch (addr->sa_family)
     {
-    case AF_LOCAL:     fprintf(stderr, "local\n"); break;
+    case AF_UNIX:      fprintf(stderr, "local\n"); break;
     case AF_INET:      fprintf(stderr, "inet\n"); break;
     case AF_INET6:     fprintf(stderr, "inet6\n"); break;
     default:           fprintf(stderr, "?\n"); break;
@@ -1698,7 +1698,7 @@

   switch (addrInfo->ai_family)
     {
-    case AF_LOCAL:     return SQ_SOCKET_FAMILY_LOCAL;
+    case AF_UNIX:      return SQ_SOCKET_FAMILY_LOCAL;
     case AF_INET:      return SQ_SOCKET_FAMILY_INET4;
     case AF_INET6:     return SQ_SOCKET_FAMILY_INET6;
     }
Index: platforms/unix/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c
===================================================================
---
platforms/unix/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c
(revision 1762)
+++
platforms/unix/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c
(working copy)
@@ -1818,7 +1818,7 @@
                return interpreterProxy->primitiveFail();
        }
        sqFile = interpreterProxy->arrayValueOf(sqFileOop);
-       if ((feof(sqFile->file)) == 0) {
+       if ((feof((FILE*)(sqFile->file))) == 0) {
                result = interpreterProxy->falseObject();
        } else {
                result = interpreterProxy->trueObject();
Index: platforms/unix/vm-sound-Sun/sqUnixSoundSun.c
===================================================================
--- platforms/unix/vm-sound-Sun/sqUnixSoundSun.c        (revision 1762)
+++ platforms/unix/vm-sound-Sun/sqUnixSoundSun.c        (working copy)
@@ -55,6 +55,7 @@
 #endif

 static int sound_Stop(void);
+static int sound_AvailableSpace(void);

 static int auFd=              -1;   /* open on /dev/dsp */
 static int fmtStereo=          0;   /* whether we are playing in stereo or
not */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20070923/4027da59/attachment.htm


More information about the Vm-dev mailing list