home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.vms      DEC's VAX* line of computers & VMS.      264,096 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 263,360 of 264,096   
   =?UTF-8?Q?Arne_Vajh=C3=B8j?= to All   
   Re: cma$tis_errno_get_addr   
   17 Sep 25 21:26:20   
   
   From: arne@vajhoej.dk   
      
   On 9/17/2025 9:13 PM, Arne Vajhøj wrote:   
   > On 9/16/2025 7:31 AM, Craig A. Berry wrote:   
   >> On 9/15/25 9:56 PM, Arne Vajhøj wrote:   
   >>> On 9/15/2025 10:39 PM, Craig A. Berry wrote:   
   >>>> call CMA$TIS_VMSERRNO_GET_ADDR   
   >>>> !   
   >>>> ! The above returns an address   
   >>>> !   
   >>>> examine/condition    
   >>>   
   >>> Interesting.   
   >>>   
   >>> The value I see is indeed 65535.   
   >>>   
   >>> One question answered, but two new questions pop up.   
   >>>   
   >>> 1) How does the C++ library know that the main program   
   >>>     is Pascal and not C (for C I get a normal errno value)?   
   >   
   >> On #1, remember that the value of errno doesn't mean anything except   
   >> immediately after the error, so if C is successful but Pascal is not,   
   >> the fact that you get different errno values doesn't really tell you   
   >> anything.  If there is an error from both languages, then it does sound   
   >> like something is different about the initialization of the image or the   
   >> debugger session.  Since the debugger does have language-specific   
   >> features, it may be a more likely suspect.   
   >   
   > It is a about this.   
   >   
   > Trying a gazillion things has let me to conclude that   
   > C free sets errno when called on something allocated   
   > with Pascal malloc_c_str.   
   >   
   > Not yet clear to me why it does that. But I will find   
   > a way to workaround it.   
      
   And in case mr. Reagan wants to take a look:   
      
   Documentation state:   
      
      
   The memory allocated with MALLOC_C_STR must be deallocated with   
   the C free() routine.   
      
      
   But:   
      
   $ type re.pas   
   program re(input,output);   
      
   [external('decc$free')]   
   procedure free_c_str(ptr : c_str_t); external;   
      
   type   
       integer_ptr = ^integer;   
      
   [external]   
   function cma$tis_errno_get_addr : integer_ptr; external;   
      
   [external]   
   function cma$tis_vmserrno_get_addr : integer_ptr; external;   
      
   var   
       p : c_str_t;   
      
   begin   
       p := malloc_c_str('xxx');   
       writeln(cma$tis_errno_get_addr^, cma$tis_vmserrno_get_addr^);   
       free_c_str(p);   
       writeln(cma$tis_errno_get_addr^, cma$tis_vmserrno_get_addr^);   
   end.   
   $ pas re   
   $ link re   
   $ run re   
             0         0   
         65535   1409636   
   $ type re.c   
   #include    
   #include    
   #include    
      
   int main()   
   {   
        char *p = malloc(4);   
        printf("%d\n", errno);   
        free(p);   
        printf("%d\n", errno);   
        return 0;   
   }   
      
   $ cc re   
   $ link re   
   $ run re   
   0   
   0   
      
   Arne   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca