hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit fa782ec3f9f9c697092f31688977ac56e73ac0ae
parent 5b0f6d2d07b674f65c30a8eeccfc5fd33bc9545c
Author: Sebastian LaVine <mail@smlavine.com>
Date:   Tue, 13 Dec 2022 21:02:13 -0500

Add os::status

This is analagous to EXIT_SUCCESS and EXIT_FAILURE in C. It is clearer
and more portable than using constants like 0 or 1 directly.

The documentation line was copied in part from the Linux man-page for
exit(3)[0].

[0]: https://www.man7.org/linux/man-pages/man3/exit.3.html

Signed-off-by: Sebastian LaVine <mail@smlavine.com>

Diffstat:
Mos/+freebsd/exit.ha | 7+++++++
Mos/+linux/exit.ha | 7+++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/os/+freebsd/exit.ha b/os/+freebsd/exit.ha @@ -2,6 +2,13 @@ // (c) 2021 Drew DeVault <sir@cmpwn.com> use rt; +// Values that may be passed to [[exit]] to indicate successful or unsuccessful +// termination, respectively. +export type status = enum { + SUCCESS = 0, + FAILURE = 1, +}; + // Exit the program with the provided status code. export @noreturn fn exit(status: int) void = { rt::fini(); diff --git a/os/+linux/exit.ha b/os/+linux/exit.ha @@ -2,6 +2,13 @@ // (c) 2021 Drew DeVault <sir@cmpwn.com> use rt; +// Values that may be passed to [[exit]] to indicate successful or unsuccessful +// termination, respectively. +export type status = enum { + SUCCESS = 0, + FAILURE = 1, +}; + // Exit the program with the provided status code. export @noreturn fn exit(status: int) void = { rt::fini();