delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/08/17/10:39:01

From: pavenis AT lanet DOT lv
To: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>, djgpp-workers AT delorie DOT com
Date: Fri, 17 Aug 2001 17:38:56 +0300
MIME-Version: 1.0
Subject: Re: _open.c commit? (was Re: Selector Exhaustion)
Message-ID: <3B7D56B0.15574.8054BC@localhost>
In-reply-to: <3B7D3F16.28936.241EE7@localhost>
References: <2561-Fri17Aug2001115601+0300-eliz AT is DOT elta DOT co DOT il>
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

--Message-Boundary-27410
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

On 17 Aug 2001, at 15:58, pavenis AT lanet DOT lv wrote:

> 
> What about this? I added test for CWSDPMI v5 (corresponding DPMI
> call doesn't work with earlier versions). Also added possibility to
> enable or disable workaround from environment:
> 	SET   WORKAROUND_LDT_DESCRIPTORS_LEAK={y|n}
> 
> y is default for all cases except when CWSDPMI is begin used. 
> Perhaps we should think also about using some bit in 
> _crt0_startup_flags
> 	

It's strange it worked for me under Win98 so many times (perhaps
due Murphys laws for me not to notice 2 identical typos ...). WinNT
related things are not changed

Some timing info with latest update of BASH-2.0.5:

Time that were needed to configure gcc-3.0.1 development version
(initially in clean place,later without erasing config.cache etc.):

Workaround disabled:   136.4s    134.0s    86.6s    86.8s  
Workaround enabled:    138.4s    138.1s    89.9s    90.0s

Andris



--Message-Boundary-27410
Content-type: text/plain; charset=US-ASCII
Content-disposition: inline
Content-description: Attachment information.

The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File:  dosexec.c.diff5
     Date:  17 Aug 2001, 17:25
     Size:  3594 bytes.
     Type:  Text

--Message-Boundary-27410
Content-type: Application/Octet-stream; name="dosexec.c.diff5"; type=Text
Content-disposition: attachment; filename="dosexec.c.diff5"

*** djgpp/src/libc/dos/process/dosexec.c~1	Mon Jul 30 14:35:52 2001
--- djgpp/src/libc/dos/process/dosexec.c	Fri Aug 17 17:00:46 2001
*************** size_t __cmdline_str_len = sizeof(__cmdl
*** 157,163 ****
     if LFN is 2, there is a possiblity that the contents of the
     transfer buffer will be overrun!  */
  static int
! direct_exec_tail(const char *program, const char *args,
  		 char * const envp[], const char *proxy, int lfn,
  		 const char *cmdline_var)
  {
--- 157,163 ----
     if LFN is 2, there is a possiblity that the contents of the
     transfer buffer will be overrun!  */
  static int
! direct_exec_tail_1 (const char *program, const char *args,
  		 char * const envp[], const char *proxy, int lfn,
  		 const char *cmdline_var)
  {
*************** direct_exec_tail(const char *program, co
*** 413,418 ****
--- 413,506 ----
    return r.h.al;	/* AL holds the child exit code */
  }
  
+ 
+ 
+ static int direct_exec_tail (const char *program, const char *args,
+ 		 char * const envp[], const char *proxy, int lfn,
+ 		 const char *cmdline_var)
+ {
+   int   i, ret;
+   int   sel1=0, sel2=0;
+   char  desc_map[8192];
+   int   sel_base = _my_ds () & 7;
+   static int   workaround_descriptor_leaks = 1;
+   static int   first_call = 1;
+   static int   is_nt = 0;
+ 
+   if (first_call)
+   {
+      int flags;
+      char dpmi_vendor[128], *W;
+      is_nt = (_osmajor==5 && _osminor==0 && _get_dos_version(1)==0x0532) ? 1 : 0;
+ 
+      /* Disable descriptors leak workaround whenCWSDPMI v5 is begin    */
+      /* used (don't work with earlier versions as corresponding DPMI   */
+      /* call is supported beginning from v5)                           */
+ 
+      ret = __dpmi_get_capabilities (&flags,dpmi_vendor);
+      if (ret==0 && strcmp(dpmi_vendor+2,"CWSDPMI")==0)
+         workaround_descriptor_leaks = 0;
+ 
+      /* Added possibility to enable/disable LDT descriptors leak       */
+      /* workaround from environment (I think nice for testing or when  */
+      /* one have trouble)                                              */                                                        
+ 
+      W = getenv("WORKAROUND_LDT_DESCRIPTORS_LEAK");
+      if (W)
+      {
+ 	 if (*W=='y' || *W=='Y') workaround_descriptor_leaks = 1;
+ 	 if (*W=='n' || *W=='N') workaround_descriptor_leaks = 0;
+      }
+ 
+      first_call = 0;
+   }
+ 
+   if (workaround_descriptor_leaks)
+   {
+      if (is_nt)
+      {
+ 	 sel1 = __dpmi_allocate_ldt_descriptors (1);
+      }
+      else
+      {
+ 	 char * map = desc_map;
+ 	 for (i=sel_base; i<0x00010000; i+=8)
+ 	 {  /* FIXME: Use __dpmi_get_selector_increment_value() instead of 8 ?  */
+ 		*map++ = (__dpmi_get_descriptor_access_rights(i) & 0x80) ? 0 : 1;
+ 	 }
+      }
+   }
+ 
+   ret = direct_exec_tail_1 ( program, args, envp, proxy, lfn, cmdline_var );
+ 
+   if (workaround_descriptor_leaks)
+   {
+      if (is_nt)
+      {
+         sel2 = __dpmi_allocate_ldt_descriptors (1);
+         if (sel1>_dos_ds && sel2>_dos_ds)
+         {
+            for (i=sel2; i>=sel1; i-=8)
+               __dpmi_free_ldt_descriptor (i);
+         }
+      }
+      else
+      {
+         char * map = desc_map;
+         for (i=sel_base; i<0x00010000; i+=8)
+         {
+            if (*map++)
+            {
+                if (__dpmi_get_descriptor_access_rights(i) & 0x80)
+                    __dpmi_free_ldt_descriptor (i);
+            }
+         }
+      }
+   }
+   return ret;
+ }
+ 
+ 
  int
  _dos_exec(const char *program, const char *args, char * const envp[],
  	  const char *cmdline_var)

--Message-Boundary-27410--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019