//Pascal &or the FreePascal use of nintendo 2ds, 3ds regime // // Copyright (c) 2013, 2015, 2017 Kenneth Dwayne Lee Bsc. // all rights reserved // Type {* * @file synchronization.h * @brief Provides synchronization locks. } {/ A light lock. } LightLock = _LOCK_T; PLightLock = ^LightLock; {/ A recursive lock. } RecursiveLock = _LOCK_RECURSIVE_T; PRecursiveLock = ^RecursiveLock; {/ A light event. } {/< State of the event: -2=cleared sticky, -1=cleared oneshot, 0=signaled oneshot, 1=signaled sticky } {/< Lock used for sticky timer operation } LightEvent = record state : s32; lock : LightLock; end; PLightEvent = ^LightEvent; {/ Performs an atomic pre-increment operation. } { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicIncrement(ptr : longint) : longint; {/ Performs an atomic pre-decrement operation. } { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicDecrement(ptr : longint) : longint; {/ Performs an atomic post-increment operation. } { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicPostIncrement(ptr : longint) : longint; {/ Performs an atomic post-decrement operation. } { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicPostDecrement(ptr : longint) : longint; {/ Performs an atomic swap operation. } { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicSwap(ptr,value : longint) : longint; {* * @brief Retrieves the synchronization subsystem's address arbiter handle. * @return The synchronization subsystem's address arbiter handle. } function __sync_get_arbiter:Handle;cdecl;external; {* * @brief Initializes a light lock. * @param lock Pointer to the lock. } procedure LightLock_Init(lock:PLightLock);cdecl;external; {* * @brief Locks a light lock. * @param lock Pointer to the lock. } procedure LightLock_Lock(lock:PLightLock);cdecl;external; {* * @brief Attempts to lock a light lock. * @param lock Pointer to the lock. * @return Zero on success, non-zero on failure. } function LightLock_TryLock(lock:PLightLock):cint;cdecl;external; {* * @brief Unlocks a light lock. * @param lock Pointer to the lock. } procedure LightLock_Unlock(lock:PLightLock);cdecl;external; {* * @brief Initializes a recursive lock. * @param lock Pointer to the lock. } procedure RecursiveLock_Init(lock:PRecursiveLock);cdecl;external; {* * @brief Locks a recursive lock. * @param lock Pointer to the lock. } procedure RecursiveLock_Lock(lock:PRecursiveLock);cdecl;external; {* * @brief Attempts to lock a recursive lock. * @param lock Pointer to the lock. * @return Zero on success, non-zero on failure. } function RecursiveLock_TryLock(lock:PRecursiveLock):cint;cdecl;external; {* * @brief Unlocks a recursive lock. * @param lock Pointer to the lock. } procedure RecursiveLock_Unlock(lock:PRecursiveLock);cdecl;external; {* * @brief Initializes a light event. * @param event Pointer to the event. * @param reset_type Type of reset the event uses (RESET_ONESHOT/RESET_STICKY). } procedure LightEvent_Init(event:PLightEvent; reset_type:ResetType);cdecl;external; {* * @brief Clears a light event. * @param event Pointer to the event. } procedure LightEvent_Clear(event:PLightEvent);cdecl;external; {* * @brief Wakes up threads waiting on a sticky light event without signaling it. If the event had been signaled before, it is cleared instead. * @param event Pointer to the event. } procedure LightEvent_Pulse(event:PLightEvent);cdecl;external; {* * @brief Signals a light event, waking up threads waiting on it. * @param event Pointer to the event. } procedure LightEvent_Signal(event:PLightEvent);cdecl;external; {* * @brief Attempts to wait on a light event. * @param event Pointer to the event. * @return Non-zero if the event was signaled, zero otherwise. } function LightEvent_TryWait(event:PLightEvent):cint;cdecl;external; {* * @brief Waits on a light event. * @param event Pointer to the event. } procedure LightEvent_Wait(event:PLightEvent);cdecl;external; {$endif 3dsintf} {$ifdef 3dsimpl} { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicIncrement(ptr : longint) : longint; begin AtomicIncrement:=__atomic_add_fetch(^u32(ptr),1,__ATOMIC_SEQ_CST); end; { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicDecrement(ptr : longint) : longint; begin AtomicDecrement:=__atomic_sub_fetch(^u32(ptr),1,__ATOMIC_SEQ_CST); end; { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicPostIncrement(ptr : longint) : longint; begin AtomicPostIncrement:=__atomic_fetch_add(^u32(ptr),1,__ATOMIC_SEQ_CST); end; { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicPostDecrement(ptr : longint) : longint; begin AtomicPostDecrement:=__atomic_fetch_sub(^u32(ptr),1,__ATOMIC_SEQ_CST); end; { was #define dname(params) para_def_expr } { argument types are unknown } { return type might be wrong } function AtomicSwap(ptr,value : longint) : longint; begin AtomicSwap:=__atomic_exchange_n(^u32(ptr),value,__ATOMIC_SEQ_CST); end; {$endif 3dsimpl}