[stunnel-users] Solaris: new_context, makecontext

Hans Werner Strube strube at physik3.gwdg.de
Wed Nov 9 17:12:05 CET 2005


Hans Werner Strube wrote:
> 1. Line 92 of sthreads.c,
> (char *)ctx->ctx.uc_stack.ss_sp+=STACK_SIZE-8;
> causes a compiler warning: "a cast does not yield an lvalue."
> 
> 2. The Solaris <9 SPARC peculiarity concerning the third argument of
> makecontext might be taken into account.
> 
> Both would be fixed by the following changes.
> ***Caveat: I do not know how the third argument of makecontext behaves
> in Solaris x86 for versions <9 vs. >=9. Have no machine to test this.

Sorry, my patch contained a bad error: ctx->stack+=STACK_SIZE-8 is, of
course, nonsense, since ctx->stack must not be changed. My patch to version
4.15b1 should read instead:

*** sthreads.c.15b1	Wed Nov  9 12:18:18 2005
--- sthreads.c	Wed Nov  9 17:07:57 2005
***************
*** 78,85 ****
          return NULL;
      }
      ctx->ctx.uc_link=NULL; /* it should never happen */
!     ctx->ctx.uc_stack.ss_sp=ctx->stack;
! #if defined(__sgi) || (defined(CPU_SPARC) && ( \
          defined(OS_SOLARIS2_0) || \
          defined(OS_SOLARIS2_1) || \
          defined(OS_SOLARIS2_2) || \
--- 78,84 ----
          return NULL;
      }
      ctx->ctx.uc_link=NULL; /* it should never happen */
! #if defined(CPU_SPARC) && ( \
          defined(OS_SOLARIS2_0) || \
          defined(OS_SOLARIS2_1) || \
          defined(OS_SOLARIS2_2) || \
***************
*** 88,96 ****
          defined(OS_SOLARIS2_5) || \
          defined(OS_SOLARIS2_6) || \
          defined(OS_SOLARIS2_7) || \
!         defined(OS_SOLARIS2_8)))
!     (char *)ctx->ctx.uc_stack.ss_sp+=STACK_SIZE-8;
  #endif
      ctx->ctx.uc_stack.ss_size=STACK_SIZE;
      ctx->ctx.uc_stack.ss_flags=0;
  
--- 87,102 ----
          defined(OS_SOLARIS2_5) || \
          defined(OS_SOLARIS2_6) || \
          defined(OS_SOLARIS2_7) || \
!         defined(OS_SOLARIS2_8))
! #define MCTXA 2
! #else
! #define MCTXA 1
  #endif
+ #if defined(__sgi) || (MCTXA == 2)
+     ctx->ctx.uc_stack.ss_sp=ctx->stack+STACK_SIZE-8;
+ #else
+     ctx->ctx.uc_stack.ss_sp=ctx->stack;
+ #endif
      ctx->ctx.uc_stack.ss_size=STACK_SIZE;
      ctx->ctx.uc_stack.ss_flags=0;
  
***************
*** 121,127 ****
      if(!ctx)
          return -1;
      s_log(LOG_DEBUG, "Context %ld created", ctx->id);
!     makecontext(&ctx->ctx, (void(*)(void))cli, 1, arg);
      return 0;
  }
  
--- 127,133 ----
      if(!ctx)
          return -1;
      s_log(LOG_DEBUG, "Context %ld created", ctx->id);
!     makecontext(&ctx->ctx, (void(*)(void))cli, MCTXA, arg);
      return 0;
  }
  



More information about the stunnel-users mailing list