commit 892dd7b4944431495dbc9821074dabdd879695e0
parent ba82886d4ad04d0a0d61e477c5d9582cac2771ca
Author: nolash <dev@holbrook.no>
Date: Fri, 31 Jan 2020 23:57:52 +0100
remove lash prefix from debug component
Diffstat:
4 files changed, 43 insertions(+), 45 deletions(-)
diff --git a/debug_log.c b/debug_log.c
@@ -6,24 +6,24 @@
struct timespec _timecontainer;
-int lash_debugLogInit(lash_debug_log_t *log, int autoflush) {
+int debugLogInit(debug_log_t *log, int autoflush) {
log->capacity = 0;
- log->items = (lash_debug_log_item_t*)malloc(sizeof(lash_debug_log_item_t) * LASH_DEBUG_LOG_CAPACITY_CHUNK);
+ log->items = (debug_log_item_t*)malloc(sizeof(debug_log_item_t) * DEBUG_LOG_CAPACITY_CHUNK);
if (log->items == NULL) {
log = NULL;
return 1;
}
- log->error_string_buffer = (char*)calloc(LASH_DEBUG_LOG_CAPACITY_DESCRIPTION, sizeof(char));
+ log->error_string_buffer = (char*)calloc(DEBUG_LOG_CAPACITY_DESCRIPTION, sizeof(char));
if (log->error_string_buffer == NULL) {
log = NULL;
return 1;
}
- log->capacity = LASH_DEBUG_LOG_CAPACITY_CHUNK;
+ log->capacity = DEBUG_LOG_CAPACITY_CHUNK;
log->count = 0;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &_timecontainer);
log->ns_start = _timecontainer.tv_nsec;
@@ -36,7 +36,7 @@ int lash_debugLogInit(lash_debug_log_t *log, int autoflush) {
* TODO Auto extend memory for log if capacity runs out
*/
-int lash_debugLogAdd(lash_debug_log_t *log, char *origin, char level, char *description) {
+int debugLogAdd(debug_log_t *log, char *origin, char level, char *description) {
if (log->count == log->capacity || log->capacity == 0)
return 1;
@@ -59,8 +59,6 @@ int lash_debugLogAdd(lash_debug_log_t *log, char *origin, char level, char *desc
if (log->autoflush > 0)
fprintf(stderr, "%s: %s\n", (log->items+log->count)->origin, (log->items+log->count)->description);
- //*(log->error_string_buffer) = NULL;
- //*(log->origin_string_buffer) = NULL;
log->error_string_buffer = NULL;
log->origin_string_buffer = NULL;
@@ -69,10 +67,10 @@ int lash_debugLogAdd(lash_debug_log_t *log, char *origin, char level, char *desc
return 0;
}
-int lash_debugLogSetDescription(lash_debug_log_t *log, const char *d) {
+int debugLogSetDescription(debug_log_t *log, const char *d) {
log->error_string_buffer = d;
}
-int lash_debugLogSetOrigin(lash_debug_log_t *log, const char *o) {
+int debugLogSetOrigin(debug_log_t *log, const char *o) {
log->origin_string_buffer = o;
}
diff --git a/debug_timer.c b/debug_timer.c
@@ -2,19 +2,19 @@
#include "debug_timer.h"
-void lash_debugTimerReset(lash_debug_timer_t *time) {
+void debugTimerReset(debug_timer_t *time) {
time->running = 0;
time->paused = 0;
time->count = 0;
time->total = 0;
}
-void lash_debugTimerStart(lash_debug_timer_t *time) {
+void debugTimerStart(debug_timer_t *time) {
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &(time->snap_start));
time->running = 1;
}
-long lash_debugTimerPause(lash_debug_timer_t *time) {
+long debugTimerPause(debug_timer_t *time) {
if (!time->running)
return 0;
@@ -30,7 +30,7 @@ long lash_debugTimerPause(lash_debug_timer_t *time) {
}
}
-void lash_debugTimerStop(lash_debug_timer_t * time) {
+void debugTimerStop(debug_timer_t * time) {
if (time->running == 0)
return;
@@ -43,6 +43,6 @@ void lash_debugTimerStop(lash_debug_timer_t * time) {
time->paused = 0;
}
-float lash_debugTimerGetAverage(lash_debug_timer_t *time) {
+float debugTimerGetAverage(debug_timer_t *time) {
return time->total / (float)time->count;
}
diff --git a/include/debug_log.h b/include/debug_log.h
@@ -1,24 +1,24 @@
-#ifndef LASH_DEBUG_LOG_H_
-#define LASH_DEBUG_LOG_H_
+#ifndef DEBUG_LOG_H_
+#define DEBUG_LOG_H_
-#define LASH_DEBUG_LOG_CAPACITY_CHUNK 255
-#define LASH_DEBUG_LOG_CAPACITY_DESCRIPTION 255
+#define DEBUG_LOG_CAPACITY_CHUNK 255
+#define DEBUG_LOG_CAPACITY_DESCRIPTION 255
-#define LASH_DEBUG_LOG_LEVEL_CRITICAL 127
-#define LASH_DEBUG_LOG_LEVEL_WARNING 64
-#define LASH_DEBUG_LOG_LEVEL_MESSAGE -1
-#define LASH_DEBUG_LOG_LEVEL_DEBUG -64
-#define LASH_DEBUG_LOG_LEVEL_ALL -128
+#define DEBUG_LOG_LEVEL_CRITICAL 127
+#define DEBUG_LOG_LEVEL_WARNING 64
+#define DEBUG_LOG_LEVEL_MESSAGE -1
+#define DEBUG_LOG_LEVEL_DEBUG -64
+#define DEBUG_LOG_LEVEL_ALL -128
-typedef struct lash_debug_log_item_t {
+typedef struct /*debug_log_item_t*/ {
unsigned long ns;
char level;
char *origin;
char *description;
-} lash_debug_log_item_t;
+} debug_log_item_t;
-typedef struct lash_debug_log_t {
+typedef struct /*lash_debug_log_t*/ {
unsigned long ns_start;
unsigned short int count;
unsigned short int capacity;
@@ -26,29 +26,29 @@ typedef struct lash_debug_log_t {
char *error_string_buffer; // used for sprintf, if no description in item is set the current error string buffer is used instead
char *origin_string_buffer; // used for sprintf, if no description in item is set the current error string buffer is used instead
int autoflush;
-} lash_debug_log_t;
+} debug_log_t;
#ifndef alog
#define alog 1;
-lash_debug_log_t lash_logobj;
+debug_log_t logobj;
#line 31 __FILE__
-#define aloglevel(x) lash_debugLogInit(&lash_logobj, 1)
-#define alogset(c, s) lash_debugLogSetDescription(&lash_logobj, s); lash_debugLogSetOrigin(&lash_logobj, c);
-#define alogadd(l) lash_debugLogAdd(&lash_logobj, NULL, l, NULL);
+#define loglevel(x) debugLogInit(&logobj, 1)
+#define logset(c, s) debugLogSetDescription(&logobj, s); debugLogSetOrigin(&logobj, c);
+#define logadd(l) debugLogAdd(&logobj, NULL, l, NULL);
#endif //lash_log
#ifdef LASH_DEBUG_LOG_GLOBAL
#include <stdio.h>
-lash_debug_log_t lash_log_global;
+debug_log_t log_global;
#endif
#ifdef __cplusplus
extern "C" {
#endif
-int lash_debugLogInit(lash_debug_log_t *log, int autoflush);
-int lash_debugLogAdd(lash_debug_log_t *log, char *origin, char level, char *description);
-int lash_debugLogSetDescription(lash_debug_log_t *log, const char *d);
-int lash_debugLogSetOrigin(lash_debug_log_t *log, const char *o);
+int debugLogInit(debug_log_t *log, int autoflush);
+int debugLogAdd(debug_log_t *log, char *origin, char level, char *description);
+int debugLogSetDescription(debug_log_t *log, const char *d);
+int debugLogSetOrigin(debug_log_t *log, const char *o);
#ifdef __cplusplus
}
diff --git a/include/debug_timer.h b/include/debug_timer.h
@@ -1,9 +1,9 @@
-#ifndef LASH_DEBUG_TIMER_H_
-#define LASH_DEBUG_TIMER_H_
+#ifndef DEBUG_TIMER_H_
+#define DEBUG_TIMER_H_
#include <time.h>
-typedef struct lash_debug_timer_t {
+typedef struct debug_timer_t {
unsigned int count;
long total;
struct timespec snap_start;
@@ -11,16 +11,16 @@ typedef struct lash_debug_timer_t {
struct timespec snap_tmp;
int running;
int paused;
-} lash_debug_timer_t;
+} debug_timer_t;
#ifdef __cplusplus
extern "C" {
#endif
-void lash_debugTimerReset(lash_debug_timer_t *time);
-void lash_debugTimerStart(lash_debug_timer_t *time);
-void lash_debugTimerStop(lash_debug_timer_t *time);
-long lash_debugTimerPause(lash_debug_timer_t *time);
-float lash_debugTimerGetAverage(lash_debug_timer_t *time);
+void debugTimerReset(debug_timer_t *time);
+void debugTimerStart(debug_timer_t *time);
+void debugTimerStop(debug_timer_t *time);
+long debugTimerPause(debug_timer_t *time);
+float debugTimerGetAverage(debug_timer_t *time);
#ifdef __cplusplus
}