unix-jthreads fixed (rather ugly) for HP-UX

kaffe@rufus.w3.org kaffe@rufus.w3.org
Tue, 28 Jul 1998 14:13:19 +0100




Hello!

I have found how to fix "assertion failed" on HP-UX. The problem was that
both "ioctl(fd, FIOSSAIOSTAT, &on)" and "ioctl(fd, FIOSSAIOOWN, &pid)"
return EINVAL in kaffe/kaffevm/systems/unix-jthreads/jthread.c. If
"ioctl(fd, FIOASYNC, &on)" and "fcntl(fd, F_SETOWN, pid)" are used
everything is more or less Ok. Following diagnostics is printed.
Standard version:
==============
[/home/proski/local/src/kaffe/kaffe/kaffe] ./Kaffe HelloWorldApp.class
FIOSSAIOSTAT: Invalid argument
./systems/unix-jthreads/internal.c:114: failed assertion `mainthread'
==============
Version with "#if defined(FIOASYNC)" before "#elif defined(FIOSSAIOSTAT)":
==============
Error doing FIOSSAIOWN: Invalid argument
Error doing FIOSSAIOWN: Invalid argument
Error doing FIOSSAIOWN: Invalid argument
FIOASYNC: Not a typewriter
FIOASYNC: Not a typewriter
Cannot find essential class 'java/lang/Object' in class library ...
aborting.
==============
It is already much better, but we still have errors.
Now let's place "#if defined(F_SETOWN)" before "#elif
defined(FIOSSAIOOWN)". We have:
==============
FIOASYNC: Not a typewriter
FIOASYNC: Not a typewriter
Cannot find essential class 'java/lang/Object' in class library ...
aborting.
==============
Now we have no serious problems (except missing class library).

I think the best solution would be to write some test for configure. I
would not recomment to apply following patch without futher tests, besause
I can only test it on HP-UX, an I can't even run HelloWorldApp on it.

==============
--- kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c.orig      Sun Jul
26 00:30:34 1998
+++ kaffe/kaffe/kaffevm/systems/unix-jthreads/jthread.c      Tue Jul 28
14:06:21 1998
@@ -1493,15 +1493,7 @@
 #endif
          );

-#if defined(FIOSSAIOSTAT)
-    /* on hpux */
-    r = ioctl(fd, FIOSSAIOSTAT, &on);
-    if (r < 0 && errno != ENOTTY) {
-         /* Defines ENOTTY to be an acceptable error */
-         perror("FIOSSAIOSTAT");
-         return (r);
-    }
-#elif defined(FIOASYNC)
+#if defined(FIOASYNC)
     /*
      * On some systems, this will not work if a terminal fd is redirected.
      * (Solaris sets errno to ENXIO in this case.)
@@ -1512,6 +1504,14 @@
          perror("FIOASYNC");
          return (r);
         }
+#elif defined(FIOSSAIOSTAT)
+    /* on hpux */
+    r = ioctl(fd, FIOSSAIOSTAT, &on);
+    if (r < 0 && errno != ENOTTY) {
+         /* Defines ENOTTY to be an acceptable error */
+         perror("FIOSSAIOSTAT");
+         return (r);
+    }
 #endif

 #if !(defined(O_ASYNC) || defined(FIOASYNC) ||  \
@@ -1521,19 +1521,19 @@


     /* Allow socket to signal this process when new data is available */
-#if defined(FIOSSAIOOWN)
+#if defined(F_SETOWN)
+    /* On some systems, this will flag an error if fd is not a socket */
+    r = fcntl(fd, F_SETOWN, pid);
+    if (r < 0) {
+         DBG(JTHREAD, perror("F_SETOWN"); )
+    }
+#elif defined(FIOSSAIOOWN)
     /* on hpux */
     r = ioctl(fd, FIOSSAIOOWN, &pid);
         if (r == -1 && errno != ENOTTY) {
          perror("Error doing FIOSSAIOWN");
     }

-#elif defined(F_SETOWN)
-    /* On some systems, this will flag an error if fd is not a socket */
-    r = fcntl(fd, F_SETOWN, pid);
-    if (r < 0) {
-         DBG(JTHREAD, perror("F_SETOWN"); )
-    }
 #endif
     return (fd);
 }
==============

Pavel Roskin
ECsoft
London, UK