|
Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
|
#include <limits.h>#include <stdarg.h>#include <stdatomic.h>#include <stddef.h>#include <stdint.h>#include <stdio.h>Go to the source code of this file.
Data Structures | |
| struct | srn_spinlock_t |
Macros | |
| #define | SERENE_DEBUG 0 |
| #define | UNUSED(x) |
| #define | PANIC(msg) |
| #define | TODO(msg) |
| #define | PANIC_WITH_CTX(ctx, msg) |
| #define | PANIC_IF(cond, msg) |
| #define | PANIC_IF_NULL(ptr) |
| #define | RETURN_IF_NULL(ptr) |
| #define | SNPRINTF(buf, s, f, ...) |
| #define | SHOULD_NOT_HAPPEN PANIC("This should not happen") |
| #define | PANIC_ON_ERR(interr) |
| #define | SRN_ATTR_COLD |
| #define | SRN_ATTR_FMT(a, b) |
| #define | DBG(...) |
| #define | DBG_HEX(...) |
| #define | DBG_ASSERT(x) |
| #define | SRN_NS_PER_SEC 1000000000ULL |
| nanoseconds in one second | |
| #define | SRN_NS_PER_MS 1000000ULL |
| nanoseconds in one millisecond | |
| #define | TYPE_BITS(T) |
| #define | MAX_POW2_EXP_FOR_UNSIGNED(T) |
Typedefs | |
| typedef struct srn_spinlock_t | srn_spinlock_t |
Functions | |
| void | srn_panic (const char *msg, const char *file, size_t line, const char *fn) |
| TODO(lxsameer): unwind the stack. | |
| static uint32_t | srn_popcnt32 (uint32_t x) |
| static uint64_t | srn_popcnt64 (uint64_t x) |
| static void | cpu_relax (void) |
| A portable way to use pasue instructions. | |
| static void | srn_spinlock_unlock (srn_spinlock_t *lock) |
| static void | srn_spinlock_init (srn_spinlock_t *lock) |
| static void | srn_spinlock_lock (srn_spinlock_t *lock) |
| char * | srn_copy_bytes (const srn_context_t *ctx, const char *src, size_t len, size_t alignment) |
| char * | srn_dup_str (srn_mm_t *mm, const char *s) |
| Copy a null terminated C string into a fresh allocation made through mm. | |
| uint64_t | srn_now_ns (void) |
| The current time on the monotonic clock, in nanoseconds. | |
| #define DBG | ( | ... | ) |
| #define DBG_ASSERT | ( | x | ) |
| #define DBG_HEX | ( | ... | ) |
| #define MAX_POW2_EXP_FOR_UNSIGNED | ( | T | ) |
| #define PANIC | ( | msg | ) |
| #define PANIC_IF | ( | cond, | |
| msg ) |
| #define PANIC_IF_NULL | ( | ptr | ) |
| #define PANIC_ON_ERR | ( | interr | ) |
| #define PANIC_WITH_CTX | ( | ctx, | |
| msg ) |
Definition at line 55 of file utils.h.
| #define RETURN_IF_NULL | ( | ptr | ) |
| #define SNPRINTF | ( | buf, | |
| s, | |||
| f, | |||
| ... ) |
Definition at line 72 of file utils.h.
| #define SRN_NS_PER_MS 1000000ULL |
| #define SRN_NS_PER_SEC 1000000000ULL |
| #define TODO | ( | msg | ) |
| typedef struct srn_spinlock_t srn_spinlock_t |
|
inlinestatic |
A portable way to use pasue instructions.
The long list of preprocessors is there thanks to: https://github.com/goodcleanfun/cpu_relax
Definition at line 223 of file utils.h.
| char * srn_copy_bytes | ( | const srn_context_t * | ctx, |
| const char * | src, | ||
| size_t | len, | ||
| size_t | alignment ) |
Definition at line 56 of file utils.c.
| char * srn_dup_str | ( | srn_mm_t * | mm, |
| const char * | s ) |
Copy a null terminated C string into a fresh allocation made through mm.
Returns nullptr on allocation failure.
Definition at line 70 of file utils.c.
| uint64_t srn_now_ns | ( | void | ) |
The current time on the monotonic clock, in nanoseconds.
Panics if the clock read fails – CLOCK_MONOTONIC with a valid buffer cannot fail on supported targets, so a failure means something is deeply wrong.
Definition at line 46 of file utils.c.
| void srn_panic | ( | const char * | msg, |
| const char * | file, | ||
| size_t | line, | ||
| const char * | fn ) |
TODO(lxsameer): unwind the stack.
Definition at line 31 of file utils.c.
|
inlinestatic |
Definition at line 194 of file utils.h.
|
inlinestatic |
|
inlinestatic |
Definition at line 280 of file utils.h.
|
inlinestatic |
|
inlinestatic |