1.1 --- a/lib/sys.py Thu Nov 10 18:19:17 2016 +0100
1.2 +++ b/lib/sys.py Thu Nov 10 18:49:15 2016 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 System functions and objects.
1.6
1.7 -Copyright (C) 2008, 2012, 2014 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2008, 2012, 2014, 2016 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -19,6 +19,8 @@
1.13 this program. If not, see <http://www.gnu.org/licenses/>.
1.14 """
1.15
1.16 +from native import _exit
1.17 +
1.18 # Placeholders for run-time data.
1.19
1.20 stdin = file()
1.21 @@ -36,6 +38,6 @@
1.22 # Functions to be implemented natively.
1.23
1.24 def exit(status=0):
1.25 - pass
1.26 + _exit(int(status))
1.27
1.28 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/templates/native.c Thu Nov 10 18:19:17 2016 +0100
2.2 +++ b/templates/native.c Thu Nov 10 18:49:15 2016 +0100
2.3 @@ -1,4 +1,4 @@
2.4 -#include <stdlib.h>
2.5 +#include <stdlib.h> /* calloc, exit */
2.6 #include "types.h"
2.7 #include "exceptions.h"
2.8 #include "ops.h"
2.9 @@ -7,6 +7,17 @@
2.10 #include "progtypes.h"
2.11 #include "main.h"
2.12
2.13 +/* Native functions. */
2.14 +
2.15 +__attr __fn_native__exit(__attr __args[])
2.16 +{
2.17 + #define status (__args[1])
2.18 +
2.19 + exit(__load_via_object(status.value, __pos___data__).intvalue);
2.20 + return __builtins___none_None;
2.21 + #undef status
2.22 +}
2.23 +
2.24 __attr __fn_native__is(__attr __args[])
2.25 {
2.26 #define x (__args[1])
3.1 --- a/templates/native.h Thu Nov 10 18:19:17 2016 +0100
3.2 +++ b/templates/native.h Thu Nov 10 18:49:15 2016 +0100
3.3 @@ -1,6 +1,9 @@
3.4 #ifndef __NATIVE_H__
3.5 #define __NATIVE_H__
3.6
3.7 +/* Native functions. */
3.8 +
3.9 +__attr __fn_native__exit(__attr __args[]);
3.10 __attr __fn_native__is(__attr __args[]);
3.11 __attr __fn_native__is_not(__attr __args[]);
3.12 __attr __fn_native__int_add(__attr __args[]);