From f9ee81f3b13103f308a95cb1e48f5f4a16751559 Mon Sep 17 00:00:00 2001 From: Randy Jordan Date: Mon, 11 May 2026 21:17:32 -0500 Subject: [PATCH] README and tidy up exceptions --- README.md | 3 ++- include/ci2_exception.h | 13 ++++++------- ...linux_ci2_exceptions.c => linux_ci2_exception.c} | 2 +- ...win32_ci2_exceptions.c => win32_ci2_exception.c} | 4 +--- 4 files changed, 10 insertions(+), 12 deletions(-) rename src/{linux_ci2_exceptions.c => linux_ci2_exception.c} (95%) rename src/{win32_ci2_exceptions.c => win32_ci2_exception.c} (96%) diff --git a/README.md b/README.md index 92662ed..95a7adf 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,8 @@ the platform layer prefix. - [x] Static Assertions - [x] Basic Assertions - [ ] Add failure flag to cause failure. -- [ ] Exceptions & Errors +- [x] Exceptions & Errors + -[ ] Add failure flag to cause failure. - [ ] Memory Allocations - [ ] Arena Allocations - [ ] Atoms diff --git a/include/ci2_exception.h b/include/ci2_exception.h index 6f132e3..fc4f158 100644 --- a/include/ci2_exception.h +++ b/include/ci2_exception.h @@ -20,13 +20,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * --------------------------------------------------------------------------*/ -#ifndef CI2_EXCEPTIONS_H -#define CI2_EXCEPTIONS_H +#ifndef CI2_EXCEPTION_H +#define CI2_EXCEPTION_H #include "./base/ci2_base.h" // CURRENT_FUNC macro #include -#include -extern int errno; +#include // dont extern anymore struct CI2_Exception { int num; @@ -70,13 +69,13 @@ extern void ci2_exception_pop(void); #define CI2_TRY do { \ volatile int ci2_exception_flag; \ CI2_Exception_Frame exception_frame; \ - if (exception_index == TLS_OUT_OF_INDEXES) \ + if (ci2_exception_index == TLS_OUT_OF_INDEXES) \ ci2_exception_init(); \ ci2_exception_push(&exception_frame); \ ci2_exception_flag = setjmp(exception_frame.env); \ if (ci2_exception_flag == CI2_EXCEPT_STATE_ENTERED) { #define CI2_EXCEPT(e) \ - if (ci2_except_flag == CI2_EXCEPT_STATE_ENTERED) ci2_exception_pop(); \ + if (ci2_exception_flag == CI2_EXCEPT_STATE_ENTERED) ci2_exception_pop(); \ } else if (exception_frame.exception == &(e)) { \ ci2_exception_flag = CI2_EXCEPT_STATE_HANDLED; #define CI2_ELSE \ @@ -124,5 +123,5 @@ extern void ci2_exception_pop(void); #endif -#endif // ci2_exceptions.h +#endif // ci2_exception.h diff --git a/src/linux_ci2_exceptions.c b/src/linux_ci2_exception.c similarity index 95% rename from src/linux_ci2_exceptions.c rename to src/linux_ci2_exception.c index 715256b..36c42c7 100644 --- a/src/linux_ci2_exceptions.c +++ b/src/linux_ci2_exception.c @@ -23,7 +23,7 @@ SOFTWARE. #include "../include/ci2_exception.h" struct CI2_Exception_Frame *ci2_exception_stack = NULL; -const struct CI2_Exception runtime_assertion_failed = { EFAULT , "CI2 Runtime Assertion Failed" }; +const struct CI2_Exception runtime_assertion_failed = { EINVAL, "CI2 Runtime Assertion Failed" }; void ci2_rt_assert(int e){ if(!e){ diff --git a/src/win32_ci2_exceptions.c b/src/win32_ci2_exception.c similarity index 96% rename from src/win32_ci2_exceptions.c rename to src/win32_ci2_exception.c index 8109d45..1c81aa6 100644 --- a/src/win32_ci2_exceptions.c +++ b/src/win32_ci2_exception.c @@ -21,11 +21,9 @@ SOFTWARE. * --------------------------------------------------------------------------*/ #include "../include/ci2_exception.h" -#include "../include/ci2_assert.h" -// #include DWORD ci2_exception_index = -1; -const struct CI2_Exception runtime_assertion_failed = { EFAULT, "CI2 Runtime Assertion Failed" }; +const struct CI2_Exception runtime_assertion_failed = { EINVAL, "CI2 Runtime Assertion Failed" }; void ci2_rt_assert(int e){ if(!e){