user: implement mlibc as the libc, finally.
It's finally done.. Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
#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
|
||||
|
||||
#elif defined (__m68k__)
|
||||
|
||||
#if __HAVE_68881__ || __mcffpu__ || __HAVE_FPU_
|
||||
|
||||
#define FE_INEXACT 8
|
||||
#define FE_DIVBYZERO 16
|
||||
#define FE_UNDERFLOW 32
|
||||
#define FE_OVERFLOW 64
|
||||
#define FE_INVALID 128
|
||||
|
||||
#define FE_ALL_EXCEPT 0xf8
|
||||
|
||||
#define FE_TONEAREST 0
|
||||
#define FE_TOWARDZERO 16
|
||||
#define FE_DOWNWARD 32
|
||||
#define FE_UPWARD 48
|
||||
|
||||
#else
|
||||
|
||||
#define FE_ALL_EXCEPT 0
|
||||
#define FE_TONEAREST 0
|
||||
|
||||
#endif
|
||||
|
||||
#elif defined(__loongarch64)
|
||||
|
||||
#define FE_INEXACT 0x010000
|
||||
#define FE_UNDERFLOW 0x020000
|
||||
#define FE_OVERFLOW 0x040000
|
||||
#define FE_DIVBYZERO 0x080000
|
||||
#define FE_INVALID 0x100000
|
||||
|
||||
#define FE_ALL_EXCEPT (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
|
||||
|
||||
#define FE_TONEAREST 0x000
|
||||
#define FE_TOWARDZERO 0x100
|
||||
#define FE_UPWARD 0x200
|
||||
#define FE_DOWNWARD 0x300
|
||||
|
||||
#else
|
||||
#error Unknown architecture
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_FENV_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
#ifndef MLIBC_TIME_T
|
||||
#define MLIBC_TIME_T
|
||||
|
||||
typedef long time_t;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
#ifndef MLIBC_TIMESPEC_H
|
||||
#define MLIBC_TIMESPEC_H
|
||||
|
||||
#include <bits/ansi/time_t.h>
|
||||
|
||||
struct timespec {
|
||||
time_t tv_sec;
|
||||
long tv_nsec;
|
||||
};
|
||||
|
||||
#endif /* MLIBC_TIMESPEC_H */
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
#ifndef MLIBC_BSD_STDLIB_H
|
||||
#define MLIBC_BSD_STDLIB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int getloadavg(double *__loadavg, int __count);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_BSD_STDLIB_H */
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef _BSD_UNISTD_H
|
||||
#define _BSD_UNISTD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
void *sbrk(intptr_t __increment);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BSD_UNISTD_H */
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _MLIBC_INTERNAL_CPU_SET_H
|
||||
#define _MLIBC_INTERNAL_CPU_SET_H
|
||||
|
||||
typedef unsigned long __cpu_mask;
|
||||
|
||||
#define CPU_SETSIZE 1024
|
||||
#define __NCPUBITS (8 * sizeof(__cpu_mask))
|
||||
|
||||
typedef struct {
|
||||
__cpu_mask __bits[CPU_SETSIZE / __NCPUBITS];
|
||||
} cpu_set_t;
|
||||
|
||||
#endif /* _MLIBC_INTERNAL_CPU_SET_H */
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
#ifndef MLIBC_ENSURE_H
|
||||
#define MLIBC_ENSURE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
void __ensure_fail(const char *assertion, const char *file, unsigned int line,
|
||||
const char *function);
|
||||
|
||||
void __ensure_warn(const char *assertion, const char *file, unsigned int line,
|
||||
const char *function);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#define __ensure(assertion) do { if(!(assertion)) \
|
||||
__ensure_fail(#assertion, __FILE__, __LINE__, __func__); } while(0)
|
||||
|
||||
#define MLIBC_UNIMPLEMENTED() __ensure_fail("Functionality is not implemented", \
|
||||
__FILE__, __LINE__, __func__)
|
||||
|
||||
#define MLIBC_MISSING_SYSDEP() __ensure_warn("Library function fails due to missing sysdep", \
|
||||
__FILE__, __LINE__, __func__)
|
||||
|
||||
#define MLIBC_CHECK_OR_ENOSYS(sysdep, ret) ({ \
|
||||
if (!(sysdep)) { \
|
||||
__ensure_warn("Library function fails due to missing sysdep", \
|
||||
__FILE__, __LINE__, __func__); \
|
||||
errno = ENOSYS; \
|
||||
return (ret); \
|
||||
} \
|
||||
sysdep; \
|
||||
})
|
||||
|
||||
#define MLIBC_STUB_BODY ({ MLIBC_UNIMPLEMENTED(); __builtin_unreachable(); })
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_ENSURE_H */
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef MLIBC_ETHER_ADDR_H
|
||||
#define MLIBC_ETHER_ADDR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct ether_addr {
|
||||
uint8_t ether_addr_octet[6];
|
||||
} __attribute__((__packed__));
|
||||
|
||||
#endif /* MLIBC_ETHER_ADDR_H */
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef MLIBC_FILE_T_H
|
||||
#define MLIBC_FILE_T_H
|
||||
|
||||
typedef struct __mlibc_file_base FILE;
|
||||
|
||||
#endif /* MLIBC_FILE_T_H */
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef MLIBC_BITS_GETOPT
|
||||
#define MLIBC_BITS_GETOPT
|
||||
|
||||
struct option {
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
#define no_argument 0
|
||||
#define required_argument 1
|
||||
#define optional_argument 2
|
||||
|
||||
#endif /* MLIBC_BITS_GETOPT */
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef MLIBC_GLIBC_ASSERT_H
|
||||
#define MLIBC_GLIBC_ASSERT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
__attribute__ ((__noreturn__)) void __assert_fail_perror(int __errno, const char *__file, unsigned int __line,
|
||||
const char *__function);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_GLIBC_ASSERT_H */
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
||||
#undef assert_perror
|
||||
#define assert_perror(ignore) ((void)0)
|
||||
|
||||
#else /* NDEBUG */
|
||||
|
||||
#undef assert_perror
|
||||
#define assert_perror(errno) (!(errno) \
|
||||
|| (__assert_fail_perror((errno), __FILE__, __LINE__, __func__), 0))
|
||||
|
||||
#endif /* NDEBUG */
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef _GLIBC_NETINET_ICMP6_H
|
||||
#define _GLIBC_NETINET_ICMP6_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ND_OPT_SOURCE_LINKADDR 1
|
||||
#define ND_OPT_TARGET_LINKADDR 2
|
||||
#define ND_OPT_PREFIX_INFORMATION 3
|
||||
#define ND_OPT_REDIRECTED_HEADER 4
|
||||
#define ND_OPT_MTU 5
|
||||
#define ND_OPT_RTR_ADV_INTERVAL 7
|
||||
#define ND_OPT_HOME_AGENT_INFO 8
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GLIBC_NETINET_ICMP6_H */
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _GLIBC_MALLOC_H
|
||||
#define _GLIBC_MALLOC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bits/size_t.h>
|
||||
|
||||
size_t malloc_usable_size(void *__ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GLIBC_MALLOC_H */
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef _GLIBC_SEARCH_H
|
||||
#define _GLIBC_SEARCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bits/search.h>
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int hcreate_r(size_t __num_entries, struct hsearch_data *__htab);
|
||||
void hdestroy_r(struct hsearch_data *__htab);
|
||||
int hsearch_r(ENTRY __item, ACTION __action, ENTRY **__ret, struct hsearch_data *__htab);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _GLIBC_SEARCH_H */
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef MLIBC_GLIBC_SIGNAL_H
|
||||
#define MLIBC_GLIBC_SIGNAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int tgkill(int __tgid, int __tid, int __sig);
|
||||
|
||||
#if defined(_GNU_SOURCE)
|
||||
|
||||
typedef void (*sighandler_t)(int __signo);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_GLIBC_SIGNAL_H */
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef MLIBC_GLIBC_STDLIB_H
|
||||
#define MLIBC_GLIBC_STDLIB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int (*comparison_fn_t) (const void *__a, const void *__b);
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int rpmatch(const char *__resp);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_GLIBC_STDLIB_H */
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef MLIBC_INLINE_DEFINITION_H
|
||||
#define MLIBC_INLINE_DEFINITION_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __MLIBC_EMIT_INLINE_DEFINITIONS
|
||||
#define __MLIBC_INLINE_DEFINITION
|
||||
#else
|
||||
#define __MLIBC_INLINE_DEFINITION __attribute__((__gnu_inline__)) extern __inline__
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_INLINE_DEFINITION_H */
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
|
||||
#ifndef MLIBC_MACHINE_H
|
||||
#define MLIBC_MACHINE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined (__i386__)
|
||||
struct __mlibc_jmpbuf_register_state {
|
||||
uint32_t ebx;
|
||||
uint32_t ebp;
|
||||
uint32_t esi;
|
||||
uint32_t edi;
|
||||
uint32_t esp;
|
||||
uint32_t eip;
|
||||
};
|
||||
#elif defined (__x86_64__)
|
||||
struct __mlibc_jmpbuf_register_state {
|
||||
uint64_t rbx;
|
||||
uint64_t rbp;
|
||||
uint64_t r12;
|
||||
uint64_t r13;
|
||||
uint64_t r14;
|
||||
uint64_t r15;
|
||||
uint64_t rsp;
|
||||
uint64_t rip;
|
||||
};
|
||||
#elif defined (__aarch64__)
|
||||
struct __mlibc_jmpbuf_register_state {
|
||||
uint64_t x19;
|
||||
uint64_t x20;
|
||||
uint64_t x21;
|
||||
uint64_t x22;
|
||||
uint64_t x23;
|
||||
uint64_t x24;
|
||||
uint64_t x25;
|
||||
uint64_t x26;
|
||||
uint64_t x27;
|
||||
uint64_t x28;
|
||||
uint64_t x29;
|
||||
uint64_t x30;
|
||||
uint64_t sp;
|
||||
uint64_t pad;
|
||||
uint64_t d8;
|
||||
uint64_t d9;
|
||||
uint64_t d10;
|
||||
uint64_t d11;
|
||||
uint64_t d12;
|
||||
uint64_t d13;
|
||||
uint64_t d14;
|
||||
uint64_t d15;
|
||||
};
|
||||
#elif defined (__riscv) && __riscv_xlen == 64
|
||||
struct __mlibc_jmpbuf_register_state {
|
||||
uint64_t ra;
|
||||
uint64_t s0;
|
||||
uint64_t s1;
|
||||
uint64_t s2;
|
||||
uint64_t s3;
|
||||
uint64_t s4;
|
||||
uint64_t s5;
|
||||
uint64_t s6;
|
||||
uint64_t s7;
|
||||
uint64_t s8;
|
||||
uint64_t s9;
|
||||
uint64_t s10;
|
||||
uint64_t s11;
|
||||
uint64_t sp;
|
||||
double fs0;
|
||||
double fs1;
|
||||
double fs2;
|
||||
double fs3;
|
||||
double fs4;
|
||||
double fs5;
|
||||
double fs6;
|
||||
double fs7;
|
||||
double fs8;
|
||||
double fs9;
|
||||
double fs10;
|
||||
double fs11;
|
||||
};
|
||||
#elif defined (__m68k__)
|
||||
struct __mlibc_jmpbuf_register_state {
|
||||
uint32_t d2;
|
||||
uint32_t d3;
|
||||
uint32_t d4;
|
||||
uint32_t d5;
|
||||
uint32_t d6;
|
||||
uint32_t d7;
|
||||
uint32_t a2;
|
||||
uint32_t a3;
|
||||
uint32_t a4;
|
||||
uint32_t a5;
|
||||
uint32_t a6;
|
||||
uint32_t a7;
|
||||
uint32_t sp;
|
||||
uint32_t pc;
|
||||
};
|
||||
#elif defined (__loongarch64)
|
||||
struct __mlibc_jmpbuf_register_state {
|
||||
uint64_t ra;
|
||||
uint64_t sp;
|
||||
uint64_t u0;
|
||||
uint64_t s0;
|
||||
uint64_t s1;
|
||||
uint64_t s2;
|
||||
uint64_t s3;
|
||||
uint64_t s4;
|
||||
uint64_t s5;
|
||||
uint64_t s6;
|
||||
uint64_t s7;
|
||||
uint64_t s8;
|
||||
double fs0;
|
||||
double fs1;
|
||||
double fs2;
|
||||
double fs3;
|
||||
double fs4;
|
||||
double fs5;
|
||||
double fs6;
|
||||
double fs7;
|
||||
};
|
||||
#else
|
||||
# error "Missing architecture specific code"
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_MACHINE_H */
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef MLIBC_MBSTATE_H
|
||||
#define MLIBC_MBSTATE_H
|
||||
|
||||
typedef struct __mlibc_mbstate {
|
||||
short __progress;
|
||||
short __shift;
|
||||
unsigned int __cpoint;
|
||||
} mbstate_t;
|
||||
|
||||
#define __MLIBC_MBSTATE_INITIALIZER {0, 0, 0}
|
||||
|
||||
#endif /* MLIBC_MBSTATE_H */
|
||||
@@ -0,0 +1,84 @@
|
||||
|
||||
#ifndef _NL_ITEM_H
|
||||
#define _NL_ITEM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int nl_item;
|
||||
|
||||
#define ABDAY_1 0x60000
|
||||
#define ABDAY_2 0x60001
|
||||
#define ABDAY_3 0x60002
|
||||
#define ABDAY_4 0x60003
|
||||
#define ABDAY_5 0x60004
|
||||
#define ABDAY_6 0x60005
|
||||
#define ABDAY_7 0x60006
|
||||
|
||||
#define DAY_1 0x60007
|
||||
#define DAY_2 0x60008
|
||||
#define DAY_3 0x60009
|
||||
#define DAY_4 0x6000A
|
||||
#define DAY_5 0x6000B
|
||||
#define DAY_6 0x6000C
|
||||
#define DAY_7 0x6000D
|
||||
|
||||
#define ABMON_1 0x6000E
|
||||
#define ABMON_2 0x6000F
|
||||
#define ABMON_3 0x60010
|
||||
#define ABMON_4 0x60011
|
||||
#define ABMON_5 0x60012
|
||||
#define ABMON_6 0x60013
|
||||
#define ABMON_7 0x60014
|
||||
#define ABMON_8 0x60015
|
||||
#define ABMON_9 0x60016
|
||||
#define ABMON_10 0x60017
|
||||
#define ABMON_11 0x60018
|
||||
#define ABMON_12 0x60019
|
||||
|
||||
#define MON_1 0x6001A
|
||||
#define MON_2 0x6001B
|
||||
#define MON_3 0x6001C
|
||||
#define MON_4 0x6001D
|
||||
#define MON_5 0x6001E
|
||||
#define MON_6 0x6001F
|
||||
#define MON_7 0x60020
|
||||
#define MON_8 0x60021
|
||||
#define MON_9 0x60022
|
||||
#define MON_10 0x60023
|
||||
#define MON_11 0x60024
|
||||
#define MON_12 0x60025
|
||||
|
||||
#define AM_STR 0x60026
|
||||
#define PM_STR 0x60027
|
||||
|
||||
#define D_T_FMT 0x60028
|
||||
#define D_FMT 0x60029
|
||||
#define T_FMT 0x6002A
|
||||
#define T_FMT_AMPM 0x6002B
|
||||
|
||||
#define ERA 0x6002C
|
||||
#define ERA_D_FMT 0x6002D
|
||||
#define ALT_DIGITS 0x6002E
|
||||
#define ERA_D_T_FMT 0x6002F
|
||||
#define ERA_T_FMT 0x60030
|
||||
|
||||
#define CODESET 0x30000
|
||||
|
||||
#define CRNCYSTR 0x40000
|
||||
|
||||
#define RADIXCHAR 0x50000
|
||||
#define DECIMAL_POINT RADIXCHAR
|
||||
#define THOUSEP 0x50001
|
||||
#define THOUSANDS_SEP THOUSEP
|
||||
|
||||
#define YESEXPR 0x70000
|
||||
#define NOEXPR 0x70001
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NL_ITEM_H */
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
#ifndef MLIBC_NULL_H
|
||||
#define MLIBC_NULL_H
|
||||
|
||||
#ifdef NULL
|
||||
#undef NULL
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
# define NULL ((void *)0)
|
||||
#else
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_NULL_H */
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef MLIBC_OFF_T_H
|
||||
#define MLIBC_OFF_T_H
|
||||
|
||||
/* TODO: use something like int64_t instead? */
|
||||
typedef long off_t;
|
||||
typedef long off64_t;
|
||||
|
||||
#endif /* MLIBC_OFF_T_H */
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef MLIBC_FD_SET_H
|
||||
#define MLIBC_FD_SET_H
|
||||
|
||||
#include <bits/types.h>
|
||||
|
||||
typedef struct {
|
||||
__mlibc_uint8 fds_bits[128];
|
||||
} fd_set;
|
||||
|
||||
#endif /* MLIBC_FD_SET_H */
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef _MLIBC_ID_T_H
|
||||
#define _MLIBC_ID_T_H
|
||||
|
||||
typedef unsigned int id_t;
|
||||
|
||||
#endif /* _MLIBC_ID_T_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef MLIBC_IN_ADDR_H
|
||||
#define MLIBC_IN_ADDR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint32_t in_addr_t;
|
||||
|
||||
#endif /* MLIBC_IN_ADDR_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef MLIBC_IN_PORT_H
|
||||
#define MLIBC_IN_PORT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint16_t in_port_t;
|
||||
|
||||
#endif /* MLIBC_IN_PORT_H */
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef MLIBC_IOVEC_H
|
||||
#define MLIBC_IOVEC_H
|
||||
|
||||
#include <bits/types.h>
|
||||
|
||||
struct iovec {
|
||||
void *iov_base;
|
||||
__mlibc_size iov_len;
|
||||
};
|
||||
|
||||
#endif /* MLIBC_IOVEC_H */
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _LOCALE_T_H
|
||||
#define _LOCALE_T_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void *locale_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _LOCALE_T_H */
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef _POSIX_CTYPE_H
|
||||
#define _POSIX_CTYPE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bits/posix/locale_t.h>
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int isalnum_l(int __c, locale_t __loc);
|
||||
int isalpha_l(int __c, locale_t __loc);
|
||||
int isblank_l(int __c, locale_t __loc);
|
||||
int iscntrl_l(int __c, locale_t __loc);
|
||||
int isdigit_l(int __c, locale_t __loc);
|
||||
int isgraph_l(int __c, locale_t __loc);
|
||||
int islower_l(int __c, locale_t __loc);
|
||||
int isprint_l(int __c, locale_t __loc);
|
||||
int ispunct_l(int __c, locale_t __loc);
|
||||
int isspace_l(int __c, locale_t __loc);
|
||||
int isupper_l(int __c, locale_t __loc);
|
||||
int isxdigit_l(int __c, locale_t __loc);
|
||||
|
||||
int isascii_l(int __c, locale_t __loc);
|
||||
|
||||
int tolower_l(int __c, locale_t __loc);
|
||||
int toupper_l(int __c, locale_t __loc);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _POSIX_CTYPE_H */
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MLIBC_POSIX_LOCALE_H
|
||||
#define MLIBC_POSIX_LOCALE_H
|
||||
|
||||
#include <bits/posix/locale_t.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
locale_t newlocale(int __category_mask, const char *__locale, locale_t __base);
|
||||
void freelocale(locale_t __locobj);
|
||||
locale_t uselocale(locale_t __locobj);
|
||||
locale_t duplocale(locale_t __locobj);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_POSIX_LOCALE_H */
|
||||
@@ -0,0 +1,113 @@
|
||||
|
||||
#ifndef MLIBC_POSIX_SIGNAL_H
|
||||
#define MLIBC_POSIX_SIGNAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bits/ansi/time_t.h>
|
||||
#include <bits/ansi/timespec.h>
|
||||
#include <bits/posix/pthread_t.h>
|
||||
#include <bits/sigset_t.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <mlibc-config.h>
|
||||
|
||||
#define FPE_INTDIV 1 /* integer divide by zero */
|
||||
#define FPE_INTOVF 2 /* integer overflow */
|
||||
#define FPE_FLTDIV 3 /* floating point divide by zero */
|
||||
#define FPE_FLTOVF 4 /* floating point overflow */
|
||||
#define FPE_FLTUND 5 /* floating point underflow */
|
||||
#define FPE_FLTRES 6 /* floating point inexact result */
|
||||
#define FPE_FLTINV 7 /* floating point invalid operation */
|
||||
#define FPE_FLTSUB 8 /* subscript out of range */
|
||||
|
||||
#define TRAP_BRKPT 1 /* process breakpoint */
|
||||
#define TRAP_TRACE 2 /* process trace trap */
|
||||
|
||||
#if defined(__x86_64__)
|
||||
/* Start Glibc stuff */
|
||||
|
||||
struct _libc_fpxreg {
|
||||
unsigned short int significand[4];
|
||||
unsigned short int exponent;
|
||||
unsigned short int __glibc_reserved1[3];
|
||||
};
|
||||
|
||||
struct _libc_xmmreg {
|
||||
uint32_t element[4];
|
||||
};
|
||||
|
||||
struct _libc_fpstate {
|
||||
uint16_t cwd;
|
||||
int16_t swd;
|
||||
uint16_t ftw;
|
||||
uint16_t fop;
|
||||
uint64_t rip;
|
||||
uint64_t dp;
|
||||
uint32_t mxcsr;
|
||||
uint32_t mxcr_mask;
|
||||
struct _libc_fpxreg _st[8];
|
||||
struct _libc_xmmreg _xmm[16];
|
||||
uint32_t __glibc_reserved1[24];
|
||||
};
|
||||
|
||||
typedef struct _libc_fpstate *fpregset_t;
|
||||
/* End Glibc stuff */
|
||||
|
||||
typedef unsigned long int greg_t;
|
||||
#endif
|
||||
|
||||
#define FPE_INTDIV 1 /* integer divide by zero */
|
||||
#define FPE_INTOVF 2 /* integer overflow */
|
||||
#define FPE_FLTDIV 3 /* floating point divide by zero */
|
||||
#define FPE_FLTOVF 4 /* floating point overflow */
|
||||
#define FPE_FLTUND 5 /* floating point underflow */
|
||||
#define FPE_FLTRES 6 /* floating point inexact result */
|
||||
#define FPE_FLTINV 7 /* floating point invalid operation */
|
||||
#define FPE_FLTSUB 8 /* subscript out of range */
|
||||
|
||||
#define TRAP_BRKPT 1 /* process breakpoint */
|
||||
#define TRAP_TRACE 2 /* process trace trap */
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
/* functions to block / wait for signals */
|
||||
int sigsuspend(const sigset_t *__sigmask);
|
||||
int sigprocmask(int __how, const sigset_t *__restrict __sigmask, sigset_t *__restrict __oldmask);
|
||||
|
||||
int pthread_sigmask(int __how, const sigset_t *__restrict __sigmask, sigset_t *__restrict __oldmask);
|
||||
int pthread_kill(pthread_t __thrd, int __sig);
|
||||
|
||||
/* functions to handle signals */
|
||||
int sigaction(int __signum, const struct sigaction *__restrict __act, struct sigaction *__restrict __oldact);
|
||||
int sigpending(sigset_t *__set);
|
||||
|
||||
int siginterrupt(int __sig, int __flag);
|
||||
|
||||
int sigaltstack(const stack_t *__restrict __ss, stack_t *__restrict __oss);
|
||||
|
||||
/* functions to raise signals */
|
||||
int kill(pid_t __pid, int __number);
|
||||
int killpg(int __pgrp, int __sig);
|
||||
|
||||
int sigtimedwait(const sigset_t *__restrict __set, siginfo_t *__restrict __info, const struct timespec *__restrict __timeout);
|
||||
int sigwait(const sigset_t *__restrict __set, int *__restrict __sig);
|
||||
int sigwaitinfo(const sigset_t *__restrict __set, siginfo_t *__restrict __info);
|
||||
|
||||
/* Glibc extension */
|
||||
#if __MLIBC_GLIBC_OPTION
|
||||
int sigisemptyset(const sigset_t *__set);
|
||||
#endif /* __MLIBC_GLIBC_OPTION */
|
||||
|
||||
int sigqueue(pid_t __pid, int __sig, const union sigval __value);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_POSIX_SIGNAL_H */
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
#ifndef MLIBC_POSIX_STDIO_H
|
||||
#define MLIBC_POSIX_STDIO_H
|
||||
|
||||
#include <bits/off_t.h>
|
||||
#include <bits/size_t.h>
|
||||
#include <bits/ssize_t.h>
|
||||
#include <bits/file.h>
|
||||
|
||||
/* MISSING: var_list */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define P_tmpdir "/tmp"
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int fileno(FILE *__file);
|
||||
FILE *fdopen(int __fd, const char *__mode);
|
||||
|
||||
FILE *fmemopen(void *__restrict __buf, size_t __size, const char *__restrict __mode);
|
||||
int pclose(FILE *__file);
|
||||
FILE *popen(const char *__command, const char *__type);
|
||||
FILE *open_memstream(char **__buf, size_t *__sizeloc);
|
||||
|
||||
int fseeko(FILE *__stream, off_t __offset, int __whence);
|
||||
int fseeko64(FILE *__stream, off64_t __offset, int __whence);
|
||||
off_t ftello(FILE *__stream);
|
||||
off64_t ftello64(FILE *__stream);
|
||||
|
||||
__attribute__((format(__printf__, 2, 3))) int dprintf(int __fd, const char *__format, ...);
|
||||
__attribute__((format(__printf__, 2, 0)))
|
||||
int vdprintf(int __fd, const char *__format, __builtin_va_list __args);
|
||||
|
||||
char *fgetln(FILE *__stream, size_t *__size);
|
||||
|
||||
char *tempnam(const char *__dir, const char *__pfx);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#define RENAME_EXCHANGE (1 << 1)
|
||||
|
||||
/* GNU extensions */
|
||||
typedef ssize_t (cookie_read_function_t)(void *__cookie, char *__buffer, size_t __size);
|
||||
typedef ssize_t (cookie_write_function_t)(void *__cookie, const char *__buffer, size_t __size);
|
||||
typedef int (cookie_seek_function_t)(void *__cookie, off_t *, int);
|
||||
typedef int (cookie_close_function_t)(void *__cookie);
|
||||
|
||||
typedef struct _IO_cookie_io_functions_t {
|
||||
cookie_read_function_t *read;
|
||||
cookie_write_function_t *write;
|
||||
cookie_seek_function_t *seek;
|
||||
cookie_close_function_t *close;
|
||||
} cookie_io_functions_t;
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
#if defined(_GNU_SOURCE)
|
||||
|
||||
FILE *fopencookie(void *__restrict __cookie, const char *__restrict __mode, cookie_io_functions_t __io_funcs);
|
||||
|
||||
#endif /* defined(_GNU_SOURCE) */
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* MISSING: various functions and macros */
|
||||
|
||||
#endif /* MLIBC_POSIX_STDIO_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
|
||||
#ifndef MLIBC_POSIX_STDLIB_H
|
||||
#define MLIBC_POSIX_STDLIB_H
|
||||
|
||||
#include <bits/posix/locale_t.h>
|
||||
#include <bits/size_t.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
long random(void);
|
||||
double drand48(void);
|
||||
double erand48(unsigned short __s[3]);
|
||||
unsigned short *seed48(unsigned short __s[3]);
|
||||
void srand48(long int __seed);
|
||||
long int mrand48(void);
|
||||
long jrand48(unsigned short __s[3]);
|
||||
char *initstate(unsigned int __seed, char *__state, size_t __size);
|
||||
char *setstate(char *__state);
|
||||
void srandom(unsigned int __seed);
|
||||
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* Environment. */
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
|
||||
int putenv(char *__string);
|
||||
int setenv(const char *__name, const char *__value, int __overwrite);
|
||||
int unsetenv(const char *__name);
|
||||
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* Path handling. */
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
|
||||
int mkstemp(char *__pattern);
|
||||
int mkstemps(char *__pattern, int __suffixlen);
|
||||
int mkostemp(char *__pattern, int __flags);
|
||||
int mkostemps(char *__pattern, int __suffixlen, int __flags);
|
||||
char *mkdtemp(char *__path);
|
||||
|
||||
char *realpath(const char *__restrict __path, char *__restrict __out);
|
||||
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* Pseudoterminals */
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
|
||||
int posix_openpt(int __flags);
|
||||
int grantpt(int __fd);
|
||||
int unlockpt(int __fd);
|
||||
char *ptsname(int __fd);
|
||||
int ptsname_r(int __fd, char *__buf, size_t __len);
|
||||
|
||||
double strtod_l(const char *__restrict__ __nptr, char ** __restrict__ __endptr, locale_t __loc);
|
||||
long double strtold_l(const char *__restrict__ __nptr, char ** __restrict__ __endptr, locale_t __loc);
|
||||
float strtof_l(const char *__restrict __string, char **__restrict __end, locale_t __loc);
|
||||
|
||||
int getsubopt(char **__restrict__ __optionp, char *const *__restrict__ __tokens, char **__restrict__ __valuep);
|
||||
|
||||
/* GNU extension */
|
||||
char *secure_getenv(const char *__name);
|
||||
char *canonicalize_file_name(const char *__name);
|
||||
|
||||
/* BSD extension */
|
||||
void *reallocarray(void *__ptr, size_t __count, size_t __size);
|
||||
|
||||
int clearenv(void);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_POSIX_STDLIB_H */
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
|
||||
#ifndef MLIBC_POSIX_STRING_H
|
||||
#define MLIBC_POSIX_STRING_H
|
||||
|
||||
#include <alloca.h>
|
||||
#include <bits/posix/locale_t.h>
|
||||
#include <bits/size_t.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
char *strdup(const char *__string);
|
||||
char *strndup(const char *__string, size_t __max_size);
|
||||
size_t strnlen(const char *__s, size_t __max_size);
|
||||
char *strtok_r(char *__restrict __s, const char *__restrict __delim, char **__restrict __ptr);
|
||||
char *strsep(char **__stringp, const char *__delim);
|
||||
char *strsignal(int __sig);
|
||||
char *stpcpy(char *__restrict __dest, const char *__restrict __src);
|
||||
char *stpncpy(char *__restrict __dest, const char *__restrict __src, size_t __n);
|
||||
void *memccpy(void *__restrict __dest, const void *__restrict __src, int __c, size_t __n);
|
||||
|
||||
int strcoll_l(const char *__s1, const char *__s2, locale_t __locale);
|
||||
|
||||
char *strerror_l(int __errnum, locale_t __locale);
|
||||
|
||||
/* GNU extensions. */
|
||||
#if defined(_GNU_SOURCE)
|
||||
char *strcasestr(const char *__s1, const char *__s2);
|
||||
#define strdupa(x) ({ \
|
||||
const char *__str = (x); \
|
||||
size_t __len = strlen(__str) + 1; \
|
||||
char *__buf = alloca(__len); \
|
||||
(char *) memcpy(__buf, __str, __len); \
|
||||
})
|
||||
#define strndupa(x, y) ({ \
|
||||
const char *__str = (x); \
|
||||
size_t __len = strnlen(__str, (y)) + 1; \
|
||||
char *__buf = alloca(__len); \
|
||||
__buf[__len - 1] = '\0'; \
|
||||
(char *) memcpy(__buf, __str, __len - 1); \
|
||||
})
|
||||
void *memrchr(const void *__m, int __c, size_t __n);
|
||||
#endif /* defined(_GNU_SOURCE) */
|
||||
|
||||
/* BSD extensions */
|
||||
size_t strlcpy(char *__d, const char *__s, size_t __n);
|
||||
size_t strlcat(char *__d, const char *__s, size_t __n);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_POSIX_STRING_H */
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef MLIBC_POSIX_TIME_H
|
||||
#define MLIBC_POSIX_TIME_H
|
||||
|
||||
#include <abi-bits/clockid_t.h>
|
||||
#include <abi-bits/sigevent.h>
|
||||
#include <bits/ansi/timespec.h>
|
||||
#include <bits/posix/timer_t.h>
|
||||
#include <bits/posix/timeval.h>
|
||||
|
||||
#define TIMER_ABSTIME 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct itimerspec {
|
||||
struct timespec it_interval;
|
||||
struct timespec it_value;
|
||||
};
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int timer_getoverrun(timer_t __timerid);
|
||||
|
||||
int utimes(const char *__filename, const struct timeval __tv[2]);
|
||||
|
||||
/* Not standardized, Linux and BSDs have it */
|
||||
int futimes(int __fd, const struct timeval __tv[2]);
|
||||
int lutimes(const char *__filename, const struct timeval __tv[2]);
|
||||
|
||||
int timer_create(clockid_t __clockid, struct sigevent *__restrict __sevp, timer_t *__restrict __timerid);
|
||||
int timer_settime(timer_t __timerid, int __flags, const struct itimerspec *__restrict __new_value,
|
||||
struct itimerspec *__restrict __old_value);
|
||||
int timer_gettime(timer_t __timerid, struct itimerspec *__curr_value);
|
||||
int timer_delete(timer_t __timerid);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_POSIX_TIME_H */
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef _POSIX_WCTYPE_H
|
||||
#define _POSIX_WCTYPE_H
|
||||
|
||||
#include <bits/posix/locale_t.h>
|
||||
#include <bits/wint_t.h>
|
||||
#include <bits/wctype_t.h>
|
||||
#include <bits/wctrans_t.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
int iswalnum_l(wint_t __wc, locale_t __loc);
|
||||
int iswblank_l(wint_t __wc, locale_t __loc);
|
||||
int iswcntrl_l(wint_t __wc, locale_t __loc);
|
||||
int iswdigit_l(wint_t __wc, locale_t __loc);
|
||||
int iswgraph_l(wint_t __wc, locale_t __loc);
|
||||
int iswlower_l(wint_t __wc, locale_t __loc);
|
||||
int iswprint_l(wint_t __wc, locale_t __loc);
|
||||
int iswpunct_l(wint_t __wc, locale_t __loc);
|
||||
int iswspace_l(wint_t __wc, locale_t __loc);
|
||||
int iswupper_l(wint_t __wc, locale_t __loc);
|
||||
int iswxdigit_l(wint_t __wc, locale_t __loc);
|
||||
int iswalpha_l(wint_t __wc, locale_t __loc);
|
||||
|
||||
wctype_t wctype_l(const char *__string, locale_t __loc);
|
||||
int iswctype_l(wint_t __wc, wctype_t __type, locale_t __loc);
|
||||
|
||||
wint_t towlower_l(wint_t __wc, locale_t __loc);
|
||||
wint_t towupper_l(wint_t __wc, locale_t __loc);
|
||||
|
||||
wctrans_t wctrans_l(const char *__string, locale_t __loc);
|
||||
wint_t towctrans_l(wint_t __wc, wctrans_t __trans, locale_t __loc);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _POSIX_WCTYPE_H */
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef _MLIBC_BITS_PTHREAD_T_HPP
|
||||
#define _MLIBC_BITS_PTHREAD_T_HPP
|
||||
|
||||
#include <bits/threads.h>
|
||||
|
||||
typedef struct __mlibc_thread_data *pthread_t;
|
||||
|
||||
#endif /* _MLIBC_BITS_PTHREAD_T_HPP */
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef MLIBC_STAT_H
|
||||
#define MLIBC_STAT_H
|
||||
|
||||
#include <abi-bits/stat.h>
|
||||
|
||||
/* Used by utimensat and friends */
|
||||
#define UTIME_NOW ((1l << 30) - 1l)
|
||||
#define UTIME_OMIT ((1l << 30) - 2l)
|
||||
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
|
||||
/* POSIX compatibility macros */
|
||||
#define st_atime st_atim.tv_sec
|
||||
#define st_mtime st_mtim.tv_sec
|
||||
#define st_ctime st_ctim.tv_sec
|
||||
|
||||
#endif /* MLIBC_STAT_H */
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef _MLIBC_TIMER_T_H
|
||||
#define _MLIBC_TIMER_T_H
|
||||
|
||||
typedef void * timer_t;
|
||||
|
||||
#endif /* _MLIBC_TIMER_T_H */
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef MLIBC_TIMEVAL_H
|
||||
#define MLIBC_TIMEVAL_H
|
||||
|
||||
#include <bits/ansi/time_t.h>
|
||||
#include <abi-bits/suseconds_t.h>
|
||||
|
||||
struct timeval {
|
||||
time_t tv_sec;
|
||||
suseconds_t tv_usec;
|
||||
};
|
||||
|
||||
#endif /* MLIBC_TIMEVAL_H */
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef _MLIBC_INTERNAL_SEARCH_H
|
||||
#define _MLIBC_INTERNAL_SEARCH_H
|
||||
|
||||
#include <bits/size_t.h>
|
||||
|
||||
typedef enum {
|
||||
FIND,
|
||||
ENTER
|
||||
} ACTION;
|
||||
|
||||
typedef struct entry {
|
||||
char *key;
|
||||
void *data;
|
||||
} ENTRY;
|
||||
|
||||
struct _ENTRY;
|
||||
|
||||
struct hsearch_data {
|
||||
struct _ENTRY *table;
|
||||
unsigned int size;
|
||||
unsigned int filled;
|
||||
};
|
||||
|
||||
#endif /* _MLIBC_INTERNAL_SEARCH_H */
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef MLIBC_BITS_SIGSET_T_H
|
||||
#define MLIBC_BITS_SIGSET_T_H
|
||||
|
||||
#include <abi-bits/signal.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
/* functions to manage sigset_t */
|
||||
int sigemptyset(sigset_t *__sigset);
|
||||
int sigfillset(sigset_t *__sigset);
|
||||
int sigaddset(sigset_t *__sigset, int __sig);
|
||||
int sigdelset(sigset_t *__sigset, int __sig);
|
||||
int sigismember(const sigset_t *__sigset, int __sig);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*MLIBC_BITS_SIGSET_T_H */
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef MLIBC_SIZE_T_H
|
||||
#define MLIBC_SIZE_T_H
|
||||
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
|
||||
#endif /* MLIBC_SIZE_T_H */
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
#ifndef MLIBC_SSIZE_T_H
|
||||
#define MLIBC_SSIZE_T_H
|
||||
|
||||
/* TODO: use ptrdiff_t instead? */
|
||||
#if __UINTPTR_MAX__ == __UINT64_MAX__
|
||||
typedef long ssize_t;
|
||||
#elif __UINTPTR_MAX__ == __UINT32_MAX__
|
||||
typedef int ssize_t;
|
||||
#else
|
||||
#error "unsupported architecture"
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_SSIZE_T_H */
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#ifndef _INTERNAL_THREADS_H
|
||||
#define _INTERNAL_THREADS_H
|
||||
|
||||
#include <abi-bits/clockid_t.h>
|
||||
#include <bits/size_t.h>
|
||||
#include <bits/cpu_set.h>
|
||||
#include <bits/sigset_t.h>
|
||||
|
||||
/* values for pthread_attr_{get,set}detachstate(). */
|
||||
#define __MLIBC_THREAD_CREATE_JOINABLE 0
|
||||
#define __MLIBC_THREAD_CREATE_DETACHED 1
|
||||
|
||||
/* values for pthread_mutexattr_{get,set}type(). */
|
||||
#define __MLIBC_THREAD_MUTEX_DEFAULT 0
|
||||
#define __MLIBC_THREAD_MUTEX_NORMAL 0
|
||||
#define __MLIBC_THREAD_MUTEX_ERRORCHECK 1
|
||||
#define __MLIBC_THREAD_MUTEX_RECURSIVE 2
|
||||
|
||||
/* values for pthread_mutexattr_{get,set}pshared(). */
|
||||
#define __MLIBC_THREAD_PROCESS_PRIVATE 0
|
||||
#define __MLIBC_THREAD_PROCESS_SHARED 1
|
||||
|
||||
/* values for pthread_mutexattr_{get,set}robust(). */
|
||||
#define __MLIBC_THREAD_MUTEX_STALLED 0
|
||||
#define __MLIBC_THREAD_MUTEX_ROBUST 1
|
||||
|
||||
/* Values for pthread_mutexattr_{get,set}protocol() */
|
||||
#define __MLIBC_THREAD_PRIO_NONE 0
|
||||
#define __MLIBC_THREAD_PRIO_INHERIT 1
|
||||
#define __MLIBC_THREAD_PRIO_PROTECT 2
|
||||
|
||||
#define __MLIBC_THREAD_MUTEX_INITIALIZER {0, 0, 0, 0}
|
||||
|
||||
struct sched_param {
|
||||
int sched_priority;
|
||||
};
|
||||
|
||||
struct __mlibc_thread_data;
|
||||
|
||||
struct __mlibc_threadattr {
|
||||
size_t __mlibc_guardsize;
|
||||
size_t __mlibc_stacksize;
|
||||
void *__mlibc_stackaddr;
|
||||
int __mlibc_detachstate;
|
||||
int __mlibc_scope;
|
||||
int __mlibc_inheritsched;
|
||||
struct sched_param __mlibc_schedparam;
|
||||
int __mlibc_schedpolicy;
|
||||
cpu_set_t *__mlibc_cpuset;
|
||||
size_t __mlibc_cpusetsize;
|
||||
sigset_t __mlibc_sigmask;
|
||||
int __mlibc_sigmaskset;
|
||||
};
|
||||
|
||||
struct __mlibc_mutex {
|
||||
unsigned int __mlibc_state;
|
||||
unsigned int __mlibc_recursion;
|
||||
unsigned int __mlibc_flags;
|
||||
int __mlibc_prioceiling;
|
||||
};
|
||||
|
||||
struct __mlibc_mutexattr {
|
||||
int __mlibc_type;
|
||||
int __mlibc_robust;
|
||||
int __mlibc_protocol;
|
||||
int __mlibc_pshared;
|
||||
int __mlibc_prioceiling;
|
||||
};
|
||||
|
||||
struct __mlibc_cond {
|
||||
unsigned int __mlibc_seq;
|
||||
unsigned int __mlibc_flags;
|
||||
clockid_t __mlibc_clock;
|
||||
};
|
||||
|
||||
struct __mlibc_condattr {
|
||||
int __mlibc_pshared;
|
||||
clockid_t __mlibc_clock;
|
||||
};
|
||||
|
||||
#endif /* _INTERNAL_THREADS_H */
|
||||
@@ -0,0 +1,408 @@
|
||||
#ifndef _MLIBC_INTERNAL_TYPES_H
|
||||
#define _MLIBC_INTERNAL_TYPES_H
|
||||
|
||||
typedef __UINT8_TYPE__ __mlibc_uint8;
|
||||
typedef __UINT16_TYPE__ __mlibc_uint16;
|
||||
typedef __UINT32_TYPE__ __mlibc_uint32;
|
||||
typedef __UINT64_TYPE__ __mlibc_uint64;
|
||||
|
||||
typedef __INT8_TYPE__ __mlibc_int8;
|
||||
typedef __INT16_TYPE__ __mlibc_int16;
|
||||
typedef __INT32_TYPE__ __mlibc_int32;
|
||||
typedef __INT64_TYPE__ __mlibc_int64;
|
||||
|
||||
/* Clang and GCC have different mechanisms for INT32_C and friends. */
|
||||
#ifdef __clang__
|
||||
# define __MLIBC_C_EXPAND_JOIN(x, suffix) x ## suffix
|
||||
# define __MLIBC_C_JOIN(x, suffix) __MLIBC_C_EXPAND_JOIN(x, suffix)
|
||||
|
||||
# define __MLIBC_INT8_C(x) __MLIBC_C_JOIN(x, __INT8_C_SUFFIX__)
|
||||
# define __MLIBC_INT16_C(x) __MLIBC_C_JOIN(x, __INT16_C_SUFFIX__)
|
||||
# define __MLIBC_INT32_C(x) __MLIBC_C_JOIN(x, __INT32_C_SUFFIX__)
|
||||
# define __MLIBC_INT64_C(x) __MLIBC_C_JOIN(x, __INT64_C_SUFFIX__)
|
||||
|
||||
# define __MLIBC_UINT8_C(x) __MLIBC_C_JOIN(x, __UINT8_C_SUFFIX__)
|
||||
# define __MLIBC_UINT16_C(x) __MLIBC_C_JOIN(x, __UINT16_C_SUFFIX__)
|
||||
# define __MLIBC_UINT32_C(x) __MLIBC_C_JOIN(x, __UINT32_C_SUFFIX__)
|
||||
# define __MLIBC_UINT64_C(x) __MLIBC_C_JOIN(x, __UINT64_C_SUFFIX__)
|
||||
|
||||
# define __MLIBC_INTMAX_C(x) __MLIBC_C_JOIN(x, __INTMAX_C_SUFFIX__)
|
||||
# define __MLIBC_UINTMAX_C(x) __MLIBC_C_JOIN(x, __UINTMAX_C_SUFFIX__)
|
||||
#else
|
||||
# define __MLIBC_INT8_C(x) __INT8_C(x)
|
||||
# define __MLIBC_INT16_C(x) __INT16_C(x)
|
||||
# define __MLIBC_INT32_C(x) __INT32_C(x)
|
||||
# define __MLIBC_INT64_C(x) __INT64_C(x)
|
||||
|
||||
# define __MLIBC_UINT8_C(x) __UINT8_C(x)
|
||||
# define __MLIBC_UINT16_C(x) __UINT16_C(x)
|
||||
# define __MLIBC_UINT32_C(x) __UINT32_C(x)
|
||||
# define __MLIBC_UINT64_C(x) __UINT64_C(x)
|
||||
|
||||
# define __MLIBC_INTMAX_C(x) __INTMAX_C(x)
|
||||
# define __MLIBC_UINTMAX_C(x) __UINTMAX_C(x)
|
||||
#endif
|
||||
|
||||
#define __MLIBC_INT8_MAX __INT8_MAX__
|
||||
#define __MLIBC_INT16_MAX __INT16_MAX__
|
||||
#define __MLIBC_INT32_MAX __INT32_MAX__
|
||||
#define __MLIBC_INT64_MAX __INT64_MAX__
|
||||
|
||||
#define __MLIBC_INT8_MIN (-__MLIBC_INT8_MAX - 1)
|
||||
#define __MLIBC_INT16_MIN (-__MLIBC_INT16_MAX - 1)
|
||||
#define __MLIBC_INT32_MIN (-__MLIBC_INT32_MAX - 1)
|
||||
#define __MLIBC_INT64_MIN (-__MLIBC_INT64_MAX - 1)
|
||||
|
||||
#define __MLIBC_UINT8_MAX __UINT8_MAX__
|
||||
#define __MLIBC_UINT16_MAX __UINT16_MAX__
|
||||
#define __MLIBC_UINT32_MAX __UINT32_MAX__
|
||||
#define __MLIBC_UINT64_MAX __UINT64_MAX__
|
||||
|
||||
/* Fast types (signed). */
|
||||
|
||||
#if defined (__i386__)
|
||||
|
||||
typedef __mlibc_int8 __mlibc_int_fast8;
|
||||
#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
|
||||
#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
|
||||
#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
|
||||
|
||||
typedef __mlibc_int32 __mlibc_int_fast16;
|
||||
#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT32_C(x)
|
||||
#define __MLIBC_INT_FAST16_MAX __MLIBC_INT32_MAX
|
||||
#define __MLIBC_INT_FAST16_MIN __MLIBC_INT32_MIN
|
||||
|
||||
typedef __mlibc_int32 __mlibc_int_fast32;
|
||||
#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT32_C(x)
|
||||
#define __MLIBC_INT_FAST32_MAX __MLIBC_INT32_MAX
|
||||
#define __MLIBC_INT_FAST32_MIN __MLIBC_INT32_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast64;
|
||||
#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
|
||||
|
||||
#elif defined (__x86_64__)
|
||||
|
||||
typedef __mlibc_int8 __mlibc_int_fast8;
|
||||
#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
|
||||
#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
|
||||
#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast16;
|
||||
#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST16_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST16_MIN __MLIBC_INT64_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast32;
|
||||
#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST32_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST32_MIN __MLIBC_INT64_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast64;
|
||||
#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
|
||||
|
||||
#elif defined (__aarch64__)
|
||||
|
||||
typedef __mlibc_int8 __mlibc_int_fast8;
|
||||
#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
|
||||
#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
|
||||
#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast16;
|
||||
#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST16_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST16_MIN __MLIBC_INT64_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast32;
|
||||
#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST32_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST32_MIN __MLIBC_INT64_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast64;
|
||||
#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
|
||||
|
||||
#elif defined (__riscv) && __riscv_xlen == 64
|
||||
|
||||
typedef __mlibc_int8 __mlibc_int_fast8;
|
||||
#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
|
||||
#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
|
||||
#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast16;
|
||||
#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST16_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST16_MIN __MLIBC_INT64_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast32;
|
||||
#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST32_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST32_MIN __MLIBC_INT64_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast64;
|
||||
#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
|
||||
|
||||
#elif defined (__m68k__)
|
||||
|
||||
typedef __mlibc_int8 __mlibc_int_fast8;
|
||||
#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
|
||||
#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
|
||||
#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
|
||||
|
||||
typedef __mlibc_int32 __mlibc_int_fast16;
|
||||
#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT16_C(x)
|
||||
#define __MLIBC_INT_FAST16_MAX __MLIBC_INT16_MAX
|
||||
#define __MLIBC_INT_FAST16_MIN __MLIBC_INT16_MIN
|
||||
|
||||
typedef __mlibc_int32 __mlibc_int_fast32;
|
||||
#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT32_C(x)
|
||||
#define __MLIBC_INT_FAST32_MAX __MLIBC_INT32_MAX
|
||||
#define __MLIBC_INT_FAST32_MIN __MLIBC_INT32_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast64;
|
||||
#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
|
||||
|
||||
#elif defined (__loongarch64)
|
||||
|
||||
typedef __mlibc_int8 __mlibc_int_fast8;
|
||||
#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
|
||||
#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
|
||||
#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast16;
|
||||
#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST16_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST16_MIN __MLIBC_INT64_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast32;
|
||||
#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST32_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST32_MIN __MLIBC_INT64_MIN
|
||||
|
||||
typedef __mlibc_int64 __mlibc_int_fast64;
|
||||
#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
|
||||
#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
|
||||
#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
|
||||
|
||||
#else
|
||||
# error "Missing architecture specific code"
|
||||
#endif
|
||||
|
||||
/* Fast types (unsigned). */
|
||||
|
||||
#if defined (__i386__)
|
||||
|
||||
typedef __mlibc_uint8 __mlibc_uint_fast8;
|
||||
#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
|
||||
#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
|
||||
#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
|
||||
|
||||
typedef __mlibc_uint32 __mlibc_uint_fast16;
|
||||
#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT32_C(x)
|
||||
#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT32_MAX
|
||||
#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT32_MIN
|
||||
|
||||
typedef __mlibc_uint32 __mlibc_uint_fast32;
|
||||
#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT32_C(x)
|
||||
#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT32_MAX
|
||||
#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT32_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast64;
|
||||
#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
#elif defined (__x86_64__)
|
||||
|
||||
typedef __mlibc_uint8 __mlibc_uint_fast8;
|
||||
#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
|
||||
#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
|
||||
#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast16;
|
||||
#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast32;
|
||||
#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast64;
|
||||
#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
#elif defined (__aarch64__)
|
||||
|
||||
typedef __mlibc_uint8 __mlibc_uint_fast8;
|
||||
#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
|
||||
#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
|
||||
#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast16;
|
||||
#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast32;
|
||||
#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast64;
|
||||
#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
#elif defined (__riscv) && __riscv_xlen == 64
|
||||
|
||||
typedef __mlibc_uint8 __mlibc_uint_fast8;
|
||||
#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
|
||||
#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
|
||||
#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast16;
|
||||
#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast32;
|
||||
#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast64;
|
||||
#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
#elif defined (__m68k__)
|
||||
|
||||
typedef __mlibc_uint8 __mlibc_uint_fast8;
|
||||
#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
|
||||
#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
|
||||
#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
|
||||
|
||||
typedef __mlibc_uint32 __mlibc_uint_fast16;
|
||||
#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT16_C(x)
|
||||
#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT16_MAX
|
||||
#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT16_MIN
|
||||
|
||||
typedef __mlibc_uint32 __mlibc_uint_fast32;
|
||||
#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT32_C(x)
|
||||
#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT32_MAX
|
||||
#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT32_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast64;
|
||||
#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
#elif defined (__loongarch64)
|
||||
|
||||
typedef __mlibc_uint8 __mlibc_uint_fast8;
|
||||
#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
|
||||
#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
|
||||
#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast16;
|
||||
#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast32;
|
||||
#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
typedef __mlibc_uint64 __mlibc_uint_fast64;
|
||||
#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
|
||||
#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
|
||||
#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
|
||||
|
||||
#else
|
||||
# error "Missing architecture specific code"
|
||||
#endif
|
||||
|
||||
/* Special types. */
|
||||
|
||||
typedef __INTMAX_TYPE__ __mlibc_intmax;
|
||||
typedef __INTPTR_TYPE__ __mlibc_intptr;
|
||||
typedef __PTRDIFF_TYPE__ __mlibc_ptrdiff;
|
||||
#define __MLIBC_INTMAX_MAX __INTMAX_MAX__
|
||||
#define __MLIBC_INTMAX_MIN (-__INTMAX_MAX__ - 1)
|
||||
#define __MLIBC_INTPTR_MAX __INTPTR_MAX__
|
||||
#define __MLIBC_INTPTR_MIN (-__INTPTR_MAX__ - 1)
|
||||
#define __MLIBC_PTRDIFF_MAX __PTRDIFF_MAX__
|
||||
#define __MLIBC_PTRDIFF_MIN (-__PTRDIFF_MAX__ - 1)
|
||||
|
||||
typedef __UINTMAX_TYPE__ __mlibc_uintmax;
|
||||
typedef __UINTPTR_TYPE__ __mlibc_uintptr;
|
||||
typedef __SIZE_TYPE__ __mlibc_size;
|
||||
#define __MLIBC_UINTMAX_MAX __UINTMAX_MAX__
|
||||
#define __MLIBC_UINTPTR_MAX __UINTPTR_MAX__
|
||||
#define __MLIBC_SIZE_MAX __SIZE_MAX__
|
||||
|
||||
/* Other limits. */
|
||||
|
||||
#define __MLIBC_WCHAR_MAX __WCHAR_MAX__
|
||||
#define __MLIBC_WCHAR_MIN __WCHAR_MIN__
|
||||
|
||||
#define __MLIBC_WINT_MAX __WINT_MAX__
|
||||
#define __MLIBC_WINT_MIN __WINT_MIN__
|
||||
|
||||
#define __MLIBC_SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
|
||||
#define __MLIBC_SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__
|
||||
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
/* Sanity checking. Make sure that we agree with the compiler's ABI. */
|
||||
/* ---------------------------------------------------------------------------- */
|
||||
|
||||
#if defined(__cplusplus) && defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
|
||||
# define __MLIBC_STATIC_ASSERT(c, text) static_assert(c, text)
|
||||
#elif !defined(__cplusplus)
|
||||
/* _Static_assert is an extension in C89/C99. */
|
||||
# define __MLIBC_STATIC_ASSERT(c, text) __extension__ _Static_assert(c, text)
|
||||
#else
|
||||
# define __MLIBC_STATIC_ASSERT(c, text) extern int __static_assert_unavailable
|
||||
#endif
|
||||
|
||||
#define __MLIBC_CHECK_TYPE(T1, T2) __MLIBC_STATIC_ASSERT(sizeof(T1) == sizeof(T2),\
|
||||
#T1 " != " #T2)
|
||||
|
||||
/* Least-width. */
|
||||
__MLIBC_CHECK_TYPE(__mlibc_int8, __INT_LEAST8_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_int16, __INT_LEAST16_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_int32, __INT_LEAST32_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_int64, __INT_LEAST64_TYPE__);
|
||||
|
||||
__MLIBC_CHECK_TYPE(__mlibc_uint8, __UINT_LEAST8_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_uint16, __UINT_LEAST16_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_uint32, __UINT_LEAST32_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_uint64, __UINT_LEAST64_TYPE__);
|
||||
|
||||
/* Fast-width. */
|
||||
/* Unfortunately, GCC and Clang disagree about fast types. */
|
||||
#ifndef __clang__
|
||||
__MLIBC_CHECK_TYPE(__mlibc_int_fast8, __INT_FAST8_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_int_fast16, __INT_FAST16_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_int_fast32, __INT_FAST32_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_int_fast64, __INT_FAST64_TYPE__);
|
||||
|
||||
__MLIBC_CHECK_TYPE(__mlibc_uint_fast8, __UINT_FAST8_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_uint_fast16, __UINT_FAST16_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_uint_fast32, __UINT_FAST32_TYPE__);
|
||||
__MLIBC_CHECK_TYPE(__mlibc_uint_fast64, __UINT_FAST64_TYPE__);
|
||||
#endif
|
||||
|
||||
#endif /* _MLIBC_INTERNAL_TYPES_H */
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef MLIBC_WCHAR_H
|
||||
#define MLIBC_WCHAR_H
|
||||
|
||||
#include <bits/types.h>
|
||||
|
||||
#define WCHAR_MAX __MLIBC_WCHAR_MAX
|
||||
#define WCHAR_MIN __MLIBC_WCHAR_MIN
|
||||
|
||||
#endif /* MLIBC_WCHAR_H */
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
#ifndef MLIBC_WCHAR_T_H
|
||||
#define MLIBC_WCHAR_T_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
typedef __WCHAR_TYPE__ wchar_t;
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* MLIBC_WCHAR_T_H */
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef MLIBC_WCTRANS_T_H
|
||||
#define MLIBC_WCTRANS_T_H
|
||||
|
||||
typedef unsigned long wctrans_t;
|
||||
|
||||
#endif /* MLIBC_WCTRANS_T_H */
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef MLIBC_WCTYPE_T_H
|
||||
#define MLIBC_WCTYPE_T_H
|
||||
|
||||
typedef unsigned long wctype_t;
|
||||
|
||||
#endif /* MLIBC_WCTYPE_T_H */
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
#ifndef MLIBC_WINSIZE_H
|
||||
#define MLIBC_WINSIZE_H
|
||||
|
||||
struct winsize {
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
unsigned short ws_xpixel;
|
||||
unsigned short ws_ypixel;
|
||||
};
|
||||
|
||||
#endif /* MLIBC_WINSIZE_H */
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef MLIBC_WINT_T_H
|
||||
#define MLIBC_WINT_T_H
|
||||
|
||||
typedef __WINT_TYPE__ wint_t;
|
||||
|
||||
#endif /* MLIBC_WINT_T_H */
|
||||
Reference in New Issue
Block a user