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
305Sys_announce(vm_registers_t &r, vm_t &vm)305Sys_announce(vm_registers_t &r, vm_t &vm)
306{306{
307 auto &fp = r.stack.peek_frame()->base<F_Sys_announce>();307 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" };
309}309}
310 310
311void311void
312Sys_aprint(vm_registers_t &r, vm_t &vm)312Sys_aprint(vm_registers_t &r, vm_t &vm)
313{313{
314 auto &fp = r.stack.peek_frame()->base<F_Sys_aprint>();314 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" };
316}316}
317 317
318void318void
319Sys_bind(vm_registers_t &r, vm_t &vm)319Sys_bind(vm_registers_t &r, vm_t &vm)
320{320{
321 auto &fp = r.stack.peek_frame()->base<F_Sys_bind>();321 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" };
323}323}
324 324
325void325void
@@ -403,7 +403,7 @@ void · 77 unmodified lines
403Sys_chdir(vm_registers_t &r, vm_t &vm)403Sys_chdir(vm_registers_t &r, vm_t &vm)
404{404{
405 auto &fp = r.stack.peek_frame()->base<F_Sys_chdir>();405 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" };
407}407}
408 408
409void409void
@@ -445,49 +445,48 @@ Sys_create(vm_registers_t &r, vm_t &vm) · 35 unmodified lines
445 }445 }
446 446
447 *fp.ret = fd_alloc->get_allocation();447 *fp.ret = fd_alloc->get_allocation();
448 fd_alloc->add_ref();
449}448}
450 449
451void450void
452Sys_dial(vm_registers_t &r, vm_t &vm)451Sys_dial(vm_registers_t &r, vm_t &vm)
453{452{
454 auto &fp = r.stack.peek_frame()->base<F_Sys_dial>();453 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" };
456}455}
457 456
458void457void
459Sys_dirread(vm_registers_t &r, vm_t &vm)458Sys_dirread(vm_registers_t &r, vm_t &vm)
460{459{
461 auto &fp = r.stack.peek_frame()->base<F_Sys_dirread>();460 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" };
463}462}
464 463
465void464void
466Sys_dup(vm_registers_t &r, vm_t &vm)465Sys_dup(vm_registers_t &r, vm_t &vm)
467{466{
468 auto &fp = r.stack.peek_frame()->base<F_Sys_dup>();467 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" };
470}469}
471 470
472void471void
473Sys_export(vm_registers_t &r, vm_t &vm)472Sys_export(vm_registers_t &r, vm_t &vm)
474{473{
475 auto &fp = r.stack.peek_frame()->base<F_Sys_export>();474 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" };
477}476}
478 477
479void478void
480Sys_fauth(vm_registers_t &r, vm_t &vm)479Sys_fauth(vm_registers_t &r, vm_t &vm)
481{480{
482 auto &fp = r.stack.peek_frame()->base<F_Sys_fauth>();481 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" };
484}483}
485 484
486void485void
487Sys_fd2path(vm_registers_t &r, vm_t &vm)486Sys_fd2path(vm_registers_t &r, vm_t &vm)
488{487{
489 auto &fp = r.stack.peek_frame()->base<F_Sys_fd2path>();488 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" };
491}490}
492 491
493void492void
@@ -510,7 +509,7 @@ void · 16 unmodified lines
510Sys_file2chan(vm_registers_t &r, vm_t &vm)509Sys_file2chan(vm_registers_t &r, vm_t &vm)
511{510{
512 auto &fp = r.stack.peek_frame()->base<F_Sys_file2chan>();511 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" };
514}513}
515 514
516void515void
@@ -532,35 +531,35 @@ void · 15 unmodified lines
532Sys_fstat(vm_registers_t &r, vm_t &vm)531Sys_fstat(vm_registers_t &r, vm_t &vm)
533{532{
534 auto &fp = r.stack.peek_frame()->base<F_Sys_fstat>();533 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" };
536}535}
537 536
538void537void
539Sys_fversion(vm_registers_t &r, vm_t &vm)538Sys_fversion(vm_registers_t &r, vm_t &vm)
540{539{
541 auto &fp = r.stack.peek_frame()->base<F_Sys_fversion>();540 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" };
543}542}
544 543
545void544void
546Sys_fwstat(vm_registers_t &r, vm_t &vm)545Sys_fwstat(vm_registers_t &r, vm_t &vm)
547{546{
548 auto &fp = r.stack.peek_frame()->base<F_Sys_fwstat>();547 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" };
550}549}
551 550
552void551void
553Sys_iounit(vm_registers_t &r, vm_t &vm)552Sys_iounit(vm_registers_t &r, vm_t &vm)
554{553{
555 auto &fp = r.stack.peek_frame()->base<F_Sys_iounit>();554 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" };
557}556}
558 557
559void558void
560Sys_listen(vm_registers_t &r, vm_t &vm)559Sys_listen(vm_registers_t &r, vm_t &vm)
561{560{
562 auto &fp = r.stack.peek_frame()->base<F_Sys_listen>();561 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" };
564}563}
565 564
566void565void
@@ -577,7 +576,7 @@ void · 10 unmodified lines
577Sys_mount(vm_registers_t &r, vm_t &vm)576Sys_mount(vm_registers_t &r, vm_t &vm)
578{577{
579 auto &fp = r.stack.peek_frame()->base<F_Sys_mount>();578 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" };
581}580}
582 581
583void582void
@@ -614,28 +613,27 @@ Sys_open(vm_registers_t &r, vm_t &vm) · 30 unmodified lines
614 }613 }
615 614
616 *fp.ret = fd_alloc->get_allocation();615 *fp.ret = fd_alloc->get_allocation();
617 fd_alloc->add_ref();
618}616}
619 617
620void618void
621Sys_pctl(vm_registers_t &r, vm_t &vm)619Sys_pctl(vm_registers_t &r, vm_t &vm)
622{620{
623 auto &fp = r.stack.peek_frame()->base<F_Sys_pctl>();621 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" };
625}623}
626 624
627void625void
628Sys_pipe(vm_registers_t &r, vm_t &vm)626Sys_pipe(vm_registers_t &r, vm_t &vm)
629{627{
630 auto &fp = r.stack.peek_frame()->base<F_Sys_pipe>();628 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" };
632}630}
633 631
634void632void
635Sys_pread(vm_registers_t &r, vm_t &vm)633Sys_pread(vm_registers_t &r, vm_t &vm)
636{634{
637 auto &fp = r.stack.peek_frame()->base<F_Sys_pread>();635 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" };
639}637}
640 638
641void639void
@@ -654,7 +652,7 @@ void · 12 unmodified lines
654Sys_pwrite(vm_registers_t &r, vm_t &vm)652Sys_pwrite(vm_registers_t &r, vm_t &vm)
655{653{
656 auto &fp = r.stack.peek_frame()->base<F_Sys_pwrite>();654 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" };
658}656}
659 657
660void658void
@@ -691,7 +689,7 @@ void · 30 unmodified lines
691Sys_readn(vm_registers_t &r, vm_t &vm)689Sys_readn(vm_registers_t &r, vm_t &vm)
692{690{
693 auto &fp = r.stack.peek_frame()->base<F_Sys_readn>();691 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" };
695}693}
696 694
697void695void
@@ -760,7 +758,6 @@ Sys_sprint(vm_registers_t &r, vm_t &vm) · 62 unmodified lines
760 new_string = new vm_string_t{ static_cast<std::size_t>(written), reinterpret_cast<uint8_t *>(dynamic_buffer.data()) };758 new_string = new vm_string_t{ static_cast<std::size_t>(written), reinterpret_cast<uint8_t *>(dynamic_buffer.data()) };
761 }759 }
762 760
763 assert(new_string != nullptr);
764 *fp.ret = new_string->get_allocation();761 *fp.ret = new_string->get_allocation();
765}762}
766 763
@@ -768,14 +765,14 @@ void · 1 unmodified line
768Sys_stat(vm_registers_t &r, vm_t &vm)765Sys_stat(vm_registers_t &r, vm_t &vm)
769{766{
770 auto &fp = r.stack.peek_frame()->base<F_Sys_stat>();767 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" };
772}769}
773 770
774void771void
775Sys_stream(vm_registers_t &r, vm_t &vm)772Sys_stream(vm_registers_t &r, vm_t &vm)
776{773{
777 auto &fp = r.stack.peek_frame()->base<F_Sys_stream>();774 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" };
779}776}
780 777
781namespace778namespace
@@ -907,7 +904,7 @@ void · 125 unmodified lines
907Sys_unmount(vm_registers_t &r, vm_t &vm)904Sys_unmount(vm_registers_t &r, vm_t &vm)
908{905{
909 auto &fp = r.stack.peek_frame()->base<F_Sys_unmount>();906 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" };
911}908}
912 909
913void910void
@@ -933,7 +930,14 @@ void · 19 unmodified lines
933Sys_werrstr(vm_registers_t &r, vm_t &vm)930Sys_werrstr(vm_registers_t &r, vm_t &vm)
934{931{
935 auto &fp = r.stack.peek_frame()->base<F_Sys_werrstr>();932 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;
937}941}
938 942
939void943void
@@ -972,5 +976,5 @@ void · 32 unmodified lines
972Sys_wstat(vm_registers_t &r, vm_t &vm)976Sys_wstat(vm_registers_t &r, vm_t &vm)
973{977{
974 auto &fp = r.stack.peek_frame()->base<F_Sys_wstat>();978 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" };
976}980}