aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/print.h4
-rw-r--r--src/stdlib/stdlib.h15
-rw-r--r--src/stdlib/util.h8
3 files changed, 20 insertions, 7 deletions
diff --git a/src/stdlib/print.h b/src/stdlib/print.h
index 60c9c139..243826e0 100644
--- a/src/stdlib/print.h
+++ b/src/stdlib/print.h
@@ -33,8 +33,12 @@
// GCC lets you define macro-like functions which are always inlined and never
// compiled using this combination of flags. See: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
#ifndef PRINT_FN
+#ifdef __TINYC__
+#define PRINT_FN static inline __attribute__((gnu_inline, always_inline)) int
+#else
#define PRINT_FN extern inline __attribute__((gnu_inline, always_inline)) int
#endif
+#endif
typedef struct {
uint64_t n;
diff --git a/src/stdlib/stdlib.h b/src/stdlib/stdlib.h
index ae2079e3..a452a04b 100644
--- a/src/stdlib/stdlib.h
+++ b/src/stdlib/stdlib.h
@@ -68,16 +68,21 @@ __attribute__((nonnull))
void start_inspect(const char *filename, int64_t start, int64_t end);
__attribute__((nonnull))
void end_inspect(const void *expr, const TypeInfo_t *type);
-#define inspect(expr, typeinfo, start, end) {\
+#define inspect(type, expr, typeinfo, start, end) {\
start_inspect(__SOURCE_FILE__, start, end); \
- auto _expr = expr; \
+ type _expr = expr; \
end_inspect(&_expr, typeinfo); \
}
+#define inspect_void(expr, typeinfo, start, end) {\
+ start_inspect(__SOURCE_FILE__, start, end); \
+ expr; \
+ end_inspect(NULL, typeinfo); \
+}
__attribute__((nonnull))
void test_value(const char *filename, int64_t start, int64_t end, const void *expr, const void *expected, const TypeInfo_t *type);
-#define test(expr, expected, typeinfo, start, end) {\
- auto _expr = expr; \
- auto _expected = expected; \
+#define test(type, expr, expected, typeinfo, start, end) {\
+ type _expr = expr; \
+ type _expected = expected; \
test_value(__SOURCE_FILE__, start, end, &_expr, &_expected, typeinfo); \
}
diff --git a/src/stdlib/util.h b/src/stdlib/util.h
index 45bf1d7b..4cb1b375 100644
--- a/src/stdlib/util.h
+++ b/src/stdlib/util.h
@@ -19,12 +19,12 @@
#define IF_DECLARE(decl, expr, block) if (({ decl; expr ? ({ block; 1; }) : 0; })) {}
-#define WHEN(subj, var, body) { auto var = subj; switch (var.$tag) body }
-
#ifndef auto
#define auto __auto_type
#endif
+#define WHEN(type, subj, var, body) { type var = subj; switch (var.$tag) body }
+
#ifndef public
#define public __attribute__ ((visibility ("default")))
#endif
@@ -52,7 +52,11 @@
// GCC lets you define macro-like functions which are always inlined and never
// compiled using this combination of flags. See: https://gcc.gnu.org/onlinedocs/gcc/Inline.html
#ifndef MACROLIKE
+#ifdef __TINYC__
+#define MACROLIKE static inline __attribute__((gnu_inline, always_inline))
+#else
#define MACROLIKE extern inline __attribute__((gnu_inline, always_inline))
#endif
+#endif
// vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0