VM: better init of stdin, stdout and stderr
parent
40c277499d
commit
e4bdbf1503
|
@ -71,13 +71,15 @@ void factor_vm::init_factor(vm_parameters* p) {
|
||||||
init_contexts(p->datastack_size, p->retainstack_size, p->callstack_size);
|
init_contexts(p->datastack_size, p->retainstack_size, p->callstack_size);
|
||||||
callbacks = new callback_heap(p->callback_size, this);
|
callbacks = new callback_heap(p->callback_size, this);
|
||||||
load_image(p);
|
load_image(p);
|
||||||
init_c_io();
|
|
||||||
max_pic_size = (int)p->max_pic_size;
|
max_pic_size = (int)p->max_pic_size;
|
||||||
special_objects[OBJ_CELL_SIZE] = tag_fixnum(sizeof(cell));
|
special_objects[OBJ_CELL_SIZE] = tag_fixnum(sizeof(cell));
|
||||||
special_objects[OBJ_ARGS] = false_object;
|
special_objects[OBJ_ARGS] = false_object;
|
||||||
special_objects[OBJ_EMBEDDED] = false_object;
|
special_objects[OBJ_EMBEDDED] = false_object;
|
||||||
|
|
||||||
cell aliens[][2] = {
|
cell aliens[][2] = {
|
||||||
|
{OBJ_STDIN, (cell)stdin},
|
||||||
|
{OBJ_STDOUT, (cell)stdout},
|
||||||
|
{OBJ_STDERR, (cell)stderr},
|
||||||
{OBJ_CPU, (cell)FACTOR_CPU_STRING},
|
{OBJ_CPU, (cell)FACTOR_CPU_STRING},
|
||||||
{OBJ_EXECUTABLE, (cell)safe_strdup(p->executable_path)},
|
{OBJ_EXECUTABLE, (cell)safe_strdup(p->executable_path)},
|
||||||
{OBJ_IMAGE, (cell)safe_strdup(p->image_path)},
|
{OBJ_IMAGE, (cell)safe_strdup(p->image_path)},
|
||||||
|
|
|
@ -41,13 +41,6 @@ int raw_fclose(FILE* stream) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void factor_vm::init_c_io() {
|
|
||||||
special_objects[OBJ_STDIN] = allot_alien(false_object, (cell)stdin);
|
|
||||||
special_objects[OBJ_STDOUT] = allot_alien(false_object, (cell)stdout);
|
|
||||||
special_objects[OBJ_STDERR] = allot_alien(false_object, (cell)stderr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocates memory
|
// Allocates memory
|
||||||
void factor_vm::io_error_if_not_EINTR() {
|
void factor_vm::io_error_if_not_EINTR() {
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
|
|
|
@ -527,7 +527,6 @@ struct factor_vm {
|
||||||
}
|
}
|
||||||
|
|
||||||
// io
|
// io
|
||||||
void init_c_io();
|
|
||||||
void io_error_if_not_EINTR();
|
void io_error_if_not_EINTR();
|
||||||
FILE* safe_fopen(char* filename, const char* mode);
|
FILE* safe_fopen(char* filename, const char* mode);
|
||||||
int safe_fgetc(FILE* stream);
|
int safe_fgetc(FILE* stream);
|
||||||
|
|
Loading…
Reference in New Issue