12 #ifndef __SPH_LOCK_FREE_LOGENTRY_H
13 #define __SPH_LOCK_FREE_LOGENTRY_H
186 result = entryPtr->
PID;
205 result = entryPtr->
TID;
239 printf (
"SPHLFLogEntryCategory(%p) entry=%p id=%x\n",
260 printf (
"SPHLFLogEntrySubcat(%p) entry=%p id=%x\n",
287 char *ptr = handle->
next;
294 #define SPHLOGENTRYGETSTRUCTPTR(__handle, __struct) SPHLFlogEntryGetStructPtr(__handle, sizeof(__struct), __alignof__(__struct))
317 unsigned long __size,
unsigned long __align)
319 char *ptr = (
char*)handle->
next;
321 unsigned long adjust = __align - 1;
322 unsigned long mask = ~adjust;
325 ((((
unsigned long)ptr)
329 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
331 len -= ((
unsigned long)ptr
332 - (
unsigned long)handle->
next);
337 handle->
next = ptr + __size;
347 #define SPHLOGENTRYALLOCSTRUCT(__handle, __struct) SPHLFlogEntryAllocStruct(__handle, sizeof(__struct), __alignof__(__struct))
372 unsigned long __size,
unsigned long __align)
374 char *ptr = (
char*)handle->
next;
376 unsigned long adjust = __align - 1;
377 unsigned long mask = ~adjust;
380 ((((
unsigned long)ptr)
384 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
386 len -= ((
unsigned long)ptr
387 - (
unsigned long)handle->
next);
392 handle->
next = ptr + __size;
412 char *ptr = handle->
next;
413 unsigned short int len = handle->
remaining;
414 int vlen = (strlen(value) + 1);
442 char *ptr = handle->
next;
443 unsigned short int len = handle->
remaining;
446 if (len >=
sizeof(
char))
450 handle->
next = (
char*)ptr;
470 short int *ptr = (
short int*)handle->
next;
471 unsigned short int len = handle->
remaining;
473 unsigned long adjust = __alignof__(
short int) -1;
474 unsigned long mask = ~adjust;
477 ((((
unsigned long)ptr)
481 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
483 len -= ((
unsigned long)ptr
484 - (
unsigned long)handle->
next);
487 if (len >=
sizeof(
short int))
490 len -=
sizeof(short);
491 handle->
next = (
char*)ptr;
511 int *ptr = (
int*)handle->
next;
512 unsigned short int len = handle->
remaining;
515 ptr = (
int*)(((((
unsigned long)ptr))
516 + (__alignof__(
int) -1))
517 & (~(__alignof__(
int) -1)));
519 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
521 len -= ((
unsigned long)ptr
522 - (
unsigned long)handle->
next);
525 if (len >=
sizeof(
int))
529 handle->
next = (
char*)ptr;
549 long *ptr = (
long*)handle->
next;
550 unsigned short int len = handle->
remaining;
553 ptr = (
long*)(((((
unsigned long)ptr))
554 + (__alignof__(
long) -1))
555 & (~(__alignof__(
long) -1)));
557 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
559 len -= ((
unsigned long)ptr
560 - (
unsigned long)handle->
next);
563 if (len >=
sizeof(
long))
567 handle->
next = (
char*)ptr;
587 void **ptr = (
void**)handle->
next;
588 unsigned short int len = handle->
remaining;
591 ptr = (
void**)(((((
unsigned long)ptr))
592 + (__alignof__(
void*) -1))
593 & (~(__alignof__(
void*) -1)));
595 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
597 len -= ((
unsigned long)ptr
598 - (
unsigned long)handle->
next);
601 if (len >=
sizeof(
void*))
604 len -=
sizeof(
void*);
605 handle->
next = (
char*)ptr;
625 long long *ptr = (
long long*)handle->
next;
626 unsigned short int len = handle->
remaining;
629 ptr = (
long long*)(((((
unsigned long)ptr))
630 + (__alignof__(
long long) -1))
631 & (~(__alignof__(
long long) -1)));
633 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
635 len -= ((
unsigned long)ptr
636 - (
unsigned long)handle->
next);
639 if (len >=
sizeof(
long long))
642 len -=
sizeof(
long long);
643 handle->
next = (
char*)ptr;
663 float *ptr = (
float*)handle->
next;
664 unsigned short int len = handle->
remaining;
667 ptr = (
float*)(((((
unsigned long)ptr))
668 + (__alignof__(
float) -1))
669 & (~(__alignof__(
float) -1)));
671 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
673 len -= ((
unsigned long)ptr
674 - (
unsigned long)handle->
next);
677 if (len >=
sizeof(
float))
680 len -=
sizeof(float);
681 handle->
next = (
char*)ptr;
701 double *ptr = (
double*)handle->
next;
702 unsigned short int len = handle->
remaining;
705 ptr = (
double*)(((((
unsigned long)ptr))
706 + (__alignof__(
double) -1))
707 & (~(__alignof__(
double) -1)));
709 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
711 len -= ((
unsigned long)ptr
712 - (
unsigned long)handle->
next);
715 if (len >=
sizeof(
double))
718 len -=
sizeof(double);
719 handle->
next = (
char*)ptr;
738 char *ptr = handle->
next;
739 unsigned short int len = handle->
remaining;
742 if (len >=
sizeof(
char))
746 handle->
next = (
char*)ptr;
763 char *ptr = handle->
next;
764 unsigned short int len = handle->
remaining;
765 int vlen = (strlen(ptr) + 1);
788 static inline short int
791 short int *ptr = (
short int*)handle->
next;
792 unsigned short int len = handle->
remaining;
793 unsigned long adjust = __alignof__(
short int) -1;
794 unsigned long mask = ~adjust;
798 ((((
unsigned long)ptr)
802 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
804 len -= ((
unsigned long)ptr
805 - (
unsigned long)handle->
next);
808 if (len >=
sizeof(
short int))
811 len -=
sizeof(short);
812 handle->
next = (
char*)ptr;
830 int *ptr = (
int*)handle->
next;
831 unsigned short int len = handle->
remaining;
834 ptr = (
int*)(((((
unsigned long)ptr))
835 + (__alignof__(
int) -1))
836 & (~(__alignof__(
int) -1)));
838 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
840 len -= ((
unsigned long)ptr
841 - (
unsigned long)handle->
next);
844 if (len >=
sizeof(
int))
848 handle->
next = (
char*)ptr;
866 long *ptr = (
long*)handle->
next;
867 unsigned short int len = handle->
remaining;
870 ptr = (
long*)(((((
unsigned long)ptr))
871 + (__alignof__(
long) -1))
872 & (~(__alignof__(
long) -1)));
874 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
876 len -= ((
unsigned long)ptr
877 - (
unsigned long)handle->
next);
880 if (len >=
sizeof(
long))
884 handle->
next = (
char*)ptr;
902 void **ptr = (
void**)handle->
next;
903 unsigned short int len = handle->
remaining;
906 ptr = (
void**)(((((
unsigned long)ptr))
907 + (__alignof__(
void*) -1))
908 & (~(__alignof__(
void*) -1)));
910 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
912 len -= ((
unsigned long)ptr
913 - (
unsigned long)handle->
next);
916 if (len >=
sizeof(
void*))
919 len -=
sizeof(
void*);
920 handle->
next = (
char*)ptr;
935 static inline long long
938 long long *ptr = (
long long*)handle->
next;
939 unsigned short int len = handle->
remaining;
940 long long value = 0LL;
942 ptr = (
long long*)(((((
unsigned long)ptr))
943 + (__alignof__(
long long) -1))
944 & (~(__alignof__(
long long) -1)));
946 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
948 len -= ((
unsigned long)ptr
949 - (
unsigned long)handle->
next);
952 if (len >=
sizeof(
long long))
955 len -=
sizeof(
long long);
956 handle->
next = (
char*)ptr;
974 float *ptr = (
float*)handle->
next;
975 unsigned short int len = handle->
remaining;
978 ptr = (
float*)(((((
unsigned long)ptr))
979 + (__alignof__(
float) -1))
980 & (~(__alignof__(
float) -1)));
982 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
984 len -= ((
unsigned long)ptr
985 - (
unsigned long)handle->
next);
988 if (len >=
sizeof(
float))
991 len -=
sizeof(float);
992 handle->
next = (
char*)ptr;
1007 static inline double
1010 double *ptr = (
double*)handle->
next;
1011 unsigned short int len = handle->
remaining;
1014 ptr = (
double*)(((((
unsigned long)ptr))
1015 + (__alignof__(
double) -1))
1016 & (~(__alignof__(
double) -1)));
1018 if ((
unsigned long)ptr != (
unsigned long)handle->
next)
1020 len -= ((
unsigned long)ptr
1021 - (
unsigned long)handle->
next);
1024 if (len >=
sizeof(
double))
1027 len -=
sizeof(double);
1028 handle->
next = (
char*)ptr;
static char * SPHLFlogEntryGetNextString(SPHLFLoggerHandle_t *handle)
Return the pointer to the next C string from the logger entry via the current next value pointer...
Definition: sphlflogentry.h:761
static int SPHLFLogEntryIsComplete(SPHLFLoggerHandle_t *handlespace)
Return the status of the entry specified by the entry handle.
Definition: sphlflogentry.h:132
static int SPHLFLogEntrySubcat(SPHLFLoggerHandle_t *handlespace)
Return the entry sub-category for the entry specified by the entry handle.
Definition: sphlflogentry.h:255
static char SPHLFlogEntryGetNextChar(SPHLFLoggerHandle_t *handle)
Return the next char from the logger entry via the current next value pointer. The internal next valu...
Definition: sphlflogentry.h:736
#define sas_write_barrier()
Definition: sasatom.h:51
char * next
Definition: sphlflogger.h:248
unsigned short int remaining
Definition: sphlflogger.h:252
unsigned int subcat
Definition: sphlflogger.h:198
static long long SPHLFlogEntryGetNextLongLong(SPHLFLoggerHandle_t *handle)
Return the next long long int from the logger entry via the current next value pointer. Leading bytes may be skipped to get the required alignment. The internal next value pointer is advanced to the next location.
Definition: sphlflogentry.h:936
static sphtimer_t SPHLFLogEntryTimeStamp(SPHLFLoggerHandle_t *handlespace)
Return the time stamp value for the entry specified by the entry handle.
Definition: sphlflogentry.h:160
static sphpid16_t SPHLFLogEntryPID(SPHLFLoggerHandle_t *handlespace)
Return the process ID for the entry specified by the entry handle.
Definition: sphlflogentry.h:179
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
static int SPHLFlogEntryAddShort(SPHLFLoggerHandle_t *handle, short int value)
Insert a short int at the next free location within the logger entry.
Definition: sphlflogentry.h:467
static sphpid16_t SPHLFLogEntryTID(SPHLFLoggerHandle_t *handlespace)
Return the thread ID for the entry specified by the entry handle.
Definition: sphlflogentry.h:198
Type and functions for SAS atomic operations.
static float SPHLFlogEntryGetNextFloat(SPHLFLoggerHandle_t *handle)
Return the next float from the logger entry via the current next value pointer. Leading bytes may be ...
Definition: sphlflogentry.h:972
static int SPHLFlogEntryAddLong(SPHLFLoggerHandle_t *handle, long value)
Insert a long int at the next free location within the logger entry.
Definition: sphlflogentry.h:546
Shared Persistent Heap, logger. For shared memory multi-thread/multi-core applications. This implementation uses atomic operations to implement Lock Free Loggers (SPHLFLogger_t).
static void * SPHLFLogEntryGetFreePtr(SPHLFLoggerHandle_t *handle)
Return the address first free byte for the entry specified by the entry handle.
Definition: sphlflogentry.h:285
static short int SPHLFlogEntryGetNextShort(SPHLFLoggerHandle_t *handle)
Return the next short int from the logger entry via the current next value pointer. Leading bytes may be skipped to get the required alignment. The internal next value pointer is advanced to the next location.
Definition: sphlflogentry.h:789
Union of Entry details with 32-bit word for atomic update.
Definition: sphlflogger.h:208
static int SPHLFlogEntryAddString(SPHLFLoggerHandle_t *handle, char *value)
Insert a C string at the next free location within the logger entry.
Definition: sphlflogentry.h:409
unsigned int timestamped
Definition: sphlflogger.h:192
static int SPHLFlogEntryAddPtr(SPHLFLoggerHandle_t *handle, void *value)
Insert a void* at the next free location within the logger entry.
Definition: sphlflogentry.h:584
Instance of a Lock Free Logger Entry Handle.
Definition: sphlflogger.h:244
unsigned short sphpid16_t
Common type for PID/TID values stored in Logger entries.
Definition: sphlflogger.h:217
static int SPHLFLogEntryIsTimestamped(SPHLFLoggerHandle_t *handlespace)
Return the status of the entry specified by the entry handle.
Definition: sphlflogentry.h:145
static int SPHLFlogEntryAddChar(SPHLFLoggerHandle_t *handle, char value)
Insert a character at the next free location within the logger entry.
Definition: sphlflogentry.h:439
static int SPHLFlogEntryAddDouble(SPHLFLoggerHandle_t *handle, double value)
Insert a double at the next free location within the logger entry.
Definition: sphlflogentry.h:698
static SPHLFLogHeader_t * SPHLFLogEntryHeader(SPHLFLoggerHandle_t *handlespace)
Return the address for the entry header specified by the entry handle.
Definition: sphlflogentry.h:217
static void * SPHLFlogEntryAllocStruct(SPHLFLoggerHandle_t *handle, unsigned long __size, unsigned long __align)
Allocate space for struct starting at the next free location within the logger entry.
Definition: sphlflogentry.h:371
unsigned int category
Definition: sphlflogger.h:196
#define sas_read_barrier()
Definition: sasatom.h:56
unsigned int valid
Definition: sphlflogger.h:190
static int SPHLFlogEntryAddLongLong(SPHLFLoggerHandle_t *handle, long long value)
Insert a long long int at the next free location within the logger entry.
Definition: sphlflogentry.h:622
static int SPHLFLogEntryComplete(SPHLFLoggerHandle_t *handlespace)
Marks the entry specified by the entry handle as complete. Also executes write memory barries require...
Definition: sphlflogentry.h:111
sphLogEntryID_t idUnit
Definition: sphlflogger.h:210
static int SPHLFlogEntryGetNextInt(SPHLFLoggerHandle_t *handle)
Return the next int from the logger entry via the current next value pointer. Leading bytes may be sk...
Definition: sphlflogentry.h:828
static long SPHLFlogEntryGetNextLong(SPHLFLoggerHandle_t *handle)
Return the next long int from the logger entry via the current next value pointer. Leading bytes may be skipped to get the required alignment. The internal next value pointer is advanced to the next location.
Definition: sphlflogentry.h:864
static int SPHLFLogEntryStrongComplete(SPHLFLoggerHandle_t *handlespace)
Marks the entry specified by the entry handle as complete. Also executes any memory barriers required...
Definition: sphlflogentry.h:65
static void * SPHLFlogEntryGetNextPtr(SPHLFLoggerHandle_t *handle)
Return the next void* from the logger entry via the current next value pointer. Leading bytes may be ...
Definition: sphlflogentry.h:900
SPHLFLogHeader_t * entry
Definition: sphlflogger.h:246
static int SPHLFlogEntryAddInt(SPHLFLoggerHandle_t *handle, int value)
Insert a int at the next free location within the logger entry.
Definition: sphlflogentry.h:508
static double SPHLFlogEntryGetNextDouble(SPHLFLoggerHandle_t *handle)
Return the next double from the logger entry via the current next value pointer. Leading bytes may be...
Definition: sphlflogentry.h:1008
static int SPHLFLogEntryWeakComplete(SPHLFLoggerHandle_t *handlespace)
Marks the entry specified by the entry handle as complete. No memory barriers are performance...
Definition: sphlflogentry.h:88
static void * SPHLFlogEntryGetStructPtr(SPHLFLoggerHandle_t *handle, unsigned long __size, unsigned long __align)
Return the correctly aligned pointer for a struct or array starting at the next free location within ...
Definition: sphlflogentry.h:316
static int SPHLFlogEntryAddFloat(SPHLFLoggerHandle_t *handle, float value)
Insert a float at the next free location within the logger entry.
Definition: sphlflogentry.h:660
static int SPHLFLogEntryCategory(SPHLFLoggerHandle_t *handlespace)
Return the entry category for the entry specified by the entry handle.
Definition: sphlflogentry.h:234