summaryrefslogtreecommitdiff
path: root/tools/sysinc
diff options
context:
space:
mode:
authormagh <magh@maghmogh.com>2023-03-06 18:44:55 -0600
committermagh <magh@maghmogh.com>2023-03-06 18:44:55 -0600
commite80d9d8871b325a04b18f90a9ea4bb7fd148fb25 (patch)
tree79dbdb8506b7ff1e92549188d1b94cfc0b3503ae /tools/sysinc
add m1n1HEADmaster
Diffstat (limited to 'tools/sysinc')
-rw-r--r--tools/sysinc/assert.h15
-rw-r--r--tools/sysinc/endian.h12
-rw-r--r--tools/sysinc/errno.h9
-rw-r--r--tools/sysinc/limits.h15
-rw-r--r--tools/sysinc/malloc.h16
-rw-r--r--tools/sysinc/math.h16
-rw-r--r--tools/sysinc/string.h39
7 files changed, 122 insertions, 0 deletions
diff --git a/tools/sysinc/assert.h b/tools/sysinc/assert.h
new file mode 100644
index 0000000..0afd561
--- /dev/null
+++ b/tools/sysinc/assert.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef ASSERT_H
+#define ASSERT_H
+
+void __assert_fail(const char *assertion, const char *file, unsigned int line,
+ const char *function);
+
+#define assert(expression) \
+ ((expression) ? (void)0 : __assert_fail(#expression, __FILE__, __LINE__, __func__))
+
+/* Requires C11 */
+#define static_assert _Static_assert
+
+#endif
diff --git a/tools/sysinc/endian.h b/tools/sysinc/endian.h
new file mode 100644
index 0000000..6115c0b
--- /dev/null
+++ b/tools/sysinc/endian.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef ENDIAN_H
+#define ENDIAN_H
+
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#define __PDP_ENDIAN 3412
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
+
+#endif
diff --git a/tools/sysinc/errno.h b/tools/sysinc/errno.h
new file mode 100644
index 0000000..5aaf0dd
--- /dev/null
+++ b/tools/sysinc/errno.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef ERRNO_H
+#define ERRNO_H
+
+#define ENOMEM 12
+#define EINVAL 22
+
+#endif
diff --git a/tools/sysinc/limits.h b/tools/sysinc/limits.h
new file mode 100644
index 0000000..5efe2fc
--- /dev/null
+++ b/tools/sysinc/limits.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef LIMITS_H
+#define LIMITS_H
+
+#define INT_MAX (0x7fffffff)
+#define UINT_MAX (0xffffffffu)
+
+#define LONG_MAX (0x7fffffffffffffffl)
+#define ULONG_MAX (0xfffffffffffffffful)
+
+#define LLONG_MAX LONG_MAX
+#define ULLONG_MAX ULLONG_MAX
+
+#endif
diff --git a/tools/sysinc/malloc.h b/tools/sysinc/malloc.h
new file mode 100644
index 0000000..945bcff
--- /dev/null
+++ b/tools/sysinc/malloc.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef MALLOC_H
+#define MALLOC_H
+
+#include <stddef.h>
+
+void *malloc(size_t);
+void free(void *);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+void *realloc_in_place(void *, size_t);
+void *memalign(size_t, size_t);
+int posix_memalign(void **, size_t, size_t);
+
+#endif
diff --git a/tools/sysinc/math.h b/tools/sysinc/math.h
new file mode 100644
index 0000000..3809446
--- /dev/null
+++ b/tools/sysinc/math.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef MATH_H
+#define MATH_H
+
+#if 100 * __GNUC__ + __GNUC_MINOR__ >= 303
+#define NAN __builtin_nanf("")
+#define INFINITY __builtin_inff()
+#else
+#define NAN (0.0f / 0.0f)
+#define INFINITY 1e5000f
+#endif
+
+float expf(float);
+
+#endif
diff --git a/tools/sysinc/string.h b/tools/sysinc/string.h
new file mode 100644
index 0000000..1aa9e26
--- /dev/null
+++ b/tools/sysinc/string.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef STRING_H
+#define STRING_H
+
+#include <stddef.h>
+
+void *memcpy(void *s1, const void *s2, size_t n);
+void *memmove(void *s1, const void *s2, size_t n);
+int memcmp(const void *s1, const void *s2, size_t n);
+void *memset(void *s, int c, size_t n);
+void *memchr(const void *s, int c, size_t n);
+char *strcpy(char *s1, const char *s2);
+char *strncpy(char *s1, const char *s2, size_t n);
+int strcmp(const char *s1, const char *s2);
+int strncmp(const char *s1, const char *s2, size_t n);
+size_t strlen(const char *s);
+size_t strnlen(const char *s, size_t n);
+char *strchr(const char *s, int c);
+char *strrchr(const char *s, int c);
+long atol(const char *s);
+
+static inline int tolower(int c)
+{
+ if (c >= 'A' && c <= 'Z')
+ return c - 'A' + 'a';
+ else
+ return c;
+}
+
+static inline int toupper(int c)
+{
+ if (c >= 'a' && c <= 'z')
+ return c - 'a' + 'A';
+ else
+ return c;
+}
+
+#endif