@@ -1,101 +0,0 @@
1−#include "../idris_stdfgn.h"
2−#include "../idris_rts.h"
3−#include "../idris_gc.h"
4−
5−#include <fcntl.h>
6−#include <stdio.h>
7−#include <time.h>
8−#include <io.h>
9−
10−extern char** environ;
11−
12−int win_fpoll(void* h);
13−
14−void putStr(char* str) {
15− printf("%s", str);
16−}
17−
18−void* fileOpen(char* name, char* mode) {
19− FILE* f = fopen(name, mode);
20− return (void*)f;
21−}
22−
23−void fileClose(void* h) {
24− FILE* f = (FILE*)h;
25− fclose(f);
26−}
27−
28−int fileEOF(void* h) {
29− FILE* f = (FILE*)h;
30− return feof(f);
31−}
32−
33−int fileError(void* h) {
34− FILE* f = (FILE*)h;
35− return ferror(f);
36−}
37−
38−int idris_writeStr(void* h, char* str) {
39− FILE* f = (FILE*)h;
40− if (fputs(str, f)) {
41− return 0;
42− } else {
43− return -1;
44− }
45−}
46−
47−int fpoll(void* h)
48−{
49− return win_fpoll(h);
50−}
51−
52−void* do_popen(const char* cmd, const char* mode) {
53− FILE* f = _popen(cmd, mode);
54−// int d = fileno(f);
55−// fcntl(d, F_SETFL, O_NONBLOCK);
56− return f;
57−}
58−
59−int isNull(void* ptr) {
60− return ptr==NULL;
61−}
62−
63−int idris_eqPtr(void* x, void* y) {
64− return x==y;
65−}
66−
67−void* idris_stdin() {
68− return (void*)stdin;
69−}
70−
71−char* getEnvPair(int i) {
72− return *(environ + i);
73−}
74−
75−VAL idris_time() {
76− time_t t = time(NULL);
77− return MKBIGI(t);
78−}
79−
80−VAL idris_mkFileError(VM* vm) {
81− VAL result;
82− switch(errno) {
83− // Make sure this corresponds to the FileError structure in
84− // Prelude.File
85− case ENOENT:
86− idris_constructor(result, vm, 2, 0, 0);
87− break;
88− case EACCES:
89− idris_constructor(result, vm, 3, 0, 0);
90− break;
91− default:
92− idris_constructor(result, vm, 4, 1, 0);
93− idris_setConArg(result, 0, MKINT((intptr_t)errno));
94− break;
95− }
96− return result;
97−}
98−
99−void idris_forceGC(void* vm) {
100− idris_gc((VM*)vm);
101−}