summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--flake.nix2
-rw-r--r--include/lcq/pit/runtime.h2
-rw-r--r--src/runtime.c6
4 files changed, 12 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index c1283d4..b26cd39 100644
--- a/Makefile
+++ b/Makefile
@@ -3,9 +3,9 @@ EXE ?= pit
CC ?= gcc
AR ?= ar
CHK_SOURCES ?= src/main.c $(SRCS)
-CPPFLAGS ?= -MMD -MP
-CFLAGS ?= -fPIC --std=c99 -g -Ideps/ -Isrc/ -Iinclude/ -Wall -Wextra -Wpedantic -Wconversion -Wformat-security -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wnull-dereference -Wfloat-equal -Wundef -Wpointer-arith -Wbad-function-cast -Wlogical-op -Wmissing-braces -Wcast-align -Wstrict-overflow=5 -ftrapv
-LDFLAGS ?= -g -static
+override CPPFLAGS += -MMD -MP
+override CFLAGS += -fPIC --std=c99 -g -Ideps/ -Isrc/ -Iinclude/ -Wall -Wextra -Wpedantic -Wconversion -Wformat-security -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wnull-dereference -Wfloat-equal -Wundef -Wpointer-arith -Wbad-function-cast -Wlogical-op -Wmissing-braces -Wcast-align -Wstrict-overflow=5 # -ftrapv
+override LDFLAGS += -g -static
BUILD = build_$(CC)
diff --git a/flake.nix b/flake.nix
index 1a57d6f..d886d37 100644
--- a/flake.nix
+++ b/flake.nix
@@ -40,7 +40,7 @@
src = ./.;
hardeningDisable = ["all"];
buildPhase = ''
- make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar libcolonq-pit.a
+ make CPPFLAGS=-DPIT_NO_DOUBLE CC=arm-none-eabi-gcc AR=arm-none-eabi-ar libcolonq-pit.a
'';
installPhase = ''
make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar prefix=$out install-core install-headers
diff --git a/include/lcq/pit/runtime.h b/include/lcq/pit/runtime.h
index d4b1b9e..48e2bcd 100644
--- a/include/lcq/pit/runtime.h
+++ b/include/lcq/pit/runtime.h
@@ -115,8 +115,10 @@ void pit_error(pit_runtime *rt, char *format, ...);
/* working with small values */
pit_value pit_value_new(pit_runtime *rt, enum pit_value_sort s, u64 data);
+#ifndef PIT_NO_DOUBLE
double pit_as_double(pit_runtime *rt, pit_value v);
pit_value pit_double_new(pit_runtime *rt, double d);
+#endif
i64 pit_as_integer(pit_runtime *rt, pit_value v);
pit_value pit_integer_new(pit_runtime *rt, i64 i);
pit_value pit_bool_new(pit_runtime *rt, bool i);
diff --git a/src/runtime.c b/src/runtime.c
index 33c9db6..c382306 100644
--- a/src/runtime.c
+++ b/src/runtime.c
@@ -67,7 +67,11 @@ i64 pit_dump(pit_runtime *rt, char *buf, i64 len, pit_value v, bool readable) {
if (len <= 0) return 0;
switch (pit_value_sort(v)) {
case PIT_VALUE_SORT_DOUBLE:
+ #ifndef PIT_NO_DOUBLE
return pit_string_snprintf(buf, (size_t) len, "%lf", pit_as_double(rt, v));
+ #else
+ return pit_string_snprintf(buf, (size_t) len, "<unsupported double>");
+ #endif
case PIT_VALUE_SORT_INTEGER:
return pit_string_snprintf(buf, (size_t) len, "%ld", pit_as_integer(rt, v));
case PIT_VALUE_SORT_SYMBOL: {
@@ -194,6 +198,7 @@ pit_value pit_value_new(pit_runtime *rt, enum pit_value_sort s, u64 data) {
| (data & 0x1ffffffffffff);
}
+#ifndef PIT_NO_DOUBLE
double pit_as_double(pit_runtime *rt, pit_value v) {
if (pit_value_sort(v) != PIT_VALUE_SORT_DOUBLE) {
pit_error(rt, "invalid use of value as double");
@@ -208,6 +213,7 @@ pit_value pit_double_new(pit_runtime *rt, double d) {
x.dval = d;
return pit_value_new(rt, PIT_VALUE_SORT_DOUBLE, x.ival);
}
+#endif
i64 pit_as_integer(pit_runtime *rt, pit_value v) {
if (pit_value_sort(v) != PIT_VALUE_SORT_INTEGER) {