From c9a32c1a43d2bdded07eaa45732c3a6e195a5442 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Sat, 20 Nov 2021 17:07:23 -0800 Subject: Chore: cleaned up the exit code to cleanly interface with libc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We use weak linking to ensure we clean up at exit time correctly. If libc is linked, then we call our cleanup function by registering an atexit callback with the library. If libc is not linked, we have a weak symbol that results in a noop. Similarly, if we call rt·exit while linked with libc, this immediately calls libc's exit (which will call our cleanup as we registered it). If we are not linked to libc, exit() is given as a weak link to a noop function. --- src/base/io/interface.c | 2 +- src/base/io/seek.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/base/io') diff --git a/src/base/io/interface.c b/src/base/io/interface.c index bc9d5ff..80469bf 100644 --- a/src/base/io/interface.c +++ b/src/base/io/interface.c @@ -44,7 +44,7 @@ int static int -·seek(void *skr, long off, enum SeekPos whence) +·seek(void *skr, long off, int whence) { return io·seek((io·Stream *)skr, off, whence); } diff --git a/src/base/io/seek.c b/src/base/io/seek.c index d0e7488..1be4ee7 100644 --- a/src/base/io/seek.c +++ b/src/base/io/seek.c @@ -1,7 +1,7 @@ #include "internal.h" int -io·seek(io·Stream *s, long off, enum SeekPos origin) +io·seek(io·Stream *s, long off, int whence) { - return fseek(s, off, origin); + return fseek(s, off, whence); } -- cgit v1.2.1