summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-03-05 21:10:01 +0100
committerMitya Selivanov <automainint@guattari.tech>2024-03-05 21:10:01 +0100
commita6306300bbe624746d036ba5c017e43472156301 (patch)
tree5394bdb66c9acd53f44a6465863e114e0489447e
parentb6e6d56dc5ab4e5071f4cbca2a44f707f61356f9 (diff)
downloadkit-a6306300bbe624746d036ba5c017e43472156301.zip
Remove defer
-rw-r--r--compile_flags.txt1
-rw-r--r--source/kit/defer.h39
-rw-r--r--source/tests/_exe.c1
-rw-r--r--source/tests/defer.test.c37
4 files changed, 1 insertions, 77 deletions
diff --git a/compile_flags.txt b/compile_flags.txt
new file mode 100644
index 0000000..b2644d9
--- /dev/null
+++ b/compile_flags.txt
@@ -0,0 +1 @@
+-Wall -Wextra -Werror -Isource
diff --git a/source/kit/defer.h b/source/kit/defer.h
deleted file mode 100644
index bb78b69..0000000
--- a/source/kit/defer.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Requres GCC or Clang with `-fblocks` option available.
-//
-
-#ifndef KIT_DEFER_H
-#define KIT_DEFER_H
-
-#if !defined(__clang__) && !defined(__APPLE__)
-# error C blocks support required
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(__GNUC__) || defined(__clang__)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wunused-function"
-# pragma GCC diagnostic ignored "-Wunknown-pragmas"
-#endif
-
-static void kit_defer_cleanup_(void (^*b)(void)) { (*b)(); }
-
-#define kit_defer_merge_(a,b) a##b
-#define kit_defer_varname_(a) \
- kit_defer_merge_(kit_defer_scopevar_,a)
-#define defer \
- __attribute__((unused, cleanup(kit_defer_cleanup_))) \
- void (^kit_defer_varname_(__COUNTER__))(void) = ^
-#define defer_ref __block
-
-#if defined(__GNUC__) || defined(__clang__)
-# pragma GCC diagnostic pop
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source/tests/_exe.c b/source/tests/_exe.c
index acbe5c2..1c59ba2 100644
--- a/source/tests/_exe.c
+++ b/source/tests/_exe.c
@@ -21,7 +21,6 @@
#include "string_ref.test.c"
#include "duration.test.c"
#include "thread.test.c"
-#include "defer.test.c"
#include "xml.test.c"
#include "http1.test.c"
#include "bench.test.c"
diff --git a/source/tests/defer.test.c b/source/tests/defer.test.c
deleted file mode 100644
index 0eb8557..0000000
--- a/source/tests/defer.test.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#if defined(__clang__) || defined(__APPLE__)
-# include "../kit/defer.h"
-
-# define KIT_TEST_FILE defer_block
-# include "../kit/test.h"
-
-TEST("defer") {
- int defer_ref x = 1;
-
- {
- defer {
- x = 2;
- };
-
- x = 3;
- }
-
- REQUIRE_EQ(x, 2);
-}
-
-TEST("defer capture") {
- int defer_ref x = 1;
-
- {
- defer {
- if (x == 3)
- x = 2;
- };
-
- x = 3;
- }
-
- REQUIRE_EQ(x, 2);
-}
-
-# undef KIT_TEST_FILE
-#endif