version and sigaction in SqueakVM classic 4.16.7

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

version and sigaction in SqueakVM classic 4.16.7

stes
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


Hi,

To come back to my previous post on __VERSION__ in SqueakVM classic 4.16.7
(from the "subversion" repository).

Reminder: __VERSION__ is not working for me, but CMAKE has
 ${CMAKE_C_COMPILER_VERSION}
which is a good alternative.

I don't know whether patches are still being accepted for SqueakVM classic,
but here below are my patches
 
  - __VERSION__ made conditional at CMAKE level via ifdef SunPro
  - use sigaction() instead of signal() in aio.c
    this is the case in SqueakVM 5.3 (4.3 is using sigaction )
    and that is better to avoid the SIGIO handler being reset to the default
  - vm-sound-pulse compilation fix

David Stes

Here's the diff:

Index: unix/vm/aio.c
===================================================================
- --- unix/vm/aio.c (revision 3775)
+++ unix/vm/aio.c (working copy)
@@ -82,7 +82,7 @@
 #   define FASYNC O_ASYNC
 # endif
 
- -#else /* !HAVE_CONFIG_H -- assume lowest common demoninator */
+#else /* !HAVE_CONFIG_H -- assume lowest common denominator */
 
 # include <stdio.h>
 # include <stdlib.h>
@@ -95,9 +95,13 @@
 # include <sys/ioctl.h>
 # include <fcntl.h>
 
+#ifdef __sun
+#include <sys/file.h>  /* include FASYNC so that code defined(FASYNC) works
*/
 #endif
 
+#endif
 
+
 #undef DEBUG
 #undef DEBUG_TICKER
 
@@ -162,6 +166,10 @@
 
 void aioInit(void)
 {
+#ifdef __sun__
+  struct sigaction sigio_action;
+#endif
+
   extern void forceInterruptCheck(int); /* not really, but hey */
 
   FD_ZERO(&fdMask);
@@ -171,7 +179,18 @@
   FD_ZERO(&xdMask);
   maxFd= 0;
   signal(SIGPIPE, SIG_IGN);
+
+#ifdef __sun__
+  sigio_action.sa_sigaction = forceInterruptCheck;
+  sigio_action.sa_flags = SA_RESTART | SA_SIGINFO;
+  sigemptyset(&sigio_action.sa_mask);
+  if (sigaction(SIGIO, &sigio_action, 0)) {
+    perror("aioInit sigaction SIGIO");
+    exit(1);
+  }
+#else
   signal(SIGIO,   forceInterruptCheck);
+#endif
 }
 
 
Index: unix/vm/config.cmake
===================================================================
- --- unix/vm/config.cmake (revision 3775)
+++ unix/vm/config.cmake (working copy)
@@ -202,7 +202,11 @@
 
 # sqUnixMain.c
 
- -SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\"
Compiler: \"
__VERSION__")
+IF (CMAKE_C_COMPILER_ID MATCHES "SunPro")
+  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\"
Compiler: ${
CMAKE_C_COMPILER_VERSION}\"")
+ELSE ()
+  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\"
Compiler: \"
__VERSION__")
+ENDIF (CMAKE_C_COMPILER_ID MATHCES "SunPro")
 
 CONFIG_DEFINE (VM_BUILD_STRING)
 
Index: unix/vm-sound-Sun/sqUnixSoundSun.c
===================================================================
- --- unix/vm-sound-Sun/sqUnixSoundSun.c (revision 3775)
+++ unix/vm-sound-Sun/sqUnixSoundSun.c (working copy)
@@ -72,7 +72,7 @@
 #endif
 
 static sqInt sound_Stop(void);
- -static int sound_AvailableSpace(void);
+static sqInt sound_AvailableSpace(void);
 
 static int auFd=       -1;   /* open on /dev/audio */
 static int auCtlFd=       -1;   /* open on /dev/audioctl */
Index: unix/vm-sound-pulse/sqUnixSoundPulseAudio.c
===================================================================
- --- unix/vm-sound-pulse/sqUnixSoundPulseAudio.c (revision 3775)
+++ unix/vm-sound-pulse/sqUnixSoundPulseAudio.c (working copy)
@@ -276,6 +276,12 @@
 
 /* ================================== UTILS */
 
+#ifdef __SUNPRO_C
+/* MIN is not C stdlib - perhaps <sys/param.h> is defining it on Linux */
+static int MIN(int a,int b) { return (a<b)?a:b; }
+static int MAX(int a,int b) { return (a<b)?b:a; }
+#endif
+
 /* RATE CONVERSION: from dsp code but not used (yet). Maybe not needed at
all w
ith AlSA */
 /* RATE CONVERSION: fixed preset rates are used. TBD: choose nearest to
request
ed */
 /*


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJejKrKAAoJEAwpOKXMq1MaGNcH/0g8kk+GVHIdZW48nT2EbAJf
z8HjIc520LPdtn/U1qBcO/L21dchKZQV1t/gUacDnXFA4W2CC5q52eWMBfaWecmn
BOdiKTGovzVTCAGL5CHlKZdJA0oqJKDVMuaiDp6kP28mNFZiRynwXSGledC0qpq2
0/eAtNxpOFP6HCjl7INdm5F5ghArhYrTzpaAJfze8CZlHREls2g+2Ct0tUY1gllJ
SVCtnyhPCWD7Tmbvs+xElfj8GVfRKvPX+mWrq0TkWk6Be+NHM0b/7Z5y4y7SpTrY
qko5iRq+LUelgMtlnpUnh8kmyqbVlYT5d3XL4Qrozg7oFVUcBb7uNukNySE696k=
=9GTB
-----END PGP SIGNATURE-----




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: version and sigaction in SqueakVM classic 4.16.7

David T. Lewis
 
Hi David Stes,

On Tue, Apr 07, 2020 at 11:32:32AM -0500, stes wrote:

>  
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
>
> Hi,
>
> To come back to my previous post on __VERSION__ in SqueakVM classic 4.16.7
> (from the "subversion" repository).
>
> Reminder: __VERSION__ is not working for me, but CMAKE has
>  ${CMAKE_C_COMPILER_VERSION}
> which is a good alternative.

The CMAKE_C_COMPILER_VERSION change seems to be good on all platforms, so
this is the right fix. I was able to test this on a Mac OS X with llvm
compiler (just today as luck would have it), and it worked without problems,
so I am confident that your original suggestion of replacing __VERSION__
with ${CMAKE_C_COMPILER_VERSION} is the correct fix.


>
> I don't know whether patches are still being accepted for SqueakVM classic,
> but here below are my patches

Thank you. I am keeping track of your updates and will commit them to the
repository as soon as I am able. I am currently having trouble reaching Ian
Piumarta to correct a technical glitch in the repository access, but I'll
catch up with it as soon as I am able. Ian (https://www.piumarta.com/cv/)
is author of the original Unix VM platform sources and much of the early
VM work and is the long-time maintainer and supporter (financially and
otherwise) of the the squeakvm.org site.

Support for the classic VM is rather minimal these days, but your contributions
are noted and appreciated.

Dave



>  
>   - __VERSION__ made conditional at CMAKE level via ifdef SunPro
>   - use sigaction() instead of signal() in aio.c
>     this is the case in SqueakVM 5.3 (4.3 is using sigaction )
>     and that is better to avoid the SIGIO handler being reset to the default
>   - vm-sound-pulse compilation fix
>
> David Stes
>
> Here's the diff:
>
> Index: unix/vm/aio.c
> ===================================================================
> - --- unix/vm/aio.c (revision 3775)
> +++ unix/vm/aio.c (working copy)
> @@ -82,7 +82,7 @@
>  #   define FASYNC O_ASYNC
>  # endif
>  
> - -#else /* !HAVE_CONFIG_H -- assume lowest common demoninator */
> +#else /* !HAVE_CONFIG_H -- assume lowest common denominator */
>  
>  # include <stdio.h>
>  # include <stdlib.h>
> @@ -95,9 +95,13 @@
>  # include <sys/ioctl.h>
>  # include <fcntl.h>
>  
> +#ifdef __sun
> +#include <sys/file.h>  /* include FASYNC so that code defined(FASYNC) works
> */
>  #endif
>  
> +#endif
>  
> +
>  #undef DEBUG
>  #undef DEBUG_TICKER
>  
> @@ -162,6 +166,10 @@
>  
>  void aioInit(void)
>  {
> +#ifdef __sun__
> +  struct sigaction sigio_action;
> +#endif
> +
>    extern void forceInterruptCheck(int); /* not really, but hey */
>  
>    FD_ZERO(&fdMask);
> @@ -171,7 +179,18 @@
>    FD_ZERO(&xdMask);
>    maxFd= 0;
>    signal(SIGPIPE, SIG_IGN);
> +
> +#ifdef __sun__
> +  sigio_action.sa_sigaction = forceInterruptCheck;
> +  sigio_action.sa_flags = SA_RESTART | SA_SIGINFO;
> +  sigemptyset(&sigio_action.sa_mask);
> +  if (sigaction(SIGIO, &sigio_action, 0)) {
> +    perror("aioInit sigaction SIGIO");
> +    exit(1);
> +  }
> +#else
>    signal(SIGIO,   forceInterruptCheck);
> +#endif
>  }
>  
>  
> Index: unix/vm/config.cmake
> ===================================================================
> - --- unix/vm/config.cmake (revision 3775)
> +++ unix/vm/config.cmake (working copy)
> @@ -202,7 +202,11 @@
>  
>  # sqUnixMain.c
>  
> - -SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\"
> Compiler: \"
> __VERSION__")
> +IF (CMAKE_C_COMPILER_ID MATCHES "SunPro")
> +  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\"
> Compiler: ${
> CMAKE_C_COMPILER_VERSION}\"")
> +ELSE ()
> +  SET (VM_BUILD_STRING "\"Unix built on \"__DATE__ \" \"__TIME__\"
> Compiler: \"
> __VERSION__")
> +ENDIF (CMAKE_C_COMPILER_ID MATHCES "SunPro")
>  
>  CONFIG_DEFINE (VM_BUILD_STRING)
>  
> Index: unix/vm-sound-Sun/sqUnixSoundSun.c
> ===================================================================
> - --- unix/vm-sound-Sun/sqUnixSoundSun.c (revision 3775)
> +++ unix/vm-sound-Sun/sqUnixSoundSun.c (working copy)
> @@ -72,7 +72,7 @@
>  #endif
>  
>  static sqInt sound_Stop(void);
> - -static int sound_AvailableSpace(void);
> +static sqInt sound_AvailableSpace(void);
>  
>  static int auFd=       -1;   /* open on /dev/audio */
>  static int auCtlFd=       -1;   /* open on /dev/audioctl */
> Index: unix/vm-sound-pulse/sqUnixSoundPulseAudio.c
> ===================================================================
> - --- unix/vm-sound-pulse/sqUnixSoundPulseAudio.c (revision 3775)
> +++ unix/vm-sound-pulse/sqUnixSoundPulseAudio.c (working copy)
> @@ -276,6 +276,12 @@
>  
>  /* ================================== UTILS */
>  
> +#ifdef __SUNPRO_C
> +/* MIN is not C stdlib - perhaps <sys/param.h> is defining it on Linux */
> +static int MIN(int a,int b) { return (a<b)?a:b; }
> +static int MAX(int a,int b) { return (a<b)?b:a; }
> +#endif
> +
>  /* RATE CONVERSION: from dsp code but not used (yet). Maybe not needed at
> all w
> ith AlSA */
>  /* RATE CONVERSION: fixed preset rates are used. TBD: choose nearest to
> request
> ed */
>  /*
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2
>
> iQEcBAEBCAAGBQJejKrKAAoJEAwpOKXMq1MaGNcH/0g8kk+GVHIdZW48nT2EbAJf
> z8HjIc520LPdtn/U1qBcO/L21dchKZQV1t/gUacDnXFA4W2CC5q52eWMBfaWecmn
> BOdiKTGovzVTCAGL5CHlKZdJA0oqJKDVMuaiDp6kP28mNFZiRynwXSGledC0qpq2
> 0/eAtNxpOFP6HCjl7INdm5F5ghArhYrTzpaAJfze8CZlHREls2g+2Ct0tUY1gllJ
> SVCtnyhPCWD7Tmbvs+xElfj8GVfRKvPX+mWrq0TkWk6Be+NHM0b/7Z5y4y7SpTrY
> qko5iRq+LUelgMtlnpUnh8kmyqbVlYT5d3XL4Qrozg7oFVUcBb7uNukNySE696k=
> =9GTB
> -----END PGP SIGNATURE-----
>
>
>
>
> --
> Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: version and sigaction in SqueakVM classic 4.16.7

stes
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


Thanks, in fact what's for me important is to be able to compare Squeak V5,
and Squeak V4.

So I'm interested in comparing those versions.

There's no hurry with the Squeak V4 fixes at all.
Squeak V4 is after all an old version ...

Also the fact that I'm working with Squeak V4 is no criticism of Squeak V5
or Squeak V6 alpha ... it's just that backwards compatibility, and testing
old code, also requires an older VM (V3, V4 etc.) to work with.

What I'll do is try to send an email to Ian Piumarta as well,
perhaps in addition with your work, which I appreciate a lot by the way.

Also regarding the CMAKE fix, by placing the code inside an

IF (CMAKE_C_COMPILER_ID MATCHES "SunPro")
...
ENDIF (CMAKE_C_COMPILER_ID MATHCES "SunPro")

This code only affects the compiler which matches with COMPILER_ID to
"SunPro".

So it will not even affect any other compiler, be it GCC or whatever is used
on any other platform, as long the compiler is not "SunPro".

Regarding my other fix for "sigaction" instead of "signal" in the old aio.c
code,  I've noticed that that change or fix if you like, was made in the V5
sources, or similar for all platforms.  On V4 I've just done it for Solaris,
as on Solaris the behavior of sigaction and signal is different.

So SqueakV5 seems to use sigaction which is fine anyway, the old SqueakV4
sometimes uses signal() which is also good, but in some case not.

Regards,
David Stes

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJejXbPAAoJEAwpOKXMq1Mavd4IAJLq3+tPZJnesWmNEd8ry861
d0q4AYompuuRrnMpNV7QmxoGQEH2LiVLZypWR9Ps8vTPFgnYQbBrSddk3k8hq8OT
bXPZiIm+i67fbLm1taGptB35z8sNH301gsL+gT5+c9uoqmd2C2Wh1oeiVkxXlDQ0
fzLtnwvglCEQkzyBt8HiX5IfDG+2anhK8gfFlcdnNr1anbUqOF9DHb1LFFWr1jUz
lLdCaaj89oesgpk4XGi2vjvx3sa0+HCpI8f4U3JOmH2HZWyKpt50m0r7AUKuL5B9
2eoY5XucQBtqKUAGUV03A8bXnzCRcY16hNJ0RDYnUHDVI/w6DTjhjk2IESPvA2E=
=/mSZ
-----END PGP SIGNATURE-----




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html
Reply | Threaded
Open this post in threaded view
|

Re: version and sigaction in SqueakVM classic 4.16.7

stes
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


By the way, there was a small typo in my previous post,
the correct fix is:

IF (CMAKE_C_COMPILER_ID MATCHES "SunPro")
...
ELSE ()
...
ENDIF (CMAKE_C_COMPILER_ID MATCHES "SunPro")

I wrote MATHCES in my previous post instead of MATCHES:
ENDIF (CMAKE_C_COMPILER_ID MATHCES "SunPro")

cmake does not seem to complain about the ending ENDIF anyway,
but who knows, it could matter somewhere ...

Regards,
David Stes

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJejXvaAAoJEAwpOKXMq1MaZUAIAJbWbLA2Fus9p5eyEdKsH01l
cBZK1b+dpvgXaTsiQlnsvQTOOC+aFKV0c7dn3CVS+q/lNzWzVoducNfRkddsRo8C
P/Db9xtQL8TXH8KlCmOMtzhWz4eziJK3BGjh9xeU60YWWrJyxD3zsqTlTZgbfLGi
YYvhnTI+DgiG3YVypGRd9+ezdO00Uvcoioq79fN7OSs4zrOmLaVs+ngZ86YRcjWR
Im60WYjc9sfAGw0+epL/IeTKY1Gp6TsLYJp/Bh8gBl3A9lGRsB0483d4IEffS0rs
GfpAObTcyNAHqOCJgVHHSfGcdGyVTnPSrR+BhlqARRGr2mjYlYOmKrym8Nbe+zw=
=LVFF
-----END PGP SIGNATURE-----




--
Sent from: http://forum.world.st/Squeak-VM-f104410.html