summaryrefslogtreecommitdiff
path: root/include/stddef.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/stddef.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/stddef.h b/include/stddef.h
new file mode 100644
index 0000000..f391a3a
--- /dev/null
+++ b/include/stddef.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2025 Danny Holman <dholman@gymli.org>
+ *
+ * This file is part of BoxOS, a free and open-source Unix-like operating
+ * system.
+ *
+ * BoxOS is free software; you can redistribute it and/or modify under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * BoxOS; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef STDDEF_H
+#define STDDEF_H
+
+#include <stdint.h>
+
+#ifndef NULL
+#define NULL ((void*)0)
+#endif
+
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__zarch__) || __riscv_xlen == 64
+typedef __int64_t ptrdiff_t;
+typedef __int64_t ssize_t;
+typedef __uint64_t size_t;
+typedef __uint32_t wchar_t;
+#elif defined(__i386__) || defined(__arm__) || __riscv_xlen == 32
+typedef __int32_t ptrdiff_t;
+typedef __int32_t ssize_t;
+typedef __uint32_t size_t;
+typedef __uint16_t wchar_t;
+#else
+#error "Unsupported architecture"
+#endif
+
+#define SIZE_MAX ((size_t)65535)
+#define offsetof(type, member) ((size_t)((char*)&(((type*)0)->member) - (char*)0))
+
+#endif