summaryrefslogtreecommitdiff
path: root/src/stddef
diff options
context:
space:
mode:
Diffstat (limited to 'src/stddef')
-rw-r--r--src/stddef/NULL.c17
-rw-r--r--src/stddef/offsetof.c17
-rw-r--r--src/stddef/ptrdiff_t.c24
-rw-r--r--src/stddef/size_t.c24
-rw-r--r--src/stddef/wchar_t.c17
5 files changed, 99 insertions, 0 deletions
diff --git a/src/stddef/NULL.c b/src/stddef/NULL.c
new file mode 100644
index 00000000..330b6b6e
--- /dev/null
+++ b/src/stddef/NULL.c
@@ -0,0 +1,17 @@
+#include <stddef.h>
+#define NULL ((void*)0)
+
+/** null pointer **/
+
+/***
+is an invalid pointer. It is used as a sentinel value in many standard
+library functions.
+***/
+
+/*
+UNDEFINED(Dereferencing THIS())
+IMPLEMENTATION(The value of THIS(), DEFINITION((void*)0))
+*/
+/*
+STDC(1)
+*/
diff --git a/src/stddef/offsetof.c b/src/stddef/offsetof.c
new file mode 100644
index 00000000..c5bf733b
--- /dev/null
+++ b/src/stddef/offsetof.c
@@ -0,0 +1,17 @@
+#include <stddef.h>
+#define offsetof(type, member) ((size_t)((void*)&(((type*)0)->##member)))
+
+/** get offset of a structure member **/
+
+/***
+determines the offset, in bytes, of a specified field in a TYPE(struct).
+***/
+
+/*
+PROTOTYPE(size_t offsetof(<var>type</var>, <var>member</var>);)
+RETURN_SUCCESS(the offset of ARGUMENT(member) in ARGUMENT(type))
+UNDEFINED(ARGUMENT(member) is a bit-field)
+*/
+/*
+STDC(1)
+*/
diff --git a/src/stddef/ptrdiff_t.c b/src/stddef/ptrdiff_t.c
new file mode 100644
index 00000000..1bbd99c8
--- /dev/null
+++ b/src/stddef/ptrdiff_t.c
@@ -0,0 +1,24 @@
+#include <stddef.h>
+#ifdef __LLP64__
+# if ! defined __STDC_VERSION__ || __STDC_VERSION__ < 199909L
+typedef __int64 ptrdiff_t;
+# else
+typedef long long int ptrdiff_t;
+# endif
+#else
+typedef long int ptrdiff_t;
+#endif
+
+/** pointer arithmetic type **/
+
+/***
+is a signed integral type which results when subtracting one pointer
+from another.
+***/
+
+/*
+TYPEDEF(signed integer)
+*/
+/*
+STDC(1)
+*/
diff --git a/src/stddef/size_t.c b/src/stddef/size_t.c
new file mode 100644
index 00000000..5435d006
--- /dev/null
+++ b/src/stddef/size_t.c
@@ -0,0 +1,24 @@
+#include <stddef.h>
+#ifdef __LLP64__
+# if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199909L
+typedef unsigned __int64 size_t;
+# else
+typedef unsigned long long int size_t;
+# endif
+#else
+typedef unsigned long int size_t;
+#endif
+
+/** memory size type **/
+
+/***
+is an unsigned integer type that is the result of using the
+OPERATOR(sizeof) operator.
+***/
+
+/*
+TYPEDEF(unsigned integer)
+*/
+/*
+STDC(1)
+*/
diff --git a/src/stddef/wchar_t.c b/src/stddef/wchar_t.c
new file mode 100644
index 00000000..dc4955fa
--- /dev/null
+++ b/src/stddef/wchar_t.c
@@ -0,0 +1,17 @@
+#include <stddef.h>
+typedef int wchar_t;
+
+/** wide character type **/
+
+/***
+is an integer type used to represent wide characters. Using a THIS(),
+every character in the current locale can be represented by a single variable.
+The null character will always have the value LITERAL(0).
+***/
+
+/*
+TYPEDEF(integer)
+*/
+/*
+STDC(1)
+*/