aboutsummaryrefslogtreecommitdiff
path: root/nerv/lib/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'nerv/lib/common.h')
-rw-r--r--nerv/lib/common.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/nerv/lib/common.h b/nerv/lib/common.h
index 1c588d1..3d98574 100644
--- a/nerv/lib/common.h
+++ b/nerv/lib/common.h
@@ -7,6 +7,8 @@
#include <stdio.h>
#include <stdlib.h>
+#define PROFILE_HASHMAP_SIZE 123457
+
typedef enum ErrCode {
NERV_NORMAL,
/* matrix err */
@@ -59,6 +61,21 @@ typedef struct Status {
nerv_error_status(L, &status); \
} while (0)
+#define CHECK_SAME_DIMENSION(a, b, status) \
+ do { \
+ if (!(a->nrow == b->nrow && a->ncol == b->ncol)) \
+ NERV_EXIT_STATUS(status, MAT_MISMATCH_DIM, 0); \
+ } while (0)
+
+#define CHECK_SAME_DIMENSION_RET(a, b, status) \
+ do { \
+ if (!(a->nrow == b->nrow && a->ncol == b->ncol)) \
+ { \
+ NERV_SET_STATUS(status, MAT_MISMATCH_DIM, 0); \
+ return 0; \
+ } \
+ } while (0)
+
typedef struct HashNode {
const char *key;
void *val;
@@ -75,10 +92,11 @@ typedef struct HashMap {
size_t size;
} HashMap;
-HashMap *hashmap_create(size_t size, HashKey_t hfunc, HashMapCmp_t cmp);
-void *hashmap_getval(HashMap *h, const char *key);
-void hashmap_setval(HashMap *h, const char *key, void *val);
-void hashmap_clear(HashMap *h);
+HashMap *nerv_hashmap_create(size_t size, HashKey_t hfunc, HashMapCmp_t cmp);
+void *nerv_hashmap_getval(HashMap *h, const char *key);
+void nerv_hashmap_setval(HashMap *h, const char *key, void *val);
+void nerv_hashmap_clear(HashMap *h);
+void nerv_hashmap_destroy(HashMap *h);
size_t bkdr_hash(const char *key);