[stunnel-users] Solaris: new_context, makecontext

Hans Werner Strube strube at physik3.gwdg.de
Wed Nov 9 15:04:11 CET 2005


Michal Trojnara wrote:
> Please try: ftp://stunnel.mirt.net/stunnel/stunnel-4.15b1.tar.gz

The changes to common.h and sthreads.c with respect to new_context and
makecontext are reasonable. However, there are two problems:

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.

*** sthreads.c.15b1	Wed Nov  9 12:18:18 2005
--- sthreads.c	Wed Nov  9 14:56:18 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,101 ----
          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->stack+=STACK_SIZE-8;
+ #endif
+     ctx->ctx.uc_stack.ss_sp=ctx->stack;
      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;
  }
  
--- 126,132 ----
      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