suricata
|
Go to the source code of this file.
Macros | |
#define | SC_ATOMIC_DECLARE(type, name) |
wrapper to declare an atomic variable including a (spin) lock to protect it. More... | |
#define | SC_ATOMIC_EXTERN(type, name) |
wrapper to reference an atomic variable already declared on another file (including the spin lock) More... | |
#define | SC_ATOMIC_DECL_AND_INIT(type, name) |
wrapper to declare an atomic variable including a (spin) lock to protect it and initialize them. More... | |
#define | SC_ATOMIC_INIT(name) |
Initialize the previously declared atomic variable and it's lock. More... | |
#define | SC_ATOMIC_RESET(name) |
Initialize the previously declared atomic variable and it's lock. More... | |
#define | SC_ATOMIC_DESTROY(name) |
Destroy the lock used to protect this variable. More... | |
#define | SC_ATOMIC_ADD(name, val) |
add a value to our atomic variable More... | |
#define | SC_ATOMIC_SUB(name, val) |
sub a value from our atomic variable More... | |
#define | SC_ATOMIC_AND(name, val) |
Bitwise AND a value from our atomic variable. More... | |
#define | SC_ATOMIC_OR(name, val) |
Bitwise OR a value from our atomic variable. More... | |
#define | SC_ATOMIC_NAND(name, val) |
Bitwise NAND a value from our atomic variable. More... | |
#define | SC_ATOMIC_XOR(name, val) |
Bitwise XOR a value from our atomic variable. More... | |
#define | SC_ATOMIC_GET(name) |
Get the value from the atomic variable. More... | |
#define | SC_ATOMIC_SET(name, val) |
Set the value for the atomic variable. More... | |
#define | SC_ATOMIC_CAS(name, cmpval, newval) |
atomic Compare and Switch More... | |
Functions | |
void | SCAtomicRegisterTests (void) |
API for atomic operations. Uses atomic instructions (GCC only at this time) where available, falls back to (spin)locked* operations otherwise.
To prevent developers from accidentally working with the atomic variables directly instead of through the proper macro's, a marco trick is performed that exposes different variable names than the developer uses. So if the dev uses "somevar", internally "somevar_sc_atomic__" is used.
Where available, we use sync_fetch_and_add and __sync_bool_compare_and_swap. If those are unavailable, the API transparently created a matching (spin)lock for each atomic variable. The lock will be named "somevar_sc_lock</strong>"
(*) where spinlocks are unavailable, the threading api falls back to mutex
Definition in file util-atomic.h.
#define SC_ATOMIC_ADD | ( | name, | |
val | |||
) |
add a value to our atomic variable
name | the atomic variable |
val | the value to add to the variable |
Definition at line 107 of file util-atomic.h.
Referenced by AFPPeersListCheck(), AppLayerExpectationCreate(), DefragInitConfig(), DefragLookupTrackerFromHash(), DefragTrackerMoveToSpare(), FlowAlloc(), FlowDisableFlowManagerThread(), FlowGetExistingFlowFromHash(), FlowInitConfig(), FTPMemcapGlobalCounter(), HostAlloc(), HostInitConfig(), HostLookupHostFromHash(), HTPMemcapGlobalCounter(), HTPParseMemcap(), IPPairAlloc(), IPPairCleanup(), IPPairInitConfig(), IPPairLookupIPPairFromHash(), LiveDevAddBypassFail(), LiveDevAddBypassStats(), LiveDevAddBypassSuccess(), NapatechPacketLoopZC(), NapatechStreamThreadExitStats(), NoNFLOGSupportExit(), OutputRegisterFiledataLogger(), PacketPoolWait(), PacketPoolWaitForN(), PacketProfileLoggertIdToString(), PcapIncreaseInvalidChecksum(), ReceiveAFPLoop(), RunModeIdsAFPRegister(), RunModeIdsNetmapRegister(), RunModeIdsPcapRegister(), RunModeIdsPfringRegister(), SCProfilePacketStart(), SCProfileRuleStart(), SRepReloadComplete(), StreamTcpIncrMemuse(), StreamTcpPacket(), StreamTcpReassembleIncrMemuse(), TagFlowAdd(), TagHashAddTag(), THashCleanup(), THashDataQueueNew(), THashLookupFromHash(), TmModuleDecodeAFPRegister(), TmModuleDecodeNetmapRegister(), TmModuleDecodePcapRegister(), and TmModuleDecodePfringRegister().
#define SC_ATOMIC_AND | ( | name, | |
val | |||
) |
Bitwise AND a value from our atomic variable.
name | the atomic variable |
val | the value to sub from the variable |
Definition at line 141 of file util-atomic.h.
Referenced by TmThreadsUnsetFlag().
#define SC_ATOMIC_CAS | ( | name, | |
cmpval, | |||
newval | |||
) |
atomic Compare and Switch
Definition at line 222 of file util-atomic.h.
Referenced by main(), OutputRegisterFiledataLogger(), and PacketProfileLoggertIdToString().
#define SC_ATOMIC_DECL_AND_INIT | ( | type, | |
name | |||
) |
wrapper to declare an atomic variable including a (spin) lock to protect it and initialize them.
Definition at line 72 of file util-atomic.h.
Referenced by PacketProfileLoggertIdToString().
#define SC_ATOMIC_DECLARE | ( | type, | |
name | |||
) |
wrapper to declare an atomic variable including a (spin) lock to protect it.
Definition at line 56 of file util-atomic.h.
Referenced by TmModuleDecodeNetmapRegister().
#define SC_ATOMIC_DESTROY | ( | name | ) |
Destroy the lock used to protect this variable.
Definition at line 97 of file util-atomic.h.
Referenced by DefragHashShutdown(), DefragTrackerClearMemory(), FlowShutdown(), GlobalsInitPreConfig(), HostFree(), HostShutdown(), HTPDestroyMemcap(), IPPairFree(), IPPairShutdown(), LiveDeviceListClean(), PacketPoolDestroy(), StreamTcpFreeConfig(), TagDestroyCtx(), THashDataQueueNew(), and THashShutdown().
#define SC_ATOMIC_EXTERN | ( | type, | |
name | |||
) |
wrapper to reference an atomic variable already declared on another file (including the spin lock)
Definition at line 64 of file util-atomic.h.
#define SC_ATOMIC_GET | ( | name | ) |
Get the value from the atomic variable.
var | value |
Definition at line 192 of file util-atomic.h.
Referenced by AFPPeersListCheck(), AppLayerExpectationHandle(), CleanupPcapFileFileVars(), DefragHashShutdown(), DefragInitConfig(), DefragLookupTrackerFromHash(), DefragTrackerGetMemcap(), DefragTrackerGetMemuse(), DefragTrackerSetMemcap(), Detect(), DetectEngineInspectPktBufferGeneric(), ExpectationGetCounter(), FlowDisableFlowManagerThread(), FlowGetExistingFlowFromHash(), FlowGetMemcap(), FlowGetMemuse(), FlowHandlePacketUpdate(), FlowInitConfig(), FlowSetMemcap(), FlowSetupPacket(), FlowShutdown(), FlowUpdateState(), FlowWorkerGetDetectCtxPtr(), FTPMemcapGlobalCounter(), FTPMemuseGlobalCounter(), HostCleanup(), HostGetActiveCount(), HostGetMemcap(), HostGetMemuse(), HostInitConfig(), HostLookupHostFromHash(), HostPrintStats(), HostSetMemcap(), HostShutdown(), HTPGetMemcap(), HTPMemcapGlobalCounter(), HTPMemuseGlobalCounter(), HTPParseMemcap(), HTPSetMemcap(), IPPairCleanup(), IPPairGetActiveCount(), IPPairGetMemcap(), IPPairGetMemuse(), IPPairInitConfig(), IPPairLookupIPPairFromHash(), IPPairPrintStats(), IPPairSetMemcap(), IPPairShutdown(), JsonAddFlow(), LiveDevAddBypassSuccess(), LiveDeviceListClean(), NapatechPacketLoopZC(), NapatechStreamThreadExitStats(), NapatechStreamThreadInit(), OutputRegisterFiledataLogger(), PacketBypassCallback(), PacketPoolReturnPacket(), PcapFileGlobalInit(), RegisterSSLParsers(), SRepResetVersion(), SSLEnableJA3(), SSLJA3IsEnabled(), SSLVersionToString(), StreamTcpCheckMemcap(), StreamTcpDecrMemuse(), StreamTcpGetMemcap(), StreamTcpInitConfig(), StreamTcpMemuseCounter(), StreamTcpReassembleCheckMemcap(), StreamTcpReassembleDecrMemuse(), StreamTcpReassembleGetMemcap(), StreamTcpReassembleMemuseGlobalCounter(), StreamTcpReassembleSetMemcap(), StreamTcpSetMemcap(), TagDestroyCtx(), TagHandlePacket(), THashCleanup(), THashLookupFromHash(), THashShutdown(), TmModuleDecodeAFPRegister(), TmModuleDecodePcapRegister(), TmModuleDecodePfringRegister(), TmModuleFlowRecyclerRegister(), TmThreadDisableReceiveThreads(), TmThreadDumpThreads(), TmThreadsCheckFlag(), TmThreadsListThreads(), TmThreadsSlotVarRun(), TmThreadWaitOnThreadInit(), VarNameStoreActivateStaging(), VarNameStoreFree(), VarNameStoreLookupById(), VarNameStoreLookupByName(), and VarNameStoreSetupStaging().
#define SC_ATOMIC_INIT | ( | name | ) |
Initialize the previously declared atomic variable and it's lock.
Definition at line 81 of file util-atomic.h.
Referenced by AFPPeersListCheck(), AFPPeersListInit(), AppLayerExpectationSetup(), DefragInitConfig(), DefragTrackerMoveToSpare(), DetectEngineResetMaxSigId(), FlowInitConfig(), HostAlloc(), HostInitConfig(), HTPParseMemcap(), IPPairAlloc(), IPPairInitConfig(), LiveDevUseBypass(), LiveRegisterDevice(), LogFilestoreRegister(), LogTlsStoreRegister(), main(), OutputFiledataLoggerRegister(), OutputFilestoreRegister(), PacketPoolInit(), PacketPoolInitEmpty(), PcapFileGlobalInit(), PcapLogRegister(), RegisterHTPParsers(), RegisterSSLParsers(), RunModeIdsAFPRegister(), RunModeIdsNetmapRegister(), RunModeIdsPcapRegister(), RunModeIdsPfringRegister(), SCProfilingInit(), SRepInit(), StreamTcpInitConfig(), StreamTcpInitMemuse(), StreamTcpReassembleInitMemuse(), TagInitCtx(), THashDataQueueNew(), THashInit(), TmModuleDecodeNetmapRegister(), TmModuleDetectLoaderRegister(), TmModuleFlowManagerRegister(), TmModuleFlowRecyclerRegister(), TmModuleNapatechStreamRegister(), TmSlotSetFuncAppend(), TmThreadCreate(), Unified2AlertInitCtx(), and VarNameStoreSetupStaging().
#define SC_ATOMIC_NAND | ( | name, | |
val | |||
) |
Bitwise NAND a value from our atomic variable.
name | the atomic variable |
val | the value to sub from the variable |
Definition at line 167 of file util-atomic.h.
#define SC_ATOMIC_OR | ( | name, | |
val | |||
) |
Bitwise OR a value from our atomic variable.
name | the atomic variable |
val | the value to sub from the variable |
Definition at line 154 of file util-atomic.h.
Referenced by AppLayerHtpEnableRequestBodyCallback(), AppLayerHtpEnableResponseBodyCallback(), AppLayerHtpNeedFileInspection(), FlowSetupPacket(), and TmThreadsSetFlag().
#define SC_ATOMIC_RESET | ( | name | ) |
Initialize the previously declared atomic variable and it's lock.
Definition at line 90 of file util-atomic.h.
Referenced by PacketPoolReturnPacket(), PacketPoolWaitForN(), RunModeIdsAFPRegister(), RunModeIdsNetmapRegister(), RunModeIdsPfringRegister(), and UTHBuildPacketOfFlows().
#define SC_ATOMIC_SET | ( | name, | |
val | |||
) |
Set the value for the atomic variable.
var | value |
Definition at line 207 of file util-atomic.h.
Referenced by AFPPeersListCheck(), AFPPeersListInit(), DefragInitConfig(), DefragTrackerSetMemcap(), Detect(), FlowDisableFlowManagerThread(), FlowDisableFlowRecyclerThread(), FlowGetExistingFlowFromHash(), FlowInitConfig(), FlowSetMemcap(), FlowTimeoutsEmergency(), FlowTimeoutsInit(), FlowUpdateState(), FlowWorkerReplaceDetectCtx(), HostInitConfig(), HostSetMemcap(), HTPParseMemcap(), HTPSetMemcap(), IPPairInitConfig(), IPPairSetMemcap(), LiveDevSetBypassStats(), LogFilestoreRegister(), OutputFilestoreRegister(), ReceiveErfDagThreadExitStats(), RegisterSSLParsers(), SRepReloadComplete(), SSLEnableJA3(), StreamTcpInitConfig(), StreamTcpReassembleSetMemcap(), StreamTcpSetMemcap(), TmModuleDecodeAFPRegister(), TmModuleDecodePcapRegister(), TmModuleFlowRecyclerRegister(), TmSlotSetFuncAppend(), TmThreadsSlotVarRun(), VarNameStoreActivateStaging(), and VarNameStoreFree().
#define SC_ATOMIC_SUB | ( | name, | |
val | |||
) |
sub a value from our atomic variable
name | the atomic variable |
val | the value to sub from the variable |
Definition at line 124 of file util-atomic.h.
Referenced by AppLayerExpectationGetDataId(), DefragHashShutdown(), DefragTrackerMoveToSpare(), DetectTagDataListFree(), FlowAlloc(), FlowFree(), FlowShutdown(), HostFree(), HostMoveToSpare(), HostShutdown(), HTPParseMemcap(), IPPairFree(), IPPairMoveToSpare(), IPPairShutdown(), LiveDevSubBypassStats(), RunModeIdsAFPRegister(), RunModeIdsNetmapRegister(), RunModeIdsPcapRegister(), RunModeIdsPfringRegister(), StreamTcpDecrMemuse(), StreamTcpReassembleDecrMemuse(), TagHashAddTag(), TagTimeoutCheck(), THashDataQueueNew(), THashShutdown(), and TmModuleDecodeAFPRegister().
#define SC_ATOMIC_XOR | ( | name, | |
val | |||
) |
Bitwise XOR a value from our atomic variable.
name | the atomic variable |
val | the value to sub from the variable |
Definition at line 180 of file util-atomic.h.
void SCAtomicRegisterTests | ( | void | ) |
Definition at line 66 of file util-atomic.c.
References UtRegisterTest().