summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/cloudlibc/src/common/limits.h
diff options
context:
space:
mode:
Diffstat (limited to 'libc-bottom-half/cloudlibc/src/common/limits.h')
-rw-r--r--libc-bottom-half/cloudlibc/src/common/limits.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/libc-bottom-half/cloudlibc/src/common/limits.h b/libc-bottom-half/cloudlibc/src/common/limits.h
new file mode 100644
index 0000000..67e2f07
--- /dev/null
+++ b/libc-bottom-half/cloudlibc/src/common/limits.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2015 Nuxi, https://nuxi.nl/
+//
+// SPDX-License-Identifier: BSD-2-Clause
+
+#ifndef COMMON_LIMITS_H
+#define COMMON_LIMITS_H
+
+#include <limits.h>
+
+#define NUMERIC_MIN(t) \
+ _Generic((t)0, char \
+ : CHAR_MIN, signed char \
+ : SCHAR_MIN, unsigned char : 0, short \
+ : SHRT_MIN, unsigned short : 0, int \
+ : INT_MIN, unsigned int : 0, long \
+ : LONG_MIN, unsigned long : 0, long long \
+ : LLONG_MIN, unsigned long long : 0, default \
+ : (void)0)
+
+#define NUMERIC_MAX(t) \
+ _Generic((t)0, char \
+ : CHAR_MAX, signed char \
+ : SCHAR_MAX, unsigned char \
+ : UCHAR_MAX, short \
+ : SHRT_MAX, unsigned short \
+ : USHRT_MAX, int \
+ : INT_MAX, unsigned int \
+ : UINT_MAX, long \
+ : LONG_MAX, unsigned long \
+ : ULONG_MAX, long long \
+ : LLONG_MAX, unsigned long long \
+ : ULLONG_MAX, default \
+ : (void)0)
+
+#endif