1 /* Native functions for system operations. 2 3 Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk> 4 5 This program is free software; you can redistribute it and/or modify it under 6 the terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3 of the License, or (at your option) any later 8 version. 9 10 This program is distributed in the hope that it will be useful, but WITHOUT 11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 13 details. 14 15 You should have received a copy of the GNU General Public License along with 16 this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #include <stdlib.h> /* abs, exit */ 20 #include <string.h> /* strlen */ 21 #include "types.h" 22 #include "common.h" 23 #include "exceptions.h" 24 #include "ops.h" 25 #include "progconsts.h" 26 #include "progops.h" 27 #include "progtypes.h" 28 #include "main.h" 29 30 /* Environment support. */ 31 32 extern int __argc; 33 extern char **__argv; 34 35 __attr __fn_native_system_exit(__attr __self, __attr status) 36 { 37 exit(__TOINT(status)); 38 return __builtins___none_None; 39 } 40 41 __attr __fn_native_system_get_argv(__attr __self) 42 { 43 __attr args[__argc]; 44 unsigned int i; 45 46 for (i = 0; i < __argc; i++) 47 args[i] = __new_str(__argv[i], strlen(__argv[i])); 48 49 return __newdata_list(__argc, args); 50 } 51 52 __attr __fn_native_system_get_path(__attr __self) 53 { 54 /* NOTE: To be written. */ 55 return __builtins___none_None; 56 } 57 58 /* Module initialisation. */ 59 60 void __main_native_system() 61 { 62 }