aboutsummaryrefslogtreecommitdiff
path: root/include/u.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/u.h')
-rw-r--r--include/u.h74
1 files changed, 2 insertions, 72 deletions
diff --git a/include/u.h b/include/u.h
index c03d545..28bc2e4 100644
--- a/include/u.h
+++ b/include/u.h
@@ -1,27 +1,15 @@
#pragma once
// ------------------------------------------------------------------------
-// Standard library
+// Freestanding headers
+#include <stdarg.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
-#include <stdarg.h>
#include <float.h>
#include <limits.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <ctype.h>
-#include <stdio.h>
-
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <fcntl.h>
-
// ------------------------------------------------------------------------
// Modern type aliases
@@ -55,57 +43,6 @@ typedef void* Iface;
#define nil NULL
-// ----------------------------------------------------------------------------
-// Dynamic array.
-
-typedef struct bufHdr
-{
- vlong len;
- vlong cap;
- byte buf[];
-} bufHdr;
-
-#define _bufHdr(s) ((bufHdr*)((uint8*)(s)-offsetof(bufHdr, buf)))
-#define buflen(s) ((s) ? (_bufHdr(s)->len) : 0)
-#define bufcap(s) ((s) ? (_bufHdr(s)->cap) : 0)
-#define bufend(s) ((s) + buflen(s))
-#define bufsize(s) ((s) ? (buflen(s) * sizeof((s)[0])) : 0)
-
-#define buffree(s) ((s) ? (free(_bufHdr(s)), (s) = nil) : 0)
-#define buffit(s, n) ((n) <= bufcap(s) ? 0 : ((s) = bufgrow((s), (n), sizeof(*(s)))))
-
-#define bufresize(s, n) \
- do { \
- (buffit(s, n)); \
- ((_bufHdr(s)->len) = (n)); \
- } while (0)
-
-#define bufpush(s, ...) (buffit((s), 1 + buflen(s)), (s)[_bufHdr(s)->len++] = (__VA_ARGS__))
-
-#define bufpop(s, i) (_bufpop((s), (i), sizeof(*(s))), (s)[_bufHdr(s)->len])
-
-void* bufgrow(void*, vlong, vlong);
-void _bufpop(void*, int, vlong);
-
-// -----------------------------------------------------------------------------
-// Co-routines
-
-typedef struct coro coro;
-
-coro* coro·new(uintptr stk, uintptr (*func)(coro*, uintptr));
-uintptr coro·yield(coro *c, uintptr arg);
-error coro·free(coro *c);
-
-// -----------------------------------------------------------------------------
-// Strings
-
-#include "str.h"
-
-// -----------------------------------------------------------------------------
-// Maps or dictionaries
-
-#include "map.h"
-
// ------------------------------------------------------------------
// Global macros
@@ -119,10 +56,3 @@ error coro·free(coro *c);
#define MAX(x, y) ((x) >= (y) ? (x) : (y))
#define MIN(x, y) ((x) < (y) ? (x) : (y))
-
-// -----------------------------------------------------------------------------
-// Error handling functions.
-
-void errorf(const byte* fmt, ...);
-
-#define panicf(...) (errorf(__VA_ARGS__), assert(0))