diff options
author | Danny Holman <dholman@gymli.org> | 2025-10-19 21:43:56 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2025-10-19 21:43:56 -0500 |
commit | b2d5436d35ce223f9d8b2d8d598c1e0b5e053c4a (patch) | |
tree | bbeb08cdb5d1ddb0ece37025d7c13b1091b4e32d /include/limits.h | |
parent | build: align all build files (diff) | |
download | box-b2d5436d35ce223f9d8b2d8d598c1e0b5e053c4a.tar.gz box-b2d5436d35ce223f9d8b2d8d598c1e0b5e053c4a.tar.zst box-b2d5436d35ce223f9d8b2d8d598c1e0b5e053c4a.zip |
include: create the basics of a libc
Create the most basic files for a POSIX-conformant standard C library
implementation. These basic files should be enough to get the bootloader
and kernel off the ground and not much else. Additional testing should
be done on these files.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'include/limits.h')
-rw-r--r-- | include/limits.h | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/include/limits.h b/include/limits.h new file mode 100644 index 0000000..6ee065d --- /dev/null +++ b/include/limits.h @@ -0,0 +1,83 @@ +/* + * 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 LIMITS_H +#define LIMITS_H + +#define CHAR_BIT 8 +#define SCHAR_MIN (-128) +#define SCHAR_MAX 127 +#define UCHAR_MAX 255 + +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX + +#define SHRT_MIN (-32768) +#define SHRT_MAX 32767 +#define USHRT_MAX 65535 + +#define INT_MIN (-2147483648) +#define INT_MAX 2147483647 +#define UINT_MAX 4294967295U + +#define LONG_MIN (-9223372036854775808L) +#define LONG_MAX 9223372036854775807L +#define ULONG_MAX 18446744073709551615UL + +#define FLT_RADIX 2 +#define FLT_MANT_DIG 24 +#define FLT_DIG 6 +#define FLT_MIN 1.175494351e-38F +#define FLT_MAX 3.402823466e+38F + +#define DBL_MANT_DIG 53 +#define DBL_DIG 15 +#define DBL_MIN 2.2250738585072014e-308 +#define DBL_MAX 1.7976931348623157e+308 + +#define INT8_MIN (-1-0x7F) +#define INT16_MIN (-1-0x7FFF) +#define INT32_MIN (-1-0x7FFFFFFF) +#define INT64_MIN (-1-0x7FFFFFFFFFFFFFFF) + +#define INT8_MAX (0x7F) +#define INT16_MAX (0x7FFF) +#define INT32_MAX (0x7FFFFFFF) +#define INT64_MAX (0x7FFFFFFFFFFFFFFF) + +#define UINT8_MAX (0xFF) +#define UINT16_MAX (0xFFFF) +#define UINT32_MAX (0xFFFFFFFF) +#define UINT64_MAX (0xFFFFFFFFFFFFFFFF) + +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX + +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST64_MIN INT64_MIN + +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST64_MAX INT64_MAX + +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST64_MIN INT64_MIN + +#endif |