Changeset 5193 for trunk/src


Ignore:
Timestamp:
Feb 19, 2001, 6:25:14 PM (25 years ago)
Author:
bird
Message:

Use DosAllocMemEx to 64KB align memory objects in the high private arena.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/oslibdos.cpp

    r5016 r5193  
    1 /* $Id: oslibdos.cpp,v 1.56 2001-01-23 11:59:45 sandervl Exp $ */
     1/* $Id: oslibdos.cpp,v 1.57 2001-02-19 17:25:14 bird Exp $ */
    22/*
    33 * Wrappers for OS/2 Dos* API
     
    3131#include "oslibdos.h"
    3232#include "dosqss.h"
     33#include "win32k.h"
    3334
    3435#define DBG_LOCALLOG    DBG_oslibdos
     
    293294//NT returns addresses aligned at 64k, so we do too.
    294295//******************************************************************************
    295 DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD size, DWORD flags)
    296 {
    297  LPVOID memaddr;
    298  DWORD  offset;
    299  APIRET rc;
    300 
    301   rc = DosAllocMem(&memaddr, size, PAG_READ | flAllocMem);
    302   if(rc) {
     296DWORD OSLibDosAllocMem(LPVOID *lplpMemAddr, DWORD cb, DWORD flFlags)
     297{
     298    PVOID   pvMemAddr;
     299    DWORD   offset;
     300    APIRET  rc;
     301
     302    /*
     303     * Let's try use the exteneded DosAllocMem API of Win32k.sys.
     304     */
     305    if (libWin32kInstalled())
     306    {
     307        rc = DosAllocMemEx(&pvMemAddr, cb, flFlags | flAllocMem | OBJ_ALIGN64K);
     308        if (rc != ERROR_NOT_SUPPORTED)  /* This call was stubbed until recently. */
     309            return rc;
     310    }
     311
     312    /*
     313     * If no or old Win32k fall back to old method.
     314     */
     315    rc = DosAllocMem(&pvMemAddr, cb, PAG_READ | flAllocMem);
     316    if (rc)
     317    {
    303318        return rc;
    304   }
    305   DosEnterCritSec();
    306   DosFreeMem(memaddr);
    307   offset = (DWORD)memaddr & 0xFFFF;
    308   if(offset) {
    309         DosAllocMem(&memaddr, 64*1024 - offset, PAG_READ | flAllocMem);
    310   }
    311   rc = DosAllocMem(lplpMemAddr, size, flags | flAllocMem);
    312   DosExitCritSec();
    313   if((DWORD)*lplpMemAddr & 0xFFFF) {//still not at 64k boundary?
     319    }
     320    DosEnterCritSec();
     321    DosFreeMem(pvMemAddr);
     322    offset = (DWORD)pvMemAddr & 0xFFFF;
     323    if (offset)
     324    {
     325        DosAllocMem(&pvMemAddr, 64*1024 - offset, PAG_READ | flAllocMem);
     326    }
     327    rc = DosAllocMem(lplpMemAddr, cb, flFlags | flAllocMem);
     328    DosExitCritSec();
     329    if ((DWORD)*lplpMemAddr & 0xFFFF)
     330    {   //still not at 64k boundary?
    314331        DosFreeMem(*lplpMemAddr);
    315         rc = OSLibDosAllocMem(lplpMemAddr, size, flags);
    316   }
    317   if(offset) {
    318         DosFreeMem(memaddr);
    319   }
    320 
    321   return rc;
     332        rc = OSLibDosAllocMem(lplpMemAddr, cb, flFlags);
     333    }
     334    if (offset)
     335    {
     336        DosFreeMem(pvMemAddr);
     337    }
     338
     339
     340    return rc;
    322341}
    323342//******************************************************************************
     
    591610  dosTime = *(USHORT*)pTime;
    592611  dosDate = *(USHORT*)pDate;
    593  
     612
    594613  // PH: probably replace with faster implementation than calling Open32
    595614  // through the external interface!
     
    17001719      return;
    17011720    }
    1702    
     1721
    17031722    if (longName[1] == '.' && longName[2] == 0) // ".."
    17041723    {
     
    17161735      return;
    17171736    }
    1718  
     1737
    17191738  INT x;
    17201739  CHAR *source = longName;
     
    17231742  // the filename.
    17241743  BOOL flag83 = TRUE;
    1725  
     1744
    17261745  // verify forbidden characters
    1727   for (x = 0; 
    1728        (x < 8) && 
     1746  for (x = 0;
     1747       (x < 8) &&
    17291748       (flag83 == TRUE);
    17301749       x++)
     
    17351754        x=1000;
    17361755        break;
    1737      
     1756
    17381757      case '/':      case '?':
    17391758      case '*':      case ':':
     
    17471766    }
    17481767  }
    1749  
     1768
    17501769  // verify we're on a period now
    17511770  if (flag83 == TRUE)
     
    17531772         flag83 = FALSE;
    17541773    else source++;
    1755  
     1774
    17561775  // verify extension
    17571776  if (flag83 == TRUE)
     
    17711790      source++;
    17721791    }
    1773  
     1792
    17741793  // verify we're at the end of the string now
    17751794  if (flag83 == TRUE)
    17761795    if (*source != 0)
    17771796      flag83 = FALSE;
    1778  
     1797
    17791798  // OK, done
    17801799  if (flag83 == TRUE)
     
    17841803    // would surely fail.
    17851804    strcpy(shortName, longName);
    1786    
     1805
    17871806    return; // Done
    17881807  }
    1789  
    1790  
     1808
     1809
    17911810  // @@@PH
    17921811  shortName[0] = 0; // this function is disabled anyway ...
    17931812  return;
    1794  
     1813
    17951814  CHAR *dest = shortName;
    17961815  CHAR *ext = strrchr(longName,'.');
    1797  
     1816
    17981817  //CB: quick and dirty, real FILE~12.EXT is too slow
    17991818  //PH: We'd have to count the number of non-8:3-compliant files
     
    18591878    name++;
    18601879    strcpy(pFind->cFileName,name);
    1861   } 
    1862   else 
     1880  }
     1881  else
    18631882    pFind->cFileName[0] = 0;
    1864  
     1883
    18651884  long2ShortName(pFind->cFileName,pFind->cAlternateFileName);
    18661885}
     
    19221941  DosError(FERR_ENABLEHARDERR | FERR_ENABLEEXCEPTION);
    19231942
    1924   if(rc) 
     1943  if(rc)
    19251944  {
    19261945    DosFindClose(hDir);
Note: See TracChangeset for help on using the changeset viewer.