Hi,<br><br>This patch fixes 4 problems which prevented the VM from building<br>on Solaris/SPARC. They shouldn't cause problems for other<br>platforms (famous last words), so please would someone (Ian?)<br>confirm this before checking in.
<br><br>The problems fixed by this patch are:<br><ol><li>"sun" is already defined by some header or other in Solaris;<br>I've changed it to s_un.</li><li>AF_LOCAL isn't defined on Solaris. W Richard Stevens'
<br>"Advanced programming in the Unix environment" says that<br>AF_UNIX is more standard anyway.</li><li>Solaris' feof() call really wants a FILE*.</li><li>A missing prototype is added for sound_AvailableSpace(void)
</li></ol>With this patch, the VM builds and runs fine if built with gcc-3.4.3.<br>I've checked both the stock 3.9a-7024 image as well as the <br>etoys image. (My motivation for this whole exercise is to fix the<br>problems with audio under Solaris for my young daughter to use
<br>etoys: the first sound plays, but after that, no sounds ever play.)<br><br>With gcc-4.2.1 and -O2, the VM won't even start up (complains<br>about a missing vm-display-X11, even though it's there). With<br>gcc-4.2.1
and no -O2, the VM starts, runs for a short while, and<br>then cores with a bus error. gdb shows a corrupt stack. I'm<br>about to build gcc-4.1.2 and give it a spin building the VM to<br>try to track this down. But I do suspect bad code generation
<br>with gcc-4.2.1.<br><br><br>Thanks,<br>Andrew<br><br>Index: platforms/unix/plugins/SocketPlugin/sqUnixSocket.c<br>===================================================================<br>--- platforms/unix/plugins/SocketPlugin/sqUnixSocket.c (revision 1762)
<br>+++ platforms/unix/plugins/SocketPlugin/sqUnixSocket.c (working copy)<br>@@ -149,7 +149,7 @@<br> union sockaddr_any<br> {<br> struct sockaddr sa;<br>- struct sockaddr_un sun;<br>+ struct sockaddr_un s_un;
<br> struct sockaddr_in sin;<br> struct sockaddr_in6 sin6;<br> };<br>@@ -533,7 +533,7 @@<br> switch (domain)<br> {<br> case 0: domain= AF_INET; break; /* SQ_SOCKET_DOMAIN_UNSPECIFIED */<br>- case 1: domain= AF_LOCAL; break; /* SQ_SOCKET_DOMAIN_LOCAL */
<br>+ case 1: domain= AF_UNIX; break; /* SQ_SOCKET_DOMAIN_LOCAL */<br> case 2: domain= AF_INET; break; /* SQ_SOCKET_DOMAIN_INET4 */<br> case 3: domain= AF_INET6; break; /* SQ_SOCKET_DOMAIN_INET6 */
<br> }<br>@@ -1563,16 +1563,16 @@<br> struct stat st;<br> if ((0 == stat(servName, &st)) && (st.st_mode & S_IFSOCK))<br> {<br>- struct sockaddr_un *sun= calloc(1, sizeof(struct sockaddr_un));
<br>+ struct sockaddr_un *s_un= calloc(1, sizeof(struct sockaddr_un));<br> localInfo= (struct addrinfo *)calloc(1, sizeof(struct addrinfo));<br>- localInfo->ai_family= AF_LOCAL;<br>+ localInfo->ai_family= AF_UNIX;
<br> localInfo->ai_socktype= SOCK_STREAM;<br> localInfo->ai_addrlen= sizeof(struct sockaddr_un);<br>- localInfo->ai_addr= (struct sockaddr *)sun;<br>- /*sun->sun_len= sizeof(struct sockaddr_un);*/
<br>- sun->sun_family= AF_LOCAL;<br>- memcpy(sun->sun_path, servName, servSize);<br>- sun->sun_path[servSize]= '\0';<br>+ localInfo->ai_addr= (struct sockaddr *)s_un;<br>
+ /*s_un->sun_len= sizeof(struct sockaddr_un);*/<br>+ s_un->sun_family= AF_UNIX;<br>+ memcpy(s_un->sun_path, servName, servSize);<br>+ s_un->sun_path[servSize]= '\0';<br>
addrInfo= localInfo;<br> interpreterProxy->signalSemaphoreWithIndex(resolverSema);<br> return;<br>@@ -1586,7 +1586,7 @@<br> <br> switch (family)<br> {<br>- case SQ_SOCKET_FAMILY_LOCAL:
request.ai_family= AF_LOCAL; break;<br>+ case SQ_SOCKET_FAMILY_LOCAL: request.ai_family= AF_UNIX; break;<br> case SQ_SOCKET_FAMILY_INET4: request.ai_family= AF_INET; break;
<br> case SQ_SOCKET_FAMILY_INET6: request.ai_family= AF_INET6; break;<br> }<br>@@ -1657,7 +1657,7 @@<br> fprintf(stderr, " ");<br> switch (addr->sa_family)<br> {<br>- case AF_LOCAL: fprintf(stderr, "local\n"); break;
<br>+ case AF_UNIX: fprintf(stderr, "local\n"); break;<br> case AF_INET: fprintf(stderr, "inet\n"); break;<br> case AF_INET6: fprintf(stderr, "inet6\n"); break;<br> default: fprintf(stderr, "?\n"); break;
<br>@@ -1698,7 +1698,7 @@<br> <br> switch (addrInfo->ai_family)<br> {<br>- case AF_LOCAL: return SQ_SOCKET_FAMILY_LOCAL;<br>+ case AF_UNIX: return SQ_SOCKET_FAMILY_LOCAL;<br> case AF_INET: return SQ_SOCKET_FAMILY_INET4;
<br> case AF_INET6: return SQ_SOCKET_FAMILY_INET6;<br> }<br>Index: platforms/unix/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c<br>===================================================================<br>
--- platforms/unix/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c (revision 1762)<br>+++ platforms/unix/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c (working copy)<br>@@ -1818,7 +1818,7 @@<br>
return interpreterProxy->primitiveFail();<br> }<br> sqFile = interpreterProxy->arrayValueOf(sqFileOop);<br>- if ((feof(sqFile->file)) == 0) {<br>+ if ((feof((FILE*)(sqFile->file))) == 0) {
<br> result = interpreterProxy->falseObject();<br> } else {<br> result = interpreterProxy->trueObject();<br>Index: platforms/unix/vm-sound-Sun/sqUnixSoundSun.c<br>===================================================================
<br>--- platforms/unix/vm-sound-Sun/sqUnixSoundSun.c (revision 1762)<br>+++ platforms/unix/vm-sound-Sun/sqUnixSoundSun.c (working copy)<br>@@ -55,6 +55,7 @@<br> #endif<br> <br> static int sound_Stop(void);<br>
+static int sound_AvailableSpace(void);<br> <br> static int auFd= -1; /* open on /dev/dsp */<br> static int fmtStereo= 0; /* whether we are playing in stereo or not */<br><br>