summaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/__constraint_info.h3
-rw-r--r--src/stdlib/__stdlib.c9
-rw-r--r--src/stdlib/_stdlib.h6
-rw-r--r--src/stdlib/abort_handler_s.c17
4 files changed, 23 insertions, 12 deletions
diff --git a/src/stdlib/__constraint_info.h b/src/stdlib/__constraint_info.h
new file mode 100644
index 00000000..f8ffb539
--- /dev/null
+++ b/src/stdlib/__constraint_info.h
@@ -0,0 +1,3 @@
+struct __constraint_info {
+ const char *func;
+};
diff --git a/src/stdlib/__stdlib.c b/src/stdlib/__stdlib.c
index aa67fa10..b6423713 100644
--- a/src/stdlib/__stdlib.c
+++ b/src/stdlib/__stdlib.c
@@ -1,12 +1,9 @@
-#if 0
-
#include "_stdlib.h"
-struct __stdlib __stdlib;
+struct __stdlib __stdlib = {
+ .constraint_handler = abort_handler_s,
+};
/*
STDC(0)
*/
-
-
-#endif
diff --git a/src/stdlib/_stdlib.h b/src/stdlib/_stdlib.h
index 929981a6..4d456594 100644
--- a/src/stdlib/_stdlib.h
+++ b/src/stdlib/_stdlib.h
@@ -7,6 +7,11 @@
#define _rand(_n) \
(((_n) = (_n) * 1103515245 + 12345) ? (_n) / UINT_MAX % RAND_MAX : 0)
+#include "errno/errno_t.h"
+#include "constraint_handler_t.h"
+#include "__constraint_info.h"
+void abort_handler_s(const char * restrict msg, void * restrict ptr, errno_t error);
+
struct __stdlib {
struct atexit {
int nfns;
@@ -16,6 +21,7 @@ struct __stdlib {
} atexit;
unsigned int rand;
char **environ;
+ constraint_handler_t constraint_handler;
};
extern struct __stdlib __stdlib;
diff --git a/src/stdlib/abort_handler_s.c b/src/stdlib/abort_handler_s.c
index 31d06568..7639ddfe 100644
--- a/src/stdlib/abort_handler_s.c
+++ b/src/stdlib/abort_handler_s.c
@@ -1,15 +1,20 @@
-#if 0
-
#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+//#include <errno.h>
+#include "errno/errno_t.h"
+#include "_stdlib.h"
void abort_handler_s(const char * restrict msg, void * restrict ptr, errno_t error)
{
- __C_EXT(1, 201112L);
+ struct __constraint_info *ci = ptr;
+
+ puts(msg);
+ printf("In call to %s\n", ci->func);
+ printf("Provided error: %s (%d)\n", strerror(error), error);
+ abort();
}
/*
CEXT1(201112)
*/
-
-
-#endif