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/rules.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/rules.mk') diff --git a/src/rules.mk b/src/rules.mk index 8e8594c..368479c 100644 --- a/src/rules.mk +++ b/src/rules.mk @@ -8,10 +8,10 @@ include $(DIR)/rules.mk DIR := $(d)/base include $(DIR)/rules.mk -# DIR := $(d)/libmath -# include $(DIR)/rules.mk +DIR := $(d)/libmath +include $(DIR)/rules.mk -# DIR := $(d)/libbio -# include $(DIR)/rules.mk +DIR := $(d)/libbio +include $(DIR)/rules.mk include share/pop.mk -- cgit v1.2.1