From: arne@vajhoej.dk   
      
   On 1/1/2026 8:51 PM, Arne Vajhøj wrote:   
   > #include    
   > #include    
   > #include    
   >   
   > #include    
   > #include    
   >   
   > int myalloc(int *siz, void **addr)   
   > {   
   > *addr = malloc(*siz);   
   > return 1;   
   > }   
   >   
   > struct myparam   
   > {   
   > int iv;   
   > char sv[100];   
   > };   
   >   
   > struct myparam *myparam_p(struct _kpb *ctx)   
   > {   
   > return (struct myparam *)(ctx + 1);   
   > }   
   >   
   > void test(struct _kpb *ctx)   
   > {   
   > printf("B1 (%s)\n", myparam_p(ctx)->sv);   
   > myparam_p(ctx)->iv = 123;   
   > exe$kp_stall_general(ctx);   
   > printf("B2 (%s)\n", myparam_p(ctx)->sv);   
   > myparam_p(ctx)->iv = 456;   
   > exe$kp_stall_general(ctx);   
   > printf("B3 (%s)\n", myparam_p(ctx)->sv);   
   > myparam_p(ctx)->iv = 789;   
   > exe$kp_end(ctx);   
   > }   
   >   
   > int main()   
   > {   
   > struct _kpb *ctx;   
   > exe$kp_user_alloc_kpb(&ctx,   
   > KP$M_VEST |   
   KP$M_SET_STACK_LIMITS,   
   > sizeof(struct myparam),   
   > myalloc,   
   > 1000000,   
   > exe$kp_all   
   c_mem_stack_user,   
   > 10000,   
   > exe$kp_all   
   c_rse_stack_p2_any,   
   > NULL);   
   > printf("A1\n");   
   > strcpy(myparam_p(ctx)->sv, "ABC");   
   > exe$kp_start(ctx, test, KPREG$K_HLL_REG_MASK);   
   > printf("A2 (%d)\n", myparam_p(ctx)->iv);   
   > strcpy(myparam_p(ctx)->sv, "DEF");   
   > exe$kp_restart(ctx, 0);   
   > printf("A3 (%d)\n", myparam_p(ctx)->iv);   
   > strcpy(myparam_p(ctx)->sv, "GHI");   
   > exe$kp_restart(ctx, 0);   
   > printf("A4 (%d)\n", myparam_p(ctx)->iv);   
   > return 0;   
   > }   
      
   In case anyone wants to build, then it is:   
      
   $ cc kp + sys$library:sys$lib_c/libr   
   $ link kp + sys$input/opt   
   sys$loadable_images:sys$base_image/share   
   $   
      
   Arne   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|