sphlflogger.h
Go to the documentation of this file.
/*
* Copyright (c) 2010-2014 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation, Steven Munroe - initial API and implementation
*/
#ifndef __SPH_LOCK_FREE_LOGGER_H
#define __SPH_LOCK_FREE_LOGGER_H
#include "sastype.h"
#include "sphtimer.h"
typedef void *SPHLFLogger_t;
#ifdef __cplusplus
#define __C__ "C"
#else
#define __C__
#endif
typedef unsigned long longPtr_t;
typedef struct {
unsigned int valid : 1;
unsigned int timestamped : 1;
unsigned int __reserved : 2;
unsigned int category : 12;
unsigned int subcat : 8;
unsigned int len : 8;
} sphLogEntryLayout_t;
typedef unsigned int sphLogEntryID_t;
typedef union {
sphLogEntryID_t idUnit;
sphLogEntryLayout_t detail;
} sphLogEntry_t;
typedef unsigned short sphpid16_t;
typedef struct {
sphLogEntry_t entryID;
sphpid16_t PID;
sphpid16_t TID;
sphtimer_t timeStamp;
} SPHLFLogHeader_t;
typedef struct {
SPHLFLogHeader_t *entry;
char *next;
unsigned short int total_size;
unsigned short int remaining;
} SPHLFLoggerHandle_t;
typedef struct {
SPHLFLogger_t logger;
longPtr_t current;
longPtr_t free;
longPtr_t start_log;
longPtr_t end_log;
unsigned int options;
} SPHLFLogIterator_t;
#define SPHLFLOGGER_CIRCULAR (1)
#define SPHLFLOGGER_CIRCULAR_WRAPED (1<<1)
#define SPHLFLOGGER_CIRCULAR_NOTFIRST (1<<2)
#define SPHLFLOGGER_CACHE_PREFETCH0 (1<<3)
#define SPHLFLOGGER_CACHE_PREFETCH1 (1<<4)
#define SPHLFLOGGER_CIRCULAR_RESETMASK (SPHLFLOGGER_CIRCULAR | \
SPHLFLOGGER_CACHE_PREFETCH0 | \
SPHLFLOGGER_CACHE_PREFETCH1)
extern __C__ SPHLFLogger_t
SPHLFLoggerInit (void *buf_seg , block_size_t buf_size);
extern __C__ SPHLFLogger_t
SPHLFLoggerInitWithStride (void* buf_seg, block_size_t buf_size,
unsigned short entry_stride,
unsigned int options);
extern __C__ SPHLFLogger_t
SPHLFLoggerCreate (block_size_t buf_size);
extern __C__ SPHLFLogger_t
SPHLFCircularLoggerCreate (block_size_t buf_size,
unsigned short stride);
extern __C__ void *
SPHLFLoggerAllocRaw (SPHLFLogger_t log,
block_size_t alloc_size);
extern __C__ SPHLFLoggerHandle_t *
SPHLFLoggerAllocTimeStamped (SPHLFLogger_t log,
int catcode, int subcode,
block_size_t alloc_size,
SPHLFLoggerHandle_t *handlespace);
extern __C__ SPHLFLoggerHandle_t *
SPHLFLoggerAllocStrideTimeStamped (SPHLFLogger_t log,
int catcode, int subcode,
SPHLFLoggerHandle_t *handlespace);
extern __C__ SPHLFLoggerHandle_t *
SPHLFLoggerAllocTimeStampedNoLock (SPHLFLogger_t log,
int catcode, int subcode,
block_size_t alloc_size,
SPHLFLoggerHandle_t *handlespace);
extern __C__ SPHLFLoggerHandle_t *
SPHLFLoggerAllocStrideTimeStampedNoLock (SPHLFLogger_t log,
int catcode, int subcode,
SPHLFLoggerHandle_t *handlespace);
extern __C__ int
SPHLFLoggerEntryComplete (SPHLFLoggerHandle_t *entryhandle);
extern __C__ int
SPHLFLoggerEntryIsComplete (SPHLFLoggerHandle_t *entryhandle);
extern __C__ int
SPHLFLoggerEntryIsTimestamped (SPHLFLoggerHandle_t *entryhandle);
extern __C__ SPHLFLoggerHandle_t *
SPHLFLoggerIteratorNext (SPHLFLogIterator_t *iterator,
SPHLFLoggerHandle_t *handlespace);
extern __C__ SPHLFLogIterator_t *
SPHLFLoggerCreateIterator(SPHLFLogger_t log,
SPHLFLogIterator_t *iteratorSpace);
extern __C__ int
SPHLFLoggerEmpty (SPHLFLogger_t log);
extern __C__ int
SPHLFLoggerWrapped (SPHLFLogger_t log);
extern __C__ block_size_t
SPHLFLoggerFreeSpace (SPHLFLogger_t log);
extern __C__ int
SPHLFLoggerFull (SPHLFLogger_t log);
extern __C__ int
SPHLFLoggerResetIfFullSync (SPHLFLogger_t log);
extern __C__ int
SPHLFLoggerResetAsync (SPHLFLogger_t log);
extern __C__ int
SPHLFLoggerPrefetch (SPHLFLogger_t log);
extern __C__ int
SPHLFLoggerSetCachePrefetch (SPHLFLogger_t log, int prefetch);
extern __C__ int
SPHLFLoggerDestroy (SPHLFLogger_t log);
#endif /* __SPH_LOCK_FREE_LOGGER_H */
SPHLFLoggerInitWithStride
__C__ SPHLFLogger_t SPHLFLoggerInitWithStride(void *buf_seg, block_size_t buf_size, unsigned short entry_stride, unsigned int options)
Initialize a shared storage block as a Lock Free Event Logger with a fixed entry stride.
SPHLFLoggerSetCachePrefetch
__C__ int SPHLFLoggerSetCachePrefetch(SPHLFLogger_t log, int prefetch)
Set the cache-line prefetch options for entry allocate.
sphLogEntryID_t
unsigned int sphLogEntryID_t
Aggregate type for handling sphLogEntryLayout_t.
Definition: sphlflogger.h:204
__C__
#define __C__
ignore this macro behined the curtain
Definition: sphlflogger.h:179
SPHLFLoggerDestroy
__C__ int SPHLFLoggerDestroy(SPHLFLogger_t log)
Destroys the logger and frees the SAS storage for reuse.
SPHLFLogger_t
void * SPHLFLogger_t
Handle to an instance of SPH Lock Free Logger.
Definition: sphlflogger.h:173
SPHLFLoggerFreeSpace
__C__ block_size_t SPHLFLoggerFreeSpace(SPHLFLogger_t log)
Returns the amount of free space (in bytes) remaining in the specified logger.
SPHLFLoggerResetIfFullSync
__C__ int SPHLFLoggerResetIfFullSync(SPHLFLogger_t log)
Resets the specific logger to empty state synchronously if it is currently full.
SPHLFLoggerResetAsync
__C__ int SPHLFLoggerResetAsync(SPHLFLogger_t log)
Resets the specific logger to empty state asynchronously (without locking or atomic updates).
SPHLFLoggerPrefetch
__C__ int SPHLFLoggerPrefetch(SPHLFLogger_t log)
Prefetch pages from the specific logger.
sphpid16_t
unsigned short sphpid16_t
Common type for PID/TID values stored in Logger entries.
Definition: sphlflogger.h:217
SPHLFLoggerCreate
__C__ SPHLFLogger_t SPHLFLoggerCreate(block_size_t buf_size)
Allocate and initialize a shared storage block as a Lock Free Event Logger.
SPHLFLoggerAllocStrideTimeStamped
__C__ SPHLFLoggerHandle_t * SPHLFLoggerAllocStrideTimeStamped(SPHLFLogger_t log, int catcode, int subcode, SPHLFLoggerHandle_t *handlespace)
Allocate and initialize the header, of a timestamped logger entry, from the specified logger.
SPHLFLoggerIteratorNext
__C__ SPHLFLoggerHandle_t * SPHLFLoggerIteratorNext(SPHLFLogIterator_t *iterator, SPHLFLoggerHandle_t *handlespace)
For the provided Logger Iterator creates a entry handle for the next sequential Logger entry....
SPHLFLoggerCreateIterator
__C__ SPHLFLogIterator_t * SPHLFLoggerCreateIterator(SPHLFLogger_t log, SPHLFLogIterator_t *iteratorSpace)
Creates a logger Iterator for reading sequential entries from a specific logger.
longPtr_t
unsigned long longPtr_t
unsigned int type, consistent with the size of a pointer and used for pointer calculations
Definition: sphlflogger.h:183
SPHLFLoggerEntryIsTimestamped
__C__ int SPHLFLoggerEntryIsTimestamped(SPHLFLoggerHandle_t *entryhandle)
Return the status of the entry specified by the entry handle.
SPHLFLoggerEntryIsComplete
__C__ int SPHLFLoggerEntryIsComplete(SPHLFLoggerHandle_t *entryhandle)
Return the status of the entry specified by the entry handle.
SPHLFLoggerInit
__C__ SPHLFLogger_t SPHLFLoggerInit(void *buf_seg, block_size_t buf_size)
Initialize a shared storage block as a Lock Free Event Logger.
SPHLFLoggerAllocStrideTimeStampedNoLock
__C__ SPHLFLoggerHandle_t * SPHLFLoggerAllocStrideTimeStampedNoLock(SPHLFLogger_t log, int catcode, int subcode, SPHLFLoggerHandle_t *handlespace)
Allocate and initialize the header, of a timestamped logger entry, from the specified logger,...
SPHLFLoggerWrapped
__C__ int SPHLFLoggerWrapped(SPHLFLogger_t log)
Return the status of the specified logger.
SPHLFLoggerAllocTimeStamped
__C__ SPHLFLoggerHandle_t * SPHLFLoggerAllocTimeStamped(SPHLFLogger_t log, int catcode, int subcode, block_size_t alloc_size, SPHLFLoggerHandle_t *handlespace)
Allocate and initialize the header, of a timestamped logger entry, from the specified logger.
SPHLFLoggerEmpty
__C__ int SPHLFLoggerEmpty(SPHLFLogger_t log)
Return the status of the specified logger.
SPHLFLoggerEntryComplete
__C__ int SPHLFLoggerEntryComplete(SPHLFLoggerHandle_t *entryhandle)
Marks the entry specified by the entry handle as complete.
SPHLFLoggerAllocTimeStampedNoLock
__C__ SPHLFLoggerHandle_t * SPHLFLoggerAllocTimeStampedNoLock(SPHLFLogger_t log, int catcode, int subcode, block_size_t alloc_size, SPHLFLoggerHandle_t *handlespace)
Allocate and initialize the header of a timestamped logger entry from the specified logger,...
SPHLFLoggerAllocRaw
__C__ void * SPHLFLoggerAllocRaw(SPHLFLogger_t log, block_size_t alloc_size)
Return the address of a (raw) Logger entry allocated from the specified logger.
SPHLFLoggerFull
__C__ int SPHLFLoggerFull(SPHLFLogger_t log)
Return the status of the specified logger.
SPHLFCircularLoggerCreate
__C__ SPHLFLogger_t SPHLFCircularLoggerCreate(block_size_t buf_size, unsigned short stride)
Allocate and initialize a shared storage block as a Lock Free Event Logger. Mark the logger as circul...
sphtimer.h
Functions to access the Time Base register (PPC) or clock_gettime(CLOCK_MONOTONIC) measure time at hi...
sphtimer_t
unsigned long long int sphtimer_t
Value from TB/TSC register (64-bits on all platforms).
Definition: sphtimer.h:66
SPHLFLogHeader_t
Instance of a Lock Free Logger Entry Header.
Definition: sphlflogger.h:223
SPHLFLogHeader_t::timeStamp
sphtimer_t timeStamp
Definition: sphlflogger.h:231
SPHLFLogHeader_t::TID
sphpid16_t TID
Definition: sphlflogger.h:229
SPHLFLogHeader_t::entryID
sphLogEntry_t entryID
Definition: sphlflogger.h:225
SPHLFLogHeader_t::PID
sphpid16_t PID
Definition: sphlflogger.h:227
SPHLFLogIterator_t
Instance of a Lock Free Logger Iterator.
Definition: sphlflogger.h:264
SPHLFLogIterator_t::current
longPtr_t current
Definition: sphlflogger.h:268
SPHLFLogIterator_t::logger
SPHLFLogger_t logger
Definition: sphlflogger.h:266
SPHLFLogIterator_t::options
unsigned int options
Definition: sphlflogger.h:276
SPHLFLogIterator_t::start_log
longPtr_t start_log
Definition: sphlflogger.h:272
SPHLFLogIterator_t::end_log
longPtr_t end_log
Definition: sphlflogger.h:274
SPHLFLogIterator_t::free
longPtr_t free
Definition: sphlflogger.h:270
SPHLFLoggerHandle_t
Instance of a Lock Free Logger Entry Handle.
Definition: sphlflogger.h:244
SPHLFLoggerHandle_t::total_size
unsigned short int total_size
Definition: sphlflogger.h:250
SPHLFLoggerHandle_t::remaining
unsigned short int remaining
Definition: sphlflogger.h:252
SPHLFLoggerHandle_t::next
char * next
Definition: sphlflogger.h:248
SPHLFLoggerHandle_t::entry
SPHLFLogHeader_t * entry
Definition: sphlflogger.h:246
sphLogEntryLayout_t
sphLogEntry_t. Fields defining the entry details word.
Definition: sphlflogger.h:188
sphLogEntryLayout_t::subcat
unsigned int subcat
Definition: sphlflogger.h:198
sphLogEntryLayout_t::timestamped
unsigned int timestamped
Definition: sphlflogger.h:192
sphLogEntryLayout_t::category
unsigned int category
Definition: sphlflogger.h:196
sphLogEntryLayout_t::len
unsigned int len
Definition: sphlflogger.h:200
sphLogEntryLayout_t::valid
unsigned int valid
Definition: sphlflogger.h:190
sphLogEntryLayout_t::__reserved
unsigned int __reserved
Definition: sphlflogger.h:194
sphLogEntry_t
Union of Entry details with 32-bit word for atomic update.
Definition: sphlflogger.h:208
sphLogEntry_t::idUnit
sphLogEntryID_t idUnit
Definition: sphlflogger.h:210
sphLogEntry_t::detail
sphLogEntryLayout_t detail
Definition: sphlflogger.h:212