diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/kit/defer.h | 39 | ||||
-rw-r--r-- | source/tests/_exe.c | 1 | ||||
-rw-r--r-- | source/tests/defer.test.c | 37 |
3 files changed, 0 insertions, 77 deletions
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 |