I have attached a new batch of patches to work towards building MoarVM on
Solaris 11/x86 with Sun's compiler suite.  One additional patch is needed
to the 3rdparty/dyncall module, but since that's in a git submodule,
I'll send it separately.

The patches were made with git format-patch and are attached.  The subjects
are:

    [PATCH 1/9] Rename a label from a plain 'ERR' to LBL_ERR.
    [PATCH 2/9] Use the full pathname for /bin/sh in Makefile.
    [PATCH 3/9] Use sched_yield() on Solaris systems.
    [PATCH 4/9] Avoid an anonymous union in MVMOSHandleBody.
    [PATCH 5/9] On Solaris, add -lkstat for libuv kernel statistics.
    [PATCH 6/9] On Solaris, add -mt to ccflags, since we are compiling
    [PATCH 7/9] Add Solaris-specific list of object files for libuv.
    [PATCH 8/9] Add #defines for various EXTENSIONS to get Solaris to
    [PATCH 9/9] Make 3rdparty/dyncall use Makefile.embedded for Solaris.

The only really invasive non-obvious one is patch 4.  Solaris cc doesn't
support anonymous unions, but MVMOSHandleBody uses them extensively.
I had to give the anonymous union a name everywhere in order to get it
to compile.

I should also note that this set of patches will probably not work with
gcc on Solaris.  It wasn't obvious to me how to set up the setup.pm file
to handle the different possible compilers (though I confess I didn't
spend a lot of time worrying about it either.)

Enjoy,

-- 
    Andy Dougherty              dough...@lafayette.edu
>From 445e6698baf9ab46cd55e288b74c4db9c44d82bc Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Mon, 2 Sep 2013 13:34:09 -0400
Subject: [PATCH 1/9] Rename a label from a plain 'ERR' to LBL_ERR.

The Solaris preprocessor has already  #defined ERR.
---
 3rdparty/libtommath/bn_mp_is_square.c         |   24 ++---
 3rdparty/libtommath/bn_mp_karatsuba_mul.c     |    4 +-
 3rdparty/libtommath/bn_mp_karatsuba_sqr.c     |    4 +-
 3rdparty/libtommath/bn_mp_reduce_2k.c         |    8 +-
 3rdparty/libtommath/bn_mp_reduce_2k_l.c       |    8 +-
 3rdparty/libtommath/bn_mp_reduce_2k_setup_l.c |    6 +-
 3rdparty/libtommath/bn_mp_toom_mul.c          |  118 ++++++++++++-------------
 3rdparty/libtommath/bn_mp_toom_sqr.c          |   92 +++++++++----------
 8 files changed, 132 insertions(+), 132 deletions(-)

diff --git a/3rdparty/libtommath/bn_mp_is_square.c b/3rdparty/libtommath/bn_mp_is_square.c
index 5bde26e..e5595b0 100644
--- a/3rdparty/libtommath/bn_mp_is_square.c
+++ b/3rdparty/libtommath/bn_mp_is_square.c
@@ -75,31 +75,31 @@ int mp_is_square(mp_int *arg,int *ret)
      return res;
   }
   if ((res = mp_mod(arg,&t,&t)) != MP_OKAY) {
-     goto ERR;
+     goto LBL_ERR;
   }
   r = mp_get_int(&t);
   /* Check for other prime modules, note it's not an ERROR but we must
-   * free "t" so the easiest way is to goto ERR.  We know that res
+   * free "t" so the easiest way is to goto LBL_ERR.  We know that res
    * is already equal to MP_OKAY from the mp_mod call 
    */ 
-  if ( (1L<<(r%11)) & 0x5C4L )             goto ERR;
-  if ( (1L<<(r%13)) & 0x9E4L )             goto ERR;
-  if ( (1L<<(r%17)) & 0x5CE8L )            goto ERR;
-  if ( (1L<<(r%19)) & 0x4F50CL )           goto ERR;
-  if ( (1L<<(r%23)) & 0x7ACCA0L )          goto ERR;
-  if ( (1L<<(r%29)) & 0xC2EDD0CL )         goto ERR;
-  if ( (1L<<(r%31)) & 0x6DE2B848L )        goto ERR;
+  if ( (1L<<(r%11)) & 0x5C4L )             goto LBL_ERR;
+  if ( (1L<<(r%13)) & 0x9E4L )             goto LBL_ERR;
+  if ( (1L<<(r%17)) & 0x5CE8L )            goto LBL_ERR;
+  if ( (1L<<(r%19)) & 0x4F50CL )           goto LBL_ERR;
+  if ( (1L<<(r%23)) & 0x7ACCA0L )          goto LBL_ERR;
+  if ( (1L<<(r%29)) & 0xC2EDD0CL )         goto LBL_ERR;
+  if ( (1L<<(r%31)) & 0x6DE2B848L )        goto LBL_ERR;
 
   /* Final check - is sqr(sqrt(arg)) == arg ? */
   if ((res = mp_sqrt(arg,&t)) != MP_OKAY) {
-     goto ERR;
+     goto LBL_ERR;
   }
   if ((res = mp_sqr(&t,&t)) != MP_OKAY) {
-     goto ERR;
+     goto LBL_ERR;
   }
 
   *ret = (mp_cmp_mag(&t,arg) == MP_EQ) ? MP_YES : MP_NO;
-ERR:mp_clear(&t);
+LBL_ERR:mp_clear(&t);
   return res;
 }
 #endif
diff --git a/3rdparty/libtommath/bn_mp_karatsuba_mul.c b/3rdparty/libtommath/bn_mp_karatsuba_mul.c
index ec1b331..853d87b 100644
--- a/3rdparty/libtommath/bn_mp_karatsuba_mul.c
+++ b/3rdparty/libtommath/bn_mp_karatsuba_mul.c
@@ -60,7 +60,7 @@ int mp_karatsuba_mul (mp_int * a, mp_int * b, mp_int * c)
 
   /* init copy all the temps */
   if (mp_init_size (&x0, B) != MP_OKAY)
-    goto ERR;
+    goto LBL_ERR;
   if (mp_init_size (&x1, a->used - B) != MP_OKAY)
     goto X0;
   if (mp_init_size (&y0, B) != MP_OKAY)
@@ -157,7 +157,7 @@ Y1:mp_clear (&y1);
 Y0:mp_clear (&y0);
 X1:mp_clear (&x1);
 X0:mp_clear (&x0);
-ERR:
+LBL_ERR:
   return err;
 }
 #endif
diff --git a/3rdparty/libtommath/bn_mp_karatsuba_sqr.c b/3rdparty/libtommath/bn_mp_karatsuba_sqr.c
index ecf44c6..0ebe9ea 100644
--- a/3rdparty/libtommath/bn_mp_karatsuba_sqr.c
+++ b/3rdparty/libtommath/bn_mp_karatsuba_sqr.c
@@ -37,7 +37,7 @@ int mp_karatsuba_sqr (mp_int * a, mp_int * b)
 
   /* init copy all the temps */
   if (mp_init_size (&x0, B) != MP_OKAY)
-    goto ERR;
+    goto LBL_ERR;
   if (mp_init_size (&x1, a->used - B) != MP_OKAY)
     goto X0;
 
@@ -111,7 +111,7 @@ T2:mp_clear (&t2);
 T1:mp_clear (&t1);
 X1:mp_clear (&x1);
 X0:mp_clear (&x0);
-ERR:
+LBL_ERR:
   return err;
 }
 #endif
diff --git a/3rdparty/libtommath/bn_mp_reduce_2k.c b/3rdparty/libtommath/bn_mp_reduce_2k.c
index 247f483..dd2c7e6 100644
--- a/3rdparty/libtommath/bn_mp_reduce_2k.c
+++ b/3rdparty/libtommath/bn_mp_reduce_2k.c
@@ -29,19 +29,19 @@ int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d)
 top:
    /* q = a/2**p, a = a mod 2**p */
    if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
-      goto ERR;
+      goto LBL_ERR;
    }
    
    if (d != 1) {
       /* q = q * d */
       if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) { 
-         goto ERR;
+         goto LBL_ERR;
       }
    }
    
    /* a = a + q */
    if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
-      goto ERR;
+      goto LBL_ERR;
    }
    
    if (mp_cmp_mag(a, n) != MP_LT) {
@@ -49,7 +49,7 @@ top:
       goto top;
    }
    
-ERR:
+LBL_ERR:
    mp_clear(&q);
    return res;
 }
diff --git a/3rdparty/libtommath/bn_mp_reduce_2k_l.c b/3rdparty/libtommath/bn_mp_reduce_2k_l.c
index c76ca41..fe8ced9 100644
--- a/3rdparty/libtommath/bn_mp_reduce_2k_l.c
+++ b/3rdparty/libtommath/bn_mp_reduce_2k_l.c
@@ -32,17 +32,17 @@ int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d)
 top:
    /* q = a/2**p, a = a mod 2**p */
    if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
-      goto ERR;
+      goto LBL_ERR;
    }
    
    /* q = q * d */
    if ((res = mp_mul(&q, d, &q)) != MP_OKAY) { 
-      goto ERR;
+      goto LBL_ERR;
    }
    
    /* a = a + q */
    if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
-      goto ERR;
+      goto LBL_ERR;
    }
    
    if (mp_cmp_mag(a, n) != MP_LT) {
@@ -50,7 +50,7 @@ top:
       goto top;
    }
    
-ERR:
+LBL_ERR:
    mp_clear(&q);
    return res;
 }
diff --git a/3rdparty/libtommath/bn_mp_reduce_2k_setup_l.c b/3rdparty/libtommath/bn_mp_reduce_2k_setup_l.c
index 49f49cb..3b425b0 100644
--- a/3rdparty/libtommath/bn_mp_reduce_2k_setup_l.c
+++ b/3rdparty/libtommath/bn_mp_reduce_2k_setup_l.c
@@ -26,14 +26,14 @@ int mp_reduce_2k_setup_l(mp_int *a, mp_int *d)
    }
    
    if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) {
-      goto ERR;
+      goto LBL_ERR;
    }
    
    if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) {
-      goto ERR;
+      goto LBL_ERR;
    }
    
-ERR:
+LBL_ERR:
    mp_clear(&tmp);
    return res;
 }
diff --git a/3rdparty/libtommath/bn_mp_toom_mul.c b/3rdparty/libtommath/bn_mp_toom_mul.c
index e73f76e..3f67453 100644
--- a/3rdparty/libtommath/bn_mp_toom_mul.c
+++ b/3rdparty/libtommath/bn_mp_toom_mul.c
@@ -39,124 +39,124 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
     
     /* a = a2 * B**2 + a1 * B + a0 */
     if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     if ((res = mp_copy(a, &a1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     mp_rshd(&a1, B);
     mp_mod_2d(&a1, DIGIT_BIT * B, &a1);
 
     if ((res = mp_copy(a, &a2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     mp_rshd(&a2, B*2);
     
     /* b = b2 * B**2 + b1 * B + b0 */
     if ((res = mp_mod_2d(b, DIGIT_BIT * B, &b0)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     if ((res = mp_copy(b, &b1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     mp_rshd(&b1, B);
     mp_mod_2d(&b1, DIGIT_BIT * B, &b1);
 
     if ((res = mp_copy(b, &b2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     mp_rshd(&b2, B*2);
     
     /* w0 = a0*b0 */
     if ((res = mp_mul(&a0, &b0, &w0)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
     /* w4 = a2 * b2 */
     if ((res = mp_mul(&a2, &b2, &w4)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
     /* w1 = (a2 + 2(a1 + 2a0))(b2 + 2(b1 + 2b0)) */
     if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
     if ((res = mp_mul_2(&b0, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp2, &b2, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
     if ((res = mp_mul(&tmp1, &tmp2, &w1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
     /* w3 = (a0 + 2(a1 + 2a2))(b0 + 2(b1 + 2b2)) */
     if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
     if ((res = mp_mul_2(&b2, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
     if ((res = mp_mul(&tmp1, &tmp2, &w3)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
 
     /* w2 = (a2 + a1 + a0)(b2 + b1 + b0) */
     if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&b2, &b1, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_mul(&tmp1, &tmp2, &w2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     
     /* now solve the matrix 
@@ -173,104 +173,104 @@ int mp_toom_mul(mp_int *a, mp_int *b, mp_int *c)
      
      /* r1 - r4 */
      if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3 - r0 */
      if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1/2 */
      if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3/2 */
      if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r2 - r0 - r4 */
      if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1 - r2 */
      if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3 - r2 */
      if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1 - 8r0 */
      if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3 - 8r4 */
      if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* 3r2 - r1 - r3 */
      if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1 - r2 */
      if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3 - r2 */
      if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1/3 */
      if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3/3 */
      if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      
      /* at this point shift W[n] by B*n */
      if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }     
      
      if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }     
      
-ERR:
+LBL_ERR:
      mp_clear_multi(&w0, &w1, &w2, &w3, &w4, 
                     &a0, &a1, &a2, &b0, &b1, 
                     &b2, &tmp1, &tmp2, NULL);
diff --git a/3rdparty/libtommath/bn_mp_toom_sqr.c b/3rdparty/libtommath/bn_mp_toom_sqr.c
index 4b81cfa..1084081 100644
--- a/3rdparty/libtommath/bn_mp_toom_sqr.c
+++ b/3rdparty/libtommath/bn_mp_toom_sqr.c
@@ -32,76 +32,76 @@ mp_toom_sqr(mp_int *a, mp_int *b)
 
     /* a = a2 * B**2 + a1 * B + a0 */
     if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     if ((res = mp_copy(a, &a1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     mp_rshd(&a1, B);
     mp_mod_2d(&a1, DIGIT_BIT * B, &a1);
 
     if ((res = mp_copy(a, &a2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     mp_rshd(&a2, B*2);
 
     /* w0 = a0*a0 */
     if ((res = mp_sqr(&a0, &w0)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     /* w4 = a2 * a2 */
     if ((res = mp_sqr(&a2, &w4)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     /* w1 = (a2 + 2(a1 + 2a0))**2 */
     if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     if ((res = mp_sqr(&tmp1, &w1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     /* w3 = (a0 + 2(a1 + 2a2))**2 */
     if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     if ((res = mp_sqr(&tmp1, &w3)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
 
     /* w2 = (a2 + a1 + a0)**2 */
     if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
     if ((res = mp_sqr(&tmp1, &w2)) != MP_OKAY) {
-       goto ERR;
+       goto LBL_ERR;
     }
 
     /* now solve the matrix
@@ -117,104 +117,104 @@ mp_toom_sqr(mp_int *a, mp_int *b)
 
      /* r1 - r4 */
      if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3 - r0 */
      if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1/2 */
      if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3/2 */
      if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r2 - r0 - r4 */
      if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1 - r2 */
      if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3 - r2 */
      if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1 - 8r0 */
      if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3 - 8r4 */
      if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* 3r2 - r1 - r3 */
      if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1 - r2 */
      if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3 - r2 */
      if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r1/3 */
      if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      /* r3/3 */
      if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
 
      /* at this point shift W[n] by B*n */
      if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
 
      if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
      if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) {
-        goto ERR;
+        goto LBL_ERR;
      }
 
-ERR:
+LBL_ERR:
      mp_clear_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL);
      return res;
 }
-- 
1.7.9.2

>From 8bbd357e70d7329be9e84a8e29c201ee01db3c88 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Fri, 30 Aug 2013 08:56:52 -0400
Subject: [PATCH 2/9] Use the full pathname for /bin/sh in Makefile.

Using a plain SHELL = sh with Solaris make results in the error message:
  mksh: Fatal error: Could not load Shell from `sh': Bad file number
---
 build/setup.pm |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build/setup.pm b/build/setup.pm
index 3372fcf..69ee042 100755
--- a/build/setup.pm
+++ b/build/setup.pm
@@ -86,7 +86,7 @@ our %THIRDPARTY = (
 
 our %SHELLS = (
     posix => {
-        sh  => 'sh',
+        sh  => '/bin/sh',
         cat => 'cat',
         rm  => 'rm -f',
         nul => '/dev/null',
-- 
1.7.9.2

>From cca0221eef8a0dd44108b20e3f1b5082195b1203 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Mon, 2 Sep 2013 13:55:34 -0400
Subject: [PATCH 3/9] Use sched_yield() on Solaris systems.

According to the Linux manpage for sched_yield(), it should also be used
whenever _POSIX_PRIORITY_SCHEDULING is defined.
---
 src/platform/threads.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/platform/threads.h b/src/platform/threads.h
index 9de99bd..266a213 100644
--- a/src/platform/threads.h
+++ b/src/platform/threads.h
@@ -1,6 +1,6 @@
 #if defined _WIN32
 #define MVM_platform_yield SwitchToThread
-#elif defined __APPLE__
+#elif defined(__APPLE__) || defined(__sun) || defined(_POSIX_PRIORITY_SCHEDULING)
 #include <sched.h>
 #define MVM_platform_yield sched_yield
 #else
-- 
1.7.9.2

>From 9f4e6be59bf685d30db36f664fc4a8c225a9b7e2 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Tue, 10 Sep 2013 07:58:26 -0400
Subject: [PATCH 4/9] Avoid an anonymous union in MVMOSHandleBody.

Although anonymous unions are in the c11 standard, and gcc has supported
them for some time, not all compilers implement the standard fully.
The Solaris Studio 12.3 compiler (the current release) does not.
This patch gives the union a minimal 'u' name.  Something more meaningful
would be fine too.
---
 src/6model/reprs/MVMOSHandle.h |    2 +-
 src/io/dirops.c                |    8 +++---
 src/io/fileops.c               |   60 ++++++++++++++++++++--------------------
 src/io/socketops.c             |   50 ++++++++++++++++-----------------
 4 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/src/6model/reprs/MVMOSHandle.h b/src/6model/reprs/MVMOSHandle.h
index a975e6b..f187a6a 100644
--- a/src/6model/reprs/MVMOSHandle.h
+++ b/src/6model/reprs/MVMOSHandle.h
@@ -22,7 +22,7 @@ struct MVMOSHandleBody {
 #else
         DIR     *dir_handle;
 #endif
-    };
+    } u;
     MVMuint8        eof;
     MVMuint8 encoding_type;
 };
diff --git a/src/io/dirops.c b/src/io/dirops.c
index 10d5d0a..53dc742 100644
--- a/src/io/dirops.c
+++ b/src/io/dirops.c
@@ -184,7 +184,7 @@ MVMObject * MVM_dir_open(MVMThreadContext *tc, MVMString *dirname) {
     }
 
     result->body.type          = MVM_OSHANDLE_DIR;
-    result->body.dir_handle    = dir_handle;
+    result->body.u.dir_handle    = dir_handle;
     result->body.encoding_type = MVM_encoding_type_utf8;
 
 #endif
@@ -230,7 +230,7 @@ MVMString * MVM_dir_read(MVMThreadContext *tc, MVMObject *oshandle) {
 
     verify_dirhandle_type(tc, oshandle, &handle, "read from dirhandle");
 
-    ret = readdir_r(handle->body.dir_handle, &entry, &result);
+    ret = readdir_r(handle->body.u.dir_handle, &entry, &result);
 
     if (ret == 0) {
         if (result == NULL) {
@@ -249,7 +249,7 @@ void MVM_dir_close(MVMThreadContext *tc, MVMObject *oshandle) {
     verify_dirhandle_type(tc, oshandle, &handle, "close dirhandle");
 #ifdef _WIN32
     if(handle->body.dir_name) {
-        free(handle->body.dir_name);
+        free(handle->body.u.dir_name);
         handle->body.dir_name = NULL;
     }
 
@@ -257,7 +257,7 @@ void MVM_dir_close(MVMThreadContext *tc, MVMObject *oshandle) {
         MVM_exception_throw_adhoc(tc, "Failed to close dirhandle: %d", GetLastError());
 #else
 
-    if (closedir(handle->body.dir_handle) == -1)
+    if (closedir(handle->body.u.dir_handle) == -1)
         MVM_exception_throw_adhoc(tc, "Failed to close dirhandle: %d", errno);
 #endif
 }
diff --git a/src/io/fileops.c b/src/io/fileops.c
index 1f3bcff..360d81a 100644
--- a/src/io/fileops.c
+++ b/src/io/fileops.c
@@ -193,7 +193,7 @@ MVMObject * MVM_file_open_fh(MVMThreadContext *tc, MVMString *filename, MVMStrin
 
     free(fmode);
 
-    if ((result->body.fd = uv_fs_open(tc->loop, &req, (const char *)fname, flag, DEFAULT_MODE, NULL)) < 0) {
+    if ((result->body.u.fd = uv_fs_open(tc->loop, &req, (const char *)fname, flag, DEFAULT_MODE, NULL)) < 0) {
         free(fname);
         MVM_exception_throw_adhoc(tc, "Failed to open file: %s", uv_strerror(req.result));
     }
@@ -212,7 +212,7 @@ void MVM_file_close_fh(MVMThreadContext *tc, MVMObject *oshandle) {
 
     verify_filehandle_type(tc, oshandle, &handle, "close filehandle");
 
-    if (uv_fs_close(tc->loop, &req, handle->body.fd, NULL) < 0) {
+    if (uv_fs_close(tc->loop, &req, handle->body.u.fd, NULL) < 0) {
         MVM_exception_throw_adhoc(tc, "Failed to close filehandle: %s", uv_strerror(req.result));
     }
 }
@@ -229,7 +229,7 @@ MVMString * MVM_file_readline_fh(MVMThreadContext *tc, MVMObject *oshandle) {
 
     verify_filehandle_type(tc, oshandle, &handle, "readline from filehandle");
 
-    while (uv_fs_read(tc->loop, &req, handle->body.fd, &ch, 1, -1, NULL) > 0) {
+    while (uv_fs_read(tc->loop, &req, handle->body.u.fd, &ch, 1, -1, NULL) > 0) {
         bytes_read++;
 
         if (ch == 10 || ch == 13)
@@ -238,7 +238,7 @@ MVMString * MVM_file_readline_fh(MVMThreadContext *tc, MVMObject *oshandle) {
 
     /* have a look if it is a windows newline. */
     if (ch == 13) {
-        if (uv_fs_read(tc->loop, &req, handle->body.fd, &ch, 1, -1, NULL) > 0 && ch == 10) {
+        if (uv_fs_read(tc->loop, &req, handle->body.u.fd, &ch, 1, -1, NULL) > 0 && ch == 10) {
             bytes_read++;
         } else {
             step_back++;
@@ -249,7 +249,7 @@ MVMString * MVM_file_readline_fh(MVMThreadContext *tc, MVMObject *oshandle) {
 
     buf = malloc(bytes_read);
 
-    if (uv_fs_read(tc->loop, &req, handle->body.fd, buf, bytes_read, -1, NULL) < 0) {
+    if (uv_fs_read(tc->loop, &req, handle->body.u.fd, buf, bytes_read, -1, NULL) < 0) {
         free(buf);
         MVM_exception_throw_adhoc(tc, "readline from filehandle failed: %s", uv_strerror(req.result));
     }
@@ -304,7 +304,7 @@ MVMString * MVM_file_readline_interactive_fh(MVMThreadContext *tc, MVMObject *os
 }
 
 static void tty_on_alloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) {
-    const MVMint64 length = ((MVMOSHandleBody *)(handle->data))->length;
+    const MVMint64 length = ((MVMOSHandleBody *)(handle->data))->u.length;
 
     buf->base = malloc(length);
     buf->len = length;
@@ -313,8 +313,8 @@ static void tty_on_alloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t *b
 static void tty_on_read(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) {
     MVMOSHandleBody * const body = (MVMOSHandleBody *)(handle->data);
 
-    body->data = buf->base;
-    body->length = buf->len;
+    body->u.data = buf->base;
+    body->u.length = buf->len;
 }
 
 /* reads a string from a filehandle. */
@@ -337,15 +337,15 @@ MVMString * MVM_file_read_fhs(MVMThreadContext *tc, MVMObject *oshandle, MVMint6
     switch (handle->body.type) {
         case MVM_OSHANDLE_HANDLE: {
             MVMOSHandleBody * const body = &handle->body;
-            body->length = length;
-            uv_read_start((uv_stream_t *)body->handle, tty_on_alloc, tty_on_read);
-            buf = body->data;
-            bytes_read = body->length;
+            body->u.length = length;
+            uv_read_start((uv_stream_t *)body->u.handle, tty_on_alloc, tty_on_read);
+            buf = body->u.data;
+            bytes_read = body->u.length;
             break;
         }
         case MVM_OSHANDLE_FD:
             buf = malloc(length);
-            bytes_read = uv_fs_read(tc->loop, &req, handle->body.fd, buf, length, -1, NULL);
+            bytes_read = uv_fs_read(tc->loop, &req, handle->body.u.fd, buf, length, -1, NULL);
             break;
         default:
             break;
@@ -381,7 +381,7 @@ MVMString * MVM_file_readall_fh(MVMThreadContext *tc, MVMObject *oshandle) {
 
     verify_filehandle_type(tc, oshandle, &handle, "Readall from filehandle");
 
-    if (uv_fs_fstat(tc->loop, &req, handle->body.fd, NULL) < 0) {
+    if (uv_fs_fstat(tc->loop, &req, handle->body.u.fd, NULL) < 0) {
         MVM_exception_throw_adhoc(tc, "Readall from filehandle failed: %s", uv_strerror(req.result));
     }
 
@@ -390,7 +390,7 @@ MVMString * MVM_file_readall_fh(MVMThreadContext *tc, MVMObject *oshandle) {
     if (file_size > 0) {
         buf = malloc(file_size);
 
-        bytes_read = uv_fs_read(tc->loop, &req, handle->body.fd, buf, file_size, -1, NULL);
+        bytes_read = uv_fs_read(tc->loop, &req, handle->body.u.fd, buf, file_size, -1, NULL);
         if (bytes_read < 0) {
             free(buf);
             MVM_exception_throw_adhoc(tc, "Readall from filehandle failed: %s", uv_strerror(req.result));
@@ -438,7 +438,7 @@ MVMint64 MVM_file_write_fhs(MVMThreadContext *tc, MVMObject *oshandle, MVMString
 
             buf.base = output;
             buf.len  = bytes_written = output_size;
-            if ((r = uv_write(&req, (uv_stream_t *)handle->body.handle, &buf, 1, NULL)) < 0) {
+            if ((r = uv_write(&req, (uv_stream_t *)handle->body.u.handle, &buf, 1, NULL)) < 0) {
                 free(output);
                 MVM_exception_throw_adhoc(tc, "Failed to write bytes to filehandle: %s", uv_strerror(r));
             }
@@ -446,7 +446,7 @@ MVMint64 MVM_file_write_fhs(MVMThreadContext *tc, MVMObject *oshandle, MVMString
         }
         case MVM_OSHANDLE_FD: {
             uv_fs_t req;
-            bytes_written = uv_fs_write(tc->loop, &req, handle->body.fd, (const void *)output, output_size, -1, NULL);
+            bytes_written = uv_fs_write(tc->loop, &req, handle->body.u.fd, (const void *)output, output_size, -1, NULL);
             if (bytes_written < 0) {
                 free(output);
                 MVM_exception_throw_adhoc(tc, "Failed to write bytes to filehandle: %s", uv_strerror(req.result));
@@ -479,7 +479,7 @@ void MVM_file_seek(MVMThreadContext *tc, MVMObject *oshandle, MVMint64 offset, M
 
     verify_filehandle_type(tc, oshandle, &handle, "seek in filehandle");
 
-    if (MVM_platform_lseek(handle->body.fd, offset, flag) == -1) {
+    if (MVM_platform_lseek(handle->body.u.fd, offset, flag) == -1) {
         MVM_exception_throw_adhoc(tc, "Failed to seek in filehandle: %d", errno);
     }
 }
@@ -491,7 +491,7 @@ MVMint64 MVM_file_tell_fh(MVMThreadContext *tc, MVMObject *oshandle) {
 
     verify_filehandle_type(tc, oshandle, &handle, "seek in filehandle");
 
-    if ((r = MVM_platform_lseek(handle->body.fd, 0, SEEK_CUR)) == -1) {
+    if ((r = MVM_platform_lseek(handle->body.u.fd, 0, SEEK_CUR)) == -1) {
         MVM_exception_throw_adhoc(tc, "Failed to seek in filehandle: %d", errno);
     }
 
@@ -509,13 +509,13 @@ MVMint64 MVM_file_lock(MVMThreadContext *tc, MVMObject *oshandle, MVMint64 flag)
   struct flock l;
   ssize_t r;
   int fc;
-  const int fd = handle->body.fd;
+  const int fd = handle->body.u.fd;
 #endif
 
     verify_filehandle_type(tc, oshandle, &handle, "lock filehandle");
 
 #ifdef _WIN32
-    hf = (HANDLE)_get_osfhandle(handle->body.fd);
+    hf = (HANDLE)_get_osfhandle(handle->body.u.fd);
     if (hf == INVALID_HANDLE_VALUE) {
         MVM_exception_throw_adhoc(tc, "Failed to seek in filehandle: bad file descriptor");
     }
@@ -567,13 +567,13 @@ void MVM_file_unlock(MVMThreadContext *tc, MVMObject *oshandle) {
 #else
   struct flock l;
   ssize_t r;
-  const int fd = handle->body.fd;
+  const int fd = handle->body.u.fd;
 #endif
 
     verify_filehandle_type(tc, oshandle, &handle, "unlock filehandle");
 
 #ifdef _WIN32
-    hf = (HANDLE)_get_osfhandle(handle->body.fd);
+    hf = (HANDLE)_get_osfhandle(handle->body.u.fd);
     if (hf == INVALID_HANDLE_VALUE) {
         MVM_exception_throw_adhoc(tc, "Failed to seek in filehandle: bad file descriptor");
     }
@@ -608,7 +608,7 @@ void MVM_file_sync(MVMThreadContext *tc, MVMObject *oshandle) {
 
     verify_filehandle_type(tc, oshandle, &handle, "sync filehandle");
 
-    if(uv_fs_fsync(tc->loop, &req, handle->body.fd, NULL) < 0 ) {
+    if(uv_fs_fsync(tc->loop, &req, handle->body.u.fd, NULL) < 0 ) {
         MVM_exception_throw_adhoc(tc, "Failed to sync filehandle: %s", uv_strerror(req.result));
     }
 }
@@ -620,7 +620,7 @@ void MVM_file_truncate(MVMThreadContext *tc, MVMObject *oshandle, MVMint64 offse
 
     verify_filehandle_type(tc, oshandle, &handle, "truncate filehandle");
 
-    if(uv_fs_ftruncate(tc->loop, &req, handle->body.fd, offset, NULL) < 0 ) {
+    if(uv_fs_ftruncate(tc->loop, &req, handle->body.u.fd, offset, NULL) < 0 ) {
         MVM_exception_throw_adhoc(tc, "Failed to truncate filehandle: %s", uv_strerror(req.result));
     }
 }
@@ -635,21 +635,21 @@ static MVMObject * MVM_file_get_stdstream(MVMThreadContext *tc, MVMuint8 type, M
         case UV_TTY: {
             uv_tty_t * const handle = malloc(sizeof(uv_tty_t));
             uv_tty_init(tc->loop, handle, type, readable);
-            body->handle = (uv_handle_t *)handle;
-            body->handle->data = body;       /* this is needed in tty_on_read function. */
+            body->u.handle = (uv_handle_t *)handle;
+            body->u.handle->data = body;       /* this is needed in tty_on_read function. */
             body->type = MVM_OSHANDLE_HANDLE;
             break;
         }
         case UV_FILE:
-            body->fd   = type;
+            body->u.fd   = type;
             body->type = MVM_OSHANDLE_FD;
             break;
         case UV_NAMED_PIPE: {
             uv_pipe_t * const handle = malloc(sizeof(uv_pipe_t));
             uv_pipe_init(tc->loop, handle, 0);
             uv_pipe_open(handle, type);
-            body->handle = (uv_handle_t *)handle;
-            body->handle->data = body;
+            body->u.handle = (uv_handle_t *)handle;
+            body->u.handle->data = body;
             body->type = MVM_OSHANDLE_HANDLE;
             break;
         }
diff --git a/src/io/socketops.c b/src/io/socketops.c
index ded9d97..856be7f 100644
--- a/src/io/socketops.c
+++ b/src/io/socketops.c
@@ -57,8 +57,8 @@ MVMObject * MVM_socket_connect(MVMThreadContext *tc, MVMObject *type_object, MVM
     result = (MVMOSHandle *)REPR(type_object)->allocate(tc, STABLE(type_object));
 
     body = &result->body;
-    body->handle = (uv_handle_t *)socket;
-    body->handle->data = body;   /* this is needed in tcp_stream_on_read function. */
+    body->u.handle = (uv_handle_t *)socket;
+    body->u.handle->data = body;   /* this is needed in tcp_stream_on_read function. */
     body->type = MVM_OSHANDLE_TCP;
     body->encoding_type = encoding_flag;
 
@@ -70,7 +70,7 @@ void MVM_socket_close(MVMThreadContext *tc, MVMObject *oshandle) {
 
     verify_socket_type(tc, oshandle, &handle, "close socket");
 
-    uv_close(handle->body.handle, NULL);
+    uv_close(handle->body.u.handle, NULL);
 }
 
 MVMObject * MVM_socket_bind(MVMThreadContext *tc, MVMObject *type_object, MVMString *address, MVMint64 port, MVMint64 protocol, MVMint64 encoding_flag) {
@@ -111,8 +111,8 @@ MVMObject * MVM_socket_bind(MVMThreadContext *tc, MVMObject *type_object, MVMStr
             uv_tcp_t *server = malloc(sizeof(uv_tcp_t));
             uv_tcp_init(tc->loop, server);
             uv_tcp_bind(server, &bind_addr);
-            body->handle = (uv_handle_t *)server;
-            body->handle->data = body;   /* this is needed in tcp_stream_on_read function. */
+            body->u.handle = (uv_handle_t *)server;
+            body->u.handle->data = body;   /* this is needed in tcp_stream_on_read function. */
             body->type = MVM_OSHANDLE_TCP;
             body->encoding_type = encoding_flag;
             break;
@@ -122,8 +122,8 @@ MVMObject * MVM_socket_bind(MVMThreadContext *tc, MVMObject *type_object, MVMStr
             uv_udp_t *server = malloc(sizeof(uv_udp_t));
             uv_udp_init(tc->loop, server);
             uv_udp_bind(server, &bind_addr, 0);
-            body->handle = (uv_handle_t *)server;
-            body->handle->data = body;    /* this is needed in udp_stream_on_read function. */
+            body->u.handle = (uv_handle_t *)server;
+            body->u.handle->data = body;    /* this is needed in udp_stream_on_read function. */
             body->type = MVM_OSHANDLE_UDP;
             body->encoding_type = encoding_flag;
             break;
@@ -139,7 +139,7 @@ void MVM_socket_listen(MVMThreadContext *tc, MVMObject *oshandle, MVMint64 backl
 
     verify_socket_type(tc, oshandle, &handle, "listen socket");
 
-    if ((r = uv_listen((uv_stream_t *)handle->body.handle, (int)backlog_size, NULL)) < 0) {
+    if ((r = uv_listen((uv_stream_t *)handle->body.u.handle, (int)backlog_size, NULL)) < 0) {
         MVM_exception_throw_adhoc(tc, "Failed to listen to the socket: %s", uv_strerror(r));
     }
 }
@@ -159,7 +159,7 @@ MVMObject * MVM_socket_accept(MVMThreadContext *tc, MVMObject *oshandle/*, MVMin
     uv_tcp_init(tc->loop, client);
 
     /* XXX TODO: set the timeout if one is provided */
-    if ((r = uv_accept((uv_stream_t *)handle->body.handle, (uv_stream_t*) client)) != 0) {
+    if ((r = uv_accept((uv_stream_t *)handle->body.u.handle, (uv_stream_t*) client)) != 0) {
         free(client);
         MVM_exception_throw_adhoc(tc, "Socket accept failed to get connection: %s", uv_strerror(r));
     }
@@ -167,8 +167,8 @@ MVMObject * MVM_socket_accept(MVMThreadContext *tc, MVMObject *oshandle/*, MVMin
     /* inherit the type object of the originating socket */
     result = (MVMOSHandle *)REPR(STABLE(oshandle)->WHAT)->allocate(tc, STABLE(STABLE(oshandle)->WHAT));
     body = &handle->body;
-    body->handle = (uv_handle_t *)client;
-    body->handle->data = body;      /* this is needed in tcp_stream_on_read function. */
+    body->u.handle = (uv_handle_t *)client;
+    body->u.handle->data = body;      /* this is needed in tcp_stream_on_read function. */
     body->type   = MVM_OSHANDLE_TCP;
     body->encoding_type = handle->body.encoding_type;
 
@@ -190,7 +190,7 @@ MVMint64 MVM_socket_send_string(MVMThreadContext *tc, MVMObject *oshandle, MVMSt
     buf.base = output;
     buf.len  = output_size;
 
-    if ((r = uv_write(&req, (uv_stream_t *)handle->body.handle, &buf, 1, NULL)) < 0) {
+    if ((r = uv_write(&req, (uv_stream_t *)handle->body.u.handle, &buf, 1, NULL)) < 0) {
         free(output);
         MVM_exception_throw_adhoc(tc, "Failed to write bytes to filehandle: %s", uv_strerror(r));
     }
@@ -201,7 +201,7 @@ MVMint64 MVM_socket_send_string(MVMThreadContext *tc, MVMObject *oshandle, MVMSt
 }
 
 static void stream_on_alloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) {
-    const MVMint64 length = ((MVMOSHandleBody *)(handle->data))->length;
+    const MVMint64 length = ((MVMOSHandleBody *)(handle->data))->u.length;
 
     buf->base = malloc(length);
     buf->len = length;
@@ -210,16 +210,16 @@ static void stream_on_alloc(uv_handle_t *handle, size_t suggested_size, uv_buf_t
 static void tcp_stream_on_read(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) {
     MVMOSHandleBody * const body = (MVMOSHandleBody *)(handle->data);
 
-    body->data = buf->base;
-    body->length = buf->len;
+    body->u.data = buf->base;
+    body->u.length = buf->len;
 }
 
 static void udp_stream_on_read(uv_udp_t *handle, ssize_t nread, const uv_buf_t *buf,
     const struct sockaddr* addr, unsigned flags) {
     MVMOSHandleBody * const body = (MVMOSHandleBody *)(handle->data);
 
-    body->data = buf->base;
-    body->length = buf->len;
+    body->u.data = buf->base;
+    body->u.length = buf->len;
 }
 
 /* reads a string from a filehandle. */
@@ -240,18 +240,18 @@ MVMString * MVM_socket_receive_string(MVMThreadContext *tc, MVMObject *oshandle,
     switch (handle->body.type) {
         case MVM_OSHANDLE_TCP: {
             MVMOSHandleBody * const body = &handle->body;
-            body->length = length;
-            uv_read_start((uv_stream_t *)body->handle, stream_on_alloc, tcp_stream_on_read);
-            buf = body->data;
-            bytes_read = body->length;
+            body->u.length = length;
+            uv_read_start((uv_stream_t *)body->u.handle, stream_on_alloc, tcp_stream_on_read);
+            buf = body->u.data;
+            bytes_read = body->u.length;
             break;
         }
         case MVM_OSHANDLE_UDP: {
             MVMOSHandleBody * const body = &handle->body;
-            body->length = length;
-            uv_udp_recv_start((uv_udp_t *)body->handle, stream_on_alloc, udp_stream_on_read);
-            buf = body->data;
-            bytes_read = body->length;
+            body->u.length = length;
+            uv_udp_recv_start((uv_udp_t *)body->u.handle, stream_on_alloc, udp_stream_on_read);
+            buf = body->u.data;
+            bytes_read = body->u.length;
             break;
         }
         default:
-- 
1.7.9.2

>From e76caf8af53d4e32735e4ac68a7328163d6583ff Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Tue, 10 Sep 2013 08:03:53 -0400
Subject: [PATCH 5/9] On Solaris, add -lkstat for libuv kernel statistics.

---
 build/setup.pm |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build/setup.pm b/build/setup.pm
index 69ee042..1a40fd6 100755
--- a/build/setup.pm
+++ b/build/setup.pm
@@ -412,7 +412,7 @@ our %OS_FREEBSD = (
 our %OS_SOLARIS = (
     %OS_POSIX,
 
-    syslibs => [ qw( socket sendfile nsl pthread m rt ) ],
+    syslibs => [ qw( socket sendfile nsl pthread kstat m rt ) ],
     mknoisy => '',
 
     -thirdparty => {
-- 
1.7.9.2

>From 5c582f867175a1d3ddd55c069f6f362eb47861f5 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Tue, 10 Sep 2013 08:05:42 -0400
Subject: [PATCH 6/9] On Solaris, add -mt to ccflags, since we are compiling
 for threads.

---
 build/setup.pm |    1 +
 1 file changed, 1 insertion(+)

diff --git a/build/setup.pm b/build/setup.pm
index 1a40fd6..75d3209 100755
--- a/build/setup.pm
+++ b/build/setup.pm
@@ -414,6 +414,7 @@ our %OS_SOLARIS = (
 
     syslibs => [ qw( socket sendfile nsl pthread kstat m rt ) ],
     mknoisy => '',
+    ccmiscflags => '-mt',
 
     -thirdparty => {
         uv => { %TP_UVDUMMY, objects => '$(UV_SOLARIS)' },
-- 
1.7.9.2

>From 3be2c399df031f62daf5d24bf359c3513c3baaa8 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Tue, 10 Sep 2013 08:07:55 -0400
Subject: [PATCH 7/9] Add Solaris-specific list of object files for libuv.

---
 build/Makefile.in |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/build/Makefile.in b/build/Makefile.in
index d17ba3b..6fb14cb 100644
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -242,6 +242,9 @@ UV_DARWIN = 3rdparty/libuv/src/unix/darwin@obj@ \
             3rdparty/libuv/src/unix/proctitle@obj@ \
             $(UV_UNIX)
 
+UV_SOLARIS = 3rdparty/libuv/src/unix/sunos@obj@ \
+	    $(UV_UNIX)
+
 UV_OBJECTS = @uvobjects@
 
 TOM_OBJECTS = @tomobjects@
-- 
1.7.9.2

>From aab44c0e225f73d217ff447405f2cead23d77d18 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Tue, 10 Sep 2013 08:10:32 -0400
Subject: [PATCH 8/9] Add #defines for various EXTENSIONS to get Solaris to
 compile libuv.

---
 build/setup.pm |    1 +
 1 file changed, 1 insertion(+)

diff --git a/build/setup.pm b/build/setup.pm
index 75d3209..04ebd75 100755
--- a/build/setup.pm
+++ b/build/setup.pm
@@ -412,6 +412,7 @@ our %OS_FREEBSD = (
 our %OS_SOLARIS = (
     %OS_POSIX,
 
+    defs     => [ qw( _XOPEN_SOURCE=500 _XOPEN_SOURCE_EXTENDED=1  __EXTENSIONS__=1  _REENTRANT _FILE_OFFSET_BITS=64 ) ],
     syslibs => [ qw( socket sendfile nsl pthread kstat m rt ) ],
     mknoisy => '',
     ccmiscflags => '-mt',
-- 
1.7.9.2

>From 0f344831de228a104cff244c20604947148406b5 Mon Sep 17 00:00:00 2001
From: Andy Dougherty <dough...@lafayette.edu>
Date: Tue, 10 Sep 2013 08:12:29 -0400
Subject: [PATCH 9/9] Make 3rdparty/dyncall use Makefile.embedded for Solaris.

See the file 3rdparty/dyncall/README.Solaris for more information.
---
 build/setup.pm |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/build/setup.pm b/build/setup.pm
index 04ebd75..c46d058 100755
--- a/build/setup.pm
+++ b/build/setup.pm
@@ -418,6 +418,10 @@ our %OS_SOLARIS = (
     ccmiscflags => '-mt',
 
     -thirdparty => {
+        dc => { %TP_DC,
+	        rule  => 'cd 3rdparty/dyncall &&  CC=\'$(CC)\' CFLAGS=\'$(CFLAGS)\' $(MAKE) -f Makefile.embedded sun',
+	        clean => 'cd 3rdparty/dyncall &&  CC=\'$(CC)\' CFLAGS=\'$(CFLAGS)\' $(MAKE) -f Makefile.embedded clean',
+	    },
         uv => { %TP_UVDUMMY, objects => '$(UV_SOLARIS)' },
     },
 );
-- 
1.7.9.2

Reply via email to