From bd5969fc876a10b18613302db7087ef3c40f18e1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:00 -0500 Subject: lib: Add mlibc Signed-off-by: Ian Moffett --- lib/mlibc/options/ansi/include/bits/ansi/fenv.h | 54 ++++++++++++++++++++++ lib/mlibc/options/ansi/include/bits/ansi/time_t.h | 8 ++++ .../options/ansi/include/bits/ansi/timespec.h | 13 ++++++ 3 files changed, 75 insertions(+) create mode 100644 lib/mlibc/options/ansi/include/bits/ansi/fenv.h create mode 100644 lib/mlibc/options/ansi/include/bits/ansi/time_t.h create mode 100644 lib/mlibc/options/ansi/include/bits/ansi/timespec.h (limited to 'lib/mlibc/options/ansi/include/bits') diff --git a/lib/mlibc/options/ansi/include/bits/ansi/fenv.h b/lib/mlibc/options/ansi/include/bits/ansi/fenv.h new file mode 100644 index 0000000..677ddaa --- /dev/null +++ b/lib/mlibc/options/ansi/include/bits/ansi/fenv.h @@ -0,0 +1,54 @@ +#ifndef MLIBC_FENV_H +#define MLIBC_FENV_H + +#if defined(__x86_64__) || defined(__i386__) + +#define FE_DENORMAL 2 +#define FE_DIVBYZERO 4 +#define FE_INEXACT 32 +#define FE_INVALID 1 +#define FE_OVERFLOW 8 +#define FE_UNDERFLOW 16 + +#define FE_ALL_EXCEPT (FE_DENORMAL | FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) + +#define FE_TONEAREST 0 +#define FE_DOWNWARD 0x400 +#define FE_UPWARD 0x800 +#define FE_TOWARDZERO 0xC00 + +#elif defined(__aarch64__) + +#define FE_INVALID 1 +#define FE_DIVBYZERO 2 +#define FE_OVERFLOW 4 +#define FE_UNDERFLOW 8 +#define FE_INEXACT 16 + +#define FE_ALL_EXCEPT 31 + +#define FE_TONEAREST 0 +#define FE_UPWARD 0x400000 +#define FE_DOWNWARD 0x800000 +#define FE_TOWARDZERO 0xC00000 + +#elif defined(__riscv) && __riscv_xlen == 64 + +#define FE_INEXACT 1 +#define FE_UNDERFLOW 2 +#define FE_OVERFLOW 4 +#define FE_DIVBYZERO 8 +#define FE_INVALID 16 + +#define FE_ALL_EXCEPT 31 + +#define FE_TONEAREST 0 +#define FE_TOWARDZERO 1 +#define FE_DOWNWARD 2 +#define FE_UPWARD 3 + +#else +#error Unknown architecture +#endif + +#endif // MLIBC_FENV_H diff --git a/lib/mlibc/options/ansi/include/bits/ansi/time_t.h b/lib/mlibc/options/ansi/include/bits/ansi/time_t.h new file mode 100644 index 0000000..1c29fa0 --- /dev/null +++ b/lib/mlibc/options/ansi/include/bits/ansi/time_t.h @@ -0,0 +1,8 @@ + +#ifndef MLIBC_TIME_T +#define MLIBC_TIME_T + +typedef long time_t; + +#endif + diff --git a/lib/mlibc/options/ansi/include/bits/ansi/timespec.h b/lib/mlibc/options/ansi/include/bits/ansi/timespec.h new file mode 100644 index 0000000..d34aa64 --- /dev/null +++ b/lib/mlibc/options/ansi/include/bits/ansi/timespec.h @@ -0,0 +1,13 @@ + +#ifndef MLIBC_TIMESPEC_H +#define MLIBC_TIMESPEC_H + +#include + +struct timespec { + time_t tv_sec; + long tv_nsec; +}; + +#endif // MLIBC_TIMESPEC_H + -- cgit v1.2.3