summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/__PREDEFINED_MACROS__/__STDC_NO_ATOMICS__.c0
-rw-r--r--src/__PREDEFINED_MACROS__/__STDC_NO_THREADS__.c0
-rw-r--r--src/assert/static_assert.c13
-rw-r--r--src/float/DBL_DECIMAL_DIG.c6
-rw-r--r--src/float/DBL_HAS_SUBNORM.c8
-rw-r--r--src/float/FLT_DECIMAL_DIG.c6
-rw-r--r--src/float/FLT_HAS_SUBNORM.c8
-rw-r--r--src/float/LDBL_DECIMAL_DIG.c6
-rw-r--r--src/float/LDBL_HAS_SUBNORM.c8
-rw-r--r--src/stdalign/__alignas_is_defined.c5
-rw-r--r--src/stdalign/__alignof_is_defined.c5
-rw-r--r--src/stdalign/alignas.c5
-rw-r--r--src/stdalign/alignof.c5
-rw-r--r--src/stddef/max_align_t.c5
-rw-r--r--src/stdlib/aligned_alloc.c12
-rw-r--r--src/stdlib/at_quick_exit.c54
-rw-r--r--src/stdlib/quick_exit.c45
-rw-r--r--src/stdnoreturn/noreturn.c5
-rw-r--r--src/time/TIME_UTC.c5
-rw-r--r--src/time/struct_timespec.c3
-rw-r--r--src/time/timespec_get.c10
-rw-r--r--src/uchar/c16rtomb.c10
-rw-r--r--src/uchar/c32rtomb.c10
-rw-r--r--src/uchar/char16_t.c5
-rw-r--r--src/uchar/char32_t.c5
-rw-r--r--src/uchar/mbrtoc16.c10
-rw-r--r--src/uchar/mbrtoc32.c10
27 files changed, 262 insertions, 2 deletions
diff --git a/src/__PREDEFINED_MACROS__/__STDC_NO_ATOMICS__.c b/src/__PREDEFINED_MACROS__/__STDC_NO_ATOMICS__.c
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/__PREDEFINED_MACROS__/__STDC_NO_ATOMICS__.c
diff --git a/src/__PREDEFINED_MACROS__/__STDC_NO_THREADS__.c b/src/__PREDEFINED_MACROS__/__STDC_NO_THREADS__.c
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/__PREDEFINED_MACROS__/__STDC_NO_THREADS__.c
diff --git a/src/assert/static_assert.c b/src/assert/static_assert.c
new file mode 100644
index 00000000..5a262b03
--- /dev/null
+++ b/src/assert/static_assert.c
@@ -0,0 +1,13 @@
+#define static_assert _Static_assert
+
+/** compile-time assertion **/
+
+/***
+The macro(static_assert) is defined as keyword(_Static_assert) to support
+compile-time assertions.
+***/
+
+/*
+DEF
+STDC(201112)
+*/
diff --git a/src/float/DBL_DECIMAL_DIG.c b/src/float/DBL_DECIMAL_DIG.c
new file mode 100644
index 00000000..16c68495
--- /dev/null
+++ b/src/float/DBL_DECIMAL_DIG.c
@@ -0,0 +1,6 @@
+#define DBL_DECIMAL_DIG (10)
+
+/*
+MIN(10)
+STDC(201112)
+*/
diff --git a/src/float/DBL_HAS_SUBNORM.c b/src/float/DBL_HAS_SUBNORM.c
new file mode 100644
index 00000000..be060884
--- /dev/null
+++ b/src/float/DBL_HAS_SUBNORM.c
@@ -0,0 +1,8 @@
+#define DBL_HAS_SUBNORM (-1)
+
+/* -1: indeterminable */
+/* 0: subnormal numbers not supported */
+/* 1: subnormal numbers are supported */
+/*
+STDC(201112)
+*/
diff --git a/src/float/FLT_DECIMAL_DIG.c b/src/float/FLT_DECIMAL_DIG.c
new file mode 100644
index 00000000..2bf60c7c
--- /dev/null
+++ b/src/float/FLT_DECIMAL_DIG.c
@@ -0,0 +1,6 @@
+#define FLT_DECIMAL_DIG (6)
+
+/* MIN: 6 */
+/*
+STDC(201112)
+*/
diff --git a/src/float/FLT_HAS_SUBNORM.c b/src/float/FLT_HAS_SUBNORM.c
new file mode 100644
index 00000000..e68672e1
--- /dev/null
+++ b/src/float/FLT_HAS_SUBNORM.c
@@ -0,0 +1,8 @@
+#define FLT_HAS_SUBNORM (-1)
+
+/* -1: indeterminable */
+/* 0: subnormal numbers not supported */
+/* 1: subnormal numbers are supported */
+/*
+STDC(201112)
+*/
diff --git a/src/float/LDBL_DECIMAL_DIG.c b/src/float/LDBL_DECIMAL_DIG.c
new file mode 100644
index 00000000..cc58e752
--- /dev/null
+++ b/src/float/LDBL_DECIMAL_DIG.c
@@ -0,0 +1,6 @@
+#define LDBL_DECIMAL_DIG (10)
+
+/* MIN: 10 */
+/*
+STDC(201112)
+*/
diff --git a/src/float/LDBL_HAS_SUBNORM.c b/src/float/LDBL_HAS_SUBNORM.c
new file mode 100644
index 00000000..c9384981
--- /dev/null
+++ b/src/float/LDBL_HAS_SUBNORM.c
@@ -0,0 +1,8 @@
+#define LDBL_HAS_SUBNORM (-1)
+
+/* -1: indeterminable */
+/* 0: subnormal numbers not supported */
+/* 1: subnormal numbers are supported */
+/*
+STDC(201112)
+*/
diff --git a/src/stdalign/__alignas_is_defined.c b/src/stdalign/__alignas_is_defined.c
new file mode 100644
index 00000000..908f81f9
--- /dev/null
+++ b/src/stdalign/__alignas_is_defined.c
@@ -0,0 +1,5 @@
+#define __alignas_is_defined (1)
+
+/*
+STDC(201112)
+*/
diff --git a/src/stdalign/__alignof_is_defined.c b/src/stdalign/__alignof_is_defined.c
new file mode 100644
index 00000000..61b0fa2b
--- /dev/null
+++ b/src/stdalign/__alignof_is_defined.c
@@ -0,0 +1,5 @@
+#define __alignof_is_defined (1)
+
+/*
+STDC(201112)
+*/
diff --git a/src/stdalign/alignas.c b/src/stdalign/alignas.c
new file mode 100644
index 00000000..c3486ae9
--- /dev/null
+++ b/src/stdalign/alignas.c
@@ -0,0 +1,5 @@
+#define alignas _Alignas
+
+/*
+STDC(201112)
+*/
diff --git a/src/stdalign/alignof.c b/src/stdalign/alignof.c
new file mode 100644
index 00000000..2ae0d90e
--- /dev/null
+++ b/src/stdalign/alignof.c
@@ -0,0 +1,5 @@
+#define alignof _Alignof
+
+/*
+STDC(201112)
+*/
diff --git a/src/stddef/max_align_t.c b/src/stddef/max_align_t.c
new file mode 100644
index 00000000..cd15c79e
--- /dev/null
+++ b/src/stddef/max_align_t.c
@@ -0,0 +1,5 @@
+typedef long double max_align_t;
+
+/*
+STDC(201112)
+*/
diff --git a/src/stdlib/aligned_alloc.c b/src/stdlib/aligned_alloc.c
new file mode 100644
index 00000000..9b721a13
--- /dev/null
+++ b/src/stdlib/aligned_alloc.c
@@ -0,0 +1,12 @@
+#include <stdli.h>
+
+void *aligned_alloc(size_t alignment, size_t size)
+{
+ /* all allocations are page aligned */
+ (void)alignment;
+ return malloc(size);
+}
+
+/*
+STDC(201112)
+*/
diff --git a/src/stdlib/at_quick_exit.c b/src/stdlib/at_quick_exit.c
new file mode 100644
index 00000000..01127d4e
--- /dev/null
+++ b/src/stdlib/at_quick_exit.c
@@ -0,0 +1,54 @@
+#include <stdlib.h>
+#include <limits.h>
+#include <errno.h>
+#include "_stdlib.h"
+
+/** register a function to run at quick exit **/
+int at_quick_exit(void (*func)(void))
+{
+ __C_MIN(201112L);
+ if (__stdlib.nat_quick_exit >= ATEXIT_MAX) {
+ return 1;
+ }
+
+ if (__stdlib.at_quick_exit == NULL) {
+ __stdlib.at_quick_exit = calloc(1,
+ sizeof(*__stdlib.at_quick_exit));
+ if (__stdlib.at_quick_exit == NULL) {
+ errno = ENOMEM;
+ return 1;
+ }
+ __stdlib.at_quick_exit->fn = func;
+ __stdlib.nat_quick_exit = 1;
+ return 0;
+ }
+
+ __stdlib.at_quick_exit->next = calloc(1,
+ sizeof(*__stdlib.at_quick_exit->next));
+ if (__stdlib.at_quick_exit->next == NULL) {
+ errno = ENOMEM;
+ return 1;
+ }
+ __stdlib.at_quick_exit->next->fn = func;
+ __stdlib.at_quick_exit->next->prev = __stdlib.at_quick_exit;
+ __stdlib.at_quick_exit = __stdlib.at_quick_exit->next;
+ __stdlib.nat_quick_exit++;
+
+ return 0;
+}
+
+/***
+The fn(at_quick_exit) registers the function arg(func) to be called when the
+program exits via fn(quick_exit). The function must take no parameters.
+***/
+
+/* UNSPECIFIED: - */
+/* UNDEFINED: - */
+/* IMPLEMENTATION: the number of registrations allowed (at least 32) */
+/* LOCALE: - */
+
+/* RETURN(0): success */
+/* RETURN(NZ): failure */
+/*
+STDC(201112)
+*/
diff --git a/src/stdlib/quick_exit.c b/src/stdlib/quick_exit.c
new file mode 100644
index 00000000..25937325
--- /dev/null
+++ b/src/stdlib/quick_exit.c
@@ -0,0 +1,45 @@
+#include <stdlib.h>
+#include <limits.h>
+#include <stddef.h>
+#include "_stdlib.h"
+
+/** cause normal quick program termination **/
+_Noreturn void quick_exit(int status)
+{
+ /* execute all at_quick_exit() registered functions in reverse order */
+ while (__stdlib.at_quick_exit) {
+ __stdlib.at_quick_exit->fn();
+ __stdlib.at_quick_exit = __stdlib.at_quick_exit->prev;
+ }
+
+ fflush(NULL);
+ // fclose(all the things);
+ // remove(all the tmpfile()s);
+ /* TODO */
+ /* __syscall(exit, status); */
+ _Exit(status);
+}
+
+/***
+The fn(quick_exit) function causes the program to terminate normally, returning
+the value arg(status) to the host environment.
+
+First, all functions registered by fn(at_quick_exit) are called in the reverse
+order in which they were registered.
+
+Then, all open streams with unwritten buffered data are flushed. All open
+streams are closed. All temporary files created by fn(tmpfile) are removed.
+***/
+
+/* UNSPECIFIED: - */
+/* UNDEFINED: calls to fn(longjmp) in a registered handler */
+/* UNDEFINED: calling fn(quick_exit) twice */
+/* UNDEFINED: calling fn(quick_exit) and fn(exit) twice */
+/* UNDEFINED: signals during fn(quick_exit) */
+/* IMPLEMENTATION: the successful termination value returned to the host environment when arg(status) is 0 of macro(EXIT_SUCESS) */
+/* IMPLEMENTATION: the unsuccessful termination value returned to the host environment when arg(status) is macro(EXIT_FAILURE) */
+/* LOCALE: - */
+
+/*
+STDC(201112)
+*/
diff --git a/src/stdnoreturn/noreturn.c b/src/stdnoreturn/noreturn.c
new file mode 100644
index 00000000..ce6b0c2b
--- /dev/null
+++ b/src/stdnoreturn/noreturn.c
@@ -0,0 +1,5 @@
+#define noreturn _Noreturn
+
+/*
+STDC(201112)
+*/
diff --git a/src/time/TIME_UTC.c b/src/time/TIME_UTC.c
new file mode 100644
index 00000000..f2fd5121
--- /dev/null
+++ b/src/time/TIME_UTC.c
@@ -0,0 +1,5 @@
+#define TIME_UTC (1)
+
+/*
+STDC(201112)
+*/
diff --git a/src/time/struct_timespec.c b/src/time/struct_timespec.c
index ecf0c8ef..cd068bd9 100644
--- a/src/time/struct_timespec.c
+++ b/src/time/struct_timespec.c
@@ -1,5 +1,3 @@
-#include <time.h>
-
struct timespec {
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseonds */
@@ -7,4 +5,5 @@ struct timespec {
/*
POSIX(199309)
+STDC(201112)
*/
diff --git a/src/time/timespec_get.c b/src/time/timespec_get.c
new file mode 100644
index 00000000..0f1c05df
--- /dev/null
+++ b/src/time/timespec_get.c
@@ -0,0 +1,10 @@
+#include <time.h>
+
+int timespec_get(struct timespec *ts, int base)
+{
+ return base;
+}
+
+/*
+STDC(201112)
+*/
diff --git a/src/uchar/c16rtomb.c b/src/uchar/c16rtomb.c
new file mode 100644
index 00000000..a99548c1
--- /dev/null
+++ b/src/uchar/c16rtomb.c
@@ -0,0 +1,10 @@
+#include <uchar.h>
+
+size_t c16rtomb(char * restrict s, char16_t c16, mbstate_t * restrict ps)
+{
+ return 0;
+}
+
+/*
+STDC(201112)
+*/
diff --git a/src/uchar/c32rtomb.c b/src/uchar/c32rtomb.c
new file mode 100644
index 00000000..6fc5ec7e
--- /dev/null
+++ b/src/uchar/c32rtomb.c
@@ -0,0 +1,10 @@
+#include <uchar.h>
+
+size_t c32rtomb(char * restrict s, char32_t c32, mbstate_t * restrict ps)
+{
+ return 0;
+}
+
+/*
+STDC(201112)
+*/
diff --git a/src/uchar/char16_t.c b/src/uchar/char16_t.c
new file mode 100644
index 00000000..f7b141aa
--- /dev/null
+++ b/src/uchar/char16_t.c
@@ -0,0 +1,5 @@
+typedef unsigned short char16_t;
+
+/*
+STDC(201112)
+*/
diff --git a/src/uchar/char32_t.c b/src/uchar/char32_t.c
new file mode 100644
index 00000000..52d7a25e
--- /dev/null
+++ b/src/uchar/char32_t.c
@@ -0,0 +1,5 @@
+typedef unsigned int char32_t;
+
+/*
+STDC(201112)
+*/
diff --git a/src/uchar/mbrtoc16.c b/src/uchar/mbrtoc16.c
new file mode 100644
index 00000000..57468cac
--- /dev/null
+++ b/src/uchar/mbrtoc16.c
@@ -0,0 +1,10 @@
+#include <uchar.h>
+
+size_t mbrtoc16(char16_t * restrict pc16, const char * restrict s, size_t n, mbstate_t * restrict ps)
+{
+ return 0;
+}
+
+/*
+STDC(201112)
+*/
diff --git a/src/uchar/mbrtoc32.c b/src/uchar/mbrtoc32.c
new file mode 100644
index 00000000..c640d4aa
--- /dev/null
+++ b/src/uchar/mbrtoc32.c
@@ -0,0 +1,10 @@
+#include <uchar.h>
+
+size_t mbrtoc32(char32_t * restrict pc32, const char * restrict s, size_t n, mbstate_t * restrict ps)
+{
+ return 0;
+}
+
+/*
+STDC(201112)
+*/