Shared Persistent Heap Data Environment Manual  1.1.0
sphlflogger.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2014 IBM Corporation.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation, Steven Munroe - initial API and implementation
10  */
11 
12 #ifndef __SPH_LOCK_FREE_LOGGER_H
13 #define __SPH_LOCK_FREE_LOGGER_H
14 
165 #include "sastype.h"
166 #include "sphtimer.h"
167 
168 
173 typedef void *SPHLFLogger_t;
174 
176 #ifdef __cplusplus
177 #define __C__ "C"
178 #else
179 #define __C__
180 #endif
181 
183 typedef unsigned long longPtr_t;
184 
188 typedef struct {
190  unsigned int valid : 1;
192  unsigned int timestamped : 1;
194  unsigned int __reserved : 2;
196  unsigned int category : 12;
198  unsigned int subcat : 8;
200  unsigned int len : 8;
202 
204 typedef unsigned int sphLogEntryID_t;
205 
208 typedef union {
213  } sphLogEntry_t;
214 
215 
217 typedef unsigned short sphpid16_t;
218 
223 typedef struct {
233 
234 
244 typedef struct {
248  char *next;
250  unsigned short int total_size;
252  unsigned short int remaining;
254 
264 typedef struct {
276  unsigned int options;
278 
280 #define SPHLFLOGGER_CIRCULAR (1)
281 
282 #define SPHLFLOGGER_CIRCULAR_WRAPED (1<<1)
283 
284 #define SPHLFLOGGER_CIRCULAR_NOTFIRST (1<<2)
285 
286 #define SPHLFLOGGER_CACHE_PREFETCH0 (1<<3)
287 
288 #define SPHLFLOGGER_CACHE_PREFETCH1 (1<<4)
289 
290 #define SPHLFLOGGER_CIRCULAR_RESETMASK (SPHLFLOGGER_CIRCULAR | \
291  SPHLFLOGGER_CACHE_PREFETCH0 | \
292  SPHLFLOGGER_CACHE_PREFETCH1)
293 
306 extern __C__ SPHLFLogger_t
307 SPHLFLoggerInit (void *buf_seg , block_size_t buf_size);
308 
325 extern __C__ SPHLFLogger_t
326 SPHLFLoggerInitWithStride (void* buf_seg, block_size_t buf_size,
327  unsigned short entry_stride,
328  unsigned int options);
329 
340 extern __C__ SPHLFLogger_t
341 SPHLFLoggerCreate (block_size_t buf_size);
342 
355 extern __C__ SPHLFLogger_t
356 SPHLFCircularLoggerCreate (block_size_t buf_size,
357  unsigned short stride);
358 
372 extern __C__ void *
374  block_size_t alloc_size);
375 
399 extern __C__ SPHLFLoggerHandle_t *
401  int catcode, int subcode,
402  block_size_t alloc_size,
403  SPHLFLoggerHandle_t *handlespace);
404 
425 extern __C__ SPHLFLoggerHandle_t *
427  int catcode, int subcode,
428  SPHLFLoggerHandle_t *handlespace);
429 
461 extern __C__ SPHLFLoggerHandle_t *
463  int catcode, int subcode,
464  block_size_t alloc_size,
465  SPHLFLoggerHandle_t *handlespace);
466 
495 extern __C__ SPHLFLoggerHandle_t *
497  int catcode, int subcode,
498  SPHLFLoggerHandle_t *handlespace);
499 
509 extern __C__ int
511 
518 extern __C__ int
520 
526 extern __C__ int
528 
541 extern __C__ SPHLFLoggerHandle_t *
543  SPHLFLoggerHandle_t *handlespace);
544 
554 extern __C__ SPHLFLogIterator_t *
556  SPHLFLogIterator_t *iteratorSpace);
557 
564 extern __C__ int
566 
573 extern __C__ int
575 
581 extern __C__ block_size_t
583 
590 extern __C__ int
592 
603 extern __C__ int
605 
613 extern __C__ int
615 
621 extern __C__ int
623 
635 extern __C__ int
636 SPHLFLoggerSetCachePrefetch (SPHLFLogger_t log, int prefetch);
637 
643 extern __C__ int
645 
646 #endif /* __SPH_LOCK_FREE_LOGGER_H */
__C__ int SPHLFLoggerPrefetch(SPHLFLogger_t log)
Prefetch pages from the specific logger.
__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...
__C__ int SPHLFLoggerDestroy(SPHLFLogger_t log)
Destroys the logger and frees the SAS storage for reuse.
__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...
longPtr_t start_log
Definition: sphlflogger.h:272
Instance of a Lock Free Logger Iterator.
Definition: sphlflogger.h:264
__C__ int SPHLFLoggerResetIfFullSync(SPHLFLogger_t log)
Resets the specific logger to empty state synchronously if it is currently full.
char * next
Definition: sphlflogger.h:248
unsigned short int remaining
Definition: sphlflogger.h:252
__C__ SPHLFLogger_t SPHLFLoggerCreate(block_size_t buf_size)
Allocate and initialize a shared storage block as a Lock Free Event Logger.
__C__ int SPHLFLoggerEntryComplete(SPHLFLoggerHandle_t *entryhandle)
Marks the entry specified by the entry handle as complete.
Functions to access the Time Base register (PPC) or clock_gettime(CLOCK_MONOTONIC) measure time at hi...
longPtr_t current
Definition: sphlflogger.h:268
unsigned long long int sphtimer_t
Value from TB/TSC register (64-bits on all platforms).
Definition: sphtimer.h:66
sphLogEntryLayout_t detail
Definition: sphlflogger.h:212
__C__ int SPHLFLoggerEntryIsTimestamped(SPHLFLoggerHandle_t *entryhandle)
Return the status of the entry specified by the entry handle.
__C__ block_size_t SPHLFLoggerFreeSpace(SPHLFLogger_t log)
Returns the amount of free space (in bytes) remaining in the specified logger.
sphLogEntry_t. Fields defining the entry details word.
Definition: sphlflogger.h:188
Union of Entry details with 32-bit word for atomic update.
Definition: sphlflogger.h:208
Instance of a Lock Free Logger Entry Handle.
Definition: sphlflogger.h:244
__C__ int SPHLFLoggerWrapped(SPHLFLogger_t log)
Return the status of the specified logger.
unsigned short sphpid16_t
Common type for PID/TID values stored in Logger entries.
Definition: sphlflogger.h:217
__C__ int SPHLFLoggerSetCachePrefetch(SPHLFLogger_t log, int prefetch)
Set the cache-line prefetch options for entry allocate.
__C__ void * SPHLFLoggerAllocRaw(SPHLFLogger_t log, block_size_t alloc_size)
Return the address of a (raw) Logger entry allocated from the specified logger.
unsigned int options
Definition: sphlflogger.h:276
SPHLFLogger_t logger
Definition: sphlflogger.h:266
longPtr_t free
Definition: sphlflogger.h:270
__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...
__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...
void * SPHLFLogger_t
Handle to an instance of SPH Lock Free Logger.
Definition: sphlflogger.h:173
unsigned long longPtr_t
unsigned int type, consistent with the size of a pointer and used for pointer calculations ...
Definition: sphlflogger.h:183
unsigned int sphLogEntryID_t
Aggregate type for handling sphLogEntryLayout_t.
Definition: sphlflogger.h:204
__C__ int SPHLFLoggerResetAsync(SPHLFLogger_t log)
Resets the specific logger to empty state asynchronously (without locking or atomic updates)...
__C__ int SPHLFLoggerFull(SPHLFLogger_t log)
Return the status of the specified logger.
sphLogEntryID_t idUnit
Definition: sphlflogger.h:210
__C__ SPHLFLogIterator_t * SPHLFLoggerCreateIterator(SPHLFLogger_t log, SPHLFLogIterator_t *iteratorSpace)
Creates a logger Iterator for reading sequential entries from a specific logger.
sphtimer_t timeStamp
Definition: sphlflogger.h:231
__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...
__C__ SPHLFLogger_t SPHLFLoggerInit(void *buf_seg, block_size_t buf_size)
Initialize a shared storage block as a Lock Free Event Logger.
sphLogEntry_t entryID
Definition: sphlflogger.h:225
sphpid16_t PID
Definition: sphlflogger.h:227
__C__ int SPHLFLoggerEmpty(SPHLFLogger_t log)
Return the status of the specified logger.
SPHLFLogHeader_t * entry
Definition: sphlflogger.h:246
__C__ int SPHLFLoggerEntryIsComplete(SPHLFLoggerHandle_t *entryhandle)
Return the status of the entry specified by the entry handle.
#define __C__
ignore this macro behined the curtain
Definition: sphlflogger.h:179
longPtr_t end_log
Definition: sphlflogger.h:274
sphpid16_t TID
Definition: sphlflogger.h:229
__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.
unsigned short int total_size
Definition: sphlflogger.h:250
Instance of a Lock Free Logger Entry Header.
Definition: sphlflogger.h:223
__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...