Ignore:
Timestamp:
Sep 13, 2020, 1:15:59 PM (5 years ago)
Author:
bird
Message:

kash: shtread.h: a couple of atomic inc/dec operations for reference counters.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/shthread.h

    r3446 r3448  
    5858void shmtx_leave(shmtx *pmtx, shmtxtmp *ptmp);
    5959
     60
     61K_INLINE unsigned sh_atomic_inc(KU32 volatile *valuep)
     62{
     63#ifdef _MSC_VER
     64    return _InterlockedIncrement((long *)valuep);
     65#else
     66    return __sync_fetch_and_add(valuep, 1);
     67#endif
     68}
     69
     70K_INLINE unsigned sh_atomic_dec(unsigned volatile *valuep)
     71{
     72#ifdef _MSC_VER
     73    return _InterlockedDecrement((long *)valuep);
     74#else
     75    return __sync_fetch_and_sub(valuep, 1);
     76#endif
     77}
     78
    6079#endif
    6180
Note: See TracChangeset for help on using the changeset viewer.