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/stddef.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/stddef.h')
-rw-r--r-- | include/stddef.h | 46 |
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 |