diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-15 15:33:47 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-15 15:33:47 -0400 |
| commit | e422079fcced744e3a6247aeb12a09a658989072 (patch) | |
| tree | 393d5e52ba67dcc822ccfa9a812198edda5e735d /stdlib/bytes.h | |
| parent | 259c7efcf8c3808d8151d8e15f1167ad2b6f2ca7 (diff) | |
Add a Byte datatype
Diffstat (limited to 'stdlib/bytes.h')
| -rw-r--r-- | stdlib/bytes.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/stdlib/bytes.h b/stdlib/bytes.h new file mode 100644 index 00000000..d74ab80c --- /dev/null +++ b/stdlib/bytes.h @@ -0,0 +1,29 @@ +#pragma once + +// An unsigned byte datatype + +#include <stdbool.h> +#include <stdint.h> + +#include "types.h" +#include "util.h" + +#define Byte_t uint8_t +#define Byte(b) ((Byte_t)(b)) + +PUREFUNC Text_t Byte$as_text(const Byte_t *b, bool colorize, const TypeInfo *type); +Byte_t Byte$random(Byte_t min, Byte_t max); + +extern const Byte_t Byte$min; +extern const Byte_t Byte$max; + +extern const TypeInfo Byte$info; + +typedef struct { + Byte_t value; + bool is_null:1; +} OptionalByte_t; + +#define NULL_BYTE ((OptionalByte_t){.is_null=true}) + +// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
