README and tidy up exceptions
This commit is contained in:
@@ -30,7 +30,8 @@ the platform layer prefix.
|
|||||||
- [x] Static Assertions
|
- [x] Static Assertions
|
||||||
- [x] Basic Assertions
|
- [x] Basic Assertions
|
||||||
- [ ] Add failure flag to cause failure.
|
- [ ] Add failure flag to cause failure.
|
||||||
- [ ] Exceptions & Errors
|
- [x] Exceptions & Errors
|
||||||
|
-[ ] Add failure flag to cause failure.
|
||||||
- [ ] Memory Allocations
|
- [ ] Memory Allocations
|
||||||
- [ ] Arena Allocations
|
- [ ] Arena Allocations
|
||||||
- [ ] Atoms
|
- [ ] Atoms
|
||||||
|
|||||||
@@ -20,13 +20,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
||||||
* --------------------------------------------------------------------------*/
|
* --------------------------------------------------------------------------*/
|
||||||
#ifndef CI2_EXCEPTIONS_H
|
#ifndef CI2_EXCEPTION_H
|
||||||
#define CI2_EXCEPTIONS_H
|
#define CI2_EXCEPTION_H
|
||||||
|
|
||||||
#include "./base/ci2_base.h" // CURRENT_FUNC macro
|
#include "./base/ci2_base.h" // CURRENT_FUNC macro
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <errno.h>
|
#include <errno.h> // dont extern anymore
|
||||||
extern int errno;
|
|
||||||
|
|
||||||
struct CI2_Exception {
|
struct CI2_Exception {
|
||||||
int num;
|
int num;
|
||||||
@@ -70,13 +69,13 @@ extern void ci2_exception_pop(void);
|
|||||||
#define CI2_TRY do { \
|
#define CI2_TRY do { \
|
||||||
volatile int ci2_exception_flag; \
|
volatile int ci2_exception_flag; \
|
||||||
CI2_Exception_Frame exception_frame; \
|
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_init(); \
|
||||||
ci2_exception_push(&exception_frame); \
|
ci2_exception_push(&exception_frame); \
|
||||||
ci2_exception_flag = setjmp(exception_frame.env); \
|
ci2_exception_flag = setjmp(exception_frame.env); \
|
||||||
if (ci2_exception_flag == CI2_EXCEPT_STATE_ENTERED) {
|
if (ci2_exception_flag == CI2_EXCEPT_STATE_ENTERED) {
|
||||||
#define CI2_EXCEPT(e) \
|
#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)) { \
|
} else if (exception_frame.exception == &(e)) { \
|
||||||
ci2_exception_flag = CI2_EXCEPT_STATE_HANDLED;
|
ci2_exception_flag = CI2_EXCEPT_STATE_HANDLED;
|
||||||
#define CI2_ELSE \
|
#define CI2_ELSE \
|
||||||
@@ -124,5 +123,5 @@ extern void ci2_exception_pop(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // ci2_exceptions.h
|
#endif // ci2_exception.h
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ SOFTWARE.
|
|||||||
#include "../include/ci2_exception.h"
|
#include "../include/ci2_exception.h"
|
||||||
|
|
||||||
struct CI2_Exception_Frame *ci2_exception_stack = NULL;
|
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){
|
void ci2_rt_assert(int e){
|
||||||
if(!e){
|
if(!e){
|
||||||
@@ -21,11 +21,9 @@ SOFTWARE.
|
|||||||
|
|
||||||
* --------------------------------------------------------------------------*/
|
* --------------------------------------------------------------------------*/
|
||||||
#include "../include/ci2_exception.h"
|
#include "../include/ci2_exception.h"
|
||||||
#include "../include/ci2_assert.h"
|
|
||||||
// #include <stdlib.h>
|
|
||||||
|
|
||||||
DWORD ci2_exception_index = -1;
|
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){
|
void ci2_rt_assert(int e){
|
||||||
if(!e){
|
if(!e){
|
||||||
Reference in New Issue
Block a user