summaryrefslogtreecommitdiff
path: root/src/libk/include
diff options
context:
space:
mode:
authordzwdz2023-08-17 00:36:04 +0200
committerdzwdz2023-08-17 00:50:52 +0200
commit292b2386d766826b15f5ca084d37aa2c485fdda6 (patch)
tree125c217a90daa957548e9acb8bdecfff3d8374b2 /src/libk/include
parenta454a4ee0c50d2a9f4eb340d4a9ec60b9e089c9a (diff)
build: rework how sysroots work
/usr/include is now built on the fly, letting me merge include files from multiple modules, which should be a win for organization later on. binutils & gcc need to be recompiled. limits.h shamelessly stolen from heat on #osdev, as gcc stopped providing me with its own header. which was a hack in the first place
Diffstat (limited to 'src/libk/include')
-rw-r--r--src/libk/include/bits/limits.h45
-rw-r--r--src/libk/include/camellia/path.h3
-rw-r--r--src/libk/include/limits.h5
3 files changed, 51 insertions, 2 deletions
diff --git a/src/libk/include/bits/limits.h b/src/libk/include/bits/limits.h
new file mode 100644
index 0000000..a64302e
--- /dev/null
+++ b/src/libk/include/bits/limits.h
@@ -0,0 +1,45 @@
+/** Adapted from code (c) 2023 Pedro Falcato, with permission.
+ * Originally licensed under BSD-2-Clause-Patent.
+ */
+
+#if defined (__LP64__)
+#define __LIMITS_64BIT
+#endif
+
+#define CHAR_BIT 8
+
+#define SCHAR_MIN -128
+#define SCHAR_MAX 127
+#define UCHAR_MAX 255
+
+#if '\xff' < 0
+/* char is signed */
+# define CHAR_MIN SCHAR_MIN
+# define CHAR_MAX SCHAR_MAX
+#else
+/* char is unsigned */
+# define CHAR_MIN 0
+# define CHAR_MAX UCHAR_MAX
+#endif
+
+#define SHRT_MIN (-1 - 0x7fff)
+#define SHRT_MAX 0x7fff
+#define USHRT_MAX 0xffff
+
+#define INT_MIN (-1 - 0x7fffffff)
+#define INT_MAX 0x7fffffff
+#define UINT_MAX 0xffffffffU
+
+#ifdef __LIMITS_64BIT
+# define LONG_MAX 0x7fffffffffffffffL
+# define LONG_MIN (-1 - 0x7fffffffffffffffL)
+# define ULONG_MAX 0xffffffffffffffffUL
+#else
+# define LONG_MAX 0x7fffffffL
+# define LONG_MIN (-1 - 0x7fffffffL)
+# define ULONG_MAX 0xffffffffUL
+#endif
+
+#define LLONG_MIN (-1 - 0x7fffffffffffffffLL)
+#define LLONG_MAX 0x7fffffffffffffffLL
+#define ULLONG_MAX 0xffffffffffffffffULL
diff --git a/src/libk/include/camellia/path.h b/src/libk/include/camellia/path.h
index b268595..ee66f7b 100644
--- a/src/libk/include/camellia/path.h
+++ b/src/libk/include/camellia/path.h
@@ -1,8 +1,7 @@
#pragma once
+#include <limits.h> /* for PATH_MAX */
#include <stddef.h>
-#define PATH_MAX 512
-
/** Reduce a path to its simplest form.
* Kinds of invalid paths:
* - relative - "" "a" "./a"
diff --git a/src/libk/include/limits.h b/src/libk/include/limits.h
new file mode 100644
index 0000000..4cb972d
--- /dev/null
+++ b/src/libk/include/limits.h
@@ -0,0 +1,5 @@
+#include <bits/limits.h>
+
+#define NAME_MAX 255
+#define PATH_MAX 512
+#define _POSIX2_RE_DUP_MAX 255