Ignore:
Timestamp:
Aug 18, 1999, 11:54:27 PM (26 years ago)
Author:
phaller
Message:

Fix: Interlocked Functions, Profile fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.CPP

    r550 r558  
    1 /* $Id: KERNEL32.CPP,v 1.15 1999-08-18 17:17:59 sandervl Exp $ */
     1/* $Id: KERNEL32.CPP,v 1.16 1999-08-18 21:54:26 phaller Exp $ */
    22
    33/*
     
    6262  return HMCloseHandle(hHandle);
    6363}
     64
     65
    6466//******************************************************************************
    6567HANDLE WIN32API GetStdHandle(DWORD fdwDevice)
     
    191193    return O32_InterlockedExchange(arg1, arg2);
    192194}
     195
     196
     197/************************************************************************
     198 *           InterlockedCompareExchange     [KERNEL32.879]
     199 *
     200 * Atomically compares Destination and Comperand, and if found equal exchanges
     201 * the value of Destination with Exchange
     202 *
     203 * RETURNS
     204 * Prior value of value pointed to by Destination
     205 */
     206PVOID WIN32API InterlockedCompareExchange(
     207       PVOID *Destination, /* Address of 32-bit value to exchange */
     208       PVOID Exchange,      /* change value, 32 bits */
     209            PVOID Comperand      /* value to compare, 32 bits */
     210) {
     211   PVOID ret;
     212   /* StopAllThreadsAndProcesses() */
     213
     214   ret=*Destination;
     215        if(*Destination==Comperand) *Destination=Exchange;
     216
     217   /* ResumeAllThreadsAndProcesses() */
     218   return ret;
     219}
     220
     221/************************************************************************
     222 *           InterlockedExchangeAdd            [KERNEL32.880]
     223 *
     224 * Atomically adds Increment to Addend and returns the previous value of
     225 * Addend
     226 *
     227 * RETURNS
     228 * Prior value of value pointed to by cwAddendTarget
     229 */
     230LONG WIN32API InterlockedExchangeAdd(
     231       PLONG Addend, /* Address of 32-bit value to exchange */
     232       LONG Increment /* Value to add */
     233) {
     234   LONG ret;
     235   /* StopAllThreadsAndProcesses() */
     236
     237   ret = *Addend;
     238   *Addend += Increment;
     239
     240   /* ResumeAllThreadsAndProcesses() */
     241   return ret;
     242}
     243
     244
    193245//******************************************************************************
    194246//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.