History

Sys module updates - address bug with leaving FD - Change error message for not implemented functions.

arr committed 9 years ago

Commit 5520e671 parent b77c2761 file · +34 −30Browse files

Showing the changes to src/vm/sys/Sysmod.cpp (1 of 1 file). Show all

Unified · Split

src/vm/sys/Sysmod.cpp+34−30
@@ -305,21 +305,21 @@ void · 304 unmodified lines
305305 Sys_announce(vm_registers_t &r, vm_t &vm)
306306 {
307307 auto &fp = r.stack.peek_frame()->base<F_Sys_announce>();
308− throw vm_system_exception{ "Instruction not implemented" };
308+ throw vm_system_exception{ "Function not implemented" };
309309 }
310310
311311 void
312312 Sys_aprint(vm_registers_t &r, vm_t &vm)
313313 {
314314 auto &fp = r.stack.peek_frame()->base<F_Sys_aprint>();
315− throw vm_system_exception{ "Instruction not implemented" };
315+ throw vm_system_exception{ "Function not implemented" };
316316 }
317317
318318 void
319319 Sys_bind(vm_registers_t &r, vm_t &vm)
320320 {
321321 auto &fp = r.stack.peek_frame()->base<F_Sys_bind>();
322− throw vm_system_exception{ "Instruction not implemented" };
322+ throw vm_system_exception{ "Function not implemented" };
323323 }
324324
325325 void
@@ -403,7 +403,7 @@ void · 77 unmodified lines
403403 Sys_chdir(vm_registers_t &r, vm_t &vm)
404404 {
405405 auto &fp = r.stack.peek_frame()->base<F_Sys_chdir>();
406− throw vm_system_exception{ "Instruction not implemented" };
406+ throw vm_system_exception{ "Function not implemented" };
407407 }
408408
409409 void
@@ -445,49 +445,48 @@ Sys_create(vm_registers_t &r, vm_t &vm) · 35 unmodified lines
445445 }
446446
447447 *fp.ret = fd_alloc->get_allocation();
448− fd_alloc->add_ref();
449448 }
450449
451450 void
452451 Sys_dial(vm_registers_t &r, vm_t &vm)
453452 {
454453 auto &fp = r.stack.peek_frame()->base<F_Sys_dial>();
455− throw vm_system_exception{ "Instruction not implemented" };
454+ throw vm_system_exception{ "Function not implemented" };
456455 }
457456
458457 void
459458 Sys_dirread(vm_registers_t &r, vm_t &vm)
460459 {
461460 auto &fp = r.stack.peek_frame()->base<F_Sys_dirread>();
462− throw vm_system_exception{ "Instruction not implemented" };
461+ throw vm_system_exception{ "Function not implemented" };
463462 }
464463
465464 void
466465 Sys_dup(vm_registers_t &r, vm_t &vm)
467466 {
468467 auto &fp = r.stack.peek_frame()->base<F_Sys_dup>();
469− throw vm_system_exception{ "Instruction not implemented" };
468+ throw vm_system_exception{ "Function not implemented" };
470469 }
471470
472471 void
473472 Sys_export(vm_registers_t &r, vm_t &vm)
474473 {
475474 auto &fp = r.stack.peek_frame()->base<F_Sys_export>();
476− throw vm_system_exception{ "Instruction not implemented" };
475+ throw vm_system_exception{ "Function not implemented" };
477476 }
478477
479478 void
480479 Sys_fauth(vm_registers_t &r, vm_t &vm)
481480 {
482481 auto &fp = r.stack.peek_frame()->base<F_Sys_fauth>();
483− throw vm_system_exception{ "Instruction not implemented" };
482+ throw vm_system_exception{ "Function not implemented" };
484483 }
485484
486485 void
487486 Sys_fd2path(vm_registers_t &r, vm_t &vm)
488487 {
489488 auto &fp = r.stack.peek_frame()->base<F_Sys_fd2path>();
490− throw vm_system_exception{ "Instruction not implemented" };
489+ throw vm_system_exception{ "Function not implemented" };
491490 }
492491
493492 void
@@ -510,7 +509,7 @@ void · 16 unmodified lines
510509 Sys_file2chan(vm_registers_t &r, vm_t &vm)
511510 {
512511 auto &fp = r.stack.peek_frame()->base<F_Sys_file2chan>();
513− throw vm_system_exception{ "Instruction not implemented" };
512+ throw vm_system_exception{ "Function not implemented" };
514513 }
515514
516515 void
@@ -532,35 +531,35 @@ void · 15 unmodified lines
532531 Sys_fstat(vm_registers_t &r, vm_t &vm)
533532 {
534533 auto &fp = r.stack.peek_frame()->base<F_Sys_fstat>();
535− throw vm_system_exception{ "Instruction not implemented" };
534+ throw vm_system_exception{ "Function not implemented" };
536535 }
537536
538537 void
539538 Sys_fversion(vm_registers_t &r, vm_t &vm)
540539 {
541540 auto &fp = r.stack.peek_frame()->base<F_Sys_fversion>();
542− throw vm_system_exception{ "Instruction not implemented" };
541+ throw vm_system_exception{ "Function not implemented" };
543542 }
544543
545544 void
546545 Sys_fwstat(vm_registers_t &r, vm_t &vm)
547546 {
548547 auto &fp = r.stack.peek_frame()->base<F_Sys_fwstat>();
549− throw vm_system_exception{ "Instruction not implemented" };
548+ throw vm_system_exception{ "Function not implemented" };
550549 }
551550
552551 void
553552 Sys_iounit(vm_registers_t &r, vm_t &vm)
554553 {
555554 auto &fp = r.stack.peek_frame()->base<F_Sys_iounit>();
556− throw vm_system_exception{ "Instruction not implemented" };
555+ throw vm_system_exception{ "Function not implemented" };
557556 }
558557
559558 void
560559 Sys_listen(vm_registers_t &r, vm_t &vm)
561560 {
562561 auto &fp = r.stack.peek_frame()->base<F_Sys_listen>();
563− throw vm_system_exception{ "Instruction not implemented" };
562+ throw vm_system_exception{ "Function not implemented" };
564563 }
565564
566565 void
@@ -577,7 +576,7 @@ void · 10 unmodified lines
577576 Sys_mount(vm_registers_t &r, vm_t &vm)
578577 {
579578 auto &fp = r.stack.peek_frame()->base<F_Sys_mount>();
580− throw vm_system_exception{ "Instruction not implemented" };
579+ throw vm_system_exception{ "Function not implemented" };
581580 }
582581
583582 void
@@ -614,28 +613,27 @@ Sys_open(vm_registers_t &r, vm_t &vm) · 30 unmodified lines
614613 }
615614
616615 *fp.ret = fd_alloc->get_allocation();
617− fd_alloc->add_ref();
618616 }
619617
620618 void
621619 Sys_pctl(vm_registers_t &r, vm_t &vm)
622620 {
623621 auto &fp = r.stack.peek_frame()->base<F_Sys_pctl>();
624− throw vm_system_exception{ "Instruction not implemented" };
622+ throw vm_system_exception{ "Function not implemented" };
625623 }
626624
627625 void
628626 Sys_pipe(vm_registers_t &r, vm_t &vm)
629627 {
630628 auto &fp = r.stack.peek_frame()->base<F_Sys_pipe>();
631− throw vm_system_exception{ "Instruction not implemented" };
629+ throw vm_system_exception{ "Function not implemented" };
632630 }
633631
634632 void
635633 Sys_pread(vm_registers_t &r, vm_t &vm)
636634 {
637635 auto &fp = r.stack.peek_frame()->base<F_Sys_pread>();
638− throw vm_system_exception{ "Instruction not implemented" };
636+ throw vm_system_exception{ "Function not implemented" };
639637 }
640638
641639 void
@@ -654,7 +652,7 @@ void · 12 unmodified lines
654652 Sys_pwrite(vm_registers_t &r, vm_t &vm)
655653 {
656654 auto &fp = r.stack.peek_frame()->base<F_Sys_pwrite>();
657− throw vm_system_exception{ "Instruction not implemented" };
655+ throw vm_system_exception{ "Function not implemented" };
658656 }
659657
660658 void
@@ -691,7 +689,7 @@ void · 30 unmodified lines
691689 Sys_readn(vm_registers_t &r, vm_t &vm)
692690 {
693691 auto &fp = r.stack.peek_frame()->base<F_Sys_readn>();
694− throw vm_system_exception{ "Instruction not implemented" };
692+ throw vm_system_exception{ "Function not implemented" };
695693 }
696694
697695 void
@@ -760,7 +758,6 @@ Sys_sprint(vm_registers_t &r, vm_t &vm) · 62 unmodified lines
760758 new_string = new vm_string_t{ static_cast<std::size_t>(written), reinterpret_cast<uint8_t *>(dynamic_buffer.data()) };
761759 }
762760
763− assert(new_string != nullptr);
764761 *fp.ret = new_string->get_allocation();
765762 }
766763
@@ -768,14 +765,14 @@ void · 1 unmodified line
768765 Sys_stat(vm_registers_t &r, vm_t &vm)
769766 {
770767 auto &fp = r.stack.peek_frame()->base<F_Sys_stat>();
771− throw vm_system_exception{ "Instruction not implemented" };
768+ throw vm_system_exception{ "Function not implemented" };
772769 }
773770
774771 void
775772 Sys_stream(vm_registers_t &r, vm_t &vm)
776773 {
777774 auto &fp = r.stack.peek_frame()->base<F_Sys_stream>();
778− throw vm_system_exception{ "Instruction not implemented" };
775+ throw vm_system_exception{ "Function not implemented" };
779776 }
780777
781778 namespace
@@ -907,7 +904,7 @@ void · 125 unmodified lines
907904 Sys_unmount(vm_registers_t &r, vm_t &vm)
908905 {
909906 auto &fp = r.stack.peek_frame()->base<F_Sys_unmount>();
910− throw vm_system_exception{ "Instruction not implemented" };
907+ throw vm_system_exception{ "Function not implemented" };
911908 }
912909
913910 void
@@ -933,7 +930,14 @@ void · 19 unmodified lines
933930 Sys_werrstr(vm_registers_t &r, vm_t &vm)
934931 {
935932 auto &fp = r.stack.peek_frame()->base<F_Sys_werrstr>();
936− throw vm_system_exception{ "Instruction not implemented" };
933+
934+ auto new_err = "";
935+ auto s = vm_alloc_t::from_allocation<vm_string_t>(fp.s);
936+ if (s != nullptr)
937+ new_err = s->str();
938+
939+ push_syscall_error_message(vm, new_err);
940+ *fp.ret = 0;
937941 }
938942
939943 void
@@ -972,5 +976,5 @@ void · 32 unmodified lines
972976 Sys_wstat(vm_registers_t &r, vm_t &vm)
973977 {
974978 auto &fp = r.stack.peek_frame()->base<F_Sys_wstat>();
975− throw vm_system_exception{ "Instruction not implemented" };
979+ throw vm_system_exception{ "Function not implemented" };
976980 }