From 8c5d6766aaca1ce3ac87ddfd661753485e7ddeff Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Tue, 24 Aug 2021 16:23:15 +0200 Subject: [PATCH] Move types to dragontype submodule --- .gitmodules | 3 + deps/dragontype | 1 + src/CMakeLists.txt | 15 ++-- src/array.c | 55 --------------- src/array.h | 22 ------ src/bintree.c | 61 ----------------- src/bintree.h | 27 -------- src/client/camera.h | 2 +- src/client/client.h | 2 +- src/client/client_commands.c | 2 +- src/client/client_map.h | 2 +- src/client/client_player.h | 2 +- src/client/facecache.c | 2 +- src/client/facecache.h | 2 +- src/client/hud.h | 4 +- src/client/object.h | 4 +- src/client/scene.c | 2 +- src/client/texture.c | 2 +- src/environment.h | 2 +- src/list.c | 100 --------------------------- src/list.h | 39 ----------- src/map.h | 6 +- src/node.h | 2 +- src/perlin.c | 3 - src/perlin.h | 2 +- src/queue.c | 47 ------------- src/queue.h | 19 ------ src/server/biomes.h | 2 +- src/server/server.h | 4 +- src/types.c | 128 ----------------------------------- src/types.h | 55 --------------- src/util.h | 2 +- 32 files changed, 34 insertions(+), 587 deletions(-) create mode 160000 deps/dragontype delete mode 100644 src/array.c delete mode 100644 src/array.h delete mode 100644 src/bintree.c delete mode 100644 src/bintree.h delete mode 100644 src/list.c delete mode 100644 src/list.h delete mode 100644 src/queue.c delete mode 100644 src/queue.h delete mode 100644 src/types.c delete mode 100644 src/types.h diff --git a/.gitmodules b/.gitmodules index 6c23b94..f126607 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "deps/stb"] path = deps/stb url = https://github.com/nothings/stb +[submodule "deps/dragontype"] + path = deps/dragontype + url = https://github.com/dragonblocks/dragontype diff --git a/deps/dragontype b/deps/dragontype new file mode 160000 index 0000000..df31600 --- /dev/null +++ b/deps/dragontype @@ -0,0 +1 @@ +Subproject commit df31600e08952b5911e0669da98491593997c623 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f04e38f..b8e67f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,8 +17,10 @@ link_libraries( z ) +set(DEPS_DIR "${CMAKE_SOURCE_DIR}/../deps/") + include_directories(SYSTEM - "${CMAKE_SOURCE_DIR}/../deps/" + ${DEPS_DIR} ) include_directories(BEFORE @@ -28,17 +30,14 @@ include_directories(BEFORE add_compile_options(-Wall -Wextra -Wpedantic -Werror) set(SOURCES_COMMON - array.c - bintree.c environment.c - list.c map.c - signal_handlers.c - util.c - types.c node.c perlin.c - queue.c + signal_handlers.c + util.c + "${DEPS_DIR}/dragontype/implementation.c" + "${DEPS_DIR}/perlin/perlin.c" ) add_executable(Dragonblocks diff --git a/src/array.c b/src/array.c deleted file mode 100644 index d5de936..0000000 --- a/src/array.c +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#include -#include "array.h" - -Array array_create(size_t membsiz) -{ - return (Array) { - .membsiz = membsiz, - .siz = 0, - .cap = 0, - .ptr = NULL, - }; -} - - -static void array_realloc(Array *array) -{ - if (array->siz > array->cap) { - array->cap = array->siz + ARRAY_REALLOC_EXTRA; - array->ptr = realloc(array->ptr, array->cap * array->membsiz); - } -} - -static void array_alloc(Array *array, size_t siz) -{ - array->siz += siz; - array_realloc(array); -} - -void array_insert(Array *array, void *elem, size_t idx) -{ - size_t oldsiz = array->siz; - array_alloc(array, 1); - - char *iptr = (char *) array->ptr + idx * array->membsiz; - memmove(iptr + array->membsiz, iptr, (oldsiz - idx) * array->membsiz); - memcpy(iptr, elem, array->membsiz); -} - -void array_append(Array *array, void *elem) -{ - size_t oldsiz = array->siz; - array_alloc(array, 1); - - memcpy((char *) array->ptr + oldsiz * array->membsiz, elem, array->membsiz); -} - -void array_copy(Array *array, void **ptr, size_t *count) -{ - *count = array->siz; - size_t size = array->siz * array->membsiz; - *ptr = malloc(size); - memcpy(*ptr, array->ptr, size); -} diff --git a/src/array.h b/src/array.h deleted file mode 100644 index a887ad5..0000000 --- a/src/array.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _ARRAY_H_ -#define _ARRAY_H_ - -#define ARRAY_REALLOC_EXTRA 25 - -#include -#include -#include "types.h" - -typedef struct -{ - size_t membsiz; - size_t siz, cap; - void *ptr; -} Array; - -Array array_create(size_t membsiz); -void array_insert(Array *array, void *elem, size_t idx); -void array_append(Array *array, void *elem); -void array_copy(Array *array, void **ptr, size_t *count); - -#endif diff --git a/src/bintree.c b/src/bintree.c deleted file mode 100644 index f68fa1e..0000000 --- a/src/bintree.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include -#include "bintree.h" - -Bintree bintree_create(size_t key_size) -{ - return (Bintree) { - .root = NULL, - .key_size = key_size, - }; -} - -static BintreeNode **search_recursive(Bintree *tree, BintreeNode **nodeptr, void *key) -{ - if (*nodeptr) { - int cond; - - if ((cond = memcmp((*nodeptr)->key, key, tree->key_size)) == 0) - return nodeptr; - else if (cond > 0) - return search_recursive(tree, &(*nodeptr)->left, key); - else - return search_recursive(tree, &(*nodeptr)->right, key); - } else { - return nodeptr; - } -} - -BintreeNode **bintree_search(Bintree *tree, void *key) -{ - return search_recursive(tree, &tree->root, key); -} - -void bintree_add_node(Bintree *tree, BintreeNode **nodeptr, void *key, void *value) -{ - *nodeptr = malloc(sizeof(BintreeNode)); - (*nodeptr)->key = malloc(tree->key_size); - memcpy((*nodeptr)->key, key, tree->key_size); - (*nodeptr)->value = value; - (*nodeptr)->left = (*nodeptr)->right = NULL; -} - -static void free_recursive(BintreeNode *node, BintreeFreeFunction func, void *arg) -{ - if (node) { - free_recursive(node->left, func, arg); - free_recursive(node->right, func, arg); - free(node->key); - if (func) - func(node->value, arg); - free(node); - } -} - -void bintree_clear(Bintree *tree, BintreeFreeFunction func, void *arg) -{ - if (tree) { - free_recursive(tree->root, func, arg); - tree->root = NULL; - } -} diff --git a/src/bintree.h b/src/bintree.h deleted file mode 100644 index 49efe15..0000000 --- a/src/bintree.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _BINTREE_H_ -#define _BINTREE_H_ - -#include - -typedef struct BintreeNode -{ - void *key; - void *value; - struct BintreeNode *left; - struct BintreeNode *right; -} BintreeNode; - -typedef struct -{ - BintreeNode *root; - size_t key_size; -} Bintree; - -typedef void (*BintreeFreeFunction)(void *value, void *arg); - -Bintree bintree_create(size_t key_size); -BintreeNode **bintree_search(Bintree *tree, void *key); -void bintree_add_node(Bintree *tree, BintreeNode **nodeptr, void *key, void *value); -void bintree_clear(Bintree *tree, BintreeFreeFunction func, void *arg); - -#endif diff --git a/src/client/camera.h b/src/client/camera.h index bc7d57c..e5f7f45 100644 --- a/src/client/camera.h +++ b/src/client/camera.h @@ -4,7 +4,7 @@ #include #include #include -#include "types.h" +#include extern struct Camera { diff --git a/src/client/client.h b/src/client/client.h index d5ac964..bca96f8 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -3,11 +3,11 @@ #include #include +#include #include "client/client_commands.h" #include "client/scene.h" #include "server/server_commands.h" #include "network.h" -#include "types.h" #ifdef RELEASE #define RESSOURCEPATH "" diff --git a/src/client/client_commands.c b/src/client/client_commands.c index cf3cf54..c2cdc60 100644 --- a/src/client/client_commands.c +++ b/src/client/client_commands.c @@ -1,8 +1,8 @@ #include #include +#include #include "client/client.h" #include "client/client_map.h" -#include "types.h" #include "util.h" static bool disconnect_handler(unused Client *client, bool good) diff --git a/src/client/client_map.h b/src/client/client_map.h index 657dcb1..ce4056b 100644 --- a/src/client/client_map.h +++ b/src/client/client_map.h @@ -3,8 +3,8 @@ #include #include +#include #include "map.h" -#include "queue.h" #include "client/object.h" typedef enum diff --git a/src/client/client_player.h b/src/client/client_player.h index 1621aa4..2bd163a 100644 --- a/src/client/client_player.h +++ b/src/client/client_player.h @@ -2,10 +2,10 @@ #define _CLIENT_PLAYER_H_ #include +#include #include "client/client.h" #include "client/hud.h" #include "client/object.h" -#include "types.h" extern struct ClientPlayer { diff --git a/src/client/facecache.c b/src/client/facecache.c index b902c90..09ea7d6 100644 --- a/src/client/facecache.c +++ b/src/client/facecache.c @@ -1,6 +1,6 @@ #include +#include #include "client/facecache.h" -#include "array.h" static struct { diff --git a/src/client/facecache.h b/src/client/facecache.h index 847b739..2900cd5 100644 --- a/src/client/facecache.h +++ b/src/client/facecache.h @@ -2,7 +2,7 @@ #define _FACECACHE_H_ #include -#include "types.h" +#include v3s32 facecache_face(size_t i, v3s32 *base); size_t facecache_count(u32 size); diff --git a/src/client/hud.h b/src/client/hud.h index 8f81eb9..d58af37 100644 --- a/src/client/hud.h +++ b/src/client/hud.h @@ -3,10 +3,10 @@ #include #include +#include +#include #include "client/font.h" #include "client/texture.h" -#include "list.h" -#include "types.h" typedef enum { diff --git a/src/client/object.h b/src/client/object.h index 7b9dab8..3e06b3d 100644 --- a/src/client/object.h +++ b/src/client/object.h @@ -6,11 +6,11 @@ #include #include #include +#include +#include #include "client/mesh.h" #include "client/texture.h" #include "client/vertex.h" -#include "array.h" -#include "types.h" typedef struct { GLfloat x, y, z; diff --git a/src/client/scene.c b/src/client/scene.c index d470851..99935f2 100644 --- a/src/client/scene.c +++ b/src/client/scene.c @@ -2,11 +2,11 @@ #include #include #include +#include #include "client/camera.h" #include "client/client.h" #include "client/scene.h" #include "client/shader.h" -#include "list.h" #include "util.h" static struct diff --git a/src/client/texture.c b/src/client/texture.c index 994f027..6393bb3 100644 --- a/src/client/texture.c +++ b/src/client/texture.c @@ -1,8 +1,8 @@ #define STB_IMAGE_IMPLEMENTATION #include #include +#include #include "client/texture.h" -#include "list.h" #include "util.h" static List textures; diff --git a/src/environment.h b/src/environment.h index 1de120c..bacda15 100644 --- a/src/environment.h +++ b/src/environment.h @@ -1,7 +1,7 @@ #ifndef _ENVIRONMENT_H_ #define _ENVIRONMENT_H_ -#include "types.h" +#include f64 get_humidity(v3s32 pos); f64 get_temperature(v3s32 pos); diff --git a/src/list.c b/src/list.c deleted file mode 100644 index 7388eaf..0000000 --- a/src/list.c +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include "list.h" - -bool list_compare_default(void *v1, void *v2) -{ - return v1 == v2; -} - -bool list_compare_string(void *v1, void *v2) -{ - return strcmp(v1, v2) == 0; -} - -List list_create(ListComparator cmp) -{ - return (List) { - .cmp = cmp ? cmp : list_compare_default, - .first = NULL, - }; -} - -void list_clear(List *list) -{ - list_clear_func(list, NULL, NULL); -} - -void list_clear_func(List *list, void (*func)(void *key, void *value, void *arg), void *arg) -{ - for (ListPair *pair = list->first; pair != NULL;) { - ListPair *next = pair->next; - if (func) - func(pair->key, pair->value, arg); - free(pair); - pair = next; - } - list->first = NULL; -} - -static ListPair *make_pair(void *key, void *value) -{ - ListPair *pair = malloc(sizeof(ListPair)); - pair->key = key; - pair->value = value; - pair->next = NULL; - return pair; -} - -bool list_put(List *list, void *key, void *value) -{ - ListPair **pairptr; - for (pairptr = &list->first; *pairptr != NULL; pairptr = &(*pairptr)->next) { - if (list->cmp((*pairptr)->key, key)) - return false; - } - *pairptr = make_pair(key, value); - return true; -} - -void *list_get_cached(List *list, void *key, void *(*provider)(void *key)) -{ - ListPair **pairptr; - for (pairptr = &list->first; *pairptr != NULL; pairptr = &(*pairptr)->next) { - if (list->cmp((*pairptr)->key, key)) - return (*pairptr)->value; - } - return (*pairptr = make_pair(key, provider(key)))->value; -} - -void list_set(List *list, void *key, void *value) -{ - ListPair **pairptr; - for (pairptr = &list->first; *pairptr != NULL; pairptr = &(*pairptr)->next) { - if (list->cmp((*pairptr)->key, key)) - break; - } - *pairptr = make_pair(key, value); -} - -void *list_delete(List *list, void *key) -{ - for (ListPair **pairptr = &list->first; *pairptr != NULL; pairptr = &(*pairptr)->next) { - if (list->cmp((*pairptr)->key, key)) { - ListPair *pair = *pairptr; - void *value = (*pairptr)->value; - *pairptr = pair->next; - free(pair); - return value; - } - } - return NULL; -} - -void *list_get(List *list, void *key) -{ - for (ListPair *pair = list->first; pair != NULL; pair = pair->next) - if (list->cmp(pair->key, key)) - return pair->value; - return NULL; -} diff --git a/src/list.h b/src/list.h deleted file mode 100644 index 065100b..0000000 --- a/src/list.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _List_H_ -#define _List_H_ - -#include - -#define ITERATE_LIST(list, pair) for (ListPair *pair = (list)->first; pair != NULL; pair = pair->next) - -typedef struct ListPair -{ - struct ListPair *next; - void *key; - void *value; -} ListPair; - -typedef bool (*ListComparator)(void *v1, void *v2); - -typedef struct -{ - ListComparator cmp; - ListPair *first; -} List; - -bool list_compare_default(void *v1, void *v2); -bool list_compare_string(void *v1, void *v2); - -List list_create(ListComparator cmp); -void list_clear(List *list); -void list_clear_func(List *list, void (*func)(void *key, void *value, void *arg), void *arg); - -bool list_put(List *list, void *key, void *value); -void *list_get_cached(List *list, void *key, void *(*provider)(void *key)); -void list_set(List *list, void *key, void *value); -void *list_get(List *list, void *key); -void *list_delete(List *list, void *key); - -bool list_serialize(int fd, List *list); // ToDo -bool list_deserialize(int fd, List *list); // ToDo - -#endif diff --git a/src/map.h b/src/map.h index c60293f..25827f0 100644 --- a/src/map.h +++ b/src/map.h @@ -3,10 +3,10 @@ #include #include -#include "bintree.h" -#include "list.h" +#include +#include +#include #include "node.h" -#include "types.h" #define MAPBLOCK_SIZE 16 #define ITERATE_MAPBLOCK for (u8 x = 0; x < MAPBLOCK_SIZE; x++) for (u8 y = 0; y < MAPBLOCK_SIZE; y++) for (u8 z = 0; z < MAPBLOCK_SIZE; z++) diff --git a/src/node.h b/src/node.h index 626b5d7..45e5231 100644 --- a/src/node.h +++ b/src/node.h @@ -2,7 +2,7 @@ #define _NODE_H_ #include -#include "types.h" +#include typedef enum { diff --git a/src/perlin.c b/src/perlin.c index 82bff95..d5bd446 100644 --- a/src/perlin.c +++ b/src/perlin.c @@ -1,6 +1,3 @@ #include "perlin.h" -// include perlin submodule implementation -#include - int seed = 0; diff --git a/src/perlin.h b/src/perlin.h index c1af34b..e90b388 100644 --- a/src/perlin.h +++ b/src/perlin.h @@ -1,7 +1,7 @@ #ifndef _PERLIN_H_ #define _PERLIN_H_ -#include // include perlin submodule header file +#include typedef enum { diff --git a/src/queue.c b/src/queue.c deleted file mode 100644 index 04aaccd..0000000 --- a/src/queue.c +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include "queue.h" - -Queue *queue_create() -{ - Queue *queue = malloc(sizeof(Queue)); - queue->list = list_create(NULL); - pthread_mutex_init(&queue->mtx, NULL); - return queue; -} - -void queue_delete(Queue *queue) -{ - pthread_mutex_destroy(&queue->mtx); - list_clear(&queue->list); - free(queue); -} - -void queue_enqueue(Queue *queue, void *elem) -{ - pthread_mutex_lock(&queue->mtx); - list_put(&queue->list, elem, NULL); - pthread_mutex_unlock(&queue->mtx); -} - -void *dequeue(Queue *queue) -{ - return queue_dequeue_callback(queue, NULL); -} - -void *queue_dequeue_callback(Queue *queue, void (*callback)(void *elem)) -{ - pthread_mutex_lock(&queue->mtx); - void *elem = NULL; - ListPair **lptr = &queue->list.first; - if (*lptr) { - elem = (*lptr)->key; - ListPair *next = (*lptr)->next; - free(*lptr); - *lptr = next; - - if (callback) - callback(elem); - } - pthread_mutex_unlock(&queue->mtx); - return elem; -} diff --git a/src/queue.h b/src/queue.h deleted file mode 100644 index d669026..0000000 --- a/src/queue.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _QUEUE_H_ -#define _QUEUE_H_ - -#include -#include "list.h" - -typedef struct -{ - List list; - pthread_mutex_t mtx; -} Queue; - -Queue *queue_create(); -void queue_delete(Queue *queue); -void queue_enqueue(Queue *queue, void *elem); -void *queue_dequeue(Queue *queue); -void *queue_dequeue_callback(Queue *queue, void (*callback)(void *elem)); - -#endif diff --git a/src/server/biomes.h b/src/server/biomes.h index 1481e3f..0cf4881 100644 --- a/src/server/biomes.h +++ b/src/server/biomes.h @@ -1,7 +1,7 @@ #ifndef _BIOMES_H_ #define _BIOMES_H_ -#include "types.h" +#include #include "map.h" #include "perlin.h" diff --git a/src/server/server.h b/src/server/server.h index f9a54c5..f532892 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -3,12 +3,12 @@ #include #include +#include +#include #include "client/client_commands.h" #include "server/database.h" #include "server/server_commands.h" -#include "list.h" #include "network.h" -#include "types.h" typedef struct { diff --git a/src/types.c b/src/types.c deleted file mode 100644 index 4a79da4..0000000 --- a/src/types.c +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include -#include -#include -#include "types.h" - -bool read_full(int fd, char *buffer, size_t size) -{ - size_t n_read_total = 0; - int n_read; - while (n_read_total < size) { - if ((n_read = read(fd, buffer + n_read_total, size - n_read_total)) == -1) { - perror("read"); - return false; - } - n_read_total += n_read; - } - return true; -} - -#define htobe8(x) x -#define be8toh(x) x - -#define READVEC(type, n) \ - type buf[n]; \ - for (int i = 0; i < n; i++) { \ - if (! read_ ## type(fd, &buf[i])) \ - return false; \ - } - -#define WRITEVEC(type, n) \ - for (int i = 0; i < n; i++) { \ - if (! write_ ## type(fd, vec[i])) \ - return false; \ - } \ - return true; - -#define DEFVEC(type) \ - bool read_v2 ## type(int fd, v2 ## type *ptr) \ - { \ - READVEC(type, 2) \ - ptr->x = buf[0]; \ - ptr->y = buf[1]; \ - return true; \ - } \ - bool write_v2 ## type(int fd, v2 ## type val) \ - { \ - type vec[2] = {val.x, val.y}; \ - WRITEVEC(type, 2) \ - } \ - bool v2 ## type ## _equals(v2 ## type a, v2 ## type b) \ - { \ - return a.x == b.x && a.y == b.y; \ - } \ - v2 ## type v2 ## type ## _add(v2 ## type a, v2 ## type b) \ - { \ - return (v2 ## type) {a.x + b.x, a.y + b.y}; \ - } \ - bool read_v3 ## type(int fd, v3 ## type *ptr) \ - { \ - READVEC(type, 3) \ - ptr->x = buf[0]; \ - ptr->y = buf[1]; \ - ptr->z = buf[2]; \ - return true; \ - } \ - bool write_v3 ## type(int fd, v3 ## type val) \ - { \ - type vec[3] = {val.x, val.y, val.z}; \ - WRITEVEC(type, 3) \ - } \ - bool v3 ## type ## _equals(v3 ## type a, v3 ## type b) \ - { \ - return a.x == b.x && a.y == b.y && a.z == b.z; \ - } \ - v3 ## type v3 ## type ## _add(v3 ## type a, v3 ## type b) \ - { \ - return (v3 ## type) {a.x + b.x, a.y + b.y, a.z + b.z}; \ - } - -#define DEFTYP(type, bits) \ - bool read_ ## type(int fd, type *buf) \ - { \ - u ## bits encoded; \ - if (! read_full(fd, (char *) &encoded, sizeof(type))) \ - return false; \ - *buf = be ## bits ## toh(encoded); \ - return true; \ - } \ - bool write_ ## type(int fd, type val) \ - { \ - u ## bits encoded = htobe ## bits(val); \ - if (write(fd, &encoded, sizeof(encoded)) == -1) { \ - perror("write"); \ - return false; \ - } \ - return true; \ - } \ - DEFVEC(type) - -#define DEFTYPES(bits) \ - DEFTYP(s ## bits, bits) \ - DEFTYP(u ## bits, bits) - -DEFTYPES(8) -DEFTYPES(16) -DEFTYPES(32) -DEFTYPES(64) - -#define DEFFLOAT(type) \ - bool read_ ## type(int fd, type *buf) \ - { \ - if (! read_full(fd, (char *) buf, sizeof(type))) \ - return false; \ - return true; \ - } \ - bool write_ ## type(int fd, type val) \ - { \ - if (write(fd, &val, sizeof(val)) == -1) { \ - perror("write"); \ - return false; \ - } \ - return true; \ - } \ - DEFVEC(type) - -DEFFLOAT(f32) -DEFFLOAT(f64) diff --git a/src/types.h b/src/types.h deleted file mode 100644 index 025e661..0000000 --- a/src/types.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _TYPES_H_ -#define _TYPES_H_ - -#include -#include -#include - -bool read_full(int fd, char *buffer, size_t size); - -#define DEFRW(type) \ - bool read_ ## type(int fd, type *ptr); \ - bool write_ ## type(int fd, type val); - -#define DEFBOX(type) \ - typedef struct {v ## type min; v ## type max;} aabb ## type; - -#define DEFVEC(type) \ - typedef struct {type x, y;} v2 ## type; \ - DEFRW(v2 ## type) \ - DEFBOX(2 ## type) \ - bool v2 ## type ## _equals(v2 ## type a, v2 ## type b); \ - v2 ## type v2 ## type ## _add(v2 ## type a, v2 ## type b); \ - typedef struct {type x, y, z;} v3 ## type; \ - DEFRW(v3 ## type) \ - DEFBOX(3 ## type) \ - bool v3 ## type ## _equals(v3 ## type a, v3 ## type b); \ - v3 ## type v3 ## type ## _add(v3 ## type a, v3 ## type b); - -#define DEFTYP(from, to) \ - typedef from to; \ - DEFRW(to) \ - DEFVEC(to) - -#define DEFTYPES(bits) \ - DEFTYP(int ## bits ## _t, s ## bits) \ - DEFTYP(uint ## bits ## _t, u ## bits) - -DEFTYPES(8) -DEFTYPES(16) -DEFTYPES(32) -DEFTYPES(64) - -typedef float f32; -typedef double f64; - -DEFTYP(float, f32) -DEFTYP(double, f64) - -#undef DEFRW -#undef DEFBOX -#undef DEFVEC -#undef DEFTYP -#undef DEFTYPES - -#endif diff --git a/src/util.h b/src/util.h index c2761f6..ec63c1c 100644 --- a/src/util.h +++ b/src/util.h @@ -3,7 +3,7 @@ #include #include -#include "types.h" +#include #define ever (;;) // infinite for loop with style #define INBRACES(str) str ? "(" : "", str ? str : "", str ? ")" : "" // wrapper for printf to optionally add a message in braces if message is not NULL