on master help sign in
Makefiles and changes needed for the C RTS on the seL4 microkernel
commit5b47f2d172ff3e0a8a09e6c26415df12c7451a46 authorJonas Claeson <jonas.cl@protonmail.com> dateWed 14 Feb 2018, 08:59 (9 years ago) parenta47ec34
6 files changed+83−3
rts/idris_rts.c+3−1 rts/idris_rts.h+4−2 rts/seL4/Kbuild+2 rts/seL4/Kconfig+9 rts/seL4/Makefile+33 rts/seL4/idris_main.c+32
rts/idris_rts.c+3−1
@@ -114,7 +114,7 @@ void init_threaddata(VM *vm) {
114114}
115115
116116void init_signals(void) {
117−#if (__linux__ || __APPLE__ || __FreeBSD__ || __DragonFly__)
117+#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
118118 signal(SIGPIPE, SIG_IGN);
119119#endif
120120}
@@ -1225,6 +1225,7 @@ void idris_disableBuffering(void) {
12251225 setvbuf(stdout, NULL, _IONBF, 0);
12261226}
12271227
1228+#ifndef SEL4
12281229int idris_usleep(int usec) {
12291230 struct timespec t;
12301231 t.tv_sec = usec / 1000000;
@@ -1232,6 +1233,7 @@ int idris_usleep(int usec) {
12321233
12331234 return nanosleep(&t, NULL);
12341235}
1236+#endif // SEL4
12351237
12361238void stackOverflow(void) {
12371239 fprintf(stderr, "Stack overflow");
rts/idris_rts.h+4−2
@@ -9,7 +9,7 @@
99#include <pthread.h>
1010#endif
1111#include <stdint.h>
12−#if (__linux__ || __APPLE__ || __FreeBSD__ || __DragonFly__)
12+#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
1313#include <signal.h>
1414#endif
1515
@@ -245,7 +245,7 @@ typedef intptr_t i_int;
245245#endif
246246
247247#define INITFRAME TRACE\
248− VAL* myoldbase
248+ __attribute__((unused)) VAL* myoldbase
249249
250250#define REBASE vm->valstack_base = oldbase
251251#define RESERVE(x) if (vm->valstack_top+(x) > vm->stack_max) { stackOverflow(); } \
@@ -442,7 +442,9 @@ const char *idris_getArg(int i);
442442// disable stdin/stdout buffering
443443void idris_disableBuffering(void);
444444
445+#ifndef SEL4
445446int idris_usleep(int usec);
447+#endif // SEL4
446448
447449// Handle stack overflow.
448450// Just reports an error and exits.
rts/seL4/Kbuildnew file+2
@@ -0,0 +1,2 @@
1+libsel4-idris-rts: $(libc) common
2+libs-$(CONFIG_LIBSEL4_IDRIS_RTS) += libsel4-idris-rts
rts/seL4/Kconfignew file+9
@@ -0,0 +1,9 @@
1+config LIBSEL4_IDRIS_RTS
2+ bool "libsel4-idris-rts"
3+ default y
4+ select HAVE_LIBSEL4_IDRIS_RTS
5+ help
6+ Idris RTS compiled for seL4
7+
8+config HAVE_LIBSEL4_IDRIS_RTS
9+ bool
rts/seL4/Makefilenew file+33
@@ -0,0 +1,33 @@
1+# Target
2+TARGETS := libsel4-idris-rts.a
3+
4+# Source files required to build the target
5+FILES := \
6+ idris_rts.c \
7+ idris_heap.c \
8+ idris_gc.c \
9+ idris_gmp.c \
10+ idris_bitstring.c \
11+ idris_opts.c \
12+ idris_stats.c \
13+ idris_utf8.c \
14+ idris_stdfgn.c \
15+ mini-gmp.c \
16+ idris_buffer.c \
17+ getline.c \
18+ idris_net.c \
19+ seL4/idris_main.c
20+CFILES := $(addprefix rts/,$(FILES))
21+
22+# Header file directory this library provides
23+HDRFILES := $(wildcard ${SOURCE_DIR}/rts/*)
24+
25+CFLAGS += -W -Wall
26+# Don't use the host machines' environment when cross compiling
27+CFLAGS += -undef
28+CFLAGS += -DIDRIS_TARGET_OS=\"seL4\"
29+CFLAGS += -DSEL4
30+MACHINE := $(shell $(CC) -dumpmachine)
31+CFLAGS += -DIDRIS_TARGET_TRIPLE=\"$(MACHINE)\"
32+
33+include $(SEL4_COMMON)/common.mk
rts/seL4/idris_main.cnew file+32
@@ -0,0 +1,32 @@
1+#include "idris_gmp.h"
2+#include "idris_opts.h"
3+#include "idris_rts.h"
4+#include "idris_stats.h"
5+
6+void _idris__123_runMain_95_0_125_(VM* vm, VAL* oldbase);
7+
8+RTSOpts opts = {
9+ .init_heap_size = 16384000,
10+ .max_stack_size = 4096000,
11+ .show_summary = 0
12+};
13+
14+int main() {
15+ VM* vm = init_vm(opts.max_stack_size, opts.init_heap_size, 1);
16+ init_gmpalloc();
17+ init_nullaries();
18+
19+ _idris__123_runMain_95_0_125_(vm, NULL);
20+
21+#ifdef IDRIS_DEBUG
22+ if (opts.show_summary) {
23+ idris_gcInfo(vm, 1);
24+ }
25+#endif
26+
27+ free_nullaries();
28+ // Remove call to terminate since it crashes the application during a free
29+ //Stats stats = terminate(vm);
30+
31+ return EXIT_SUCCESS;
32+}