Changeset 4067 for trunk/src


Ignore:
Timestamp:
Aug 22, 2000, 4:45:41 AM (25 years ago)
Author:
phaller
Message:

implemented _lock, _unlock, CxxThrowException

Location:
trunk/src/msvcrt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/msvcrt/msvcrt.cpp

    r3734 r4067  
    1 /* $Id: msvcrt.cpp,v 1.12 2000-06-21 17:33:37 phaller Exp $ */
     1/* $Id: msvcrt.cpp,v 1.13 2000-08-22 02:45:40 phaller Exp $ */
    22
    33/*
     
    1414#include <wchar.h>
    1515#include <math.h>
     16#include <string.h>
     17
    1618#include <heapstring.h>
    1719#include <crtdll.h>
     20
     21#include <win/winbase.h>
     22#include <win/winnt.h>
    1823#include "msvcrt.h"
    1924
     
    611616 *      FIXME - Could not find anything about it
    612617 */
    613 INT CDECL MSVCRT__CxxThrowException(DWORD ret)
    614 {
    615   dprintf(("MSVCRT: _CxxThrowException not implemented.\n"));
    616   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
    617   return FALSE;
     618
     619static EXCEPTION_RECORD cxxExceptionFrame =
     620{ 0x0e06d763, // Exception Code
     621  0x00000001, // Exception Flags
     622  0x00000000, // Exception Record Pointer
     623  0x00000000, // Exception Address
     624  0x00000003, // Number Of Parameters
     625  0x19930520, // Parameter #1
     626  0x00000000, // Parameter #2
     627  0x00000000  // Parameter #3
     628};
     629
     630VOID CDECL MSVCRT__CxxThrowException(DWORD arg1,
     631                                     DWORD arg2)
     632{
     633  EXCEPTION_RECORD er;
     634 
     635  dprintf(("MSVCRT: _CxxThrowException %08xh %08xh\n",
     636           arg1,
     637           arg2));
     638 
     639  //memcpy(er, cxxExceptionFrame, sizeof(er));
     640  // PH: optimization - why copying values when they're overwritten anyway...
     641  memcpy(&er, &cxxExceptionFrame, 6);
     642 
     643  // Note: er.ExceptionInformation[0] is already set!
     644  er.ExceptionInformation[1] = arg1;
     645  er.ExceptionInformation[2] = arg2;
     646 
     647  RaiseException(er.ExceptionCode,
     648                 er.ExceptionFlags,
     649                 er.NumberParameters,
     650                 &er.ExceptionInformation[0]);
    618651}
    619652
     
    12181251
    12191252/*********************************************************************
     1253 *                  _unlock    (MSVCRT.480)
     1254 */
     1255// Note: PH 2000/08/22 array size is probably larger than 0x12!
     1256static CRITICAL_SECTION* arrpCriticalSections[0x12] = {0};
     1257
     1258#define CRITSEC_TABLE_LOCK 0x11
     1259 
     1260VOID CDECL MSVCRT__unlock(unsigned long ulIndex)
     1261{
     1262  dprintf(("MSVCRT: _unlock\n"));
     1263 
     1264  CRITICAL_SECTION *pCS = arrpCriticalSections[ulIndex];
     1265  LeaveCriticalSection(pCS);
     1266}
     1267
     1268
     1269/*********************************************************************
     1270 *                  _lock    (MSVCRT.318)
     1271 */
     1272// Prototype from CRTDLL.CPP
     1273VOID CDECL amsg_exit(int errnum);
     1274
     1275VOID CDECL MSVCRT__lock(unsigned long ulIndex)
     1276{
     1277  dprintf(("MSVCRT: _lock\n"));
     1278 
     1279  CRITICAL_SECTION *pCS = arrpCriticalSections[ulIndex];
     1280  if (pCS == NULL)
     1281  {
     1282    CRITICAL_SECTION *pCSNew;
     1283   
     1284    pCSNew = (CRITICAL_SECTION*)malloc( sizeof(CRITICAL_SECTION) );
     1285    if (pCSNew == NULL)
     1286      amsg_exit(0x11); // yield error message
     1287   
     1288    MSVCRT__lock(CRITSEC_TABLE_LOCK); // lock table
     1289    if (pCS != NULL) // has been modified meanwhile by other thread ?
     1290      free(pCSNew);
     1291    else
     1292    {
     1293      InitializeCriticalSection(pCSNew);
     1294      arrpCriticalSections[ulIndex] = pCSNew;
     1295    }
     1296     
     1297    MSVCRT__unlock(CRITSEC_TABLE_LOCK); // unlock table
     1298  }
     1299   
     1300  EnterCriticalSection(pCS);
     1301}
     1302
     1303
     1304/*********************************************************************
    12201305 *                  _lseeki64    (MSVCRT.326)
    12211306 */
  • trunk/src/msvcrt/msvcrt.def

    r3734 r4067  
    1 ; $Id: msvcrt.def,v 1.17 2000-06-21 17:33:37 phaller Exp $
     1; $Id: msvcrt.def,v 1.18 2000-08-22 02:45:41 phaller Exp $
    22
    33;
     
    329329    _loaddll                    = _CRTDLL__loaddll              @316
    330330    _local_unwind2              = _CRTDLL__local_unwind2        @317
    331 ;   _lock                                                       @318
     331    _lock                       = _MSVCRT__lock                 @318
    332332    _locking                    = _CRTDLL__locking              @319
    333333    _logb                       = _CRTDLL__logb                 @320
     
    493493    _unlink                     = _CRTDLL__unlink               @478
    494494    _unloaddll                  = _CRTDLL__unloaddll            @479
    495 ;   _unlock                                                     @480
     495    _unlock                     = _MSVCRT__unlock               @480
    496496    _utime                      = _CRTDLL__utime                @481
    497497    _vsnprintf                  = _CRTDLL__vsnprintf            @482
Note: See TracChangeset for help on using the changeset viewer.