@@ -168,6 +168,15 @@ void SLIDE(VM* vm, int args);
168168void* allocate(VM* vm, size_t size, int outerlock);
169169// void* allocCon(VM* vm, int arity, int outerlock);
170170
171+// When allocating from C, call 'idris_requireAlloc' with a size to
172+// guarantee that no garbage collection will happen (and hence nothing
173+// will move) until at least size bytes have been allocated.
174+// idris_doneAlloc *must* be called when allocation from C is done (as it
175+// may take a lock if other threads are running).
176+
177+void idris_requireAlloc(VM* vm, size_t size);
178+void idris_doneAlloc(VM* vm);
179+
171180#define allocCon(cl, vm, t, a, o) \
172181 cl = allocate(vm, sizeof(Closure) + sizeof(VAL)*a, o); \
173182 SETTY(cl, CON); \
@@ -222,6 +231,25 @@ VAL idris_getArg(VM* vm, int i);
222231
223232void stackOverflow();
224233
234+// Some FFI help (functions and macros below are all which C code should
235+// use)
236+
237+// When allocating from C, call 'idris_requireAlloc' with a size to
238+// guarantee that no garbage collection will happen (and hence nothing
239+// will move) until at least size bytes have been allocated.
240+// idris_doneAlloc *must* be called when allocation from C is done (as it
241+// may take a lock if other threads are running).
242+
243+void idris_requireAlloc(VM* vm, size_t size);
244+void idris_doneAlloc(VM* vm);
245+
246+// I think these names are nicer for an API...
247+
248+#define idris_constructor allocCon
249+#define idris_setConArg SETARG
250+#define idris_getConArg GETARG
251+#define idris_mkInt(x) MKINT((intptr_t)(x))
252+
225253#include "idris_gmp.h"
226254
227255#endif