diff options
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/compilers.h | 5 | ||||
| -rw-r--r-- | src/utils/constants.h | 5 | ||||
| -rw-r--r-- | src/utils/dbg_log.h | 5 | ||||
| -rw-r--r-- | src/utils/math.h | 5 | ||||
| -rw-r--r-- | src/utils/prefetch.h | 5 | ||||
| -rw-r--r-- | src/utils/sleep.h | 5 | ||||
| -rw-r--r-- | src/utils/utils.h | 5 | ||||
| -rw-r--r-- | src/utils/wrapthread.h | 5 |
8 files changed, 40 insertions, 0 deletions
diff --git a/src/utils/compilers.h b/src/utils/compilers.h index 1b175bb..a2ae3ba 100644 --- a/src/utils/compilers.h +++ b/src/utils/compilers.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_COMPILERS_H | ||
| 2 | #define UTILS_COMPILERS_H | ||
| 3 | |||
| 1 | #if defined(__GNUC__) | 4 | #if defined(__GNUC__) |
| 2 | 5 | ||
| 3 | #define UNUSED __attribute__((unused)) | 6 | #define UNUSED __attribute__((unused)) |
| @@ -22,3 +25,5 @@ a[static N] notation for array parameters). | |||
| 22 | #define NON_NULL | 25 | #define NON_NULL |
| 23 | 26 | ||
| 24 | #endif | 27 | #endif |
| 28 | |||
| 29 | #endif /* UTILS_COMPILERS_H */ | ||
diff --git a/src/utils/constants.h b/src/utils/constants.h index 3eed27d..3d0f6e3 100644 --- a/src/utils/constants.h +++ b/src/utils/constants.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_CONSTANTS_H | ||
| 2 | #define UTILS_CONSTANTS_H | ||
| 3 | |||
| 1 | #define UINT8_BIT(i) (UINT8_C(1) << (uint8_t)(i)) | 4 | #define UINT8_BIT(i) (UINT8_C(1) << (uint8_t)(i)) |
| 2 | 5 | ||
| 3 | #define FACTORIAL_MAX UINT64_C(12) | 6 | #define FACTORIAL_MAX UINT64_C(12) |
| @@ -42,3 +45,5 @@ STATIC uint64_t binomial[12][12] = { | |||
| 42 | {1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1, 0}, | 45 | {1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1, 0}, |
| 43 | {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1}, | 46 | {1, 11, 55, 165, 330, 462, 462, 330, 165, 55, 11, 1}, |
| 44 | }; | 47 | }; |
| 48 | |||
| 49 | #endif /* UTILS_CONSTANTS_H */ | ||
diff --git a/src/utils/dbg_log.h b/src/utils/dbg_log.h index 08d42a3..f22260a 100644 --- a/src/utils/dbg_log.h +++ b/src/utils/dbg_log.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_DBG_LOG_H | ||
| 2 | #define UTILS_DBG_LOG_H | ||
| 3 | |||
| 1 | #include <stdio.h> | 4 | #include <stdio.h> |
| 2 | 5 | ||
| 3 | void (*nissy_log)(const char *, void *); | 6 | void (*nissy_log)(const char *, void *); |
| @@ -31,3 +34,5 @@ write_wrapper(void (*write)(const char *, void *), const char *str, ...) | |||
| 31 | #define DBG_WARN(condition, ...) | 34 | #define DBG_WARN(condition, ...) |
| 32 | #define DBG_ASSERT(condition, ...) | 35 | #define DBG_ASSERT(condition, ...) |
| 33 | #endif | 36 | #endif |
| 37 | |||
| 38 | #endif /* UTILS_DBG_LOG_H */ | ||
diff --git a/src/utils/math.h b/src/utils/math.h index 0c56861..66ddaed 100644 --- a/src/utils/math.h +++ b/src/utils/math.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_MATH_H | ||
| 2 | #define UTILS_MATH_H | ||
| 3 | |||
| 1 | #define SWAP(x, y) do { x ^= y; y ^= x; x ^= y; } while (0) | 4 | #define SWAP(x, y) do { x ^= y; y ^= x; x ^= y; } while (0) |
| 2 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) | 5 | #define MIN(x, y) ((x) < (y) ? (x) : (y)) |
| 3 | #define MAX(x, y) ((x) > (y) ? (x) : (y)) | 6 | #define MAX(x, y) ((x) > (y) ? (x) : (y)) |
| @@ -146,3 +149,5 @@ intpow(double b, uint64_t e) | |||
| 146 | 149 | ||
| 147 | return e % 2 == 0 ? r * r : b * r * r; | 150 | return e % 2 == 0 ? r * r : b * r * r; |
| 148 | } | 151 | } |
| 152 | |||
| 153 | #endif /* UTILS_MATH_H */ | ||
diff --git a/src/utils/prefetch.h b/src/utils/prefetch.h index a2c41ef..30e364e 100644 --- a/src/utils/prefetch.h +++ b/src/utils/prefetch.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_PREFETCH_H | ||
| 2 | #define UTILS_PREFETCH_H | ||
| 3 | |||
| 1 | #if defined(__GNUC__) || defined(__clang__) | 4 | #if defined(__GNUC__) || defined(__clang__) |
| 2 | #define prefetch(a, i) __builtin_prefetch(a+i, 0, 0) | 5 | #define prefetch(a, i) __builtin_prefetch(a+i, 0, 0) |
| 3 | #elif defined(AVX2) | 6 | #elif defined(AVX2) |
| @@ -5,3 +8,5 @@ | |||
| 5 | #else | 8 | #else |
| 6 | #define prefetch(a, i) (void)i | 9 | #define prefetch(a, i) (void)i |
| 7 | #endif | 10 | #endif |
| 11 | |||
| 12 | #endif /* UTILS_PREFETCH_H */ | ||
diff --git a/src/utils/sleep.h b/src/utils/sleep.h index 7c0a84d..28bb807 100644 --- a/src/utils/sleep.h +++ b/src/utils/sleep.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_SLEEP_H | ||
| 2 | #define UTILS_SLEEP_H | ||
| 3 | |||
| 1 | #define BASE_SLEEP_TIME 500 | 4 | #define BASE_SLEEP_TIME 500 |
| 2 | 5 | ||
| 3 | STATIC void msleep(int); | 6 | STATIC void msleep(int); |
| @@ -50,3 +53,5 @@ msleep(int milliseconds) | |||
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | #endif | 55 | #endif |
| 56 | |||
| 57 | #endif /* UTILS_SLEEP_H */ | ||
diff --git a/src/utils/utils.h b/src/utils/utils.h index e322f20..e320105 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_UTILS_H | ||
| 2 | #define UTILS_UTILS_H | ||
| 3 | |||
| 1 | #include "compilers.h" | 4 | #include "compilers.h" |
| 2 | #include "dbg_log.h" | 5 | #include "dbg_log.h" |
| 3 | #include "constants.h" | 6 | #include "constants.h" |
| @@ -5,3 +8,5 @@ | |||
| 5 | #include "sleep.h" | 8 | #include "sleep.h" |
| 6 | #include "wrapthread.h" | 9 | #include "wrapthread.h" |
| 7 | #include "prefetch.h" | 10 | #include "prefetch.h" |
| 11 | |||
| 12 | #endif /* UTILS_UTILS_H */ | ||
diff --git a/src/utils/wrapthread.h b/src/utils/wrapthread.h index 9578293..e88eb58 100644 --- a/src/utils/wrapthread.h +++ b/src/utils/wrapthread.h | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | #ifndef UTILS_WRAPTHREAD_H | ||
| 2 | #define UTILS_WRAPTHREAD_H | ||
| 3 | |||
| 1 | #if THREADS == 1 | 4 | #if THREADS == 1 |
| 2 | #define WRAPTHREAD_NOTHREADS 1 | 5 | #define WRAPTHREAD_NOTHREADS 1 |
| 3 | #elif defined(__unix__) | 6 | #elif defined(__unix__) |
| @@ -75,3 +78,5 @@ | |||
| 75 | #define wrapthread_mutex_unlock(a) | 78 | #define wrapthread_mutex_unlock(a) |
| 76 | 79 | ||
| 77 | #endif | 80 | #endif |
| 81 | |||
| 82 | #endif /* UTILS_WRAPTHREAD_H */ | ||
